File: read-numerical-json.py

package info (click to toggle)
python-awkward 2.8.10-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 25,144 kB
  • sloc: python: 182,845; cpp: 33,828; sh: 432; makefile: 21; javascript: 8
file content (24 lines) | stat: -rw-r--r-- 1,076 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
os.chdir("..")
print(os.getcwd())

import numpy
import awkward1

content = numpy.fromfile(open("studies/sample-content.float32", "rb"), dtype=numpy.float32)
offsets1 = numpy.fromfile(open("studies/sample-offsets1.int64", "rb"), dtype=numpy.int64)
offsets2 = numpy.fromfile(open("studies/sample-offsets2.int64", "rb"), dtype=numpy.int64)
offsets3 = numpy.fromfile(open("studies/sample-offsets3.int64", "rb"), dtype=numpy.int64)

array = awkward1.layout.ListOffsetArray64(
            awkward1.layout.Index64(offsets3),
            awkward1.layout.ListOffsetArray64(
                awkward1.layout.Index64(offsets2),
                awkward1.layout.ListOffsetArray64(
                    awkward1.layout.Index64(offsets1),
                    awkward1.layout.NumpyArray(content))))

array.tojson("studies/sample-jagged3.json", maxdecimals=5)
array.content.tojson("studies/sample-jagged2.json", maxdecimals=5)
array.content.content.tojson("studies/sample-jagged1.json", maxdecimals=5)
array.content.content.content.tojson("studies/sample-jagged0.json", maxdecimals=5)