commit 9b2e9b184ff5adb619c43b36086de0dd8ce9610b Author: Dimitri Lozeve Date: Wed Oct 4 13:26:25 2023 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..56fa964 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.npy diff --git a/npy.bqn b/npy.bqn new file mode 100644 index 0000000..7febe2a --- /dev/null +++ b/npy.bqn @@ -0,0 +1,40 @@ +⟨SaveNpy,LoadNpy⟩⇐ + +lf←@+10 +magicString←(@+147)∾"NUMPY" # "\x93NUMPY" + +To_i16le←{@+256(|∾⌊∘÷˜)𝕩} +# To_i16le←⟨16,8‿'c'⟩•bit._cast∘≍ # assumes the platform is little-endian +FloatToBytes←⟨64,8‿'c'⟩•bit._cast + +FormatShape←{'('∾(1↓∾⥊','∾˘•Fmt¨≢𝕩)∾')'} + +BuildHeader←{𝕊𝕩: + version←1‿0 + # Hypothesis: BQN arrays are C-contiguous + headerData←"{'descr': '