Skip to content

Conversation

@igopalakrishna
Copy link
Contributor

@igopalakrishna igopalakrishna commented Jul 26, 2025

Fixes #28

This pull request resolves the issue by replacing assert statements with explicit ValueError exceptions in the example file mentioned, smart_control/simulator/stochastic_occupancy.py.

Using ValueError is better practice as assert statements can be disabled in production environments, which would otherwise silently ignore important precondition checks.

  • Tests pass
  • No documentation changes were necessary for this change.

@google-cla
Copy link

google-cla bot commented Jul 26, 2025

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.

@igopalakrishna igopalakrishna changed the title Fix: Replaced assert with ValueError in stochastic_occupancy fix: Replaced assert with ValueError in stochastic_occupancy Jul 27, 2025
Copy link
Collaborator

@s2t2 s2t2 left a 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 "
Copy link
Collaborator

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.

Copy link
Collaborator

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.

@s2t2
Copy link
Collaborator

s2t2 commented Aug 15, 2025

@igopalakrishna should we close this PR in favor of #113 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove assertions from non-test code

2 participants