-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bugfix] Cast yaw angles to np.ndarray on set #828
Conversation
The fix was straightforward here---in Incidentally, this is something that @rafmudaf warned me about---that reaching in and altering the attributes (rather than instantiating them properly, which would pass through |
@paulf81 I can't add you as a reviewer, since you opened the PR, but please look through and see what you think. |
This works great for me, thank you @misi9170 I "approve" |
floris/tools/floris_interface.py
Outdated
@@ -355,7 +355,7 @@ def _set_operation( | |||
""" | |||
# Add operating conditions to the floris object | |||
if yaw_angles is not None: | |||
self.floris.farm.yaw_angles = yaw_angles | |||
self.floris.farm.yaw_angles = np.array(yaw_angles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the only place where yaw angles are going to be set? If not, you might consider adding a setter method on Farm
to do this always:
class Farm:
def set_yaw_angles(yaw_angles):
# Do lots of checks
...
# Cast to Numpy array
self.yaw_angles = np.array(yaw_angles)
You could also use the @property
decorator the way we used to do, if you think maintaining the attribute-style use is important.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, there's already a function with this name at https://github.com/NREL/floris/blob/v4/floris/simulation/farm.py#L332
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah and I just read #828 (comment), sorry to say the same thing @misi9170
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem---I'm going to try to do this (use a setter method), it seems like a better approach
[Bugfix] Fix yaw setting
In the course of some other work, I noticed that a few conditions that I would've expected to be ok throw an error:
This is not so hard to fix but I wasn't positive the preferred solution (attrs?). So I thought I'd start just by adding the failing tests and then we can agree on how we want to fix it.
Other things to consider:
Note this issue is a little bit being worked-around in #821