Comments (5)
@tovrstra It is safe to say that we use numpy.testing.assert_array_almost_equal
for almost all cases and numpy.testing.assert_allclose
in rare cases when precision is required?
from iodata.
The Numpy docs recommend using assert_allclose
instead of assert_almost_equal
. See https://docs.scipy.org/doc/numpy-1.15.0/reference/generated/numpy.testing.assert_almost_equal.html
from iodata.
Or maybe use the Python (not numpy) intrinsic:
math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
Probably clunkier without the "assert" built in....
from iodata.
The numpy.testing.assert_allclose
is asymmetric, which means that a=b
might result b not equal a. For example (taken from https://stackoverflow.com/questions/48156460/isclose-function-in-numpy-is-different-from-math)
a = 0.142253
b = 0.142219
rel_tol = 1e-4
abs_tol = 1.9776e-05
# test failed
numpy.testing.assert_allclose(actual=a, desired=b, rtol=rel_tol, atol=abs_tol)
# test passed
np.testing.assert_allclose(actual=b, desired=a, rtol=rel_tol, atol=abs_tol)
But for math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0)
, it seems only support scaler instead of numpy array.
a = np.linspace(0., 1., 100).reshape(10, 10)
b = np.arcsin(np.sin(a))
# this will raise an TypeError
math.isclose(a, b, rel_tol=1e-09, abs_tol=0.0)
Once an agreement is reached, I can start working on this.
from iodata.
It sounds to me like you should use numpy.testing.assert_allclose
The nuance of directionality is unlikely to be important; the example is a rather evil one. To the extent that you can identify one value which is "reference" and one which is "approximate" you should make sure the "desired" is the reference.
from iodata.
Related Issues (20)
- Support different types of normalization of the primitives in `iodata.basis` HOT 1
- Fix `dump_one` and `dump_many` for SDF file format HOT 6
- Support *.mol files HOT 3
- CFOUR molden files HOT 4
- Extract some information from results of `opt` and `scrf` Gaussian jobs HOT 4
- 2-electron reduced density matrices HOT 14
- PDB load_one issue with atom type CL HOT 5
- Compute electronic energy/gradient(force) in IOData
- Input writers for other quantum chemistry software HOT 2
- Install issue on Windows HOT 2
- Can I trust IOData for handling molden files generated from PySCF HOT 2
- Rename some fields read from PDB, to be more in line with PDB conventions HOT 3
- AttributeError: module 'numpy' has no attribute 'int'
- Scipy Factorial2 change HOT 4
- Issues related to factorial2 function HOT 1
- Can't install on macos with M1 HOT 3
- Computing Center of Mass HOT 3
- Support GPAW HOT 2
- Python 3.9 Numpy 1.20 Depreciation: np.int, np.float HOT 7
- Fix Factorial2 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iodata.