Skip to content

Commit c821c36

Browse files
authored
update to change awkward arrays to load lazily (#96)
These changes will update the awkward data converter. It will now convert data to LazyArray objects. This change also updates the data_conversion tests to reflect that a LazyArray is a different type of object from the previous Array dictionaries.
1 parent 078dabb commit c821c36

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

servicex/data_conversions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def do_the_work(file: Path) -> Dict[bytes, Union[ndarray, JaggedArray]]:
6666
f_in = uproot.open(file)
6767
try:
6868
r = f_in[f_in.keys()[0]]
69-
return r.arrays() # type: ignore
69+
return r.lazyarrays() # type: ignore
7070
finally:
7171
f_in._context.source.close()
7272

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def good_awkward_file_data(mocker):
176176
import awkward as awk
177177

178178
async def good_awkward_data(fname: str):
179-
df = {b'JetPt': awk.fromiter([0, 1, 2, 3, 4, 5])}
179+
df = {'JetPt': awk.fromiter([0, 1, 2, 3, 4, 5])}
180180
return df
181181

182182
mocker.patch('servicex.servicex._convert_root_to_awkward', side_effect=good_awkward_data)

tests/test_data_conversions.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,4 @@ async def test_root_to_pandas(good_root_file_path):
1313
@pytest.mark.asyncio
1414
async def test_root_to_awkward(good_root_file_path):
1515
df = await _convert_root_to_awkward(good_root_file_path)
16-
assert isinstance(df, dict)
17-
assert len(df) == 1
18-
assert b'JetPt' in df
19-
assert len(df[b'JetPt']) == 283458
16+
assert len(df['JetPt']) == 283458

tests/test_servicex.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ async def test_good_run_single_ds_1file_awkward(mocker, good_awkward_file_data):
232232
r = await ds.get_data_awkward_async('(valid qastle string)')
233233
assert isinstance(r, dict)
234234
assert len(r) == 1
235-
assert b'JetPt' in r
236-
assert len(r[b'JetPt']) == 6
235+
assert 'JetPt' in r
236+
assert len(r['JetPt']) == 6
237237

238238

239239
@pytest.mark.asyncio
@@ -270,8 +270,8 @@ async def test_good_run_single_ds_2file_awkward(mocker, good_awkward_file_data):
270270
r = await ds.get_data_awkward_async('(valid qastle string)')
271271
assert isinstance(r, dict)
272272
assert len(r) == 1
273-
assert b'JetPt' in r
274-
assert len(r[b'JetPt']) == 6 * 2
273+
assert 'JetPt' in r
274+
assert len(r['JetPt']) == 6 * 2
275275

276276

277277
@pytest.mark.asyncio

0 commit comments

Comments
 (0)