jonasrauber / eagerpy

PyTorch, TensorFlow, JAX and NumPy — all of them natively using the same code
https://eagerpy.jonasrauber.de
MIT License
695 stars 40 forks source link

Add basic trigonometric functions #46

Closed JelleAalbers closed 2 years ago

JelleAalbers commented 3 years ago

First of all, thanks for creating this great package!

This PR adds the twelve basic trigonometric functions -- sin, cos, tan, their hyperbolics, inverses, and inverse hyperbolics. Currently eagerpy only has tanh and arctanh.

PyTorch added inverse hyperbolics in 1.6.0 / July 2020. Since eagerpy's test builds still use torch 1.4.0, the implementation falls back to (less numerically stable) implementations in terms of logarithms if needed.

jonasrauber commented 2 years ago

Thanks @JelleAalbers. This looks good. The tests currently fail due to version conflicts. Once I've merged https://github.com/jonasrauber/eagerpy/pull/47 into master, could you update your PR to include these changes (we then test with PyTorch 1.9.0, so you can remove your workaround for inverse hyperbolics)? Looking forward to merging this once the tests pass :)

jonasrauber commented 2 years ago

@JelleAalbers FYI: I just updated PR to include the latest updates from master

codecov[bot] commented 2 years ago

Codecov Report

Merging #46 (b44c0a3) into master (dad71ff) will decrease coverage by 0.10%. The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master      #46      +/-   ##
===========================================
- Coverage   100.00%   99.89%   -0.11%     
===========================================
  Files           16       16              
  Lines         1760     1860     +100     
===========================================
+ Hits          1760     1858      +98     
- Misses           0        2       +2     
Impacted Files Coverage Δ
eagerpy/tensor/tensor.py 100.00% <ø> (ø)
eagerpy/framework.py 100.00% <100.00%> (ø)
eagerpy/tensor/jax.py 100.00% <100.00%> (ø)
eagerpy/tensor/numpy.py 100.00% <100.00%> (ø)
eagerpy/tensor/pytorch.py 100.00% <100.00%> (ø)
eagerpy/tensor/tensorflow.py 100.00% <100.00%> (ø)
eagerpy/tensor/extensions.py 93.10% <0.00%> (-6.90%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dad71ff...b44c0a3. Read the comment docs.