Skip to content

Commit

Permalink
Fixes bug where bounds weren't set for nominal
Browse files Browse the repository at this point in the history
  • Loading branch information
apbassett committed Nov 8, 2024
1 parent dc21437 commit b8b09ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 2 additions & 5 deletions howso/utilities/feature_attributes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,8 @@ def _process(self, # noqa: C901

if infer_bounds:
for feature_name in self.attributes:
# Don't infer bounds for manually-specified nominal features
if self.attributes[feature_name].get('type') == 'nominal':
continue
# Likewise, don't infer bounds for JSON/YAML features
elif any([
# Don't infer bounds for JSON/YAML features
if any([
self.attributes[feature_name].get('data_type') in ['json', 'yaml'],
features and features.get(feature_name, {}).get('data_type') in ['json', 'yaml']
]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,12 @@ def test_preset_feature_types(data, types, expected_types, is_valid):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
if is_valid:
features = infer_feature_attributes(data, types=types)
features = infer_feature_attributes(data, types=types, )
for feature_name, expected_type in expected_types.items():
# Make sure it is the correct type
assert features[feature_name]['type'] == expected_type
# All features in this test, including nominals, should have bounds (at the very least: `allow_null`)
assert 'allow_null' in features[feature_name].get('bounds', {}).keys()
else:
with pytest.raises(ValueError):
infer_feature_attributes(data, types=types)

0 comments on commit b8b09ea

Please sign in to comment.