pytensor
pytensor copied to clipboard
Remove reimplementation of np.testing.assert_allclose
Description
I think I got all the unittest_tools.assert_allclose instances
The following files no longer used functions from unittest_tools so I removed the import tests/link/test_vm.py tests/tensor/test_variable.py tests/scalar/test_basic.py tests/sparse/test_rewriting.py tests/link/c/test_params_type.py tests/tensor/rewriting/test_elemwise.py
There was a mention of utt.assert_all close in the creating_an_op document file so I changed that as well.
Related Issue
- [x] Closes #551
Checklist
- [X] Checked that the pre-commit linting/style checks pass
- [X] Included tests that prove the fix is effective or that the new feature works
- [X] Added necessary documentation (docstrings and/or example notebooks)
- [ ] If you are a pro: each commit corresponds to a [relevant logical changes
Type of change
- [ ] New feature / enhancement
- [ ] Bug fix
- [ ] Documentation
- [X] Maintenance
- [ ] Other (please specify):
Seems like the rtol/atol values may need to be tweaked slightly, as some tests are now failing
Seems like the rtol/atol values may need to be tweaked slightly, as some tests are now failing
Potentially dumb question, is that something I need to do?
Yes, we can only merge the changes if all tests pass. You can see which tests failed here on GitHub
Oh ok yeah I just wasn't sure what the atol and rtol values were and if that was something I was supposed to modify. But I'll look and see which tests failed and why. Thanks!
Ok I fixed up some remaining calls to the old unittest_tools assert_allclose function and fixed some typos I had introduced.
On the rtol and atol issues, in the current unittest_tools assert_allclose function, the default values for those are set to 'None'. That is
def assert_allclose(expected, value, rtol=None, atol=None):
if not _allclose(expected, value, rtol, atol):
raise WrongValue(expected, value, rtol, atol)
Should I also pass 'None' to the np.testing.assert_allclose function calls (assuming that's allowed)?
Instead of none, we should not specify them at all (unless the test fails, then we need to tweak them)
If things get out of hand, the default atol and rtol were being defined here: https://github.com/pymc-devs/pytensor/blob/0ebc83b393b7a3c310cdb451baee35b56b0dcc2f/pytensor/tensor/math.py#L102
And used here: https://github.com/pymc-devs/pytensor/blob/0ebc83b393b7a3c310cdb451baee35b56b0dcc2f/pytensor/tensor/math.py#L117
Hi @jaharvey8 Are you still working on this PR? I'd like to take it up if you are not.