From 319ba361bbb0e251a29d5f787e65e95fba710b38 Mon Sep 17 00:00:00 2001 From: bpuchala Date: Wed, 8 Nov 2023 15:43:10 -0500 Subject: [PATCH 1/2] Add is_operator to allow other packages to add __rmul__ implementations --- python/src/xtal.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/python/src/xtal.cpp b/python/src/xtal.cpp index ae59a9a..90a5944 100644 --- a/python/src/xtal.cpp +++ b/python/src/xtal.cpp @@ -2104,7 +2104,8 @@ PYBIND11_MODULE(_xtal, m) { return get_matrix(op) * coordinate_cart + get_translation(op); }, py::arg("coordinate_cart"), - "Transform Cartesian coordinates, represented as a 1d array") + "Transform Cartesian coordinates, represented as a 1d array", + py::is_operator()) .def( "__mul__", [](xtal::SymOp const &op, Eigen::MatrixXd const &coordinate_cart) { @@ -2116,14 +2117,16 @@ PYBIND11_MODULE(_xtal, m) { }, py::arg("coordinate_cart"), "Transform multiple Cartesian coordinates, represented as columns of " - "a matrix.") + "a matrix.", + py::is_operator()) .def( "__mul__", [](xtal::SymOp const &lhs, xtal::SymOp const &rhs) { return lhs * rhs; }, py::arg("rhs"), - "Construct the SymOp equivalent to applying first `rhs`, then this.") + "Construct the SymOp equivalent to applying first `rhs`, then this.", + py::is_operator()) .def( "__mul__", [](xtal::SymOp const &op, @@ -2131,19 +2134,20 @@ PYBIND11_MODULE(_xtal, m) { return copy_apply(op, properties); }, py::arg("rhs"), - "Transform CASM-supported properties (local or global).") + "Transform CASM-supported properties (local or global).", + py::is_operator()) .def( "__mul__", [](xtal::SymOp const &op, xtal::Lattice const &lattice) { return sym::copy_apply(op, lattice); }, - py::arg("lattice"), "Transform a Lattice.") + py::arg("lattice"), "Transform a Lattice.", py::is_operator()) .def( "__mul__", [](xtal::SymOp const &op, xtal::SimpleStructure const &simple) { return copy_apply(op, simple); }, - py::arg("structure"), "Transform a Structure.") + py::arg("structure"), "Transform a Structure.", py::is_operator()) .def_static( "from_dict", [](const nlohmann::json &data) { @@ -3199,7 +3203,8 @@ PYBIND11_MODULE(_xtal, m) { return copy_apply(rep, integral_site_coordinate); }, py::arg("integral_site_coordinate"), - "Transform an :class:`~libcasm.xtal.IntegralSiteCoordinate`"); + "Transform an :class:`~libcasm.xtal.IntegralSiteCoordinate`", + py::is_operator()); m.def( "apply", From f956e38b84f247c8afdd0369c92a77b27336bb10 Mon Sep 17 00:00:00 2001 From: bpuchala Date: Tue, 14 Nov 2023 14:36:30 -0500 Subject: [PATCH 2/2] version 2.0a7 --- CHANGELOG.md | 7 +++++++ pyproject.toml | 2 +- python/doc/conf.py | 2 +- python/setup.py | 2 +- setup.py | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94b856b..129fbd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.0a7] - 2023-11-14 + +### Changed + +- Add py::is_operator() in the bindings of the `__mul__` operators xtal.SymOp and xtal.IntegralSiteCoordinateRep so it possible to add `__rmul__` operators to classes in other modules. + + ## [2.0a6] - 2023-11-07 ### Changed diff --git a/pyproject.toml b/pyproject.toml index d8d0ec6..b1f6183 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta" [project] name = "libcasm-xtal" -version = "2.0a6" +version = "2.0a7" authors = [ { name="CASM developers", email="casm-developers@lists.engr.ucsb.edu" }, ] diff --git a/python/doc/conf.py b/python/doc/conf.py index 828663a..b7de571 100644 --- a/python/doc/conf.py +++ b/python/doc/conf.py @@ -96,7 +96,7 @@ # The short X.Y version. version = "2.0" # The full version, including alpha/beta/rc tags. -release = "2.0a6" +release = "2.0a7" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/python/setup.py b/python/setup.py index feb5e26..8bdd9b1 100644 --- a/python/setup.py +++ b/python/setup.py @@ -1,6 +1,6 @@ import os -__version__ = "2.0a6" +__version__ = "2.0a7" # Available at setup time due to pyproject.toml from pybind11.setup_helpers import Pybind11Extension, build_ext diff --git a/setup.py b/setup.py index b514faf..c67d003 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="libcasm-xtal", - version="2.0a6", + version="2.0a7", packages=["libcasm", "libcasm.xtal"], package_dir={"": "python"}, cmake_install_dir="python/libcasm",