Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Depend on uproot3-methods, rather than uproot-methods. #529

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 13 additions & 16 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Strict dependencies:

- `numpy <https://scipy.org/install.html>`__ (1.13.1+)
- `Awkward Array 0.x <https://github.com/scikit-hep/awkward-0.x>`__
- `uproot-methods <https://github.com/scikit-hep/uproot-methods>`__ (0.9.1+)
- `uproot3-methods <https://github.com/scikit-hep/uproot3-methods>`__
- `cachetools <https://pypi.org/project/cachetools>`__

Optional dependencies:
Expand Down Expand Up @@ -178,7 +178,7 @@ In short, you should never see a segmentation fault.
Uproot is strictly concerned with file I/O only—all other functionality
is handled by other libraries:

- `uproot-methods <https://github.com/scikit-hep/uproot-methods>`__:
- `uproot3-methods <https://github.com/scikit-hep/uproot3-methods>`__:
physics methods for types read from ROOT files, such as histograms
and Lorentz vectors. It is intended to be largely user-contributed
(and is).
Expand Down Expand Up @@ -3157,10 +3157,10 @@ Special physics objects: Lorentz vectors
Although any C++ type can in principle be read (see below), some are
important enough to be given convenience methods for analysis. These are
not defined in Uproot (which is strictly concerned with I/O), but in
`uproot-methods <https://github.com/scikit-hep/uproot-methods>`__. If
`uproot3-methods <https://github.com/scikit-hep/uproot3-methods>`__. If
you need certain classes to have user-friendly methods in Python, you’re
encouraged to contribute them to
`uproot-methods <https://github.com/scikit-hep/uproot-methods>`__.
`uproot3-methods <https://github.com/scikit-hep/uproot3-methods>`__.

One of these classes is ``TLorentzVectorArray``, which defines an
*array* of Lorentz vectors.
Expand Down Expand Up @@ -3190,7 +3190,7 @@ at individuals.

muon = muons[0, 0]
type(muon), muon
# (uproot_methods.classes.TLorentzVector.TLorentzVector,
# (uproot3_methods.classes.TLorentzVector.TLorentzVector,
# TLorentzVector(-52.899, -11.655, -8.1608, 54.779))

This object has all the usual kinematics methods,
Expand All @@ -3211,10 +3211,7 @@ method on each).

.. code-block:: python3

muons.mass # some mass**2 are slightly negative, hence the Numpy warning about negative square roots
# /home/pivarski/miniconda3/lib/python3.7/site-packages/uproot_methods-0.6.1-py3.7.egg/uproot_methods/
# classes/TLorentzVector.py:189: RuntimeWarning: invalid value encountered in sqrt
# return self._trymemo("mass", lambda self: self.awkward0.numpy.sqrt(self.mag2))
muons.mass
# <JaggedArray [[0.10559298741436905 0.10545247041042287] [0.105499240400313]
# [0.10696309110601164 0.10513788128369116] ... [0.1054382466674704] [0.0975059956172863]
# [0.10447224169767522]] at 0x7f36246f8080>
Expand Down Expand Up @@ -3249,9 +3246,9 @@ need to use a special constructor to build the object from its branches.

.. code-block:: python3

import uproot_methods
import uproot3_methods

array = uproot_methods.TLorentzVectorArray.from_cartesian(px, py, pz, E)
array = uproot3_methods.TLorentzVectorArray.from_cartesian(px, py, pz, E)
array
# <JaggedArrayMethods [[TLorentzVector(-52.899, -11.655, -8.1608, 54.779)
# TLorentzVector(37.738, 0.69347, -11.308, 39.402)]
Expand All @@ -3268,7 +3265,7 @@ converts to other systems on demand.

.. code-block:: python3

[x for x in dir(uproot_methods.TLorentzVectorArray) if x.startswith("from_")]
[x for x in dir(uproot3_methods.TLorentzVectorArray) if x.startswith("from_")]
# ['from_cartesian',
# 'from_cylindrical',
# 'from_p3',
Expand Down Expand Up @@ -3569,7 +3566,7 @@ between ``uproot3.asobj``

# TLorentzVectors all have the same number of fixed width components, so they can be read vectorially.
events3["muonp4"].interpretation
# asjagged(asobj(<uproot_methods.classes.TLorentzVector.Methods>), 10)
# asjagged(asobj(<uproot3_methods.classes.TLorentzVector.Methods>), 10)

.. code-block:: python3

Expand Down Expand Up @@ -3860,7 +3857,7 @@ Python. Here’s a way to find out which ones have been defined so far:

import pkgutil

[modname for importer, modname, ispkg in pkgutil.walk_packages(uproot_methods.classes.__path__)]
[modname for importer, modname, ispkg in pkgutil.walk_packages(uproot3_methods.classes.__path__)]
# ['TGraph',
# 'TGraphAsymmErrors',
# 'TGraphErrors',
Expand Down Expand Up @@ -4199,9 +4196,9 @@ or it may be created entirely in Python.
.. code-block:: python3

import types
import uproot_methods.classes.TH1
import uproot3_methods.classes.TH1

class MyTH1(uproot_methods.classes.TH1.Methods, list):
class MyTH1(uproot3_methods.classes.TH1.Methods, list):
def __init__(self, low, high, values, title=""):
self._fXaxis = types.SimpleNamespace()
self._fXaxis._fNbins = len(values)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
numpy>=1.13.1
awkward0
uproot-methods>=0.9.1
uproot3-methods
cachetools
backports.lzma;python_version<"3.3"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_description():
license = "BSD 3-clause",
test_suite = "tests",
python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
install_requires = ["numpy>=1.13.1", "awkward0", "uproot-methods>=0.9.1", "cachetools"],
install_requires = ["numpy>=1.13.1", "awkward0", "uproot3-methods", "cachetools"],
setup_requires = ["pytest-runner"],
extras_require = {
"testing": ["pytest>=3.9", "pkgconfig", "lz4", "zstandard", 'backports.lzma;python_version<"3.3"', "xxhash", "mock", "requests"],
Expand Down
18 changes: 9 additions & 9 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import uproot3
import awkward0

import uproot_methods.classes.TVector3
import uproot_methods.classes.TLorentzVector
import uproot3_methods.classes.TVector3
import uproot3_methods.classes.TLorentzVector


class Test(object):
Expand Down Expand Up @@ -123,15 +123,15 @@ def test_issue57(self):
for x in tree["sel_lep"].array():
for y in x:
assert isinstance(
y, uproot_methods.classes.TLorentzVector.
y, uproot3_methods.classes.TLorentzVector.
Methods) and isinstance(
y._fP, uproot_methods.classes.TVector3.Methods)
y._fP, uproot3_methods.classes.TVector3.Methods)
for x in tree["selJet"].array():
for y in x:
assert isinstance(
y, uproot_methods.classes.TLorentzVector.
y, uproot3_methods.classes.TLorentzVector.
Methods) and isinstance(
y._fP, uproot_methods.classes.TVector3.Methods)
y._fP, uproot3_methods.classes.TVector3.Methods)

def test_issue60(self):
t = uproot3.open("tests/samples/issue60.root")["nllscan"]
Expand Down Expand Up @@ -200,10 +200,10 @@ def test_issue70(self):
def test_issue74(self):
t = uproot3.open("tests/samples/issue74.root")["Events"]
assert all(
isinstance(x[0], uproot_methods.classes.TVector3.Methods)
isinstance(x[0], uproot3_methods.classes.TVector3.Methods)
for x in t.array("bees.xyzPosition"))
assert t.array("bees.xyzPosition"
)[0][0] == uproot_methods.classes.TVector3.TVector3(
)[0][0] == uproot3_methods.classes.TVector3.TVector3(
1.0, 2.0, -1.0)

def test_issue76(self):
Expand All @@ -222,7 +222,7 @@ def test_issue79(self):
def test_issue96(self):
t = uproot3.open("tests/samples/issue96.root")["tree"]
assert all(
isinstance(x, uproot_methods.classes.TLorentzVector.Methods)
isinstance(x, uproot3_methods.classes.TLorentzVector.Methods)
for x in t.array("jet1P4"))

def test_geant4(self):
Expand Down
44 changes: 22 additions & 22 deletions uproot3/rootio.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from uproot3.source.cursor import Cursor
from uproot3._util import _tobytes

import uproot_methods.classes
import uproot3_methods.classes

################################################################ high-level interface

Expand Down Expand Up @@ -937,7 +937,7 @@ def _defineclasses(streamerinfos, classes):
code.insert(0, " _fields = [{0}]".format(", ".join(repr(str(x)) for x in fields)))
code.insert(0, " @classmethod\n def _recarray(cls):\n out = []\n out.append((' cnt', 'u4'))\n out.append((' vers', 'u2'))\n for base in cls._bases:\n out.extend(base._recarray())\n {0}\n return out".format("\n ".join(recarray)))
code.insert(0, " _bases = [{0}]".format(", ".join(bases)))
code.insert(0, " _methods = {0}".format("uproot_methods.classes.{0}.Methods".format(pyclassname) if uproot_methods.classes.hasmethods(pyclassname) else "None"))
code.insert(0, " _methods = {0}".format("uproot3_methods.classes.{0}.Methods".format(pyclassname) if uproot3_methods.classes.hasmethods(pyclassname) else "None"))

if len(bases) == 0:
bases.append("ROOTStreamedObject")
Expand All @@ -946,8 +946,8 @@ def _defineclasses(streamerinfos, classes):
bases.insert(0, "uproot3.tree.TTreeMethods")
if pyclassname == "TBranch":
bases.insert(0, "uproot3.tree.TBranchMethods")
if uproot_methods.classes.hasmethods(pyclassname):
bases.insert(0, "uproot_methods.classes.{0}.Methods".format(pyclassname))
if uproot3_methods.classes.hasmethods(pyclassname):
bases.insert(0, "uproot3_methods.classes.{0}.Methods".format(pyclassname))

code.insert(0, "class {0}({1}):".format(pyclassname, ", ".join(bases)))

Expand Down Expand Up @@ -1701,24 +1701,24 @@ def __repr__(self):
else:
return "<{0} at 0x{1:012x}>".format(self.__class__.__name__, id(self))

builtin_classes = {"uproot_methods": uproot_methods,
"TObject": TObject,
"TString": TString,
"TNamed": TNamed,
"TObjArray": TObjArray,
"TObjString": TObjString,
"TList": TList,
"THashList": THashList,
"TRef": TRef,
"TArray": TArray,
"TArrayC": TArrayC,
"TArrayS": TArrayS,
"TArrayI": TArrayI,
"TArrayL": TArrayL,
"TArrayL64": TArrayL64,
"TArrayF": TArrayF,
"TArrayD": TArrayD,
"TRefArray": TRefArray,
builtin_classes = {"uproot3_methods": uproot3_methods,
"TObject": TObject,
"TString": TString,
"TNamed": TNamed,
"TObjArray": TObjArray,
"TObjString": TObjString,
"TList": TList,
"THashList": THashList,
"TRef": TRef,
"TArray": TArray,
"TArrayC": TArrayC,
"TArrayS": TArrayS,
"TArrayI": TArrayI,
"TArrayL": TArrayL,
"TArrayL64": TArrayL64,
"TArrayF": TArrayF,
"TArrayD": TArrayD,
"TRefArray": TRefArray,
"ROOT_3a3a_TIOFeatures": ROOT_3a3a_TIOFeatures,
"ROOT_3a3a_Experimental_3a3a_RNTuple": ROOT_3a3a_Experimental_3a3a_RNTuple}

Expand Down
6 changes: 3 additions & 3 deletions uproot3/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import cachetools

import awkward0
import uproot_methods.profiles
import uproot3_methods.profiles

import uproot3.rootio
from uproot3.rootio import _bytesid
Expand Down Expand Up @@ -643,7 +643,7 @@ def lazyarrays(self, branches=None, namedecode="utf-8", entrysteps=None, entryst
out[name].__doc__ = branch.title.decode('ascii')

if profile is not None:
out = uproot_methods.profiles.transformer(profile)(out)
out = uproot3_methods.profiles.transformer(profile)(out)
return out

def _normalize_entrysteps(self, entrysteps, branches, entrystart, entrystop, keycache):
Expand Down Expand Up @@ -2059,7 +2059,7 @@ def lazyarrays(path, treepath, branches=None, namedecode="utf-8", entrysteps=flo
out[name] = awkward0.ChunkedArray(chunks, counts)

if profile is not None:
out = uproot_methods.profiles.transformer(profile)(out)
out = uproot3_methods.profiles.transformer(profile)(out)
return out

def daskarray(path, treepath, branchname, interpretation=None, namedecode="utf-8", entrysteps=float("inf"), flatten=False, awkwardlib=None, cache=None, basketcache=None, keycache=None, executor=None, localsource=MemmapSource.defaults, xrootdsource=XRootDSource.defaults, httpsource=HTTPSource.defaults, **options):
Expand Down
2 changes: 1 addition & 1 deletion uproot3/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import re

__version__ = "3.14.0"
__version__ = "3.14.1"
version = __version__
version_info = tuple(re.split(r"[-\.]", __version__))

Expand Down
6 changes: 3 additions & 3 deletions uproot3/write/TFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from collections import Mapping


import uproot_methods.convert
import uproot3_methods.convert

import uproot3.const
import uproot3.source.file
Expand Down Expand Up @@ -85,7 +85,7 @@ def __setitem__(self, where, what):
self.util = Util()
where, cycle = self._normalizewhere(where)
if what.__class__.__name__ != "TTree" and what.__class__.__name__ != "newtree":
what = uproot_methods.convert.towriteable(what)
what = uproot3_methods.convert.towriteable(what)
elif what.__class__.__name__ == "newtree":
what = TTree(where, what, self)
cursor = uproot3.write.sink.cursor.Cursor(self._fSeekFree)
Expand Down Expand Up @@ -124,7 +124,7 @@ def update(self, *args, **kwargs):
isTTree = what.__class__.__name__ in ("newtree", "TTree")
assert not isTTree # prevent TTree writing, otherwise migth invoke nasty magic
if not isTTree:
what = uproot_methods.convert.towriteable(what)
what = uproot3_methods.convert.towriteable(what)
elif what.__class__.__name__ == "newtree":
what = TTree(where, what, self)

Expand Down