Closed samm82 closed 6 years ago
I like your proposed changes to the code. Please proceed. Let us hold off on capitalization errors etc. It is an interesting idea, but I'm not sure we want to go in that direction.
If I remember correctly, the test cases for GlassBR are not working right now. We need to fix the test cases so that when the code is refactored as you suggest, we can make sure that we run the regression tests. It is hard to imagine your currently proposed code adding an errors, but in general, we want the confidence that re-running the test cases provides.
Does the Python code for GlassBR use exceptions anywhere? Exceptions are a better design choice than simply printing messages to the terminal.
Exceptions are used in the following places:
checkConstraints.py
interp.py
@smiths Should I change the printed error into an exception/start on #81?
raise SystemExit("Input Error: Invalid glass type entered")
Also, can this issue be closed, since the only remaining things to do are encapsulated in other issues?
Yes, please replace the print statement with exceptions. I suggest that you use ValueError, rather than SystemExit. We may eventually want to write an exception handler that provides some means to correct the erroneous value. Given that you already have an issue for the exceptions (#81), we can leave the current issue closed.
TODO:
[x] Exceptions (#81)
I'm not sure what implications this would have in Drasil, but in derivedValues.py, perhaps a better way to implement this:
https://github.com/smiths/caseStudies/blob/63fee225c72db5ff0e73639eec56fab12bb457c2/CaseStudies/glass/Implementations/Python/Implementation/derivedValues.py#L47-L55
could be:
We could also potentially add erroneous capitalization instances (eg. 'aN', 'Hs') to the lists and/or apply the
.strip()
method toparams.gt
to account for whitespace errors, however, I'm not sure if this would make it too broad/what the implications are of this change.