Skip to content

Testing of transfer of data from Python to Javascript

Notifications You must be signed in to change notification settings

zdenekhynek/numpy-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NUMERICAL DATA FROM PYTHON TO JAVASCRIPT

An example of sending numerical data from numpy array, co, commonly used as binary data in an octet-stream which can be loaded to JavaScript typed arrays for efficient processing and visualisation.

There are snippets loading .npyc files in Javascript, however this project shows how to send the numerical data without storing them into a file first.

Server

This is a Python application that uses FastAPI web framework to create a simple API for generating and streaming numerical arrays.

Requirements

  • Python 3.6 or later
  • pip

Installation

python -m venv ~/.venvs/numpy-stream
pip install -r requirements.txt

### Usage

Go to the correct directory

cd server

activate project venv

source ~/.venvs/numpy-stream/bin/activate

and then start the development server

uvicorn main:app --reload --port 5001

Visit the following routes in your browser or via a tool like curl or postman:

Client

cd client
npm install
npm start

References

https://github.com/aplbrain/npyjs https://www.sharpsightlabs.com/blog/numpy-savetxt/

https://github.com/numpy/numpy/blob/v1.24.0/numpy/lib/npyio.py#L451-L523 https://github.com/numpy/numpy/blob/v1.24.0/numpy/lib/npyio.py#L1367-L1612 https://github.com/numpy/numpy/blob/8cec82012694571156e8d7696307c848a7603b4e/numpy/lib/format.py#L658

Contributing

If you would like to contribute to this project, please open a pull request.

Contact

If you have any questions or issues, please open an issue or contact the repository owner.

About

Testing of transfer of data from Python to Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published