Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing property is_rational #369

Closed
mzaffalon opened this issue Aug 31, 2020 · 3 comments
Closed

Missing property is_rational #369

mzaffalon opened this issue Aug 31, 2020 · 3 comments

Comments

@mzaffalon
Copy link
Contributor

mzaffalon commented Aug 31, 2020

It looks like is_rational is not set for certain types on master

julia> x = Sym(2.5)
2.50000000000000

julia> SymPy.pycall_hasproperty(x, :is_rational)
true

julia> isnothing(x.__pyobject__.is_rational)
true

This leads to the following error:

julia> N(x, 256)
ERROR: TypeError: non-boolean (Nothing) used in boolean context
Stacktrace:
 [1] N(::Sym, ::Int64; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\michele.zaffalon\.julia\packages\SymPy\yYD8e\src\numbers.jl:286
 [2] N(::Sym, ::Int64) at C:\Users\michele.zaffalon\.julia\packages\SymPy\yYD8e\src\numbers.jl:277
 [3] top-level scope at REPL[20]:1

I forgot most of my Python, but it looks like sympy also fails to set the property correctly. Would in this case make sense e.g. in

SymPy.jl/src/numbers.jl

Lines 53 to 54 in 382a805

function is_rational(x::Sym)
pycall_hasproperty(x, :is_rational) && return x.is_rational
, to return

pycall_hasproperty(x, :is_rational) && return (isnothing(x.is_rational) ? false : x.is_rational)
@jverzani
Copy link
Collaborator

Yes, that seems to make sense. I'll try to put in a PR when I get a chance. Thanks!

@mzaffalon
Copy link
Contributor Author

Do you mind if I take a stab at it?

jverzani added a commit to jverzani/SymPy.jl that referenced this issue Aug 31, 2020
@jverzani
Copy link
Collaborator

jverzani commented Aug 31, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants