Download ScaleDF_rebuttal/python_dedup_pkgs/sympy/sets/setexpr.py from VideoUFO/ResearchData_P1: direct link, hf CLI and curl.
- Browser
- Download file 3.02 kB
-
https://huggingface.co/datasets/VideoUFO/ResearchData_P1/resolve/main/ScaleDF_rebuttal/python_dedup_pkgs/sympy/sets/setexpr.py
- Command line
-
hf download hf://datasets/VideoUFO/ResearchData_P1/ScaleDF_rebuttal/python_dedup_pkgs/sympy/sets/setexpr.py
-
curl -L -o setexpr.py https://huggingface.co/datasets/VideoUFO/ResearchData_P1/resolve/main/ScaleDF_rebuttal/python_dedup_pkgs/sympy/sets/setexpr.py
3.02 kB
| from sympy.core import Expr | |
| from sympy.core.decorators import call_highest_priority, _sympifyit | |
| from .fancysets import ImageSet | |
| from .sets import set_add, set_sub, set_mul, set_div, set_pow, set_function | |
| class SetExpr(Expr): | |
| """An expression that can take on values of a set. | |
| Examples | |
| ======== | |
| >>> from sympy import Interval, FiniteSet | |
| >>> from sympy.sets.setexpr import SetExpr | |
| >>> a = SetExpr(Interval(0, 5)) | |
| >>> b = SetExpr(FiniteSet(1, 10)) | |
| >>> (a + b).set | |
| Union(Interval(1, 6), Interval(10, 15)) | |
| >>> (2*a + b).set | |
| Interval(1, 20) | |
| """ | |
| _op_priority = 11.0 | |
| def __new__(cls, setarg): | |
| return Expr.__new__(cls, setarg) | |
| set = property(lambda self: self.args[0]) | |
| def _latex(self, printer): | |
| return r"SetExpr\left({}\right)".format(printer._print(self.set)) | |
| def __add__(self, other): | |
| return _setexpr_apply_operation(set_add, self, other) | |
| def __radd__(self, other): | |
| return _setexpr_apply_operation(set_add, other, self) | |
| def __mul__(self, other): | |
| return _setexpr_apply_operation(set_mul, self, other) | |
| def __rmul__(self, other): | |
| return _setexpr_apply_operation(set_mul, other, self) | |
| def __sub__(self, other): | |
| return _setexpr_apply_operation(set_sub, self, other) | |
| def __rsub__(self, other): | |
| return _setexpr_apply_operation(set_sub, other, self) | |
| def __pow__(self, other): | |
| return _setexpr_apply_operation(set_pow, self, other) | |
| def __rpow__(self, other): | |
| return _setexpr_apply_operation(set_pow, other, self) | |
| def __truediv__(self, other): | |
| return _setexpr_apply_operation(set_div, self, other) | |
| def __rtruediv__(self, other): | |
| return _setexpr_apply_operation(set_div, other, self) | |
| def _eval_func(self, func): | |
| # TODO: this could be implemented straight into `imageset`: | |
| res = set_function(func, self.set) | |
| if res is None: | |
| return SetExpr(ImageSet(func, self.set)) | |
| return SetExpr(res) | |
| def _setexpr_apply_operation(op, x, y): | |
| if isinstance(x, SetExpr): | |
| x = x.set | |
| if isinstance(y, SetExpr): | |
| y = y.set | |
| out = op(x, y) | |
| return SetExpr(out) | |