Skip to content

Commit

Permalink
Tidying up language
Browse files Browse the repository at this point in the history
Also fixed up some examples to work for the latest version of the code.
  • Loading branch information
iamsrp-deshaw committed Aug 16, 2024
1 parent edebef1 commit 8847a53
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions python/tests/hypercube.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"As part of the `hypercube` package, the `CubeMath` library is designed to offer many of `numpy`'s math operations for Hypercubes. As part of this effort, we have also developed `VectorizedCubeMath`, an experimental library, that offers SIMD-accelerated operations through [the Vector API](https://openjdk.org/jeps/426). It's worth making note here that [the Vector API](https://openjdk.org/jeps/426), as of 08/18/2023, is an incubator module in Java, and so it should be regarded as highly experimental.\n",
"\n",
"In this notebook, we'll be using hypercubes in Python (through PJRmi) for ease of demonstration. We'll be covering:\n",
"- hypercubes and `ndarray` operations on them\n",
"- Hypercubes and `ndarray` operations on them\n",
"- `CubeMath` and math operations on hypercubes\n",
"- `VectorizedCubeMath` (experimental library)\n",
"- Performance and benchmarks\n",
"\n",
"### Let's dive in!\n",
"\n",
"Note that we're passing the `includeVectorized` parameter to include `VectorizedCubeMath` in our build. By default, all Vectorized code is hidden from the build, since we'll be needing **Java 17** for that.\n",
"Note that we're passing the `includeVectorized` parameter to include `VectorizedCubeMath` in our build. By default, all Vectorized code is hidden from the build, since it requires Java 17 and we don't want to force users there unless we have to.\n",
"\n",
"Assuming you are in the PJRmi directory and only have one wheel file, you can run something like:\n",
"\n",
Expand Down Expand Up @@ -189,10 +189,11 @@
"\n",
"# We can slice cubes\n",
"subcube = cube[3:7]\n",
"print(\"Subcube: \", subcube)\n",
"print(\"Subcube:\")\n",
"print(subcube)\n",
"\n",
"# We can use Python's get/set syntax\n",
"subcube[0] = np.int32(10) # Note that we cast the number to a 32-bit integer for PJRmi to correctly type the value on the Java side.\n",
"subcube[0] = 10",
"print(cube[3]) # Unsurprisingly, the change is reflected in the original cube."
]
},
Expand Down Expand Up @@ -223,17 +224,17 @@
},
"outputs": [],
"source": [
"# First, let's reshape the cube, so we have multiple dimensions to work with.\n",
"# First let's reshape the cube, so we have multiple dimensions to work with.\n",
"reshaped = cube.reshape((2, 5))\n",
"print(\"Reshaped:\")\n",
"print(reshaped)\n",
"\n",
"# Now, shift (i.e., \"flat roll\") the cube.\n",
"# Now shift (i.e., \"flat roll\") the cube.\n",
"shifted = reshaped.roll(2)\n",
"print(\"Shifted:\")\n",
"print(shifted)\n",
"\n",
"# Now, let's try rolling the cube across both axes.\n",
"# Now let's try rolling the cube across both axes.\n",
"rolled = reshaped.roll((1, 2))\n",
"print(\"Rolled:\")\n",
"print(rolled)\n",
Expand Down

0 comments on commit 8847a53

Please sign in to comment.