From 4994adba9ec21779bba7f9041ac2859436d06124 Mon Sep 17 00:00:00 2001 From: Joey Kleingers Date: Thu, 28 Dec 2023 10:19:39 -0500 Subject: [PATCH] Expose IDataArray/IDataStore resize_tuples method to Python. (#807) Signed-off-by: Joey Kleingers Signed-off-by: Michael Jackson Co-authored-by: Michael Jackson --- .gitignore | 1 + conda/meta.yaml | 2 +- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 2 ++ wrapping/python/docs/source/DataObjects.rst | 19 +++++++++++++++++++ wrapping/python/docs/source/Overview.rst | 12 ++++++------ 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 5c4af167d4..2ed0689094 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ CMakeLists.txt.* test_data/ CMakeUserPresets.json Workspace +/__pycache__/ diff --git a/conda/meta.yaml b/conda/meta.yaml index c95f3071e0..3bccc8d23d 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,5 +1,5 @@ {% set name = "simplnx" %} -{% set version = "1.2.1" %} +{% set version = "1.2.2" %} package: name: {{ name|lower }} diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 753e94613b..178435a4e3 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -161,6 +161,7 @@ auto BindDataStore(py::handle scope, const char* name) py::return_value_policy::reference_internal); dataStore.def("__getitem__", &DataStore::at); dataStore.def("__len__", &DataStore::getSize); + dataStore.def("resize_tuples", &DataStore::resizeTuples, "Resize the tuples with the given shape"); return dataStore; } @@ -703,6 +704,7 @@ PYBIND11_MODULE(simplnx, mod) iDataArray.def_property_readonly("tdims", &IDataArray::getTupleShape); iDataArray.def_property_readonly("cdims", &IDataArray::getComponentShape); iDataArray.def_property_readonly("data_type", &IDataArray::getDataType); + iDataArray.def("resize_tuples", &IDataArray::resizeTuples, "Resize the tuples with the given shape"); auto dataArrayInt8 = SIMPLNX_PY_BIND_DATA_ARRAY(mod, Int8Array); auto dataArrayUInt8 = SIMPLNX_PY_BIND_DATA_ARRAY(mod, UInt8Array); diff --git a/wrapping/python/docs/source/DataObjects.rst b/wrapping/python/docs/source/DataObjects.rst index 6d09f285ad..861cb96875 100644 --- a/wrapping/python/docs/source/DataObjects.rst +++ b/wrapping/python/docs/source/DataObjects.rst @@ -194,6 +194,16 @@ in the example. :ivar store: The DataStore object. :ivar dtype: The type of data stored in the DataArray + + .. py:method:: resize_tuples + + Resize the DataStore with the given shape array. + + :ivar shape: List: The new dimensions of the DataStore in the order from slowest to fastest + +DataArray Example Usage +^^^^^^^^^^^^^^^^^^^^^^^ + This code will create a DataArray called "2D Array" with tuple dimensions of [4,5], 3 components at each tuple, of type Float32 with every element initialized to "0.0" and then print the name, tuple_dimensions and component_dims of the created DatArray object @@ -249,6 +259,15 @@ from a created DataArray_ by executing the :ref:`Create Data Array