Implemented crisscross algorithm for solving LP problems.
[sympycore.git] / sympycore / heads / special.py
blob3687151a06f1cb0ff055d8df7855fcc75869c2bb
2 from .base import AtomicHead, heads_precedence, Expr
4 import re
5 _is_atomic = re.compile(r'\A\w+\Z').match
7 class SpecialHead(AtomicHead):
8 """
9 SpecialHead is head for special objects like None, NotImplemented,
10 Ellipsis, etc. Data can be any Python object.
11 """
13 def __repr__(self): return 'SPECIAL'
15 def data_to_str_and_precedence(self, cls, data):
16 if isinstance(data, Expr):
17 h, d = data.pair
18 return h.data_to_str_and_precedence(cls, d)
19 if data is Ellipsis:
20 return '...', heads_precedence.SYMBOL
22 s = str(data)
23 if _is_atomic(s):
24 return s, heads_precedence.SYMBOL
25 return s, 0.0 # force parenthesis
27 SPECIAL = SpecialHead()