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
Piecewise: added as_expr_set_pair property #2859
Conversation
Can the name be |
Matthew is working on creating |
Can anyone else give a +1 on this? It seems ok to me. |
@@ -508,6 +508,16 @@ def __eval_cond(cls, cond): | |||
return diff.is_zero | |||
return None | |||
|
|||
@property | |||
def as_expr_set_pair(cls, input_set=S.UniversalSet): |
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.
why do you use a parameter in a property function? Shouldn't you just set U = S.UniversalSet
below?
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.
Sorry, this rose out of some confusion in my mind. I have removed it.
This looks reasonable to me. I might add an |
@@ -508,6 +508,16 @@ def __eval_cond(cls, cond): | |||
return diff.is_zero | |||
return None | |||
|
|||
@property | |||
def as_expr_set_pair(cls): |
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.
why as_expr_set_pair is a property, but as_set isn't?
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.
The first argument should be self
, not cls
. Only use cls
on classmethod (meaning __new__
or anything with a @classmethod
decorator).
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.
why as_expr_set_pair is a property, but as_set isn't?
Yes, maybe as_set
should also have been a property. Shall I correct it ?
Yes please add an |
I have made the recommended changes. |
I don't think it should be a property. All the other |
I removed |
Will merge in 24hr |
Piecewise: added as_expr_set_pair property
This came up in the discussion at https://groups.google.com/forum/#!topic/sympy/x7IgsNoofNE.
This method will be useful in general while handling
Piecewise
functions. A few examples can beplot
cannot plot even simple Piecewise functions likePiecewise((x, x > 0), (-x, True))
Piecewise(((x - 2)**2, x >= 0), (0, True))
. See line 305sympy.functions.elementary.tests.test_piecewise