|
@@ 32-48 (lines=17) @@
|
| 29 |
|
assert expected == actual |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
def test_sorted_h5_keys_many(): |
| 33 |
|
""" |
| 34 |
|
Test to check a key is returned with many entries |
| 35 |
|
""" |
| 36 |
|
with TempDirectory() as tempdir: |
| 37 |
|
# Creating some dummy data |
| 38 |
|
d1 = np.random.random(size=(10, 20)) |
| 39 |
|
hf = h5py.File(tempdir.path + "data.h5", "w") |
| 40 |
|
# Adding entries in different order |
| 41 |
|
hf.create_dataset("dataset_1", data=d1) |
| 42 |
|
hf.create_dataset("dataset_3", data=d1) |
| 43 |
|
hf.create_dataset("dataset_2", data=d1) |
| 44 |
|
hf.close() |
| 45 |
|
# Checking func returns the same thing |
| 46 |
|
expected = ["dataset_1", "dataset_2", "dataset_3"] |
| 47 |
|
actual = util.get_h5_sorted_keys(tempdir.path + "data.h5") |
| 48 |
|
assert expected == actual |
| 49 |
|
|
| 50 |
|
|
| 51 |
|
def test_get_sorted_file_paths_in_dir_with_suffix(): |
|
@@ 16-29 (lines=14) @@
|
| 13 |
|
import deepreg.dataset.util as util |
| 14 |
|
|
| 15 |
|
|
| 16 |
|
def test_sorted_h5_keys(): |
| 17 |
|
""" |
| 18 |
|
Test to check a key is returned with one entry |
| 19 |
|
""" |
| 20 |
|
with TempDirectory() as tempdir: |
| 21 |
|
# Creating some dummy data |
| 22 |
|
d1 = np.random.random(size=(1000, 20)) |
| 23 |
|
hf = h5py.File(tempdir.path + "data.h5", "w") |
| 24 |
|
hf.create_dataset("dataset_1", data=d1) |
| 25 |
|
hf.close() |
| 26 |
|
# Checking func returns the same thing |
| 27 |
|
expected = ["dataset_1"] |
| 28 |
|
actual = util.get_h5_sorted_keys(tempdir.path + "data.h5") |
| 29 |
|
assert expected == actual |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
def test_sorted_h5_keys_many(): |