From 0b9bf7ef622b634b749a0fa664da2c2a565affa1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 31 Jan 2022 23:50:14 -0500 Subject: [PATCH] [pre-commit.ci] pre-commit autoupdate (#169) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 21.12b0 → 22.1.0](https://github.com/psf/black/compare/21.12b0...22.1.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- src/vector/_backends/awkward_.py | 38 ++++++++-------- src/vector/_backends/numba_object.py | 18 ++++---- src/vector/_compute/lorentz/Et.py | 2 +- src/vector/_compute/lorentz/Et2.py | 8 ++-- src/vector/_compute/lorentz/Mt2.py | 16 +++---- src/vector/_compute/lorentz/boostX_beta.py | 24 +++++------ src/vector/_compute/lorentz/boostX_gamma.py | 24 +++++------ src/vector/_compute/lorentz/boostY_beta.py | 24 +++++------ src/vector/_compute/lorentz/boostY_gamma.py | 24 +++++------ src/vector/_compute/lorentz/boostZ_beta.py | 24 +++++------ src/vector/_compute/lorentz/boostZ_gamma.py | 24 +++++------ src/vector/_compute/lorentz/boost_beta3.py | 8 ++-- src/vector/_compute/lorentz/boost_p4.py | 48 ++++++++++----------- src/vector/_compute/lorentz/t2.py | 12 +++--- src/vector/_compute/lorentz/tau2.py | 24 +++++------ src/vector/_compute/planar/add.py | 2 +- src/vector/_compute/planar/rho2.py | 4 +- src/vector/_compute/planar/subtract.py | 2 +- src/vector/_compute/spatial/dot.py | 4 +- src/vector/_compute/spatial/eta.py | 4 +- src/vector/_compute/spatial/mag.py | 8 ++-- src/vector/_compute/spatial/mag2.py | 16 +++---- src/vector/_compute/spatial/rotate_axis.py | 8 ++-- tests/backends/test_awkward.py | 2 +- tests/backends/test_numba_object.py | 6 +-- tests/backends/test_operators.py | 16 +++---- 27 files changed, 196 insertions(+), 196 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bbc74c1b..3013bd35 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,7 +6,7 @@ repos: args: [--py36-plus] - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.1.0 hooks: - id: black diff --git a/src/vector/_backends/awkward_.py b/src/vector/_backends/awkward_.py index d11e2e8e..1d2ca97f 100644 --- a/src/vector/_backends/awkward_.py +++ b/src/vector/_backends/awkward_.py @@ -865,37 +865,37 @@ class MomentumRecord4D(MomentumAwkward4D, ak.Record): # type: ignore[misc] behavior[numpy.square, "Momentum3D"] = lambda v: v.mag2 behavior[numpy.square, "Momentum4D"] = lambda v: v.tau2 -behavior[numpy.sqrt, "Vector2D"] = lambda v: v.rho2 ** 0.25 -behavior[numpy.sqrt, "Vector3D"] = lambda v: v.mag2 ** 0.25 -behavior[numpy.sqrt, "Vector4D"] = lambda v: v.tau2 ** 0.25 -behavior[numpy.sqrt, "Momentum2D"] = lambda v: v.rho2 ** 0.25 -behavior[numpy.sqrt, "Momentum3D"] = lambda v: v.mag2 ** 0.25 -behavior[numpy.sqrt, "Momentum4D"] = lambda v: v.tau2 ** 0.25 - -behavior[numpy.cbrt, "Vector2D"] = lambda v: v.rho2 ** 0.16666666666666666 -behavior[numpy.cbrt, "Vector3D"] = lambda v: v.mag2 ** 0.16666666666666666 -behavior[numpy.cbrt, "Vector4D"] = lambda v: v.tau2 ** 0.16666666666666666 -behavior[numpy.cbrt, "Momentum2D"] = lambda v: v.rho2 ** 0.16666666666666666 -behavior[numpy.cbrt, "Momentum3D"] = lambda v: v.mag2 ** 0.16666666666666666 -behavior[numpy.cbrt, "Momentum4D"] = lambda v: v.tau2 ** 0.16666666666666666 +behavior[numpy.sqrt, "Vector2D"] = lambda v: v.rho2**0.25 +behavior[numpy.sqrt, "Vector3D"] = lambda v: v.mag2**0.25 +behavior[numpy.sqrt, "Vector4D"] = lambda v: v.tau2**0.25 +behavior[numpy.sqrt, "Momentum2D"] = lambda v: v.rho2**0.25 +behavior[numpy.sqrt, "Momentum3D"] = lambda v: v.mag2**0.25 +behavior[numpy.sqrt, "Momentum4D"] = lambda v: v.tau2**0.25 + +behavior[numpy.cbrt, "Vector2D"] = lambda v: v.rho2**0.16666666666666666 +behavior[numpy.cbrt, "Vector3D"] = lambda v: v.mag2**0.16666666666666666 +behavior[numpy.cbrt, "Vector4D"] = lambda v: v.tau2**0.16666666666666666 +behavior[numpy.cbrt, "Momentum2D"] = lambda v: v.rho2**0.16666666666666666 +behavior[numpy.cbrt, "Momentum3D"] = lambda v: v.mag2**0.16666666666666666 +behavior[numpy.cbrt, "Momentum4D"] = lambda v: v.tau2**0.16666666666666666 behavior[numpy.power, "Vector2D", numbers.Real] = ( - lambda v, expo: v.rho2 if expo == 2 else v.rho ** expo + lambda v, expo: v.rho2 if expo == 2 else v.rho**expo ) behavior[numpy.power, "Vector3D", numbers.Real] = ( - lambda v, expo: v.mag2 if expo == 2 else v.mag ** expo + lambda v, expo: v.mag2 if expo == 2 else v.mag**expo ) behavior[numpy.power, "Vector4D", numbers.Real] = ( - lambda v, expo: v.tau2 if expo == 2 else v.tau ** expo + lambda v, expo: v.tau2 if expo == 2 else v.tau**expo ) behavior[numpy.power, "Momentum2D", numbers.Real] = ( - lambda v, expo: v.rho2 if expo == 2 else v.rho ** expo + lambda v, expo: v.rho2 if expo == 2 else v.rho**expo ) behavior[numpy.power, "Momentum3D", numbers.Real] = ( - lambda v, expo: v.mag2 if expo == 2 else v.mag ** expo + lambda v, expo: v.mag2 if expo == 2 else v.mag**expo ) behavior[numpy.power, "Momentum4D", numbers.Real] = ( - lambda v, expo: v.tau2 if expo == 2 else v.tau ** expo + lambda v, expo: v.tau2 if expo == 2 else v.tau**expo ) behavior["__cast__", VectorNumpy2D] = lambda v: vector.Array(v) diff --git a/src/vector/_backends/numba_object.py b/src/vector/_backends/numba_object.py index 9785e579..1918e692 100644 --- a/src/vector/_backends/numba_object.py +++ b/src/vector/_backends/numba_object.py @@ -3170,21 +3170,21 @@ def numpy_sqrt(v): if isinstance(v, VectorObject2DType): def numpy_sqrt_impl(v): - return v.rho2 ** 0.25 + return v.rho2**0.25 return numpy_sqrt_impl elif isinstance(v, VectorObject3DType): def numpy_sqrt_impl(v): - return v.mag2 ** 0.25 + return v.mag2**0.25 return numpy_sqrt_impl elif isinstance(v, VectorObject4DType): def numpy_sqrt_impl(v): - return v.tau2 ** 0.25 + return v.tau2**0.25 return numpy_sqrt_impl @@ -3194,21 +3194,21 @@ def numpy_cbrt(v): if isinstance(v, VectorObject2DType): def numpy_cbrt_impl(v): - return v.rho2 ** 0.16666666666666666 + return v.rho2**0.16666666666666666 return numpy_cbrt_impl elif isinstance(v, VectorObject3DType): def numpy_cbrt_impl(v): - return v.mag2 ** 0.16666666666666666 + return v.mag2**0.16666666666666666 return numpy_cbrt_impl elif isinstance(v, VectorObject4DType): def numpy_cbrt_impl(v): - return v.tau2 ** 0.16666666666666666 + return v.tau2**0.16666666666666666 return numpy_cbrt_impl @@ -3223,7 +3223,7 @@ def numpy_power_impl(v, expo): if expo == 2: return v.rho2 else: - return v.rho ** expo + return v.rho**expo return numpy_power_impl @@ -3235,7 +3235,7 @@ def numpy_power_impl(v, expo): if expo == 2: return v.mag2 else: - return v.mag ** expo + return v.mag**expo return numpy_power_impl @@ -3247,7 +3247,7 @@ def numpy_power_impl(v, expo): if expo == 2: return v.tau2 else: - return v.tau ** expo + return v.tau**expo return numpy_power_impl diff --git a/src/vector/_compute/lorentz/Et.py b/src/vector/_compute/lorentz/Et.py index 1e68e5d5..e3bfcbbc 100644 --- a/src/vector/_compute/lorentz/Et.py +++ b/src/vector/_compute/lorentz/Et.py @@ -57,7 +57,7 @@ def xy_eta_tau(lib, x, y, eta, tau): def rhophi_z_t(lib, rho, phi, z, t): - return t * rho / lib.sqrt(rho ** 2 + z ** 2) + return t * rho / lib.sqrt(rho**2 + z**2) def rhophi_z_tau(lib, rho, phi, z, tau): diff --git a/src/vector/_compute/lorentz/Et2.py b/src/vector/_compute/lorentz/Et2.py index 3cde8a0b..94dd075c 100644 --- a/src/vector/_compute/lorentz/Et2.py +++ b/src/vector/_compute/lorentz/Et2.py @@ -32,8 +32,8 @@ def xy_z_t(lib, x, y, z, t): - pt2 = x ** 2 + y ** 2 - return t ** 2 * pt2 / (pt2 + z ** 2) + pt2 = x**2 + y**2 + return t**2 * pt2 / (pt2 + z**2) def xy_z_tau(lib, x, y, z, tau): @@ -58,8 +58,8 @@ def xy_eta_tau(lib, x, y, eta, tau): def rhophi_z_t(lib, rho, phi, z, t): - pt2 = rho ** 2 - return t ** 2 * pt2 / (pt2 + z ** 2) + pt2 = rho**2 + return t**2 * pt2 / (pt2 + z**2) def rhophi_z_tau(lib, rho, phi, z, tau): diff --git a/src/vector/_compute/lorentz/Mt2.py b/src/vector/_compute/lorentz/Mt2.py index 144ece35..a941e3b7 100644 --- a/src/vector/_compute/lorentz/Mt2.py +++ b/src/vector/_compute/lorentz/Mt2.py @@ -33,11 +33,11 @@ def xy_z_t(lib, x, y, z, t): - return t ** 2 - z ** 2 + return t**2 - z**2 def xy_z_tau(lib, x, y, z, tau): - return lib.maximum(tau2.xy_z_tau(lib, x, y, z, tau) + x ** 2 + y ** 2, 0) + return lib.maximum(tau2.xy_z_tau(lib, x, y, z, tau) + x**2 + y**2, 0) def xy_theta_t(lib, x, y, theta, t): @@ -45,7 +45,7 @@ def xy_theta_t(lib, x, y, theta, t): def xy_theta_tau(lib, x, y, theta, tau): - return lib.maximum(tau2.xy_theta_tau(lib, x, y, theta, tau) + x ** 2 + y ** 2, 0) + return lib.maximum(tau2.xy_theta_tau(lib, x, y, theta, tau) + x**2 + y**2, 0) def xy_eta_t(lib, x, y, eta, t): @@ -53,15 +53,15 @@ def xy_eta_t(lib, x, y, eta, t): def xy_eta_tau(lib, x, y, eta, tau): - return lib.maximum(tau2.xy_eta_tau(lib, x, y, eta, tau) + x ** 2 + y ** 2, 0) + return lib.maximum(tau2.xy_eta_tau(lib, x, y, eta, tau) + x**2 + y**2, 0) def rhophi_z_t(lib, rho, phi, z, t): - return t ** 2 - z ** 2 + return t**2 - z**2 def rhophi_z_tau(lib, rho, phi, z, tau): - return lib.maximum(tau2.rhophi_z_tau(lib, rho, phi, z, tau) + rho ** 2, 0) + return lib.maximum(tau2.rhophi_z_tau(lib, rho, phi, z, tau) + rho**2, 0) def rhophi_theta_t(lib, rho, phi, theta, t): @@ -69,7 +69,7 @@ def rhophi_theta_t(lib, rho, phi, theta, t): def rhophi_theta_tau(lib, rho, phi, theta, tau): - return lib.maximum(tau2.rhophi_theta_tau(lib, rho, phi, theta, tau) + rho ** 2, 0) + return lib.maximum(tau2.rhophi_theta_tau(lib, rho, phi, theta, tau) + rho**2, 0) def rhophi_eta_t(lib, rho, phi, eta, t): @@ -77,7 +77,7 @@ def rhophi_eta_t(lib, rho, phi, eta, t): def rhophi_eta_tau(lib, rho, phi, eta, tau): - return lib.maximum(tau2.rhophi_eta_tau(lib, rho, phi, eta, tau) + rho ** 2, 0) + return lib.maximum(tau2.rhophi_eta_tau(lib, rho, phi, eta, tau) + rho**2, 0) dispatch_map = { diff --git a/src/vector/_compute/lorentz/boostX_beta.py b/src/vector/_compute/lorentz/boostX_beta.py index 2ebf519b..aa9b50f6 100644 --- a/src/vector/_compute/lorentz/boostX_beta.py +++ b/src/vector/_compute/lorentz/boostX_beta.py @@ -33,7 +33,7 @@ def xy_z_t(lib, beta, x, y, z, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -43,7 +43,7 @@ def xy_z_t(lib, beta, x, y, z, t): def xy_z_tau(lib, beta, x, y, z, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -53,7 +53,7 @@ def xy_z_tau(lib, beta, x, y, z, tau): def xy_theta_t(lib, beta, x, y, theta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -63,7 +63,7 @@ def xy_theta_t(lib, beta, x, y, theta, t): def xy_theta_tau(lib, beta, x, y, theta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -73,7 +73,7 @@ def xy_theta_tau(lib, beta, x, y, theta, tau): def xy_eta_t(lib, beta, x, y, eta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -83,7 +83,7 @@ def xy_eta_t(lib, beta, x, y, eta, t): def xy_eta_tau(lib, beta, x, y, eta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -93,7 +93,7 @@ def xy_eta_tau(lib, beta, x, y, eta, tau): def rhophi_z_t(lib, beta, rho, phi, z, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -103,7 +103,7 @@ def rhophi_z_t(lib, beta, rho, phi, z, t): def rhophi_z_tau(lib, beta, rho, phi, z, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -113,7 +113,7 @@ def rhophi_z_tau(lib, beta, rho, phi, z, tau): def rhophi_theta_t(lib, beta, rho, phi, theta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -123,7 +123,7 @@ def rhophi_theta_t(lib, beta, rho, phi, theta, t): def rhophi_theta_tau(lib, beta, rho, phi, theta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -133,7 +133,7 @@ def rhophi_theta_tau(lib, beta, rho, phi, theta, tau): def rhophi_eta_t(lib, beta, rho, phi, eta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -143,7 +143,7 @@ def rhophi_eta_t(lib, beta, rho, phi, eta, t): def rhophi_eta_tau(lib, beta, rho, phi, eta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) diff --git a/src/vector/_compute/lorentz/boostX_gamma.py b/src/vector/_compute/lorentz/boostX_gamma.py index 7765b3e3..60d914ce 100644 --- a/src/vector/_compute/lorentz/boostX_gamma.py +++ b/src/vector/_compute/lorentz/boostX_gamma.py @@ -34,7 +34,7 @@ def xy_z_t(lib, gamma, x, y, z, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z @@ -44,7 +44,7 @@ def xy_z_t(lib, gamma, x, y, z, t): def xy_z_tau(lib, gamma, x, y, z, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z @@ -54,7 +54,7 @@ def xy_z_tau(lib, gamma, x, y, z, tau): def xy_theta_t(lib, gamma, x, y, theta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_theta(lib, x, y, theta) @@ -64,7 +64,7 @@ def xy_theta_t(lib, gamma, x, y, theta, t): def xy_theta_tau(lib, gamma, x, y, theta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_theta(lib, x, y, theta) @@ -74,7 +74,7 @@ def xy_theta_tau(lib, gamma, x, y, theta, tau): def xy_eta_t(lib, gamma, x, y, eta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_eta(lib, x, y, eta) @@ -84,7 +84,7 @@ def xy_eta_t(lib, gamma, x, y, eta, t): def xy_eta_tau(lib, gamma, x, y, eta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_eta(lib, x, y, eta) @@ -94,7 +94,7 @@ def xy_eta_tau(lib, gamma, x, y, eta, tau): def rhophi_z_t(lib, gamma, rho, phi, z, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z @@ -104,7 +104,7 @@ def rhophi_z_t(lib, gamma, rho, phi, z, t): def rhophi_z_tau(lib, gamma, rho, phi, z, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z @@ -114,7 +114,7 @@ def rhophi_z_tau(lib, gamma, rho, phi, z, tau): def rhophi_theta_t(lib, gamma, rho, phi, theta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_theta(lib, rho, phi, theta) @@ -124,7 +124,7 @@ def rhophi_theta_t(lib, gamma, rho, phi, theta, t): def rhophi_theta_tau(lib, gamma, rho, phi, theta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_theta(lib, rho, phi, theta) @@ -134,7 +134,7 @@ def rhophi_theta_tau(lib, gamma, rho, phi, theta, tau): def rhophi_eta_t(lib, gamma, rho, phi, eta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_eta(lib, rho, phi, eta) @@ -144,7 +144,7 @@ def rhophi_eta_t(lib, gamma, rho, phi, eta, t): def rhophi_eta_tau(lib, gamma, rho, phi, eta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_eta(lib, rho, phi, eta) diff --git a/src/vector/_compute/lorentz/boostY_beta.py b/src/vector/_compute/lorentz/boostY_beta.py index 71e3fe6c..1d7bb88b 100644 --- a/src/vector/_compute/lorentz/boostY_beta.py +++ b/src/vector/_compute/lorentz/boostY_beta.py @@ -33,7 +33,7 @@ def xy_z_t(lib, beta, x, y, z, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -43,7 +43,7 @@ def xy_z_t(lib, beta, x, y, z, t): def xy_z_tau(lib, beta, x, y, z, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -53,7 +53,7 @@ def xy_z_tau(lib, beta, x, y, z, tau): def xy_theta_t(lib, beta, x, y, theta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -63,7 +63,7 @@ def xy_theta_t(lib, beta, x, y, theta, t): def xy_theta_tau(lib, beta, x, y, theta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -73,7 +73,7 @@ def xy_theta_tau(lib, beta, x, y, theta, tau): def xy_eta_t(lib, beta, x, y, eta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -83,7 +83,7 @@ def xy_eta_t(lib, beta, x, y, eta, t): def xy_eta_tau(lib, beta, x, y, eta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x why = y @@ -93,7 +93,7 @@ def xy_eta_tau(lib, beta, x, y, eta, tau): def rhophi_z_t(lib, beta, rho, phi, z, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -103,7 +103,7 @@ def rhophi_z_t(lib, beta, rho, phi, z, t): def rhophi_z_tau(lib, beta, rho, phi, z, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -113,7 +113,7 @@ def rhophi_z_tau(lib, beta, rho, phi, z, tau): def rhophi_theta_t(lib, beta, rho, phi, theta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -123,7 +123,7 @@ def rhophi_theta_t(lib, beta, rho, phi, theta, t): def rhophi_theta_tau(lib, beta, rho, phi, theta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -133,7 +133,7 @@ def rhophi_theta_tau(lib, beta, rho, phi, theta, tau): def rhophi_eta_t(lib, beta, rho, phi, eta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) @@ -143,7 +143,7 @@ def rhophi_eta_t(lib, beta, rho, phi, eta, t): def rhophi_eta_tau(lib, beta, rho, phi, eta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) diff --git a/src/vector/_compute/lorentz/boostY_gamma.py b/src/vector/_compute/lorentz/boostY_gamma.py index 349788c8..7acde845 100644 --- a/src/vector/_compute/lorentz/boostY_gamma.py +++ b/src/vector/_compute/lorentz/boostY_gamma.py @@ -34,7 +34,7 @@ def xy_z_t(lib, gamma, x, y, z, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z @@ -44,7 +44,7 @@ def xy_z_t(lib, gamma, x, y, z, t): def xy_z_tau(lib, gamma, x, y, z, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z @@ -54,7 +54,7 @@ def xy_z_tau(lib, gamma, x, y, z, tau): def xy_theta_t(lib, gamma, x, y, theta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_theta(lib, x, y, theta) @@ -64,7 +64,7 @@ def xy_theta_t(lib, gamma, x, y, theta, t): def xy_theta_tau(lib, gamma, x, y, theta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_theta(lib, x, y, theta) @@ -74,7 +74,7 @@ def xy_theta_tau(lib, gamma, x, y, theta, tau): def xy_eta_t(lib, gamma, x, y, eta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_eta(lib, x, y, eta) @@ -84,7 +84,7 @@ def xy_eta_t(lib, gamma, x, y, eta, t): def xy_eta_tau(lib, gamma, x, y, eta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x why = y zee = z.xy_eta(lib, x, y, eta) @@ -94,7 +94,7 @@ def xy_eta_tau(lib, gamma, x, y, eta, tau): def rhophi_z_t(lib, gamma, rho, phi, z, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z @@ -104,7 +104,7 @@ def rhophi_z_t(lib, gamma, rho, phi, z, t): def rhophi_z_tau(lib, gamma, rho, phi, z, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z @@ -114,7 +114,7 @@ def rhophi_z_tau(lib, gamma, rho, phi, z, tau): def rhophi_theta_t(lib, gamma, rho, phi, theta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_theta(lib, rho, phi, theta) @@ -124,7 +124,7 @@ def rhophi_theta_t(lib, gamma, rho, phi, theta, t): def rhophi_theta_tau(lib, gamma, rho, phi, theta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_theta(lib, rho, phi, theta) @@ -134,7 +134,7 @@ def rhophi_theta_tau(lib, gamma, rho, phi, theta, tau): def rhophi_eta_t(lib, gamma, rho, phi, eta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_eta(lib, rho, phi, eta) @@ -144,7 +144,7 @@ def rhophi_eta_t(lib, gamma, rho, phi, eta, t): def rhophi_eta_tau(lib, gamma, rho, phi, eta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) exx = x.rhophi(lib, rho, phi) why = y.rhophi(lib, rho, phi) zee = z.rhophi_eta(lib, rho, phi, eta) diff --git a/src/vector/_compute/lorentz/boostZ_beta.py b/src/vector/_compute/lorentz/boostZ_beta.py index 4e0b29a5..63f62bad 100644 --- a/src/vector/_compute/lorentz/boostZ_beta.py +++ b/src/vector/_compute/lorentz/boostZ_beta.py @@ -32,7 +32,7 @@ def xy_z_t(lib, beta, x, y, z, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z tee = t @@ -40,7 +40,7 @@ def xy_z_t(lib, beta, x, y, z, t): def xy_z_tau(lib, beta, x, y, z, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z tee = t.xy_z_tau(lib, x, y, z, tau) @@ -48,7 +48,7 @@ def xy_z_tau(lib, beta, x, y, z, tau): def xy_theta_t(lib, beta, x, y, theta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.xy_theta(lib, x, y, theta) tee = t @@ -56,7 +56,7 @@ def xy_theta_t(lib, beta, x, y, theta, t): def xy_theta_tau(lib, beta, x, y, theta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.xy_theta(lib, x, y, theta) tee = t.xy_theta_tau(lib, x, y, theta, tau) @@ -64,7 +64,7 @@ def xy_theta_tau(lib, beta, x, y, theta, tau): def xy_eta_t(lib, beta, x, y, eta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.xy_eta(lib, x, y, eta) tee = t @@ -72,7 +72,7 @@ def xy_eta_t(lib, beta, x, y, eta, t): def xy_eta_tau(lib, beta, x, y, eta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.xy_eta(lib, x, y, eta) tee = t.xy_eta_tau(lib, x, y, eta, tau) @@ -80,7 +80,7 @@ def xy_eta_tau(lib, beta, x, y, eta, tau): def rhophi_z_t(lib, beta, rho, phi, z, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z tee = t @@ -88,7 +88,7 @@ def rhophi_z_t(lib, beta, rho, phi, z, t): def rhophi_z_tau(lib, beta, rho, phi, z, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z tee = t.rhophi_z_tau(lib, rho, phi, z, tau) @@ -96,7 +96,7 @@ def rhophi_z_tau(lib, beta, rho, phi, z, tau): def rhophi_theta_t(lib, beta, rho, phi, theta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.rhophi_theta(lib, rho, phi, theta) tee = t @@ -104,7 +104,7 @@ def rhophi_theta_t(lib, beta, rho, phi, theta, t): def rhophi_theta_tau(lib, beta, rho, phi, theta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.rhophi_theta(lib, rho, phi, theta) tee = t.rhophi_theta_tau(lib, rho, phi, theta, tau) @@ -112,7 +112,7 @@ def rhophi_theta_tau(lib, beta, rho, phi, theta, tau): def rhophi_eta_t(lib, beta, rho, phi, eta, t): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.rhophi_eta(lib, rho, phi, eta) tee = t @@ -120,7 +120,7 @@ def rhophi_eta_t(lib, beta, rho, phi, eta, t): def rhophi_eta_tau(lib, beta, rho, phi, eta, tau): - gam = (1 - beta ** 2) ** -0.5 + gam = (1 - beta**2) ** -0.5 bgam = beta * gam zee = z.rhophi_eta(lib, rho, phi, eta) tee = t.rhophi_eta_tau(lib, rho, phi, eta, tau) diff --git a/src/vector/_compute/lorentz/boostZ_gamma.py b/src/vector/_compute/lorentz/boostZ_gamma.py index 88d7eb2e..95b6a6b4 100644 --- a/src/vector/_compute/lorentz/boostZ_gamma.py +++ b/src/vector/_compute/lorentz/boostZ_gamma.py @@ -33,7 +33,7 @@ def xy_z_t(lib, gamma, x, y, z, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z tee = t return (x, y, gam * zee + bgam * tee, bgam * zee + gam * tee) @@ -41,7 +41,7 @@ def xy_z_t(lib, gamma, x, y, z, t): def xy_z_tau(lib, gamma, x, y, z, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z tee = t.xy_z_tau(lib, x, y, z, tau) return (x, y, gam * zee + bgam * tee, tau) @@ -49,7 +49,7 @@ def xy_z_tau(lib, gamma, x, y, z, tau): def xy_theta_t(lib, gamma, x, y, theta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.xy_theta(lib, x, y, theta) tee = t return (x, y, gam * zee + bgam * tee, bgam * zee + gam * tee) @@ -57,7 +57,7 @@ def xy_theta_t(lib, gamma, x, y, theta, t): def xy_theta_tau(lib, gamma, x, y, theta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.xy_theta(lib, x, y, theta) tee = t.xy_theta_tau(lib, x, y, theta, tau) return (x, y, gam * zee + bgam * tee, tau) @@ -65,7 +65,7 @@ def xy_theta_tau(lib, gamma, x, y, theta, tau): def xy_eta_t(lib, gamma, x, y, eta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.xy_eta(lib, x, y, eta) tee = t return (x, y, gam * zee + bgam * tee, bgam * zee + gam * tee) @@ -73,7 +73,7 @@ def xy_eta_t(lib, gamma, x, y, eta, t): def xy_eta_tau(lib, gamma, x, y, eta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.xy_eta(lib, x, y, eta) tee = t.xy_eta_tau(lib, x, y, eta, tau) return (x, y, gam * zee + bgam * tee, tau) @@ -81,7 +81,7 @@ def xy_eta_tau(lib, gamma, x, y, eta, tau): def rhophi_z_t(lib, gamma, rho, phi, z, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z tee = t return (rho, phi, gam * zee + bgam * tee, bgam * zee + gam * tee) @@ -89,7 +89,7 @@ def rhophi_z_t(lib, gamma, rho, phi, z, t): def rhophi_z_tau(lib, gamma, rho, phi, z, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z tee = t.rhophi_z_tau(lib, rho, phi, z, tau) return (rho, phi, gam * zee + bgam * tee, tau) @@ -97,7 +97,7 @@ def rhophi_z_tau(lib, gamma, rho, phi, z, tau): def rhophi_theta_t(lib, gamma, rho, phi, theta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.rhophi_theta(lib, rho, phi, theta) tee = t return (rho, phi, gam * zee + bgam * tee, bgam * zee + gam * tee) @@ -105,7 +105,7 @@ def rhophi_theta_t(lib, gamma, rho, phi, theta, t): def rhophi_theta_tau(lib, gamma, rho, phi, theta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.rhophi_theta(lib, rho, phi, theta) tee = t.rhophi_theta_tau(lib, rho, phi, theta, tau) return (rho, phi, gam * zee + bgam * tee, tau) @@ -113,7 +113,7 @@ def rhophi_theta_tau(lib, gamma, rho, phi, theta, tau): def rhophi_eta_t(lib, gamma, rho, phi, eta, t): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.rhophi_eta(lib, rho, phi, eta) tee = t return (rho, phi, gam * zee + bgam * tee, bgam * zee + gam * tee) @@ -121,7 +121,7 @@ def rhophi_eta_t(lib, gamma, rho, phi, eta, t): def rhophi_eta_tau(lib, gamma, rho, phi, eta, tau): gam = lib.absolute(gamma) - bgam = lib.copysign(lib.sqrt(gam ** 2 - 1), gamma) + bgam = lib.copysign(lib.sqrt(gam**2 - 1), gamma) zee = z.rhophi_eta(lib, rho, phi, eta) tee = t.rhophi_eta_tau(lib, rho, phi, eta, tau) return (rho, phi, gam * zee + bgam * tee, tau) diff --git a/src/vector/_compute/lorentz/boost_beta3.py b/src/vector/_compute/lorentz/boost_beta3.py index b262a772..5a27415d 100644 --- a/src/vector/_compute/lorentz/boost_beta3.py +++ b/src/vector/_compute/lorentz/boost_beta3.py @@ -41,9 +41,9 @@ def cartesian_t(lib, x1, y1, z1, t1, betax, betay, betaz): - bp2 = betax ** 2 + betay ** 2 + betaz ** 2 + bp2 = betax**2 + betay**2 + betaz**2 gamma = 1 / lib.sqrt(1 - bp2) - bgam = gamma ** 2 / (1 + gamma) + bgam = gamma**2 / (1 + gamma) xx = 1 + bgam * betax * betax yy = 1 + bgam * betay * betay zz = 1 + bgam * betaz * betaz @@ -74,9 +74,9 @@ def cartesian_t(lib, x1, y1, z1, t1, betax, betay, betaz): def cartesian_tau(lib, x1, y1, z1, tau1, betax, betay, betaz): - bp2 = betax ** 2 + betay ** 2 + betaz ** 2 + bp2 = betax**2 + betay**2 + betaz**2 gamma = 1 / lib.sqrt(1 - bp2) - bgam = gamma ** 2 / (1 + gamma) + bgam = gamma**2 / (1 + gamma) xx = 1 + bgam * betax * betax yy = 1 + bgam * betay * betay zz = 1 + bgam * betaz * betaz diff --git a/src/vector/_compute/lorentz/boost_p4.py b/src/vector/_compute/lorentz/boost_p4.py index eca41f30..8bc674b1 100644 --- a/src/vector/_compute/lorentz/boost_p4.py +++ b/src/vector/_compute/lorentz/boost_p4.py @@ -107,7 +107,7 @@ def cartesian_tau(lib, x1, y1, z1, tau1, energy, mass, mass2, x2, y2, z2): def cartesian_t_xy_z_t(lib, x1, y1, z1, t1, x2, y2, z2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.xy_z(lib, x2, y2, z2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_t(lib, x1, y1, z1, t1, energy, mass, mass2, x2, y2, z2) @@ -115,7 +115,7 @@ def cartesian_t_xy_z_t(lib, x1, y1, z1, t1, x2, y2, z2, t2): def cartesian_tau_xy_z_t(lib, x1, y1, z1, tau1, x2, y2, z2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.xy_z(lib, x2, y2, z2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau(lib, x1, y1, z1, tau1, energy, mass, mass2, x2, y2, z2) @@ -123,7 +123,7 @@ def cartesian_tau_xy_z_t(lib, x1, y1, z1, tau1, x2, y2, z2, t2): def cartesian_t_xy_z_tau(lib, x1, y1, z1, t1, x2, y2, z2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.xy_z(lib, x2, y2, z2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_t(lib, x1, y1, z1, t1, energy, mass, mass2, x2, y2, z2) @@ -131,7 +131,7 @@ def cartesian_t_xy_z_tau(lib, x1, y1, z1, t1, x2, y2, z2, tau2): def cartesian_tau_xy_z_tau(lib, x1, y1, z1, tau1, x2, y2, z2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.xy_z(lib, x2, y2, z2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau(lib, x1, y1, z1, tau1, energy, mass, mass2, x2, y2, z2) @@ -139,7 +139,7 @@ def cartesian_tau_xy_z_tau(lib, x1, y1, z1, tau1, x2, y2, z2, tau2): def cartesian_t_xy_theta_t(lib, x1, y1, z1, t1, x2, y2, theta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.xy_theta(lib, x2, y2, theta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -159,7 +159,7 @@ def cartesian_t_xy_theta_t(lib, x1, y1, z1, t1, x2, y2, theta2, t2): def cartesian_tau_xy_theta_t(lib, x1, y1, z1, tau1, x2, y2, theta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.xy_theta(lib, x2, y2, theta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -179,7 +179,7 @@ def cartesian_tau_xy_theta_t(lib, x1, y1, z1, tau1, x2, y2, theta2, t2): def cartesian_t_xy_theta_tau(lib, x1, y1, z1, t1, x2, y2, theta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.xy_theta(lib, x2, y2, theta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -199,7 +199,7 @@ def cartesian_t_xy_theta_tau(lib, x1, y1, z1, t1, x2, y2, theta2, tau2): def cartesian_tau_xy_theta_tau(lib, x1, y1, z1, tau1, x2, y2, theta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.xy_theta(lib, x2, y2, theta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -219,7 +219,7 @@ def cartesian_tau_xy_theta_tau(lib, x1, y1, z1, tau1, x2, y2, theta2, tau2): def cartesian_t_xy_eta_t(lib, x1, y1, z1, t1, x2, y2, eta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.xy_eta(lib, x2, y2, eta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -229,7 +229,7 @@ def cartesian_t_xy_eta_t(lib, x1, y1, z1, t1, x2, y2, eta2, t2): def cartesian_tau_xy_eta_t(lib, x1, y1, z1, tau1, x2, y2, eta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.xy_eta(lib, x2, y2, eta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -239,7 +239,7 @@ def cartesian_tau_xy_eta_t(lib, x1, y1, z1, tau1, x2, y2, eta2, t2): def cartesian_t_xy_eta_tau(lib, x1, y1, z1, t1, x2, y2, eta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.xy_eta(lib, x2, y2, eta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -249,7 +249,7 @@ def cartesian_t_xy_eta_tau(lib, x1, y1, z1, t1, x2, y2, eta2, tau2): def cartesian_tau_xy_eta_tau(lib, x1, y1, z1, tau1, x2, y2, eta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.xy_eta(lib, x2, y2, eta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -259,7 +259,7 @@ def cartesian_tau_xy_eta_tau(lib, x1, y1, z1, tau1, x2, y2, eta2, tau2): def cartesian_t_rhophi_z_t(lib, x1, y1, z1, t1, rho2, phi2, z2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.rhophi_z(lib, rho2, phi2, z2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -279,7 +279,7 @@ def cartesian_t_rhophi_z_t(lib, x1, y1, z1, t1, rho2, phi2, z2, t2): def cartesian_tau_rhophi_z_t(lib, x1, y1, z1, tau1, rho2, phi2, z2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.rhophi_z(lib, rho2, phi2, z2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -299,7 +299,7 @@ def cartesian_tau_rhophi_z_t(lib, x1, y1, z1, tau1, rho2, phi2, z2, t2): def cartesian_t_rhophi_z_tau(lib, x1, y1, z1, t1, rho2, phi2, z2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.rhophi_z(lib, rho2, phi2, z2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -319,7 +319,7 @@ def cartesian_t_rhophi_z_tau(lib, x1, y1, z1, t1, rho2, phi2, z2, tau2): def cartesian_tau_rhophi_z_tau(lib, x1, y1, z1, tau1, rho2, phi2, z2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.rhophi_z(lib, rho2, phi2, z2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -339,7 +339,7 @@ def cartesian_tau_rhophi_z_tau(lib, x1, y1, z1, tau1, rho2, phi2, z2, tau2): def cartesian_t_rhophi_theta_t(lib, x1, y1, z1, t1, rho2, phi2, theta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.rhophi_theta(lib, rho2, phi2, theta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -359,7 +359,7 @@ def cartesian_t_rhophi_theta_t(lib, x1, y1, z1, t1, rho2, phi2, theta2, t2): def cartesian_tau_rhophi_theta_t(lib, x1, y1, z1, tau1, rho2, phi2, theta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.rhophi_theta(lib, rho2, phi2, theta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -379,7 +379,7 @@ def cartesian_tau_rhophi_theta_t(lib, x1, y1, z1, tau1, rho2, phi2, theta2, t2): def cartesian_t_rhophi_theta_tau(lib, x1, y1, z1, t1, rho2, phi2, theta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.rhophi_theta(lib, rho2, phi2, theta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -399,7 +399,7 @@ def cartesian_t_rhophi_theta_tau(lib, x1, y1, z1, t1, rho2, phi2, theta2, tau2): def cartesian_tau_rhophi_theta_tau(lib, x1, y1, z1, tau1, rho2, phi2, theta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.rhophi_theta(lib, rho2, phi2, theta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -419,7 +419,7 @@ def cartesian_tau_rhophi_theta_tau(lib, x1, y1, z1, tau1, rho2, phi2, theta2, ta def cartesian_t_rhophi_eta_t(lib, x1, y1, z1, t1, rho2, phi2, eta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.rhophi_eta(lib, rho2, phi2, eta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -439,7 +439,7 @@ def cartesian_t_rhophi_eta_t(lib, x1, y1, z1, t1, rho2, phi2, eta2, t2): def cartesian_tau_rhophi_eta_t(lib, x1, y1, z1, tau1, rho2, phi2, eta2, t2): energy = t2 - energy2 = energy ** 2 + energy2 = energy**2 mass2 = energy2 - mag2.rhophi_eta(lib, rho2, phi2, eta2) mass = lib.sqrt(mass2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( @@ -459,7 +459,7 @@ def cartesian_tau_rhophi_eta_t(lib, x1, y1, z1, tau1, rho2, phi2, eta2, t2): def cartesian_t_rhophi_eta_tau(lib, x1, y1, z1, t1, rho2, phi2, eta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.rhophi_eta(lib, rho2, phi2, eta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_t( @@ -479,7 +479,7 @@ def cartesian_t_rhophi_eta_tau(lib, x1, y1, z1, t1, rho2, phi2, eta2, tau2): def cartesian_tau_rhophi_eta_tau(lib, x1, y1, z1, tau1, rho2, phi2, eta2, tau2): mass = tau2 - mass2 = mass ** 2 + mass2 = mass**2 energy2 = mass2 + mag2.rhophi_eta(lib, rho2, phi2, eta2) energy = lib.sqrt(energy2) # NaN for spacelike boosts propagates everywhere! return cartesian_tau( diff --git a/src/vector/_compute/lorentz/t2.py b/src/vector/_compute/lorentz/t2.py index de2b2707..b1c866e2 100644 --- a/src/vector/_compute/lorentz/t2.py +++ b/src/vector/_compute/lorentz/t2.py @@ -33,7 +33,7 @@ def xy_z_t(lib, x, y, z, t): - return t ** 2 + return t**2 def xy_z_tau(lib, x, y, z, tau): @@ -41,7 +41,7 @@ def xy_z_tau(lib, x, y, z, tau): def xy_theta_t(lib, x, y, theta, t): - return t ** 2 + return t**2 def xy_theta_tau(lib, x, y, theta, tau): @@ -51,7 +51,7 @@ def xy_theta_tau(lib, x, y, theta, tau): def xy_eta_t(lib, x, y, eta, t): - return t ** 2 + return t**2 def xy_eta_tau(lib, x, y, eta, tau): @@ -61,7 +61,7 @@ def xy_eta_tau(lib, x, y, eta, tau): def rhophi_z_t(lib, rho, phi, z, t): - return t ** 2 + return t**2 def rhophi_z_tau(lib, rho, phi, z, tau): @@ -71,7 +71,7 @@ def rhophi_z_tau(lib, rho, phi, z, tau): def rhophi_theta_t(lib, rho, phi, theta, t): - return t ** 2 + return t**2 def rhophi_theta_tau(lib, rho, phi, theta, tau): @@ -83,7 +83,7 @@ def rhophi_theta_tau(lib, rho, phi, theta, tau): def rhophi_eta_t(lib, rho, phi, eta, t): - return t ** 2 + return t**2 def rhophi_eta_tau(lib, rho, phi, eta, tau): diff --git a/src/vector/_compute/lorentz/tau2.py b/src/vector/_compute/lorentz/tau2.py index 5f7334b0..4b454be3 100644 --- a/src/vector/_compute/lorentz/tau2.py +++ b/src/vector/_compute/lorentz/tau2.py @@ -32,51 +32,51 @@ def xy_z_t(lib, x, y, z, t): - return t ** 2 - mag2.xy_z(lib, x, y, z) + return t**2 - mag2.xy_z(lib, x, y, z) def xy_z_tau(lib, x, y, z, tau): - return lib.copysign(tau ** 2, tau) + return lib.copysign(tau**2, tau) def xy_theta_t(lib, x, y, theta, t): - return t ** 2 - mag2.xy_theta(lib, x, y, theta) + return t**2 - mag2.xy_theta(lib, x, y, theta) def xy_theta_tau(lib, x, y, theta, tau): - return lib.copysign(tau ** 2, tau) + return lib.copysign(tau**2, tau) def xy_eta_t(lib, x, y, eta, t): - return t ** 2 - mag2.xy_eta(lib, x, y, eta) + return t**2 - mag2.xy_eta(lib, x, y, eta) def xy_eta_tau(lib, x, y, eta, tau): - return lib.copysign(tau ** 2, tau) + return lib.copysign(tau**2, tau) def rhophi_z_t(lib, rho, phi, z, t): - return t ** 2 - mag2.rhophi_z(lib, rho, phi, z) + return t**2 - mag2.rhophi_z(lib, rho, phi, z) def rhophi_z_tau(lib, rho, phi, z, tau): - return lib.copysign(tau ** 2, tau) + return lib.copysign(tau**2, tau) def rhophi_theta_t(lib, rho, phi, theta, t): - return t ** 2 - mag2.rhophi_theta(lib, rho, phi, theta) + return t**2 - mag2.rhophi_theta(lib, rho, phi, theta) def rhophi_theta_tau(lib, rho, phi, theta, tau): - return lib.copysign(tau ** 2, tau) + return lib.copysign(tau**2, tau) def rhophi_eta_t(lib, rho, phi, eta, t): - return t ** 2 - mag2.rhophi_eta(lib, rho, phi, eta) + return t**2 - mag2.rhophi_eta(lib, rho, phi, eta) def rhophi_eta_tau(lib, rho, phi, eta, tau): - return lib.copysign(tau ** 2, tau) + return lib.copysign(tau**2, tau) dispatch_map = { diff --git a/src/vector/_compute/planar/add.py b/src/vector/_compute/planar/add.py index aeb4087a..f2c1fc69 100644 --- a/src/vector/_compute/planar/add.py +++ b/src/vector/_compute/planar/add.py @@ -48,7 +48,7 @@ def rhophi_rhophi(lib, rho1, phi1, rho2, phi2): u = rho2 * lib.cos(diff) v = rho2 * lib.sin(diff) return ( - lib.sqrt((rho1 + u) ** 2 + v ** 2), + lib.sqrt((rho1 + u) ** 2 + v**2), rectify(lib, phi1 + lib.arctan2(v, rho1 + u)), ) diff --git a/src/vector/_compute/planar/rho2.py b/src/vector/_compute/planar/rho2.py index a1235331..71942960 100644 --- a/src/vector/_compute/planar/rho2.py +++ b/src/vector/_compute/planar/rho2.py @@ -24,11 +24,11 @@ def xy(lib, x, y): - return x ** 2 + y ** 2 + return x**2 + y**2 def rhophi(lib, rho, phi): - return rho ** 2 + return rho**2 dispatch_map = { diff --git a/src/vector/_compute/planar/subtract.py b/src/vector/_compute/planar/subtract.py index 997696cc..5881e004 100644 --- a/src/vector/_compute/planar/subtract.py +++ b/src/vector/_compute/planar/subtract.py @@ -48,7 +48,7 @@ def rhophi_rhophi(lib, rho1, phi1, rho2, phi2): u = rho2 * lib.cos(diff) v = rho2 * lib.sin(diff) return ( - lib.sqrt((rho1 + u) ** 2 + v ** 2), + lib.sqrt((rho1 + u) ** 2 + v**2), rectify(lib, phi1 + lib.arctan2(v, rho1 + u)), ) diff --git a/src/vector/_compute/spatial/dot.py b/src/vector/_compute/spatial/dot.py index 16afbf0a..3e601c7a 100644 --- a/src/vector/_compute/spatial/dot.py +++ b/src/vector/_compute/spatial/dot.py @@ -405,8 +405,8 @@ def rhophi_eta_rhophi_theta(lib, rho1, phi1, eta1, rho2, phi2, theta2): def rhophi_eta_rhophi_eta(lib, rho1, phi1, eta1, rho2, phi2, eta2): expmeta1 = lib.exp(-eta1) expmeta2 = lib.exp(-eta2) - invtantheta1 = 0.5 * (1 - expmeta1 ** 2) / expmeta1 - invtantheta2 = 0.5 * (1 - expmeta2 ** 2) / expmeta2 + invtantheta1 = 0.5 * (1 - expmeta1**2) / expmeta1 + invtantheta2 = 0.5 * (1 - expmeta2**2) / expmeta2 return rho1 * rho2 * (lib.cos(phi1 - phi2) + invtantheta1 * invtantheta2) diff --git a/src/vector/_compute/spatial/eta.py b/src/vector/_compute/spatial/eta.py index 12178a5e..35a55777 100644 --- a/src/vector/_compute/spatial/eta.py +++ b/src/vector/_compute/spatial/eta.py @@ -29,7 +29,7 @@ def xy_z(lib, x, y, z): return lib.nan_to_num( - lib.arctanh(z / lib.sqrt(x ** 2 + y ** 2 + z ** 2)), nan=0.0 + lib.arctanh(z / lib.sqrt(x**2 + y**2 + z**2)), nan=0.0 ) * lib.absolute(lib.sign(z)) @@ -43,7 +43,7 @@ def xy_eta(lib, x, y, eta): def rhophi_z(lib, rho, phi, z): return lib.nan_to_num( - lib.arctanh(z / lib.sqrt(rho ** 2 + z ** 2)), nan=0.0 + lib.arctanh(z / lib.sqrt(rho**2 + z**2)), nan=0.0 ) * lib.absolute(lib.sign(z)) diff --git a/src/vector/_compute/spatial/mag.py b/src/vector/_compute/spatial/mag.py index ecbf0b06..b97ebc09 100644 --- a/src/vector/_compute/spatial/mag.py +++ b/src/vector/_compute/spatial/mag.py @@ -33,13 +33,13 @@ def xy_z(lib, x, y, z): def xy_theta(lib, x, y, theta): - return lib.sqrt(x ** 2 + y ** 2) / lib.absolute(lib.sin(theta)) + return lib.sqrt(x**2 + y**2) / lib.absolute(lib.sin(theta)) def xy_eta(lib, x, y, eta): expmeta = lib.exp(-eta) - invsintheta = 0.5 * (1 + expmeta ** 2) / expmeta - return lib.sqrt(x ** 2 + y ** 2) * invsintheta + invsintheta = 0.5 * (1 + expmeta**2) / expmeta + return lib.sqrt(x**2 + y**2) * invsintheta def rhophi_z(lib, rho, phi, z): @@ -52,7 +52,7 @@ def rhophi_theta(lib, rho, phi, theta): def rhophi_eta(lib, rho, phi, eta): expmeta = lib.exp(-eta) - invsintheta = 0.5 * (1 + expmeta ** 2) / expmeta + invsintheta = 0.5 * (1 + expmeta**2) / expmeta return rho * invsintheta diff --git a/src/vector/_compute/spatial/mag2.py b/src/vector/_compute/spatial/mag2.py index 32f514e0..29c6022f 100644 --- a/src/vector/_compute/spatial/mag2.py +++ b/src/vector/_compute/spatial/mag2.py @@ -28,31 +28,31 @@ def xy_z(lib, x, y, z): - return x ** 2 + y ** 2 + z ** 2 + return x**2 + y**2 + z**2 def xy_theta(lib, x, y, theta): - return (x ** 2 + y ** 2) / lib.sin(theta) ** 2 + return (x**2 + y**2) / lib.sin(theta) ** 2 def xy_eta(lib, x, y, eta): expmeta = lib.exp(-eta) - invsintheta = 0.5 * (1 + expmeta ** 2) / expmeta - return (x ** 2 + y ** 2) * invsintheta ** 2 + invsintheta = 0.5 * (1 + expmeta**2) / expmeta + return (x**2 + y**2) * invsintheta**2 def rhophi_z(lib, rho, phi, z): - return rho ** 2 + z ** 2 + return rho**2 + z**2 def rhophi_theta(lib, rho, phi, theta): - return rho ** 2 / lib.sin(theta) ** 2 + return rho**2 / lib.sin(theta) ** 2 def rhophi_eta(lib, rho, phi, eta): expmeta = lib.exp(-eta) - invsintheta = 0.5 * (1 + expmeta ** 2) / expmeta - return rho ** 2 * invsintheta ** 2 + invsintheta = 0.5 * (1 + expmeta**2) / expmeta + return rho**2 * invsintheta**2 dispatch_map = { diff --git a/src/vector/_compute/spatial/rotate_axis.py b/src/vector/_compute/spatial/rotate_axis.py index 72c9a71f..4c4bce47 100644 --- a/src/vector/_compute/spatial/rotate_axis.py +++ b/src/vector/_compute/spatial/rotate_axis.py @@ -33,7 +33,7 @@ def cartesian(lib, angle, x1, y1, z1, x2, y2, z2): - norm = lib.sqrt(x1 ** 2 + y1 ** 2 + z1 ** 2) + norm = lib.sqrt(x1**2 + y1**2 + z1**2) ux = x1 / norm uy = y1 / norm uz = z1 / norm @@ -41,19 +41,19 @@ def cartesian(lib, angle, x1, y1, z1, x2, y2, z2): s = lib.sin(angle) c1 = 1 - c xp = ( - (c + ux ** 2 * c1) * x2 + (c + ux**2 * c1) * x2 + (ux * uy * c1 - uz * s) * y2 + (ux * uz * c1 + uy * s) * z2 ) yp = ( (ux * uy * c1 + uz * s) * x2 - + (c + uy ** 2 * c1) * y2 + + (c + uy**2 * c1) * y2 + (uy * uz * c1 - ux * s) * z2 ) zp = ( (ux * uz * c1 - uy * s) * x2 + (uy * uz * c1 + ux * s) * y2 - + (c + uz ** 2 * c1) * z2 + + (c + uz**2 * c1) * z2 ) return (xp, yp, zp) diff --git a/tests/backends/test_awkward.py b/tests/backends/test_awkward.py index 0efb0d14..f17fb944 100644 --- a/tests/backends/test_awkward.py +++ b/tests/backends/test_awkward.py @@ -156,7 +156,7 @@ def test_ufuncs(): [[{"x": 3, "y": 4}, {"x": 5, "y": 12}], [], [{"x": 8, "y": 15}]] ) assert abs(array).tolist() == [[5, 13], [], [17]] - assert (array ** 2).tolist() == [[5 ** 2, 13 ** 2], [], [17 ** 2]] + assert (array**2).tolist() == [[5**2, 13**2], [], [17**2]] one = vector.Array( [[{"x": 1, "y": 1.1}, {"x": 2, "y": 2.2}], [], [{"x": 3, "y": 3.3}]] diff --git a/tests/backends/test_numba_object.py b/tests/backends/test_numba_object.py index b84e033a..b699b7bf 100644 --- a/tests/backends/test_numba_object.py +++ b/tests/backends/test_numba_object.py @@ -754,7 +754,7 @@ def get_Et(v): with pytest.raises(numba.TypingError): get_Et(vector.obj(x=1, y=2, z=3, t=4)) assert get_Et(vector.obj(px=1, py=2, pz=3, E=4)) == pytest.approx( - numpy.sqrt(4 ** 2 * (1 ** 2 + 2 ** 2) / (1 ** 2 + 2 ** 2 + 3 ** 2)) + numpy.sqrt(4**2 * (1**2 + 2**2) / (1**2 + 2**2 + 3**2)) ) @@ -1487,11 +1487,11 @@ def get_div(a, b): def test_operator_pow(): @numba.njit def get_pow(a, b): - return a ** b + return a**b @numba.njit def get_square(a): - return a ** 2 + return a**2 assert get_pow(vector.obj(x=1, y=2), 4) == pytest.approx(25) diff --git a/tests/backends/test_operators.py b/tests/backends/test_operators.py index 625ae80e..5a7d2cd3 100644 --- a/tests/backends/test_operators.py +++ b/tests/backends/test_operators.py @@ -38,7 +38,7 @@ def test_ne(): def test_abs(): - assert abs(v1) == pytest.approx(numpy.sqrt(1 ** 2 + 5 ** 2)) + assert abs(v1) == pytest.approx(numpy.sqrt(1**2 + 5**2)) assert numpy.allclose( abs(a1), numpy.sqrt(numpy.array([1, 2, 3, 4]) ** 2 + numpy.array([5, 6, 7, 8]) ** 2), @@ -128,21 +128,21 @@ def test_truediv(): def test_pow(): - assert v1 ** 2 == pytest.approx(1 ** 2 + 5 ** 2) + assert v1**2 == pytest.approx(1**2 + 5**2) with pytest.raises(TypeError): - 2 ** v1 + 2**v1 assert numpy.allclose( - a1 ** 2, + a1**2, numpy.array( - [1 ** 2 + 5 ** 2, 2 ** 2 + 6 ** 2, 3 ** 2 + 7 ** 2, 4 ** 2 + 8 ** 2] + [1**2 + 5**2, 2**2 + 6**2, 3**2 + 7**2, 4**2 + 8**2] ), ) with pytest.raises(TypeError): - 2 ** a1 + 2**a1 with pytest.raises(TypeError): - v1 ** v2 + v1**v2 with pytest.raises(TypeError): - a1 ** a2 + a1**a2 def test_matmul():