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 #9 from scikit-hep/henryiii-cross-fix
Browse files Browse the repository at this point in the history
Adding fix for cross and rotate
  • Loading branch information
jpivarski authored Nov 8, 2018
2 parents 7e0af9e + d2ed45e commit 77f5667
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
11 changes: 6 additions & 5 deletions tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# Copyright (c) 2018, DIANA-HEP
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -87,6 +87,7 @@ def test_vector2_jagged(self):
def test_vector3(self):
a = TVector3(4.4, 5.5, 0)
self.assertEqual(a.dot(a), 49.61)
self.assertEqual(a.cross(a), TVector3(0,0,0))
self.assertEqual(a + TVector3(1000, 2000, 0), TVector3(1004.4, 2005.5, 0))
self.assertEqual(a - TVector3(1000, 2000, 0), TVector3(-995.6, -1994.5, 0))
self.assertEqual(TVector3(1000, 2000, 0) - a, TVector3(995.6, 1994.5, 0))
Expand Down
16 changes: 8 additions & 8 deletions uproot_methods/classes/TVector3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# Copyright (c) 2018, DIANA-HEP
# All rights reserved.
#
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Expand Down Expand Up @@ -227,18 +227,18 @@ def _unary(self, operator):

def cross(self, other):
x, y, z = self._cross(other)
return self.TVector3(x, y, z)
return TVector3(x, y, z)

@property
def theta(self):
return math.atan2(self.rho, self.z)

def rotate_axis(self, axis, angle):
x, y, z = self._rotate_axis(axis, angle)
return self.TVector3(x, y, z)
return TVector3(x, y, z)

def rotate_euler(self, phi=0, theta=0, psi=0):
return self.TVector3(x, y, z)
return TVector3(x, y, z)

class TVector3Array(ArrayMethods, awkward.ObjectArray):
def __init__(self, x, y, z):
Expand Down

0 comments on commit 77f5667

Please sign in to comment.