Skip to content

Set Pxx value to unsigned, limit to 1-99#2160

Open
mjprilliman wants to merge 2 commits intodevelopfrom
sam_1970
Open

Set Pxx value to unsigned, limit to 1-99#2160
mjprilliman wants to merge 2 commits intodevelopfrom
sam_1970

Conversation

@mjprilliman
Copy link
Copy Markdown
Collaborator

Pull Request Template

Description

-Update PXX input on PV Uncertainty form to be unsigned, limited to 1-99

Fixes #1970

Corresponding branches and PRs:

develop everywhere else

Unit Test Impact:

[ new tests written? ]
NO
[ expected changes in unit tests or speed of tests? ]
None
[ expected changes in test_results files? ]
None

Checklist

  • requires help revision and I added that label
  • adds, removes, modifies, or deletes variables in existing compute modules
  • adds a new compute module
  • changes defaults
  • I've tagged this PR to a milestone

Reminders- this section can be deleted

[Checking for PySAM Incompatible API Changes]
(https://github.com/NREL/SAM/wiki/PySAM-Incompatible-API-Changes-&-Regenerating-PySAM-Files).

[When do the PySAM files need to be regenerated?]
(https://github.com/NREL/SAM/wiki/PySAM-Incompatible-API-Changes-&-Regenerating-PySAM-Files#when-do-the-pysam-files-need-to-be-regenerated-via-export_config)

@mjprilliman mjprilliman added this to the SAM 2026 Release milestone Apr 1, 2026
@mjprilliman mjprilliman requested review from Copilot and sjanzou April 1, 2026 14:31
@mjprilliman mjprilliman self-assigned this Apr 1, 2026
@mjprilliman mjprilliman added bug pv pvsam1, pvwatts, hcpv labels Apr 1, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the PV Uncertainty “Custom Px” input to prevent negative values and constrain the selectable P-value range, addressing out-of-bounds P-values in the Uncertainty tool (Fixes #1970).

Changes:

  • Switches the “Custom Px” wxNumericCtrl to an unsigned numeric mode.
  • Adds a 1–99 allowed range constraint to the P-value input.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

wxStaticBoxSizer *sizer_changePvalue = new wxStaticBoxSizer( wxHORIZONTAL, this, "Update P value" );
label = new wxStaticText( this, wxID_ANY, "Custom Px:" );
m_puser = new wxNumericCtrl( this, wxID_ANY, 90, wxNUMERIC_REAL );
m_puser = new wxNumericCtrl( this, wxID_ANY, 90, wxNUMERIC_UNSIGNED );
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI range/unsigned restriction here only affects what the user can type going forward; m_data.pValue can still be out of bounds when loading an existing case file (see PVUncertaintyData::Read() and UpdateFromSimInfo() setting the control from m_data.pValue). Consider clamping/normalizing the value (and persisting it back to m_data.pValue) when reading/applying it so legacy projects with pValue <=0 or >=100 don’t continue running with invalid internal state even if the control display gets constrained.

Suggested change
m_puser = new wxNumericCtrl( this, wxID_ANY, 90, wxNUMERIC_UNSIGNED );
int pValue = static_cast<int>(m_data.pValue);
if (pValue < 1) pValue = 1;
else if (pValue > 99) pValue = 99;
m_data.pValue = pValue;
m_puser = new wxNumericCtrl( this, wxID_ANY, pValue, wxNUMERIC_UNSIGNED );

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjanzou does that look more correct?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, between the explicit pValue check and the m_puser->SetRange the P value should be limited to 1<=P<=99. if you test and that is not the case, you will need to override the OnChange event for m_puser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug pv pvsam1, pvwatts, hcpv

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncertainty tool allows out of bounds P-values

3 participants