Skip to content

Commit 86073a0

Browse files
authored
Merge pull request #263 from chillerb/master
add channel_labels check for creating Sample from ndarray
2 parents 553eac0 + a735236 commit 86073a0

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/flowkit/_models/sample.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ def __init__(
183183
if sample_id is None:
184184
raise ValueError("'sample_id' is required for a NumPy array")
185185

186+
if channel_labels is None:
187+
raise ValueError("'channel_labels' is required for a NumPy array")
188+
186189
tmp_file = TemporaryFile()
187190
flowio.create_fcs(
188191
tmp_file,

tests/sample_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ def test_load_numpy_array_no_id_raises(self):
126126

127127
self.assertRaises(ValueError, Sample, npy_data, channel_labels=channels)
128128

129+
def test_load_numpy_array_no_labels_raises(self):
130+
npy_file_path = "data/test_comp_example.npy"
131+
# noinspection SpellCheckingInspection
132+
133+
npy_data = np.fromfile(npy_file_path)
134+
135+
self.assertRaises(ValueError, Sample, npy_data, sample_id="my_sample")
136+
129137
def test_load_dataframe_no_id_raises(self):
130138
npy_file_path = "data/test_comp_example.npy"
131139
# noinspection SpellCheckingInspection

0 commit comments

Comments
 (0)