-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Resolving AttributeError when using ModelChain with multiple Arrays #1938
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
Conversation
…attribute-error-mult-arrays
…till None after attempt to infer
… inference to be more informative to user
…uired args to infer temperature_model_parameters
…tive for user to diagnose
…reflect new required argument
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.
Formatting suggestions
|
||
Testing | ||
~~~~~~~ | ||
|
||
|
||
Documentation | ||
~~~~~~~~~~~~~ | ||
|
||
* Update all examples in :ref:`pvsystem` User's guide page that reference | ||
`pvsystem` to adhere to new required argument. |
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.
`pvsystem` to adhere to new required argument. | |
`pvsystem` to adhere to new required argument. |
error in `ModelChain` instantiation when the `temperature_model_parameters` | ||
for a `PVSystem` have not been set. Update requires `PVSystem` or `Array` | ||
to have `temperature_model_parameters` explicitly or implicitly by providing | ||
`racking_model` and `module_type`. |
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.
error in `ModelChain` instantiation when the `temperature_model_parameters` | |
for a `PVSystem` have not been set. Update requires `PVSystem` or `Array` | |
to have `temperature_model_parameters` explicitly or implicitly by providing | |
`racking_model` and `module_type`. | |
error in `ModelChain` instantiation when the `temperature_model_parameters` | |
for a `PVSystem` have not been set. Update requires `PVSystem` or `Array` | |
to have `temperature_model_parameters` explicitly or implicitly by providing | |
`racking_model` and `module_type`. |
@@ -977,6 +984,18 @@ def __init__(self, mount, | |||
else: | |||
self.temperature_model_parameters = temperature_model_parameters | |||
|
|||
if self.temperature_model_parameters=={}: |
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.
if self.temperature_model_parameters=={}: | |
if self.temperature_model_parameters == {}: |
@@ -977,6 +984,18 @@ def __init__(self, mount, | |||
else: | |||
self.temperature_model_parameters = temperature_model_parameters | |||
|
|||
if self.temperature_model_parameters=={}: | |||
raise ValueError("The `temperature_model_parameters` is empty " | |||
"after an attempt to infer it. " |
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.
"after an attempt to infer it. " | |
"after an attempt to infer it. " |
if self.temperature_model_parameters=={}: | ||
raise ValueError("The `temperature_model_parameters` is empty " | ||
"after an attempt to infer it. " | ||
"Pass either `temperature_model_parameters` to " |
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.
"Pass either `temperature_model_parameters` to " | |
"Pass either `temperature_model_parameters` to " |
raise ValueError("The `temperature_model_parameters` is empty " | ||
"after an attempt to infer it. " | ||
"Pass either `temperature_model_parameters` to " | ||
"`Array` or `PVSystem` (if not passing arrays), or " |
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.
"`Array` or `PVSystem` (if not passing arrays), or " | |
"`Array` or `PVSystem` (if not passing arrays), or" |
"after an attempt to infer it. " | ||
"Pass either `temperature_model_parameters` to " | ||
"`Array` or `PVSystem` (if not passing arrays), or " | ||
"`racking_module` to the `Array` `mount` " |
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.
"`racking_module` to the `Array` `mount` " | |
" `racking_module` to the `Array` `mount` " |
"Pass either `temperature_model_parameters` to " | ||
"`Array` or `PVSystem` (if not passing arrays), or " | ||
"`racking_module` to the `Array` `mount` " | ||
"object and `module_type` to `Array. For guidance " |
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.
"object and `module_type` to `Array. For guidance " | |
"object and `module_type` to `Array. For guidance" |
"`Array` or `PVSystem` (if not passing arrays), or " | ||
"`racking_module` to the `Array` `mount` " | ||
"object and `module_type` to `Array. For guidance " | ||
"on allowed values to use for `racking_module` and " |
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.
"on allowed values to use for `racking_module` and " | |
" on values allowed for `racking_module` and " |
mount = pvsystem.FixedMount(surface_tilt=20, surface_azimuth=180, | ||
racking_model=racking_model) | ||
with pytest.raises(ValueError, match='`temperature_model_parameters` is empty'): | ||
pvsystem.Array(mount = mount, module_type=module_type) |
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.
pvsystem.Array(mount = mount, module_type=module_type) | |
pvsystem.Array(mount=mount, module_type=module_type) |
@cwhanse, these all look like formatting changes that I can accept right here. However, would like to understand the reason for these updates. For example: Why do we need the line to begin with a space? Is there a setting that I need to tweak in my linter / yapf to format it according to this standard? The only reference to spaces I see in the Contributing page is
Thanks |
I noticed that the Contributing document has 2 instances of |
It may be unnecessary but it makes the text file easier to read. |
@pvlib/pvlib-maintainer this PR will change default behavior, although the current behavior is buggy. It will be required to provide either What do we think about deprecation for this change? I view the change as primarily correcting a bug in v0.9.0 where we dropped defaulting to a SAPM temperature model when the inputs weren't supplied. |
Those RST files are used to build our documentation, and the spaces are necessary for that multi-line text to be considered a single bullet item instead of a bullet followed by a new paragraph. That file isn't included in our docs build yet, but you can check that currently it is not rendering correctly using GitHub's viewer: https://github.com/matsuobasho/pvlib-python/blob/main/docs/sphinx/source/whatsnew/v0.10.4.rst
I still need to read and digest the discussion in #1759, but on the face of it, this seems not ideal to me. Currently it's possible to instantiate a PVSystem with no arguments at all. Seems strange to me for these temperature model inputs to be the only required inputs. |
@cwhanse please confirm my interpretation that it's best to wait without making any updates to this until further word |
@matsuobasho yes, we're sorting out what the desired behavior should be. |
@@ -977,6 +984,18 @@ def __init__(self, mount, | |||
else: | |||
self.temperature_model_parameters = temperature_model_parameters | |||
|
|||
if self.temperature_model_parameters=={}: |
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.
@matsuobasho I agree with @kandersolar point of view, that we should remove this ValueError
. I think we'll want to undo most of the changes in test_pvsystem.py as well. Because I can push to your fork, let me know if you'd like some help. And thanks again for your effort here.
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.
It'll be most efficient to delete this entire MR because there are so many changes that will not be used. The proposed change is just deleting two lines and will be easiest to recreate with a new MR.
Let me know if you can kill the entire MR. I'll then create a new MR with just that one change.
In this case, it looks like we do not need a new test or any docstring modifications?
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.
You can close this PR and start a new one.
For the new PR I recommend that you first create a branch in your fork and use that branch for changes. Its not usually a good idea to make changes in your main branch.
First reset your main branch
git reset --hard upstream/ main where upstream is your name for pvlib/pvlib-python
Then create a branch
git checkout -b
Make the edits in the branch, add, commit, push, etc.
docs/sphinx/source/reference
for API changes. -- Doesn't seem to be relevant forPVSystem
docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.