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

issue with using property decorator #2

Open
tulay opened this issue Jul 21, 2021 · 0 comments
Open

issue with using property decorator #2

tulay opened this issue Jul 21, 2021 · 0 comments

Comments

@tulay
Copy link

tulay commented Jul 21, 2021

@kpe

We store and log our run configuration as Params.
When using property decorator, we noticed that changes to dependent variables are not reflected. Observe param_h values in the following example based on AnotherSubParams test class in https://github.com/kpe/py-params/blob/master/tests/test_subclassing.py

def test_param_change():
    asp = AnotherSubParams()
    print("Before modification of param_d")
    print(f"Printing instance:{asp}")
    print(f"Accessing param.d: {asp.param_d}")
    print(f"Accessing param.h: {asp.param_h}")
    asp.param_d = "FIND_ME"
    print("After modification of param_d: aD => FIND_ME")
    print(f"Printing instance: {asp}")
    print(f"Accessing param.d: {asp.param_d}")
    print(f"Accessing param.h: {asp.param_h}")
    print(f"Printing instance: {asp}")

generates

Before modification of param_d
Printing instance:{'param_a': 'SBBa_ASg_ASh_aDMSc_ASg_ASh_aD', 'param_b': 'b', 'param_c': 'MSc_ASg_ASh_aD', 'param_d': 'aD', 'param_e': 'aE', 'param_f': 'SBf', 'param_g': 'ASg_ASh_aD', 'param_h': 'ASh_aD', 'param_j': 'MSj'}
Accessing param.d: aD
Accessing param.h: ASh_aD
After modification of param_d: aD => FIND_ME
Printing instance: {'param_a': 'SBBa_ASg_ASh_aDMSc_ASg_ASh_aD', 'param_b': 'b', 'param_c': 'MSc_ASg_ASh_aD', 'param_d': 'FIND_ME', 'param_e': 'aE', 'param_f': 'SBf', 'param_g': 'ASg_ASh_aD', 'param_h': 'ASh_aD', 'param_j': 'MSj'}
Accessing param.d: FIND_ME
Accessing param.h: ASh_FIND_ME
Printing instance: {'param_a': 'SBBa_ASg_ASh_aDMSc_ASg_ASh_aD', 'param_b': 'b', 'param_c': 'MSc_ASg_ASh_aD', 'param_d': 'FIND_ME', 'param_e': 'aE', 'param_f': 'SBf', 'param_g': 'ASg_ASh_aD', 'param_h': 'ASh_aD', 'param_j': 'MSj'}
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

No branches or pull requests

1 participant