Skip to content

Commit a17d1a7

Browse files
authored
Merge pull request #181 from iguinn/main
Allow multi-dim array literals
2 parents e00d106 + fcadf3f commit a17d1a7

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/dspeed/processing_chain.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -797,10 +797,7 @@ def _parse_expr(
797797
npparr = np.array(
798798
ast.literal_eval(expr[node.col_offset : node.end_col_offset])
799799
)
800-
if len(npparr.shape) == 1:
801-
return npparr
802-
else:
803-
raise ProcessingChainError("only 1D arrays are supported: " + expr)
800+
return npparr
804801

805802
elif isinstance(node, ast.Constant):
806803
return node.value

tests/test_processing_chain.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,19 @@ def test_numpy_math_constants_dsp(lgnd_test_data):
119119

120120
def test_list_parsing(lgnd_test_data, tmptestdir):
121121
dsp_config = {
122-
"outputs": ["wf_out", "ievt"],
122+
"outputs": ["a1", "a2", "wf_out", "ievt"],
123123
"processors": {
124124
"a1": "[1,2,3,4,5]",
125-
"a2": "[6,7,8,9,10]",
126-
"wf_out": "a1+a2",
125+
"a2": "[[1, 2], [3, 4]]",
126+
"wf_out": "a1+[6,7,8,9,10]",
127127
},
128128
}
129129

130130
raw_in = lgnd_test_data.get_path("lh5/LDQTA_r117_20200110T105115Z_cal_geds_raw.lh5")
131131
dsp_out = build_dsp(raw_in=raw_in, dsp_config=dsp_config, n_entries=1)
132-
assert np.all(dsp_out["geds"]["dsp"]["wf_out"].nda == np.array([7, 9, 11, 13, 15]))
132+
assert np.all(dsp_out.geds.dsp.a1.nda == np.array([1, 2, 3, 4, 5]))
133+
assert np.all(dsp_out.geds.dsp.a2.nda == np.array([[1, 2], [3, 4]]))
134+
assert np.all(dsp_out.geds.dsp.wf_out.nda == np.array([7, 9, 11, 13, 15]))
133135

134136

135137
def test_comparators():

0 commit comments

Comments
 (0)