Skip to content

Commit

Permalink
modify real, imag to return Sym not N(...) (#443)
Browse files Browse the repository at this point in the history
* modify real, imag to return Sym not N(...)

* version bump, minor change
  • Loading branch information
jverzani authored Oct 26, 2021
1 parent aeec333 commit baaefe1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SymPy"
uuid = "24249f21-da20-56a4-8eb1-6a02cf4ae2e6"
version = "1.0.53"
version = "1.1.0"

[deps]
CommonEq = "3709ef60-1bee-4518-9f2f-acd86f176c50"
Expand Down
11 changes: 2 additions & 9 deletions src/generic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,8 @@ function Base.transpose(f::Sym)::Sym
end

Base.real(::Type{Sym}) = Sym
Base.real(x::Sym) = _real(N(x))
_real(x::Sym) = sympy.:re(x)
_real(x) = real(x)



Base.imag(x::Sym) = _imag(N(x))
_imag(x::Sym) = sympy.im(x)
_imag(x) = imag(x)
Base.real(x::Sym) = sympy.re(x)
Base.imag(x::Sym) = sympy.im(x)

Base.angle(z::SymPy.SymbolicObject) = atan(sympy.im(z), sympy.re(z))

Expand Down
5 changes: 5 additions & 0 deletions test/test-math.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ using SpecialFunctions
@test simplify(hypot*cos(ϕ), ρ * sin(ϕ))) == ρ
@test simplify(hypot*cos(ϕ), 3)) == sqrt^2*cos(ϕ)^2 + 9)

@test real(sqrt(Sym(5))+im) == sqrt(Sym(5))
@test real(sqrt(Sym(5))+im) isa Sym
@test imag(sqrt(Sym(5))+im) == 1
@test imag(sqrt(Sym(5))+im) isa Sym

@test atan(Sym(1), 1) == PI/4
@test atan(Sym(1), -1) == 3PI/4

Expand Down

2 comments on commit baaefe1

@jverzani
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/47564

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.1.0 -m "<description of version>" baaefe1bb126e3c9db59475312120c82a054e99c
git push origin v1.1.0

Please sign in to comment.