Even if patch weren't accepted for some reason, is there a library version that 
can be called from J?  Less, but still, useful would be conversion to/from 3!:1 
format.

For consistency with 3!:1, likely should be 2 monadic foreigns (if encoding 
does not require a dyadic control parameter) that operate on strings rather 
than files.






On Thursday, September 24, 2020, 12:06:34 p.m. EDT, 'Zhihao Yuan' via Source 
<[email protected]> wrote: 





NPY is a popular lightweight binary format
for exchanging multidimensional arrays.

  https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html

NumPy introduced it, and now it gains support
in the NumPy ecosystem. It gains support in
other languages, too, such as C++ (via xtensor-io).

This patch proposes a new foreign, 128!:9. Its
dyad form writes a J array to a npy file,

x 128!:9 '1d'
(returns a boxed full path to 1d.npy)

and its monad form can read it back

x =: 128!:9 '1d'

An atom array is treated as zero-dimension
NumPy array. The data types are supported
with best efforts.

SimpleRose Inc crafted this patch and would
like to contribute it to J, so that J can exchange
data with NumPy/Python in binary, without
losing a bit of precision.

About the patch: To parse npy headers
correctly, the patch uses a PEG parser
generated with PackCC.

-- 
Zhihao
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to