From 717b07ff28b307fbfa066286d698fa526df8ee80 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 17 Nov 2023 23:43:01 +0530 Subject: [PATCH 1/2] Update `README` and `intro.ipynb` to include the latest developments --- README.md | 51 ++- docs/changelog.md | 8 + docs/usage/intro.ipynb | 944 ++++++++++++++++++++++++++++------------- 3 files changed, 710 insertions(+), 293 deletions(-) diff --git a/README.md b/README.md index 9049e50c..e9e0b1df 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,19 @@ The easiest way to create one or many vectors is with a helper function: ### Pure Python vectors +You can directly use the `VectorObject` classes to construct object type vectors: + +```python +vector.VectorObject2D(x=1.1, y=2.2) +vector.MomentumObject3D(px=1.1, py=2.2, pz=3.3) +vector.VectorObject4D(x=1.1, y=2.2, eta=3.3, tau=4.4) +``` + +and so on for every class. + +Or, you can use a single wrapper function to construct all possible combinations of +object type vectors: + ```python # Cartesian 2D vector vector.obj(x=3, y=4) @@ -148,6 +161,34 @@ and so on, for all combinations of azimuthal, longitudinal, and temporal coordin ### NumPy arrays of vectors +You can directly use the `VectorNumpy` classes to construct object type vectors: + +```python +# NumPy-like arguments (literally passed through to NumPy) +vector.VectorNumpy2D( + [(1.1, 2.1), (1.2, 2.2), (1.3, 2.3), (1.4, 2.4), (1.5, 2.5)], + dtype=[("x", float), ("y", float)], +) + +# Pandas-like arguments (dict from names to column arrays) +vector.VectorNumpy2D({"x": [1.1, 1.2, 1.3, 1.4, 1.5], "y": [2.1, 2.2, 2.3, 2.4, 2.5]}) + +# As with objects, the coordinate system and dimension is taken from the names of the fields. +vector.VectorNumpy4D( + { + "x": [1.1, 1.2, 1.3, 1.4, 1.5], + "y": [2.1, 2.2, 2.3, 2.4, 2.5], + "z": [3.1, 3.2, 3.3, 3.4, 3.5], + "t": [4.1, 4.2, 4.3, 4.4, 4.5], + } +) +``` + +and so on for every class. + +Or, you can use a single wrapper function to construct all possible combinations of +NumPy type vectors: + ```python # NumPy-like arguments (literally passed through to NumPy) vector.array( @@ -576,7 +617,12 @@ The (current) list of properties and methods is: - `scale(factor)`: can also use the `*` operator - `equal(vector)`: can also use the `==` operator, but consider `isclose` instead - `not_equal(vector)`: can also use the `!=` operator, but consider `isclose` instead +- `sum()`: can also use the `numpy.sum` or `awkward.sum`, only for NumPy and Awkward vectors +- `count_nonzero()`: can also use `numpy.count_nonzero` or `awkward.count_nonzero`, only for NumPy and Awkward vectors +- `count()`: can also use `awkward.count`, only for Awkward vectors - `isclose(vector, rtol=1e-5, atol=1e-8, equal_nan=False)`: works like [np.isclose](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html); arrays also have an [allclose](https://numpy.org/doc/stable/reference/generated/numpy.allclose.html) method +- `to_Vector*D(coordinates)`: replace `*` with the reuquired vector dimension +- `to_{coordinate-names}`: for example - `to_rhophietatau` ## Compiling your Python with Numba @@ -631,14 +677,15 @@ compute_masses(array) ## Talks about vector +- 9th October 2023 - [What’s new with Vector? First major release is out!](https://indi.to/35ym5) - [PyHEP 2023 (virtual)](https://indico.cern.ch/event/1252095/) [🎥](https://www.youtube.com/watch?v=JHEAb2R3xzE&list=PLKZ9c4ONm-VlAorAG8kR09ZqhMfHiH2LJ&index=10) - 13th September 2022 - [Constructing HEP vectors and analyzing HEP data using Vector](https://indi.to/bPmMc) - [PyHEP 2022 (virtual)](https://indico.cern.ch/event/1150631/) [🎥](https://www.youtube.com/watch?v=4iveMzrbe7s&list=PLKZ9c4ONm-VkohKG-skzEG_gklMaSgaO7&index=15) - 20th July 2022 - [Analysis Grand Challenge / HEP Scientific Python Ecosystem](https://indico.cern.ch/event/1151329/timetable/#3-analysis-grand-challenge-hep) - [DANCE/CoDaS@Snowmass 2022 computational and data science software training](https://indico.cern.ch/event/1151329/) - 25th April 2022 - [Foundation libraries (uproot, awkward, hist, mplhep)](https://indico.cern.ch/event/1126109/contributions/4780138/) - [IRIS-HEP AGC Tools 2022 Workshop](https://indico.cern.ch/event/1126109/) [🎥](https://www.youtube.com/watch?v=O9KvsDMKOmY) - 3rd November 2021 - [Data handling: uproot, awkward & vector](https://indico.cern.ch/event/1076231/contributions/4560398/) - [IRIS-HEP AGC Tools 2021 Workshop](https://indico.cern.ch/event/1076231/) [🎥](https://indico.cern.ch/event/1076231/contributions/4560398/attachments/2338579/4017718/agc_uproot_awk.mp4) -### Status as of April 8, 2021 +### Status as of November 17, 2023 -Undoubtedly, there are rough edges, but most of the functionality is there and Vector is ready for user-testing. It can only be improved by your feedback! +First major release of vector is out and the package has reached a stable position. The work is spearheaded by bug reports and feature requests created on GitHub. It can only be improved by your feedback! ## Contributors ✨ diff --git a/docs/changelog.md b/docs/changelog.md index 8b4dcd9d..8afb9f5e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,14 @@ ## Version 1.1 +### Unreleased + +#### Documentation + +- Update `README` and `intro.ipynb` to include the latest developments [#399][] + +[#399]: https://github.com/scikit-hep/vector/pull/399 + ### Version 1.1.1.post1 #### Maintenance diff --git a/docs/usage/intro.ipynb b/docs/usage/intro.ipynb index 2b1a9c04..6f471ed6 100644 --- a/docs/usage/intro.ipynb +++ b/docs/usage/intro.ipynb @@ -7,7 +7,7 @@ "source": [ "# Introduction to Vector\n", "\n", - "Vector is a Python library for 2D, 3D, and [Lorentz vectors](https://en.wikipedia.org/wiki/Special_relativity#Physics_in_spacetime), especially _arrays of vectors_, to solve common physics problems in a NumPy-like way.\n", + "Vector is a Python 3.8+ library (Python 3.6 and 3.7 supported till `v0.9.0` and `v1.0.0`, respectively) for 2D, 3D, and [Lorentz vectors](https://en.wikipedia.org/wiki/Special_relativity#Physics_in_spacetime), especially _arrays of vectors_, to solve common physics problems in a NumPy-like way.\n", "\n", "Main features of Vector:\n", "\n", @@ -59,19 +59,20 @@ "id": "instant-phoenix", "metadata": {}, "source": [ - "### Pure Python vectors" + "### Pure Python vectors\n", + "\n", + "You can directly use the `VectorObject` classes to construct object type vectors:" ] }, { "cell_type": "code", "execution_count": 2, - "id": "divided-control", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=3, y=4)" + "VectorObject2D(x=1.1, y=2.2)" ] }, "execution_count": 2, @@ -80,19 +81,18 @@ } ], "source": [ - "vector.obj(x=3, y=4) # Cartesian 2D vector" + "vector.VectorObject2D(x=1.1, y=2.2)" ] }, { "cell_type": "code", "execution_count": 3, - "id": "touched-reader", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(rho=5, phi=0.9273)" + "MomentumObject3D(px=1.1, py=2.2, pz=3.3)" ] }, "execution_count": 3, @@ -101,12 +101,84 @@ } ], "source": [ - "vector.obj(rho=5, phi=0.9273) # same in polar coordinates" + "vector.MomentumObject3D(px=1.1, py=2.2, pz=3.3)" ] }, { "cell_type": "code", "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "VectorObject4D(x=1.1, y=2.2, eta=3.3, tau=4.4)" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vector.VectorObject4D(x=1.1, y=2.2, eta=3.3, tau=4.4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and so on for every class.\n", + "\n", + "Or, you can use a single wrapper function to construct all possible combinations of\n", + "object type vectors:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "divided-control", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "VectorObject2D(x=3, y=4)" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vector.obj(x=3, y=4) # Cartesian 2D vector" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "touched-reader", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "VectorObject2D(rho=5, phi=0.9273)" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vector.obj(rho=5, phi=0.9273) # same in polar coordinates" + ] + }, + { + "cell_type": "code", + "execution_count": 7, "id": "coordinated-banner", "metadata": {}, "outputs": [ @@ -116,7 +188,7 @@ "True" ] }, - "execution_count": 4, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -129,17 +201,17 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 8, "id": "worse-depression", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=3, y=4, z=-2)" + "VectorObject3D(x=3, y=4, z=-2)" ] }, - "execution_count": 5, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -150,17 +222,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "id": "copyrighted-answer", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=3, y=4, z=-2, t=10)" + "VectorObject4D(x=3, y=4, z=-2, t=10)" ] }, - "execution_count": 6, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -171,17 +243,17 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "id": "recovered-platinum", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(rho=5, phi=0.9273, eta=-0.39, t=10)" + "VectorObject4D(rho=5, phi=0.9273, eta=-0.39, t=10)" ] }, - "execution_count": 7, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -194,17 +266,17 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 11, "id": "exempt-palestine", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(pt=5, phi=0.9273, eta=-0.39, E=10)" + "MomentumObject4D(pt=5, phi=0.9273, eta=-0.39, E=10)" ] }, - "execution_count": 8, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -217,7 +289,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "id": "better-responsibility", "metadata": {}, "outputs": [ @@ -227,7 +299,7 @@ "False" ] }, - "execution_count": 9, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -240,7 +312,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "id": "adverse-lighting", "metadata": {}, "outputs": [ @@ -250,7 +322,7 @@ "8.426194916448265" ] }, - "execution_count": 10, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -263,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "id": "broadband-budget", "metadata": {}, "outputs": [ @@ -273,7 +345,7 @@ "8.426194916448265" ] }, - "execution_count": 11, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -286,17 +358,17 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 15, "id": "prompt-archive", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(pt=5, phi=0.9273, theta=1.9513, mass=8.4262)" + "MomentumObject4D(pt=5, phi=0.9273, theta=1.9513, mass=8.4262)" ] }, - "execution_count": 12, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -309,7 +381,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 16, "id": "southern-register", "metadata": {}, "outputs": [ @@ -319,7 +391,7 @@ "True" ] }, - "execution_count": 13, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -332,7 +404,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 17, "id": "utility-cartridge", "metadata": {}, "outputs": [ @@ -342,7 +414,7 @@ "(True, True, True, True, True, True, True, True, True, True)" ] }, - "execution_count": 14, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -418,17 +490,17 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 18, "id": "center-beauty", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=1.1, y=2.2)" + "VectorObject2D(x=1.1, y=2.2)" ] }, - "execution_count": 15, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -439,17 +511,17 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "id": "indoor-playing", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(pt=1.1, phi=2.2, pz=3.3)" + "MomentumObject3D(pt=1.1, phi=2.2, pz=3.3)" ] }, - "execution_count": 16, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -460,17 +532,17 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 20, "id": "documented-lyric", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=1.1, y=2.2, eta=3.3, tau=4.4)" + "VectorObject4D(x=1.1, y=2.2, eta=3.3, tau=4.4)" ] }, - "execution_count": 17, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -492,12 +564,101 @@ "id": "sustained-object", "metadata": {}, "source": [ - "### NumPy arrays of vectors" + "### NumPy arrays of vectors\n", + "\n", + "You can directly use the `VectorNumpy` classes to construct object type vectors:" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "VectorNumpy2D([(1.1, 2.1), (1.2, 2.2), (1.3, 2.3), (1.4, 2.4), (1.5, 2.5)],\n", + " dtype=[('x', '[[{x: 1, y: 1.1, z: 0.1}, {x: 2, y: 2.2, z: 0.2}],\n", + " [],\n", + " [{x: 3, y: 3.3, z: 0.3}],\n", + " [{x: 4, y: 4.4, z: 0.4}, {x: 5, y: 5.5, ...}, {x: 6, y: 6.6, z: 0.6}]]\n", + "-----------------------------------------------------------------------\n", + "type: 4 * var * Vector3D[\n", + " x: int64,\n", + " y: float64,\n", + " z: float64\n", + "]" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 25, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -821,7 +994,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 32, "id": "becoming-demand", "metadata": {}, "outputs": [], @@ -831,17 +1004,29 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 33, "id": "bored-ribbon", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[[{x: 1, y: 1.1, z: 0.1}, {x: 2, y: 2.2, z: 0.2}],\n",
+       " [],\n",
+       " [{x: 3, y: 3.3, z: 0.3}],\n",
+       " [{x: 4, y: 4.4, z: 0.4}, {x: 5, y: 5.5, ...}, {x: 6, y: 6.6, z: 0.6}]]\n",
+       "-----------------------------------------------------------------------\n",
+       "type: 4 * var * Vector3D[\n",
+       "    x: int64,\n",
+       "    y: float64,\n",
+       "    z: float64\n",
+       "]
" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 27, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -882,7 +1067,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 34, "id": "colored-directory", "metadata": {}, "outputs": [ @@ -892,7 +1077,7 @@ "5.0" ] }, - "execution_count": 28, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -903,7 +1088,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 35, "id": "passive-benchmark", "metadata": {}, "outputs": [ @@ -913,7 +1098,7 @@ "2.9999808719721477" ] }, - "execution_count": 29, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -924,7 +1109,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 36, "id": "indoor-opportunity", "metadata": {}, "outputs": [ @@ -934,7 +1119,7 @@ "4.000014345949428" ] }, - "execution_count": 30, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -945,7 +1130,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 37, "id": "mature-clone", "metadata": {}, "outputs": [ @@ -955,7 +1140,7 @@ "0.6405223126794245" ] }, - "execution_count": 31, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -966,17 +1151,17 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 38, "id": "peripheral-script", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1.1035868415601453" + "1.103586841560145" ] }, - "execution_count": 32, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -995,7 +1180,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 39, "id": "stretch-knife", "metadata": {}, "outputs": [ @@ -1005,7 +1190,7 @@ "0.8017837257372732" ] }, - "execution_count": 33, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1016,7 +1201,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 40, "id": "bearing-protein", "metadata": {}, "outputs": [ @@ -1026,7 +1211,7 @@ "3.7416573867739413" ] }, - "execution_count": 34, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -1037,7 +1222,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 41, "id": "green-crack", "metadata": {}, "outputs": [ @@ -1047,7 +1232,7 @@ "14" ] }, - "execution_count": 35, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1066,7 +1251,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 42, "id": "amber-disco", "metadata": {}, "outputs": [ @@ -1076,7 +1261,7 @@ "25" ] }, - "execution_count": 36, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1095,7 +1280,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 43, "id": "latest-thunder", "metadata": {}, "outputs": [ @@ -1105,7 +1290,7 @@ "5.0" ] }, - "execution_count": 37, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1116,7 +1301,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 44, "id": "included-fireplace", "metadata": {}, "outputs": [ @@ -1126,7 +1311,7 @@ "5.0" ] }, - "execution_count": 38, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -1137,7 +1322,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 45, "id": "analyzed-andrews", "metadata": {}, "outputs": [ @@ -1147,7 +1332,7 @@ "1.4142135623730951" ] }, - "execution_count": 39, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1158,7 +1343,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 46, "id": "declared-yeast", "metadata": {}, "outputs": [ @@ -1168,7 +1353,7 @@ "1.4142135623730951" ] }, - "execution_count": 40, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1187,7 +1372,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 47, "id": "attempted-country", "metadata": {}, "outputs": [ @@ -1197,7 +1382,7 @@ "array([1.50363023, 1.50363023, 1.50363023, 1.50363023, 1.50363023])" ] }, - "execution_count": 41, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -1214,17 +1399,25 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 48, "id": "consecutive-attempt", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[[1.5, 1.5],\n",
+       " [],\n",
+       " [1.5],\n",
+       " [1.5, 1.5]]\n",
+       "-----------------------\n",
+       "type: 4 * var * float64
" + ], "text/plain": [ "" ] }, - "execution_count": 42, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1242,71 +1435,71 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 49, "id": "latin-channels", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "MomentumNumpy3D([[[(-0.5816785 , -0.05413944, 0.76144538),\n", - " (-1.28722717, -1.08334531, -0.6673024 )],\n", - " [(-0.62358686, 0.55198952, 1.7445032 ),\n", - " ( 0.01700467, 1.15120078, -0.25539554)],\n", - " [(-1.34635672, -2.12940091, -1.54467987),\n", - " (-0.81493735, 0.20080621, -1.55001381)],\n", - " [( 1.24975086, -0.51898145, 0.60519884),\n", - " ( 0.96658282, 1.09592942, -0.06253526)],\n", - " [( 2.20226434, -0.31735941, -1.65264014),\n", - " (-0.24360299, -1.35841058, 0.58728995)]],\n", + "MomentumNumpy3D([[[( 2.26039025, -1.98481124, -1.29907057),\n", + " ( 0.95952588, -2.00396017, -0.4404866 )],\n", + " [(-2.55169443, 0.45531406, 0.2200994 ),\n", + " (-1.0996391 , -0.73624228, -0.80890089)],\n", + " [(-0.7411634 , -0.110458 , -0.19701435),\n", + " ( 1.35582837, 0.200836 , -1.27418951)],\n", + " [(-0.62333052, 0.52145296, 0.24492175),\n", + " ( 0.38686249, -1.62346243, -1.06885481)],\n", + " [( 0.54233445, -0.72464489, 0.70890249),\n", + " (-0.10019824, 0.93090357, 0.73060395)]],\n", "\n", - " [[( 1.34917966, 2.09671483, -0.11296369),\n", - " (-0.95766198, 0.61822435, 0.00631232)],\n", - " [(-0.63470122, -1.57605684, 1.93922382),\n", - " (-1.49464097, -0.25947235, -1.42989385)],\n", - " [( 0.13181703, -0.23925908, -1.29684743),\n", - " (-1.30332525, 0.22076072, -1.85090259)],\n", - " [( 0.23572319, -1.37731231, 0.47495316),\n", - " (-1.03116698, 1.31698481, 0.05923118)],\n", - " [( 0.26381498, 0.81470087, -0.4088332 ),\n", - " ( 1.07145768, -0.02538051, 0.56726254)]],\n", + " [[( 0.41104402, 0.5590012 , 2.36215303),\n", + " ( 1.73855749, -0.75679797, 0.15862517)],\n", + " [(-0.0985614 , 0.57614691, -0.13468802),\n", + " (-1.75545141, 0.31520659, -1.0191747 )],\n", + " [( 0.52953509, -0.454113 , 0.9103319 ),\n", + " ( 1.06982529, -0.73796475, 0.47365608)],\n", + " [( 0.70143481, -2.48893272, 0.60751234),\n", + " ( 0.26390769, 0.19964715, -0.37988363)],\n", + " [(-2.00117585, 0.07216232, 0.3443312 ),\n", + " (-0.54123369, 1.42881317, 0.39421562)]],\n", "\n", - " [[( 0.78343072, -0.02741195, 0.7812837 ),\n", - " (-0.9815062 , 0.45809367, 1.70387148)],\n", - " [( 0.22003486, 0.27980794, 0.47145122),\n", - " ( 0.93975121, 0.06854498, -0.78840851)],\n", - " [( 1.91018848, 0.65588855, -0.26309178),\n", - " (-0.24689939, -0.63389731, -0.18429427)],\n", - " [(-0.45547946, -0.60659614, 0.3710947 ),\n", - " ( 0.20913049, -0.0568765 , -0.03245573)],\n", - " [(-0.15149451, -0.53761606, 0.61024707),\n", - " (-1.72565708, 1.34034237, -0.05086564)]],\n", + " [[(-0.0130378 , 0.51884925, 0.38741933),\n", + " ( 0.12128434, 1.63382031, 0.62769807)],\n", + " [(-0.02453509, 0.0088992 , -1.97146483),\n", + " ( 0.52108073, -1.77611003, -0.17590794)],\n", + " [(-2.14835586, 0.16964633, 2.02826159),\n", + " ( 0.73103243, 0.85196301, 1.1617289 )],\n", + " [(-0.16432348, 0.39310727, 0.00777254),\n", + " (-1.05791558, 0.55587963, 0.23693828)],\n", + " [( 0.94864117, 0.77488342, -0.74026367),\n", + " ( 0.71154967, -0.36412087, 0.09636387)]],\n", "\n", - " [[( 0.32961237, 0.13714739, -0.61025587),\n", - " (-0.36806236, 1.64625621, 0.44977818)],\n", - " [(-0.16190701, 0.44515714, -1.00738623),\n", - " ( 1.53029679, -0.15509494, -0.82669165)],\n", - " [(-0.71576504, -1.21193201, -0.61774313),\n", - " (-0.05330236, 0.33569103, 1.22197535)],\n", - " [(-1.14971585, 2.25842249, 0.07937847),\n", - " ( 0.93505701, -1.01045082, -0.40314804)],\n", - " [( 0.05238702, -0.27996488, 1.15669341),\n", - " (-0.23345516, 0.50328019, 0.13368106)]],\n", + " [[( 0.91218559, 1.17236545, -0.0619832 ),\n", + " (-0.13943885, -0.53065792, 0.13009332)],\n", + " [( 0.0400739 , -1.33943471, -0.04176005),\n", + " (-0.47738235, 2.08961029, -1.48695025)],\n", + " [(-0.84699974, -0.16730622, -0.20521711),\n", + " ( 0.37491512, 0.6729008 , -0.47241812)],\n", + " [(-0.83194681, 1.62940666, 0.44099987),\n", + " ( 0.63878738, 1.46062868, -0.41644439)],\n", + " [(-0.10227976, 0.74096051, -1.31529571),\n", + " ( 1.09401836, 0.77294462, 0.27773291)]],\n", "\n", - " [[(-1.34294052, -1.40223737, 0.58557272),\n", - " ( 0.14018108, 1.24216928, -0.64543334)],\n", - " [(-0.03884685, 2.61315639, -0.88051183),\n", - " ( 0.24816409, -0.41001159, 0.94234544)],\n", - " [( 0.1734323 , -0.67060395, 1.01330813),\n", - " (-1.57644514, 0.51398789, -0.5226023 )],\n", - " [( 0.61337692, -0.45606094, 1.79962181),\n", - " (-0.19398749, 0.12963915, 0.46498903)],\n", - " [( 0.64323387, 0.27050203, -0.54877836),\n", - " ( 0.97756399, -0.43162287, -0.29129695)]]],\n", + " [[( 1.17205984, -0.15417393, 0.31004223),\n", + " ( 0.99275882, -1.11519843, 1.08783846)],\n", + " [(-0.54770178, -1.69687857, 0.25023612),\n", + " (-0.27828739, 1.14492199, 2.29676035)],\n", + " [(-0.20599501, 0.54057953, -0.83481415),\n", + " (-0.68719168, -2.08795544, 0.83253276)],\n", + " [(-2.55054126, -1.46269813, 1.79934732),\n", + " ( 1.77585908, -1.33620677, -0.35172656)],\n", + " [( 0.50447696, 2.09937313, 0.23885731),\n", + " (-0.21897479, -0.84282187, 2.71267012)]]],\n", " dtype=[('x', '[[{x: -0.376, y: 1.92, z: -1.87}],\n", + " [{x: -0.106, y: -0.827, z: -0.61}],\n", + " [{x: 0.682, y: -0.445, z: 1.25}, {...}, {x: 0.336, y: -1.04, z: 1.59}],\n", + " [{x: 0.236, y: -0.778, z: 2.41}, {x: -0.627, y: -0.654, z: 1.6}],\n", + " [],\n", + " [{x: -0.689, y: -1.14, z: -0.376}, {x: 0.141, y: 0.546, z: -1.1}],\n", + " [],\n", + " [{x: 0.426, y: 1.25, z: -0.33}, {...}, {x: 0.792, y: 0.0574, z: -1.69}],\n", + " [],\n", + " [{x: -0.165, y: 0.0744, z: 1}],\n", + " ...,\n", + " [{x: -0.922, y: -0.895, z: -1.07}],\n", + " [{x: -1.95, y: -1.75, z: 1.41}, {...}, {x: 0.73, y: 0.472, z: -0.969}],\n", + " [{x: -0.139, y: 1.62, z: -0.308}, {x: -0.0608, y: 0.825, z: -1.75}],\n", + " [{x: 1.41, y: 0.951, z: -1.47}, {x: -0.836, y: -0.196, z: -0.887}],\n", + " [{x: -1, y: 0.94, z: 1.12}],\n", + " [],\n", + " [{x: 0.718, y: -1.04, z: -0.305}, {x: -0.228, y: 0.862, z: -0.5}],\n", + " [{x: 0.754, y: 0.365, z: 0.465}],\n", + " [{x: -0.99, y: 0.726, z: -1.38}, {x: 1.03, y: 0.119, z: -0.0639}]]\n", + "-------------------------------------------------------------------------\n", + "type: 50 * var * Momentum3D[\n", + " x: float64,\n", + " y: float64,\n", + " z: float64\n", + "]" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 47, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -1448,17 +1669,41 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 54, "id": "conditional-modeling", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[[1.96],\n",
+       " [0.834],\n",
+       " [0.814, 1.72, 1.09],\n",
+       " [0.813, 0.906],\n",
+       " [],\n",
+       " [1.33, 0.564],\n",
+       " [],\n",
+       " [1.32, 1.75, 0.794],\n",
+       " [],\n",
+       " [0.181],\n",
+       " ...,\n",
+       " [1.29],\n",
+       " [2.62, 2.66, 0.869],\n",
+       " [1.63, 0.828],\n",
+       " [1.7, 0.859],\n",
+       " [1.37],\n",
+       " [],\n",
+       " [1.26, 0.892],\n",
+       " [0.838],\n",
+       " [1.23, 1.04]]\n",
+       "------------------------\n",
+       "type: 50 * var * float64
" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 48, + "execution_count": 54, "metadata": {}, "output_type": "execute_result" } @@ -1470,17 +1715,41 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 55, "id": "general-october", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[1,\n",
+       " 1,\n",
+       " 3,\n",
+       " 2,\n",
+       " 0,\n",
+       " 2,\n",
+       " 0,\n",
+       " 3,\n",
+       " 0,\n",
+       " 1,\n",
+       " ...,\n",
+       " 1,\n",
+       " 3,\n",
+       " 2,\n",
+       " 2,\n",
+       " 1,\n",
+       " 0,\n",
+       " 2,\n",
+       " 1,\n",
+       " 2]\n",
+       "----------------\n",
+       "type: 50 * int64
" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 49, + "execution_count": 55, "metadata": {}, "output_type": "execute_result" } @@ -1492,17 +1761,41 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 56, "id": "ongoing-rally", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[1,\n",
+       " 1,\n",
+       " 3,\n",
+       " 2,\n",
+       " 0,\n",
+       " 2,\n",
+       " 0,\n",
+       " 3,\n",
+       " 0,\n",
+       " 1,\n",
+       " ...,\n",
+       " 1,\n",
+       " 3,\n",
+       " 2,\n",
+       " 2,\n",
+       " 1,\n",
+       " 0,\n",
+       " 2,\n",
+       " 1,\n",
+       " 2]\n",
+       "----------------\n",
+       "type: 50 * int64
" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 50, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -1523,17 +1816,17 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 57, "id": "unique-trance", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=2.585678829246765, y=4.279516911052588)" + "VectorObject2D(x=2.585678829246765, y=4.279516911052588)" ] }, - "execution_count": 51, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -1544,17 +1837,17 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 58, "id": "pharmaceutical-notebook", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(rho=5, phi=0.5)" + "VectorObject2D(rho=5, phi=0.5)" ] }, - "execution_count": 52, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -1565,7 +1858,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 59, "id": "approved-ancient", "metadata": {}, "outputs": [ @@ -1588,7 +1881,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 60, "id": "derived-lincoln", "metadata": {}, "outputs": [ @@ -1611,7 +1904,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 61, "id": "dangerous-effect", "metadata": {}, "outputs": [ @@ -1634,7 +1927,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 62, "id": "weird-insert", "metadata": {}, "outputs": [ @@ -1657,7 +1950,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 63, "id": "satellite-southeast", "metadata": {}, "outputs": [ @@ -1688,17 +1981,17 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 64, "id": "statutory-bathroom", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=30, y=40)" + "VectorObject2D(x=30, y=40)" ] }, - "execution_count": 58, + "execution_count": 64, "metadata": {}, "output_type": "execute_result" } @@ -1709,17 +2002,17 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 65, "id": "foreign-celebration", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=30, y=40)" + "VectorObject2D(x=30, y=40)" ] }, - "execution_count": 59, + "execution_count": 65, "metadata": {}, "output_type": "execute_result" } @@ -1730,17 +2023,17 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 66, "id": "solved-resident", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=30, y=40)" + "VectorObject2D(x=30, y=40)" ] }, - "execution_count": 60, + "execution_count": 66, "metadata": {}, "output_type": "execute_result" } @@ -1751,17 +2044,17 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 67, "id": "comic-threshold", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(rho=50, phi=0.5)" + "VectorObject2D(rho=50, phi=0.5)" ] }, - "execution_count": 61, + "execution_count": 67, "metadata": {}, "output_type": "execute_result" } @@ -1780,17 +2073,17 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 68, "id": "prescription-arkansas", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=6, y=7)" + "VectorObject2D(x=6, y=7)" ] }, - "execution_count": 62, + "execution_count": 68, "metadata": {}, "output_type": "execute_result" } @@ -1801,17 +2094,17 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 69, "id": "sought-allah", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=6, y=7)" + "VectorObject2D(x=6, y=7)" ] }, - "execution_count": 63, + "execution_count": 69, "metadata": {}, "output_type": "execute_result" } @@ -1822,7 +2115,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 70, "id": "egyptian-nursing", "metadata": {}, "outputs": [ @@ -1832,7 +2125,7 @@ "15" ] }, - "execution_count": 64, + "execution_count": 70, "metadata": {}, "output_type": "execute_result" } @@ -1843,7 +2136,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 71, "id": "hourly-section", "metadata": {}, "outputs": [ @@ -1853,7 +2146,7 @@ "15" ] }, - "execution_count": 65, + "execution_count": 71, "metadata": {}, "output_type": "execute_result" } @@ -1872,7 +2165,7 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 72, "id": "unlike-melissa", "metadata": {}, "outputs": [ @@ -1882,7 +2175,7 @@ "50" ] }, - "execution_count": 66, + "execution_count": 72, "metadata": {}, "output_type": "execute_result" } @@ -1893,7 +2186,7 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 73, "id": "seasonal-section", "metadata": {}, "outputs": [ @@ -1903,7 +2196,7 @@ "49.99999999942831" ] }, - "execution_count": 67, + "execution_count": 73, "metadata": {}, "output_type": "execute_result" } @@ -1916,7 +2209,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 74, "id": "second-joseph", "metadata": {}, "outputs": [ @@ -1926,7 +2219,7 @@ "49.99999999942831" ] }, - "execution_count": 68, + "execution_count": 74, "metadata": {}, "output_type": "execute_result" } @@ -1939,7 +2232,7 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 75, "id": "material-technician", "metadata": {}, "outputs": [ @@ -1949,7 +2242,7 @@ "50.0" ] }, - "execution_count": 69, + "execution_count": 75, "metadata": {}, "output_type": "execute_result" } @@ -1970,7 +2263,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 76, "id": "focal-tactics", "metadata": {}, "outputs": [ @@ -1980,7 +2273,7 @@ "5.0" ] }, - "execution_count": 70, + "execution_count": 76, "metadata": {}, "output_type": "execute_result" } @@ -2013,7 +2306,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 77, "id": "purple-disco", "metadata": {}, "outputs": [ @@ -2024,7 +2317,7 @@ " dtype=[('x', '[[{x: 11, y: 6.1}, {x: 12, y: 7.2}],\n", + " [],\n", + " [{x: 13, y: 8.3}],\n", + " [{x: 14, y: 9.4}, {x: 15, y: 10.5}]]\n", + "-------------------------------------\n", + "type: 4 * var * Vector2D[\n", + " x: int64,\n", + " y: float64\n", + "]" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 72, + "execution_count": 78, "metadata": {}, "output_type": "execute_result" } @@ -2068,17 +2372,28 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 79, "id": "empirical-starter", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[[{x: 5, y: 1.2}, {x: 6, y: 2.3}],\n",
+       " [],\n",
+       " [{x: 5, y: 3.4}],\n",
+       " [{x: 5, y: 4.5}, {x: 6, y: 5.6}]]\n",
+       "----------------------------------\n",
+       "type: 4 * var * Vector2D[\n",
+       "    x: float64,\n",
+       "    y: float64\n",
+       "]
" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 73, + "execution_count": 79, "metadata": {}, "output_type": "execute_result" } @@ -2109,7 +2424,7 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 80, "id": "blocked-keyboard", "metadata": {}, "outputs": [ @@ -2119,7 +2434,7 @@ "0.20000000000000018" ] }, - "execution_count": 74, + "execution_count": 80, "metadata": {}, "output_type": "execute_result" } @@ -2132,7 +2447,7 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 81, "id": "exposed-pendant", "metadata": {}, "outputs": [ @@ -2142,7 +2457,7 @@ "0.20000000000000018" ] }, - "execution_count": 75, + "execution_count": 81, "metadata": {}, "output_type": "execute_result" } @@ -2155,7 +2470,7 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 82, "id": "liked-depression", "metadata": {}, "outputs": [ @@ -2165,7 +2480,7 @@ "0.20000000000000018" ] }, - "execution_count": 76, + "execution_count": 82, "metadata": {}, "output_type": "execute_result" } @@ -2178,7 +2493,7 @@ }, { "cell_type": "code", - "execution_count": 77, + "execution_count": 83, "id": "several-senator", "metadata": {}, "outputs": [ @@ -2188,7 +2503,7 @@ "0.20000000000000018" ] }, - "execution_count": 77, + "execution_count": 83, "metadata": {}, "output_type": "execute_result" } @@ -2209,17 +2524,17 @@ }, { "cell_type": "code", - "execution_count": 78, + "execution_count": 84, "id": "considerable-general", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=1, y=-0.7071067811865472, z=3.5355339059327378)" + "VectorObject3D(x=1, y=-0.7071067811865472, z=3.5355339059327378)" ] }, - "execution_count": 78, + "execution_count": 84, "metadata": {}, "output_type": "execute_result" } @@ -2230,17 +2545,17 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": 85, "id": "formed-fisher", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=1, y=-0.7071067811865472, z=3.5355339059327378, tau=10)" + "VectorObject4D(x=1, y=-0.7071067811865472, z=3.5355339059327378, tau=10)" ] }, - "execution_count": 79, + "execution_count": 85, "metadata": {}, "output_type": "execute_result" } @@ -2251,7 +2566,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 86, "id": "tribal-danger", "metadata": {}, "outputs": [ @@ -2261,7 +2576,7 @@ "1.4142135623730951" ] }, - "execution_count": 80, + "execution_count": 86, "metadata": {}, "output_type": "execute_result" } @@ -2272,7 +2587,7 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": 87, "id": "strategic-hypothesis", "metadata": {}, "outputs": [ @@ -2282,7 +2597,7 @@ "1.4142135623730951" ] }, - "execution_count": 81, + "execution_count": 87, "metadata": {}, "output_type": "execute_result" } @@ -2303,17 +2618,17 @@ }, { "cell_type": "code", - "execution_count": 82, + "execution_count": 88, "id": "loaded-kidney", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=0, y=0, z=3)" + "VectorObject3D(x=0, y=0, z=3)" ] }, - "execution_count": 82, + "execution_count": 88, "metadata": {}, "output_type": "execute_result" } @@ -2324,7 +2639,7 @@ }, { "cell_type": "code", - "execution_count": 83, + "execution_count": 89, "id": "atomic-corps", "metadata": {}, "outputs": [ @@ -2334,7 +2649,7 @@ "True" ] }, - "execution_count": 83, + "execution_count": 89, "metadata": {}, "output_type": "execute_result" } @@ -2355,17 +2670,17 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 90, "id": "preceding-possibility", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "vector.obj(x=-0.03, y=0.06, z=-0.030000000000000013)" + "VectorObject3D(x=-0.03, y=0.06, z=-0.030000000000000013)" ] }, - "execution_count": 84, + "execution_count": 90, "metadata": {}, "output_type": "execute_result" } @@ -2452,7 +2767,12 @@ " * `scale(factor)`: can also use the `*` operator\n", " * `equal(vector)`: can also use the `==` operator, but consider `isclose` instead\n", " * `not_equal(vector)`: can also use the `!=` operator, but consider `isclose` instead\n", - " * `isclose(vector, rtol=1e-5, atol=1e-8, equal_nan=False)`: works like [np.isclose](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html); arrays also have an [allclose](https://numpy.org/doc/stable/reference/generated/numpy.allclose.html) method" + " * `sum()`: can also use the `numpy.sum` or `awkward.sum`, only for NumPy and Awkward vectors\n", + " * `count_nonzero()`: can also use `numpy.count_nonzero` or `awkward.count_nonzero`, only for NumPy and Awkward vectors\n", + " * `count()`: can also use `awkward.count`, only for Awkward vectors\n", + " * `isclose(vector, rtol=1e-5, atol=1e-8, equal_nan=False)`: works like [np.isclose](https://numpy.org/doc/stable/reference/generated/numpy.isclose.html); arrays also have an [allclose](https://numpy.org/doc/stable/reference/generated/numpy.allclose.html) method\n", + " * `to_Vector*D(coordinates)`: replace `*` with the reuquired vector dimension\n", + " * `to_{coordinate-names}`: for example - `to_rhophietatau`\n" ] }, { @@ -2471,7 +2791,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 91, "id": "sporting-champion", "metadata": {}, "outputs": [], @@ -2483,7 +2803,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": 92, "id": "blocked-attribute", "metadata": {}, "outputs": [ @@ -2493,7 +2813,7 @@ "8.0" ] }, - "execution_count": 86, + "execution_count": 92, "metadata": {}, "output_type": "execute_result" } @@ -2514,17 +2834,46 @@ }, { "cell_type": "code", - "execution_count": 87, + "execution_count": 93, "id": "round-supplier", "metadata": {}, "outputs": [ { "data": { + "text/html": [ + "
[[{x: 0.687, y: 1.15, z: -0.272, t: 11.5}],\n",
+       " [{x: -0.00848, y: 0.739, z: 1.91, t: 11.2}, {x: 0.684, y: 0.686, ...}],\n",
+       " [{x: -0.348, y: 1.72, z: -0.385, t: 10.3}],\n",
+       " [{x: -0.818, y: -1.59, z: -0.719, t: 9.27}],\n",
+       " [{x: -0.15, y: -1.29, z: 1.05, t: 8.68}],\n",
+       " [{x: 0.789, y: 1.43, z: 0.76, t: 8.26}],\n",
+       " [],\n",
+       " [{x: -0.151, y: 1.87, z: -0.418, t: 10.8}, ..., {x: 1.16, y: -0.342, ...}],\n",
+       " [],\n",
+       " [{x: 0.111, y: -0.17, z: -1.85, t: 10.4}],\n",
+       " ...,\n",
+       " [{x: 0.281, y: 1.15, z: -0.604, t: 9.11}],\n",
+       " [{x: 1.19, y: 0.0225, z: 0.453, t: 10.4}],\n",
+       " [],\n",
+       " [{x: 0.637, y: 1.12, z: -0.651, t: 9.12}],\n",
+       " [{x: -0.609, y: -0.739, z: -0.225, t: 8.64}, {x: 0.326, y: -0.913, ...}],\n",
+       " [{x: 0.996, y: 1.03, z: 1.92, t: 9.4}],\n",
+       " [{x: 0.174, y: 0.759, z: 0.298, t: 9.74}],\n",
+       " [{x: 0.0768, y: -1.53, z: 1.87, t: 10.4}],\n",
+       " [{x: -1.22, y: -0.848, z: -0.486, t: 8.1}, {x: 0.487, y: 2.11, ...}]]\n",
+       "----------------------------------------------------------------------------\n",
+       "type: 50 * var * Momentum4D[\n",
+       "    x: float64,\n",
+       "    y: float64,\n",
+       "    z: float64,\n",
+       "    t: float64\n",
+       "]
" + ], "text/plain": [ - "" + "" ] }, - "execution_count": 87, + "execution_count": 93, "metadata": {}, "output_type": "execute_result" } @@ -2548,7 +2897,7 @@ }, { "cell_type": "code", - "execution_count": 88, + "execution_count": 94, "id": "emotional-headquarters", "metadata": {}, "outputs": [], @@ -2566,26 +2915,26 @@ }, { "cell_type": "code", - "execution_count": 89, + "execution_count": 95, "id": "recorded-grass", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "array([ 8.95477603, 0. , 9.8871152 , 0. , 39.07925142,\n", - " 48.55053642, 9.55009174, 31.75711709, 10.04008594, 0. ,\n", - " 51.7984392 , 8.66502552, 9.69483698, 29.51663446, 12.41687358,\n", - " 31.415441 , 0. , 19.80136543, 29.56169674, 9.87277159,\n", - " 9.73184162, 11.38881315, 22.24734135, 21.37722606, 8.03300384,\n", - " 0. , 29.03811593, 9.88647946, 21.95344143, 10.68257124,\n", - " 9.96117033, 23.35887444, 0. , 9.3885009 , 18.96812068,\n", - " 29.25050679, 0. , 0. , 0. , 0. ,\n", - " 0. , 8.48410078, 18.50092416, 0. , 9.43988115,\n", - " 0. , 9.0743725 , 8.96849697, 17.25900391, 29.60567615])" + "array([11.41642718, 22.27865971, 10.18939374, 9.07252983, 8.51331485,\n", + " 8.06422211, 0. , 29.352758 , 0. , 10.21844468,\n", + " 11.34362616, 21.10216985, 11.4527522 , 20.14324739, 9.98358839,\n", + " 18.23053058, 10.98279243, 11.19606712, 10.26290851, 0. ,\n", + " 38.84013335, 8.15996425, 0. , 0. , 30.09499597,\n", + " 19.91427266, 19.72327799, 8.73084137, 20.89841204, 31.50194351,\n", + " 21.27361129, 9.11625113, 16.13237037, 31.6223863 , 52.00371003,\n", + " 9.42533027, 18.02849722, 9.26139639, 0. , 9.28157987,\n", + " 30.40031906, 9.01300947, 10.32904192, 0. , 9.0039702 ,\n", + " 18.76867382, 9.0933228 , 9.70217628, 10.06981863, 19.48030101])" ] }, - "execution_count": 89, + "execution_count": 95, "metadata": {}, "output_type": "execute_result" } @@ -2594,14 +2943,27 @@ "compute_masses(array)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Talks about vector\n", + "\n", + "- 9th October 2023 - [What’s new with Vector? First major release is out!](https://indi.to/35ym5) - [PyHEP 2023 (virtual)](https://indico.cern.ch/event/1252095/) [🎥](https://www.youtube.com/watch?v=JHEAb2R3xzE&list=PLKZ9c4ONm-VlAorAG8kR09ZqhMfHiH2LJ&index=10)\n", + "- 13th September 2022 - [Constructing HEP vectors and analyzing HEP data using Vector](https://indi.to/bPmMc) - [PyHEP 2022 (virtual)](https://indico.cern.ch/event/1150631/) [🎥](https://www.youtube.com/watch?v=4iveMzrbe7s&list=PLKZ9c4ONm-VkohKG-skzEG_gklMaSgaO7&index=15)\n", + "- 20th July 2022 - [Analysis Grand Challenge / HEP Scientific Python Ecosystem](https://indico.cern.ch/event/1151329/timetable/#3-analysis-grand-challenge-hep) - [DANCE/CoDaS@Snowmass 2022 computational and data science software training](https://indico.cern.ch/event/1151329/)\n", + "- 25th April 2022 - [Foundation libraries (uproot, awkward, hist, mplhep)](https://indico.cern.ch/event/1126109/contributions/4780138/) - [IRIS-HEP AGC Tools 2022 Workshop](https://indico.cern.ch/event/1126109/) [🎥](https://www.youtube.com/watch?v=O9KvsDMKOmY)\n", + "- 3rd November 2021 - [Data handling: uproot, awkward & vector](https://indico.cern.ch/event/1076231/contributions/4560398/) - [IRIS-HEP AGC Tools 2021 Workshop](https://indico.cern.ch/event/1076231/) [🎥](https://indico.cern.ch/event/1076231/contributions/4560398/attachments/2338579/4017718/agc_uproot_awk.mp4)\n" + ] + }, { "cell_type": "markdown", "id": "particular-bangkok", "metadata": {}, "source": [ - "### Status as of April 8, 2021\n", + "### Status as of November 17, 2023\n", "\n", - "Undoubtedly, there are rough edges, but most of the functionality is there and Vector is ready for user-testing. It can only be improved by your feedback!" + "First major release of vector is out and the package has reached a stable position. The work is spearheaded by bug reports and feature requests created on GitHub. It can only be improved by your feedback!" ] } ], @@ -2621,7 +2983,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.0" + "version": "3.11.5" } }, "nbformat": 4, From 86bac3691b28325a557efe26ef81fb5857680ec5 Mon Sep 17 00:00:00 2001 From: Saransh Chopra Date: Fri, 17 Nov 2023 23:50:03 +0530 Subject: [PATCH 2/2] normalize notebook --- docs/usage/intro.ipynb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/usage/intro.ipynb b/docs/usage/intro.ipynb index 6f471ed6..83d6df58 100644 --- a/docs/usage/intro.ipynb +++ b/docs/usage/intro.ipynb @@ -67,6 +67,7 @@ { "cell_type": "code", "execution_count": 2, + "id": "c133d634", "metadata": {}, "outputs": [ { @@ -87,6 +88,7 @@ { "cell_type": "code", "execution_count": 3, + "id": "2e48bfd8", "metadata": {}, "outputs": [ { @@ -107,6 +109,7 @@ { "cell_type": "code", "execution_count": 4, + "id": "73748719", "metadata": {}, "outputs": [ { @@ -126,6 +129,7 @@ }, { "cell_type": "markdown", + "id": "3dbe90b0", "metadata": {}, "source": [ "and so on for every class.\n", @@ -572,6 +576,7 @@ { "cell_type": "code", "execution_count": 21, + "id": "c88d6a0c", "metadata": {}, "outputs": [ { @@ -597,6 +602,7 @@ { "cell_type": "code", "execution_count": 22, + "id": "63ce54aa", "metadata": {}, "outputs": [ { @@ -619,6 +625,7 @@ { "cell_type": "code", "execution_count": 23, + "id": "443654ec", "metadata": {}, "outputs": [ { @@ -648,6 +655,7 @@ }, { "cell_type": "markdown", + "id": "0c54ccf5", "metadata": {}, "source": [ "and so on for every class.\n", @@ -2945,6 +2953,7 @@ }, { "cell_type": "markdown", + "id": "bb6c289a", "metadata": {}, "source": [ "## Talks about vector\n",