Trying to parse a rank-one tensor from a .npy file currently results in a JSON::ParseException.
The exception is raised when trying to parse the JSON header, and is specifically due to a trailing comma that is left behind only in the rank-one case after the gsub calls here.
Problem description
Trying to parse a rank-one tensor from a .npy file currently results in a
JSON::ParseException
. The exception is raised when trying to parse the JSON header, and is specifically due to a trailing comma that is left behind only in the rank-one case after thegsub
calls here.Example
Workaround
One can pad the shape with one or mores
1
s before serialization and reshape back to rank-one after de-serialization.Proposed Fix
Change the second
gsub
on line 51 inio/npy.cr
fromgsub(/,]|],/, "]")
togsub(/,],|],/, "]")