Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 55bb801

Browse files
committed
model: simple: Split applicable check into two methods
Signed-off-by: John Andersen <[email protected]>
1 parent abe44a2 commit 55bb801

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

dffml/model/model.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,20 @@ def applicable_features(self, features):
205205

206206
def check_applicable_feature(self, feature):
207207
# Check the data datatype is in the list of supported data types
208-
if feature.dtype() not in self.DTYPES:
208+
self.check_feature_dtype(feature.dtype())
209+
# Check that length (dimensions) of feature is supported
210+
self.check_feature_length(feature.length())
211+
return True
212+
213+
def check_feature_dtype(self, dtype):
214+
if dtype not in self.DTYPES:
209215
msg = f"{self.__class__.__qualname__} only supports features "
210216
msg += f"with these data types: {self.DTYPES}"
211217
raise ValueError(msg)
218+
219+
def check_feature_length(self, length):
212220
# If SUPPORTED_LENGTHS is None then all lengths are supported
213-
if self.SUPPORTED_LENGTHS is None:
214-
return True
215-
# Check that length (dimensions) of feature is supported
216-
if feature.length() not in self.SUPPORTED_LENGTHS:
221+
if self.SUPPORTED_LENGTHS and length not in self.SUPPORTED_LENGTHS:
217222
msg = f"{self.__class__.__qualname__} only supports "
218223
msg += f"{self.SUPPORTED_LENGTHS} dimensional values"
219224
raise ValueError(msg)
220-
return True

0 commit comments

Comments
 (0)