aplbrain / npyjs

Read numpy .npy files in JavaScript
https://aplbrain.github.io/npyjs/
Apache License 2.0
77 stars 21 forks source link

dtype '|u1'? #3

Closed Fil closed 4 years ago

Fil commented 4 years ago

Someone sent me a npy with '|u1', which results in an error. I had to add it in dtypes so that it would parse.

hexdump -C

00000000  93 4e 55 4d 50 59 01 00  76 00 7b 27 64 65 73 63  |.NUMPY..v.{'desc|
00000010  72 27 3a 20 27 7c 75 31  27 2c 20 27 66 6f 72 74  |r': '|u1', 'fort|
00000020  72 61 6e 5f 6f 72 64 65  72 27 3a 20 46 61 6c 73  |ran_order': Fals|
00000030  65 2c 20 27 73 68 61 70  65 27 3a 20 28 34 39 39  |e, 'shape': (499|
00000040  35 30 30 2c 29 2c 20 7d  20 20 20 20 20 20 20 20  |500,), }        |
j6k4m8 commented 4 years ago

Got it! Won't be able to add this for a while on my end, but if you PR it we can merge (and we'd be very appreciative!)

Fil commented 4 years ago

I've sent a PR.

I've also extracted the decoding function so I could use in the browser: https://observablehq.com/@fil/npyjs