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

Support missing namespace in parameter names in design_kw #163

Merged
merged 1 commit into from
Sep 16, 2020

Conversation

berland
Copy link
Collaborator

@berland berland commented Sep 4, 2020

First attempt at solving #59

Check first if the behaviour imposed by the added tests is what we want, then assess whether the code achieving it was sufficiently elegant (perhaps it was not..)

@ertomatic
Copy link
Collaborator

Can one of the admins verify this patch?

Copy link
Contributor

@markusdregi markusdregi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a fair approach and the tests seems adequate 👍 I would like to see an added test for logging if that is the expected behaviour and in addition I think the implementation of rm_genkw_prefix could be simplified a bit.

I'm supporting this direction

({"foo:bar": "value"}, {"bar": "value"}),
({"foo:bar": "value", "foo:com": "value2"}, {"bar": "value", "com": "value2"}),
({}, {}),
# Duplicates are dropped, a warning is logged.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any warning is logged here...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added extra duplicates warning.

@@ -116,3 +119,53 @@ def extract_key_value(parameters):
if errors:
raise ValueError("\n".join(errors))
return res


def rm_genkw_prefix(str_or_dict, ignoreprefixes="LOG10_"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I've misunderstood the type of str_or_dict will always be a dict on the first call, and then the string support is used internally on the keys afterwards. I think the implementation would be much cleaner if we utilised this assumption and hid the string-support within the function such that rm_genkw_prefix only accepts dicts of depth one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New implementation written - it got a lot better with only dict as input.

@berland berland force-pushed the gen_kw_handling branch 5 times, most recently from 6fcec8d to 5e6bac1 Compare September 14, 2020 13:20


def rm_genkw_prefix(paramsdict, ignoreprefixes="LOG10_"):
"""Remove anything before the first colon in a string, or remove
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc string still need an update, besides that it looks good 👍 Nice clean up of rm_genkw_prefix ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

rm_genkw_prefix is refactored and improved from fm_pyscal into
design_kw.

fm_pyscal will not any longer ignore a namespace
prefix in the interpolation parameter names, if the user actually
supplies a prefix (has probably never happened in practice yet)

Update docs for design_kw accordingly
Copy link
Contributor

@markusdregi markusdregi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants