Ejemplo n.º 1
0
def test_fileforBinJS():
    filename = "../s3/u2.bin"
    format = "u2"

    with open(filename, "wb") as f:
        buffer = binpy.write({"variableA": np.arange(0, 100, dtype=format)})
        f.write(buffer)
Ejemplo n.º 2
0
def f2d(format):
    print("Testing {}".format(format))
    buffer = binpy.write({
        "variableA":
        np.arange(0, 100, dtype=format),
        "variableB":
        np.arange(0, 400, dtype=format).reshape(200, 2)
    })
    results = binpy.read(buffer)
    np.testing.assert_array_equal(
        results["variableB"],
        np.arange(0, 400, dtype=format).reshape(200, 2))
Ejemplo n.º 3
0
def test_file():
    filename = "test.bin"
    format = "u2"

    with open(filename, "wb") as f:
        buffer = binpy.write({"variableA": np.arange(0, 100, dtype=format)})
        f.write(buffer)

    with open(filename, "rb") as f:
        results = binpy.read(f)
        np.testing.assert_array_equal(results["variableA"],
                                      np.arange(0, 100, dtype=format))

    os.remove(filename)
Ejemplo n.º 4
0
def f1dt():
    print("Testing datetime")
    dt = np.datetime64('2017-01-01') + np.arange(10) * np.timedelta64(1, 'h')
    buffer = binpy.write({"variableA": dt})
    results = binpy.read(buffer)
    np.testing.assert_array_equal(results["variableA"], dt)