Skip to content

Change single number inputs to single element array inputs for SSC_ARRAY required input variables#907

Merged
sjanzou merged 1 commit into
developfrom
ssc_906
Oct 26, 2022
Merged

Change single number inputs to single element array inputs for SSC_ARRAY required input variables#907
sjanzou merged 1 commit into
developfrom
ssc_906

Conversation

@sjanzou

@sjanzou sjanzou commented Oct 26, 2022

Copy link
Copy Markdown
Collaborator

works with previous ssc test files and SDKtool with lk generated from previous releases

@tyneises tyneises left a comment

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.

Is it correct that the outcome of this change is that if the cmod variable type is ARRAY but the input variable type is NUMBER, then the new code will convert the number to an array?

If so, I understand that this solves the current issue with the financial model inputs. However, this could make "real" variable definition errors harder to catch/fix. For example, if I incorrectly set an ARRAY as a NUMBER, instead of the pre-checks catching it, I won't know it's an error until whatever code is using that array finds that it isn't the expected length. Oftentimes the error reporting in these scenarios is hard to follow until you step through the code in debug. My opinion (if I understand this change correctly) is that we need a solution specific to the problem of a variable name/definition changing, but I could live with this fix.

@janinefreeman

janinefreeman commented Oct 26, 2022

Copy link
Copy Markdown
Collaborator

@tyneises that is a correct understanding. We also discussed updating the precheck routine to issue a warning when this action is triggered, @sjanzou is that in this PR as well or will that be separate? (I understand that warnings in scripts are not as useful as they are in the UI, but that's perhaps a separate conversation). However, we discussed that this change will still trigger any var_table prechecks where the array length is checked, even if the type gets changed, and it obviously also will trigger any exec-level errors about array length (which should be checked anywhere an array is used).

That said, this is definitely not a perfect solution- it was the best balance between crashing every financial script ever created, giving the user some information, and ease of development given the imminence of the release, that we could think of, and we all agreed a more elegant solution is in order after the release.

@cpaulgilman

Copy link
Copy Markdown
Collaborator

We also discussed updating the precheck routine to issue a warning when this action is triggered, @sjanzou is that in this PR as well or will that be separate? (I understand that warnings in scripts are not as useful as they are in the UI, but that's perhaps a separate conversation).

This PR does include the warnings. For example setting itc_fed_amount = 300 results in Notice: precheck input: variable 'itc_fed_amount' input type changed from <number> to single element <array>. time -1.000000

These simulation warnings are not always obvious in PySAM.

@cpaulgilman

Copy link
Copy Markdown
Collaborator

Tested and working in SDKtool: number-to-array-tests-sdktool.zip

This solution does not work for LK in SAM. When a script sets an input to a value of the wrong type, the value of the input does not change and you don't get any feedback: For example, try this script with a PVWatts - Single Owner case: number-to-array-test.zip

@brtietz

brtietz commented Oct 26, 2022

Copy link
Copy Markdown
Collaborator

Code looks good to me.

PySAM tests pass (except the REopt test, which hung and had to be cancelled - I think that's unrelated), however PySAM examples fail, and changes to PySSC are required as per: #906 (comment) - I'll work on that this afternoon.

@sjanzou

sjanzou commented Oct 26, 2022

Copy link
Copy Markdown
Collaborator Author

@tyneises that is a correct understanding. We also discussed updating the precheck routine to issue a warning when this action is triggered, @sjanzou is that in this PR as well or will that be separate? (I understand that warnings in scripts are not as useful as they are in the UI, but that's perhaps a separate conversation). However, we discussed that this change will still trigger any var_table prechecks where the array length is checked, even if the type gets changed, and it obviously also will trigger any exec-level errors about array length (which should be checked anywhere an array is used).

That said, this is definitely not a perfect solution- it was the best balance between crashing every financial script ever created, giving the user some information, and ease of development given the imminence of the release, that we could think of, and we all agreed a more elegant solution is in order after the release.

@tyneises , @janinefreeman , @cpaulgilman , this pull request is for ssc only and for pysam and scripting against ssc only. The conversion in SAM scripting and updating old project files will be a separate pull request. Thanks for reviewing!

@sjanzou sjanzou requested a review from tyneises October 26, 2022 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change array inputs that are specified as single number to single value array inputs in ssc precheck

5 participants