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

Update parameter validation to treat the case where "of" is None #590

Merged
merged 5 commits into from
Jul 8, 2021
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
9 changes: 9 additions & 0 deletions gtda/homology/tests/test_simplicial.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ def test_wrp_params():
wrp.fit_transform(X_pc)


def test_wrp_metric_params():
def metric(x, y, **kwargs):
return np.linalg.norm(x - y)

metric_params = {"parameter": 0.}
wrp = WeightedRipsPersistence(metric=metric, metric_params=metric_params)
wrp.fit_transform(X_pc)


def test_wrp_not_fitted():
wrp = WeightedRipsPersistence()

Expand Down
5 changes: 4 additions & 1 deletion gtda/utils/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def _validate_params_single(_parameter, _reference, _name):
ref_type = _validate_params_single(parameter, reference, name)
if ref_type:
ref_of = reference.get('of', None)
if ref_type == dict:
if ref_of is None:
# if ref_of is None, the elements are not to be validated
continue
elif ref_type == dict:
_validate_params(parameter, ref_of, rec_name=name)
else: # List, tuple or ndarray type
for i, parameter_elem in enumerate(parameter):
Expand Down