Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAINT: changes for test failures from python 3.9 & pandas 2.* update #201

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion q2_feature_classifier/_skl.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def num_leaf_nodes(self) -> int:
{'__type__': 'feature_extraction.text.HashingVectorizer',
'analyzer': 'char_wb',
'n_features': 8192,
'ngram_range': [7, 7],
'ngram_range': (7, 7),
'alternate_sign': False}],
['classify',
{'__type__': 'custom.LowMemoryMultinomialNB',
Expand Down
4 changes: 4 additions & 0 deletions q2_feature_classifier/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ def default(self, obj):

def pipeline_from_spec(spec):
def as_steps(obj):
if 'ngram_range' in obj:
obj['ngram_range'] = tuple(obj['ngram_range'])
if '__type__' in obj:
klass = _load_class(obj['__type__'])
return klass(**{k: v for k, v in obj.items() if k != '__type__'})
Expand Down Expand Up @@ -332,6 +334,8 @@ def generic_fitter(reference_reads: DNAIterator,
kwargs[param] = json.loads(kwargs[param])
except (json.JSONDecodeError, TypeError):
pass
if param == 'feat_ext__ngram_range':
kwargs[param] = tuple(kwargs[param])
pipeline = pipeline_from_spec(spec)
pipeline.set_params(**kwargs)
if class_weight is not None:
Expand Down
4 changes: 2 additions & 2 deletions q2_feature_classifier/tests/test_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_populate_class_weight(self):
{'__type__': 'feature_extraction.text.HashingVectorizer',
'analyzer': 'char_wb',
'n_features': 8192,
'ngram_range': [8, 8],
'ngram_range': (8, 8),
'alternate_sign': False}],
['classify',
{'__type__': 'naive_bayes.GaussianNB'}]]
Expand Down Expand Up @@ -117,7 +117,7 @@ def test_class_weight(self):
{'__type__': 'feature_extraction.text.HashingVectorizer',
'analyzer': 'char_wb',
'n_features': 8192,
'ngram_range': [8, 8],
'ngram_range': (8, 8),
'alternate_sign': False}],
['classify',
{'__type__': 'linear_model.LogisticRegression'}]]
Expand Down
4 changes: 2 additions & 2 deletions q2_feature_classifier/tests/test_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_low_memory_multinomial_nb(self):
{'__type__': 'feature_extraction.text.HashingVectorizer',
'analyzer': 'char',
'n_features': 8192,
'ngram_range': [8, 8],
'ngram_range': (8, 8),
'alternate_sign': False}],
['classify',
{'__type__': 'custom.LowMemoryMultinomialNB',
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_chunked_hashing_vectorizer(self):

params = {'analyzer': 'char',
'n_features': 8192,
'ngram_range': [8, 8],
'ngram_range': (8, 8),
'alternate_sign': False}
hv = HashingVectorizer(**params)
unchunked = hv.fit_transform(X)
Expand Down
Loading