Skip to content

Commit

Permalink
fix: Uproot should be able to run without Awkward. (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Feb 20, 2023
1 parent 217bcd5 commit c241599
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/uproot/models/RNTuple.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import struct
import zlib

import awkward as ak
import numpy

import uproot
Expand Down Expand Up @@ -213,6 +212,8 @@ def page_list_envelopes(self):
return self._page_list_envelopes

def base_col_form(self, cr, col_id, parameters=None):
ak = uproot.extras.awkward()

form_key = f"column-{col_id}"
dtype_byte = cr.type
if dtype_byte == uproot.const.rntuple_role_union:
Expand All @@ -230,6 +231,8 @@ def base_col_form(self, cr, col_id, parameters=None):
return form_key

def col_form(self, field_id):
ak = uproot.extras.awkward()

# FIXME remove this ugly logic
rel_crs = []
rel_crs_idxs = []
Expand Down Expand Up @@ -257,6 +260,8 @@ def col_form(self, field_id):
raise (RuntimeError(f"Missing special case: {field_id}"))

def field_form(self, this_id, seen):
ak = uproot.extras.awkward()

field_records = self.header.field_records
this_record = field_records[this_id]
seen.append(this_id)
Expand Down Expand Up @@ -310,6 +315,8 @@ def field_form(self, this_id, seen):
raise AssertionError("this should be unreachable")

def to_akform(self):
ak = uproot.extras.awkward()

field_records = self.header.field_records
recordlist = []
topnames = self.keys()
Expand Down Expand Up @@ -382,6 +389,8 @@ def arrays(
decompression_executor=None,
array_cache=None,
):
ak = uproot.extras.awkward()

entry_stop = entry_stop or self._length

clusters = self.cluster_summaries
Expand Down Expand Up @@ -431,6 +440,8 @@ def _split_switch_bits(content):


def _recursive_find(form, res):
ak = uproot.extras.awkward()

if hasattr(form, "form_key"):
res.append(form.form_key)
if hasattr(form, "contents"):
Expand Down
2 changes: 2 additions & 0 deletions tests/test_0630-rntuple-basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import uproot

pytest.importorskip("awkward")


def test_flat():
filename = skhep_testdata.data_path("test_ntuple_int_float.root")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_0662-rntuple-stl-containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
import queue
import sys

import awkward as ak
import numpy
import pytest
import skhep_testdata

import uproot

ak = pytest.importorskip("awkward")


def test_rntuple_stl_containers():
filename = skhep_testdata.data_path("test_ntuple_stl_containers.root")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_0705-rntuple-writing-metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import queue
import sys

import awkward as ak
import numpy
import pytest
import skhep_testdata

import uproot

ak = pytest.importorskip("awkward")


def test_header(tmp_path):
filepath = os.path.join(tmp_path, "test.root")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_0808-fix_awkward_form_for_AsStridedObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import uproot

pytest.importorskip("awkward")


def test():
path = skhep_testdata.data_path("uproot-HZZ-objects.root")
Expand Down
2 changes: 2 additions & 0 deletions tests/test_0816-separate-AwkwardForth-machines-by-TBranch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import uproot

pytest.importorskip("awkward")


@pytest.mark.parametrize("do_hack", [False, True])
def test(do_hack):
Expand Down

0 comments on commit c241599

Please sign in to comment.