Hello,
Is there a way I could configure NumPy or SymPy so that NumPy functions
would accept SymPy numbers (e.g. sympy.Rational)?
For example:
>>> import numpy as np
>>> import sympy
>>> np.linspace(0, sympy.Rational(1,2), 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<__array_function__ internals>", line 180, in linspace
File
"C:\Users\idank\mambaforge\lib\site-packages\numpy\core\function_base.py",
line 130, in linspace
dt = result_type(start, stop, float(num))
File "<__array_function__ internals>", line 180, in result_type
TypeError: Cannot interpret '0.500000000000000' as a data type
>>> np.isnan(sympy.Rational(1,2))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ufunc 'isnan' not supported for the input types, and the inputs
could not be safely coerced to any supported types according to the casting
rule ''safe''
Background:
I'm using IPython+SymPy+NumPy as a calculator.
For convenience, I automatically convert all divisions and floats to
sympy.Rational
(and display results both as fractions and as decimals)
After such conversions stuff like np.log(2.33) fails.
For more details, see - https://github.com/idanpa/calcpy
(SymPy version 1.12, NumPy version 1.25.1)
Thanks!
Idan
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/208b8d87-9e7b-4fe9-86fc-9575a0b57002n%40googlegroups.com.