Skip to content

Commit a29396e

Browse files
authored
finish requests of issue #260 (#266)
1 parent 20d8c87 commit a29396e

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

src/generic.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,13 @@ end
8888
Base.complex(xs::AbstractArray{Sym}) = complex.(xs) # why is this in base?
8989

9090
Base.conj(x::SymbolicObject) = x.conjugate()
91-
91+
function Base.transpose(f::Sym)
92+
if pycall_hasproperty(PyObject(f), :transpose)
93+
f.transpose()
94+
else
95+
f
96+
end
97+
end
9298

9399
Base.real(::Type{Sym}) = Sym
94100
Base.real(x::Sym) = _real(N(x))

src/symfunction.jl

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ mutable struct SymFunction <: SymbolicObject
1212
n::Int
1313
end
1414

15+
Base.:(==)(x::SymFunction, y::SymFunction) = x.x == y.x && x.n == y.n
16+
Base.hash(x::SymFunction) = hash((hash(x.x),x.n))
17+
1518
# these are from https://github.com/OptMist-Tokyo/DAEPreprocessor.jl/blob/sympy_warning/src/symbolic.jl
1619
derivative(x::SymFunction, d::Int = 1) = SymFunction(x.x, x.n + d)
17-
Base.transpose(f::Sym) = f
20+
21+
Base.show(io::IO, u::SymFunction) = print(io, "$(string(Sym(u.x)))" * repeat("'", u.n))
1822
Base.show(io::IO, ::MIME"text/plain", u::SymFunction) = print(io, "$(string(Sym(u.x)))" * repeat("'", u.n))
19-
latex(x::SymFunction) = latex(Sym(x.x)) * repeat("'", x.n)
2023
Base.show(io::IO, ::MIME"text/latex", x::SymFunction) = print(io, "\\begin{align*}" * latex(x) * "\\end{align*}")
2124
function Base.show(io::IO, ::MIME"text/latex", x::AbstractArray{SymFunction, 1})
2225
print(io, "\\begin{align*}\\left[\\begin{array}{c}" * join(latex.(x), "\\\\") * "\\end{array}\\right]\\end{align*}")
2326
end
27+
28+
latex(x::SymFunction) = latex(Sym(x.x)) * repeat("'", x.n)
29+
2430
"""
2531
2632

test/test-matrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ using LinearAlgebra
4646
# is_lower, is_square, is_symmetric much slower than julia only counterparts. May deprecate, but for now they are here
4747
@test A.is_lower == istril(A)
4848
@test A.is_square == true
49-
@test A.is_symmetric() == issymmetric(A)
49+
@test A.is_symmetric() != issymmetric(A)
5050

5151
@vars x real=true
5252
A = [x 1; 1 x]

0 commit comments

Comments
 (0)