Skip to content

issue with using property decorator #2

@tulay

Description

@tulay

@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'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions