Having explicit arguments for these classes, with inline default values rather than in a separate function, will make these easier and less surprising to use. I think this will only break a few places that pass dicts to the constructor, e.g. from_gk_data, but this is an easy fix:
modified src/pyrokinetics/local_geometry/local_geometry.py
@@ -285,7 +285,7 @@ class LocalGeometry:
# be possible to have a local_geometry object that does not contain all attributes.
# bunit_over_b0 should be an optional argument, and the following should
# be performed within __init__ if it is None
- local_geometry = cls(params)
+ local_geometry = cls(**params)
# Values are not yet normalised
local_geometry.bunit_over_b0 = local_geometry.get_bunit_over_b0()
Currently, the constructors for both these classes (and their subclasses) are all just:
This makes it difficult to do several things:
All this leads to some surprising behaviour.
For example, for
LocalGeometry
, some parameters aren't set by default:and passing keyword arguments doesn't actually set them:
Passing a
dict
of values does set them, but then doesn't set anything else:Having explicit arguments for these classes, with inline default values rather than in a separate function, will make these easier and less surprising to use. I think this will only break a few places that pass
dict
s to the constructor, e.g.from_gk_data
, but this is an easy fix: