Skip to content

Commit

Permalink
Updated to cover hypercubes
Browse files Browse the repository at this point in the history
  • Loading branch information
iamsrp-deshaw committed Nov 3, 2023
1 parent 095de47 commit ac15efe
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Some headline features of PJRmi are:
- Thread-safe execution, with built-in locking support and asynchronous
execution via futures.
- Realtime code injection.
- A [numpy](https://numpy.org/)-like math library for Java, which is also
directly interoperable with Python.

Use-case examples:
- Scriptification of Java applications.
Expand Down Expand Up @@ -105,6 +107,27 @@ And you can treat the Java objects much like Python ones:
>>> 1 in a
True

The `hypercube` package supports `ndarray`-like Java classes, as well as
providing a subset of `numpy` math library operations. Hypercubes also duck-type
as `ndarray`s in Python:

>>> DoubleArrayHypercube = c.class_for_name('com.deshaw.hypercube.DoubleArrayHypercube')
>>> Dimension = c.class_for_name('com.deshaw.hypercube.Dimension')
>>> CubeMath = c.class_for_name('com.deshaw.hypercube.CubeMath')
>>> dac = DoubleArrayHypercube(Dimension.of((3,3,3)))
>>> dac.reshape((27,))[:] = tuple(range(27))
>>> dac[0]
DoubleSlicedHypercube([ [0.0, 1.0, 2.0] ,
[3.0, 4.0, 5.0] ,
[6.0, 7.0, 8.0] ])
>>> numpy.sum(dac)
351.0
>>> CubeMath.sum(dac)
351.0

These are covered in more detail in the Jupyter
[notebook](python/tests/hypercube.ipynb).


## Accessing Existing Object Instances

Expand Down

0 comments on commit ac15efe

Please sign in to comment.