Skip to content
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

Put all printing orderings in one central location #5453

Open
asmeurer opened this issue May 9, 2011 · 9 comments
Open

Put all printing orderings in one central location #5453

asmeurer opened this issue May 9, 2011 · 9 comments

Comments

@asmeurer
Copy link
Member

asmeurer commented May 9, 2011

$./bin/isympy -o notarealordering
IPython console for SymPy 0.6.7-git (Python 2.7.1) (ground types: gmpy)

These commands were executed:
>>> from __future__ import division
>>> from sympy import *
>>> x, y, z, t = symbols('x y z t')
>>> k, m, n = symbols('k m n', integer=True)
>>> f, g, h = symbols('f g h', cls=Function)

Documentation can be found at http://www.sympy.org In [1]: x**2 + 1
Out[1]: ---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/<ipython console> in <module>()

/sw/lib/python2.7/site-packages/IPython/Prompts.pyc in __call__(self, arg)
    550 
    551             # and now call a possibly user-defined print mechanism

--> 552             manipulated_val = self.display(arg)
    553 
    554             # user display hooks can change the variable to be stored in


/sw/lib/python2.7/site-packages/IPython/Prompts.pyc in _display(self, arg)
    576             return IPython.generics.result_display(arg)
    577         except TryNext:
--> 578             return self.shell.hooks.result_display(arg)
    579 
    580     # Assign the default display method:


/sw/lib/python2.7/site-packages/IPython/hooks.pyc in __call__(self, *args, **kw)
    139             #print "prio",prio,"cmd",cmd #dbg

    140             try:
--> 141                 ret = cmd(*args, **kw)
    142                 return ret
    143             except ipapi.TryNext, exc:

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/interactive/printing.pyc in result_display(self, arg)
     32         """
     33         if self.rc.pprint:
---> 34             out = stringify_func(arg)
     35 
     36             if '\n' in out:

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/pretty/pretty.pyc in pretty(expr, **settings)
    864 
    865     try:
--> 866         return pp.doprint(expr)
    867     finally:
    868         pretty_use_unicode(uflag)

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/pretty/pretty.pyc in doprint(self, expr)
     36 
     37     def doprint(self, expr):
---> 38         return self._print(expr).render(**self._settings)
     39 
     40     # empty op so _print(stringPict) returns the same


/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/printer.pyc in _print(self, expr, *args)
    246                 printmethod = '_print_' + cls.__name__
    247                 if hasattr(self, printmethod):
--> 248                     return getattr(self, printmethod)(expr, *args)
    249 
    250             # Unknown object, fall back to the emptyPrinter.


/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/pretty/pretty.pyc in _print_Add(self, expr, order)
    497 
    498     def _print_Add(self, expr, order=None):
--> 499         terms = self._as_ordered_terms(expr, order=order)
    500         pforms, indices = [], []
    501 

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/printing/printer.pyc in _as_ordered_terms(self, expr, order)
    259         if order is None:
    260             return sorted(Add.make_args(expr), Basic._compare_pretty)
    261         else:
--> 262             return expr.as_ordered_terms(order=order)
    263 

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/core/expr.pyc in as_ordered_terms(self, order, data)
    254         from sympy.utilities import any
    255 
--> 256         key, reverse = self._parse_order(order)
    257         terms, gens = self.as_terms()
    258 

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/core/expr.pyc in _parse_order(cls, order)
    212                 order = order[4:]
    213 
--> 214         monom_key = monomial_key(order)
    215 
    216         def key(term):

/Users/aaronmeurer/Documents/python/sympy/sympy-scratch/sympy/polys/monomialtools.pyc in monomial_key(order)
    127             return _monomial_key[order]
    128         except KeyError:
--> 129             raise ValueError("supported monomial orderings are 'lex', 'grlex' and 'grevlex', got %r" % order)
    130     elif hasattr(order, '__call__'):
    131         return order

ValueError: supported monomial orderings are 'lex', 'grlex' and 'grevlex', got 'notarealordering'


isympy should give an error straightway about this.  There should be one unified list of allowable ordering somewhere that all the various things can check against, to make it easier if we decide to add any new orderings.

Original issue for #5453: http://code.google.com/p/sympy/issues/detail?id=2354
Original author: https://code.google.com/u/asmeurer@gmail.com/
Original owner: https://code.google.com/u/101069955704897915480/

@asmeurer
Copy link
Member Author

asmeurer commented May 9, 2011

**Blocking:** 4590  

Referenced issues: #4590
Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c1
Original author: https://code.google.com/u/asmeurer@gmail.com/

@asmeurer
Copy link
Member Author

asmeurer commented May 9, 2011

By the way, regarding the above error message, why is revlex not supported?

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c2
Original author: https://code.google.com/u/asmeurer@gmail.com/

@asmeurer
Copy link
Member Author

asmeurer commented May 9, 2011

**Cc:** matt...@gmail.com  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c3
Original author: https://code.google.com/u/asmeurer@gmail.com/

@mattpap
Copy link
Member

mattpap commented May 9, 2011

Yes, it should be done by isympy. There are rev-orderings, e.g.:

mateusz@hpfem-2:~/repo/git/sympy$ bin/isympy -q -o rev-lex
IPython console for SymPy 0.6.7-git (Python 2.6.6) (ground types: python)

In [1]: x**2 + 1
Out[1]: 
     2
1 + x 

You just need to use dash, e.g. rev-lex, rev-grlex. I don't mind to support reversed orderings that names don't include dash. I did it this way, because orderings are defined in sympy.polys, but reversed orderings are only for printing purpose and are defined (parsed) in sympy.printing.

**Status:** Started  
**Owner:** matt...@gmail.com  
**Cc:** -matt...@gmail.com  
**Labels:** mattpap  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c4
Original author: https://code.google.com/u/101069955704897915480/

@asmeurer
Copy link
Member Author

asmeurer commented May 9, 2011

I gues what I meant wasy, why don't the monomials support reverse orderings?

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c5
Original author: https://code.google.com/u/asmeurer@gmail.com/

@asmeurer
Copy link
Member Author

This isn't really blocking the release (though you can still fix it by then if you want). Issue 1491 is blocking the release, though, so if that requires this, then I guess it will have to be done.

**Labels:** -Milestone-Release0.7.0 -mattpap  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c6
Original author: https://code.google.com/u/asmeurer@gmail.com/

@mattpap
Copy link
Member

mattpap commented May 23, 2011

Pull request is here: https://github.com/sympy/sympy/pull/348

**Labels:** Milestone-Release0.7.0 NeedsReview  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c7
Original author: https://code.google.com/u/101069955704897915480/

@asmeurer
Copy link
Member Author

This was pushed in.

As was mentioned on the pull request, I am leaving this open because we need to centralize the location of all the orderings (to make it easier to extend).  Also, the error message from the OP should use that list (currently it doesn't even list all of them).

**Summary:** Put all printing orderings in one central location  
**Labels:** -Milestone-Release0.7.0 -NeedsReview PassedReview  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c8
Original author: https://code.google.com/u/asmeurer@gmail.com/

@asmeurer
Copy link
Member Author

**Blocking:** -1491  

Original comment: http://code.google.com/p/sympy/issues/detail?id=2354#c9
Original author: https://code.google.com/u/asmeurer@gmail.com/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants