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

feat: pre_trans for variable #112

Merged
merged 8 commits into from
Sep 18, 2023
Merged

feat: pre_trans for variable #112

merged 8 commits into from
Sep 18, 2023

Conversation

jiangyi15
Copy link
Owner

Add transform before read variables. We can set two variable to the same, and add transform for one variable to make the constrains of linear transform. For example,

constrains:
    var_equal: [[var_name, var_name2]]
    pre_trans:
         var_name2:
              model: linear
              k: 2.0
              b: 0.0

then var_name2 will be 2 * var_name.

@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

Patch coverage: 92.66% and project coverage change: +0.16% 🎉

Comparison is base (20ac860) 76.21% compared to head (cf340bb) 76.37%.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #112      +/-   ##
==========================================
+ Coverage   76.21%   76.37%   +0.16%     
==========================================
  Files         108      109       +1     
  Lines       15894    15995     +101     
  Branches     2981     2999      +18     
==========================================
+ Hits        12113    12216     +103     
+ Misses       3084     3079       -5     
- Partials      697      700       +3     
Flag Coverage Δ
unittests 76.37% <92.66%> (+0.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
tf_pwa/config_loader/config_loader.py 69.16% <88.57%> (+0.78%) ⬆️
tf_pwa/transform.py 91.42% <91.42%> (ø)
tf_pwa/variable.py 60.75% <94.73%> (+1.33%) ⬆️
tf_pwa/tests/test_variable.py 93.89% <100.00%> (+1.10%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Yinrui-Liu
Copy link
Collaborator

I agree it's worth adding pre-trans function. For var_equal, you can use VarsManager.set_same(). I think it might be better to show it in configuration file as

constrains:
    pre_trans:
         [var_name2, var_name]:
              model: linear
              k: 2.0
              b: 0.0

and var_equal will be first done implicitly inside pre_trans.

@jiangyi15
Copy link
Owner Author

     [var_name2, var_name]:

the list is unhashable, it it unable to use it in the key.
It would be better to used in another special config for connect two variables instead of pre_trans. That support more complex constrains, such as constrains for 3 variables.

@jiangyi15
Copy link
Owner Author

I have change it to

constrains:
    from_trans:
         var_name2:
              x:  var_name
              model: linear
              k: 2.0
              b: 0.0

@Yinrui-Liu Yinrui-Liu merged commit 043c05f into dev Sep 18, 2023
12 checks passed
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.

2 participants