[BUGFIX] Allow empty arrays in export as dict #1061
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Bug fix: Allow empty arrays in export as dict
In #1040, functionality was added to support initializing the
FlorisModel
from a default configuration. I intentionally left the wind speed, wind direction, and turbulence intensity inputs as empty arrays instead of some default numeric value so that theFlorisModel.run()
function would fail with an error requiring the user to set these inputs themselves. However, if FLORIS is initialized and some parameters set but not the wind speed, wind direction, and TI, then these arrays are dropped during theFlorisModel.set()
routine.Details:
FlorisModel.set()
callsFlorisModel._reinitialize()
FlorisModel._reinitialize()
exportsFlorisModel.Core
to a dictionary withas_dict
from theFromDictMixin
classCore
inherits fromBaseClass
which inherits fromFromDictMixin
FromDictMixin.as_dict()
callsattr.asdict
with the_attr_floris_filter
filter_attr_floris_filter
filters out the following conditions from the export:field(init=False
)None
np.array
FlorisModel._reinitialize()
callsCore.from_dict()
, but the empty arrays have been removedFlowField
requires wind speed, wind direction and turbulence intensity inputs, so there's an errorThis pull request removes the last condition in
_attr_floris_filter
. While the complete impact of this is difficult to assess, all the tests pass and the examples run without change. Also, I added an error within the last condition to check if it's used at all in the examples, and it was not called (see Test Results).Related issue
No open issue, but introduced in #1040 and spotted in WISDEM/Ard#47
Test results, if applicable
Before removing it, I added an error in the
_attr_floris_filter
condition to check whether any examples execute this branch.