-
Notifications
You must be signed in to change notification settings - Fork 137
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
[DEFECT] Pickled RAVEN ROM outside of RAVEN non-array inputs #1962
Comments
I get why SupervisedLearning.py line 339 is a problem if an integer is passed in, but what is the problem if a float is passed in?
As in at a quick glance at the code, the bottom one is the one that needs the conversion. But maybe I am missing something? (And the new code in #1963 is fine with me, I am just trying to understand why it also fixes floats) |
Sometimes a float is actually a numpy.float64 or other variant. in that case A second issue occurs later for the first case, |
Okay, so to approve this, I need answers to: " If it is a defect, can it cause wrong results for users? " and "If the issue is a defect, is the defect tested for in the regression test system? (If not explain why not.)" (A two sentence answer is sufficient.) |
It works fine when run inside of RAVEN and so this should not produce wrong results for users. I noticed this because I unpickled a RAVEN ROM and attempted to use the ROM as a Python function in an external script. We don't currently have a test for this use case. Is this in the scope of RAVEN tests? If so, the best way to test this would probably be a unit test for ROM inputs. |
Hm, I am checking if any regression touches this already with: --- a/ravenframework/SupervisedLearning/SupervisedLearning.py
+++ b/ravenframework/SupervisedLearning/SupervisedLearning.py
@@ -337,6 +337,7 @@ class SupervisedLearning(BaseInterface):
for index in range(len(values)):
# If value is a float or int, convert to numpy array for evaluation
if isinstance(values[index], (float, int)):
+ a = 1/0
values[index] = np.array([values[index]])
resp = self.checkArrayConsistency(values[index], self.isDynamic())
if not resp[0]: |
Regression test added, so this now can be closed with #1963 |
Thank you for the defect report
RAVEN
.that demonstrates the defect.
Defect Description
When using a ROM built in RAVEN outside of RAVEN (in a Python script or Jupyter notebook), passing in a float as input should result in the float being recast as a numpy array. This does not work.
This was noticed with a DMDc ROM from RAVEN when passing in the initial state values. There is a check for floats (SupervisedLearning.py line 339), but it does not work correctly. Also, an error will be thrown if an integer is passed in as an input.
Steps to Reproduce
Expected Behavior
ROM should act as any ordinary function, pass in inputs, return outputs.
Screenshots and Input Files
No response
OS
Windows
OS Version
No response
Dependency Manager
CONDA
For Change Control Board: Issue Review
For Change Control Board: Issue Closure
The text was updated successfully, but these errors were encountered: