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
Implementing Sequences #9435
Implementing Sequences #9435
Changes from 18 commits
2589a69
60b993c
c1fe967
60c2473
1ef88b9
1e67431
4787dba
388b544
cf0716d
1df4a2b
f912eb9
5b2e257
1380f33
e871dd1
4a0fc91
fc945ee
72c60c4
94f46c5
801f752
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
import warnings | ||
import io | ||
|
||
from sympy import Basic, S, symbols, sqrt, sin, oo, Interval, exp | ||
from sympy import Basic, S, symbols, sqrt, sin, oo, Interval, exp, Lambda | ||
from sympy.core.compatibility import range | ||
from sympy.utilities.pytest import XFAIL, SKIP | ||
from sympy.utilities.exceptions import SymPyDeprecationWarning | ||
|
@@ -240,7 +240,6 @@ def test_sympy__core__function__Function(): | |
|
||
|
||
def test_sympy__core__function__Lambda(): | ||
from sympy.core.function import Lambda | ||
assert _test_args(Lambda((x, y), x + y + z)) | ||
|
||
|
||
|
@@ -498,7 +497,7 @@ def test_sympy__sets__fancysets__Reals(): | |
|
||
def test_sympy__sets__fancysets__ImageSet(): | ||
from sympy.sets.fancysets import ImageSet | ||
from sympy import S, Lambda, Symbol | ||
from sympy import S, Symbol | ||
x = Symbol('x') | ||
assert _test_args(ImageSet(Lambda(x, x**2), S.Naturals)) | ||
|
||
|
@@ -2065,7 +2064,7 @@ def test_sympy__matrices__expressions__determinant__Determinant(): | |
|
||
def test_sympy__matrices__expressions__funcmatrix__FunctionMatrix(): | ||
from sympy.matrices.expressions.funcmatrix import FunctionMatrix | ||
from sympy import Lambda, symbols | ||
from sympy import symbols | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here. |
||
i, j = symbols('i,j') | ||
assert _test_args(FunctionMatrix(3, 3, Lambda((i, j), i - j) )) | ||
|
||
|
@@ -3006,6 +3005,52 @@ def test_sympy__series__order__Order(): | |
assert _test_args(Order(1, x, y)) | ||
|
||
|
||
@SKIP('Abstract Class') | ||
def test_sympy__series__sequences__SeqBase(): | ||
pass | ||
|
||
|
||
def test_sympy__series__sequences__EmptySequence(): | ||
from sympy.series.sequences import EmptySequence | ||
assert _test_args(EmptySequence()) | ||
|
||
|
||
@SKIP('Abstract Class') | ||
def test_sympy__series__sequences__SeqExpr(): | ||
pass | ||
|
||
|
||
def test_sympy__series__sequences__SeqPer(): | ||
from sympy.series.sequences import SeqPer | ||
assert _test_args(SeqPer((1, 2, 3), (0, 10))) | ||
|
||
|
||
def test_sympy__series__sequences__SeqFormula(): | ||
from sympy.series.sequences import SeqFormula | ||
assert _test_args(SeqFormula(x**2, (0, 10))) | ||
|
||
|
||
def test_sympy__series__sequences__SeqExprOp(): | ||
from sympy.series.sequences import SeqExprOp, sequence | ||
s1 = sequence((1, 2, 3)) | ||
s2 = sequence(x**2) | ||
assert _test_args(SeqExprOp(s1, s2)) | ||
|
||
|
||
def test_sympy__series__sequences__SeqAdd(): | ||
from sympy.series.sequences import SeqAdd, sequence | ||
s1 = sequence((1, 2, 3)) | ||
s2 = sequence(x**2) | ||
assert _test_args(SeqAdd(s1, s2)) | ||
|
||
|
||
def test_sympy__series__sequences__SeqMul(): | ||
from sympy.series.sequences import SeqMul, sequence | ||
s1 = sequence((1, 2, 3)) | ||
s2 = sequence(x**2) | ||
assert _test_args(SeqMul(s1, s2)) | ||
|
||
|
||
def test_sympy__simplify__hyperexpand__Hyper_Function(): | ||
from sympy.simplify.hyperexpand import Hyper_Function | ||
assert _test_args(Hyper_Function([2], [1])) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1496,7 +1496,6 @@ def _print_Complement(self, u): | |
parenthesize=lambda set: set.is_ProductSet or set.is_Intersection | ||
or set.is_Union) | ||
|
||
|
||
def _print_ImageSet(self, ts): | ||
if self._use_unicode: | ||
inn = u("\N{SMALL ELEMENT OF}") | ||
|
@@ -1518,6 +1517,28 @@ def _print_Contains(self, e): | |
else: | ||
return prettyForm(sstr(e)) | ||
|
||
def _print_SeqFormula(self, s): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will cause issues
Well that's because it is abstract class, and doesn't have all the methods. So, I think I will need to define printers explicitly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But no one should ever be creating instances of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well from user point of view it should never occur. But from a developer point of view, it will become a headache if everytime you initialize There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The solution to this is not to use |
||
if self._use_unicode: | ||
dots = u("\N{HORIZONTAL ELLIPSIS}") | ||
else: | ||
dots = '...' | ||
|
||
if s.start is S.NegativeInfinity: | ||
stop = s.stop | ||
printset = (dots, s.coeff(stop - 3), s.coeff(stop - 2), | ||
s.coeff(stop - 1), s.coeff(stop)) | ||
elif s.stop is S.Infinity or s.length > 4: | ||
printset = s[:4] | ||
printset.append(dots) | ||
printset = tuple(printset) | ||
else: | ||
printset = tuple(s) | ||
return self._print_list(printset) | ||
|
||
_print_SeqPer = _print_SeqFormula | ||
_print_SeqAdd = _print_SeqFormula | ||
_print_SeqMul = _print_SeqFormula | ||
|
||
def _print_seq(self, seq, left=None, right=None, delimiter=', ', | ||
parenthesize=lambda x: False): | ||
s = None | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ | |
from .gruntz import gruntz | ||
from .series import series | ||
from .residues import residue | ||
from .sequences import (EmptySequence, SeqPer, SeqFormula, sequence, SeqAdd, | ||
SeqMul) | ||
|
||
O = Order | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you delete this, instead of adding your stuff to it? This controls what's actually imported from the submodules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, a mistake on my part. Will fix this in my next commit. |
||
|
||
__all__ = ['gruntz', 'limit', 'series', 'O', 'Order', 'Limit', "residue"] | ||
__all__ = ['Order', 'O', 'limit', 'Limit', 'gruntz', 'series', 'residue', | ||
'EmptySequence', 'SeqPer', 'SeqFormula', 'sequence', | ||
'SeqAdd', 'SeqMul'] |
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.
Perhaps symbols are already imported above, you can use that.
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.
I needed to import
Lambda
, which was imported multiple times already. So, I took it out. Well, I will try to cleanup other imports as well. 👍