Skip to content
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

Deprecate redefinition of np.testing.assert_allclose #784

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Dhruvanshu-Joshi
Copy link
Member

@Dhruvanshu-Joshi Dhruvanshu-Joshi commented May 27, 2024

Description

Replaced all instances of assert_allclose with corresponding np.testing.assert_allclose.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

@Dhruvanshu-Joshi Dhruvanshu-Joshi force-pushed the deprecate_testingnp branch 5 times, most recently from 94bdd55 to ba18c65 Compare June 3, 2024 06:48
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.

Project coverage is 80.96%. Comparing base (5c8afae) to head (87c6ee6).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #784      +/-   ##
==========================================
- Coverage   80.97%   80.96%   -0.02%     
==========================================
  Files         169      169              
  Lines       47015    47011       -4     
  Branches    11497    11497              
==========================================
- Hits        38072    38061      -11     
- Misses       6728     6729       +1     
- Partials     2215     2221       +6     
Files Coverage Δ
pytensor/tensor/math.py 90.09% <ø> (-0.34%) ⬇️
pytensor/tensor/type.py 93.73% <33.33%> (-0.81%) ⬇️

... and 3 files with indirect coverage changes

@Dhruvanshu-Joshi Dhruvanshu-Joshi force-pushed the deprecate_testingnp branch 3 times, most recently from 135ff93 to 87c6ee6 Compare July 2, 2024 19:08
Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Asking whether we can remove one more helper from the non-test codebase

Comment on lines +665 to +671
atol_, rtol_ = pytensor.tensor.math._get_atol_rtol(a, b)
if rtol is not None:
rtol_ = rtol
if atol is not None:
atol_ = atol
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage says this is not being used, can we just remove?

@@ -85,7 +85,15 @@ def test_variable_only(self):
z = dot(x, y)
assert hasattr(z.tag, "test_value")
f = pytensor.function([x, y], z)
assert _allclose(f(x.tag.test_value, y.tag.test_value), z.tag.test_value)
atol_, rtol_ = _get_atol_rtol(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this ends up only being used in the tests here, we can remove from math and include only in the test file?

@Dhruvanshu-Joshi
Copy link
Member Author

So what is to be done here. Here's what is changing. So originally in pytensor.tensor.type, the function def values_eq_approx uses _allclose function from pytensor.tensor.math. Here if atol and rtol values are not provided, _allclose makes a call to _get_atol_rtol_values which calculates them. Now since we are removing the _allclose function altogether, I used the _get_atol_rtol_values directly in pytensor.tensor.type. And because _get_atol_rtol_values is used in pytensor.tensor.type, we cannot move it into unittest_tools.py in tests.

@Dhruvanshu-Joshi
Copy link
Member Author

Hi @ricardoV94
Is there something left here? I don't understand why the coverage test is failing.

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 reimplementation of np.testing.assert_allclose
2 participants