Skip to content

Commit

Permalink
Merge 725168c into 39db5f5
Browse files Browse the repository at this point in the history
  • Loading branch information
skirpichev committed Apr 17, 2015
2 parents 39db5f5 + 725168c commit a94d48b
Show file tree
Hide file tree
Showing 15 changed files with 721 additions and 707 deletions.
8 changes: 8 additions & 0 deletions sympy/core/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,14 @@ def __str__(self):
from sympy.printing import sstr
return sstr(self, order=None)

def _repr_pretty_(self, p, cycle):
from sympy.printing import pretty
p.text(pretty(self, order=None))

def _repr_latex_(self):
from sympy.printing import latex
return '$$' + latex(self, order=None) + '$$'

def atoms(self, *types):
"""Returns the atoms that form the current object.
Expand Down
2 changes: 1 addition & 1 deletion sympy/core/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class UndefinedFunction(FunctionClass):
The (meta)class of undefined functions.
"""
def __new__(mcl, name, **kwargs):
ret = BasicMeta.__new__(mcl, name, (AppliedUndef,), kwargs)
ret = BasicMeta.__new__(mcl, str(name), (AppliedUndef,), kwargs)
ret.__module__ = None
return ret

Expand Down
4 changes: 2 additions & 2 deletions sympy/core/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
from __future__ import print_function, division

from sympy.core.compatibility import range
from sympy.core.compatibility import range, string_types


def _fuzzy_group(args, quick_exit=False):
Expand Down Expand Up @@ -333,7 +333,7 @@ def _eval_propagate_not(self):
class Not(Logic):

def __new__(cls, arg):
if isinstance(arg, str):
if isinstance(arg, string_types):
return Logic.__new__(cls, arg)

elif isinstance(arg, bool):
Expand Down
8 changes: 4 additions & 4 deletions sympy/core/multidimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from __future__ import print_function, division

from sympy.core.decorators import wraps
from sympy.core.compatibility import range
from sympy.core.compatibility import range, string_types


def apply_on_element(f, args, kwargs, n):
Expand All @@ -19,7 +19,7 @@ def apply_on_element(f, args, kwargs, n):
if isinstance(n, int):
structure = args[n]
is_arg = True
elif isinstance(n, str):
elif isinstance(n, string_types):
structure = kwargs[n]
is_arg = False

Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, *mdargs):
If no argument is given, everything is treated multidimensional.
"""
for a in mdargs:
if not isinstance(a, (int, str)):
if not isinstance(a, (int,) + string_types):
raise TypeError("a is of invalid type")
self.mdargs = mdargs

Expand All @@ -119,7 +119,7 @@ def wrapper(*args, **kwargs):
continue
entry = args[n]
is_arg = True
elif isinstance(n, str):
elif isinstance(n, string_types):
try:
entry = kwargs[n]
except KeyError:
Expand Down
2 changes: 1 addition & 1 deletion sympy/core/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def __new__(cls, num, prec=None):
prec = mlib.libmpf.dps_to_prec(dps)
if isinstance(num, float):
_mpf_ = mlib.from_float(num, prec, rnd)
elif isinstance(num, str):
elif isinstance(num, string_types):
_mpf_ = mlib.from_str(num, prec, rnd)
elif isinstance(num, decimal.Decimal):
_mpf_ = mlib.from_str(str(num), prec, rnd)
Expand Down
4 changes: 2 additions & 2 deletions sympy/polys/orderings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__all__ = ["lex", "grlex", "grevlex", "ilex", "igrlex", "igrevlex"]

from sympy.core import Symbol
from sympy.core.compatibility import iterable
from sympy.core.compatibility import iterable, string_types

class MonomialOrder(object):
"""Base class for monomial orderings. """
Expand Down Expand Up @@ -225,7 +225,7 @@ def monomial_key(order=None, gens=None):
if isinstance(order, Symbol):
order = str(order)

if isinstance(order, str):
if isinstance(order, string_types):
try:
order = _monomial_key[order]
except KeyError:
Expand Down
6 changes: 3 additions & 3 deletions sympy/polys/polyoptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class Wrt(with_metaclass(OptionType, Option)):
def preprocess(cls, wrt):
if isinstance(wrt, Basic):
return [str(wrt)]
elif isinstance(wrt, str):
elif isinstance(wrt, string_types):
wrt = wrt.strip()
if wrt.endswith(','):
raise OptionError('Bad input: missing parameter.')
Expand All @@ -335,7 +335,7 @@ def default(cls):

@classmethod
def preprocess(cls, sort):
if isinstance(sort, str):
if isinstance(sort, string_types):
return [ gen.strip() for gen in sort.split('>') ]
elif hasattr(sort, '__getitem__'):
return list(map(str, sort))
Expand Down Expand Up @@ -705,7 +705,7 @@ class Method(with_metaclass(OptionType, Flag)):

@classmethod
def preprocess(cls, method):
if isinstance(method, str):
if isinstance(method, string_types):
return method.lower()
else:
raise OptionError("expected a string, got %s" % method)
Expand Down
6 changes: 3 additions & 3 deletions sympy/polys/specialpolys.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

from sympy.utilities import subsets, public

from sympy.core.compatibility import range
from sympy.core.compatibility import range, string_types


@public
Expand Down Expand Up @@ -117,10 +117,10 @@ def random_poly(x, n, inf, sup, domain=ZZ, polys=False):
@public
def interpolating_poly(n, x, X='x', Y='y'):
"""Construct Lagrange interpolating polynomial for ``n`` data points. """
if isinstance(X, str):
if isinstance(X, string_types):
X = symbols("%s:%s" % (X, n))

if isinstance(Y, str):
if isinstance(Y, string_types):
Y = symbols("%s:%s" % (Y, n))

coeffs = []
Expand Down
Loading

0 comments on commit a94d48b

Please sign in to comment.