-
Notifications
You must be signed in to change notification settings - Fork 39
fix: Replaced assert with ValueError in stochastic_occupancy #109
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
base: copybara_push
Are you sure you want to change the base?
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
d848cad to
adf06bb
Compare
adf06bb to
e452979
Compare
s2t2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks @igopalakrishna for taking up this issue. 🙌 I provided some specific comments below for the first instance you fixed.
In general, it would be nice to have a single PR that addresses all the instances across the codebase.
With the error raising implemented, we should now be able to add some tests to ensure each of the errors is triggered when we pass in certain invalid conditions. If you are able to add a corresponding test for each error, that would be awesome!
| ): | ||
| raise ValueError( | ||
| "Time bounds must be in chronological order i.e., " | ||
| "expected arrival/departure hours must be strictly increasing:" "earliest_expected_arrival_hour < latest_expected_arrival_hour " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we want the second string on its own line, to avoid line-too-long errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's consider using more natural language in the error message, like "earliest expected arrival must come before latest expected arrival, earliest expected departure must come before latest expected departure", etc.
|
@igopalakrishna should we close this PR in favor of #113 ? |
Fixes #28
This pull request resolves the issue by replacing
assertstatements with explicitValueErrorexceptions in the example file mentioned,smart_control/simulator/stochastic_occupancy.py.Using
ValueErroris better practice asassertstatements can be disabled in production environments, which would otherwise silently ignore important precondition checks.