Buckets:
MisterAI/LocalAI_Demo_backends / cpu-diffusers.upgrade-tmp /venv /lib /python3.10 /site-packages /sympy /sets /setexpr.py
| 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) | |
Xet Storage Details
- Size:
- 3.02 kB
- Xet hash:
- f7f49bfc91a97cae9520023b434625d798dccf39032415a0025397f1d40c204d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.