Add license and readme
This commit is contained in:
parent
b868903a81
commit
1c6c3b8df7
2 changed files with 72 additions and 0 deletions
28
LICENSE
Normal file
28
LICENSE
Normal file
|
@ -0,0 +1,28 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2023, Dimitri Lozeve
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
44
README.org
Normal file
44
README.org
Normal file
|
@ -0,0 +1,44 @@
|
|||
* Serialization and deserialization library for BQN arrays
|
||||
|
||||
This library allows to save and load BQN arrays to the binary [[https://numpy.org/doc/stable/reference/generated/numpy.lib.format.html][NPY
|
||||
format]] compatible with Numpy. It can also be used to interoperate
|
||||
with Numpy.
|
||||
|
||||
** Limitations
|
||||
|
||||
The library only support homogeneous multidimensional arrays with the
|
||||
following Numpy dtypes:
|
||||
|
||||
| dtype | Description |
|
||||
|-------+-------------------------------------------------------------|
|
||||
| ~<f8~ | little-endian 64-bit double-precision floating point number |
|
||||
| ~<i4~ | little-endian 32-bit signed integer |
|
||||
| ~<u4~ | little-endian 32-bit unsigned integer |
|
||||
|
||||
All other dtypes (big-endian numbers, booleans, bytes, objects, other
|
||||
sizes of floats or integers) are unsupported and files containing them
|
||||
will raise an error when loaded.
|
||||
|
||||
When serializing BQN arrays, the library uses the most restrictive
|
||||
dtype possible. An array consisting only of positive integers will be
|
||||
saved as ~<u4~, otherwise ~<i4~ if there are negative integers,
|
||||
otherwise ~<f8~ for arbitrary numbers.
|
||||
|
||||
** Usage
|
||||
|
||||
#+begin_src bqn
|
||||
⟨SaveNpy,LoadNpy⟩←•Import"npy.bqn"
|
||||
|
||||
# Deserialization
|
||||
arr1←LoadNpy"arr1.npy"
|
||||
|
||||
# Serialization
|
||||
arr2←2‿3‿4⥊•rand.Range 0 # will be saved as a floating point array
|
||||
"arr2.npy" SaveNpy arr2
|
||||
#+end_src
|
||||
|
||||
** Tests
|
||||
|
||||
Run the Python script to generate test data: =python gentest.py=.
|
||||
|
||||
To run tests, run =bqn tests.bqn=.
|
Loading…
Add table
Add a link
Reference in a new issue