-
-
Notifications
You must be signed in to change notification settings - Fork 577
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
Implementing Property Based Tesing using Hypothesis #4724
base: develop
Are you sure you want to change the base?
Conversation
@RohitP2005 Add Here: Line 100 in 421784e
|
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've added reviews for test_averages.py
. I'll add reviews for test_unary_operators.py
once the failing tests are fixed.
@@ -267,8 +271,9 @@ def test_r_average(self): | |||
assert pybamm.r_average(a + b) == pybamm.r_average(a) + pybamm.r_average(b) | |||
assert pybamm.r_average(a - b) == pybamm.r_average(a) - pybamm.r_average(b) | |||
|
|||
def test_yz_average(self): | |||
a = pybamm.Scalar(1) | |||
@given(st.integers(min_value=-(2**63), max_value=2**63 - 1)) |
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.
Same question here.
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.
explained here at #4724 (comment)
Also, fix the PR heading. It's not proper. |
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
@prady0t |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #4724 +/- ##
===========================================
- Coverage 99.22% 99.22% -0.01%
===========================================
Files 303 303
Lines 23070 23101 +31
===========================================
+ Hits 22891 22921 +30
- Misses 179 180 +1 ☔ View full report in Codecov by Sentry. |
@@ -174,9 +177,10 @@ def test_x_average(self): | |||
assert pybamm.x_average(a + b) == pybamm.x_average(a) + pybamm.x_average(b) | |||
assert pybamm.x_average(a - b) == pybamm.x_average(a) - pybamm.x_average(b) | |||
|
|||
def test_size_average(self): | |||
@given(st.integers(min_value=-(2**63), max_value=2**63 - 1)) |
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 see. Having large-sized integers causes buffer overflow (probably because of different ways int is handled by pybamm and numpy ). Yes it's good to restrict the range here.
random_value=st.integers(), | ||
random_matrix=st.lists( | ||
st.floats(min_value=-10, max_value=10), min_size=5, max_size=5 | ||
), |
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.
Can we increase the size here? i'll look into this bit later
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.
okay , i guess 10 will be good a number
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
Co-authored-by: Pradyot Ranjan <[email protected]>
@RohitP2005 you keep merging develop into this branch, but there are still a bunch of failing tests. Can you fix those so the review can continue |
Sorry about that, my previous commit passed the CI test, after the new branch merge it is failing. I will look into it asap. |
Description
This change introduces the use of Hypothesis-based testing in two files and is being applied to selective functions as requested by the author and members of the issue #4703 (comment)
Fixes #4703
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run
(or$ nox -s pre-commit
) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python -m pytest
(or$ nox -s tests
)$ python -m pytest --doctest-plus src
(or$ nox -s doctests
)You can run integration tests, unit tests, and doctests together at once, using
$ nox -s quick
.Further checks: