Change single number inputs to single element array inputs for SSC_ARRAY required input variables#907
Conversation
…RAY required input variables
tyneises
left a comment
There was a problem hiding this comment.
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.
|
@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. |
This PR does include the warnings. For example setting These simulation warnings are not always obvious in PySAM. |
|
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 |
|
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. |
@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! |
works with previous ssc test files and SDKtool with lk generated from previous releases