Esempio n. 1
0
def test_tileshape_adjustment_10():
    sig_shape = (122, 455)
    tile_shape = (8, 1)
    base_shape = (2, 1)
    excluded_coords = np.array([(121, ), (454, )])
    excluded_pixels = sparse.COO(coords=excluded_coords,
                                 shape=sig_shape,
                                 data=True)
    corr = CorrectionSet(excluded_pixels=excluded_pixels)
    adjusted = corr.adjust_tileshape(tile_shape=tile_shape,
                                     sig_shape=sig_shape,
                                     base_shape=base_shape)
    assert adjusted == (8, 3)
    _validate(excluded_coords=excluded_coords,
              adjusted=adjusted,
              sig_shape=sig_shape)
Esempio n. 2
0
def test_tileshape_adjustment_7():
    sig_shape = (123, 456)
    tile_shape = (14, 42)
    base_shape = (7, 1)
    excluded_coords = np.array([(14, ), (42, )])
    excluded_pixels = sparse.COO(coords=excluded_coords,
                                 shape=sig_shape,
                                 data=True)
    corr = CorrectionSet(excluded_pixels=excluded_pixels)
    adjusted = corr.adjust_tileshape(tile_shape=tile_shape,
                                     sig_shape=sig_shape,
                                     base_shape=base_shape)
    assert adjusted == (21, 41)
    _validate(excluded_coords=excluded_coords,
              adjusted=adjusted,
              sig_shape=sig_shape)
Esempio n. 3
0
def test_tileshape_adjustment_6_3():
    sig_shape = (123, 456)
    tile_shape = (1, 1)
    base_shape = (1, 1)
    excluded_coords = np.array([range(123), range(0, 246, 2)])
    excluded_pixels = sparse.COO(coords=excluded_coords,
                                 shape=sig_shape,
                                 data=True)
    corr = CorrectionSet(excluded_pixels=excluded_pixels)
    adjusted = corr.adjust_tileshape(tile_shape=tile_shape,
                                     sig_shape=sig_shape,
                                     base_shape=base_shape)
    assert adjusted == (123, 256)
    _validate(excluded_coords=excluded_coords,
              adjusted=adjusted,
              sig_shape=sig_shape)
Esempio n. 4
0
def test_tileshape_adjustment_6_1():
    sig_shape = (123, 456)
    tile_shape = (122, 1)
    base_shape = (1, 1)
    excluded_coords = np.array([range(123), np.zeros(123, dtype=int)])
    excluded_pixels = sparse.COO(coords=excluded_coords,
                                 shape=sig_shape,
                                 data=True)
    corr = CorrectionSet(excluded_pixels=excluded_pixels)
    adjusted = corr.adjust_tileshape(tile_shape=tile_shape,
                                     sig_shape=sig_shape,
                                     base_shape=base_shape)
    print(adjusted)
    assert adjusted == (123, 2)
    _validate(excluded_coords=excluded_coords,
              adjusted=adjusted,
              sig_shape=sig_shape)
Esempio n. 5
0
def test_tileshape_adjustment_8():
    sig_shape = (1014, 1024)
    tile_shape = (1, 1)
    base_shape = (1, 1)
    # These magic numbers are "worst case" to produce collisions
    # 2*3*4*5*6*7
    excluded_coords = np.array([(720, 210, 306), (120, 210, 210)])
    excluded_pixels = sparse.COO(coords=excluded_coords,
                                 shape=sig_shape,
                                 data=True)
    corr = CorrectionSet(excluded_pixels=excluded_pixels)
    adjusted = corr.adjust_tileshape(tile_shape=tile_shape,
                                     sig_shape=sig_shape,
                                     base_shape=base_shape)
    print(adjusted)
    assert adjusted != (1014, 1024)
    _validate(excluded_coords=excluded_coords,
              adjusted=adjusted,
              sig_shape=sig_shape)
Esempio n. 6
0
def test_tileshape_adjustment_fuzz():
    for n in range(10):
        sig_shape = (np.random.randint(1, 2**12), np.random.randint(1, 2**12))
        print("Sig shape", sig_shape)
        tile_shape = (1, 1)
        base_shape = (1, 1)
        size = max(1, max(sig_shape) // 10)
        excluded_coords = np.vstack([
            np.random.randint(0, sig_shape[0], size=size),
            np.random.randint(0, sig_shape[1], size=size),
        ])
        print("excluded_coords", excluded_coords.shape, excluded_coords)
        excluded_pixels = sparse.COO(coords=excluded_coords,
                                     shape=sig_shape,
                                     data=True)
        corr = CorrectionSet(excluded_pixels=excluded_pixels, allow_empty=True)
        adjusted = corr.adjust_tileshape(tile_shape=tile_shape,
                                         sig_shape=sig_shape,
                                         base_shape=base_shape)
        print(adjusted)
        _validate(excluded_coords=excluded_coords,
                  adjusted=adjusted,
                  sig_shape=sig_shape)