def __init__(self, parent, partition): r""" An irreducible representation of the symmetric group corresponding to ``partition``. For more information, see the documentation for :func:`SymmetricGroupRepresentation`. EXAMPLES:: sage: spc = SymmetricGroupRepresentation([3]) sage: spc([3,2,1]) [1] sage: spc == loads(dumps(spc)) True sage: spc = SymmetricGroupRepresentation([3], cache_matrices=False) sage: spc([3,2,1]) [1] sage: spc == loads(dumps(spc)) True """ self._partition = Partition(partition) self._n = parent._n self._ring = parent._ring if not parent._cache_matrices: self.representation_matrix = self._representation_matrix_uncached Element.__init__(self, parent)
def __init__(self, parent, component_dict, name="sheaf morpism"): Element.__init__(self, parent) self._parent = parent self._components = component_dict self._base_ring = self._parent._base_ring self._domain_poset = self._parent._domain_poset self._name = name
def __init__(self, parent, blocks): self._blocks = blocks self._number_of_blocks = len(blocks) self._n = parent._n if not SetPartitions(self._n)(self._blocks).is_noncrossing(): raise ValueError("{} is not noncrossing".format(blocks)) Element.__init__(self, parent)
def __init__(self, model, coordinates, is_boundary, check=True, **graphics_options): r""" See ``HyperbolicPoint`` for full documentation. EXAMPLES:: sage: p = HyperbolicPlane().UHP().get_point(I) sage: TestSuite(p).run() """ if is_boundary: if not model.is_bounded(): raise NotImplementedError("boundary points are not implemented in the {0} model".format(model.short_name())) if check and not model.boundary_point_in_model(coordinates): raise ValueError( "{0} is not a valid".format(coordinates) + " boundary point in the {0} model".format(model.short_name())) elif check and not model.point_in_model(coordinates): raise ValueError( "{0} is not a valid".format(coordinates) + " point in the {0} model".format(model.short_name())) if isinstance(coordinates, tuple): coordinates = vector(coordinates) self._coordinates = coordinates self._bdry = is_boundary self._graphics_options = graphics_options Element.__init__(self, model)
def __init__(self, domain, coords=None, chart=None, name=None, latex_name=None): Element.__init__(self, domain) self.manifold = domain.manifold self.domain = domain self.coordinates = {} if coords is not None: if len(coords) != self.manifold.dim: raise ValueError("The number of coordinates must be equal" + " to the manifold dimension.") if chart is None: chart = self.domain.def_chart else: if chart not in self.domain.atlas: raise ValueError("The " + str(chart) + " has not been defined on the " + str(self.domain)) #!# The following check is not performed for it would fail with # symbolic coordinates: # if not chart.valid_coordinates(*coords): # raise ValueError("The coordinates " + str(coords) + # " are not valid on the " + str(chart)) for schart in chart.supercharts: self.coordinates[schart] = tuple(coords) for schart in chart.subcharts: if schart != chart: if schart.valid_coordinates(*coords): self.coordinates[schart] = tuple(coords) self.name = name if latex_name is None: self.latex_name = self.name else: self.latex_name = latex_name
def __init__(self, parent, series): Element.__init__(self, parent) if isinstance(series,ContinuousGeneralizedSeriesMult): series=series.get_summands() m=parent.get_monoid() if not type(series) is list: series=[series] series=[i for i in series if i!=0] if len(series)==0: series=[parent.get_monoid().zero()] for i in range(len(series)): if isinstance(series[i],FractionFieldElement_1poly_field): var=series[0].parent().gen() expansion=padic_expansion(series[i],var,parent.prec()) series[i]=m(sum([lift(expansion[1][j])*var**j for j in range(len(expansion[1]))]),expansion[0]) series=[*map(m,series)] self.__summands=[series[0]] series=series[1:] for i in series: found=False for j in range(len(self.__summands)): if self.__summands[j].similar(i): self.__summands[j]=self.__summands[j]+i found=True if not found: self.__summands.append(i)
def __init__(self, data, check=True): """ Initialize ``self``. TESTS:: sage: B = BraidGroup(8) sage: K = Knot(B([1, -2, 1, -2])) sage: TestSuite(K).run() sage: K = Knot([[1, 1, 2, 2]]) sage: TestSuite(K).run() The following is not a knot: it has two components. :: sage: Knot([[[1, 2], [-2, -1]], [1, -1]]) Traceback (most recent call last): ... ValueError: the input has more than 1 connected component sage: Knot([[[1, 2], [-2, -1]], [1, -1]], check=False) Knot represented by 2 crossings """ Element.__init__(self, Knots()) Link.__init__(self, data) if check: if self.number_of_components() != 1: raise ValueError("the input has more than 1 connected " "component")
def __init__(self, parent, Vrep, Hrep, polymake_polytope=None, **kwds): """ Initializes the polyhedron. See :class:`Polyhedron_polymake` for a description of the input data. TESTS: We skip the pickling test because pickling is currently not implemented:: sage: p = Polyhedron(backend='polymake') # optional - polymake sage: TestSuite(p).run(skip="_test_pickling") # optional - polymake sage: p = Polyhedron(vertices=[(1, 1)], rays=[(0, 1)], # optional - polymake ....: backend='polymake') sage: TestSuite(p).run(skip="_test_pickling") # optional - polymake sage: p = Polyhedron(vertices=[(-1,-1), (1,0), (1,1), (0,1)], # optional - polymake ....: backend='polymake') sage: TestSuite(p).run(skip="_test_pickling") # optional - polymake """ if polymake_polytope: if Hrep is not None or Vrep is not None: raise ValueError("only one of Vrep, Hrep, or polymake_polytope can be different from None") Element.__init__(self, parent=parent) self._init_from_polymake_polytope(polymake_polytope) else: Polyhedron_base.__init__(self, parent, Vrep, Hrep, **kwds)
def __init__(self, core, parent): """ TESTS:: sage: C = Cores(4,3) sage: c = C([2,1]); c [2, 1] sage: type(c) <class 'sage.combinat.core.Cores_length_with_category.element_class'> sage: c.parent() 4-Cores of length 3 sage: TestSuite(c).run() sage: C = Cores(3,3) sage: C([2,1]) Traceback (most recent call last): ... ValueError: [2, 1] is not a 3-core """ k = parent.k part = Partition(core) if not part.is_core(k): raise ValueError, "%s is not a %s-core" % (part, k) CombinatorialObject.__init__(self, core) Element.__init__(self, parent)
def __init__(self, core, parent): """ TESTS:: sage: C = Cores(4,3) sage: c = C([2,1]); c [2, 1] sage: type(c) <class 'sage.combinat.core.Cores_length_with_category.element_class'> sage: c.parent() 4-Cores of length 3 sage: TestSuite(c).run() sage: C = Cores(3,3) sage: C([2,1]) Traceback (most recent call last): ... ValueError: [2, 1] is not a 3-core """ k = parent.k part = Partition(core) if not part.is_core(k): raise ValueError, "%s is not a %s-core"%(part, k) CombinatorialObject.__init__(self, core) Element.__init__(self, parent)
def __init__(self, parent, Vrep, Hrep, normaliz_cone=None, **kwds): """ Initializes the polyhedron. See :class:`Polyhedron_normaliz` for a description of the input data. TESTS: We skip the pickling test because pickling is currently not implemented:: sage: p = Polyhedron(backend='normaliz') # optional - pynormaliz sage: TestSuite(p).run(skip="_test_pickling") # optional - pynormaliz sage: p = Polyhedron(vertices=[(1, 1)], rays=[(0, 1)], # optional - pynormaliz ....: backend='normaliz') sage: TestSuite(p).run(skip="_test_pickling") # optional - pynormaliz sage: p = Polyhedron(vertices=[(-1,-1), (1,0), (1,1), (0,1)], # optional - pynormaliz ....: backend='normaliz') sage: TestSuite(p).run(skip="_test_pickling") # optional - pynormaliz """ if normaliz_cone: if Hrep is not None or Vrep is not None: raise ValueError( "only one of Vrep, Hrep, or normaliz_cone can be different from None" ) Element.__init__(self, parent=parent) self._init_from_normaliz_cone(normaliz_cone) else: Polyhedron_base.__init__(self, parent, Vrep, Hrep, **kwds)
def __init__(self, poset, element, vertex): r""" Establishes the parent-child relationship between ``poset`` and ``element``, where ``element`` is associated to the vertex ``vertex`` of the Hasse diagram of the poset. INPUT: - ``poset`` - a poset object - ``element`` - any object - ``vertex`` - a vertex of the Hasse diagram of the poset TESTS:: sage: from sage.combinat.posets.elements import PosetElement sage: P = Poset([[1,2],[4],[3],[4],[]], facade = False) sage: e = P(0) sage: e.parent() is P True sage: TestSuite(e).run() """ Element.__init__(self, poset) if isinstance(element, self.parent().element_class): self.element = element.element else: self.element = element self.vertex = vertex
def __init__(self, model, coordinates, is_boundary, check=True, **graphics_options): r""" See ``HyperbolicPoint`` for full documentation. EXAMPLES:: sage: p = HyperbolicPlane().UHP().get_point(I) sage: TestSuite(p).run() """ if is_boundary: if not model.is_bounded(): raise NotImplementedError( "boundary points are not implemented in the {0} model". format(model.short_name())) if check and not model.boundary_point_in_model(coordinates): raise ValueError("{0} is not a valid".format(coordinates) + " boundary point in the {0} model".format( model.short_name())) elif check and not model.point_in_model(coordinates): raise ValueError( "{0} is not a valid".format(coordinates) + " point in the {0} model".format(model.short_name())) if isinstance(coordinates, tuple): coordinates = vector(coordinates) self._coordinates = coordinates self._bdry = is_boundary self._graphics_options = graphics_options Element.__init__(self, model)
def __init__(self, parent, coords=None, chart=None, name=None, latex_name=None, check_coords=True): r""" Construct a manifold point. TESTS:: sage: M = Manifold(2, 'M', structure='topological') sage: X.<x,y> = M.chart() sage: p = M((2,3), name='p'); p Point p on the 2-dimensional topological manifold M sage: TestSuite(p).run() sage: U = M.open_subset('U', coord_def={X: x<0}) sage: q = U((-1,2), name='q'); q Point q on the 2-dimensional topological manifold M sage: TestSuite(q).run() """ if parent.is_empty(): raise TypeError( f'cannot define a point on the {parent} because it has been declared empty' ) Element.__init__(self, parent) parent._has_defined_points = True self._manifold = parent.manifold() # a useful shortcut self._coordinates = { } # dictionary of the point coordinates in various # charts, with the charts as keys if coords is not None: if len(coords) != parent.manifold().dimension(): raise ValueError("the number of coordinates must be equal " + "to the manifold's dimension") from sage.manifolds.manifold import TopologicalManifold if chart is None: chart = parent._def_chart elif isinstance(parent, TopologicalManifold): if chart not in parent._atlas: raise ValueError("the {} has not been".format(chart) + "defined on the {}".format(parent)) if check_coords: if not chart.valid_coordinates(*coords): raise ValueError("the coordinates {}".format(coords) + " are not valid on the {}".format(chart)) for schart in chart._supercharts: self._coordinates[schart] = tuple(coords) for schart in chart._subcharts: if schart != chart: if schart.valid_coordinates(*coords): self._coordinates[schart] = tuple(coords) self._name = name if latex_name is None: self._latex_name = self._name else: self._latex_name = latex_name
def __init__(self, parent, t): r""" Initialize a composition tableau. TESTS:: sage: t = CompositionTableaux()([[1],[2,2]]) sage: s = CompositionTableaux(3)([[1],[2,2]]) sage: s==t True sage: t.parent() Composition Tableaux sage: s.parent() Composition Tableaux of size 3 and maximum entry 3 sage: r = CompositionTableaux()(s) sage: r.parent() Composition Tableaux """ if isinstance(t, CompositionTableau): Element.__init__(self, parent) CombinatorialObject.__init__(self, t._list) return # CombinatorialObject verifies that t is a list # We must verify t is a list of lists if not all(isinstance(row, list) for row in t): raise ValueError("A composition tableau must be a list of lists.") if not map(len, t) in Compositions(): raise ValueError( "A composition tableau must be a list of non-empty lists.") # Verify rows weakly decrease from left to right for row in t: if any(row[i] < row[i + 1] for i in range(len(row) - 1)): raise ValueError( "Rows must weakly decrease from left to right.") # Verify leftmost column strictly increases from top to bottom first_col = [row[0] for row in t if t != [[]]] if any(first_col[i] >= first_col[i + 1] for i in range(len(t) - 1)): raise ValueError( "Leftmost column must strictly increase from top to bottom.") # Verify triple condition l = len(t) m = max(map(len, t) + [0]) TT = [row + [0] * (m - len(row)) for row in t] for i in range(l): for j in range(i + 1, l): for k in range(1, m): if TT[j][k] != 0 and TT[j][k] >= TT[i][k] and TT[j][ k] <= TT[i][k - 1]: raise ValueError("Triple condition must be satisfied.") Element.__init__(self, parent) CombinatorialObject.__init__(self, t)
def __init__(self, parent, data): r""" TESTS:: sage: T = TotallyOrderedFiniteSet([3,2,1],facade=False) sage: TestSuite(T.an_element()).run() """ Element.__init__(self, parent) self.value = data
def __init__(self, parent, key): """ Create a cipher. INPUT: Parent and key EXAMPLES: None yet """ Element.__init__(self, parent) self._key = key
def __init__(self, instance, workprec=None): if isinstance(instance, LazyApproximationWrapper): raise TypeError Element.__init__(self, instance.parent()) self._instance = instance ref = weakref.ref(self, delete_max_workprec) wrappers[ref] = instance self._ref = ref if workprec is not None: instance.update_max_workprec(workprec, wrapper=ref)
def __init__(self, parent, m): r""" EXAMPLES:: sage: B = crystals.elementary.Elementary(['B',7],7) sage: elt = B(17); elt 17 """ self._m = m Element.__init__(self, parent)
def __init__(self, subset, coords=None, chart=None, name=None, latex_name=None, check_coords=True): r""" Construct a manifold point. TESTS:: sage: Manifold._clear_cache_() # for doctests only sage: M = Manifold(2, 'M') sage: X.<x,y> = M.chart() sage: p = M((2,3), name='p') ; p point 'p' on 2-dimensional manifold 'M' sage: TestSuite(p).run() sage: U = M.open_subset('U', coord_def={X: x<0}) sage: q = U((-1,2), name='q') ; q point 'q' on 2-dimensional manifold 'M' sage: TestSuite(q).run() """ Element.__init__(self, subset._manifold) self._manifold = subset._manifold self._subset = subset self._coordinates = {} if coords is not None: if len(coords) != self._manifold._dim: raise ValueError("The number of coordinates must be equal" + " to the manifold dimension.") if chart is None: chart = self._subset._def_chart else: if chart not in self._subset._atlas: raise ValueError("The " + str(chart) + " has not been defined on the " + str(self._subset)) if check_coords: if not chart.valid_coordinates(*coords): raise ValueError("The coordinates " + str(coords) + " are not valid on the " + str(chart)) for schart in chart._supercharts: self._coordinates[schart] = tuple(coords) for schart in chart._subcharts: if schart != chart: if schart.valid_coordinates(*coords): self._coordinates[schart] = tuple(coords) self._name = name if latex_name is None: self._latex_name = self._name else: self._latex_name = latex_name self._tangent_space = None # tangent vector space at the point (not
def __init__(self, parent, rdict): r""" Create an eta product object. Usually called implicitly via EtaGroup_class.__call__ or the EtaProduct factory function. EXAMPLES:: sage: EtaProduct(8, {1:24, 2:-24}) Eta product of level 8 : (eta_1)^24 (eta_2)^-24 sage: g = _; g == loads(dumps(g)) True sage: TestSuite(g).run() """ self._N = parent._N N = self._N if isinstance(rdict, EtaGroupElement): rdict = rdict._rdict # Note: This is needed because the "x in G" test tries to call G(x) # and see if it returns an error. So sometimes this will be getting # called with rdict being an eta product, not a dictionary. if rdict == 1: rdict = {} # Check Ligozat criteria sumR = sumDR = sumNoverDr = 0 prod = 1 for d in list(rdict): if N % d: raise ValueError("%s does not divide %s" % (d, N)) if rdict[d] == 0: del rdict[d] continue sumR += rdict[d] sumDR += rdict[d] * d sumNoverDr += rdict[d] * N / d prod *= (N // d)**rdict[d] if sumR != 0: raise ValueError("sum r_d (=%s) is not 0" % sumR) if sumDR % 24: raise ValueError("sum d r_d (=%s) is not 0 mod 24" % sumDR) if sumNoverDr % 24: raise ValueError("sum (N/d) r_d (=%s) is not 0 mod 24" % sumNoverDr) if not is_square(prod): raise ValueError("product (N/d)^(r_d) (=%s) is not a square" % prod) self._sumDR = ZZ(sumDR) # this is useful to have around self._rdict = rdict Element.__init__(self, parent)
def __init__(self, parent, lst): """ Initialize ``self``. EXAMPLES:: sage: C = Composition([3,1,2]) sage: TestSuite(C).run() """ CombinatorialObject.__init__(self, lst) Element.__init__(self, parent)
def __init__(self, parent): r""" Initialisation function. EXAMPLES:: sage: pAdicWeightSpace(17)(0) 0 """ Element.__init__(self, parent) self._p = self.parent().prime()
def __init__(self, parent, tau): """ Initialize ``self``. EXAMPLES:: sage: elt = SimilarityClassType([[3, [3, 2, 1]], [2, [2, 1]]]) sage: TestSuite(elt).run() """ CombinatorialObject.__init__(self, sorted(tau, key=lambda PT: (PT.degree(), PT.partition()))) Element.__init__(self, parent)
def __init__(self, parent, vecpar): """ Initialize ``self``. EXAMPLES:: sage: elt = VectorPartition([[3, 2, 1], [2, 2, 1]]) sage: TestSuite(elt).run() """ CombinatorialObject.__init__(self, sorted(vecpar)) Element.__init__(self, parent)
def __init__(self, parent, x): """ Initialize ``self``. EXAMPLES:: sage: mst = MultiSkewTableau([ [[None,1],[2,3]], [[1,2],[2]] ]) sage: TestSuite(mst).run() """ CombinatorialObject.__init__(self, x) Element.__init__(self, parent)
def __init__(self, parent, t): r""" Initialize a composition tableau. TESTS:: sage: t = CompositionTableaux()([[1],[2,2]]) sage: s = CompositionTableaux(3)([[1],[2,2]]) sage: s==t True sage: t.parent() Composition Tableaux sage: s.parent() Composition Tableaux of size 3 and maximum entry 3 sage: r = CompositionTableaux()(s) sage: r.parent() Composition Tableaux """ if isinstance(t, CompositionTableau): Element.__init__(self, parent) CombinatorialObject.__init__(self, t._list) return # CombinatorialObject verifies that t is a list # We must verify t is a list of lists if not all(isinstance(row, list) for row in t): raise ValueError("A composition tableau must be a list of lists.") if not map(len,t) in Compositions(): raise ValueError("A composition tableau must be a list of non-empty lists.") # Verify rows weakly decrease from left to right for row in t: if any(row[i] < row[i+1] for i in range(len(row)-1)): raise ValueError("Rows must weakly decrease from left to right.") # Verify leftmost column strictly increases from top to bottom first_col = [row[0] for row in t if t!=[[]]] if any(first_col[i] >= first_col[i+1] for i in range(len(t)-1)): raise ValueError("Leftmost column must strictly increase from top to bottom.") # Verify triple condition l = len(t) m = max(map(len,t)+[0]) TT = [row+[0]*(m-len(row)) for row in t] for i in range(l): for j in range(i+1,l): for k in range(1,m): if TT[j][k] != 0 and TT[j][k] >= TT[i][k] and TT[j][k] <= TT[i][k-1]: raise ValueError("Triple condition must be satisfied.") Element.__init__(self, parent) CombinatorialObject.__init__(self, t)
def __init__(self, parent, deg, par): """ Initialize ``self``. EXAMPLES:: sage: elt = PrimarySimilarityClassType(2, [3, 2, 1]) sage: TestSuite(elt).run() """ self._deg = deg self._par = par Element.__init__(self, parent)
def __init__(self, parent, gap_handle): """ Initialize an element of ``parent`` .. TODO:: make this more robust """ #from sage.libs.gap.element import GapElement #if not isinstance(gap_handle, GapElement): # raise ValueError("Input not a GAP handle") Element.__init__(self, parent) GAPObject.__init__(self, gap_handle)
def __init__(self, parent, tau): """ Initialize ``self``. EXAMPLES:: sage: elt = SimilarityClassType([[3, [3, 2, 1]], [2, [2, 1]]]) sage: TestSuite(elt).run() """ CombinatorialObject.__init__( self, sorted(tau, key=lambda PT: (PT.degree(), PT.partition()))) Element.__init__(self, parent)
def __init__(self, lst): """ TESTS:: sage: NonDecreasingParkingFunction([1, 1, 2, 2, 5, 6]) [1, 1, 2, 2, 5, 6] """ if not is_a(lst): raise ValueError('%s is not a non-decreasing parking function' % lst) parent = NonDecreasingParkingFunctions_n(len(lst)) Element.__init__(self, parent) self._list = lst
def __init__(self, parent, asm): """ Initialize ``self``. EXAMPLES: sage: A = AlternatingSignMatrices(3) sage: elt = A([[1, 0, 0],[0, 1, 0],[0, 0, 1]]) sage: TestSuite(elt).run() """ self._matrix = asm Element.__init__(self, parent)
def __init__(self, parent, lst): """ Initialize ``self``. EXAMPLES:: sage: D = Derangements(4) sage: elt = D([4,3,2,1]) sage: TestSuite(elt).run() """ CombinatorialObject.__init__(self, lst) Element.__init__(self, parent)
def __init__(self, parent): r""" Initialisation function. EXAMPLE:: sage: pAdicWeightSpace(17)(0) 0 """ Element.__init__(self, parent) self._p = self.parent().prime()
def __init__(self, parent, b, m): """ Initialize ``self``. EXAMPLES:: sage: A = crystals.KirillovReshetikhin(['A',2,1], 2, 2).affinization() sage: mg = A.module_generators[0] sage: TestSuite(mg).run() """ self._b = b self._m = m Element.__init__(self, parent)
def __init__(self,parent,data): i = len(data)-1 while i >= 0 and len(data[i]) == 0: data.pop() i -= 1 self.rows = len(data) if data == []: self.cols = 0 else: self.cols = max([len(r) for r in data]) self.data = data CombinatorialObject.__init__(self, data) Element.__init__(self, parent)
def __init__(self, triangulation, parent, check=True): """ The constructor of a ``Triangulation`` object. Note that an internal reference to the underlying ``PointConfiguration`` is kept. INPUT: - ``parent`` -- a :class:`~sage.geometry.triangulation.point_configuration.PointConfiguration` - ``triangulation`` -- an iterable of integers or iterable of iterables (e.g. a list of lists). In the first case, the integers specify simplices via :meth:`PointConfiguration.simplex_to_int`. In the second case, the point indices of the maximal simplices of the triangulation. - ``check`` -- boolean. Whether to perform checks that the triangulation is, indeed, a triangulation of the point configuration. NOTE: Passing ``check=False`` allows you to create triangulations of subsets of the points of the configuration, see :meth:`~sage.geometry.triangulation.point_configuration.PointConfiguration.bistellar_flips`. EXAMPLES:: sage: p = [[0,1],[0,0],[1,0]] sage: points = PointConfiguration(p) sage: from sage.geometry.triangulation.point_configuration import Triangulation sage: Triangulation([(0,1,2)], points) (<0,1,2>) sage: Triangulation([1], points) (<0,1,2>) """ Element.__init__(self, parent=parent) self._point_configuration = parent try: triangulation = tuple( sorted(tuple(sorted(t)) for t in triangulation)) except TypeError: triangulation = tuple(self.point_configuration().int_to_simplex(i) for i in triangulation) assert not check or all( len(t) == self.point_configuration().dim() + 1 for t in triangulation) self._triangulation = triangulation
def __init__(self, parent, value, format): """ EXAMPLES:: sage: C = crystals.FastRankTwo(['A',2],shape=[2,1]) sage: c = C(0); c [0, 0, 0] sage: C[0].parent() The fast crystal for A2 with shape [2,1] sage: TestSuite(c).run() """ Element.__init__(self, parent) self.value = value self.format = format
def __init__(self, parent, dim, name): """ Initialize ``self``. EXAMPLES:: sage: from sage.categories.cw_complexes import CWComplexes sage: X = CWComplexes().example() sage: f = X.an_element() sage: TestSuite(f).run() """ Element.__init__(self, parent) self._dim = dim self._name = name
def __init__(self, parent, dict): r""" INPUT: - ``dict`` -- a dictionary of with pairs of the form ``{(i,k):y}`` EXAMPLES:: sage: M = crystals.infinity.NakajimaMonomials("C5") sage: mg = M.module_generators[0] sage: TestSuite(mg).run() """ self._dict = dict Element.__init__(self, parent)
def __init__(self, parent, list): """ EXAMPLES:: sage: from sage.combinat.crystals.tensor_product import ImmutableListWithParent, TestParent sage: l = ImmutableListWithParent(TestParent(), [1,2,3]) sage: l.parent() A parent for tests sage: parent(l) A parent for tests sage: TestSuite(l).run(skip = "_test_category") """ Element.__init__(self, parent) CombinatorialObject.__init__(self, list)
def __init__(self, triangulation, parent, check=True): """ The constructor of a ``Triangulation`` object. Note that an internal reference to the underlying ``PointConfiguration`` is kept. INPUT: - ``parent`` -- a :class:`~sage.geometry.triangulation.point_configuration.PointConfiguration` - ``triangulation`` -- an iterable of integers or iterable of iterables (e.g. a list of lists). In the first case, the integers specify simplices via :meth:`PointConfiguration.simplex_to_int`. In the second case, the point indices of the maximal simplices of the triangulation. - ``check`` -- boolean. Whether to perform checks that the triangulation is, indeed, a triangulation of the point configuration. NOTE: Passing ``check=False`` allows you to create triangulations of subsets of the points of the configuration, see :meth:`~sage.geometry.triangulation.point_configuration.PointConfiguration.bistellar_flips`. EXAMPLES:: sage: p = [[0,1],[0,0],[1,0]] sage: points = PointConfiguration(p) sage: from sage.geometry.triangulation.point_configuration import Triangulation sage: Triangulation([(0,1,2)], points) (<0,1,2>) sage: Triangulation([1], points) (<0,1,2>) """ Element.__init__(self, parent=parent) self._point_configuration = parent try: triangulation = tuple(sorted( tuple(sorted(t)) for t in triangulation)) except TypeError: triangulation = tuple( self.point_configuration().int_to_simplex(i) for i in triangulation ) assert not check or all( len(t)==self.point_configuration().dim()+1 for t in triangulation) self._triangulation = triangulation
def __init__(self, parent, value, is_name=False, name=None): Element.__init__(self, parent) self._create = value if parent is None: return # means "invalid element" # idea: Joe Wetherell -- try to find out if the output # is too long and if so get it using file, otherwise # don't. if is_name: self._name = value else: try: self._name = parent._create(value, name=name) except (TypeError, RuntimeError, ValueError) as x: raise TypeError(x)