The input/result to the foreign should be a list of bytes, not a file.
Henry Rich On 9/24/2020 12:06 PM, 'Zhihao Yuan' via Source 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.
-- This email has been checked for viruses by AVG. https://www.avg.com ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm