Skip to content

Support constructing array from JSON #246

@mateogianolio

Description

@mateogianolio

Example:

import { array, equals } from 'vectorious';

const x = array([1, 2, 3]);
/*
array([ 1, 2, 3 ], dtype=float64)
*/

const serialized = JSON.stringify(x);
/*
'{"data":{"0":1,"1":2,"2":3},"dtype":"float64","length":3,"shape":[3],"strides":[1]}'
*/

const deserialized = JSON.parse(serialized);
/*
{
  data: { '0': 1, '1': 2, '2': 3 },
  dtype: 'float64',
  length: 3,
  shape: [ 3 ],
  strides: [ 1 ]
}
*/

const y = array(deserialized)

assert(equals(x, y));

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions