-
Notifications
You must be signed in to change notification settings - Fork 23
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
Improve runtime and peak memory usage of PVEngine.run_full_mode #140
Draft
kandersolar
wants to merge
8
commits into
SunPower:master
Choose a base branch
from
kandersolar:sparse
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
38922c8
proof of concept sparse linear solve
kandersolar 4450fcc
a nice sprinkling of dels
kandersolar 077a160
document sparse solve helper function
kandersolar e0e1e3e
add scipy dependency
kandersolar 5268d5f
add basic sparse solve test
kandersolar 12f93e5
what's new
kandersolar 0d2e6f6
edits from review
kandersolar 480b350
bugfix for empty inputs
kandersolar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from pvfactors.engine import PVEngine | ||
from pvfactors.engine import PVEngine, _sparse_solve_3D | ||
from pvfactors.geometry.pvarray import OrderedPVArray | ||
from pvfactors.irradiance import IsotropicOrdered, HybridPerezOrdered | ||
from pvfactors.irradiance.utils import breakup_df_inputs | ||
|
@@ -709,3 +709,36 @@ def test_engine_variable_albedo(params, df_inputs_clearsky_8760): | |
expected_bfg_after_aoi = 14.670709 | ||
np.testing.assert_allclose(bfg, expected_bfg) | ||
np.testing.assert_allclose(bfg_after_aoi, expected_bfg_after_aoi) | ||
|
||
|
||
def test__sparse_solve_3d(): | ||
"""Verify the sparse solver returns same results as np.linalg.solve""" | ||
A = np.random.rand(5, 3, 3) | ||
b = np.random.rand(5, 3) | ||
x_dense = np.linalg.solve(A, b) | ||
x_sparse = _sparse_solve_3D(A, b) | ||
assert x_sparse.shape == b.shape | ||
np.testing.assert_allclose(x_dense, x_sparse) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. awesome 👍 |
||
|
||
|
||
def test_engine_empty_inputs(params, df_inputs_clearsky_8760): | ||
"""Empty inputs yields empty outputs""" | ||
df_inputs = df_inputs_clearsky_8760.iloc[:0] | ||
timestamps = df_inputs.index | ||
dni = df_inputs.dni.values | ||
dhi = df_inputs.dhi.values | ||
solar_zenith = df_inputs.solar_zenith.values | ||
solar_azimuth = df_inputs.solar_azimuth.values | ||
surface_tilt = df_inputs.surface_tilt.values | ||
surface_azimuth = df_inputs.surface_azimuth.values | ||
|
||
# Run engine | ||
pvarray = OrderedPVArray.init_from_dict(params) | ||
eng = PVEngine(pvarray) | ||
eng.fit(timestamps, dni, dhi, solar_zenith, solar_azimuth, surface_tilt, | ||
surface_azimuth, params['rho_ground']) | ||
qinc = eng.run_full_mode( | ||
fn_build_report=lambda pvarray: (pvarray.ts_pvrows[1] | ||
.back.get_param_weighted('qinc'))) | ||
|
||
assert len(qinc) == 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pvlib>=0.9.0,<0.10.0 | ||
shapely>=1.6.4.post2,<2 | ||
scipy>=1.2.0 | ||
matplotlib | ||
future | ||
six |
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.
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.
awesome 👍 it doesn't shock me to have the
del
s in this function for now, although it is true that it is not that frequent to see in python. We could maybe add a small note in the docstrings to explain why we're doing that