def iterate(**type): '''Iterate through all of the enumerations in the database that match the keyword specified by `type`.''' if not type: type = {'predicate':lambda n: True} res = builtins.list(__iterate__()) for key, value in six.iteritems(type): res = builtins.list(__matcher__.match(key, value, res)) for item in res: yield item
def list(**type): '''List all of the enumerations within the database that match the keyword specified by `type`.''' res = builtins.list(iterate(**type)) maxindex = max(builtins.map(idaapi.get_enum_idx, res) or [1]) maxname = max( builtins.map(utils.fcompose(idaapi.get_enum_name, len), res) or [0]) maxsize = max(builtins.map(size, res) or [0]) cindex = math.ceil(math.log(maxindex or 1) / math.log(10)) try: cmask = max( builtins.map( utils.fcompose( mask, utils.fcondition(utils.fpartial(operator.eq, 0))( utils.fconstant(1), utils.fidentity), math.log, functools.partial(operator.mul, 1.0 / math.log(8)), math.ceil), res) or [database.config.bits() / 4.0]) except: cmask = 0 for n in res: six.print_( "[{:{:d}d}] {:>{:d}s} & {:<{:d}x} ({:d} members){:s}".format( idaapi.get_enum_idx(n), int(cindex), idaapi.get_enum_name(n), maxname, mask(n), int(cmask), len(builtins.list(members(n))), " // {:s}".format(comment(n)) if comment(n) else '')) return
def cardinality(self): """ Returns the number of Lyndon words with the evaluation e. EXAMPLES:: sage: LyndonWords([]).cardinality() 0 sage: LyndonWords([2,2]).cardinality() 1 sage: LyndonWords([2,3,2]).cardinality() 30 Check to make sure that the count matches up with the number of Lyndon words generated. :: sage: comps = [[],[2,2],[3,2,7],[4,2]] + Compositions(4).list() sage: lws = [LyndonWords(comp) for comp in comps] sage: all(lw.cardinality() == len(lw.list()) for lw in lws) True """ evaluation = self._e le = builtins.list(evaluation) if len(evaluation) == 0: return 0 n = sum(evaluation) return sum([moebius(j)*factorial(n/j) / prod([factorial(ni/j) for ni in evaluation]) for j in divisors(gcd(le))])/n
def __getitem__(cls, mtype_or_choices, typedcls=None, choicecls=None): """Dynamically create a derived typed member class and optionally a further derived class with member value choices. - Member value type can be implicitly determined from choices. - Override __getitem__ methods in derived classes can optionally provide a precreated `typedcls` or `choicecls`. """ if type(mtype_or_choices) is builtins.tuple: choices = mtype_or_choices try: # Is member cls already typed? cls.mtype except AttributeError: mtype = type(choices[0]) cls = typed.base.type.__getitem__(cls, mtype, typedcls) if not choicecls: class choicecls(cls): pass choicecls.choices = choices = builtins.list(choices) choicecls.__module__ = cls.__module__ choicecls.__name__ = '%s%s' % (cls.__name__, choices) return choicecls mtype = mtype_or_choices return typed.base.type.__getitem__(cls, mtype, typedcls)
def by(**type): '''Return the segment matching the specified keywords in `type`.''' searchstring = ', '.join("{:s}={!r}".format(key, value) for key, value in six.iteritems(type)) res = builtins.list(__iterate__(**type)) if len(res) > 1: maxaddr = max(builtins.map(operator.attrgetter('endEA'), res) or [1]) caddr = math.ceil(math.log(maxaddr) / math.log(16)) builtins.map( logging.info, (("[{:d}] {:0{:d}x}:{:0{:d}x} {:s} {:+#x} sel:{:04x} flags:{:02x}". format(seg.index, seg.startEA, int(caddr), seg.endEA, int(caddr), idaapi.get_true_segm_name(seg), seg.size(), seg.sel, seg.flags)) for seg in res)) logging.warn( "{:s}.by({:s}) : Found {:d} matching results. Returning the first segment at index {:d} from {:0{:d}x}<>{:0{:d}x} with the name {:s} and size {:+#x}." .format(__name__, searchstring, len(res), res[0].index, res[0].startEA, int(caddr), res[0].endEA, int(caddr), idaapi.get_true_segm_name(res[0]), res[0].size())) res = next(iter(res), None) if res is None: raise E.SearchResultsError( "{:s}.by({:s}) : Found 0 matching results.".format( __name__, searchstring)) return res
def cardinality(self): """ Returns the number of Lyndon words with the evaluation e. EXAMPLES:: sage: LyndonWords([]).cardinality() 0 sage: LyndonWords([2,2]).cardinality() 1 sage: LyndonWords([2,3,2]).cardinality() 30 Check to make sure that the count matches up with the number of Lyndon words generated. :: sage: comps = [[],[2,2],[3,2,7],[4,2]] + Compositions(4).list() sage: lws = [LyndonWords(comp) for comp in comps] sage: all(lw.cardinality() == len(lw.list()) for lw in lws) True """ evaluation = self._e le = builtins.list(evaluation) if len(evaluation) == 0: return 0 n = sum(evaluation) return sum([ moebius(j) * factorial(n / j) / prod([factorial(ni / j) for ni in evaluation]) for j in divisors(gcd(le)) ]) / n
def by(**type): '''Return the segment matching the specified keywords in `type`.''' searchstring = utils.string.kwargs(type) get_segment_name = idaapi.get_segm_name if hasattr( idaapi, 'get_segm_name') else idaapi.get_true_segm_name listable = builtins.list(__iterate__(**type)) if len(listable) > 1: maxaddr = max(builtins.map(interface.range.end, listable) or [1]) caddr = math.ceil(math.log(maxaddr) / math.log(16)) builtins.map( logging.info, ((u"[{:d}] {:0{:d}x}:{:0{:d}x} {:s} {:+#x} sel:{:04x} flags:{:02x}" .format(seg.index, interface.range.start(seg), int(caddr), interface.range.end(seg), int(caddr), utils.string.of(get_segment_name(seg)), seg.size(), seg.sel, seg.flags)) for seg in listable)) logging.warn( u"{:s}.by({:s}) : Found {:d} matching results. Returning the first segment at index {:d} from {:0{:d}x}<>{:0{:d}x} with the name {:s} and size {:+#x}." .format(__name__, searchstring, len(listable), listable[0].index, interface.range.start(listable[0]), int(caddr), interface.range.end(listable[0]), int(caddr), utils.string.of(get_segment_name(listable[0])), listable[0].size())) res = six.next(iter(listable), None) if res is None: raise E.SearchResultsError( u"{:s}.by({:s}) : Found 0 matching results.".format( __name__, searchstring)) return res
def list(**type): '''List all of the segments in the database that match the keyword specified by `type`.''' res = builtins.list(__iterate__(**type)) maxindex = max(builtins.map(operator.attrgetter('index'), res) or [1]) maxaddr = max(builtins.map(operator.attrgetter('endEA'), res) or [1]) maxsize = max(builtins.map(operator.methodcaller('size'), res) or [1]) maxname = max( builtins.map(utils.fcompose(idaapi.get_true_segm_name, len), res) or [1]) cindex = math.ceil(math.log(maxindex or 1) / math.log(10)) caddr = math.ceil(math.log(maxaddr or 1) / math.log(16)) csize = math.ceil(math.log(maxsize or 1) / math.log(16)) for seg in res: comment = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt( seg, 1) six.print_( u"[{:{:d}d}] {:#0{:d}x}<>{:#0{:d}x} : {:<+#{:d}x} : {:>{:d}s} : sel:{:04x} flags:{:02x}{:s}" .format( seg.index, int(cindex), seg.startEA, 2 + int(caddr), seg.endEA, 2 + int(caddr), seg.size(), 3 + int(csize), utils.string.of(idaapi.get_true_segm_name(seg)), maxname, seg.sel, seg.flags, u"// {:s}".format( utils.string.of(comment)) if comment else '')) return
def list(cls, enum): '''List all the members belonging to the enumeration identified by `enum`.''' # FIXME: make this consistent with every other .list using the matcher class eid = by(enum) res = builtins.list(cls.iterate(eid)) maxindex = max(builtins.map(utils.first, enumerate(res)) or [1]) maxvalue = max(builtins.map(utils.fcompose(member.value, "{:#x}".format, len), res) or [1]) for i, mid in enumerate(res): six.print_(u"[{:d}] 0x{:>0{:d}x} {:s}".format(i, member.value(mid), maxvalue, member.name(mid))) return
def __iterate__(**type): '''Iterate through each segment defined in the database that match the keywords specified by `type`.''' if not type: type = {'predicate':lambda n: True} def newsegment(index): res = idaapi.getnseg(index) res.index = index return res res = builtins.map(newsegment, six.moves.range(idaapi.get_segm_qty())) for key, value in six.iteritems(type): res = builtins.list(__matcher__.match(key, value, res)) for item in res: yield item
def by(**type): '''Return the identifier for the first enumeration matching the keyword specified by `type`.''' searchstring = utils.string.kwargs(type) res = builtins.list(iterate(**type)) if len(res) > 1: map(logging.info, (u"[{:d}] {:s} & {:#x} ({:d} members){:s}".format( idaapi.get_enum_idx(n), idaapi.get_enum_name(n), mask(n), len(builtins.list(members(n))), u" // {:s}".format(comment(n)) if comment(n) else '') for i, n in enumerate(res))) logging.warn( u"{:s}.search({:s}) : Found {:d} matching results. Returning the first enumeration {:#x}." .format(__name__, searchstring, len(res), res[0])) res = next(iter(res), None) if res is None: raise E.SearchResultsError( u"{:s}.search({:s}) : Found 0 matching results.".format( __name__, searchstring)) return res
def by(**type): '''Return the identifier for the first enumeration matching the keyword specified by `type`.''' searchstring = utils.string.kwargs(type) res = builtins.list(iterate(**type)) if len(res) > 1: map(logging.info, (u"[{:d}] {:s} & {:#x} ({:d} members){:s}".format(idaapi.get_enum_idx(n), idaapi.get_enum_name(n), mask(n), len(builtins.list(members(n))), u" // {:s}".format(comment(n)) if comment(n) else '') for i,n in enumerate(res))) logging.warn(u"{:s}.search({:s}) : Found {:d} matching results. Returning the first enumeration {:#x}.".format(__name__, searchstring, len(res), res[0])) res = next(iter(res), None) if res is None: raise E.SearchResultsError(u"{:s}.search({:s}) : Found 0 matching results.".format(__name__, searchstring)) return res
def getmodeledproperties(obj): """Get a list of all :class:`modeled.property` (name, instance) pairs of a :class:`modeleled.object` subclass or (name, value) pairs of a :class:`modeled.object` instance in property creation and inheritance order. """ if modeled.ismodeledclass(obj): return builtins.list(obj.model.properties) if modeled.ismodeledobject(obj): return [(name, getattr(obj, name)) for (name, _) in obj.model.properties] raise TypeError("getmodeledproperties() arg must be a subclass or instance" " of modeled.object")
def __init__(self, *default, **options): """Create a typed :class:`modeled.object` data member with an optional `default` value with implicit type. """ # First the unique member ordering id global _memberid self._id = _memberid _memberid += 1 try: self.strict except AttributeError: self.strict = bool(options.pop('strict', False)) # Then set data type/default and options try: mtype = self.mtype except AttributeError: assert(len(default) == 1) default = self.default = default[0] self.__class__ = type(self)[type(default)] else: if default: self.default = mtype(*default) try: options = options['options'] except KeyError: pass try: newfunc = options.pop('new') except KeyError: self.new = self.mtype else: new = self.new self.new = lambda value, func=newfunc: new(value, func) self.new.func = newfunc try: changed = options.pop('changed') except KeyError: self.changed = Handlers() else: self.changed = Handlers(changed) # If no explicit name is given, the associated class attribute name # will be used and assigned in modeled.object.type.__init__: self.name = options.pop('name', None) self.title = options.pop('title', None) self.format = options.pop('format', None) try: # Were choices already defined on class level? self.choices except AttributeError: choices = options.pop('choices', None) self.choices = choices and builtins.list(choices) self.options = Options.frozen(options)
def __iterate__(**type): '''Iterate through each segment defined in the database that match the keywords specified by `type`.''' def newsegment(index): seg = idaapi.getnseg(index) seg.index, _ = index, ui.navigation.set(interface.range.start(seg)) return seg iterable = itertools.imap(newsegment, six.moves.range(idaapi.get_segm_qty())) for key, value in six.iteritems( type or builtins.dict(predicate=utils.fconstant(True))): iterable = builtins.list(__matcher__.match(key, value, iterable)) for item in iterable: yield item
def getmodeledproperties(obj): """Get a list of all :class:`modeled.property` (name, instance) pairs of a :class:`modeleled.object` subclass or (name, value) pairs of a :class:`modeled.object` instance in property creation and inheritance order. """ if modeled.ismodeledclass(obj): return builtins.list(obj.model.properties) if modeled.ismodeledobject(obj): return [(name, getattr(obj, name)) for (name, _) in obj.model.properties] raise TypeError( "getmodeledproperties() arg must be a subclass or instance" " of modeled.object")
def __iterate__(**type): '''Iterate through each segment defined in the database that match the keywords specified by `type`.''' if not type: type = {'predicate': lambda n: True} def newsegment(index): res = idaapi.getnseg(index) res.index = index return res res = builtins.map(newsegment, six.moves.range(idaapi.get_segm_qty())) for key, value in six.iteritems(type): res = builtins.list(__matcher__.match(key, value, res)) for item in res: yield item
def by(**type): '''Return the segment matching the specified keywords in `type`.''' searchstring = utils.string.kwargs(type) res = builtins.list(__iterate__(**type)) if len(res) > 1: maxaddr = max(builtins.map(operator.attrgetter('endEA'), res) or [1]) caddr = math.ceil(math.log(maxaddr)/math.log(16)) builtins.map(logging.info, ((u"[{:d}] {:0{:d}x}:{:0{:d}x} {:s} {:+#x} sel:{:04x} flags:{:02x}".format(seg.index, seg.startEA, int(caddr), seg.endEA, int(caddr), utils.string.of(idaapi.get_true_segm_name(seg)), seg.size(), seg.sel, seg.flags)) for seg in res)) logging.warn(u"{:s}.by({:s}) : Found {:d} matching results. Returning the first segment at index {:d} from {:0{:d}x}<>{:0{:d}x} with the name {:s} and size {:+#x}.".format(__name__, searchstring, len(res), res[0].index, res[0].startEA, int(caddr), res[0].endEA, int(caddr), utils.string.of(idaapi.get_true_segm_name(res[0])), res[0].size())) res = next(iter(res), None) if res is None: raise E.SearchResultsError(u"{:s}.by({:s}) : Found 0 matching results.".format(__name__, searchstring)) return res
def list(**type): '''List all of the enumerations within the database that match the keyword specified by `type`.''' res = builtins.list(iterate(**type)) maxindex = max(builtins.map(idaapi.get_enum_idx, res) or [1]) maxname = max(builtins.map(utils.fcompose(idaapi.get_enum_name, len), res) or [0]) maxsize = max(builtins.map(size, res) or [0]) cindex = math.ceil(math.log(maxindex or 1)/math.log(10)) try: cmask = max(builtins.map(utils.fcompose(mask, utils.fcondition(utils.fpartial(operator.eq, 0))(utils.fconstant(1), utils.fidentity), math.log, functools.partial(operator.mul, 1.0/math.log(8)), math.ceil), res) or [database.config.bits()/4.0]) except: cmask = 0 for n in res: name = idaapi.get_enum_name(n) six.print_(u"[{:{:d}d}] {:>{:d}s} & {:<{:d}x} ({:d} members){:s}".format(idaapi.get_enum_idx(n), int(cindex), utils.string.of(name), maxname, mask(n), int(cmask), len(builtins.list(members(n))), u" // {:s}".format(comment(n)) if comment(n) else '')) return
def list(**type): '''List all of the segments in the database that match the keyword specified by `type`.''' res = builtins.list(__iterate__(**type)) maxindex = max(builtins.map(operator.attrgetter('index'), res) or [1]) maxaddr = max(builtins.map(operator.attrgetter('endEA'), res) or [1]) maxsize = max(builtins.map(operator.methodcaller('size'), res) or [1]) maxname = max(builtins.map(utils.fcompose(idaapi.get_true_segm_name,len), res) or [1]) cindex = math.ceil(math.log(maxindex or 1)/math.log(10)) caddr = math.ceil(math.log(maxaddr or 1)/math.log(16)) csize = math.ceil(math.log(maxsize or 1)/math.log(16)) for seg in res: comment = idaapi.get_segment_cmt(seg, 0) or idaapi.get_segment_cmt(seg, 1) six.print_(u"[{:{:d}d}] {:#0{:d}x}<>{:#0{:d}x} : {:<+#{:d}x} : {:>{:d}s} : sel:{:04x} flags:{:02x}{:s}".format(seg.index, int(cindex), seg.startEA, 2+int(caddr), seg.endEA, 2+int(caddr), seg.size(), 3+int(csize), utils.string.of(idaapi.get_true_segm_name(seg)), maxname, seg.sel, seg.flags, u"// {:s}".format(utils.string.of(comment)) if comment else '')) return
def getmodeledmembers(obj, properties=True): """Get a list of all :class:`modeled.member` (name, instance) pairs of a :class:`modeleled.object` subclass or (name, value) pairs of a :class:`modeled.object` instance in member creation and inheritance order. :param properties: Include :class:`modeled.property` instances? """ if modeled.ismodeledclass(obj): if properties: return builtins.list(obj.model.members) return [(name, m) for name, m in obj.model.members if not modeled.ismodeledproperty(m)] if modeled.ismodeledobject(obj): if properties: return [(name, getattr(obj, name)) for (name, _) in obj.model.members] return [(name, getattr(obj, name)) for (name, im) in obj.model.members if not modeled.ismodeledproperty(im.m)] raise TypeError( "getmodeledmembers() arg must be a subclass or instance" " of modeled.object")
def __init__(self, n, length=None, min_length=0, max_length=float('+inf'), floor=None, ceiling=None, min_part=0, max_part=float('+inf'), min_slope=float('-inf'), max_slope=float('+inf'), name=None, element_constructor=None, element_class=None, global_options=None): """ Initialize ``self``. TESTS:: sage: import sage.combinat.integer_list_old as integer_list sage: C = integer_list.IntegerListsLex(2, length=3) sage: C == loads(dumps(C)) True sage: C == loads(dumps(C)) # this did fail at some point, really! True sage: C is loads(dumps(C)) # todo: not implemented True sage: C.cardinality().parent() is ZZ True sage: TestSuite(C).run() """ stopgap( "The old implementation of IntegerListsLex does not allow for arbitrary input;" " non-allowed input can return wrong results," " please see the documentation for IntegerListsLex for details.", 17548) # Convert to float infinity from sage.rings.infinity import infinity if max_slope == infinity: max_slope = float('+inf') if min_slope == -infinity: min_slope = float('-inf') if max_length == infinity: max_length = float('inf') if max_part == infinity: max_part = float('+inf') if floor is None: self.floor_list = [] else: try: # Is ``floor`` an iterable? # Not ``floor[:]`` because we want ``self.floor_list`` # mutable, and applying [:] to a tuple gives a tuple. self.floor_list = builtins.list(floor) # Make sure the floor list will make the list satisfy the constraints if min_slope != float('-inf'): for i in range(1, len(self.floor_list)): self.floor_list[i] = max( self.floor_list[i], self.floor_list[i - 1] + min_slope) # Some input checking for i in range(1, len(self.floor_list)): if self.floor_list[i] - self.floor_list[i - 1] > max_slope: raise ValueError( "floor does not satisfy the max slope condition") if self.floor_list and min_part - self.floor_list[ -1] > max_slope: raise ValueError( "floor does not satisfy the max slope condition") except TypeError: self.floor = floor if ceiling is None: self.ceiling_list = [] else: try: # Is ``ceiling`` an iterable? self.ceiling_list = builtins.list(ceiling) # Make sure the ceiling list will make the list satisfy the constraints if max_slope != float('+inf'): for i in range(1, len(self.ceiling_list)): self.ceiling_list[i] = min( self.ceiling_list[i], self.ceiling_list[i - 1] + max_slope) # Some input checking for i in range(1, len(self.ceiling_list)): if self.ceiling_list[i] - self.ceiling_list[i - 1] < min_slope: raise ValueError( "ceiling does not satisfy the min slope condition") if self.ceiling_list and max_part - self.ceiling_list[ -1] < min_slope: raise ValueError( "ceiling does not satisfy the min slope condition") except TypeError: # ``ceiling`` is not an iterable. self.ceiling = ceiling if name is not None: self.rename(name) if n in ZZ: self.n = n self.n_range = [n] else: self.n_range = n if length is not None: min_length = length max_length = length self.min_length = min_length self.max_length = max_length self.min_part = min_part self.max_part = max_part # FIXME: the internal functions currently assume that floor and ceiling start at 1 # this is a workaround self.max_slope = max_slope self.min_slope = min_slope if element_constructor is not None: self._element_constructor_ = element_constructor if element_class is not None: self.Element = element_class if global_options is not None: self.global_options = global_options Parent.__init__(self, category=FiniteEnumeratedSets())
from six.moves import builtins c1 = complex() d1 = dict() f1 = float() i1 = int() l1 = list() s1 = str() t1 = tuple() c2 = builtins.complex() d2 = builtins.dict() f2 = builtins.float() i2 = builtins.int() l2 = builtins.list() s2 = builtins.str() t2 = builtins.tuple()
@classmethod def byname(cls, name, *default): '''Lookup the value in an enumeration by it's first-defined name''' if len(default) > 1: raise TypeError("{:s}.byname expected at most 3 arguments, got {:d}".format(cls.typename(), 2+len(default))) try: return six.next(value for item, value in cls._values_ if item == name) except StopIteration: if default: return six.next(iter(default)) raise KeyError(cls, 'enum.byname', name) # update our current state for _, definition in builtins.list(six.viewitems(globals())): if definition in [type] or getattr(definition, '__base__', type) is type: continue if isinstance(definition, builtins.type) and issubclass(definition, type): __state__.setdefault(Config.integer.order, {})[definition] = definition continue del(definition) if __name__ == '__main__': class Result(Exception): pass class Success(Result): pass class Failure(Result): pass TestCaseList = [] def TestCase(fn): def harness(**kwds):
def __init__(self, n, length = None, min_length=0, max_length=float('+inf'), floor=None, ceiling = None, min_part = 0, max_part = float('+inf'), min_slope=float('-inf'), max_slope=float('+inf'), name = None, element_constructor = None, element_class = None, global_options = None): """ Initialize ``self``. TESTS:: sage: import sage.combinat.integer_list_old as integer_list sage: C = integer_list.IntegerListsLex(2, length=3) sage: C == loads(dumps(C)) True sage: C == loads(dumps(C)) # this did fail at some point, really! True sage: C is loads(dumps(C)) # todo: not implemented True sage: C.cardinality().parent() is ZZ True sage: TestSuite(C).run() """ stopgap("The old implementation of IntegerListsLex does not allow for arbitrary input;" " non-allowed input can return wrong results," " please see the documentation for IntegerListsLex for details.", 17548) # Convert to float infinity from sage.rings.infinity import infinity if max_slope == infinity: max_slope = float('+inf') if min_slope == -infinity: min_slope = float('-inf') if max_length == infinity: max_length = float('inf') if max_part == infinity: max_part = float('+inf') if floor is None: self.floor_list = [] else: try: # Is ``floor`` an iterable? # Not ``floor[:]`` because we want ``self.floor_list`` # mutable, and applying [:] to a tuple gives a tuple. self.floor_list = builtins.list(floor) # Make sure the floor list will make the list satisfy the constraints if min_slope != float('-inf'): for i in range(1, len(self.floor_list)): self.floor_list[i] = max(self.floor_list[i], self.floor_list[i-1] + min_slope) # Some input checking for i in range(1, len(self.floor_list)): if self.floor_list[i] - self.floor_list[i-1] > max_slope: raise ValueError("floor does not satisfy the max slope condition") if self.floor_list and min_part - self.floor_list[-1] > max_slope: raise ValueError("floor does not satisfy the max slope condition") except TypeError: self.floor = floor if ceiling is None: self.ceiling_list = [] else: try: # Is ``ceiling`` an iterable? self.ceiling_list = builtins.list(ceiling) # Make sure the ceiling list will make the list satisfy the constraints if max_slope != float('+inf'): for i in range(1, len(self.ceiling_list)): self.ceiling_list[i] = min(self.ceiling_list[i], self.ceiling_list[i-1] + max_slope) # Some input checking for i in range(1, len(self.ceiling_list)): if self.ceiling_list[i] - self.ceiling_list[i-1] < min_slope: raise ValueError("ceiling does not satisfy the min slope condition") if self.ceiling_list and max_part - self.ceiling_list[-1] < min_slope: raise ValueError("ceiling does not satisfy the min slope condition") except TypeError: # ``ceiling`` is not an iterable. self.ceiling = ceiling if name is not None: self.rename(name) if n in ZZ: self.n = n self.n_range = [n] else: self.n_range = n if length is not None: min_length = length max_length = length self.min_length = min_length self.max_length = max_length self.min_part = min_part self.max_part = max_part # FIXME: the internal functions currently assume that floor and ceiling start at 1 # this is a workaround self.max_slope = max_slope self.min_slope = min_slope if element_constructor is not None: self._element_constructor_ = element_constructor if element_class is not None: self.Element = element_class if global_options is not None: self.global_options = global_options Parent.__init__(self, category=FiniteEnumeratedSets())