File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -137,10 +137,10 @@ def __ge__(self, other) -> bool:
137137 return self .get_sort_key () >= other .get_sort_key ()
138138
139139 def __eq__ (self , other ) -> bool :
140- return self .get_sort_key () == other .get_sort_key ()
140+ return hasattr ( other , "get_sort_key" ) and self .get_sort_key () == other .get_sort_key ()
141141
142142 def __ne__ (self , other ) -> bool :
143- return self .get_sort_key () != other .get_sort_key ()
143+ return ( not hasattr ( other , "get_sort_key" )) or self .get_sort_key () != other .get_sort_key ()
144144
145145
146146# ExpressionCache keeps track of the following attributes for one Expression instance:
@@ -2635,7 +2635,10 @@ def __new__(cls, value):
26352635 self = super (StringFromPython , cls ).__new__ (cls , value )
26362636 if isinstance (value , sympy .NumberSymbol ):
26372637 self .value = "sympy." + str (value )
2638- elif value == math .inf :
2638+
2639+ # Note that the test is done with math.inf first.
2640+ # This is to use float's ==, which may not strictly be necessary.
2641+ if math .inf == value :
26392642 self .value = "math.inf"
26402643 return self
26412644
You can’t perform that action at this time.
0 commit comments