diff --git a/floris/simulation/base.py b/floris/simulation/base.py index 26f82d362..eb26364ab 100644 --- a/floris/simulation/base.py +++ b/floris/simulation/base.py @@ -26,7 +26,6 @@ ) from attrs import ( - asdict, Attribute, define, field, @@ -54,28 +53,6 @@ class BaseClass(FromDictMixin): state = field(init=False, default=State.UNINITIALIZED) _logging_manager: LoggingManager = field(init=False, default=LoggingManager()) - @classmethod - def get_model_defaults(cls) -> Dict[str, Any]: - """Produces a dictionary of the keyword arguments and their defaults. - - Returns - ------- - Dict[str, Any] - Dictionary of keyword argument: default. - """ - return {el.name: el.default for el in fields(cls)} - - def _get_model_dict(self) -> dict: - """Convenience method that wraps the `attrs.asdict` method. Returns the object's - parameters as a dictionary. - - Returns - ------- - dict - The provided or default, if no input provided, model settings as a dictionary. - """ - return asdict(self) - @property def logger(self): """Returns the logger manager object.""" diff --git a/floris/tools/interface_utilities.py b/floris/tools/interface_utilities.py index e719aea9f..3a02b6960 100644 --- a/floris/tools/interface_utilities.py +++ b/floris/tools/interface_utilities.py @@ -27,6 +27,7 @@ def show_params( # props = get_props(obj, fi) props = fi.floris.wake._asdict() # props = props["wake_velocity_parameters"][fi.floris.wake.velocity_model.model_string] + # NOTE: _get_model_dict is remove and model.as_dict() should be used instead props = fi.floris.wake.velocity_model._get_model_dict() if verbose: diff --git a/tests/base_test.py b/tests/base_test.py index 7dc440c51..298fe80e4 100644 --- a/tests/base_test.py +++ b/tests/base_test.py @@ -31,29 +31,16 @@ def function() -> None: return None -def test_get_model_defaults(): - """ - This tests that the default parameter values are set correctly and unchanged if not - explicitly set. - Note that the attributes in BaseClass and BaseModel are treated as default parameters - by attrs. - """ - defaults = ClassTest.get_model_defaults() - assert len(defaults) == 5 - assert defaults["x"] == 1 - assert defaults["a_string"] == "abc" - - def test_get_model_values(): """ + BaseClass and therefore BaseModel previously had a method `get_model_values` that + returned the values of the model parameters. This was removed because it was redundant + but this test was refactored to test the as_dict method from FromDictMixin. This tests that the parameters are changed when set by the user. - Note that the attributes in BaseClass and BaseModel are treated as parameters by attrs. - They aren't changed in the instantiation method, but they are still included in the - parameter set. """ cls = ClassTest(x=4, a_string="xyz") - values = cls._get_model_dict() - assert len(values) == 5 + values = cls.as_dict() + assert len(values) == 2 assert values["x"] == 4 assert values["a_string"] == "xyz"