Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
Merge pull request #93 from scikit-hep/jpivarski/rename-awkward-as-aw…
Browse files Browse the repository at this point in the history
…kward0

Removed Travis and AppVeyor tests and renamed awkward -> awkward0.
  • Loading branch information
jpivarski authored Nov 23, 2020
2 parents 95ab507 + 0180b22 commit 7655097
Show file tree
Hide file tree
Showing 18 changed files with 287 additions and 428 deletions.
69 changes: 0 additions & 69 deletions .travis.yml

This file was deleted.

15 changes: 4 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ Pythonic mix-ins for ROOT classes.

.. inclusion-marker-1-5-do-not-remove
This package is typically used as a dependency for `uproot <https://github.com/scikit-hep/uproot>`__, to define methods on the classes that are automatically generated from ROOT files. This includes histograms (TH*) and physics objects like TLorentzVectors. The reason it's a separate library is so that we can add physics-specific functionality on a shorter timescale than we can update uproot itself, which is purely an I/O package.
This package is typically used as a dependency for `uproot 3.x <https://github.com/scikit-hep/uproot3>`__, to define methods on the classes that are automatically generated from ROOT files. This includes histograms (TH*) and physics objects like TLorentzVectors. The reason it's a separate library is so that we can add physics-specific functionality on a shorter timescale than we can update uproot itself, which is purely an I/O package.

Occasionally, this library is used without uproot, as a way to make arrays of TLorentzVectors.

**Note:** this package is incompatible with ``awkward>=1.0`` and ``uproot>=4.0``! For Lorentz vectors, use `vector <https://github.com/scikit-hep/vector>`__. Since the versions of Awkward Array and Uproot that this is compatible with are deprecated, **this library is deprecated** as well.

.. inclusion-marker-2-do-not-remove
Installation
Expand All @@ -22,20 +24,11 @@ Install uproot-methods like any other Python package:
pip install uproot-methods # maybe with sudo or --user, or in virtualenv
or install with `conda <https://conda.io/en/latest/miniconda.html>`__:

.. code-block:: bash
conda config --add channels conda-forge # if you haven't added conda-forge already
conda install uproot-methods
Both installers automatically install the dependencies.

Dependencies:
-------------

- `numpy <https://scipy.org/install.html>`__ (1.13.1+)
- `awkward-array <https://github.com/scikit-hep/awkward-array>`__ (0.11.0+)
- `Awkward Array 0.x <https://github.com/scikit-hep/awkward-0.x>`__

.. inclusion-marker-3-do-not-remove
Expand Down
66 changes: 0 additions & 66 deletions appveyor.yml

This file was deleted.

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
numpy>=1.13.1
awkward>=0.11.0
awkward0
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ def get_description():
download_url = "https://github.com/scikit-hep/uproot-methods/releases",
license = "BSD 3-clause",
test_suite = "tests",
install_requires = ["numpy>=1.13.1", "awkward>=0.11.0"],
install_requires = ["numpy>=1.13.1", "awkward0"],
tests_require = [],
classifiers = [
"Development Status :: 5 - Production/Stable",
"Development Status :: 7 - Inactive",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
Expand Down
32 changes: 16 additions & 16 deletions tests/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy

import awkward
import awkward0
import uproot_methods
from uproot_methods import *

Expand All @@ -17,35 +17,35 @@ def runTest(self):
pass

def test_issue10(self):
p4 = TLorentzVectorArray.from_ptetaphim(awkward.JaggedArray.fromiter([[1.0]]), awkward.JaggedArray.fromiter([[1.0]]), awkward.JaggedArray.fromiter([[1.0]]), awkward.JaggedArray.fromiter([[1.0]]))
p4 = TLorentzVectorArray.from_ptetaphim(awkward0.JaggedArray.fromiter([[1.0]]), awkward0.JaggedArray.fromiter([[1.0]]), awkward0.JaggedArray.fromiter([[1.0]]), awkward0.JaggedArray.fromiter([[1.0]]))
assert p4.mass.tolist() == [[1.0]]
assert p4[0].mass.tolist() == [1.0]
assert p4[0][0].mass == 1.0
assert p4[0][0]._to_cartesian().mass == 0.9999999999999999
assert type(p4.mass) is awkward.JaggedArray
assert type(p4.x) is awkward.JaggedArray
assert type(p4.mass) is awkward0.JaggedArray
assert type(p4.x) is awkward0.JaggedArray

p3 = TVector3Array.from_cylindrical(awkward.JaggedArray.fromiter([[1.0]]), awkward.JaggedArray.fromiter([[1.0]]), awkward.JaggedArray.fromiter([[1.0]]))
p3 = TVector3Array.from_cylindrical(awkward0.JaggedArray.fromiter([[1.0]]), awkward0.JaggedArray.fromiter([[1.0]]), awkward0.JaggedArray.fromiter([[1.0]]))
assert p3.rho.tolist() == [[1.0]]
assert p3[0].rho.tolist() == [1.0]
assert p3[0][0].rho == 1.0
assert type(p3.rho) is awkward.JaggedArray
assert type(p3.x) is awkward.JaggedArray
assert type(p3.rho) is awkward0.JaggedArray
assert type(p3.x) is awkward0.JaggedArray

p2 = TVector2Array.from_polar(awkward.JaggedArray.fromiter([[1.0]]), awkward.JaggedArray.fromiter([[1.0]]))
p2 = TVector2Array.from_polar(awkward0.JaggedArray.fromiter([[1.0]]), awkward0.JaggedArray.fromiter([[1.0]]))
assert p2.rho.tolist() == [[1.0]]
assert p2[0].rho.tolist() == [1.0]
assert p2[0][0].rho == 1.0
assert type(p2.rho) is awkward.JaggedArray
assert type(p2.x) is awkward.JaggedArray
assert type(p2.rho) is awkward0.JaggedArray
assert type(p2.x) is awkward0.JaggedArray

def test_issue39(self):
counts = [2,2,2]
mask = [True, False, True]

pt = awkward.JaggedArray.fromcounts(counts, [42.71, 31.46, 58.72, 30.19, 47.75, 10.83])
eta = awkward.JaggedArray.fromcounts(counts, [0.54, 1.57, -2.33, -1.22, -2.03, -0.37])
phi = awkward.JaggedArray.fromcounts(counts, [-2.13, 0.65, 2.74, 0.36, 2.87, -0.47])
pt = awkward0.JaggedArray.fromcounts(counts, [42.71, 31.46, 58.72, 30.19, 47.75, 10.83])
eta = awkward0.JaggedArray.fromcounts(counts, [0.54, 1.57, -2.33, -1.22, -2.03, -0.37])
phi = awkward0.JaggedArray.fromcounts(counts, [-2.13, 0.65, 2.74, 0.36, 2.87, -0.47])

pt = pt[mask]
eta = eta[mask]
Expand All @@ -60,6 +60,6 @@ def test_issue61(self):
_ys = numpy.array([0, 2, 1])
arr = TVector2Array.from_cartesian(_xs, _ys).rotate(numpy.pi/4).rotate(-numpy.pi/4)

_jxs = awkward.JaggedArray.fromiter([[2,], [], [0, 1]])
_jys = awkward.JaggedArray.fromiter([[0,], [], [2, 1]])
jarr = TVector2Array.from_cartesian(_jxs, _jys).rotate(numpy.pi/3).rotate(-numpy.pi/3)
_jxs = awkward0.JaggedArray.fromiter([[2,], [], [0, 1]])
_jys = awkward0.JaggedArray.fromiter([[0,], [], [2, 1]])
jarr = TVector2Array.from_cartesian(_jxs, _jys).rotate(numpy.pi/3).rotate(-numpy.pi/3)
8 changes: 4 additions & 4 deletions tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy

import awkward
import awkward0
import uproot_methods
from uproot_methods import *

Expand Down Expand Up @@ -47,7 +47,7 @@ def test_vector2_array(self):
assert (a**3).tolist() == [0.0, 1.0, 8.0, 27.0, 64.0, 125.0, 216.0, 343.0, 512.0, 729.0]

def test_vector2_jagged(self):
TVector2Jagged = type("TVector2Jagged", (awkward.JaggedArray, uproot_methods.classes.TVector2.ArrayMethods), {})
TVector2Jagged = type("TVector2Jagged", (awkward0.JaggedArray, uproot_methods.classes.TVector2.ArrayMethods), {})
a = TVector2Jagged.fromoffsets([0, 3, 3, 5, 10], TVector2Array(numpy.zeros(10), numpy.arange(10)))
a._generator = uproot_methods.classes.TVector2.TVector2
a._args = ()
Expand Down Expand Up @@ -113,7 +113,7 @@ def test_vector3_array(self):
numpy.testing.assert_almost_equal(a[1:].angle(-2 * a[1:]), numpy.ones_like(a[1:]) * numpy.pi)

def test_vector3_jagged(self):
TVector3Jagged = type("TVector3Jagged", (awkward.JaggedArray, uproot_methods.classes.TVector3.ArrayMethods), {})
TVector3Jagged = type("TVector3Jagged", (awkward0.JaggedArray, uproot_methods.classes.TVector3.ArrayMethods), {})
a = TVector3Jagged.fromoffsets([0, 3, 3, 5, 10], TVector3Array(numpy.zeros(10), numpy.arange(10), numpy.zeros(10)))
a._generator = uproot_methods.classes.TVector3.TVector3
a._args = ()
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_ptetaphim_array(self):
assert a.sum().mass == numpy.hypot(20 * numpy.cosh(a.eta), a.mass).sum()

def test_lorentzvector_jagged(self):
TLorentzVectorJagged = type("TLorentzVectorJagged", (awkward.JaggedArray, uproot_methods.classes.TLorentzVector.ArrayMethods), {})
TLorentzVectorJagged = type("TLorentzVectorJagged", (awkward0.JaggedArray, uproot_methods.classes.TLorentzVector.ArrayMethods), {})
a = TLorentzVectorJagged.fromoffsets([0, 3, 3, 5, 10], TLorentzVectorArray(numpy.zeros(10), numpy.arange(10), numpy.zeros(10), numpy.zeros(10)))
a._generator = uproot_methods.classes.TLorentzVector.TLorentzVector
a._args = ()
Expand Down
11 changes: 6 additions & 5 deletions uproot_methods/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@

# BSD 3-Clause License; see https://github.com/scikit-hep/uproot-methods/blob/master/LICENSE

import awkward
import awkward.util
import awkward0
import awkward0.util

class ROOTMethods(awkward.Methods):
class ROOTMethods(awkward0.Methods):
_arraymethods = None

awkward = awkward
awkward = awkward0
awkward0 = awkward0

def __ne__(self, other):
return not self.__eq__(other)

def _trymemo(self, name, function):
memoname = "_memo_" + name
wrap, (array,) = awkward.util.unwrap_jagged(type(self), self.JaggedArray, (self,))
wrap, (array,) = awkward0.util.unwrap_jagged(type(self), self.JaggedArray, (self,))
if not hasattr(array, memoname):
setattr(array, memoname, function(array))
return wrap(getattr(array, memoname))
Loading

0 comments on commit 7655097

Please sign in to comment.