-
Notifications
You must be signed in to change notification settings - Fork 19
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
Comparison operators for PwAff #115
base: main
Are you sure you want to change the base?
Conversation
:return: self <= other | ||
""" | ||
if isinstance(other, int): | ||
return self.le_set(self * 0 + other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be a better way to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero = Aff.zero_on_domain(LocalSpace.from_space(space))
result[0] = PwAff.from_aff(zero)
PwAff.__le__ = pw_le | ||
PwAff.__lt__ = pw_lt | ||
PwAff.__ge__ = pw_ge | ||
PwAff.__gt__ = pw_gt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One issue with this is that it can't extend to ==
and !=
. I wonder whether that invalidates the idea...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. This is a problem for eg: SymPy where ==
and !=
are structural equivalence and Eq
gives an expression. Numpy however is consistent and implements ==
and !=
and returns a numpy array of bools.
PwAff.__lt__ = pw_lt | ||
PwAff.__ge__ = pw_ge | ||
PwAff.__gt__ = pw_gt | ||
PwAff.__bool__ = pw_bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to override __bool__
on Set
.
:return: self <= other | ||
""" | ||
if isinstance(other, int): | ||
return self.le_set(self * 0 + other) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zero = Aff.zero_on_domain(LocalSpace.from_space(space))
result[0] = PwAff.from_aff(zero)
No description provided.