Skip to content

Instantly share code, notes, and snippets.

@glegrain
Created October 1, 2020 16:11
Show Gist options
  • Save glegrain/b2ad2e2f4d3e98bab36fef6e502d9e35 to your computer and use it in GitHub Desktop.
Save glegrain/b2ad2e2f4d3e98bab36fef6e502d9e35 to your computer and use it in GitHub Desktop.
Numpy array to C file
import numpy as np
import subprocess
my_data = np.array([0, 0.1, 0.2, 0.3], dtype=np.float32)
np.array(my_data).tofile('my_data.bin')
subprocess.run(["xxd", "-i", "my_data.bin", "my_data.h"], capture_output=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment