From a2f34695fbd303dc4ffd111a89d9c2b1a0d2733d Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Mon, 27 Jan 2020 08:12:25 +0100 Subject: [PATCH 1/6] Allow tests to be ran with minimal dependencies --- tests/test_compression.py | 8 ++++++++ tests/test_http.py | 2 +- tests/test_issues.py | 1 + tests/test_tree.py | 10 ++++++---- tests/test_versions.py | 6 ++++-- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/test_compression.py b/tests/test_compression.py index 409e3741..1cc9e080 100644 --- a/tests/test_compression.py +++ b/tests/test_compression.py @@ -2,8 +2,16 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE +import pytest +try: + import lzma +except ImportError: + lzma = pytest.importorskip('backports.lzma') +lz4 = pytest.importorskip('lz4') +zstandard = pytest.importorskip('zstandard') import uproot + class Test(object): def test_compression_identity(self): assert uproot.open("tests/samples/Zmumu-zlib.root").compression.algoname == "zlib" diff --git a/tests/test_http.py b/tests/test_http.py index e52dd02a..f7255693 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -4,7 +4,7 @@ import pytest import mock -from requests.exceptions import HTTPError +HTTPError = pytest.importorskip('requests.exceptions').HTTPError import uproot diff --git a/tests/test_issues.py b/tests/test_issues.py index 7d2b42e8..0e1373ea 100644 --- a/tests/test_issues.py +++ b/tests/test_issues.py @@ -248,6 +248,7 @@ def test_issue187(self): assert t.array("V0s.fEtaPos")[-3].tolist() == [-0.390625, 0.046875] def test_issue213(self): + pytest.importorskip("xxhash") t = uproot.open("tests/samples/issue213.root")["T"] assert t["fMCHits.fPosition"].array().x.tolist() == [ [], [], [], [], [], [], [], [42.17024612426758, 50.63192367553711], diff --git a/tests/test_tree.py b/tests/test_tree.py index cf4fdfcf..b154955b 100644 --- a/tests/test_tree.py +++ b/tests/test_tree.py @@ -595,12 +595,13 @@ def test_tree_lazy_cached(self): @pytest.mark.parametrize("use_http", [False, True]) def test_hist_in_tree(self, use_http): if use_http: + pytest.importorskip("requests") + tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"] + else: path = os.path.join("tests", "samples", "Event.root") if not os.path.exists(path): raise pytest.skip() tree = uproot.open(path)["T"] - else: - tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"] check = [0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, @@ -625,12 +626,13 @@ def test_branch_auto_interpretation(self, use_http): b'fTriggerBits.TObject' ] if use_http: + pytest.importorskip("requests") + tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"] + else: path = os.path.join("tests", "samples", "Event.root") if not os.path.exists(path): raise pytest.skip() tree = uproot.open(path)["T"] - else: - tree = uproot.open("http://scikit-hep.org/uproot/examples/Event.root")["T"] branches_without_interp = [b.name for b in tree.allvalues() if b.interpretation is None] assert branches_without_interp == known_branches_without_interp assert tree.array("fTracks.fTArray[3]", entrystop=10)[5][10].tolist() == [11.03951644897461, 19.40645980834961, 34.54059982299805] diff --git a/tests/test_versions.py b/tests/test_versions.py index e31526f1..eb772375 100644 --- a/tests/test_versions.py +++ b/tests/test_versions.py @@ -2,14 +2,16 @@ # BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE +import pytest try: import lzma except ImportError: - from backports import lzma -import lz4 + lzma = pytest.importorskip('backports.lzma') +lz4 = pytest.importorskip('lz4') import uproot + class Test(object): sample = { b"n": [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4], From ecec79180d45dc66017b3d2c8ce1a8f45a0ab330 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 30 Jan 2020 11:57:50 +0100 Subject: [PATCH 2/6] Set correct Python version in appveyor --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index dd52ce28..3ee789ee 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -44,6 +44,7 @@ install: - "python --version" build_script: + - "SET PATH=%PYTHON%;%PATH%" - "python -m pip install --upgrade pip" - "pip install %NUMPY%" - "pip install \"awkward>=0.12.0,<1.0\"" From 958e745d23c5929a7a2f08699a6c29f02f880e11 Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 30 Jan 2020 12:07:27 +0100 Subject: [PATCH 3/6] Use python -m pip instead of pip on appveyor --- appveyor.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 3ee789ee..747c4386 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -41,18 +41,18 @@ environment: NUMPY: "numpy>=1.15" install: + - "SET PATH=%PYTHON%;%PATH%" - "python --version" build_script: - - "SET PATH=%PYTHON%;%PATH%" - "python -m pip install --upgrade pip" - - "pip install %NUMPY%" - - "pip install \"awkward>=0.12.0,<1.0\"" + - "python -m pip install %NUMPY%" + - "python -m pip install \"awkward>=0.12.0,<1.0\"" - "python -c \"import awkward; print(awkward.__version__)\"" - - "pip install \"uproot-methods>=0.7.0\"" + - "python -m pip install \"uproot-methods>=0.7.0\"" - "python -c \"import uproot_methods; print(uproot_methods.__version__)\"" - - "pip install cachetools lz4 zstandard mock xxhash" - - "pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma" - - "pip install pytest pytest-runner pandas requests" + - "python -m pip install cachetools lz4 zstandard mock xxhash" + - "python -m pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma" + - "python -m pip install pytest pytest-runner pandas requests" - "curl -fsS -o tests/samples/Event.root http://scikit-hep.org/uproot/examples/Event.root" - "pytest -v tests" From a366f13cc095933de17f434f737a7393fb50bdbe Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 30 Jan 2020 12:43:09 +0100 Subject: [PATCH 4/6] Only install backports.lzma for Python 2 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 747c4386..42f9476f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,7 +52,7 @@ build_script: - "python -m pip install \"uproot-methods>=0.7.0\"" - "python -c \"import uproot_methods; print(uproot_methods.__version__)\"" - "python -m pip install cachetools lz4 zstandard mock xxhash" - - "python -m pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma" + - "IF \"%PYTHON_VERSION%\"==\"2.7.10\" ( python -m pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma )" - "python -m pip install pytest pytest-runner pandas requests" - "curl -fsS -o tests/samples/Event.root http://scikit-hep.org/uproot/examples/Event.root" - "pytest -v tests" From dc87f4953fd6dde0ff87063359bfd0ed5be1125f Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Thu, 30 Jan 2020 13:11:56 +0100 Subject: [PATCH 5/6] Use python -m pytest --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 42f9476f..6041b2aa 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -55,4 +55,4 @@ build_script: - "IF \"%PYTHON_VERSION%\"==\"2.7.10\" ( python -m pip install -i https://pypi.anaconda.org/carlkl/simple backports.lzma )" - "python -m pip install pytest pytest-runner pandas requests" - "curl -fsS -o tests/samples/Event.root http://scikit-hep.org/uproot/examples/Event.root" - - "pytest -v tests" + - "python -m pytest -v tests" From be5f56c7f2ad5ae64f5a04c6b60225f8f486d59c Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Thu, 30 Jan 2020 10:21:16 -0600 Subject: [PATCH 6/6] Remove platform dependence in interpreting 'long' and 'unsigned long' types. --- uproot/interp/auto.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uproot/interp/auto.py b/uproot/interp/auto.py index 5679cd95..1c8858c2 100644 --- a/uproot/interp/auto.py +++ b/uproot/interp/auto.py @@ -52,9 +52,9 @@ def _ftype2dtype(fType, awkward): elif fType in (uproot.const.kBits, uproot.const.kUInt, uproot.const.kCounter): return awkward.numpy.dtype(">u4") elif fType == uproot.const.kLong: - return awkward.numpy.dtype(awkward.numpy.long).newbyteorder(">") + return awkward.numpy.dtype(">i8") elif fType == uproot.const.kULong: - return awkward.numpy.dtype(">u" + repr(awkward.numpy.dtype(awkward.numpy.long).itemsize)) + return awkward.numpy.dtype(">u8") elif fType == uproot.const.kLong64: return awkward.numpy.dtype(">i8") elif fType == uproot.const.kULong64: