good example of ad hoc use of layout strings

John Rose john.r.rose at oracle.com
Wed Aug 17 00:39:50 UTC 2016


We should be able to provide something similar to SciPy formatted arrays.

http://docs.scipy.org/doc/numpy/user/basics.rec.html#structured-arrays

Their example looks like this:

x = np.array([(1,2.,'Hello'), (2,3.,"World")],
              dtype=[('foo', 'i4'),('bar', 'f4'), ('baz', 'S10')])

Here's a straw men imitation in Java.

StructArray x = new StructArray(scope,
  2, StructArray.type(" Sw(foo) Fw(bar) A10o(baz) "),
  new Object[][]{{1,2.0,"Hello"}, {2,3.0,"World"}});

Struct x1 = x.refElement(1);
x1.toString() => (2, 3.0, World)

DoubleArray1D c1 = x.refColumn("bar");
c1.toString() => [2.0, 3.0]

c1.setElement(1, 3.14);
x1.toString() => (2, 3.14, World)



More information about the panama-spec-experts mailing list