From 4a1828cb84422dc060a18fb9c60a1ee87b21eb57 Mon Sep 17 00:00:00 2001 From: Hugo Ledoux Date: Mon, 3 Jun 2024 11:31:13 +0200 Subject: [PATCH] Add dtype to DT constructor --- src/lib.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 255db0e..b36ffd6 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,14 +81,22 @@ pub struct DT { #[pymethods] impl DT { /// Constructor for a DT (returns an empty DT). + /// + /// :param attributes_schema: Optional schema for attributes. + /// :type attributes_schema: Optional[PyAny] #[new] - fn new() -> Self { + #[args(attributes_schema = "None")] + fn new(attributes_schema: Option<&PyAny>) -> Self { let tmp = startin::Triangulation::new(); let tmp2 = Vec::new(); - DT { + let mut dt = DT { t: tmp, dtype: tmp2, + }; + if attributes_schema.is_some() { + let _ = dt.set_attributes_schema(&attributes_schema.unwrap()); } + dt } /// Get the points [x, y, z] of all vertices in the DT.