Пример #1
0
def test_ignores_misnamed_files():
    dataroot, _, _, _ = fake_geo_data(1)

    open(os.path.join(dataroot, 'garbage'), 'w').close()
    open(os.path.join(dataroot, 'garbage_norm.dat'), 'w').close()

    p = GeoPickler(dataroot)

    p.initialise()

    assert (len(p.get_folder_by_id(0)) == 1)
Пример #2
0
def test_skip_save_if_no_Vy(mocker):
    mocker.patch('torch.save')

    dataroot, _, _, _ = fake_geo_data(1)

    p = GeoPickler(dataroot, 'out_dir')

    os.remove(glob.glob(os.path.join(dataroot, '*DIV.dat'))[0])
    p.initialise()
    p.pickle_series(0, 0, 1000, 4, 0)

    torch.save.assert_not_called()
Пример #3
0
def test_skip_if_pkl_exists(mocker):
    mocker.patch('torch.save')

    dataroot, _, _, _ = fake_geo_data(1)

    out_dir = tempfile.mkdtemp()

    p = GeoPickler(dataroot, out_dir)
    p.initialise()

    open(os.path.join(out_dir, '00000.pkl'), 'w').close()

    p.pickle_all(1000, 4, 0, skip_existing=True)

    torch.save.assert_not_called()