Repository navigation
Conversation
With one position, pdist returns an empty distance array and the effective-size optimizer converges to n_dist=0, so _compute_vr divided by zero and scaling.wvm returned an all-NaN signal. A single site has no variability reduction, so _compute_vr now returns a reduction factor of 1 for every timescale and wvm passes the input through unchanged. Fixes pvlib#2895 Signed-off-by: bfs2021 <101915083+bfs2021@users.noreply.github.com>
Hey @bfs2021! 🎉Thanks for opening your first pull request! We appreciate your If AI is used for any portion of this PR, you must vet the content Finally, be sure the PR description includes the PR |
Signed-off-by: bfs2021 <101915083+bfs2021@users.noreply.github.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
pvlib.scaling.wvmreturns an entirely NaN output for a layout with one coordinate pair. See #2895 for the full report, including the float-precision analysis (0.29 * 100 == 28.999...-style rounding is a separate symptom of the samerounder).Root cause
With a single position,
scipy.spatial.distance.pdistreturns an empty distance array, son_pairs = 0and the effective-size objective has two roots (x=0 and x=1). The optimizer converges ton_dist = 0, which makes the Eq. 6 denominator2 * sum(rho) + n_distequal to zero — dividing by zero yields NaN for every timescale, and the reconstructed signal is all NaN.Fix
_compute_vrnow returns a variability reduction factor of 1 for every timescale whenpositionscontains a single site. Per the WVM equations, one site has no pairwise correlations and therefore no variability reduction, sowvmpasses the input signal through unchanged — the behavior the issue describes as expected.Testing
test_compute_vr_single_site:_compute_vrwith one position returns all ones for every timescale.test_wvm_single_site:wvmwith one position returns the input signal unchanged (previously all NaNs).pytest tests/test_scaling.py→ 18 passed (16 existing + 2 new), Python 3.12, Windows.Fixes #2895
Checklist
docs/sphinx/source/whatsnew/v0.16.2.rst(:issue:2895, :pull:2896, by :ghuser:bfs2021)