def set_shape(c: Case, new_shape: Tuple[int, int]) -> Case:
    assert new_shape[0] >= c.shape[0]
    assert new_shape[1] >= c.shape[1]
    new_case = c.copy()
    new_case.matter_list = c.matter_list[:]
    new_case.n_row, new_case.col = new_shape
    return new_case
 def case_fit(cls, c: Case, ca: AbstractCase):
     new_case: Case = c.copy()
     new_case.matter_list = []
     for m, y in zip(c.matter_list, ca.y_list):
         if y:
             new_case.matter_list.append(m.deepcopy())
     return new_case
def set_color_add(c: Case, color_add: int) -> Case:
    new_case = c.copy()
    new_case.matter_list = [
        attr_mat.set_color_add(m, color_add) for m in c.matter_list
    ]
    new_case.color_add = color_add
    return new_case
 def case_row_col(cls, c: Case) -> Case:
     new_case = c.copy()
     new_values = cls.auto_fill_row_col(c.repr_values(), c.background_color)
     new_case.matter_list = [
         Matter(new_values, background_color=c.background_color, new=True)
     ]
     return new_case
 def case_m(cls, c: Case, m_row, m_col) -> Case:
     new_case: Case = c.copy()
     new_case.matter_list = [
         cls.matter(m, m_row, m_col) for m in c.matter_list
     ]
     new_case.shape = c.shape[0] * m_row, c.shape[1] * m_col
     return new_case
Exemplo n.º 6
0
 def case(cls, c: Case, allow_diagonal: bool, boundary_none: bool) -> Case:
     assert len(c.matter_list) == 1
     new_case = c.copy()
     new_case.matter_list = cls.matter(c.matter_list[0], allow_diagonal,
                                       c.background_color, boundary_none)
     # print(len(new_case.matter_list))
     return new_case
Exemplo n.º 7
0
 def case(cls, c: Case) -> Case:
     m: Matter
     new_case = c.copy()
     new_case.matter_list = [
         m if m.is_mesh else cls.matter(m) for m in c.matter_list
     ]
     return new_case
Exemplo n.º 8
0
    def case(cls, c: Case) -> Case:
        m: Matter
        x0_arr = np.array([m.x0 for m in c.matter_list if not m.is_mesh])
        y0_arr = np.array([m.y0 for m in c.matter_list if not m.is_mesh])
        x1_arr = np.array([m.x0 + m.shape[0] for m in c.matter_list if not m.is_mesh])
        y1_arr = np.array([m.y0 + m.shape[1] for m in c.matter_list if not m.is_mesh])

        non_mesh_list = [m for m in c.matter_list if not m.is_mesh]
        c_arr = np.arange(len(non_mesh_list))

        # same shape
        assert len(non_mesh_list) >= 2
        assert len({m.shape[0] for m in non_mesh_list}) == 1
        assert len({m.shape[1] for m in non_mesh_list}) == 1
        matter_shape = non_mesh_list[0].shape

        res_arr = align_xy(x0_arr, y0_arr, x1_arr, y1_arr, c_arr)

        new_case: Case = c.copy()
        new_case.shape = res_arr.shape[0] * matter_shape[0], res_arr.shape[1] * matter_shape[1]
        new_case.matter_list = []
        for i in range(res_arr.shape[0]):
            for j in range(res_arr.shape[1]):
                m = non_mesh_list[res_arr[i, j]]
                m_add = m.deepcopy()
                m_add.x0 = i * matter_shape[0]
                m_add.y0 = j * matter_shape[1]
                new_case.matter_list.append(m_add)
        return new_case
 def case(cls, c: Case, full: bool) -> Case:
     new_case: Case = c.copy()
     m: Matter
     new_case.matter_list = [
         m if m.is_mesh else cls.matter(m, full) for m in c.matter_list
     ]
     return new_case
 def case(cls, c: Case, hole_type: str) -> Case:
     new_case: Case = c.copy()
     m: Matter
     new_case.matter_list = [
         cls.matter(m, hole_type) for m in c.matter_list
     ]
     return new_case
 def case(cls, c: Case) -> Case:
     assert c.color_add is not None
     new_case: Case = c.copy()
     new_case.matter_list = [
         cls.matter(m, c.color_add) for m in c.matter_list
     ]
     return new_case
 def case_x(cls, c_x: Case, x0: int, x1: int, y0: int, y1: int) -> Case:
     new_case_x = c_x.copy()
     new_case_x.matter_list = [cls.matter_x(m_x) for m_x in c_x.matter_list]
     new_case_x.display_x0 = x0
     new_case_x.display_x1 = x1
     new_case_x.display_y0 = y0
     new_case_x.display_y1 = y1
     return new_case_x
Exemplo n.º 13
0
    def case(cls, c: Case) -> Case:

        res_arr = c.repr_fractal_values()

        new_case: Case = c.copy()
        new_case.shape = res_arr.shape
        new_case.matter_list = [Matter(res_arr, background_color=c.background_color, new=True)]
        return new_case
 def case(cls, c: Case) -> Case:
     assert len(c.matter_list) == 1
     new_case: Case = c.copy()
     new_matter, m_row, m_col = cls.matter(c.matter_list[0], c.shape[0],
                                           c.shape[1])
     new_case.matter_list = [new_matter]
     new_case.shape = c.shape[0] * m_row, c.shape[1] * m_col
     return new_case
 def case(cls, c: Case, allow_diagonal: bool) -> Case:
     assert len(c.matter_list) == 1
     new_case = c.copy()
     new_case.matter_list = cls.matter(c.matter_list[0], allow_diagonal)
     # a <- n_cell by default
     for m in new_case.matter_list:
         m.a = m.n_cell()
     return new_case
Exemplo n.º 16
0
def hand_pick_case(c: Case, ind: int) -> Case:
    new_case: Case = c.copy()
    new_matter: Matter = c.matter_list[ind % len(c.matter_list)].deepcopy()
    new_matter.x0 = 0
    new_matter.y0 = 0
    new_case.matter_list = [new_matter]
    new_case.shape = new_matter.shape
    return new_case
Exemplo n.º 17
0
 def case(cls, c: Case) -> Case:
     m: Matter
     new_case = c.copy()
     new_case.matter_list = [m.deepcopy() for m in c.matter_list]
     for m in new_case.matter_list:
         m.a = m.n_color()
     new_case.matter_list = list(sorted(new_case.matter_list, key=lambda x: -x.a))
     return new_case
 def case(cls, c: Case, op: str, const: int) -> Case:
     assert c.color_add is not None
     new_case: Case = c.copy()
     m: Matter
     new_case.matter_list = [
         cls.matter(m, op, const, c.color_add) for m in c.matter_list
     ]
     return new_case
Exemplo n.º 19
0
 def case(cls, c: Case) -> Case:
     new_case: Case = c.copy()
     new_background = c.max_color()
     m: Matter
     new_case.matter_list = [
         cls.matter(m, new_background) for m in c.matter_list
     ]
     new_case.background_color = new_background
     return new_case
def point_cross_fit_case(c: Case, op_arr: np.array) -> Case:

    new_case: Case = c.copy()
    new_case.matter_list = [
        point_cross_fit_mat(m, c.shape[0], c.shape[1], op_arr)
        for m in c.matter_list
    ]

    return new_case
 def case(cls, c_x: Case, pattern_arr: np.array) -> Case:
     x_values = c_x.repr_values()
     if c_x.color_delete is None:
         new_x_values = cls.array(x_values, pattern_arr,
                                  c_x.background_color)
     else:
         new_x_values = cls.array(x_values, pattern_arr, c_x.color_delete)
     new_case: Case = c_x.copy()
     new_case.matter_list = [Matter(new_x_values, new=True)]
     return new_case
 def case_y(cls, c_y: Case, new_y_arr, x0: int, x1: int, y0: int,
            y1: int) -> Case:
     new_case_y = c_y.copy()
     new_case_y.matter_list = [cls.matter_y(c_y.matter_list[0], new_y_arr)]
     new_case_y.shape = new_y_arr.shape
     new_case_y.display_x0 = x0
     new_case_y.display_x1 = x1
     new_case_y.display_y0 = y0
     new_case_y.display_y1 = y1
     return new_case_y
 def case(cls, c: Case) -> Case:
     m: Matter
     new_case = c.copy()
     new_case.matter_list = [m.deepcopy() for m in c.matter_list]
     for m in new_case.matter_list:
         if m.a is None:
             pass
         else:
             m.a = m.a % 2
     return new_case
 def case(cls, c: Case) -> Case:
     new_case = c.copy()
     x_arr = trivial_reducer(c)
     # print(x_arr)
     new_values = cls.array(x_arr)
     new_case.matter_list = [
         Matter(new_values, background_color=c.background_color, new=True)
     ]
     new_case.shape = new_values.shape
     return new_case
Exemplo n.º 25
0
 def case_fit(cls, c: Case, ca: AbstractCase):
     for m, y in zip(c.matter_list, ca.y_list):
         if y:
             new_case: Case = c.copy()
             new_matter: Matter = m.deepcopy()
             new_matter.x0 = 0
             new_matter.y0 = 0
             new_case.matter_list = [new_matter]
             new_case.shape = new_matter.shape
             return new_case
     raise AssertionError
Exemplo n.º 26
0
 def case(cls, c: Case, full) -> Case:
     assert c.shape[0] > 2 and c.shape[1] > 2
     new_case = c.copy()
     if c.color_delete is None:
         new_values = cls.array(c.repr_values(), c.background_color, full)
     else:
         new_values = cls.array(c.repr_values(), c.color_delete, full)
     new_case.matter_list = [
         Matter(new_values, background_color=c.background_color, new=True)
     ]
     return new_case
Exemplo n.º 27
0
 def case_col(cls, c: Case) -> Case:
     new_case = c.copy()
     if c.color_delete is None:
         new_values = cls.auto_fill_symmetry_col_background(c.repr_values())
     else:
         new_values = cls.auto_fill_symmetry_col(c.repr_values(),
                                                 c.color_delete)
     new_case.matter_list = [
         Matter(new_values, background_color=c.background_color, new=True)
     ]
     return new_case
 def case(cls, c: Case, descending: bool = False) -> Case:
     new_case = c.copy()
     for m in c.matter_list:
         assert m.a is not None
     if descending:
         new_case.matter_list = list(
             sorted(c.matter_list, key=lambda x: -x.a))
     else:
         new_case.matter_list = list(
             sorted(c.matter_list, key=lambda x: x.a))
     return new_case
 def case_n(cls, c: Case, n_row, n_col) -> Case:
     assert n_row % c.shape[0] == 0
     assert n_col % c.shape[1] == 0
     m_row = n_row // c.shape[0]
     m_col = n_col // c.shape[1]
     new_case: Case = c.copy()
     new_case.matter_list = [
         cls.matter(m, m_row, m_col) for m in c.matter_list
     ]
     new_case.shape = c.shape[0] * m_row, c.shape[1] * m_col
     return new_case
Exemplo n.º 30
0
 def case(cls, c: Case) -> Case:
     new_case = c.copy()
     m: Matter
     if c.color_add is not None:
         color_add = c.color_add
     else:
         color_add = c.max_color()
     new_case.matter_list = [
         cls.matter(m, color_add) for m in c.matter_list
     ]
     return new_case