MDAnalysis / transport-analysis

A Python package to compute and analyze transport properties.
https://transport-analysis.readthedocs.io
GNU General Public License v2.0
10 stars 2 forks source link

Refactor tests to use NumPy vectorized operations #26

Open xhgchen opened 1 year ago

xhgchen commented 1 year ago

The characteristic polynomials testing the VelocityAutocorr class and the ViscosityHelfand class use for loops and could benefit from more vectorized operations in NumPy, as explained by @hmacdope i.e. we can set up entire arrays with the values beforehand and then perform the mathematical operations on the entire arrays with NumPy instead of looping through.

This is already done in the actual implementations in each of the classes. It would speed up the tests and potentially improve agreement between the expected test values and the actual implementation.

hmacdope commented 1 year ago

https://blog.paperspace.com/numpy-optimization-vectorization-and-broadcasting/ for a good visual introduction to vectorisaton and broadcasting.