def local_print_mode(obj, print_options, pos = None, ram_name = None): r""" Context manager for safely temporarily changing the print_mode of a p-adic ring/field. EXAMPLES:: sage: R = Zp(5) sage: R(45) 4*5 + 5^2 + O(5^21) sage: with local_print_mode(R, 'val-unit'): ....: print(R(45)) 5 * 9 + O(5^21) NOTES:: For more documentation see localvars in parent_gens.pyx """ if isinstance(print_options, str): print_options = {'mode': print_options} elif not isinstance(print_options, dict): raise TypeError("print_options must be a dictionary or a string") if pos is not None: print_options['pos'] = pos if ram_name is not None: print_options['ram_name'] = ram_name for option in ['mode', 'pos', 'ram_name', 'unram_name', 'var_name', 'max_ram_terms', 'max_unram_terms', 'max_terse_terms', 'sep', 'alphabet']: if option not in print_options: print_options[option] = obj._printer.dict()[option] return pAdicPrinter(obj, print_options)
def local_print_mode(obj, print_options, pos = None, ram_name = None): r""" Context manager for safely temporarily changing the print_mode of a p-adic ring/field. EXAMPLES:: sage: R = Zp(5) sage: R(45) 4*5 + 5^2 + O(5^21) sage: with local_print_mode(R, 'val-unit'): ... print R(45) ... 5 * 9 + O(5^21) NOTES:: For more documentation see localvars in parent_gens.pyx """ if isinstance(print_options, str): print_options = {'mode': print_options} elif not isinstance(print_options, dict): raise TypeError, "print_options must be a dictionary or a string" if pos is not None: print_options['pos'] = pos if ram_name is not None: print_options['ram_name'] = ram_name for option in ['mode', 'pos', 'ram_name', 'unram_name', 'var_name', 'max_ram_terms', 'max_unram_terms', 'max_terse_terms', 'sep', 'alphabet']: if not print_options.has_key(option): print_options[option] = obj._printer.dict()[option] return pAdicPrinter(obj, print_options)
def __init__(self, base, p, prec, print_mode, names, element_class, category=None): """ Initialization. INPUT: - base -- Base ring. - p -- prime - print_mode -- dictionary of print options - names -- how to print the uniformizer - element_class -- the class for elements of this ring EXAMPLES:: sage: R = Zp(17) #indirect doctest """ if category is None: if self.is_field(): category = Fields() else: category = PrincipalIdealDomains() category = category.Metric().Complete() LocalGeneric.__init__(self, base, prec, names, element_class, category) self._printer = pAdicPrinter(self, print_mode)
def __init__(self, base, p, prec, print_mode, names, element_class): """ Initialization. INPUTS:: - base -- Base ring. - p -- prime - print_mode -- dictionary of print options - names -- how to print the uniformizer - element_class -- the class for elements of this ring EXAMPLES:: sage: R = Zp(17) #indirect doctest """ LocalGeneric.__init__(self, base, prec, names, element_class) self._printer = pAdicPrinter(self, print_mode)
def local_print_mode(obj, print_options, pos=None, ram_name=None): r""" Context manager for safely temporarily changing the print_mode of a p-adic ring/field. EXAMPLES:: sage: R = Zp(5) sage: R(45) 4*5 + 5^2 + O(5^21) sage: with local_print_mode(R, 'val-unit'): ... print R(45) ... 5 * 9 + O(5^21) NOTES:: For more documentation see localvars in parent_gens.pyx """ if isinstance(print_options, str): print_options = {"mode": print_options} elif not isinstance(print_options, dict): raise TypeError, "print_options must be a dictionary or a string" if pos is not None: print_options["pos"] = pos if ram_name is not None: print_options["ram_name"] = ram_name for option in [ "mode", "pos", "ram_name", "unram_name", "var_name", "max_ram_terms", "max_unram_terms", "max_terse_terms", "sep", "alphabet", ]: if not print_options.has_key(option): print_options[option] = obj._printer.dict()[option] return pAdicPrinter(obj, print_options)
def __init__(self, base, p, prec, print_mode, names, element_class, category=None): """ Initialization. INPUTS:: - base -- Base ring. - p -- prime - print_mode -- dictionary of print options - names -- how to print the uniformizer - element_class -- the class for elements of this ring EXAMPLES:: sage: R = Zp(17) #indirect doctest """ if category is None: if self.is_field(): category = Fields() else: category = PrincipalIdealDomains() LocalGeneric.__init__(self, base, prec, names, element_class, category) self._printer = pAdicPrinter(self, print_mode)