[ZC-1342]: Disable variable syntax in derivations#489
[ZC-1342]: Disable variable syntax in derivations#489slobodan-ilic wants to merge 8 commits intomasterfrom
Conversation
c4633ae to
25bcb3d
Compare
jjdelc
left a comment
There was a problem hiding this comment.
This is amazing work!! Thanks @slobodan-ilic
| return list(range(lower, upper + 1)) | ||
|
|
||
|
|
||
| def parse_expr(expr, platonic=False): |
scrunch/tests/test_datasets.py
Outdated
| # `sum` fails | ||
| with pytest.raises(Exception, match='not 1.0'): | ||
| _test_sum(targets[0]['foo']) | ||
| # with pytest.raises(Exception, match='not 1.0'): |
There was a problem hiding this comment.
Should this be deleted? Is it not tested or doesn't fail anymore?
There was a problem hiding this comment.
yeah, since the sum doesn't fail, no need to keep this around. deleted.
| 'expression': { | ||
| 'function': '!=', | ||
| 'args': [ | ||
| {'variable': var.url}, # Crunch needs variable URLs! |
There was a problem hiding this comment.
Is there somewhere a var variable that isn't used anymore now?
| "function": "in", | ||
| "args": [ | ||
| { | ||
| "variable": var1.url |
| }, | ||
| { | ||
| 'variable': 'caseid' | ||
| 'var': 'caseid' |
There was a problem hiding this comment.
Ok, I see so parse_expr now outputs the var term directly. Great!!
| # We are in the case of a default fill, replace the -1 with the new | ||
| # variable | ||
| fill_map["-1"] = {"variable": vars_by_alias[else_case["variable"]]["id"]} | ||
| fill_map["-1"] = {"var": else_case["var"]} |
There was a problem hiding this comment.
Is there still a vars_by_alias that's being fetched that we may not need anymore?
|
|
||
| elif isinstance(var_value, str): | ||
| for var in variables: | ||
| for va, var in variables.items(): |
There was a problem hiding this comment.
What a mess is all this code. It's so complex for things that should be much simpler :-(
|
|
||
| # inspect function, then inspect variable, if multiple_response, | ||
| # then change in --> any | ||
| if 'function' in obj and 'args' in obj: |
There was a problem hiding this comment.
We're not making this replacement anymore?
This is because in scrunch they say subvar in mr_var but in zz9 it is more like any(mr_var, [subvar]) so they need to replace IN for ANY
| methods = {m[1]: m[0] for m in CRUNCH_METHOD_MAP.items()} | ||
| functions = {f[1]: f[0] for f in CRUNCH_FUNC_MAP.items()} | ||
|
|
||
| def _resolve_variable(var): |
|
|
||
| if 'var' in fragment: | ||
| if 'axes' in fragment: | ||
| return "{}[{}]".format(fragment['var'], fragment['axes'][0]) |
There was a problem hiding this comment.
uhhh are we parsing this back? I can't remember if we have tests that show that scrunch can understand this. It's been so long 🧓🏽
All derivation expressions should use
{"var": <alias>}syntax. The{"variable": <varid>}syntax is deprecated and will not be supported in the fututre.