示例#1
0
    def test_facediv(self):
        oc1 = HyperFaceDivSubset(dim=2, div=3, face=(0, 0),
                                 cubes=[(2, )])  # x0=0, x1>2/3
        oc2 = HyperFaceDivSubset(dim=2, div=3, face=(0, 1), cubes=[(2, )])
        bms = [
            bm for bm in BaseMap.gen_base_maps(dim=2, time_rev=False)
            if bm * oc1 == oc2
        ]
        assert len(bms) == 1

        oc3 = HyperFaceDivSubset(dim=2, div=3, face=(0, 0))  # x0=0
        oc4 = HyperFaceDivSubset(dim=2, div=3, face=(0, 1))
        bms = [
            bm for bm in BaseMap.gen_base_maps(dim=2, time_rev=False)
            if bm * oc3 == oc4
        ]
        assert len(bms) == 2

        assert oc3.map_to_cube(div=3, cube=(0, 2)) == oc1
        assert oc4.map_to_cube(div=3, cube=(2, 2)) == oc2

        assert len(list(oc1.gen_neighbours())) == 1
        assert list(oc1.gen_neighbours()) == [((-1, 0), oc2)]

        assert len(list(oc1.divide(div=3))) == 1
        assert len(list(oc2.divide(div=3))) == 1

        assert len(list(oc3.divide(div=3))) == 3
        assert len(list(oc4.divide(div=3))) == 3
示例#2
0
def check_genus5_ye_proto():
    YE_curve = get_ye_curve()
    YE_proto = YE_curve.proto
    YE_protos = set(bm * YE_proto for bm in BaseMap.gen_base_maps(dim=2))
    paths_gen = PathsGenerator(dim=2, div=5, links=(SIDE_LINK, ), max_cdist=1)
    paths_list = list(paths_gen.generate_paths(std=True))
    print('got paths:', len(paths_list))
    paths_list = [paths for paths in paths_list if paths[0].proto in YE_protos]
    print('got YE paths:', len(paths_list))
    assert len(paths_list) == 1

    assert paths_list[0][0].proto == YE_proto

    test_pcurves = []
    ye_pcurve = get_ye_curve().forget()
    for cnum, ye_spec in enumerate(YE_curve.specs):
        allowed = ye_pcurve.gen_allowed_specs(pnum=0, cnum=cnum)
        test_pcurves += [
            ye_pcurve.specify(pnum=0, cnum=cnum, spec=sp) for sp in allowed
            if sp != ye_spec
        ]

    estimator = Estimator(ratio_l2, cache_max_size=2**16)

    result = estimator.estimate_dilation_sequence(
        test_pcurves,
        rel_tol_inv=1000,
        sat_strategy={
            'type': 'geometric',
            'multiplier': 1.3
        },
    )
    print(result)
    print('lower bound:', float(result['lo']))
    print('upper bound:', float(result['up']))
示例#3
0
 def test_compose(self):
     for curve in self.curves:
         for bm in BaseMap.gen_base_maps(dim=curve.dim):
             for pnum in range(curve.pcount):
                 for cnum in range(curve.genus):
                     spec = Spec(base_map=bm, pnum=pnum)
                     C = spec * curve
                     assert C.specs[cnum] * C == curve.compose_specs(spec, cnum) * curve
示例#4
0
 def test_constraint_fast(self):
     pairs = [
         (
             [FF(0, 1), FF(1, 1), FF(1, 3),
              FF(1, 2)],
             [FF(0, 1), FF(1, 2), FF(1, 3),
              FF(0, 1)],
         ),
         (
             [FF(0, 1), FF(0, 1)],
             [FF(1, 2), FF(1, 2)],
         ),
         (
             [FF(0, 1), FF(0, 1),
              FF(1, 2), FF(1, 2),
              FF(1, 4)],
             [FF(1, 2), FF(1, 2),
              FF(1, 1), FF(1, 1),
              FF(3, 4)],
         ),
         (
             [FF(0, 1), FF(0, 1), FF(0, 1),
              FF(0, 1)],
             [FF(0, 1), FF(0, 1), FF(1, 1),
              FF(1, 1)],
         ),
     ]
     for src_coords, dst_coords in pairs:
         src = Point(src_coords)
         dst = Point(dst_coords)
         dim = len(src)
         bms = set(BaseMap.gen_constraint_fast(src, dst))
         for bm in BaseMap.gen_base_maps(dim, time_rev=False):
             if bm in bms:
                 assert bm * src == dst
             else:
                 assert bm * src != dst
示例#5
0
def check_genus5_non_ye():
    YE_proto = get_ye_curve().proto
    YE_protos = set(bm * YE_proto for bm in BaseMap.gen_base_maps(dim=2))
    paths_gen = PathsGenerator(dim=2, div=5, links=(SIDE_LINK, ), max_cdist=1)
    paths_list = list(paths_gen.generate_paths(std=True))
    print('got paths:', len(paths_list))
    paths_list = [
        paths for paths in paths_list if paths[0].proto not in YE_protos
    ]
    print('got non-YE paths:', len(paths_list))

    estimator = Estimator(ratio_l2, cache_max_size=2**16)

    result = estimator.estimate_dilation_sequence(
        [PathFuzzyCurve.init_from_paths(paths) for paths in paths_list],
        rel_tol_inv=200,
        sat_strategy={
            'type': 'geometric',
            'multiplier': 1.3
        },
    )
    print(result)
    print('lower bound:', float(result['lo']))
    print('upper bound:', float(result['up']))
示例#6
0
 def setUp(self):
     self.base_maps = []
     for dim in range(2, 6):
         self.base_maps += list(BaseMap.gen_base_maps(dim))