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)
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))
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)
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)