Skip to content

Commit

Permalink
feat: implement more operands
Browse files Browse the repository at this point in the history
  • Loading branch information
JabobKrauskopf committed Oct 10, 2024
1 parent 15ef86d commit 439eef5
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 3 deletions.
36 changes: 35 additions & 1 deletion rustmodels/src/medrecord/querying/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use medmodels_core::medrecord::{AttributesTreeOperand, Wrapper};
use medmodels_core::medrecord::{
AttributesTreeOperand, MultipleAttributesOperand, SingleAttributeOperand, Wrapper,
};
use pyo3::pyclass;

#[pyclass]
Expand All @@ -16,3 +18,35 @@ impl From<PyAttributesTreeOperand> for Wrapper<AttributesTreeOperand> {
operand.0
}
}

#[pyclass]
#[repr(transparent)]
pub struct PyMultipleAttributesOperand(Wrapper<MultipleAttributesOperand>);

impl From<Wrapper<MultipleAttributesOperand>> for PyMultipleAttributesOperand {
fn from(operand: Wrapper<MultipleAttributesOperand>) -> Self {
Self(operand)
}
}

impl From<PyMultipleAttributesOperand> for Wrapper<MultipleAttributesOperand> {
fn from(operand: PyMultipleAttributesOperand) -> Self {
operand.0
}
}

#[pyclass]
#[repr(transparent)]
pub struct PySingleAttributeOperand(Wrapper<SingleAttributeOperand>);

impl From<Wrapper<SingleAttributeOperand>> for PySingleAttributeOperand {
fn from(operand: Wrapper<SingleAttributeOperand>) -> Self {
Self(operand)
}
}

impl From<PySingleAttributeOperand> for Wrapper<SingleAttributeOperand> {
fn from(operand: PySingleAttributeOperand) -> Self {
operand.0
}
}
47 changes: 46 additions & 1 deletion rustmodels/src/medrecord/querying/nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use super::{
PyGroupCardinalityWrapper, PyMedRecordAttributeCardinalityWrapper,
};
use crate::medrecord::attribute::PyMedRecordAttribute;
use medmodels_core::medrecord::{EdgeDirection, NodeIndicesOperand, NodeOperand, Wrapper};
use medmodels_core::medrecord::{
EdgeDirection, NodeIndexOperand, NodeIndicesOperand, NodeOperand, Wrapper,
};
use pyo3::{
pyclass, pymethods,
types::{PyAnyMethods, PyFunction},
Expand Down Expand Up @@ -118,3 +120,46 @@ impl From<PyNodeIndicesOperand> for Wrapper<NodeIndicesOperand> {
operand.0
}
}

#[pymethods]
impl PyNodeIndicesOperand {
pub fn max(&mut self) -> PyNodeIndexOperand {
self.0.max().into()
}

pub fn min(&mut self) -> PyNodeIndexOperand {
self.0.min().into()
}

pub fn count(&mut self) -> PyNodeIndexOperand {
self.0.count().into()
}

pub fn sum(&mut self) -> PyNodeIndexOperand {
self.0.sum().into()
}

pub fn first(&mut self) -> PyNodeIndexOperand {
self.0.first().into()
}

pub fn last(&mut self) -> PyNodeIndexOperand {
self.0.last().into()
}
}

#[pyclass]
#[repr(transparent)]
pub struct PyNodeIndexOperand(Wrapper<NodeIndexOperand>);

impl From<Wrapper<NodeIndexOperand>> for PyNodeIndexOperand {
fn from(operand: Wrapper<NodeIndexOperand>) -> Self {
Self(operand)
}
}

impl From<PyNodeIndexOperand> for Wrapper<NodeIndexOperand> {
fn from(operand: PyNodeIndexOperand) -> Self {
operand.0
}
}
18 changes: 17 additions & 1 deletion rustmodels/src/medrecord/querying/values.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use medmodels_core::medrecord::{MultipleValuesOperand, Wrapper};
use medmodels_core::medrecord::{MultipleValuesOperand, SingleValueOperand, Wrapper};
use pyo3::pyclass;

#[pyclass]
Expand All @@ -16,3 +16,19 @@ impl From<PyMultipleValuesOperand> for Wrapper<MultipleValuesOperand> {
operand.0
}
}

#[pyclass]
#[repr(transparent)]
pub struct PySingleValueOperand(Wrapper<SingleValueOperand>);

impl From<Wrapper<SingleValueOperand>> for PySingleValueOperand {
fn from(operand: Wrapper<SingleValueOperand>) -> Self {
Self(operand)
}
}

impl From<PySingleValueOperand> for Wrapper<SingleValueOperand> {
fn from(operand: PySingleValueOperand) -> Self {
operand.0
}
}

0 comments on commit 439eef5

Please sign in to comment.