Skip to content

Commit d04327a

Browse files
committed
annotate for pyo3 0.28
1 parent fbeaad5 commit d04327a

File tree

7 files changed

+19
-19
lines changed

7 files changed

+19
-19
lines changed

cellular_raza-building-blocks/src/cell_building_blocks/cycle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use pyo3::prelude::*;
88

99
/// No cycle of the cell.
1010
#[derive(Clone, Debug, Serialize, Deserialize)]
11-
#[cfg_attr(feature = "pyo3", pyclass)]
11+
#[cfg_attr(feature = "pyo3", pyclass(from_py_object))]
1212
pub struct NoCycle;
1313

1414
impl<Cel, Float> Cycle<Cel, Float> for NoCycle {

cellular_raza-building-blocks/src/cell_building_blocks/interaction.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use approx::RelativeEq;
1111

1212
/// No interaction of the cell with any other.
1313
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
14-
#[cfg_attr(feature = "pyo3", pyclass)]
14+
#[cfg_attr(feature = "pyo3", pyclass(from_py_object))]
1515
pub struct NoInteraction;
1616

1717
impl<Pos, Vel, For> Interaction<Pos, Vel, For> for NoInteraction
@@ -82,7 +82,7 @@ impl InteractionInformation<()> for NoInteraction {
8282
/// [10.1098/rspa.1924.0081](https://doi.org/10.1098/rspa.1924.0081).
8383
///
8484
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
85-
#[cfg_attr(feature = "pyo3", pyclass(get_all, set_all))]
85+
#[cfg_attr(feature = "pyo3", pyclass(get_all, set_all, from_py_object))]
8686
#[cfg_attr(feature = "approx", derive(RelativeEq))]
8787
pub struct BoundLennardJones {
8888
/// Interaction strength $\epsilon$ of the potential.
@@ -96,7 +96,7 @@ pub struct BoundLennardJones {
9696
}
9797

9898
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
99-
#[cfg_attr(feature = "pyo3", pyclass(get_all, set_all))]
99+
#[cfg_attr(feature = "pyo3", pyclass(get_all, set_all, from_py_object))]
100100
#[cfg_attr(feature = "approx", derive(RelativeEq))]
101101
/// Identical to [BoundLennardJones] but for `f32` type.
102102
pub struct BoundLennardJonesF32 {
@@ -210,7 +210,7 @@ macro_rules! implement_morse_potential(
210210
/// pp. 57–64, Jul. 01, 1929.
211211
/// doi: [10.1103/physrev.34.57](https://doi.org/10.1103/PhysRev.34.57).
212212
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
213-
#[cfg_attr(feature = "pyo3", pyclass(set_all, get_all))]
213+
#[cfg_attr(feature = "pyo3", pyclass(set_all, get_all, from_py_object))]
214214
#[cfg_attr(feature = "approx", derive(RelativeEq))]
215215
pub struct $struct_name {
216216
/// Radius of the object
@@ -316,7 +316,7 @@ macro_rules! implement_mie_potential(
316316
/// G. Mie, “Zur kinetischen Theorie der einatomigen Körper,”
317317
/// Annalen der Physik, vol. 316, no. 8. Wiley, pp. 657–697, Jan. 1903.
318318
/// doi: [10.1002/andp.19033160802](https://doi.org/10.1002/andp.19033160802).
319-
#[cfg_attr(feature = "pyo3", pyclass(get_all, set_all))]
319+
#[cfg_attr(feature = "pyo3", pyclass(get_all, set_all, from_py_object))]
320320
#[cfg_attr(feature = "approx", derive(RelativeEq))]
321321
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
322322
pub struct $name {

cellular_raza-building-blocks/src/cell_building_blocks/mechanics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ macro_rules! implement_newton_damped_mechanics(
4848
/// Both operations need to be implemented by other concepts such as
4949
/// [Cycle](cellular_raza_concepts::Cycle).
5050
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
51-
#[cfg_attr(feature = "pyo3", pyclass)]
51+
#[cfg_attr(feature = "pyo3", pyclass(from_py_object))]
5252
#[cfg_attr(feature = "approx", derive(RelativeEq))]
5353
#[cfg_attr(feature = "approx", approx(epsilon_type = $float_type))]
5454
pub struct $struct_name {
@@ -247,7 +247,7 @@ macro_rules! implement_brownian_mechanics(
247247
/// If we choose this value larger than one, we can
248248
/// resolve smaller timesteps to more accurately solve the equations.
249249
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
250-
#[cfg_attr(feature = "pyo3", pyclass)]
250+
#[cfg_attr(feature = "pyo3", pyclass(from_py_object))]
251251
#[cfg_attr(feature = "approx", derive(RelativeEq))]
252252
#[cfg_attr(feature = "approx", approx(epsilon_type = $float_type))]
253253
pub struct $struct_name {
@@ -407,7 +407,7 @@ macro_rules! define_langevin_nd(
407407
/// M \ddot{\mathbf{X}} = - \mathbf{\nabla} U(\mathbf{X}) - \gamma M\dot{\mathbf{X}} + \sqrt{2 M \gamma k_{\rm B} T}\mathbf{R}(t)
408408
/// \\end{equation}
409409
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
410-
#[cfg_attr(feature = "pyo3", pyclass)]
410+
#[cfg_attr(feature = "pyo3", pyclass(from_py_object))]
411411
#[cfg_attr(feature = "approx", derive(RelativeEq))]
412412
#[cfg_attr(feature = "approx", approx(epsilon_type = $float_type))]
413413
pub struct $struct_name {

cellular_raza-building-blocks/src/cell_models/pool_bacteria.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub type ReactionVector = nalgebra::SVector<f64, NUMBER_OF_REACTION_COMPONENTS>;
2020

2121
/// Bacteria-Agent as used in the pool-model example
2222
#[derive(CellAgent, Clone, Debug, Deserialize, Serialize)]
23-
#[pyclass(get_all, set_all)]
23+
#[pyclass(get_all, set_all, from_py_object)]
2424
pub struct Bacteria {
2525
/// See [NewtonDamped2D](crate::cell_building_blocks::NewtonDamped2D) mechanics
2626
#[Mechanics]
@@ -45,7 +45,7 @@ pub struct Bacteria {
4545
/// It contains heap-allocated instances of the python classes for the individual aspects.
4646
/// This is useful when modifying said properties from python directly via dot-notation.
4747
#[derive(Clone, Debug, Deserialize, Serialize)]
48-
#[pyclass(get_all, set_all)]
48+
#[pyclass(get_all, set_all, from_py_object)]
4949
pub struct BacteriaTemplate {
5050
/// See [NewtonDamped2D](crate::cell_building_blocks::NewtonDamped2D) mechanics
5151
pub mechanics: pyo3::Py<NewtonDamped2D>,
@@ -192,7 +192,7 @@ impl Interaction<Vector2<f64>, Vector2<f64>, Vector2<f64>, f64> for BacteriaReac
192192

193193
/// Implementation of the [cellular_raza_concepts::Cycle] trait for the [Bacteria] struct
194194
#[derive(Serialize, Deserialize, Debug, Clone)]
195-
#[pyclass(get_all, set_all)]
195+
#[pyclass(get_all, set_all, from_py_object)]
196196
pub struct BacteriaCycle {
197197
/// Threshold for the volume when the cell should divide
198198
pub volume_division_threshold: f64,
@@ -294,7 +294,7 @@ impl Cycle<Bacteria> for BacteriaCycle {
294294

295295
/// Species of the cells (S1, S2)
296296
#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
297-
#[pyclass(eq, eq_int)]
297+
#[pyclass(eq, eq_int, from_py_object)]
298298
pub enum Species {
299299
/// Species 1
300300
S1,
@@ -305,7 +305,7 @@ pub enum Species {
305305
/// Implementation of the [cellular_raza_concepts::CellularReactions] trait and
306306
/// [cellular_raza_concepts::Interaction] trait for [Bacteria].
307307
#[derive(Serialize, Deserialize, Clone, Debug)]
308-
#[pyclass(get_all, set_all)]
308+
#[pyclass(get_all, set_all, from_py_object)]
309309
pub struct BacteriaReactions {
310310
/// Overall interaction strength for physical interaction
311311
pub potential_strength: f64,
@@ -431,7 +431,7 @@ impl Volume for Bacteria {
431431

432432
/// This struct does nothing
433433
#[derive(Clone, Debug, Serialize, Deserialize)]
434-
#[pyclass]
434+
#[pyclass(from_py_object)]
435435
pub struct GradientSensing;
436436

437437
impl

cellular_raza-concepts/src/cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use serde::{Deserialize, Serialize};
1313
/// This can be due to initial setup or due to other methods such as division in a cell cycle.
1414
/// The second parameter is a counter which is unique for each voxel.
1515
/// This ensures that each cell obtains a unique identifier over the course of the simulation.
16-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
16+
#[cfg_attr(feature = "pyo3", pyo3::pyclass(from_py_object))]
1717
#[derive(Clone, Copy, Debug, Deserialize, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize)]
1818
pub enum CellIdentifier {
1919
/// Produced from a division process

cellular_raza-concepts/src/domain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::{BTreeMap, BTreeSet};
44
use crate::errors::{BoundaryError, DecomposeError};
55

66
/// Identifier for voxels used internally to get rid of user-defined ones.
7-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
7+
#[cfg_attr(feature = "pyo3", pyo3::pyclass(from_py_object))]
88
#[derive(Clone, Copy, Debug, Deserialize, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize)]
99
pub struct VoxelPlainIndex(pub usize);
1010

@@ -28,7 +28,7 @@ impl VoxelPlainIndex {
2828

2929
/// Identifier or subdomains
3030
#[derive(Clone, Copy, Debug, Deserialize, Hash, PartialEq, Eq, Ord, PartialOrd, Serialize)]
31-
#[cfg_attr(feature = "pyo3", pyo3::pyclass)]
31+
#[cfg_attr(feature = "pyo3", pyo3::pyclass(from_py_object))]
3232
pub struct SubDomainPlainIndex(pub usize);
3333

3434
/// Provides an abstraction of the physical total simulation domain.

cellular_raza-core/src/storage/concepts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl Error for StorageError {}
124124
///
125125
/// We currently support saving results in a [sled] database, or as a json file by using
126126
/// [serde_json].
127-
#[cfg_attr(feature = "pyo3", pyo3::pyclass(eq, eq_int))]
127+
#[cfg_attr(feature = "pyo3", pyo3::pyclass(eq, eq_int, from_py_object))]
128128
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize)]
129129
pub enum StorageOption {
130130
/// Save results as [sled] database.

0 commit comments

Comments
 (0)