Skip to content

Commit

Permalink
Merge pull request py4dstem#503 from bsavitzky/listwrite_patch
Browse files Browse the repository at this point in the history
Listwrite patch
  • Loading branch information
sezelt authored Aug 25, 2023
2 parents a188444 + bfdb478 commit 3bfbdaf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'gdown >= 4.4.0',
'dask >= 2.3.0',
'distributed >= 2.3.0',
'emdfile >= 0.0.10',
'emdfile >= 0.0.12',
'mpire >= 2.7.1',
'threadpoolctl >= 3.1.0'
],
Expand Down
47 changes: 47 additions & 0 deletions test/test_native_io/test_listwrite.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import py4DSTEM
import numpy as np

# filepath
from os import getcwd, remove
from os.path import join, exists
path = join(getcwd(),"test.h5")


def test_listwrite():

# make two arrays
ar1 = py4DSTEM.RealSlice(
data = np.arange(24).reshape((2,3,4)),
name = 'array1'
)
ar2 = py4DSTEM.RealSlice(
data = np.arange(48).reshape((4,3,4)),
name = 'array2'
)

# save them
py4DSTEM.save(
filepath = path,
data = [ar1,ar2],
mode = 'o'
)

# read them
data1 = py4DSTEM.read(
path,
datapath = 'array1_root'
)
data2 = py4DSTEM.read(
path,
datapath = 'array2_root'
)

# check
assert(np.array_equal(data1.data, ar1.data))
assert(np.array_equal(data2.data, ar2.data))

# delete the file
if exists(path):
remove(path)


0 comments on commit 3bfbdaf

Please sign in to comment.