Skip to content

Conversation

@yungyuc
Copy link
Member

@yungyuc yungyuc commented Dec 12, 2021

  • Add SimpleArray::swap().
  • Create modmesh::python::makeSimpleArray to create SimpleArray from ndarray (pybind11::array_t) buffer.
    • Use a more concise declaration to return reference from lambda.

* Add SimpleArray::swap().
* Create modmesh::python::makeSimpleArray to create SimpleArray from ndarray (pybind11::array_t) buffer.
  * Use a more concuse declaration to return reference from lambda.
@yungyuc yungyuc added the refactor Change code without changing tests label Dec 12, 2021
@yungyuc yungyuc self-assigned this Dec 12, 2021

struct
MODMESH_PYTHON_WRAPPER_VISIBILITY
ConcreteBufferNdarrayRemover : ConcreteBuffer::remover_type
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the remover to the common file.

}; /* end struct ConcreteBufferNdarrayRemover */

template < typename T >
static SimpleArray<T> makeSimpleArray(pybind11::array_t<T> & ndarr)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Helper function to convert from pybind11::array_t to SimpleArray while sharing the buffer.

#undef DECL_MM_PYBIND_CLASS_METHOD

template < typename Func >
wrapper_type & expose_SimpleArray(char const * name, Func && f)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapper helper for SimpleArray member accessors.

std::swap(self.coord(), sarr);
}
)
.expose_SimpleArray("coord", [](wrapped_type & self) -> decltype(auto) { return self.coord(); })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use decltype(auto) to make the line shorter.


OneTimeInitializer<T> & operator()(
OneTimeInitializer<T> & operator()
(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix style.

@yungyuc yungyuc merged commit fb9d9c9 into solvcon:master Dec 12, 2021
@yungyuc yungyuc deleted the refactor/simple-array branch December 12, 2021 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Change code without changing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant