@@ -6,7 +6,11 @@ Base.convert(::Type{S}, x::Sym{T}) where {T <: PythonCall.Py, S<:Sym} = x
6
6
Base. convert (:: Type{S} , x:: T ) where {T<: PythonCall.Py , S <: SymbolicObject } = Sym (x)
7
7
8
8
SymPyCore. _convert (:: Type{T} , x) where {T} = pyconvert (T, x)
9
- SymPyCore. _convert (:: Type{Bool} , x) = pyconvert (Bool, pybool (x))
9
+ function SymPyCore. _convert (:: Type{Bool} , x:: Py )
10
+ pyconvert (Bool, x == _sympy_. logic. boolalg. BooleanTrue) && return true
11
+ pyconvert (Bool, x == _sympy_. logic. boolalg. BooleanFalse) && return false
12
+ pyconvert (Bool, pybool (x))
13
+ end
10
14
11
15
12
16
# # Modifications for ↓, ↑
@@ -53,42 +57,39 @@ function Base.getproperty(x::SymbolicObject{T}, a::Symbol) where {T <: PythonCal
53
57
Base. depwarn (" The field `.py` has been renamed `.o`" , :getproperty )
54
58
return getfield (x,:o )
55
59
end
60
+
56
61
val = ↓ (x)
57
- if hasproperty (val, a)
58
- meth = getproperty (val, a)
62
+ ! hasproperty (val, a) && return nothing # not a property
59
63
60
- pyconvert (Bool, meth == pybuiltins . None) && return nothing
64
+ meth = getproperty (val, a)
61
65
62
- if hasproperty (meth, " is_Boolean" )
63
- o = Sym (getproperty (meth, " is_Boolean" ))
64
- o == Sym (true ) && return true
65
- a == :is_Boolean && return o == Sym (False) ? false : nothing
66
+ pyconvert (Bool, meth == pybuiltins. None) && return nothing
67
+
68
+ if hasproperty (meth, " is_Boolean" )
69
+ if pyconvert (Bool, meth. is_Boolean == true )
70
+ return meth == _sympy_. logic. boolalg. BooleanFalse
66
71
end
72
+ end
67
73
68
- # __class__ dispath
69
- if hasproperty (meth, :__class__ )
70
- cnm = string (meth. __class__. __name__)
71
- if cnm == " bool"
72
- a = Sym (meth)
73
- return a == Sym (true ) ? true :
74
- a == Sym (false ) ? false : nothing
75
- end
76
- if cnm == " module"
77
- # treat modules, callsm others differently
78
- return Sym (meth)
79
- end
74
+ # __class__ dispatch
75
+ if hasproperty (meth, :__class__ )
76
+ cnm = string (meth. __class__. __name__)
77
+ if cnm == " bool"
78
+ return pyconvert (Bool, meth)
80
79
end
81
- # # __function__
82
- if hasproperty (meth, " __call__" )
83
- # meth = getproperty(meth, "__call__")
84
- return SymPyCore. SymbolicCallable (meth)
80
+ if cnm == " module"
81
+ # treat modules, callsm others differently
82
+ return Sym (meth)
85
83
end
84
+ end
86
85
87
- return ↑ (convert (PythonCall. Py, meth))
88
-
86
+ # # __call__
87
+ if hasproperty (meth, " __call__" )
88
+ return SymPyCore. SymbolicCallable (meth)
89
89
end
90
- # not a property; should this error
91
- return nothing
90
+
91
+ return ↑ (convert (PythonCall. Py, meth))
92
+
92
93
end
93
94
94
95
0 commit comments