Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSid output format #136

Merged
merged 5 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions SciFiReaders/readers/SID/Nsid_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,21 @@

if recursive:
list_of_main = self._main_dsets
keys = ['Channel_{:03}'.format(i) for i in range(len(list_of_main))]
else:
list_of_main = []
keys = []

Check warning on line 161 in SciFiReaders/readers/SID/Nsid_reader.py

View check run for this annotation

Codecov / codecov/patch

SciFiReaders/readers/SID/Nsid_reader.py#L161

Added line #L161 was not covered by tests
for key in h5_group:
if isinstance(h5_group[key], h5py.Dataset):
if check_if_main(h5_group[key]):
list_of_main.append(h5_group[key])
keys.append(key)

Check warning on line 166 in SciFiReaders/readers/SID/Nsid_reader.py

View check run for this annotation

Codecov / codecov/patch

SciFiReaders/readers/SID/Nsid_reader.py#L166

Added line #L166 was not covered by tests

# Go through each of the identified
list_of_datasets = []
for dset in list_of_main:
list_of_datasets.append(read_h5py_dataset(dset))
list_of_datasets = {}
for i,dset in enumerate(list_of_main):
list_of_datasets[keys[i]] = read_h5py_dataset(dset)
return list_of_datasets

def close(self):
self._h5_file.close()
def close(self):
self._h5_file.close()

Check warning on line 175 in SciFiReaders/readers/SID/Nsid_reader.py

View check run for this annotation

Codecov / codecov/patch

SciFiReaders/readers/SID/Nsid_reader.py#L175

Added line #L175 was not covered by tests
20 changes: 11 additions & 9 deletions tests/readers/SID/test_nsid_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ def test_nsid_bepfm_file(self):
data = reader.read()
assert len(data)==3, "Data should have been length 3 but was instead {}".format(len(data))
#Check to see if these are sidpy datasets
for ind in range(3):
assert type(data[ind])==sidpy.sid.dataset.Dataset, "Expected sidpy dataset but received {}".format(type(data[ind]))

assert data[0].shape==(3, 128, 128, 1)
assert data[1].shape == (128, 128, 61)
assert data[2].shape == (128,128,5)
for key in data:
assert type(data[key])==sidpy.sid.dataset.Dataset, "Expected sidpy dataset but received {}".format(type(data[ind]))

data_keys = list(data.keys())

assert data[data_keys[0]].shape==(3, 128, 128, 1)
assert data[data_keys[1]].shape == (128, 128, 61)
assert data[data_keys[2]].shape == (128,128,5)

assert len(data[0].original_metadata.keys())==285, "Expected 285 keys but received {} for data[0]"
assert len(data[1].original_metadata.keys())==285, "Expected 285 keys but received {} for data[1]"
assert len(data[2].original_metadata.keys())==0, "Expected 0 keys but received {} for data[2]"
assert len(data[data_keys[0]].original_metadata.keys())==285, "Expected 285 keys but received {} for data[0]"
assert len(data[data_keys[1]].original_metadata.keys())==285, "Expected 285 keys but received {} for data[1]"
assert len(data[data_keys[2]].original_metadata.keys())==0, "Expected 0 keys but received {} for data[2]"



Expand Down
Loading