update __getitem__ to intercept specific prefixes #1987
jgostick
started this conversation in
Development
Replies: 1 comment
-
The new Base refactor will be allowing 'param' in the dicts, so pore-scale models could work like this: def viscosity(target, temperature='pore.temperature'):
mu = f(temperature)
return mu Note that 'pore.temperature' is the default value, but the user could call it like: viscosity(target=geo, temperature='param.T') Thanks to Numpy's vectorization this can be done with 0 effort/changes inside the functions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If
__getitem__
were upgraded it could intercept any dict keys that don't start with pore or throat, like'parameter.temperature'
and if found it could fetch the value from theparameters
attribute of the object. This would allow automatically having all pore scale models look up values from different places other than the object's own dict. Theparameters
look-up could also work like the interleave data method, buy looking on self first, then parent object, then project if necessary.This is a bit 'magic', but very handy and could be a good alternative to allowing new prefixes into the dictionaries, which will be a nightmare to change.
Beta Was this translation helpful? Give feedback.
All reactions