Exemplo n.º 1
0
    def __init__(self, parent, text_variable=None, constraints=None, **kw):
        self._var = text_variable or StringVar()
        self._constraints = constraints or Constraints()
        self._var.set(1)
        self.refresh_input()

        Entry.__init__(self, parent, textvariable=self._var, width=10, **kw)
        self.bind("<FocusOut>", lambda event: self.refresh_input())
Exemplo n.º 2
0
    def _init_components(self):
        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        # upper pane contains apex list
        upper_pane = ListContainer(self)
        self.apex_list = ApexList(upper_pane, self._apex)
        upper_pane.set_listbox(self.apex_list)

        # buttons pane contain
        buttons_pane = Frame(self)

        self._expand_button = Button(buttons_pane,
                                     text="Expand All",
                                     command=self.apex_list.expand_all)
        self._expand_button.pack(side='left', expand=True, fill='x')

        self._reset_button = Button(buttons_pane,
                                    text="Collapse All",
                                    command=self.apex_list.reset)
        self._reset_button.pack()

        # panel with number search box
        search_pane = LabelFrame(self, text="Find number")

        self._search_box = NumberBox(search_pane,
                                     allow_expression=True,
                                     constraints=Constraints(min=1))
        self._search_box.pack(side='left', expand=True, fill='x')

        self._search_box_initial_bg = self._search_box['bg']
        self._search_box_alert_bg = '#ffaaaa'

        self._search_box.bind('<Return>', self._find_number)
        for event in ('<FocusIn>', '<FocusOut>', '<Key>'):
            self._search_box.bind(event, self._reset_search_box_alert)

        search_number_button = Button(search_pane,
                                      text="Find",
                                      command=self._find_number)
        search_number_button.pack()

        upper_pane.grid(sticky='nesw')
        buttons_pane.grid(row=1, sticky='nesw')
        search_pane.grid(row=2, sticky='nesw')
Exemplo n.º 3
0
    def _init_components(self):
        # group type selection (alternating, classical, sporadic, exceptional)
        group_type_frame = LabelFrame(self, text="Group type", padx=10, pady=5)
        group_type_frame.pack(expand=True, fill='x')

        # group type radio buttons (Alternating, Classical etc.)
        self._group_type = StringVar()
        self._type_radio_buttons = dict()
        for group_type in ("Alternating", "Classical", "Exceptional", "Sporadic"):
            radiobutton = Radiobutton(group_type_frame, variable=self._group_type, value=group_type, text=group_type)
            radiobutton.pack(anchor='nw')
            self._type_radio_buttons[group_type] = radiobutton

        # set group type selection handler
        self._group_type.trace("w", lambda n, i, m: self._group_type_selection())

        # spacer
        Frame(self, height=10).pack()

        # parameters for each group (degree for alternating, field and dimension for classical etc.)
        # notice that we do not pack LabelFrame contents. We do that in _group_type_selection method instead.
        group_params_frame = LabelFrame(self, text="Parameters", padx=10, pady=5)
        group_params_frame.pack(expand=True, fill='x')

        # alternating
        self._alt_params = Frame(group_params_frame)
        self._alt_params.columnconfigure(1, weight=1)
        Label(self._alt_params, text="Degree").grid(sticky='w')
        self._alt_degree = NumberBox(self._alt_params, constraints=Constraints(min=5))
        self._alt_degree.grid(row=0, column=1, sticky='we')

        # classical
        self._clas_params = Frame(group_params_frame)
        self._clas_params.columnconfigure(1, weight=1)

        Label(self._clas_params, text="Type").grid(row=0, sticky='w')
        self._clas_type = OptionList(self._clas_params, values=ClassicalGroup.types())
        self._clas_type.variable.trace("w", lambda n, i, m: self._classical_group_type_selection())
        self._clas_type.grid(row=0, column=1, sticky='we')

        Label(self._clas_params, text="Dimension").grid(row=1, sticky='w')
        self._clas_dim = NumberBox(self._clas_params)
        self._clas_dim.grid(row=1, column=1, sticky='we')

        Label(self._clas_params, text="Field order").grid(row=2, sticky='w')
        self._clas_field = NumberBox(self._clas_params, constraints=Constraints(primality=numeric.PRIME_POWER))
        self._clas_field.grid(row=2, column=1, sticky='we')

        self._classical_group_type_selection()

        # exceptional
        self._ex_params = Frame(group_params_frame)
        self._ex_params.columnconfigure(1, weight=1)

        Label(self._ex_params, text="Type").grid(row=0, sticky='w')
        self._ex_type = OptionList(self._ex_params, values=ExceptionalGroup.types())
        self._ex_type.setvar(value=ExceptionalGroup.types()[0])
        self._ex_type.variable.trace("w", lambda n, i, m: self._exceptional_group_type_selection())
        self._ex_type.grid(row=0, column=1, sticky='we')

        Label(self._ex_params, text="Field order").grid(row=1, sticky='w')
        self._ex_field = NumberBox(self._ex_params, constraints=Constraints(primality=numeric.PRIME_POWER))
        self._ex_field.grid(row=1, column=1, sticky='we')
        self._exceptional_group_type_selection()

        # sporadic
        self._spor_params = Frame(group_params_frame)
        self._spor_params.columnconfigure(1, weight=1)

        Label(self._spor_params, text="Group").grid(row=0, sticky='w')
        self._sporadic_group = OptionList(self._spor_params, values=SporadicGroup.all_groups())
        self._sporadic_group.grid(row=0, column=1, sticky='we')
Exemplo n.º 4
0
 def dim_constraints(name):
     """Returns constraints on dimension for specified kind of groups
     """
     return ClassicalGroup._dim_constraints.get(name, Constraints(min=2))
Exemplo n.º 5
0
 def field_constraints(name):
     """Returns constraints on field for specified kind of groups
     """
     return ClassicalGroup._field_constraints.get(
         name, Constraints(min=2, primality=numeric.PRIME_POWER))
Exemplo n.º 6
0
class ClassicalGroup(Group):
    """Usage:
    ClassicalGroup("PSp", 14, Field(2, 5))
    ClassicalGroup("PSp", 14, 32)
    ClassicalGroup("PSp", 14, 2, 5)
    """
    if _CACHE:
        __metaclass__ = GroupCache

    _groups = ('PGL', 'PGU', 'Omega', 'Omega+', 'POmega+', 'Omega-', 'POmega-',
               'SL', 'PSL', 'SO', 'SO+', 'SO-', 'SU', 'PSU', 'Sp', 'PSp')

    _latex = {
        'Omega+': 'Omega^+',
        'Omega-': 'Omega^-',
        'POmega+': 'POmega^+',
        'POmega-': 'POmega^-',
        'SO+': 'SO^+',
        'SO-': 'SO^-'
    }

    # constraints for dimension
    _dim_constraints = {
        'Omega': Constraints(min=5, parity=-1),
        'Omega+': Constraints(min=8, parity=1),
        'Omega-': Constraints(min=8, parity=1),
        'POmega+': Constraints(min=8, parity=1),
        'POmega-': Constraints(min=8, parity=1),
        'SO': Constraints(min=5, parity=-1),
        'SO+': Constraints(min=8, parity=1),
        'SO-': Constraints(min=8, parity=1),
        'Sp': Constraints(min=4, parity=1),
        'PSp': Constraints(min=4, parity=1)
    }

    # constraints for field order
    _field_constraints = {
        'SO': Constraints(min=3, primality=numeric.PRIME_POWER, parity=-1)
    }

    def __init__(self, name, dimension, *field):
        super(ClassicalGroup, self).__init__()
        self._name = name
        self._dim = dimension
        self._field = field[0] if isinstance(field[0], Field) else Field(
            *field)
        self._apex = None
        self._order = None

    def __str__(self):
        return "{}({}, {})".format(self._name, self._dim, self._field.order)

    def str_latex(self):
        name = ClassicalGroup._latex.get(self._name, self._name)
        dim = str(self._dim)
        if len(dim) > 1:
            dim = "{" + dim + "}"
        return "{}_{}({})".format(name, dim, self._field.order)

    @staticmethod
    def types():
        return ClassicalGroup._groups

    @property
    def field(self):
        """Returns field of this group
        """
        return self._field

    def apex(self):
        if self._apex is None:
            func = spectra.classical_spectra.get(self._name, lambda *arg: [])
            self._apex = numeric.sort_and_filter(func(self._dim, self._field))
        return self._apex

    def order(self):
        if self._order is None:
            func = orders.classical_orders.get(self._name,
                                               lambda *arg: Integer())
            self._order = func(self._dim, self._field)
        return self._order

    @staticmethod
    def field_constraints(name):
        """Returns constraints on field for specified kind of groups
        """
        return ClassicalGroup._field_constraints.get(
            name, Constraints(min=2, primality=numeric.PRIME_POWER))

    @staticmethod
    def dim_constraints(name):
        """Returns constraints on dimension for specified kind of groups
        """
        return ClassicalGroup._dim_constraints.get(name, Constraints(min=2))
Exemplo n.º 7
0
 def field_constraints(cls, name):
     return cls._field_constraints.get(
         name, Constraints(min=2, primality=numeric.PRIME_POWER))
Exemplo n.º 8
0
class ExceptionalGroup(Group):
    if _CACHE:
        __metaclass__ = ObjectCache

    _groups = (
        "E6",
        "2E6",
        "E7",
        "E8",
        "F4",
        "2F4",
        "G2",
        "2G2",
        "2B2",
        "3D4",
    )

    _latex = {
        "E6": 'E_6',
        "2E6": '{}^2E_6',
        "E7": 'E_7',
        "E8": 'E_8',
        "F4": 'F_4',
        "2F4": '{}^2F_4',
        "G2": 'G_2',
        "2G2": '{}^2G_2',
        "2B2": '{}^2B_2',
        "3D4": '{}^3D_4'
    }

    # constraints for field order
    _field_constraints = {
        '2F4': Constraints(min=2, primality=numeric.ODD_POWER_OF_2),
        '2B2': Constraints(min=2, primality=numeric.ODD_POWER_OF_2),
        '2G2': Constraints(min=2, primality=numeric.ODD_POWER_OF_3),
    }

    def __init__(self, name, *field):
        super(ExceptionalGroup, self).__init__()
        self._name = name
        self._field = field[0] if isinstance(field[0], Field) else Field(
            *field)
        self._apex = None
        self._order = None

    def __str__(self):
        return "{}({})".format(self._name, self._field.order)

    def str_latex(self):
        name = ExceptionalGroup._latex.get(self._name, self._name)
        return "{}({})".format(name, self._field.order)

    @staticmethod
    def types():
        return ExceptionalGroup._groups

    @property
    def field(self):
        """Returns field of this group
        """
        return self._field

    def apex(self):
        if self._apex is None:
            func = spectra.exceptional_spectra.get(self._name, lambda *arg: [])
            self._apex = numeric.sort_and_filter(func(self._field))
        return self._apex

    def order(self):
        if self._order is None:
            func = orders.exceptional_orders.get(self._name,
                                                 lambda *arg: Integer())
            self._order = func(self._field)
        return self._order

    @classmethod
    def field_constraints(cls, name):
        return cls._field_constraints.get(
            name, Constraints(min=2, primality=numeric.PRIME_POWER))