Skip to content

Commit

Permalink
Expose IDataArray/IDataStore resize_tuples method to Python. (#807)
Browse files Browse the repository at this point in the history
Signed-off-by: Joey Kleingers <[email protected]>
Signed-off-by: Michael Jackson <[email protected]>
Co-authored-by: Michael Jackson <[email protected]>
  • Loading branch information
joeykleingers and imikejackson authored Dec 28, 2023
1 parent 26de993 commit 4994adb
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ CMakeLists.txt.*
test_data/
CMakeUserPresets.json
Workspace
/__pycache__/
2 changes: 1 addition & 1 deletion conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "simplnx" %}
{% set version = "1.2.1" %}
{% set version = "1.2.2" %}

package:
name: {{ name|lower }}
Expand Down
2 changes: 2 additions & 0 deletions src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ auto BindDataStore(py::handle scope, const char* name)
py::return_value_policy::reference_internal);
dataStore.def("__getitem__", &DataStore<T>::at);
dataStore.def("__len__", &DataStore<T>::getSize);
dataStore.def("resize_tuples", &DataStore<T>::resizeTuples, "Resize the tuples with the given shape");
return dataStore;
}

Expand Down Expand Up @@ -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);
Expand Down
19 changes: 19 additions & 0 deletions wrapping/python/docs/source/DataObjects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -249,6 +259,15 @@ from a created DataArray_ by executing the :ref:`Create Data Array <CreateDataAr
Get a value at a specified index. Use of the numpy view into the DataArray is preferred.

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


DataStore Example Usage
^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python
Expand Down
12 changes: 6 additions & 6 deletions wrapping/python/docs/source/Overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ created.

.. py:method:: execute()
:return: A simplnx.IFilter.Result object that contains any warnings or errors
that were encountered during the execution of the filter.
:rtype: simplnx.IFilter.Result
:return: A complex.IFilter.Result object that contains any warnings or errors that were encountered during the execution of the filter.

:rtype: complex.IFilter.Result

.. py:method:: preflight()
:return: A simplnx.IFilter.Result object that contains any warnings or errors
that were encountered during the preflight of the filter.
:rtype: simplnx.IFilter.Result
:return: A complex.IFilter.Result object that contains any warnings or errors that were encountered during the preflight of the filter.

:rtype: complex.IFilter.Result

.. code:: python
Expand Down

0 comments on commit 4994adb

Please sign in to comment.