def pack_binomial(value): value = ''.join(c for c in value if c in set('1234567890.-+K')) K = 0 C = 0 sgn = 1 for k, g in ((k, ''.join(g)) for k, g in groupby( value, key=lambda v: True if v in ('+', '-') else False)): if k: if g.count('-') % 2: sgn = -1 else: sgn = 1 else: if 'K' in g: if g[0] == 'K': coefficient = 1 else: coefficient = interpret_int(g[:g.find('K')]) K += coefficient * sgn else: constant = interpret_float(g) C += constant * sgn if K < 0: SIGN = -1 K = abs(K) else: SIGN = 1 return C, SIGN, K
def pack_binomial(value): value = "".join(c for c in value if c in set("1234567890.-+K")) K = 0 C = 0 sgn = 1 for k, g in ((k, "".join(g)) for k, g in groupby(value, key=lambda v: True if v in ("+", "-") else False)): if k: if g.count("-") % 2: sgn = -1 else: sgn = 1 else: if "K" in g: if g[0] == "K": coefficient = 1 else: coefficient = interpret_int(g[: g.find("K")]) K += coefficient * sgn else: constant = interpret_float(g) C += constant * sgn if K < 0: SIGN = -1 K = abs(K) else: SIGN = 1 return C, SIGN, K
def interpret_enumeration(e): if type(e) is set: return e else: return set( interpret_int(val) for val in e.split(',') if any(c in '0123456789' for c in val))
def pack_binomial(value): value = ''.join(c for c in value if c in set('1234567890.-+K')) K = 0 C = 0 sgn = 1 for k, g in ( (k, ''.join(g)) for k, g in groupby(value, key=lambda v: True if v in ('+', '-') else False) ): if k: if g.count('-') % 2: sgn = -1 else: sgn = 1 else: if 'K' in g: if g[0] == 'K': coefficient = 1 else: coefficient = interpret_int(g[:g.find('K')]) K += coefficient*sgn else: constant = interpret_float(g) C += constant*sgn if K < 0: SIGN = -1 K = abs(K) else: SIGN = 1 return C, SIGN, K
def __init__(self, KT, attrs, content=None): self.mode = attrs['mode'] self.H = interpret_int(attrs['h']) self.K = interpret_int(attrs['k']) self.Hc = interpret_int(attrs['hc']) self.Kc = interpret_int(attrs['kc']) self._displacement = 0, 0 self._zoom_levels = 0.1, 0.13, 0.15, 0.2, 0.22, 0.3, 0.4, 0.5, 0.6, 0.8, 0.89, 1, 1.25, 1.5, 1.75, 1.989, 2, 2.5, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 20, 30 self.zoom_level = interpret_int(attrs['zoom']) self.A = self._zoom_levels[self.zoom_level] self.KT = KT
def assign(self, A, S): if A == 'page': self.page = interpret_int(S) self.KT.BODY.layout_all()
def interpret_enumeration(e): if type(e) is set: return e else: return set(interpret_int(val) for val in e.split(",") if any(c in "0123456789" for c in val))
def __init__(self, KT, attrs, content=None): self.__orig_info = (interpret_int(attrs['section']), interpret_int(attrs['frame'])) self.KT = KT