Skip to content

Commit 116c221

Browse files
committed
Python bindings and tests
1 parent c962c95 commit 116c221

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/binding/python/Series.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,18 @@ void init_Series(py::module &m) {
8080

8181
py::class_<Series, Attributable>(m, "Series")
8282

83-
.def(py::init<std::string const&, Access, std::string const &>(),
84-
py::arg("filepath"), py::arg("access"), py::arg("options") = "{}")
83+
.def(py::init<std::string const&, Access, std::string const &, bool>(),
84+
py::arg("filepath"),
85+
py::arg("access"),
86+
py::arg("options") = "{}",
87+
py::arg("parse_lazily") = false)
8588
#if openPMD_HAVE_MPI
8689
.def(py::init([](
8790
std::string const& filepath,
8891
Access at,
8992
py::object &comm,
90-
std::string const& options){
93+
std::string const& options,
94+
bool parseLazily){
9195
//! TODO perform mpi4py import test and check min-version
9296
//! careful: double MPI_Init risk? only import mpi4py.MPI?
9397
//! required C-API init? probably just checks:
@@ -133,12 +137,13 @@ void init_Series(py::module &m) {
133137
"(Mismatched MPI at compile vs. runtime?)");
134138
}
135139

136-
return new Series(filepath, at, *mpiCommPtr, options);
140+
return new Series(filepath, at, *mpiCommPtr, options, parseLazily);
137141
}),
138142
py::arg("filepath"),
139143
py::arg("access"),
140144
py::arg("mpi_communicator"),
141-
py::arg("options") = "{}"
145+
py::arg("options") = "{}",
146+
py::arg("parse_lazily") = false
142147
)
143148
#endif
144149

test/python/unittest/API/APITest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,8 @@ def makeIteratorRoundTrip(self, backend, file_ending):
16341634
read = io.Series(
16351635
"../samples/unittest_serialIterator." + file_ending,
16361636
io.Access_Type.read_only,
1637-
jsonConfig
1637+
jsonConfig,
1638+
parse_lazily=True
16381639
)
16391640
for it in read.read_iterations():
16401641
lastIterationIndex = it.iteration_index
@@ -1682,9 +1683,11 @@ def makeAvailableChunksRoundTrip(self, ext):
16821683

16831684
read = io.Series(
16841685
name,
1685-
io.Access_Type.read_only
1686+
io.Access_Type.read_only,
1687+
parse_lazily=True
16861688
)
16871689

1690+
read.iterations[0].open()
16881691
chunks = read.iterations[0].meshes["E"]["x"].available_chunks()
16891692
chunks = sorted(chunks, key=lambda chunk: chunk.offset)
16901693
for chunk in chunks:

0 commit comments

Comments
 (0)