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

Check for changes to operator attributes when getting the schema #118

Merged
merged 1 commit into from Sep 2, 2020

Conversation

hdoupe
Copy link
Collaborator

@hdoupe hdoupe commented Sep 1, 2020

This fixes a bug that occurs when you update an operator attribute like array_first after creating the Parameters instance and then call dump. The "schema" object returned will not have the updated operators.

Before:

In [1]: from paramtools import Parameters

In [2]: class Params(Parameters):
   ...:     defaults = {"schema": {"operators": {"array_first": True}}}
   ...: 

In [3]: params = Params()

In [4]: params.array_first = False

In [5]: params.dump()
Out[5]: 
{'schema': {'labels': {},
  'operators': {'label_to_extend': None,
   'uses_extend_func': False,
   'array_first': True},                          # <=== this should be False!
  'additional_members': {}}}

After fix:

In [1]: from paramtools import Parameters

In [2]: class Params(Parameters):
   ...:     defaults = {"schema": {"operators": {"array_first": True}}}
   ...: 

In [3]: params = Params()

In [4]: params.array_first = False

In [5]: params.dump()
Out[5]: 
{'schema': {'additional_members': {},
  'operators': {'uses_extend_func': False,
   'array_first': False,                          # <=== this is False now.
   'label_to_extend': None},
  'labels': {}}}

@hdoupe hdoupe merged commit cb3a140 into master Sep 2, 2020
@hdoupe hdoupe deleted the update-operators2 branch September 2, 2020 12:35
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.

None yet

1 participant