Skip to main content

graphrecords_python/graphrecord/
plugins.rs

1use crate::{
2    graphrecord::traits::DeepInto,
3    prelude::{PyAttributes, PyGraphRecord, PyGroup, PyNodeIndex, PySchema},
4};
5use graphrecords_core::{
6    errors::{GraphRecordError, GraphRecordResult},
7    graphrecord::{
8        EdgeDataFrameInput, EdgeIndex, GraphRecord, NodeDataFrameInput,
9        plugins::{
10            Plugin, PostAddEdgeContext, PostAddEdgeToGroupContext, PostAddEdgeToGroupsContext,
11            PostAddEdgeWithGroupContext, PostAddEdgeWithGroupsContext, PostAddEdgesContext,
12            PostAddEdgesDataframesContext, PostAddEdgesDataframesWithGroupContext,
13            PostAddEdgesDataframesWithGroupsContext, PostAddEdgesToGroupsContext,
14            PostAddEdgesWithGroupContext, PostAddEdgesWithGroupsContext, PostAddGroupContext,
15            PostAddNodeContext, PostAddNodeToGroupContext, PostAddNodeToGroupsContext,
16            PostAddNodeWithGroupContext, PostAddNodeWithGroupsContext, PostAddNodesContext,
17            PostAddNodesDataframesContext, PostAddNodesDataframesWithGroupContext,
18            PostAddNodesDataframesWithGroupsContext, PostAddNodesToGroupsContext,
19            PostAddNodesWithGroupContext, PostAddNodesWithGroupsContext, PostRemoveEdgeContext,
20            PostRemoveEdgeFromGroupContext, PostRemoveEdgeFromGroupsContext,
21            PostRemoveEdgesFromGroupsContext, PostRemoveGroupContext, PostRemoveNodeContext,
22            PostRemoveNodeFromGroupContext, PostRemoveNodeFromGroupsContext,
23            PostRemoveNodesFromGroupsContext, PreAddEdgeContext, PreAddEdgeToGroupContext,
24            PreAddEdgeToGroupsContext, PreAddEdgeWithGroupContext, PreAddEdgeWithGroupsContext,
25            PreAddEdgesContext, PreAddEdgesDataframesContext,
26            PreAddEdgesDataframesWithGroupContext, PreAddEdgesDataframesWithGroupsContext,
27            PreAddEdgesToGroupsContext, PreAddEdgesWithGroupContext, PreAddEdgesWithGroupsContext,
28            PreAddGroupContext, PreAddNodeContext, PreAddNodeToGroupContext,
29            PreAddNodeToGroupsContext, PreAddNodeWithGroupContext, PreAddNodeWithGroupsContext,
30            PreAddNodesContext, PreAddNodesDataframesContext,
31            PreAddNodesDataframesWithGroupContext, PreAddNodesDataframesWithGroupsContext,
32            PreAddNodesToGroupsContext, PreAddNodesWithGroupContext, PreAddNodesWithGroupsContext,
33            PreRemoveEdgeContext, PreRemoveEdgeFromGroupContext, PreRemoveEdgeFromGroupsContext,
34            PreRemoveEdgesFromGroupsContext, PreRemoveGroupContext, PreRemoveNodeContext,
35            PreRemoveNodeFromGroupContext, PreRemoveNodeFromGroupsContext,
36            PreRemoveNodesFromGroupsContext, PreSetSchemaContext,
37        },
38    },
39};
40use pyo3::{IntoPyObjectExt, Py, PyAny, Python, pyclass, pymethods, types::PyAnyMethods};
41use pyo3_polars::PyDataFrame;
42use serde::{Deserialize, Deserializer, Serialize, Serializer};
43
44macro_rules! impl_pre_hook {
45    ($method:ident, $py_context_type:ident, $core_context_type:ident) => {
46        fn $method(
47            &self,
48            graphrecord: &mut GraphRecord,
49            context: $core_context_type,
50        ) -> GraphRecordResult<$core_context_type> {
51            Python::attach(|py| {
52                PyGraphRecord::scope_mut(py, graphrecord, |py, graphrecord| {
53                    let py_context = $py_context_type::bind(py, context);
54
55                    let result = self
56                        .0
57                        .call_method1(py, stringify!($method), (graphrecord, py_context))
58                        .map_err(|err| GraphRecordError::PluginFailure {
59                            message: err.to_string(),
60                        })?;
61
62                    Ok(result
63                        .extract::<$py_context_type>(py)
64                        .map_err(|err| GraphRecordError::PluginFailure {
65                            message: err.to_string(),
66                        })?
67                        .extract(py))
68                })
69            })
70        }
71    };
72}
73
74macro_rules! impl_post_hook {
75    ($method:ident) => {
76        fn $method(&self, graphrecord: &mut GraphRecord) -> GraphRecordResult<()> {
77            Python::attach(|py| {
78                PyGraphRecord::scope_mut(py, graphrecord, |py, graphrecord| {
79                    self.0
80                        .call_method1(py, stringify!($method), (graphrecord,))
81                        .map_err(|err| GraphRecordError::PluginFailure {
82                            message: err.to_string(),
83                        })?;
84
85                    Ok(())
86                })
87            })
88        }
89    };
90    ($method:ident, $py_context_type:ident, $core_context_type:ident) => {
91        fn $method(
92            &self,
93            graphrecord: &mut GraphRecord,
94            context: $core_context_type,
95        ) -> GraphRecordResult<()> {
96            Python::attach(|py| {
97                PyGraphRecord::scope_mut(py, graphrecord, |py, graphrecord| {
98                    let py_context = $py_context_type::bind(py, context);
99
100                    self.0
101                        .call_method1(py, stringify!($method), (graphrecord, py_context))
102                        .map_err(|err| GraphRecordError::PluginFailure {
103                            message: err.to_string(),
104                        })?;
105
106                    Ok(())
107                })
108            })
109        }
110    };
111}
112
113#[derive(Debug)]
114pub struct PyPlugin(Py<PyAny>);
115
116impl Serialize for PyPlugin {
117    fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
118        Python::attach(|py| {
119            let cloudpickle = py
120                .import("cloudpickle")
121                .map_err(serde::ser::Error::custom)?;
122
123            let bytes: Vec<u8> = cloudpickle
124                .call_method1("dumps", (&self.0,))
125                .map_err(serde::ser::Error::custom)?
126                .extract()
127                .map_err(serde::ser::Error::custom)?;
128
129            serializer.serialize_bytes(&bytes)
130        })
131    }
132}
133
134impl<'de> Deserialize<'de> for PyPlugin {
135    fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
136        let bytes: Vec<u8> = Deserialize::deserialize(deserializer)?;
137
138        Python::attach(|py| {
139            let cloudpickle = py.import("cloudpickle").map_err(serde::de::Error::custom)?;
140
141            let obj: Py<PyAny> = cloudpickle
142                .call_method1("loads", (bytes.as_slice(),))
143                .map_err(serde::de::Error::custom)?
144                .into();
145
146            Ok(Self(obj))
147        })
148    }
149}
150
151impl PyPlugin {
152    pub const fn new(py_obj: Py<PyAny>) -> Self {
153        Self(py_obj)
154    }
155}
156
157fn node_dataframe_inputs_to_py(inputs: Vec<NodeDataFrameInput>) -> Vec<(PyDataFrame, String)> {
158    inputs
159        .into_iter()
160        .map(|input| (PyDataFrame(input.dataframe), input.index_column))
161        .collect()
162}
163
164fn py_to_node_dataframe_inputs(inputs: Vec<(PyDataFrame, String)>) -> Vec<NodeDataFrameInput> {
165    inputs
166        .into_iter()
167        .map(|(dataframe, index_column)| NodeDataFrameInput {
168            dataframe: dataframe.0,
169            index_column,
170        })
171        .collect()
172}
173
174fn edge_dataframe_inputs_to_py(
175    inputs: Vec<EdgeDataFrameInput>,
176) -> Vec<(PyDataFrame, String, String)> {
177    inputs
178        .into_iter()
179        .map(|input| {
180            (
181                PyDataFrame(input.dataframe),
182                input.source_index_column,
183                input.target_index_column,
184            )
185        })
186        .collect()
187}
188
189fn py_to_edge_dataframe_inputs(
190    inputs: Vec<(PyDataFrame, String, String)>,
191) -> Vec<EdgeDataFrameInput> {
192    inputs
193        .into_iter()
194        .map(
195            |(dataframe, source_index_column, target_index_column)| EdgeDataFrameInput {
196                dataframe: dataframe.0,
197                source_index_column,
198                target_index_column,
199            },
200        )
201        .collect()
202}
203
204#[pyclass(frozen)]
205#[derive(Debug)]
206pub struct PyPreSetSchemaContext {
207    schema: Py<PySchema>,
208}
209
210impl Clone for PyPreSetSchemaContext {
211    fn clone(&self) -> Self {
212        Python::attach(|py| Self {
213            schema: self.schema.clone_ref(py),
214        })
215    }
216}
217
218impl PyPreSetSchemaContext {
219    /// # Panics
220    ///
221    /// Panics if the python typing was not followed.
222    pub fn bind(py: Python<'_>, context: PreSetSchemaContext) -> Self {
223        Self {
224            schema: Py::new(py, PySchema::from(context.schema))
225                .expect("PySchema should be creatable"),
226        }
227    }
228
229    /// # Panics
230    ///
231    /// Panics if the python typing was not followed.
232    pub fn extract(self, py: Python<'_>) -> PreSetSchemaContext {
233        let py_schema: PySchema = self
234            .schema
235            .extract(py)
236            .expect("PySchema should be extractable");
237
238        PreSetSchemaContext {
239            schema: py_schema.into(),
240        }
241    }
242}
243
244#[pymethods]
245impl PyPreSetSchemaContext {
246    #[new]
247    pub const fn new(schema: Py<PySchema>) -> Self {
248        Self { schema }
249    }
250
251    #[getter]
252    pub fn schema(&self, py: Python<'_>) -> Py<PySchema> {
253        self.schema.clone_ref(py)
254    }
255}
256
257#[pyclass(frozen)]
258#[derive(Debug)]
259pub struct PyPreAddNodeContext {
260    node_index: Py<PyAny>,
261    attributes: Py<PyAny>,
262}
263
264impl Clone for PyPreAddNodeContext {
265    fn clone(&self) -> Self {
266        Python::attach(|py| Self {
267            node_index: self.node_index.clone_ref(py),
268            attributes: self.attributes.clone_ref(py),
269        })
270    }
271}
272
273impl PyPreAddNodeContext {
274    /// # Panics
275    ///
276    /// Panics if the python typing was not followed.
277    pub fn bind(py: Python<'_>, context: PreAddNodeContext) -> Self {
278        Self {
279            node_index: PyNodeIndex::from(context.node_index)
280                .into_py_any(py)
281                .expect("PyNodeIndex should be creatable"),
282            attributes: {
283                let py_attrs: PyAttributes = context.attributes.deep_into();
284                py_attrs
285                    .into_py_any(py)
286                    .expect("PyAttributes should be creatable")
287            },
288        }
289    }
290
291    /// # Panics
292    ///
293    /// Panics if the python typing was not followed.
294    pub fn extract(self, py: Python<'_>) -> PreAddNodeContext {
295        let node_index: PyNodeIndex = self
296            .node_index
297            .extract(py)
298            .expect("PyNodeIndex should be extractable");
299
300        let attributes: PyAttributes = self
301            .attributes
302            .extract(py)
303            .expect("PyAttributes should be extractable");
304
305        PreAddNodeContext {
306            node_index: node_index.into(),
307            attributes: attributes.deep_into(),
308        }
309    }
310}
311
312#[pymethods]
313impl PyPreAddNodeContext {
314    #[new]
315    pub const fn new(node_index: Py<PyAny>, attributes: Py<PyAny>) -> Self {
316        Self {
317            node_index,
318            attributes,
319        }
320    }
321
322    #[getter]
323    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
324        self.node_index.clone_ref(py)
325    }
326
327    #[getter]
328    pub fn attributes(&self, py: Python<'_>) -> Py<PyAny> {
329        self.attributes.clone_ref(py)
330    }
331}
332
333#[pyclass(frozen)]
334#[derive(Debug)]
335pub struct PyPostAddNodeContext {
336    node_index: Py<PyAny>,
337}
338
339impl Clone for PyPostAddNodeContext {
340    fn clone(&self) -> Self {
341        Python::attach(|py| Self {
342            node_index: self.node_index.clone_ref(py),
343        })
344    }
345}
346
347impl PyPostAddNodeContext {
348    /// # Panics
349    ///
350    /// Panics if the python typing was not followed.
351    pub fn bind(py: Python<'_>, context: PostAddNodeContext) -> Self {
352        Self {
353            node_index: PyNodeIndex::from(context.node_index)
354                .into_py_any(py)
355                .expect("PyNodeIndex should be creatable"),
356        }
357    }
358}
359
360#[pymethods]
361impl PyPostAddNodeContext {
362    #[new]
363    pub const fn new(node_index: Py<PyAny>) -> Self {
364        Self { node_index }
365    }
366
367    #[getter]
368    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
369        self.node_index.clone_ref(py)
370    }
371}
372
373#[pyclass(frozen)]
374#[derive(Debug)]
375pub struct PyPreAddNodeWithGroupContext {
376    node_index: Py<PyAny>,
377    attributes: Py<PyAny>,
378    group: Py<PyAny>,
379}
380
381impl Clone for PyPreAddNodeWithGroupContext {
382    fn clone(&self) -> Self {
383        Python::attach(|py| Self {
384            node_index: self.node_index.clone_ref(py),
385            attributes: self.attributes.clone_ref(py),
386            group: self.group.clone_ref(py),
387        })
388    }
389}
390
391impl PyPreAddNodeWithGroupContext {
392    /// # Panics
393    ///
394    /// Panics if the python typing was not followed.
395    pub fn bind(py: Python<'_>, context: PreAddNodeWithGroupContext) -> Self {
396        Self {
397            node_index: PyNodeIndex::from(context.node_index)
398                .into_py_any(py)
399                .expect("PyNodeIndex should be creatable"),
400            attributes: {
401                let py_attrs: PyAttributes = context.attributes.deep_into();
402                py_attrs
403                    .into_py_any(py)
404                    .expect("PyAttributes should be creatable")
405            },
406            group: PyGroup::from(context.group)
407                .into_py_any(py)
408                .expect("PyGroup should be creatable"),
409        }
410    }
411
412    /// # Panics
413    ///
414    /// Panics if the python typing was not followed.
415    pub fn extract(self, py: Python<'_>) -> PreAddNodeWithGroupContext {
416        let node_index: PyNodeIndex = self
417            .node_index
418            .extract(py)
419            .expect("PyNodeIndex should be extractable");
420
421        let attributes: PyAttributes = self
422            .attributes
423            .extract(py)
424            .expect("PyAttributes should be extractable");
425
426        let group: PyGroup = self
427            .group
428            .extract(py)
429            .expect("PyGroup should be extractable");
430
431        PreAddNodeWithGroupContext {
432            node_index: node_index.into(),
433            attributes: attributes.deep_into(),
434            group: group.into(),
435        }
436    }
437}
438
439#[pymethods]
440impl PyPreAddNodeWithGroupContext {
441    #[new]
442    pub const fn new(node_index: Py<PyAny>, attributes: Py<PyAny>, group: Py<PyAny>) -> Self {
443        Self {
444            node_index,
445            attributes,
446            group,
447        }
448    }
449
450    #[getter]
451    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
452        self.node_index.clone_ref(py)
453    }
454
455    #[getter]
456    pub fn attributes(&self, py: Python<'_>) -> Py<PyAny> {
457        self.attributes.clone_ref(py)
458    }
459
460    #[getter]
461    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
462        self.group.clone_ref(py)
463    }
464}
465
466#[pyclass(frozen)]
467#[derive(Debug)]
468pub struct PyPostAddNodeWithGroupContext {
469    node_index: Py<PyAny>,
470    group: Py<PyAny>,
471}
472
473impl Clone for PyPostAddNodeWithGroupContext {
474    fn clone(&self) -> Self {
475        Python::attach(|py| Self {
476            node_index: self.node_index.clone_ref(py),
477            group: self.group.clone_ref(py),
478        })
479    }
480}
481
482impl PyPostAddNodeWithGroupContext {
483    /// # Panics
484    ///
485    /// Panics if the python typing was not followed.
486    pub fn bind(py: Python<'_>, context: PostAddNodeWithGroupContext) -> Self {
487        Self {
488            node_index: PyNodeIndex::from(context.node_index)
489                .into_py_any(py)
490                .expect("PyNodeIndex should be creatable"),
491            group: PyGroup::from(context.group)
492                .into_py_any(py)
493                .expect("PyGroup should be creatable"),
494        }
495    }
496}
497
498#[pymethods]
499impl PyPostAddNodeWithGroupContext {
500    #[new]
501    pub const fn new(node_index: Py<PyAny>, group: Py<PyAny>) -> Self {
502        Self { node_index, group }
503    }
504
505    #[getter]
506    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
507        self.node_index.clone_ref(py)
508    }
509
510    #[getter]
511    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
512        self.group.clone_ref(py)
513    }
514}
515
516#[pyclass(frozen)]
517#[derive(Debug)]
518pub struct PyPreAddNodeWithGroupsContext {
519    node_index: Py<PyAny>,
520    attributes: Py<PyAny>,
521    groups: Py<PyAny>,
522}
523
524impl Clone for PyPreAddNodeWithGroupsContext {
525    fn clone(&self) -> Self {
526        Python::attach(|py| Self {
527            node_index: self.node_index.clone_ref(py),
528            attributes: self.attributes.clone_ref(py),
529            groups: self.groups.clone_ref(py),
530        })
531    }
532}
533
534impl PyPreAddNodeWithGroupsContext {
535    /// # Panics
536    ///
537    /// Panics if the python typing was not followed.
538    pub fn bind(py: Python<'_>, context: PreAddNodeWithGroupsContext) -> Self {
539        let groups: Vec<PyGroup> = context.groups.deep_into();
540
541        Self {
542            node_index: PyNodeIndex::from(context.node_index)
543                .into_py_any(py)
544                .expect("PyNodeIndex should be creatable"),
545            attributes: {
546                let py_attrs: PyAttributes = context.attributes.deep_into();
547                py_attrs
548                    .into_py_any(py)
549                    .expect("PyAttributes should be creatable")
550            },
551            groups: groups.into_py_any(py).expect("groups should be creatable"),
552        }
553    }
554
555    /// # Panics
556    ///
557    /// Panics if the python typing was not followed.
558    pub fn extract(self, py: Python<'_>) -> PreAddNodeWithGroupsContext {
559        let node_index: PyNodeIndex = self
560            .node_index
561            .extract(py)
562            .expect("PyNodeIndex should be extractable");
563
564        let attributes: PyAttributes = self
565            .attributes
566            .extract(py)
567            .expect("PyAttributes should be extractable");
568
569        let groups: Vec<PyGroup> = self
570            .groups
571            .extract(py)
572            .expect("groups should be extractable");
573
574        PreAddNodeWithGroupsContext {
575            node_index: node_index.into(),
576            attributes: attributes.deep_into(),
577            groups: groups.deep_into(),
578        }
579    }
580}
581
582#[pymethods]
583impl PyPreAddNodeWithGroupsContext {
584    #[new]
585    pub const fn new(node_index: Py<PyAny>, attributes: Py<PyAny>, groups: Py<PyAny>) -> Self {
586        Self {
587            node_index,
588            attributes,
589            groups,
590        }
591    }
592
593    #[getter]
594    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
595        self.node_index.clone_ref(py)
596    }
597
598    #[getter]
599    pub fn attributes(&self, py: Python<'_>) -> Py<PyAny> {
600        self.attributes.clone_ref(py)
601    }
602
603    #[getter]
604    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
605        self.groups.clone_ref(py)
606    }
607}
608
609#[pyclass(frozen)]
610#[derive(Debug)]
611pub struct PyPostAddNodeWithGroupsContext {
612    node_index: Py<PyAny>,
613    groups: Py<PyAny>,
614}
615
616impl Clone for PyPostAddNodeWithGroupsContext {
617    fn clone(&self) -> Self {
618        Python::attach(|py| Self {
619            node_index: self.node_index.clone_ref(py),
620            groups: self.groups.clone_ref(py),
621        })
622    }
623}
624
625impl PyPostAddNodeWithGroupsContext {
626    /// # Panics
627    ///
628    /// Panics if the python typing was not followed.
629    pub fn bind(py: Python<'_>, context: PostAddNodeWithGroupsContext) -> Self {
630        let groups: Vec<PyGroup> = context.groups.deep_into();
631
632        Self {
633            node_index: PyNodeIndex::from(context.node_index)
634                .into_py_any(py)
635                .expect("PyNodeIndex should be creatable"),
636            groups: groups.into_py_any(py).expect("groups should be creatable"),
637        }
638    }
639}
640
641#[pymethods]
642impl PyPostAddNodeWithGroupsContext {
643    #[new]
644    pub const fn new(node_index: Py<PyAny>, groups: Py<PyAny>) -> Self {
645        Self { node_index, groups }
646    }
647
648    #[getter]
649    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
650        self.node_index.clone_ref(py)
651    }
652
653    #[getter]
654    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
655        self.groups.clone_ref(py)
656    }
657}
658
659#[pyclass(frozen)]
660#[derive(Debug)]
661pub struct PyPreRemoveNodeContext {
662    node_index: Py<PyAny>,
663}
664
665impl Clone for PyPreRemoveNodeContext {
666    fn clone(&self) -> Self {
667        Python::attach(|py| Self {
668            node_index: self.node_index.clone_ref(py),
669        })
670    }
671}
672
673impl PyPreRemoveNodeContext {
674    /// # Panics
675    ///
676    /// Panics if the python typing was not followed.
677    pub fn bind(py: Python<'_>, context: PreRemoveNodeContext) -> Self {
678        Self {
679            node_index: PyNodeIndex::from(context.node_index)
680                .into_py_any(py)
681                .expect("PyNodeIndex should be creatable"),
682        }
683    }
684
685    /// # Panics
686    ///
687    /// Panics if the python typing was not followed.
688    pub fn extract(self, py: Python<'_>) -> PreRemoveNodeContext {
689        let py_node_index: PyNodeIndex = self
690            .node_index
691            .extract(py)
692            .expect("PyNodeIndex should be extractable");
693
694        PreRemoveNodeContext {
695            node_index: py_node_index.into(),
696        }
697    }
698}
699
700#[pymethods]
701impl PyPreRemoveNodeContext {
702    #[new]
703    pub const fn new(node_index: Py<PyAny>) -> Self {
704        Self { node_index }
705    }
706
707    #[getter]
708    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
709        self.node_index.clone_ref(py)
710    }
711}
712
713#[pyclass(frozen)]
714#[derive(Debug)]
715pub struct PyPostRemoveNodeContext {
716    node_index: Py<PyAny>,
717}
718
719impl Clone for PyPostRemoveNodeContext {
720    fn clone(&self) -> Self {
721        Python::attach(|py| Self {
722            node_index: self.node_index.clone_ref(py),
723        })
724    }
725}
726
727impl PyPostRemoveNodeContext {
728    /// # Panics
729    ///
730    /// Panics if the python typing was not followed.
731    pub fn bind(py: Python<'_>, context: PostRemoveNodeContext) -> Self {
732        Self {
733            node_index: PyNodeIndex::from(context.node_index)
734                .into_py_any(py)
735                .expect("PyNodeIndex should be creatable"),
736        }
737    }
738}
739
740#[pymethods]
741impl PyPostRemoveNodeContext {
742    #[new]
743    pub const fn new(node_index: Py<PyAny>) -> Self {
744        Self { node_index }
745    }
746
747    #[getter]
748    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
749        self.node_index.clone_ref(py)
750    }
751}
752
753#[pyclass(frozen)]
754#[derive(Debug)]
755pub struct PyPreAddNodesContext {
756    nodes: Py<PyAny>,
757}
758
759impl Clone for PyPreAddNodesContext {
760    fn clone(&self) -> Self {
761        Python::attach(|py| Self {
762            nodes: self.nodes.clone_ref(py),
763        })
764    }
765}
766
767impl PyPreAddNodesContext {
768    /// # Panics
769    ///
770    /// Panics if the python typing was not followed.
771    pub fn bind(py: Python<'_>, context: PreAddNodesContext) -> Self {
772        let nodes: Vec<(PyNodeIndex, PyAttributes)> = context.nodes.deep_into();
773
774        Self {
775            nodes: nodes.into_py_any(py).expect("nodes should be creatable"),
776        }
777    }
778
779    /// # Panics
780    ///
781    /// Panics if the python typing was not followed.
782    pub fn extract(self, py: Python<'_>) -> PreAddNodesContext {
783        let nodes: Vec<(PyNodeIndex, PyAttributes)> =
784            self.nodes.extract(py).expect("nodes should be extractable");
785
786        PreAddNodesContext {
787            nodes: nodes.deep_into(),
788        }
789    }
790}
791
792#[pymethods]
793impl PyPreAddNodesContext {
794    #[new]
795    pub const fn new(nodes: Py<PyAny>) -> Self {
796        Self { nodes }
797    }
798
799    #[getter]
800    pub fn nodes(&self, py: Python<'_>) -> Py<PyAny> {
801        self.nodes.clone_ref(py)
802    }
803}
804
805#[pyclass(frozen)]
806#[derive(Debug)]
807pub struct PyPostAddNodesContext {
808    nodes: Py<PyAny>,
809}
810
811impl Clone for PyPostAddNodesContext {
812    fn clone(&self) -> Self {
813        Python::attach(|py| Self {
814            nodes: self.nodes.clone_ref(py),
815        })
816    }
817}
818
819impl PyPostAddNodesContext {
820    /// # Panics
821    ///
822    /// Panics if the python typing was not followed.
823    pub fn bind(py: Python<'_>, context: PostAddNodesContext) -> Self {
824        let nodes: Vec<(PyNodeIndex, PyAttributes)> = context.nodes.deep_into();
825
826        Self {
827            nodes: nodes.into_py_any(py).expect("nodes should be creatable"),
828        }
829    }
830}
831
832#[pymethods]
833impl PyPostAddNodesContext {
834    #[new]
835    pub const fn new(nodes: Py<PyAny>) -> Self {
836        Self { nodes }
837    }
838
839    #[getter]
840    pub fn nodes(&self, py: Python<'_>) -> Py<PyAny> {
841        self.nodes.clone_ref(py)
842    }
843}
844
845#[pyclass(frozen)]
846#[derive(Debug)]
847pub struct PyPreAddNodesWithGroupContext {
848    nodes: Py<PyAny>,
849    group: Py<PyAny>,
850}
851
852impl Clone for PyPreAddNodesWithGroupContext {
853    fn clone(&self) -> Self {
854        Python::attach(|py| Self {
855            nodes: self.nodes.clone_ref(py),
856            group: self.group.clone_ref(py),
857        })
858    }
859}
860
861impl PyPreAddNodesWithGroupContext {
862    /// # Panics
863    ///
864    /// Panics if the python typing was not followed.
865    pub fn bind(py: Python<'_>, context: PreAddNodesWithGroupContext) -> Self {
866        let nodes: Vec<(PyNodeIndex, PyAttributes)> = context.nodes.deep_into();
867
868        Self {
869            nodes: nodes.into_py_any(py).expect("nodes should be creatable"),
870            group: PyGroup::from(context.group)
871                .into_py_any(py)
872                .expect("PyGroup should be creatable"),
873        }
874    }
875
876    /// # Panics
877    ///
878    /// Panics if the python typing was not followed.
879    pub fn extract(self, py: Python<'_>) -> PreAddNodesWithGroupContext {
880        let nodes: Vec<(PyNodeIndex, PyAttributes)> =
881            self.nodes.extract(py).expect("nodes should be extractable");
882
883        let group: PyGroup = self
884            .group
885            .extract(py)
886            .expect("PyGroup should be extractable");
887
888        PreAddNodesWithGroupContext {
889            nodes: nodes.deep_into(),
890            group: group.into(),
891        }
892    }
893}
894
895#[pymethods]
896impl PyPreAddNodesWithGroupContext {
897    #[new]
898    pub const fn new(nodes: Py<PyAny>, group: Py<PyAny>) -> Self {
899        Self { nodes, group }
900    }
901
902    #[getter]
903    pub fn nodes(&self, py: Python<'_>) -> Py<PyAny> {
904        self.nodes.clone_ref(py)
905    }
906
907    #[getter]
908    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
909        self.group.clone_ref(py)
910    }
911}
912
913#[pyclass(frozen)]
914#[derive(Debug)]
915pub struct PyPostAddNodesWithGroupContext {
916    nodes: Py<PyAny>,
917    group: Py<PyAny>,
918}
919
920impl Clone for PyPostAddNodesWithGroupContext {
921    fn clone(&self) -> Self {
922        Python::attach(|py| Self {
923            nodes: self.nodes.clone_ref(py),
924            group: self.group.clone_ref(py),
925        })
926    }
927}
928
929impl PyPostAddNodesWithGroupContext {
930    /// # Panics
931    ///
932    /// Panics if the python typing was not followed.
933    pub fn bind(py: Python<'_>, context: PostAddNodesWithGroupContext) -> Self {
934        let nodes: Vec<(PyNodeIndex, PyAttributes)> = context.nodes.deep_into();
935
936        Self {
937            nodes: nodes.into_py_any(py).expect("nodes should be creatable"),
938            group: PyGroup::from(context.group)
939                .into_py_any(py)
940                .expect("PyGroup should be creatable"),
941        }
942    }
943}
944
945#[pymethods]
946impl PyPostAddNodesWithGroupContext {
947    #[new]
948    pub const fn new(nodes: Py<PyAny>, group: Py<PyAny>) -> Self {
949        Self { nodes, group }
950    }
951
952    #[getter]
953    pub fn nodes(&self, py: Python<'_>) -> Py<PyAny> {
954        self.nodes.clone_ref(py)
955    }
956
957    #[getter]
958    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
959        self.group.clone_ref(py)
960    }
961}
962
963#[pyclass(frozen)]
964#[derive(Debug)]
965pub struct PyPreAddNodesWithGroupsContext {
966    nodes: Py<PyAny>,
967    groups: Py<PyAny>,
968}
969
970impl Clone for PyPreAddNodesWithGroupsContext {
971    fn clone(&self) -> Self {
972        Python::attach(|py| Self {
973            nodes: self.nodes.clone_ref(py),
974            groups: self.groups.clone_ref(py),
975        })
976    }
977}
978
979impl PyPreAddNodesWithGroupsContext {
980    /// # Panics
981    ///
982    /// Panics if the python typing was not followed.
983    pub fn bind(py: Python<'_>, context: PreAddNodesWithGroupsContext) -> Self {
984        let nodes: Vec<(PyNodeIndex, PyAttributes)> = context.nodes.deep_into();
985        let groups: Vec<PyGroup> = context.groups.deep_into();
986
987        Self {
988            nodes: nodes.into_py_any(py).expect("nodes should be creatable"),
989            groups: groups.into_py_any(py).expect("groups should be creatable"),
990        }
991    }
992
993    /// # Panics
994    ///
995    /// Panics if the python typing was not followed.
996    pub fn extract(self, py: Python<'_>) -> PreAddNodesWithGroupsContext {
997        let nodes: Vec<(PyNodeIndex, PyAttributes)> =
998            self.nodes.extract(py).expect("nodes should be extractable");
999
1000        let groups: Vec<PyGroup> = self
1001            .groups
1002            .extract(py)
1003            .expect("groups should be extractable");
1004
1005        PreAddNodesWithGroupsContext {
1006            nodes: nodes.deep_into(),
1007            groups: groups.deep_into(),
1008        }
1009    }
1010}
1011
1012#[pymethods]
1013impl PyPreAddNodesWithGroupsContext {
1014    #[new]
1015    pub const fn new(nodes: Py<PyAny>, groups: Py<PyAny>) -> Self {
1016        Self { nodes, groups }
1017    }
1018
1019    #[getter]
1020    pub fn nodes(&self, py: Python<'_>) -> Py<PyAny> {
1021        self.nodes.clone_ref(py)
1022    }
1023
1024    #[getter]
1025    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
1026        self.groups.clone_ref(py)
1027    }
1028}
1029
1030#[pyclass(frozen)]
1031#[derive(Debug)]
1032pub struct PyPostAddNodesWithGroupsContext {
1033    nodes: Py<PyAny>,
1034    groups: Py<PyAny>,
1035}
1036
1037impl Clone for PyPostAddNodesWithGroupsContext {
1038    fn clone(&self) -> Self {
1039        Python::attach(|py| Self {
1040            nodes: self.nodes.clone_ref(py),
1041            groups: self.groups.clone_ref(py),
1042        })
1043    }
1044}
1045
1046impl PyPostAddNodesWithGroupsContext {
1047    /// # Panics
1048    ///
1049    /// Panics if the python typing was not followed.
1050    pub fn bind(py: Python<'_>, context: PostAddNodesWithGroupsContext) -> Self {
1051        let nodes: Vec<(PyNodeIndex, PyAttributes)> = context.nodes.deep_into();
1052        let groups: Vec<PyGroup> = context.groups.deep_into();
1053
1054        Self {
1055            nodes: nodes.into_py_any(py).expect("nodes should be creatable"),
1056            groups: groups.into_py_any(py).expect("groups should be creatable"),
1057        }
1058    }
1059}
1060
1061#[pymethods]
1062impl PyPostAddNodesWithGroupsContext {
1063    #[new]
1064    pub const fn new(nodes: Py<PyAny>, groups: Py<PyAny>) -> Self {
1065        Self { nodes, groups }
1066    }
1067
1068    #[getter]
1069    pub fn nodes(&self, py: Python<'_>) -> Py<PyAny> {
1070        self.nodes.clone_ref(py)
1071    }
1072
1073    #[getter]
1074    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
1075        self.groups.clone_ref(py)
1076    }
1077}
1078
1079#[pyclass(frozen)]
1080#[derive(Debug)]
1081pub struct PyPreAddNodesDataframesContext {
1082    nodes_dataframes: Py<PyAny>,
1083}
1084
1085impl Clone for PyPreAddNodesDataframesContext {
1086    fn clone(&self) -> Self {
1087        Python::attach(|py| Self {
1088            nodes_dataframes: self.nodes_dataframes.clone_ref(py),
1089        })
1090    }
1091}
1092
1093impl PyPreAddNodesDataframesContext {
1094    /// # Panics
1095    ///
1096    /// Panics if the python typing was not followed.
1097    pub fn bind(py: Python<'_>, context: PreAddNodesDataframesContext) -> Self {
1098        let nodes_dataframes = node_dataframe_inputs_to_py(context.nodes_dataframes);
1099
1100        Self {
1101            nodes_dataframes: nodes_dataframes
1102                .into_py_any(py)
1103                .expect("nodes_dataframes should be creatable"),
1104        }
1105    }
1106
1107    /// # Panics
1108    ///
1109    /// Panics if the python typing was not followed.
1110    pub fn extract(self, py: Python<'_>) -> PreAddNodesDataframesContext {
1111        let nodes_dataframes: Vec<(PyDataFrame, String)> = self
1112            .nodes_dataframes
1113            .extract(py)
1114            .expect("nodes_dataframes should be extractable");
1115
1116        PreAddNodesDataframesContext {
1117            nodes_dataframes: py_to_node_dataframe_inputs(nodes_dataframes),
1118        }
1119    }
1120}
1121
1122#[pymethods]
1123impl PyPreAddNodesDataframesContext {
1124    #[new]
1125    pub const fn new(nodes_dataframes: Py<PyAny>) -> Self {
1126        Self { nodes_dataframes }
1127    }
1128
1129    #[getter]
1130    pub fn nodes_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
1131        self.nodes_dataframes.clone_ref(py)
1132    }
1133}
1134
1135#[pyclass(frozen)]
1136#[derive(Debug)]
1137pub struct PyPostAddNodesDataframesContext {
1138    nodes_dataframes: Py<PyAny>,
1139}
1140
1141impl Clone for PyPostAddNodesDataframesContext {
1142    fn clone(&self) -> Self {
1143        Python::attach(|py| Self {
1144            nodes_dataframes: self.nodes_dataframes.clone_ref(py),
1145        })
1146    }
1147}
1148
1149impl PyPostAddNodesDataframesContext {
1150    /// # Panics
1151    ///
1152    /// Panics if the python typing was not followed.
1153    pub fn bind(py: Python<'_>, context: PostAddNodesDataframesContext) -> Self {
1154        let nodes_dataframes = node_dataframe_inputs_to_py(context.nodes_dataframes);
1155
1156        Self {
1157            nodes_dataframes: nodes_dataframes
1158                .into_py_any(py)
1159                .expect("nodes_dataframes should be creatable"),
1160        }
1161    }
1162}
1163
1164#[pymethods]
1165impl PyPostAddNodesDataframesContext {
1166    #[new]
1167    pub const fn new(nodes_dataframes: Py<PyAny>) -> Self {
1168        Self { nodes_dataframes }
1169    }
1170
1171    #[getter]
1172    pub fn nodes_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
1173        self.nodes_dataframes.clone_ref(py)
1174    }
1175}
1176
1177#[pyclass(frozen)]
1178#[derive(Debug)]
1179pub struct PyPreAddNodesDataframesWithGroupContext {
1180    nodes_dataframes: Py<PyAny>,
1181    group: Py<PyAny>,
1182}
1183
1184impl Clone for PyPreAddNodesDataframesWithGroupContext {
1185    fn clone(&self) -> Self {
1186        Python::attach(|py| Self {
1187            nodes_dataframes: self.nodes_dataframes.clone_ref(py),
1188            group: self.group.clone_ref(py),
1189        })
1190    }
1191}
1192
1193impl PyPreAddNodesDataframesWithGroupContext {
1194    /// # Panics
1195    ///
1196    /// Panics if the python typing was not followed.
1197    pub fn bind(py: Python<'_>, context: PreAddNodesDataframesWithGroupContext) -> Self {
1198        let nodes_dataframes = node_dataframe_inputs_to_py(context.nodes_dataframes);
1199
1200        Self {
1201            nodes_dataframes: nodes_dataframes
1202                .into_py_any(py)
1203                .expect("nodes_dataframes should be creatable"),
1204            group: PyGroup::from(context.group)
1205                .into_py_any(py)
1206                .expect("PyGroup should be creatable"),
1207        }
1208    }
1209
1210    /// # Panics
1211    ///
1212    /// Panics if the python typing was not followed.
1213    pub fn extract(self, py: Python<'_>) -> PreAddNodesDataframesWithGroupContext {
1214        let nodes_dataframes: Vec<(PyDataFrame, String)> = self
1215            .nodes_dataframes
1216            .extract(py)
1217            .expect("nodes_dataframes should be extractable");
1218
1219        let group: PyGroup = self
1220            .group
1221            .extract(py)
1222            .expect("PyGroup should be extractable");
1223
1224        PreAddNodesDataframesWithGroupContext {
1225            nodes_dataframes: py_to_node_dataframe_inputs(nodes_dataframes),
1226            group: group.into(),
1227        }
1228    }
1229}
1230
1231#[pymethods]
1232impl PyPreAddNodesDataframesWithGroupContext {
1233    #[new]
1234    pub const fn new(nodes_dataframes: Py<PyAny>, group: Py<PyAny>) -> Self {
1235        Self {
1236            nodes_dataframes,
1237            group,
1238        }
1239    }
1240
1241    #[getter]
1242    pub fn nodes_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
1243        self.nodes_dataframes.clone_ref(py)
1244    }
1245
1246    #[getter]
1247    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
1248        self.group.clone_ref(py)
1249    }
1250}
1251
1252#[pyclass(frozen)]
1253#[derive(Debug)]
1254pub struct PyPostAddNodesDataframesWithGroupContext {
1255    nodes_dataframes: Py<PyAny>,
1256    group: Py<PyAny>,
1257}
1258
1259impl Clone for PyPostAddNodesDataframesWithGroupContext {
1260    fn clone(&self) -> Self {
1261        Python::attach(|py| Self {
1262            nodes_dataframes: self.nodes_dataframes.clone_ref(py),
1263            group: self.group.clone_ref(py),
1264        })
1265    }
1266}
1267
1268impl PyPostAddNodesDataframesWithGroupContext {
1269    /// # Panics
1270    ///
1271    /// Panics if the python typing was not followed.
1272    pub fn bind(py: Python<'_>, context: PostAddNodesDataframesWithGroupContext) -> Self {
1273        let nodes_dataframes = node_dataframe_inputs_to_py(context.nodes_dataframes);
1274
1275        Self {
1276            nodes_dataframes: nodes_dataframes
1277                .into_py_any(py)
1278                .expect("nodes_dataframes should be creatable"),
1279            group: PyGroup::from(context.group)
1280                .into_py_any(py)
1281                .expect("PyGroup should be creatable"),
1282        }
1283    }
1284}
1285
1286#[pymethods]
1287impl PyPostAddNodesDataframesWithGroupContext {
1288    #[new]
1289    pub const fn new(nodes_dataframes: Py<PyAny>, group: Py<PyAny>) -> Self {
1290        Self {
1291            nodes_dataframes,
1292            group,
1293        }
1294    }
1295
1296    #[getter]
1297    pub fn nodes_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
1298        self.nodes_dataframes.clone_ref(py)
1299    }
1300
1301    #[getter]
1302    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
1303        self.group.clone_ref(py)
1304    }
1305}
1306
1307#[pyclass(frozen)]
1308#[derive(Debug)]
1309pub struct PyPreAddNodesDataframesWithGroupsContext {
1310    nodes_dataframes: Py<PyAny>,
1311    groups: Py<PyAny>,
1312}
1313
1314impl Clone for PyPreAddNodesDataframesWithGroupsContext {
1315    fn clone(&self) -> Self {
1316        Python::attach(|py| Self {
1317            nodes_dataframes: self.nodes_dataframes.clone_ref(py),
1318            groups: self.groups.clone_ref(py),
1319        })
1320    }
1321}
1322
1323impl PyPreAddNodesDataframesWithGroupsContext {
1324    /// # Panics
1325    ///
1326    /// Panics if the python typing was not followed.
1327    pub fn bind(py: Python<'_>, context: PreAddNodesDataframesWithGroupsContext) -> Self {
1328        let nodes_dataframes = node_dataframe_inputs_to_py(context.nodes_dataframes);
1329        let groups: Vec<PyGroup> = context.groups.deep_into();
1330
1331        Self {
1332            nodes_dataframes: nodes_dataframes
1333                .into_py_any(py)
1334                .expect("nodes_dataframes should be creatable"),
1335            groups: groups.into_py_any(py).expect("groups should be creatable"),
1336        }
1337    }
1338
1339    /// # Panics
1340    ///
1341    /// Panics if the python typing was not followed.
1342    pub fn extract(self, py: Python<'_>) -> PreAddNodesDataframesWithGroupsContext {
1343        let nodes_dataframes: Vec<(PyDataFrame, String)> = self
1344            .nodes_dataframes
1345            .extract(py)
1346            .expect("nodes_dataframes should be extractable");
1347
1348        let groups: Vec<PyGroup> = self
1349            .groups
1350            .extract(py)
1351            .expect("groups should be extractable");
1352
1353        PreAddNodesDataframesWithGroupsContext {
1354            nodes_dataframes: py_to_node_dataframe_inputs(nodes_dataframes),
1355            groups: groups.deep_into(),
1356        }
1357    }
1358}
1359
1360#[pymethods]
1361impl PyPreAddNodesDataframesWithGroupsContext {
1362    #[new]
1363    pub const fn new(nodes_dataframes: Py<PyAny>, groups: Py<PyAny>) -> Self {
1364        Self {
1365            nodes_dataframes,
1366            groups,
1367        }
1368    }
1369
1370    #[getter]
1371    pub fn nodes_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
1372        self.nodes_dataframes.clone_ref(py)
1373    }
1374
1375    #[getter]
1376    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
1377        self.groups.clone_ref(py)
1378    }
1379}
1380
1381#[pyclass(frozen)]
1382#[derive(Debug)]
1383pub struct PyPostAddNodesDataframesWithGroupsContext {
1384    nodes_dataframes: Py<PyAny>,
1385    groups: Py<PyAny>,
1386}
1387
1388impl Clone for PyPostAddNodesDataframesWithGroupsContext {
1389    fn clone(&self) -> Self {
1390        Python::attach(|py| Self {
1391            nodes_dataframes: self.nodes_dataframes.clone_ref(py),
1392            groups: self.groups.clone_ref(py),
1393        })
1394    }
1395}
1396
1397impl PyPostAddNodesDataframesWithGroupsContext {
1398    /// # Panics
1399    ///
1400    /// Panics if the python typing was not followed.
1401    pub fn bind(py: Python<'_>, context: PostAddNodesDataframesWithGroupsContext) -> Self {
1402        let nodes_dataframes = node_dataframe_inputs_to_py(context.nodes_dataframes);
1403        let groups: Vec<PyGroup> = context.groups.deep_into();
1404
1405        Self {
1406            nodes_dataframes: nodes_dataframes
1407                .into_py_any(py)
1408                .expect("nodes_dataframes should be creatable"),
1409            groups: groups.into_py_any(py).expect("groups should be creatable"),
1410        }
1411    }
1412}
1413
1414#[pymethods]
1415impl PyPostAddNodesDataframesWithGroupsContext {
1416    #[new]
1417    pub const fn new(nodes_dataframes: Py<PyAny>, groups: Py<PyAny>) -> Self {
1418        Self {
1419            nodes_dataframes,
1420            groups,
1421        }
1422    }
1423
1424    #[getter]
1425    pub fn nodes_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
1426        self.nodes_dataframes.clone_ref(py)
1427    }
1428
1429    #[getter]
1430    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
1431        self.groups.clone_ref(py)
1432    }
1433}
1434
1435#[pyclass(frozen)]
1436#[derive(Debug)]
1437pub struct PyPreAddEdgeContext {
1438    source_node_index: Py<PyAny>,
1439    target_node_index: Py<PyAny>,
1440    attributes: Py<PyAny>,
1441}
1442
1443impl Clone for PyPreAddEdgeContext {
1444    fn clone(&self) -> Self {
1445        Python::attach(|py| Self {
1446            source_node_index: self.source_node_index.clone_ref(py),
1447            target_node_index: self.target_node_index.clone_ref(py),
1448            attributes: self.attributes.clone_ref(py),
1449        })
1450    }
1451}
1452
1453impl PyPreAddEdgeContext {
1454    /// # Panics
1455    ///
1456    /// Panics if the python typing was not followed.
1457    pub fn bind(py: Python<'_>, context: PreAddEdgeContext) -> Self {
1458        Self {
1459            source_node_index: PyNodeIndex::from(context.source_node_index)
1460                .into_py_any(py)
1461                .expect("PyNodeIndex should be creatable"),
1462            target_node_index: PyNodeIndex::from(context.target_node_index)
1463                .into_py_any(py)
1464                .expect("PyNodeIndex should be creatable"),
1465            attributes: {
1466                let py_attrs: PyAttributes = context.attributes.deep_into();
1467                py_attrs
1468                    .into_py_any(py)
1469                    .expect("PyAttributes should be creatable")
1470            },
1471        }
1472    }
1473
1474    /// # Panics
1475    ///
1476    /// Panics if the python typing was not followed.
1477    pub fn extract(self, py: Python<'_>) -> PreAddEdgeContext {
1478        let source: PyNodeIndex = self
1479            .source_node_index
1480            .extract(py)
1481            .expect("PyNodeIndex should be extractable");
1482
1483        let target: PyNodeIndex = self
1484            .target_node_index
1485            .extract(py)
1486            .expect("PyNodeIndex should be extractable");
1487
1488        let attributes: PyAttributes = self
1489            .attributes
1490            .extract(py)
1491            .expect("PyAttributes should be extractable");
1492
1493        PreAddEdgeContext {
1494            source_node_index: source.into(),
1495            target_node_index: target.into(),
1496            attributes: attributes.deep_into(),
1497        }
1498    }
1499}
1500
1501#[pymethods]
1502impl PyPreAddEdgeContext {
1503    #[new]
1504    pub const fn new(
1505        source_node_index: Py<PyAny>,
1506        target_node_index: Py<PyAny>,
1507        attributes: Py<PyAny>,
1508    ) -> Self {
1509        Self {
1510            source_node_index,
1511            target_node_index,
1512            attributes,
1513        }
1514    }
1515
1516    #[getter]
1517    pub fn source_node_index(&self, py: Python<'_>) -> Py<PyAny> {
1518        self.source_node_index.clone_ref(py)
1519    }
1520
1521    #[getter]
1522    pub fn target_node_index(&self, py: Python<'_>) -> Py<PyAny> {
1523        self.target_node_index.clone_ref(py)
1524    }
1525
1526    #[getter]
1527    pub fn attributes(&self, py: Python<'_>) -> Py<PyAny> {
1528        self.attributes.clone_ref(py)
1529    }
1530}
1531
1532#[pyclass(frozen)]
1533#[derive(Debug)]
1534pub struct PyPostAddEdgeContext {
1535    edge_index: Py<PyAny>,
1536}
1537
1538impl Clone for PyPostAddEdgeContext {
1539    fn clone(&self) -> Self {
1540        Python::attach(|py| Self {
1541            edge_index: self.edge_index.clone_ref(py),
1542        })
1543    }
1544}
1545
1546impl PyPostAddEdgeContext {
1547    /// # Panics
1548    ///
1549    /// Panics if the python typing was not followed.
1550    pub fn bind(py: Python<'_>, context: PostAddEdgeContext) -> Self {
1551        Self {
1552            edge_index: context
1553                .edge_index
1554                .into_py_any(py)
1555                .expect("edge_index should be creatable"),
1556        }
1557    }
1558
1559    /// # Panics
1560    ///
1561    /// Panics if the python typing was not followed.
1562    pub fn extract(self, py: Python<'_>) -> PostAddEdgeContext {
1563        PostAddEdgeContext {
1564            edge_index: self
1565                .edge_index
1566                .extract(py)
1567                .expect("edge_index should be extractable"),
1568        }
1569    }
1570}
1571
1572#[pymethods]
1573impl PyPostAddEdgeContext {
1574    #[new]
1575    pub const fn new(edge_index: Py<PyAny>) -> Self {
1576        Self { edge_index }
1577    }
1578
1579    #[getter]
1580    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
1581        self.edge_index.clone_ref(py)
1582    }
1583}
1584
1585#[pyclass(frozen)]
1586#[derive(Debug)]
1587pub struct PyPreAddEdgeWithGroupContext {
1588    source_node_index: Py<PyAny>,
1589    target_node_index: Py<PyAny>,
1590    attributes: Py<PyAny>,
1591    group: Py<PyAny>,
1592}
1593
1594impl Clone for PyPreAddEdgeWithGroupContext {
1595    fn clone(&self) -> Self {
1596        Python::attach(|py| Self {
1597            source_node_index: self.source_node_index.clone_ref(py),
1598            target_node_index: self.target_node_index.clone_ref(py),
1599            attributes: self.attributes.clone_ref(py),
1600            group: self.group.clone_ref(py),
1601        })
1602    }
1603}
1604
1605impl PyPreAddEdgeWithGroupContext {
1606    /// # Panics
1607    ///
1608    /// Panics if the python typing was not followed.
1609    pub fn bind(py: Python<'_>, context: PreAddEdgeWithGroupContext) -> Self {
1610        Self {
1611            source_node_index: PyNodeIndex::from(context.source_node_index)
1612                .into_py_any(py)
1613                .expect("PyNodeIndex should be creatable"),
1614            target_node_index: PyNodeIndex::from(context.target_node_index)
1615                .into_py_any(py)
1616                .expect("PyNodeIndex should be creatable"),
1617            attributes: {
1618                let py_attrs: PyAttributes = context.attributes.deep_into();
1619                py_attrs
1620                    .into_py_any(py)
1621                    .expect("PyAttributes should be creatable")
1622            },
1623            group: PyGroup::from(context.group)
1624                .into_py_any(py)
1625                .expect("PyGroup should be creatable"),
1626        }
1627    }
1628
1629    /// # Panics
1630    ///
1631    /// Panics if the python typing was not followed.
1632    pub fn extract(self, py: Python<'_>) -> PreAddEdgeWithGroupContext {
1633        let source: PyNodeIndex = self
1634            .source_node_index
1635            .extract(py)
1636            .expect("PyNodeIndex should be extractable");
1637
1638        let target: PyNodeIndex = self
1639            .target_node_index
1640            .extract(py)
1641            .expect("PyNodeIndex should be extractable");
1642
1643        let attributes: PyAttributes = self
1644            .attributes
1645            .extract(py)
1646            .expect("PyAttributes should be extractable");
1647
1648        let group: PyGroup = self
1649            .group
1650            .extract(py)
1651            .expect("PyGroup should be extractable");
1652
1653        PreAddEdgeWithGroupContext {
1654            source_node_index: source.into(),
1655            target_node_index: target.into(),
1656            attributes: attributes.deep_into(),
1657            group: group.into(),
1658        }
1659    }
1660}
1661
1662#[pymethods]
1663impl PyPreAddEdgeWithGroupContext {
1664    #[new]
1665    pub const fn new(
1666        source_node_index: Py<PyAny>,
1667        target_node_index: Py<PyAny>,
1668        attributes: Py<PyAny>,
1669        group: Py<PyAny>,
1670    ) -> Self {
1671        Self {
1672            source_node_index,
1673            target_node_index,
1674            attributes,
1675            group,
1676        }
1677    }
1678
1679    #[getter]
1680    pub fn source_node_index(&self, py: Python<'_>) -> Py<PyAny> {
1681        self.source_node_index.clone_ref(py)
1682    }
1683
1684    #[getter]
1685    pub fn target_node_index(&self, py: Python<'_>) -> Py<PyAny> {
1686        self.target_node_index.clone_ref(py)
1687    }
1688
1689    #[getter]
1690    pub fn attributes(&self, py: Python<'_>) -> Py<PyAny> {
1691        self.attributes.clone_ref(py)
1692    }
1693
1694    #[getter]
1695    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
1696        self.group.clone_ref(py)
1697    }
1698}
1699
1700#[pyclass(frozen)]
1701#[derive(Debug)]
1702pub struct PyPostAddEdgeWithGroupContext {
1703    edge_index: Py<PyAny>,
1704}
1705
1706impl Clone for PyPostAddEdgeWithGroupContext {
1707    fn clone(&self) -> Self {
1708        Python::attach(|py| Self {
1709            edge_index: self.edge_index.clone_ref(py),
1710        })
1711    }
1712}
1713
1714impl PyPostAddEdgeWithGroupContext {
1715    /// # Panics
1716    ///
1717    /// Panics if the python typing was not followed.
1718    pub fn bind(py: Python<'_>, context: PostAddEdgeWithGroupContext) -> Self {
1719        Self {
1720            edge_index: context
1721                .edge_index
1722                .into_py_any(py)
1723                .expect("edge_index should be creatable"),
1724        }
1725    }
1726}
1727
1728#[pymethods]
1729impl PyPostAddEdgeWithGroupContext {
1730    #[new]
1731    pub const fn new(edge_index: Py<PyAny>) -> Self {
1732        Self { edge_index }
1733    }
1734
1735    #[getter]
1736    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
1737        self.edge_index.clone_ref(py)
1738    }
1739}
1740
1741#[pyclass(frozen)]
1742#[derive(Debug)]
1743pub struct PyPreAddEdgeWithGroupsContext {
1744    source_node_index: Py<PyAny>,
1745    target_node_index: Py<PyAny>,
1746    attributes: Py<PyAny>,
1747    groups: Py<PyAny>,
1748}
1749
1750impl Clone for PyPreAddEdgeWithGroupsContext {
1751    fn clone(&self) -> Self {
1752        Python::attach(|py| Self {
1753            source_node_index: self.source_node_index.clone_ref(py),
1754            target_node_index: self.target_node_index.clone_ref(py),
1755            attributes: self.attributes.clone_ref(py),
1756            groups: self.groups.clone_ref(py),
1757        })
1758    }
1759}
1760
1761impl PyPreAddEdgeWithGroupsContext {
1762    /// # Panics
1763    ///
1764    /// Panics if the python typing was not followed.
1765    pub fn bind(py: Python<'_>, context: PreAddEdgeWithGroupsContext) -> Self {
1766        let groups: Vec<PyGroup> = context.groups.deep_into();
1767
1768        Self {
1769            source_node_index: PyNodeIndex::from(context.source_node_index)
1770                .into_py_any(py)
1771                .expect("PyNodeIndex should be creatable"),
1772            target_node_index: PyNodeIndex::from(context.target_node_index)
1773                .into_py_any(py)
1774                .expect("PyNodeIndex should be creatable"),
1775            attributes: {
1776                let py_attrs: PyAttributes = context.attributes.deep_into();
1777                py_attrs
1778                    .into_py_any(py)
1779                    .expect("PyAttributes should be creatable")
1780            },
1781            groups: groups.into_py_any(py).expect("groups should be creatable"),
1782        }
1783    }
1784
1785    /// # Panics
1786    ///
1787    /// Panics if the python typing was not followed.
1788    pub fn extract(self, py: Python<'_>) -> PreAddEdgeWithGroupsContext {
1789        let source: PyNodeIndex = self
1790            .source_node_index
1791            .extract(py)
1792            .expect("PyNodeIndex should be extractable");
1793
1794        let target: PyNodeIndex = self
1795            .target_node_index
1796            .extract(py)
1797            .expect("PyNodeIndex should be extractable");
1798
1799        let attributes: PyAttributes = self
1800            .attributes
1801            .extract(py)
1802            .expect("PyAttributes should be extractable");
1803
1804        let groups: Vec<PyGroup> = self
1805            .groups
1806            .extract(py)
1807            .expect("groups should be extractable");
1808
1809        PreAddEdgeWithGroupsContext {
1810            source_node_index: source.into(),
1811            target_node_index: target.into(),
1812            attributes: attributes.deep_into(),
1813            groups: groups.deep_into(),
1814        }
1815    }
1816}
1817
1818#[pymethods]
1819impl PyPreAddEdgeWithGroupsContext {
1820    #[new]
1821    pub const fn new(
1822        source_node_index: Py<PyAny>,
1823        target_node_index: Py<PyAny>,
1824        attributes: Py<PyAny>,
1825        groups: Py<PyAny>,
1826    ) -> Self {
1827        Self {
1828            source_node_index,
1829            target_node_index,
1830            attributes,
1831            groups,
1832        }
1833    }
1834
1835    #[getter]
1836    pub fn source_node_index(&self, py: Python<'_>) -> Py<PyAny> {
1837        self.source_node_index.clone_ref(py)
1838    }
1839
1840    #[getter]
1841    pub fn target_node_index(&self, py: Python<'_>) -> Py<PyAny> {
1842        self.target_node_index.clone_ref(py)
1843    }
1844
1845    #[getter]
1846    pub fn attributes(&self, py: Python<'_>) -> Py<PyAny> {
1847        self.attributes.clone_ref(py)
1848    }
1849
1850    #[getter]
1851    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
1852        self.groups.clone_ref(py)
1853    }
1854}
1855
1856#[pyclass(frozen)]
1857#[derive(Debug)]
1858pub struct PyPostAddEdgeWithGroupsContext {
1859    edge_index: Py<PyAny>,
1860    groups: Py<PyAny>,
1861}
1862
1863impl Clone for PyPostAddEdgeWithGroupsContext {
1864    fn clone(&self) -> Self {
1865        Python::attach(|py| Self {
1866            edge_index: self.edge_index.clone_ref(py),
1867            groups: self.groups.clone_ref(py),
1868        })
1869    }
1870}
1871
1872impl PyPostAddEdgeWithGroupsContext {
1873    /// # Panics
1874    ///
1875    /// Panics if the python typing was not followed.
1876    pub fn bind(py: Python<'_>, context: PostAddEdgeWithGroupsContext) -> Self {
1877        let groups: Vec<PyGroup> = context.groups.deep_into();
1878
1879        Self {
1880            edge_index: context
1881                .edge_index
1882                .into_py_any(py)
1883                .expect("edge_index should be creatable"),
1884            groups: groups.into_py_any(py).expect("groups should be creatable"),
1885        }
1886    }
1887}
1888
1889#[pymethods]
1890impl PyPostAddEdgeWithGroupsContext {
1891    #[new]
1892    pub const fn new(edge_index: Py<PyAny>, groups: Py<PyAny>) -> Self {
1893        Self { edge_index, groups }
1894    }
1895
1896    #[getter]
1897    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
1898        self.edge_index.clone_ref(py)
1899    }
1900
1901    #[getter]
1902    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
1903        self.groups.clone_ref(py)
1904    }
1905}
1906
1907#[pyclass(frozen)]
1908#[derive(Debug)]
1909pub struct PyPreRemoveEdgeContext {
1910    edge_index: Py<PyAny>,
1911}
1912
1913impl Clone for PyPreRemoveEdgeContext {
1914    fn clone(&self) -> Self {
1915        Python::attach(|py| Self {
1916            edge_index: self.edge_index.clone_ref(py),
1917        })
1918    }
1919}
1920
1921impl PyPreRemoveEdgeContext {
1922    /// # Panics
1923    ///
1924    /// Panics if the python typing was not followed.
1925    pub fn bind(py: Python<'_>, context: PreRemoveEdgeContext) -> Self {
1926        Self {
1927            edge_index: context
1928                .edge_index
1929                .into_py_any(py)
1930                .expect("edge_index should be creatable"),
1931        }
1932    }
1933
1934    /// # Panics
1935    ///
1936    /// Panics if the python typing was not followed.
1937    pub fn extract(self, py: Python<'_>) -> PreRemoveEdgeContext {
1938        PreRemoveEdgeContext {
1939            edge_index: self
1940                .edge_index
1941                .extract(py)
1942                .expect("edge_index should be extractable"),
1943        }
1944    }
1945}
1946
1947#[pymethods]
1948impl PyPreRemoveEdgeContext {
1949    #[new]
1950    pub const fn new(edge_index: Py<PyAny>) -> Self {
1951        Self { edge_index }
1952    }
1953
1954    #[getter]
1955    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
1956        self.edge_index.clone_ref(py)
1957    }
1958}
1959
1960#[pyclass(frozen)]
1961#[derive(Debug)]
1962pub struct PyPostRemoveEdgeContext {
1963    edge_index: Py<PyAny>,
1964}
1965
1966impl Clone for PyPostRemoveEdgeContext {
1967    fn clone(&self) -> Self {
1968        Python::attach(|py| Self {
1969            edge_index: self.edge_index.clone_ref(py),
1970        })
1971    }
1972}
1973
1974impl PyPostRemoveEdgeContext {
1975    /// # Panics
1976    ///
1977    /// Panics if the python typing was not followed.
1978    pub fn bind(py: Python<'_>, context: PostRemoveEdgeContext) -> Self {
1979        Self {
1980            edge_index: context
1981                .edge_index
1982                .into_py_any(py)
1983                .expect("edge_index should be creatable"),
1984        }
1985    }
1986}
1987
1988#[pymethods]
1989impl PyPostRemoveEdgeContext {
1990    #[new]
1991    pub const fn new(edge_index: Py<PyAny>) -> Self {
1992        Self { edge_index }
1993    }
1994
1995    #[getter]
1996    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
1997        self.edge_index.clone_ref(py)
1998    }
1999}
2000
2001#[pyclass(frozen)]
2002#[derive(Debug)]
2003pub struct PyPreAddEdgesContext {
2004    edges: Py<PyAny>,
2005}
2006
2007impl Clone for PyPreAddEdgesContext {
2008    fn clone(&self) -> Self {
2009        Python::attach(|py| Self {
2010            edges: self.edges.clone_ref(py),
2011        })
2012    }
2013}
2014
2015impl PyPreAddEdgesContext {
2016    /// # Panics
2017    ///
2018    /// Panics if the python typing was not followed.
2019    pub fn bind(py: Python<'_>, context: PreAddEdgesContext) -> Self {
2020        let edges: Vec<(PyNodeIndex, PyNodeIndex, PyAttributes)> = context.edges.deep_into();
2021
2022        Self {
2023            edges: edges.into_py_any(py).expect("edges should be creatable"),
2024        }
2025    }
2026
2027    /// # Panics
2028    ///
2029    /// Panics if the python typing was not followed.
2030    pub fn extract(self, py: Python<'_>) -> PreAddEdgesContext {
2031        let edges: Vec<(PyNodeIndex, PyNodeIndex, PyAttributes)> =
2032            self.edges.extract(py).expect("edges should be extractable");
2033
2034        PreAddEdgesContext {
2035            edges: edges.deep_into(),
2036        }
2037    }
2038}
2039
2040#[pymethods]
2041impl PyPreAddEdgesContext {
2042    #[new]
2043    pub const fn new(edges: Py<PyAny>) -> Self {
2044        Self { edges }
2045    }
2046
2047    #[getter]
2048    pub fn edges(&self, py: Python<'_>) -> Py<PyAny> {
2049        self.edges.clone_ref(py)
2050    }
2051}
2052
2053#[pyclass(frozen)]
2054#[derive(Debug)]
2055pub struct PyPostAddEdgesContext {
2056    edge_indices: Py<PyAny>,
2057}
2058
2059impl Clone for PyPostAddEdgesContext {
2060    fn clone(&self) -> Self {
2061        Python::attach(|py| Self {
2062            edge_indices: self.edge_indices.clone_ref(py),
2063        })
2064    }
2065}
2066
2067impl PyPostAddEdgesContext {
2068    /// # Panics
2069    ///
2070    /// Panics if the python typing was not followed.
2071    pub fn bind(py: Python<'_>, context: PostAddEdgesContext) -> Self {
2072        Self {
2073            edge_indices: context
2074                .edge_indices
2075                .into_py_any(py)
2076                .expect("edge_indices should be creatable"),
2077        }
2078    }
2079}
2080
2081#[pymethods]
2082impl PyPostAddEdgesContext {
2083    #[new]
2084    pub const fn new(edge_indices: Py<PyAny>) -> Self {
2085        Self { edge_indices }
2086    }
2087
2088    #[getter]
2089    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
2090        self.edge_indices.clone_ref(py)
2091    }
2092}
2093
2094#[pyclass(frozen)]
2095#[derive(Debug)]
2096pub struct PyPreAddEdgesWithGroupContext {
2097    edges: Py<PyAny>,
2098    group: Py<PyAny>,
2099}
2100
2101impl Clone for PyPreAddEdgesWithGroupContext {
2102    fn clone(&self) -> Self {
2103        Python::attach(|py| Self {
2104            edges: self.edges.clone_ref(py),
2105            group: self.group.clone_ref(py),
2106        })
2107    }
2108}
2109
2110impl PyPreAddEdgesWithGroupContext {
2111    /// # Panics
2112    ///
2113    /// Panics if the python typing was not followed.
2114    pub fn bind(py: Python<'_>, context: PreAddEdgesWithGroupContext) -> Self {
2115        let edges: Vec<(PyNodeIndex, PyNodeIndex, PyAttributes)> = context.edges.deep_into();
2116
2117        Self {
2118            edges: edges.into_py_any(py).expect("edges should be creatable"),
2119            group: PyGroup::from(context.group)
2120                .into_py_any(py)
2121                .expect("PyGroup should be creatable"),
2122        }
2123    }
2124
2125    /// # Panics
2126    ///
2127    /// Panics if the python typing was not followed.
2128    pub fn extract(self, py: Python<'_>) -> PreAddEdgesWithGroupContext {
2129        let edges: Vec<(PyNodeIndex, PyNodeIndex, PyAttributes)> =
2130            self.edges.extract(py).expect("edges should be extractable");
2131
2132        let group: PyGroup = self
2133            .group
2134            .extract(py)
2135            .expect("PyGroup should be extractable");
2136
2137        PreAddEdgesWithGroupContext {
2138            edges: edges.deep_into(),
2139            group: group.into(),
2140        }
2141    }
2142}
2143
2144#[pymethods]
2145impl PyPreAddEdgesWithGroupContext {
2146    #[new]
2147    pub const fn new(edges: Py<PyAny>, group: Py<PyAny>) -> Self {
2148        Self { edges, group }
2149    }
2150
2151    #[getter]
2152    pub fn edges(&self, py: Python<'_>) -> Py<PyAny> {
2153        self.edges.clone_ref(py)
2154    }
2155
2156    #[getter]
2157    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2158        self.group.clone_ref(py)
2159    }
2160}
2161
2162#[pyclass(frozen)]
2163#[derive(Debug)]
2164pub struct PyPostAddEdgesWithGroupContext {
2165    edge_indices: Py<PyAny>,
2166}
2167
2168impl Clone for PyPostAddEdgesWithGroupContext {
2169    fn clone(&self) -> Self {
2170        Python::attach(|py| Self {
2171            edge_indices: self.edge_indices.clone_ref(py),
2172        })
2173    }
2174}
2175
2176impl PyPostAddEdgesWithGroupContext {
2177    /// # Panics
2178    ///
2179    /// Panics if the python typing was not followed.
2180    pub fn bind(py: Python<'_>, context: PostAddEdgesWithGroupContext) -> Self {
2181        Self {
2182            edge_indices: context
2183                .edge_indices
2184                .into_py_any(py)
2185                .expect("edge_indices should be creatable"),
2186        }
2187    }
2188}
2189
2190#[pymethods]
2191impl PyPostAddEdgesWithGroupContext {
2192    #[new]
2193    pub const fn new(edge_indices: Py<PyAny>) -> Self {
2194        Self { edge_indices }
2195    }
2196
2197    #[getter]
2198    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
2199        self.edge_indices.clone_ref(py)
2200    }
2201}
2202
2203#[pyclass(frozen)]
2204#[derive(Debug)]
2205pub struct PyPreAddEdgesWithGroupsContext {
2206    edges: Py<PyAny>,
2207    groups: Py<PyAny>,
2208}
2209
2210impl Clone for PyPreAddEdgesWithGroupsContext {
2211    fn clone(&self) -> Self {
2212        Python::attach(|py| Self {
2213            edges: self.edges.clone_ref(py),
2214            groups: self.groups.clone_ref(py),
2215        })
2216    }
2217}
2218
2219impl PyPreAddEdgesWithGroupsContext {
2220    /// # Panics
2221    ///
2222    /// Panics if the python typing was not followed.
2223    pub fn bind(py: Python<'_>, context: PreAddEdgesWithGroupsContext) -> Self {
2224        let edges: Vec<(PyNodeIndex, PyNodeIndex, PyAttributes)> = context.edges.deep_into();
2225        let groups: Vec<PyGroup> = context.groups.deep_into();
2226
2227        Self {
2228            edges: edges.into_py_any(py).expect("edges should be creatable"),
2229            groups: groups.into_py_any(py).expect("groups should be creatable"),
2230        }
2231    }
2232
2233    /// # Panics
2234    ///
2235    /// Panics if the python typing was not followed.
2236    pub fn extract(self, py: Python<'_>) -> PreAddEdgesWithGroupsContext {
2237        let edges: Vec<(PyNodeIndex, PyNodeIndex, PyAttributes)> =
2238            self.edges.extract(py).expect("edges should be extractable");
2239
2240        let groups: Vec<PyGroup> = self
2241            .groups
2242            .extract(py)
2243            .expect("groups should be extractable");
2244
2245        PreAddEdgesWithGroupsContext {
2246            edges: edges.deep_into(),
2247            groups: groups.deep_into(),
2248        }
2249    }
2250}
2251
2252#[pymethods]
2253impl PyPreAddEdgesWithGroupsContext {
2254    #[new]
2255    pub const fn new(edges: Py<PyAny>, groups: Py<PyAny>) -> Self {
2256        Self { edges, groups }
2257    }
2258
2259    #[getter]
2260    pub fn edges(&self, py: Python<'_>) -> Py<PyAny> {
2261        self.edges.clone_ref(py)
2262    }
2263
2264    #[getter]
2265    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
2266        self.groups.clone_ref(py)
2267    }
2268}
2269
2270#[pyclass(frozen)]
2271#[derive(Debug)]
2272pub struct PyPostAddEdgesWithGroupsContext {
2273    edge_indices: Py<PyAny>,
2274    groups: Py<PyAny>,
2275}
2276
2277impl Clone for PyPostAddEdgesWithGroupsContext {
2278    fn clone(&self) -> Self {
2279        Python::attach(|py| Self {
2280            edge_indices: self.edge_indices.clone_ref(py),
2281            groups: self.groups.clone_ref(py),
2282        })
2283    }
2284}
2285
2286impl PyPostAddEdgesWithGroupsContext {
2287    /// # Panics
2288    ///
2289    /// Panics if the python typing was not followed.
2290    pub fn bind(py: Python<'_>, context: PostAddEdgesWithGroupsContext) -> Self {
2291        let groups: Vec<PyGroup> = context.groups.deep_into();
2292
2293        Self {
2294            edge_indices: context
2295                .edge_indices
2296                .into_py_any(py)
2297                .expect("edge_indices should be creatable"),
2298            groups: groups.into_py_any(py).expect("groups should be creatable"),
2299        }
2300    }
2301}
2302
2303#[pymethods]
2304impl PyPostAddEdgesWithGroupsContext {
2305    #[new]
2306    pub const fn new(edge_indices: Py<PyAny>, groups: Py<PyAny>) -> Self {
2307        Self {
2308            edge_indices,
2309            groups,
2310        }
2311    }
2312
2313    #[getter]
2314    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
2315        self.edge_indices.clone_ref(py)
2316    }
2317
2318    #[getter]
2319    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
2320        self.groups.clone_ref(py)
2321    }
2322}
2323
2324#[pyclass(frozen)]
2325#[derive(Debug)]
2326pub struct PyPreAddEdgesDataframesContext {
2327    edges_dataframes: Py<PyAny>,
2328}
2329
2330impl Clone for PyPreAddEdgesDataframesContext {
2331    fn clone(&self) -> Self {
2332        Python::attach(|py| Self {
2333            edges_dataframes: self.edges_dataframes.clone_ref(py),
2334        })
2335    }
2336}
2337
2338impl PyPreAddEdgesDataframesContext {
2339    /// # Panics
2340    ///
2341    /// Panics if the python typing was not followed.
2342    pub fn bind(py: Python<'_>, context: PreAddEdgesDataframesContext) -> Self {
2343        let edges_dataframes = edge_dataframe_inputs_to_py(context.edges_dataframes);
2344
2345        Self {
2346            edges_dataframes: edges_dataframes
2347                .into_py_any(py)
2348                .expect("edges_dataframes should be creatable"),
2349        }
2350    }
2351
2352    /// # Panics
2353    ///
2354    /// Panics if the python typing was not followed.
2355    pub fn extract(self, py: Python<'_>) -> PreAddEdgesDataframesContext {
2356        let edges_dataframes: Vec<(PyDataFrame, String, String)> = self
2357            .edges_dataframes
2358            .extract(py)
2359            .expect("edges_dataframes should be extractable");
2360
2361        PreAddEdgesDataframesContext {
2362            edges_dataframes: py_to_edge_dataframe_inputs(edges_dataframes),
2363        }
2364    }
2365}
2366
2367#[pymethods]
2368impl PyPreAddEdgesDataframesContext {
2369    #[new]
2370    pub const fn new(edges_dataframes: Py<PyAny>) -> Self {
2371        Self { edges_dataframes }
2372    }
2373
2374    #[getter]
2375    pub fn edges_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
2376        self.edges_dataframes.clone_ref(py)
2377    }
2378}
2379
2380#[pyclass(frozen)]
2381#[derive(Debug)]
2382pub struct PyPostAddEdgesDataframesContext {
2383    edges_dataframes: Py<PyAny>,
2384}
2385
2386impl Clone for PyPostAddEdgesDataframesContext {
2387    fn clone(&self) -> Self {
2388        Python::attach(|py| Self {
2389            edges_dataframes: self.edges_dataframes.clone_ref(py),
2390        })
2391    }
2392}
2393
2394impl PyPostAddEdgesDataframesContext {
2395    /// # Panics
2396    ///
2397    /// Panics if the python typing was not followed.
2398    pub fn bind(py: Python<'_>, context: PostAddEdgesDataframesContext) -> Self {
2399        let edges_dataframes = edge_dataframe_inputs_to_py(context.edges_dataframes);
2400
2401        Self {
2402            edges_dataframes: edges_dataframes
2403                .into_py_any(py)
2404                .expect("edges_dataframes should be creatable"),
2405        }
2406    }
2407}
2408
2409#[pymethods]
2410impl PyPostAddEdgesDataframesContext {
2411    #[new]
2412    pub const fn new(edges_dataframes: Py<PyAny>) -> Self {
2413        Self { edges_dataframes }
2414    }
2415
2416    #[getter]
2417    pub fn edges_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
2418        self.edges_dataframes.clone_ref(py)
2419    }
2420}
2421
2422#[pyclass(frozen)]
2423#[derive(Debug)]
2424pub struct PyPreAddEdgesDataframesWithGroupContext {
2425    edges_dataframes: Py<PyAny>,
2426    group: Py<PyAny>,
2427}
2428
2429impl Clone for PyPreAddEdgesDataframesWithGroupContext {
2430    fn clone(&self) -> Self {
2431        Python::attach(|py| Self {
2432            edges_dataframes: self.edges_dataframes.clone_ref(py),
2433            group: self.group.clone_ref(py),
2434        })
2435    }
2436}
2437
2438impl PyPreAddEdgesDataframesWithGroupContext {
2439    /// # Panics
2440    ///
2441    /// Panics if the python typing was not followed.
2442    pub fn bind(py: Python<'_>, context: PreAddEdgesDataframesWithGroupContext) -> Self {
2443        let edges_dataframes = edge_dataframe_inputs_to_py(context.edges_dataframes);
2444
2445        Self {
2446            edges_dataframes: edges_dataframes
2447                .into_py_any(py)
2448                .expect("edges_dataframes should be creatable"),
2449            group: PyGroup::from(context.group)
2450                .into_py_any(py)
2451                .expect("PyGroup should be creatable"),
2452        }
2453    }
2454
2455    /// # Panics
2456    ///
2457    /// Panics if the python typing was not followed.
2458    pub fn extract(self, py: Python<'_>) -> PreAddEdgesDataframesWithGroupContext {
2459        let edges_dataframes: Vec<(PyDataFrame, String, String)> = self
2460            .edges_dataframes
2461            .extract(py)
2462            .expect("edges_dataframes should be extractable");
2463
2464        let group: PyGroup = self
2465            .group
2466            .extract(py)
2467            .expect("PyGroup should be extractable");
2468
2469        PreAddEdgesDataframesWithGroupContext {
2470            edges_dataframes: py_to_edge_dataframe_inputs(edges_dataframes),
2471            group: group.into(),
2472        }
2473    }
2474}
2475
2476#[pymethods]
2477impl PyPreAddEdgesDataframesWithGroupContext {
2478    #[new]
2479    pub const fn new(edges_dataframes: Py<PyAny>, group: Py<PyAny>) -> Self {
2480        Self {
2481            edges_dataframes,
2482            group,
2483        }
2484    }
2485
2486    #[getter]
2487    pub fn edges_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
2488        self.edges_dataframes.clone_ref(py)
2489    }
2490
2491    #[getter]
2492    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2493        self.group.clone_ref(py)
2494    }
2495}
2496
2497#[pyclass(frozen)]
2498#[derive(Debug)]
2499pub struct PyPostAddEdgesDataframesWithGroupContext {
2500    edges_dataframes: Py<PyAny>,
2501    group: Py<PyAny>,
2502}
2503
2504impl Clone for PyPostAddEdgesDataframesWithGroupContext {
2505    fn clone(&self) -> Self {
2506        Python::attach(|py| Self {
2507            edges_dataframes: self.edges_dataframes.clone_ref(py),
2508            group: self.group.clone_ref(py),
2509        })
2510    }
2511}
2512
2513impl PyPostAddEdgesDataframesWithGroupContext {
2514    /// # Panics
2515    ///
2516    /// Panics if the python typing was not followed.
2517    pub fn bind(py: Python<'_>, context: PostAddEdgesDataframesWithGroupContext) -> Self {
2518        let edges_dataframes = edge_dataframe_inputs_to_py(context.edges_dataframes);
2519
2520        Self {
2521            edges_dataframes: edges_dataframes
2522                .into_py_any(py)
2523                .expect("edges_dataframes should be creatable"),
2524            group: PyGroup::from(context.group)
2525                .into_py_any(py)
2526                .expect("PyGroup should be creatable"),
2527        }
2528    }
2529}
2530
2531#[pymethods]
2532impl PyPostAddEdgesDataframesWithGroupContext {
2533    #[new]
2534    pub const fn new(edges_dataframes: Py<PyAny>, group: Py<PyAny>) -> Self {
2535        Self {
2536            edges_dataframes,
2537            group,
2538        }
2539    }
2540
2541    #[getter]
2542    pub fn edges_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
2543        self.edges_dataframes.clone_ref(py)
2544    }
2545
2546    #[getter]
2547    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2548        self.group.clone_ref(py)
2549    }
2550}
2551
2552#[pyclass(frozen)]
2553#[derive(Debug)]
2554pub struct PyPreAddEdgesDataframesWithGroupsContext {
2555    edges_dataframes: Py<PyAny>,
2556    groups: Py<PyAny>,
2557}
2558
2559impl Clone for PyPreAddEdgesDataframesWithGroupsContext {
2560    fn clone(&self) -> Self {
2561        Python::attach(|py| Self {
2562            edges_dataframes: self.edges_dataframes.clone_ref(py),
2563            groups: self.groups.clone_ref(py),
2564        })
2565    }
2566}
2567
2568impl PyPreAddEdgesDataframesWithGroupsContext {
2569    /// # Panics
2570    ///
2571    /// Panics if the python typing was not followed.
2572    pub fn bind(py: Python<'_>, context: PreAddEdgesDataframesWithGroupsContext) -> Self {
2573        let edges_dataframes = edge_dataframe_inputs_to_py(context.edges_dataframes);
2574        let groups: Vec<PyGroup> = context.groups.deep_into();
2575
2576        Self {
2577            edges_dataframes: edges_dataframes
2578                .into_py_any(py)
2579                .expect("edges_dataframes should be creatable"),
2580            groups: groups.into_py_any(py).expect("groups should be creatable"),
2581        }
2582    }
2583
2584    /// # Panics
2585    ///
2586    /// Panics if the python typing was not followed.
2587    pub fn extract(self, py: Python<'_>) -> PreAddEdgesDataframesWithGroupsContext {
2588        let edges_dataframes: Vec<(PyDataFrame, String, String)> = self
2589            .edges_dataframes
2590            .extract(py)
2591            .expect("edges_dataframes should be extractable");
2592
2593        let groups: Vec<PyGroup> = self
2594            .groups
2595            .extract(py)
2596            .expect("groups should be extractable");
2597
2598        PreAddEdgesDataframesWithGroupsContext {
2599            edges_dataframes: py_to_edge_dataframe_inputs(edges_dataframes),
2600            groups: groups.deep_into(),
2601        }
2602    }
2603}
2604
2605#[pymethods]
2606impl PyPreAddEdgesDataframesWithGroupsContext {
2607    #[new]
2608    pub const fn new(edges_dataframes: Py<PyAny>, groups: Py<PyAny>) -> Self {
2609        Self {
2610            edges_dataframes,
2611            groups,
2612        }
2613    }
2614
2615    #[getter]
2616    pub fn edges_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
2617        self.edges_dataframes.clone_ref(py)
2618    }
2619
2620    #[getter]
2621    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
2622        self.groups.clone_ref(py)
2623    }
2624}
2625
2626#[pyclass(frozen)]
2627#[derive(Debug)]
2628pub struct PyPostAddEdgesDataframesWithGroupsContext {
2629    edges_dataframes: Py<PyAny>,
2630    groups: Py<PyAny>,
2631}
2632
2633impl Clone for PyPostAddEdgesDataframesWithGroupsContext {
2634    fn clone(&self) -> Self {
2635        Python::attach(|py| Self {
2636            edges_dataframes: self.edges_dataframes.clone_ref(py),
2637            groups: self.groups.clone_ref(py),
2638        })
2639    }
2640}
2641
2642impl PyPostAddEdgesDataframesWithGroupsContext {
2643    /// # Panics
2644    ///
2645    /// Panics if the python typing was not followed.
2646    pub fn bind(py: Python<'_>, context: PostAddEdgesDataframesWithGroupsContext) -> Self {
2647        let edges_dataframes = edge_dataframe_inputs_to_py(context.edges_dataframes);
2648        let groups: Vec<PyGroup> = context.groups.deep_into();
2649
2650        Self {
2651            edges_dataframes: edges_dataframes
2652                .into_py_any(py)
2653                .expect("edges_dataframes should be creatable"),
2654            groups: groups.into_py_any(py).expect("groups should be creatable"),
2655        }
2656    }
2657}
2658
2659#[pymethods]
2660impl PyPostAddEdgesDataframesWithGroupsContext {
2661    #[new]
2662    pub const fn new(edges_dataframes: Py<PyAny>, groups: Py<PyAny>) -> Self {
2663        Self {
2664            edges_dataframes,
2665            groups,
2666        }
2667    }
2668
2669    #[getter]
2670    pub fn edges_dataframes(&self, py: Python<'_>) -> Py<PyAny> {
2671        self.edges_dataframes.clone_ref(py)
2672    }
2673
2674    #[getter]
2675    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
2676        self.groups.clone_ref(py)
2677    }
2678}
2679
2680#[pyclass(frozen)]
2681#[derive(Debug)]
2682pub struct PyPreAddGroupContext {
2683    group: Py<PyAny>,
2684    node_indices: Py<PyAny>,
2685    edge_indices: Py<PyAny>,
2686}
2687
2688impl Clone for PyPreAddGroupContext {
2689    fn clone(&self) -> Self {
2690        Python::attach(|py| Self {
2691            group: self.group.clone_ref(py),
2692            node_indices: self.node_indices.clone_ref(py),
2693            edge_indices: self.edge_indices.clone_ref(py),
2694        })
2695    }
2696}
2697
2698impl PyPreAddGroupContext {
2699    /// # Panics
2700    ///
2701    /// Panics if the python typing was not followed.
2702    pub fn bind(py: Python<'_>, context: PreAddGroupContext) -> Self {
2703        let node_indices: Option<Vec<PyNodeIndex>> = context.node_indices.deep_into();
2704
2705        Self {
2706            group: PyGroup::from(context.group)
2707                .into_py_any(py)
2708                .expect("PyGroup should be creatable"),
2709            node_indices: node_indices
2710                .into_py_any(py)
2711                .expect("node_indices should be creatable"),
2712            edge_indices: context
2713                .edge_indices
2714                .into_py_any(py)
2715                .expect("edge_indices should be creatable"),
2716        }
2717    }
2718
2719    /// # Panics
2720    ///
2721    /// Panics if the python typing was not followed.
2722    pub fn extract(self, py: Python<'_>) -> PreAddGroupContext {
2723        let group: PyGroup = self
2724            .group
2725            .extract(py)
2726            .expect("PyGroup should be extractable");
2727
2728        let node_indices: Option<Vec<PyNodeIndex>> = self
2729            .node_indices
2730            .extract(py)
2731            .expect("node_indices should be extractable");
2732
2733        let edge_indices: Option<Vec<EdgeIndex>> = self
2734            .edge_indices
2735            .extract(py)
2736            .expect("edge_indices should be extractable");
2737
2738        PreAddGroupContext {
2739            group: group.into(),
2740            node_indices: node_indices.deep_into(),
2741            edge_indices,
2742        }
2743    }
2744}
2745
2746#[pymethods]
2747impl PyPreAddGroupContext {
2748    #[new]
2749    pub const fn new(group: Py<PyAny>, node_indices: Py<PyAny>, edge_indices: Py<PyAny>) -> Self {
2750        Self {
2751            group,
2752            node_indices,
2753            edge_indices,
2754        }
2755    }
2756
2757    #[getter]
2758    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2759        self.group.clone_ref(py)
2760    }
2761
2762    #[getter]
2763    pub fn node_indices(&self, py: Python<'_>) -> Py<PyAny> {
2764        self.node_indices.clone_ref(py)
2765    }
2766
2767    #[getter]
2768    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
2769        self.edge_indices.clone_ref(py)
2770    }
2771}
2772
2773#[pyclass(frozen)]
2774#[derive(Debug)]
2775pub struct PyPostAddGroupContext {
2776    group: Py<PyAny>,
2777    node_indices: Py<PyAny>,
2778    edge_indices: Py<PyAny>,
2779}
2780
2781impl Clone for PyPostAddGroupContext {
2782    fn clone(&self) -> Self {
2783        Python::attach(|py| Self {
2784            group: self.group.clone_ref(py),
2785            node_indices: self.node_indices.clone_ref(py),
2786            edge_indices: self.edge_indices.clone_ref(py),
2787        })
2788    }
2789}
2790
2791impl PyPostAddGroupContext {
2792    /// # Panics
2793    ///
2794    /// Panics if the python typing was not followed.
2795    pub fn bind(py: Python<'_>, context: PostAddGroupContext) -> Self {
2796        let node_indices: Option<Vec<PyNodeIndex>> = context.node_indices.deep_into();
2797
2798        Self {
2799            group: PyGroup::from(context.group)
2800                .into_py_any(py)
2801                .expect("PyGroup should be creatable"),
2802            node_indices: node_indices
2803                .into_py_any(py)
2804                .expect("node_indices should be creatable"),
2805            edge_indices: context
2806                .edge_indices
2807                .into_py_any(py)
2808                .expect("edge_indices should be creatable"),
2809        }
2810    }
2811}
2812
2813#[pymethods]
2814impl PyPostAddGroupContext {
2815    #[new]
2816    pub const fn new(group: Py<PyAny>, node_indices: Py<PyAny>, edge_indices: Py<PyAny>) -> Self {
2817        Self {
2818            group,
2819            node_indices,
2820            edge_indices,
2821        }
2822    }
2823
2824    #[getter]
2825    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2826        self.group.clone_ref(py)
2827    }
2828
2829    #[getter]
2830    pub fn node_indices(&self, py: Python<'_>) -> Py<PyAny> {
2831        self.node_indices.clone_ref(py)
2832    }
2833
2834    #[getter]
2835    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
2836        self.edge_indices.clone_ref(py)
2837    }
2838}
2839
2840#[pyclass(frozen)]
2841#[derive(Debug)]
2842pub struct PyPreRemoveGroupContext {
2843    group: Py<PyAny>,
2844}
2845
2846impl Clone for PyPreRemoveGroupContext {
2847    fn clone(&self) -> Self {
2848        Python::attach(|py| Self {
2849            group: self.group.clone_ref(py),
2850        })
2851    }
2852}
2853
2854impl PyPreRemoveGroupContext {
2855    /// # Panics
2856    ///
2857    /// Panics if the python typing was not followed.
2858    pub fn bind(py: Python<'_>, context: PreRemoveGroupContext) -> Self {
2859        Self {
2860            group: PyGroup::from(context.group)
2861                .into_py_any(py)
2862                .expect("PyGroup should be creatable"),
2863        }
2864    }
2865
2866    /// # Panics
2867    ///
2868    /// Panics if the python typing was not followed.
2869    pub fn extract(self, py: Python<'_>) -> PreRemoveGroupContext {
2870        let group: PyGroup = self
2871            .group
2872            .extract(py)
2873            .expect("PyGroup should be extractable");
2874
2875        PreRemoveGroupContext {
2876            group: group.into(),
2877        }
2878    }
2879}
2880
2881#[pymethods]
2882impl PyPreRemoveGroupContext {
2883    #[new]
2884    pub const fn new(group: Py<PyAny>) -> Self {
2885        Self { group }
2886    }
2887
2888    #[getter]
2889    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2890        self.group.clone_ref(py)
2891    }
2892}
2893
2894#[pyclass(frozen)]
2895#[derive(Debug)]
2896pub struct PyPostRemoveGroupContext {
2897    group: Py<PyAny>,
2898}
2899
2900impl Clone for PyPostRemoveGroupContext {
2901    fn clone(&self) -> Self {
2902        Python::attach(|py| Self {
2903            group: self.group.clone_ref(py),
2904        })
2905    }
2906}
2907
2908impl PyPostRemoveGroupContext {
2909    /// # Panics
2910    ///
2911    /// Panics if the python typing was not followed.
2912    pub fn bind(py: Python<'_>, context: PostRemoveGroupContext) -> Self {
2913        Self {
2914            group: PyGroup::from(context.group)
2915                .into_py_any(py)
2916                .expect("PyGroup should be creatable"),
2917        }
2918    }
2919}
2920
2921#[pymethods]
2922impl PyPostRemoveGroupContext {
2923    #[new]
2924    pub const fn new(group: Py<PyAny>) -> Self {
2925        Self { group }
2926    }
2927
2928    #[getter]
2929    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2930        self.group.clone_ref(py)
2931    }
2932}
2933
2934#[pyclass(frozen)]
2935#[derive(Debug)]
2936pub struct PyPreAddNodeToGroupContext {
2937    group: Py<PyAny>,
2938    node_index: Py<PyAny>,
2939}
2940
2941impl Clone for PyPreAddNodeToGroupContext {
2942    fn clone(&self) -> Self {
2943        Python::attach(|py| Self {
2944            group: self.group.clone_ref(py),
2945            node_index: self.node_index.clone_ref(py),
2946        })
2947    }
2948}
2949
2950impl PyPreAddNodeToGroupContext {
2951    /// # Panics
2952    ///
2953    /// Panics if the python typing was not followed.
2954    pub fn bind(py: Python<'_>, context: PreAddNodeToGroupContext) -> Self {
2955        Self {
2956            group: PyGroup::from(context.group)
2957                .into_py_any(py)
2958                .expect("PyGroup should be creatable"),
2959            node_index: PyNodeIndex::from(context.node_index)
2960                .into_py_any(py)
2961                .expect("PyNodeIndex should be creatable"),
2962        }
2963    }
2964
2965    /// # Panics
2966    ///
2967    /// Panics if the python typing was not followed.
2968    pub fn extract(self, py: Python<'_>) -> PreAddNodeToGroupContext {
2969        let group: PyGroup = self
2970            .group
2971            .extract(py)
2972            .expect("PyGroup should be extractable");
2973
2974        let node_index: PyNodeIndex = self
2975            .node_index
2976            .extract(py)
2977            .expect("PyNodeIndex should be extractable");
2978
2979        PreAddNodeToGroupContext {
2980            group: group.into(),
2981            node_index: node_index.into(),
2982        }
2983    }
2984}
2985
2986#[pymethods]
2987impl PyPreAddNodeToGroupContext {
2988    #[new]
2989    pub const fn new(group: Py<PyAny>, node_index: Py<PyAny>) -> Self {
2990        Self { group, node_index }
2991    }
2992
2993    #[getter]
2994    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
2995        self.group.clone_ref(py)
2996    }
2997
2998    #[getter]
2999    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3000        self.node_index.clone_ref(py)
3001    }
3002}
3003
3004#[pyclass(frozen)]
3005#[derive(Debug)]
3006pub struct PyPostAddNodeToGroupContext {
3007    group: Py<PyAny>,
3008    node_index: Py<PyAny>,
3009}
3010
3011impl Clone for PyPostAddNodeToGroupContext {
3012    fn clone(&self) -> Self {
3013        Python::attach(|py| Self {
3014            group: self.group.clone_ref(py),
3015            node_index: self.node_index.clone_ref(py),
3016        })
3017    }
3018}
3019
3020impl PyPostAddNodeToGroupContext {
3021    /// # Panics
3022    ///
3023    /// Panics if the python typing was not followed.
3024    pub fn bind(py: Python<'_>, context: PostAddNodeToGroupContext) -> Self {
3025        Self {
3026            group: PyGroup::from(context.group)
3027                .into_py_any(py)
3028                .expect("PyGroup should be creatable"),
3029            node_index: PyNodeIndex::from(context.node_index)
3030                .into_py_any(py)
3031                .expect("PyNodeIndex should be creatable"),
3032        }
3033    }
3034}
3035
3036#[pymethods]
3037impl PyPostAddNodeToGroupContext {
3038    #[new]
3039    pub const fn new(group: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3040        Self { group, node_index }
3041    }
3042
3043    #[getter]
3044    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
3045        self.group.clone_ref(py)
3046    }
3047
3048    #[getter]
3049    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3050        self.node_index.clone_ref(py)
3051    }
3052}
3053
3054#[pyclass(frozen)]
3055#[derive(Debug)]
3056pub struct PyPreAddNodeToGroupsContext {
3057    groups: Py<PyAny>,
3058    node_index: Py<PyAny>,
3059}
3060
3061impl Clone for PyPreAddNodeToGroupsContext {
3062    fn clone(&self) -> Self {
3063        Python::attach(|py| Self {
3064            groups: self.groups.clone_ref(py),
3065            node_index: self.node_index.clone_ref(py),
3066        })
3067    }
3068}
3069
3070impl PyPreAddNodeToGroupsContext {
3071    /// # Panics
3072    ///
3073    /// Panics if the python typing was not followed.
3074    pub fn bind(py: Python<'_>, context: PreAddNodeToGroupsContext) -> Self {
3075        let groups: Vec<PyGroup> = context.groups.deep_into();
3076
3077        Self {
3078            groups: groups.into_py_any(py).expect("groups should be creatable"),
3079            node_index: PyNodeIndex::from(context.node_index)
3080                .into_py_any(py)
3081                .expect("PyNodeIndex should be creatable"),
3082        }
3083    }
3084
3085    /// # Panics
3086    ///
3087    /// Panics if the python typing was not followed.
3088    pub fn extract(self, py: Python<'_>) -> PreAddNodeToGroupsContext {
3089        let groups: Vec<PyGroup> = self
3090            .groups
3091            .extract(py)
3092            .expect("groups should be extractable");
3093
3094        let node_index: PyNodeIndex = self
3095            .node_index
3096            .extract(py)
3097            .expect("PyNodeIndex should be extractable");
3098
3099        PreAddNodeToGroupsContext {
3100            groups: groups.deep_into(),
3101            node_index: node_index.into(),
3102        }
3103    }
3104}
3105
3106#[pymethods]
3107impl PyPreAddNodeToGroupsContext {
3108    #[new]
3109    pub const fn new(groups: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3110        Self { groups, node_index }
3111    }
3112
3113    #[getter]
3114    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3115        self.groups.clone_ref(py)
3116    }
3117
3118    #[getter]
3119    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3120        self.node_index.clone_ref(py)
3121    }
3122}
3123
3124#[pyclass(frozen)]
3125#[derive(Debug)]
3126pub struct PyPostAddNodeToGroupsContext {
3127    groups: Py<PyAny>,
3128    node_index: Py<PyAny>,
3129}
3130
3131impl Clone for PyPostAddNodeToGroupsContext {
3132    fn clone(&self) -> Self {
3133        Python::attach(|py| Self {
3134            groups: self.groups.clone_ref(py),
3135            node_index: self.node_index.clone_ref(py),
3136        })
3137    }
3138}
3139
3140impl PyPostAddNodeToGroupsContext {
3141    /// # Panics
3142    ///
3143    /// Panics if the python typing was not followed.
3144    pub fn bind(py: Python<'_>, context: PostAddNodeToGroupsContext) -> Self {
3145        let groups: Vec<PyGroup> = context.groups.deep_into();
3146
3147        Self {
3148            groups: groups.into_py_any(py).expect("groups should be creatable"),
3149            node_index: PyNodeIndex::from(context.node_index)
3150                .into_py_any(py)
3151                .expect("PyNodeIndex should be creatable"),
3152        }
3153    }
3154}
3155
3156#[pymethods]
3157impl PyPostAddNodeToGroupsContext {
3158    #[new]
3159    pub const fn new(groups: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3160        Self { groups, node_index }
3161    }
3162
3163    #[getter]
3164    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3165        self.groups.clone_ref(py)
3166    }
3167
3168    #[getter]
3169    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3170        self.node_index.clone_ref(py)
3171    }
3172}
3173
3174#[pyclass(frozen)]
3175#[derive(Debug)]
3176pub struct PyPreAddNodesToGroupsContext {
3177    groups: Py<PyAny>,
3178    node_indices: Py<PyAny>,
3179}
3180
3181impl Clone for PyPreAddNodesToGroupsContext {
3182    fn clone(&self) -> Self {
3183        Python::attach(|py| Self {
3184            groups: self.groups.clone_ref(py),
3185            node_indices: self.node_indices.clone_ref(py),
3186        })
3187    }
3188}
3189
3190impl PyPreAddNodesToGroupsContext {
3191    /// # Panics
3192    ///
3193    /// Panics if the python typing was not followed.
3194    pub fn bind(py: Python<'_>, context: PreAddNodesToGroupsContext) -> Self {
3195        let groups: Vec<PyGroup> = context.groups.deep_into();
3196        let node_indices: Vec<PyNodeIndex> = context.node_indices.deep_into();
3197
3198        Self {
3199            groups: groups.into_py_any(py).expect("groups should be creatable"),
3200            node_indices: node_indices
3201                .into_py_any(py)
3202                .expect("node_indices should be creatable"),
3203        }
3204    }
3205
3206    /// # Panics
3207    ///
3208    /// Panics if the python typing was not followed.
3209    pub fn extract(self, py: Python<'_>) -> PreAddNodesToGroupsContext {
3210        let groups: Vec<PyGroup> = self
3211            .groups
3212            .extract(py)
3213            .expect("groups should be extractable");
3214
3215        let node_indices: Vec<PyNodeIndex> = self
3216            .node_indices
3217            .extract(py)
3218            .expect("node_indices should be extractable");
3219
3220        PreAddNodesToGroupsContext {
3221            groups: groups.deep_into(),
3222            node_indices: node_indices.deep_into(),
3223        }
3224    }
3225}
3226
3227#[pymethods]
3228impl PyPreAddNodesToGroupsContext {
3229    #[new]
3230    pub const fn new(groups: Py<PyAny>, node_indices: Py<PyAny>) -> Self {
3231        Self {
3232            groups,
3233            node_indices,
3234        }
3235    }
3236
3237    #[getter]
3238    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3239        self.groups.clone_ref(py)
3240    }
3241
3242    #[getter]
3243    pub fn node_indices(&self, py: Python<'_>) -> Py<PyAny> {
3244        self.node_indices.clone_ref(py)
3245    }
3246}
3247
3248#[pyclass(frozen)]
3249#[derive(Debug)]
3250pub struct PyPostAddNodesToGroupsContext {
3251    groups: Py<PyAny>,
3252    node_indices: Py<PyAny>,
3253}
3254
3255impl Clone for PyPostAddNodesToGroupsContext {
3256    fn clone(&self) -> Self {
3257        Python::attach(|py| Self {
3258            groups: self.groups.clone_ref(py),
3259            node_indices: self.node_indices.clone_ref(py),
3260        })
3261    }
3262}
3263
3264impl PyPostAddNodesToGroupsContext {
3265    /// # Panics
3266    ///
3267    /// Panics if the python typing was not followed.
3268    pub fn bind(py: Python<'_>, context: PostAddNodesToGroupsContext) -> Self {
3269        let groups: Vec<PyGroup> = context.groups.deep_into();
3270        let node_indices: Vec<PyNodeIndex> = context.node_indices.deep_into();
3271
3272        Self {
3273            groups: groups.into_py_any(py).expect("groups should be creatable"),
3274            node_indices: node_indices
3275                .into_py_any(py)
3276                .expect("node_indices should be creatable"),
3277        }
3278    }
3279}
3280
3281#[pymethods]
3282impl PyPostAddNodesToGroupsContext {
3283    #[new]
3284    pub const fn new(groups: Py<PyAny>, node_indices: Py<PyAny>) -> Self {
3285        Self {
3286            groups,
3287            node_indices,
3288        }
3289    }
3290
3291    #[getter]
3292    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3293        self.groups.clone_ref(py)
3294    }
3295
3296    #[getter]
3297    pub fn node_indices(&self, py: Python<'_>) -> Py<PyAny> {
3298        self.node_indices.clone_ref(py)
3299    }
3300}
3301
3302#[pyclass(frozen)]
3303#[derive(Debug)]
3304pub struct PyPreAddEdgeToGroupContext {
3305    group: Py<PyAny>,
3306    edge_index: Py<PyAny>,
3307}
3308
3309impl Clone for PyPreAddEdgeToGroupContext {
3310    fn clone(&self) -> Self {
3311        Python::attach(|py| Self {
3312            group: self.group.clone_ref(py),
3313            edge_index: self.edge_index.clone_ref(py),
3314        })
3315    }
3316}
3317
3318impl PyPreAddEdgeToGroupContext {
3319    /// # Panics
3320    ///
3321    /// Panics if the python typing was not followed.
3322    pub fn bind(py: Python<'_>, context: PreAddEdgeToGroupContext) -> Self {
3323        Self {
3324            group: PyGroup::from(context.group)
3325                .into_py_any(py)
3326                .expect("PyGroup should be creatable"),
3327            edge_index: context
3328                .edge_index
3329                .into_py_any(py)
3330                .expect("edge_index should be creatable"),
3331        }
3332    }
3333
3334    /// # Panics
3335    ///
3336    /// Panics if the python typing was not followed.
3337    pub fn extract(self, py: Python<'_>) -> PreAddEdgeToGroupContext {
3338        let group: PyGroup = self
3339            .group
3340            .extract(py)
3341            .expect("PyGroup should be extractable");
3342
3343        PreAddEdgeToGroupContext {
3344            group: group.into(),
3345            edge_index: self
3346                .edge_index
3347                .extract(py)
3348                .expect("edge_index should be extractable"),
3349        }
3350    }
3351}
3352
3353#[pymethods]
3354impl PyPreAddEdgeToGroupContext {
3355    #[new]
3356    pub const fn new(group: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
3357        Self { group, edge_index }
3358    }
3359
3360    #[getter]
3361    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
3362        self.group.clone_ref(py)
3363    }
3364
3365    #[getter]
3366    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
3367        self.edge_index.clone_ref(py)
3368    }
3369}
3370
3371#[pyclass(frozen)]
3372#[derive(Debug)]
3373pub struct PyPostAddEdgeToGroupContext {
3374    group: Py<PyAny>,
3375    edge_index: Py<PyAny>,
3376}
3377
3378impl Clone for PyPostAddEdgeToGroupContext {
3379    fn clone(&self) -> Self {
3380        Python::attach(|py| Self {
3381            group: self.group.clone_ref(py),
3382            edge_index: self.edge_index.clone_ref(py),
3383        })
3384    }
3385}
3386
3387impl PyPostAddEdgeToGroupContext {
3388    /// # Panics
3389    ///
3390    /// Panics if the python typing was not followed.
3391    pub fn bind(py: Python<'_>, context: PostAddEdgeToGroupContext) -> Self {
3392        Self {
3393            group: PyGroup::from(context.group)
3394                .into_py_any(py)
3395                .expect("PyGroup should be creatable"),
3396            edge_index: context
3397                .edge_index
3398                .into_py_any(py)
3399                .expect("edge_index should be creatable"),
3400        }
3401    }
3402}
3403
3404#[pymethods]
3405impl PyPostAddEdgeToGroupContext {
3406    #[new]
3407    pub const fn new(group: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
3408        Self { group, edge_index }
3409    }
3410
3411    #[getter]
3412    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
3413        self.group.clone_ref(py)
3414    }
3415
3416    #[getter]
3417    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
3418        self.edge_index.clone_ref(py)
3419    }
3420}
3421
3422#[pyclass(frozen)]
3423#[derive(Debug)]
3424pub struct PyPreAddEdgeToGroupsContext {
3425    groups: Py<PyAny>,
3426    edge_index: Py<PyAny>,
3427}
3428
3429impl Clone for PyPreAddEdgeToGroupsContext {
3430    fn clone(&self) -> Self {
3431        Python::attach(|py| Self {
3432            groups: self.groups.clone_ref(py),
3433            edge_index: self.edge_index.clone_ref(py),
3434        })
3435    }
3436}
3437
3438impl PyPreAddEdgeToGroupsContext {
3439    /// # Panics
3440    ///
3441    /// Panics if the python typing was not followed.
3442    pub fn bind(py: Python<'_>, context: PreAddEdgeToGroupsContext) -> Self {
3443        let groups: Vec<PyGroup> = context.groups.deep_into();
3444
3445        Self {
3446            groups: groups.into_py_any(py).expect("groups should be creatable"),
3447            edge_index: context
3448                .edge_index
3449                .into_py_any(py)
3450                .expect("edge_index should be creatable"),
3451        }
3452    }
3453
3454    /// # Panics
3455    ///
3456    /// Panics if the python typing was not followed.
3457    pub fn extract(self, py: Python<'_>) -> PreAddEdgeToGroupsContext {
3458        let groups: Vec<PyGroup> = self
3459            .groups
3460            .extract(py)
3461            .expect("groups should be extractable");
3462
3463        PreAddEdgeToGroupsContext {
3464            groups: groups.deep_into(),
3465            edge_index: self
3466                .edge_index
3467                .extract(py)
3468                .expect("edge_index should be extractable"),
3469        }
3470    }
3471}
3472
3473#[pymethods]
3474impl PyPreAddEdgeToGroupsContext {
3475    #[new]
3476    pub const fn new(groups: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
3477        Self { groups, edge_index }
3478    }
3479
3480    #[getter]
3481    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3482        self.groups.clone_ref(py)
3483    }
3484
3485    #[getter]
3486    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
3487        self.edge_index.clone_ref(py)
3488    }
3489}
3490
3491#[pyclass(frozen)]
3492#[derive(Debug)]
3493pub struct PyPostAddEdgeToGroupsContext {
3494    groups: Py<PyAny>,
3495    edge_index: Py<PyAny>,
3496}
3497
3498impl Clone for PyPostAddEdgeToGroupsContext {
3499    fn clone(&self) -> Self {
3500        Python::attach(|py| Self {
3501            groups: self.groups.clone_ref(py),
3502            edge_index: self.edge_index.clone_ref(py),
3503        })
3504    }
3505}
3506
3507impl PyPostAddEdgeToGroupsContext {
3508    /// # Panics
3509    ///
3510    /// Panics if the python typing was not followed.
3511    pub fn bind(py: Python<'_>, context: PostAddEdgeToGroupsContext) -> Self {
3512        let groups: Vec<PyGroup> = context.groups.deep_into();
3513
3514        Self {
3515            groups: groups.into_py_any(py).expect("groups should be creatable"),
3516            edge_index: context
3517                .edge_index
3518                .into_py_any(py)
3519                .expect("edge_index should be creatable"),
3520        }
3521    }
3522}
3523
3524#[pymethods]
3525impl PyPostAddEdgeToGroupsContext {
3526    #[new]
3527    pub const fn new(groups: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
3528        Self { groups, edge_index }
3529    }
3530
3531    #[getter]
3532    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3533        self.groups.clone_ref(py)
3534    }
3535
3536    #[getter]
3537    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
3538        self.edge_index.clone_ref(py)
3539    }
3540}
3541
3542#[pyclass(frozen)]
3543#[derive(Debug)]
3544pub struct PyPreAddEdgesToGroupsContext {
3545    groups: Py<PyAny>,
3546    edge_indices: Py<PyAny>,
3547}
3548
3549impl Clone for PyPreAddEdgesToGroupsContext {
3550    fn clone(&self) -> Self {
3551        Python::attach(|py| Self {
3552            groups: self.groups.clone_ref(py),
3553            edge_indices: self.edge_indices.clone_ref(py),
3554        })
3555    }
3556}
3557
3558impl PyPreAddEdgesToGroupsContext {
3559    /// # Panics
3560    ///
3561    /// Panics if the python typing was not followed.
3562    pub fn bind(py: Python<'_>, context: PreAddEdgesToGroupsContext) -> Self {
3563        let groups: Vec<PyGroup> = context.groups.deep_into();
3564
3565        Self {
3566            groups: groups.into_py_any(py).expect("groups should be creatable"),
3567            edge_indices: context
3568                .edge_indices
3569                .into_py_any(py)
3570                .expect("edge_indices should be creatable"),
3571        }
3572    }
3573
3574    /// # Panics
3575    ///
3576    /// Panics if the python typing was not followed.
3577    pub fn extract(self, py: Python<'_>) -> PreAddEdgesToGroupsContext {
3578        let groups: Vec<PyGroup> = self
3579            .groups
3580            .extract(py)
3581            .expect("groups should be extractable");
3582
3583        PreAddEdgesToGroupsContext {
3584            groups: groups.deep_into(),
3585            edge_indices: self
3586                .edge_indices
3587                .extract(py)
3588                .expect("edge_indices should be extractable"),
3589        }
3590    }
3591}
3592
3593#[pymethods]
3594impl PyPreAddEdgesToGroupsContext {
3595    #[new]
3596    pub const fn new(groups: Py<PyAny>, edge_indices: Py<PyAny>) -> Self {
3597        Self {
3598            groups,
3599            edge_indices,
3600        }
3601    }
3602
3603    #[getter]
3604    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3605        self.groups.clone_ref(py)
3606    }
3607
3608    #[getter]
3609    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
3610        self.edge_indices.clone_ref(py)
3611    }
3612}
3613
3614#[pyclass(frozen)]
3615#[derive(Debug)]
3616pub struct PyPostAddEdgesToGroupsContext {
3617    groups: Py<PyAny>,
3618    edge_indices: Py<PyAny>,
3619}
3620
3621impl Clone for PyPostAddEdgesToGroupsContext {
3622    fn clone(&self) -> Self {
3623        Python::attach(|py| Self {
3624            groups: self.groups.clone_ref(py),
3625            edge_indices: self.edge_indices.clone_ref(py),
3626        })
3627    }
3628}
3629
3630impl PyPostAddEdgesToGroupsContext {
3631    /// # Panics
3632    ///
3633    /// Panics if the python typing was not followed.
3634    pub fn bind(py: Python<'_>, context: PostAddEdgesToGroupsContext) -> Self {
3635        let groups: Vec<PyGroup> = context.groups.deep_into();
3636
3637        Self {
3638            groups: groups.into_py_any(py).expect("groups should be creatable"),
3639            edge_indices: context
3640                .edge_indices
3641                .into_py_any(py)
3642                .expect("edge_indices should be creatable"),
3643        }
3644    }
3645}
3646
3647#[pymethods]
3648impl PyPostAddEdgesToGroupsContext {
3649    #[new]
3650    pub const fn new(groups: Py<PyAny>, edge_indices: Py<PyAny>) -> Self {
3651        Self {
3652            groups,
3653            edge_indices,
3654        }
3655    }
3656
3657    #[getter]
3658    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3659        self.groups.clone_ref(py)
3660    }
3661
3662    #[getter]
3663    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
3664        self.edge_indices.clone_ref(py)
3665    }
3666}
3667
3668#[pyclass(frozen)]
3669#[derive(Debug)]
3670pub struct PyPreRemoveNodeFromGroupContext {
3671    group: Py<PyAny>,
3672    node_index: Py<PyAny>,
3673}
3674
3675impl Clone for PyPreRemoveNodeFromGroupContext {
3676    fn clone(&self) -> Self {
3677        Python::attach(|py| Self {
3678            group: self.group.clone_ref(py),
3679            node_index: self.node_index.clone_ref(py),
3680        })
3681    }
3682}
3683
3684impl PyPreRemoveNodeFromGroupContext {
3685    /// # Panics
3686    ///
3687    /// Panics if the python typing was not followed.
3688    pub fn bind(py: Python<'_>, context: PreRemoveNodeFromGroupContext) -> Self {
3689        Self {
3690            group: PyGroup::from(context.group)
3691                .into_py_any(py)
3692                .expect("PyGroup should be creatable"),
3693            node_index: PyNodeIndex::from(context.node_index)
3694                .into_py_any(py)
3695                .expect("PyNodeIndex should be creatable"),
3696        }
3697    }
3698
3699    /// # Panics
3700    ///
3701    /// Panics if the python typing was not followed.
3702    pub fn extract(self, py: Python<'_>) -> PreRemoveNodeFromGroupContext {
3703        let group: PyGroup = self
3704            .group
3705            .extract(py)
3706            .expect("PyGroup should be extractable");
3707
3708        let node_index: PyNodeIndex = self
3709            .node_index
3710            .extract(py)
3711            .expect("PyNodeIndex should be extractable");
3712
3713        PreRemoveNodeFromGroupContext {
3714            group: group.into(),
3715            node_index: node_index.into(),
3716        }
3717    }
3718}
3719
3720#[pymethods]
3721impl PyPreRemoveNodeFromGroupContext {
3722    #[new]
3723    pub const fn new(group: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3724        Self { group, node_index }
3725    }
3726
3727    #[getter]
3728    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
3729        self.group.clone_ref(py)
3730    }
3731
3732    #[getter]
3733    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3734        self.node_index.clone_ref(py)
3735    }
3736}
3737
3738#[pyclass(frozen)]
3739#[derive(Debug)]
3740pub struct PyPostRemoveNodeFromGroupContext {
3741    group: Py<PyAny>,
3742    node_index: Py<PyAny>,
3743}
3744
3745impl Clone for PyPostRemoveNodeFromGroupContext {
3746    fn clone(&self) -> Self {
3747        Python::attach(|py| Self {
3748            group: self.group.clone_ref(py),
3749            node_index: self.node_index.clone_ref(py),
3750        })
3751    }
3752}
3753
3754impl PyPostRemoveNodeFromGroupContext {
3755    /// # Panics
3756    ///
3757    /// Panics if the python typing was not followed.
3758    pub fn bind(py: Python<'_>, context: PostRemoveNodeFromGroupContext) -> Self {
3759        Self {
3760            group: PyGroup::from(context.group)
3761                .into_py_any(py)
3762                .expect("PyGroup should be creatable"),
3763            node_index: PyNodeIndex::from(context.node_index)
3764                .into_py_any(py)
3765                .expect("PyNodeIndex should be creatable"),
3766        }
3767    }
3768}
3769
3770#[pymethods]
3771impl PyPostRemoveNodeFromGroupContext {
3772    #[new]
3773    pub const fn new(group: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3774        Self { group, node_index }
3775    }
3776
3777    #[getter]
3778    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
3779        self.group.clone_ref(py)
3780    }
3781
3782    #[getter]
3783    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3784        self.node_index.clone_ref(py)
3785    }
3786}
3787
3788#[pyclass(frozen)]
3789#[derive(Debug)]
3790pub struct PyPreRemoveNodeFromGroupsContext {
3791    groups: Py<PyAny>,
3792    node_index: Py<PyAny>,
3793}
3794
3795impl Clone for PyPreRemoveNodeFromGroupsContext {
3796    fn clone(&self) -> Self {
3797        Python::attach(|py| Self {
3798            groups: self.groups.clone_ref(py),
3799            node_index: self.node_index.clone_ref(py),
3800        })
3801    }
3802}
3803
3804impl PyPreRemoveNodeFromGroupsContext {
3805    /// # Panics
3806    ///
3807    /// Panics if the python typing was not followed.
3808    pub fn bind(py: Python<'_>, context: PreRemoveNodeFromGroupsContext) -> Self {
3809        let groups: Vec<PyGroup> = context.groups.deep_into();
3810
3811        Self {
3812            groups: groups.into_py_any(py).expect("groups should be creatable"),
3813            node_index: PyNodeIndex::from(context.node_index)
3814                .into_py_any(py)
3815                .expect("PyNodeIndex should be creatable"),
3816        }
3817    }
3818
3819    /// # Panics
3820    ///
3821    /// Panics if the python typing was not followed.
3822    pub fn extract(self, py: Python<'_>) -> PreRemoveNodeFromGroupsContext {
3823        let groups: Vec<PyGroup> = self
3824            .groups
3825            .extract(py)
3826            .expect("groups should be extractable");
3827
3828        let node_index: PyNodeIndex = self
3829            .node_index
3830            .extract(py)
3831            .expect("PyNodeIndex should be extractable");
3832
3833        PreRemoveNodeFromGroupsContext {
3834            groups: groups.deep_into(),
3835            node_index: node_index.into(),
3836        }
3837    }
3838}
3839
3840#[pymethods]
3841impl PyPreRemoveNodeFromGroupsContext {
3842    #[new]
3843    pub const fn new(groups: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3844        Self { groups, node_index }
3845    }
3846
3847    #[getter]
3848    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3849        self.groups.clone_ref(py)
3850    }
3851
3852    #[getter]
3853    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3854        self.node_index.clone_ref(py)
3855    }
3856}
3857
3858#[pyclass(frozen)]
3859#[derive(Debug)]
3860pub struct PyPostRemoveNodeFromGroupsContext {
3861    groups: Py<PyAny>,
3862    node_index: Py<PyAny>,
3863}
3864
3865impl Clone for PyPostRemoveNodeFromGroupsContext {
3866    fn clone(&self) -> Self {
3867        Python::attach(|py| Self {
3868            groups: self.groups.clone_ref(py),
3869            node_index: self.node_index.clone_ref(py),
3870        })
3871    }
3872}
3873
3874impl PyPostRemoveNodeFromGroupsContext {
3875    /// # Panics
3876    ///
3877    /// Panics if the python typing was not followed.
3878    pub fn bind(py: Python<'_>, context: PostRemoveNodeFromGroupsContext) -> Self {
3879        let groups: Vec<PyGroup> = context.groups.deep_into();
3880
3881        Self {
3882            groups: groups.into_py_any(py).expect("groups should be creatable"),
3883            node_index: PyNodeIndex::from(context.node_index)
3884                .into_py_any(py)
3885                .expect("PyNodeIndex should be creatable"),
3886        }
3887    }
3888}
3889
3890#[pymethods]
3891impl PyPostRemoveNodeFromGroupsContext {
3892    #[new]
3893    pub const fn new(groups: Py<PyAny>, node_index: Py<PyAny>) -> Self {
3894        Self { groups, node_index }
3895    }
3896
3897    #[getter]
3898    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3899        self.groups.clone_ref(py)
3900    }
3901
3902    #[getter]
3903    pub fn node_index(&self, py: Python<'_>) -> Py<PyAny> {
3904        self.node_index.clone_ref(py)
3905    }
3906}
3907
3908#[pyclass(frozen)]
3909#[derive(Debug)]
3910pub struct PyPreRemoveNodesFromGroupsContext {
3911    groups: Py<PyAny>,
3912    node_indices: Py<PyAny>,
3913}
3914
3915impl Clone for PyPreRemoveNodesFromGroupsContext {
3916    fn clone(&self) -> Self {
3917        Python::attach(|py| Self {
3918            groups: self.groups.clone_ref(py),
3919            node_indices: self.node_indices.clone_ref(py),
3920        })
3921    }
3922}
3923
3924impl PyPreRemoveNodesFromGroupsContext {
3925    /// # Panics
3926    ///
3927    /// Panics if the python typing was not followed.
3928    pub fn bind(py: Python<'_>, context: PreRemoveNodesFromGroupsContext) -> Self {
3929        let groups: Vec<PyGroup> = context.groups.deep_into();
3930        let node_indices: Vec<PyNodeIndex> = context.node_indices.deep_into();
3931
3932        Self {
3933            groups: groups.into_py_any(py).expect("groups should be creatable"),
3934            node_indices: node_indices
3935                .into_py_any(py)
3936                .expect("node_indices should be creatable"),
3937        }
3938    }
3939
3940    /// # Panics
3941    ///
3942    /// Panics if the python typing was not followed.
3943    pub fn extract(self, py: Python<'_>) -> PreRemoveNodesFromGroupsContext {
3944        let groups: Vec<PyGroup> = self
3945            .groups
3946            .extract(py)
3947            .expect("groups should be extractable");
3948
3949        let node_indices: Vec<PyNodeIndex> = self
3950            .node_indices
3951            .extract(py)
3952            .expect("node_indices should be extractable");
3953
3954        PreRemoveNodesFromGroupsContext {
3955            groups: groups.deep_into(),
3956            node_indices: node_indices.deep_into(),
3957        }
3958    }
3959}
3960
3961#[pymethods]
3962impl PyPreRemoveNodesFromGroupsContext {
3963    #[new]
3964    pub const fn new(groups: Py<PyAny>, node_indices: Py<PyAny>) -> Self {
3965        Self {
3966            groups,
3967            node_indices,
3968        }
3969    }
3970
3971    #[getter]
3972    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
3973        self.groups.clone_ref(py)
3974    }
3975
3976    #[getter]
3977    pub fn node_indices(&self, py: Python<'_>) -> Py<PyAny> {
3978        self.node_indices.clone_ref(py)
3979    }
3980}
3981
3982#[pyclass(frozen)]
3983#[derive(Debug)]
3984pub struct PyPostRemoveNodesFromGroupsContext {
3985    groups: Py<PyAny>,
3986    node_indices: Py<PyAny>,
3987}
3988
3989impl Clone for PyPostRemoveNodesFromGroupsContext {
3990    fn clone(&self) -> Self {
3991        Python::attach(|py| Self {
3992            groups: self.groups.clone_ref(py),
3993            node_indices: self.node_indices.clone_ref(py),
3994        })
3995    }
3996}
3997
3998impl PyPostRemoveNodesFromGroupsContext {
3999    /// # Panics
4000    ///
4001    /// Panics if the python typing was not followed.
4002    pub fn bind(py: Python<'_>, context: PostRemoveNodesFromGroupsContext) -> Self {
4003        let groups: Vec<PyGroup> = context.groups.deep_into();
4004        let node_indices: Vec<PyNodeIndex> = context.node_indices.deep_into();
4005
4006        Self {
4007            groups: groups.into_py_any(py).expect("groups should be creatable"),
4008            node_indices: node_indices
4009                .into_py_any(py)
4010                .expect("node_indices should be creatable"),
4011        }
4012    }
4013}
4014
4015#[pymethods]
4016impl PyPostRemoveNodesFromGroupsContext {
4017    #[new]
4018    pub const fn new(groups: Py<PyAny>, node_indices: Py<PyAny>) -> Self {
4019        Self {
4020            groups,
4021            node_indices,
4022        }
4023    }
4024
4025    #[getter]
4026    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
4027        self.groups.clone_ref(py)
4028    }
4029
4030    #[getter]
4031    pub fn node_indices(&self, py: Python<'_>) -> Py<PyAny> {
4032        self.node_indices.clone_ref(py)
4033    }
4034}
4035
4036#[pyclass(frozen)]
4037#[derive(Debug)]
4038pub struct PyPreRemoveEdgeFromGroupContext {
4039    group: Py<PyAny>,
4040    edge_index: Py<PyAny>,
4041}
4042
4043impl Clone for PyPreRemoveEdgeFromGroupContext {
4044    fn clone(&self) -> Self {
4045        Python::attach(|py| Self {
4046            group: self.group.clone_ref(py),
4047            edge_index: self.edge_index.clone_ref(py),
4048        })
4049    }
4050}
4051
4052impl PyPreRemoveEdgeFromGroupContext {
4053    /// # Panics
4054    ///
4055    /// Panics if the python typing was not followed.
4056    pub fn bind(py: Python<'_>, context: PreRemoveEdgeFromGroupContext) -> Self {
4057        Self {
4058            group: PyGroup::from(context.group)
4059                .into_py_any(py)
4060                .expect("PyGroup should be creatable"),
4061            edge_index: context
4062                .edge_index
4063                .into_py_any(py)
4064                .expect("edge_index should be creatable"),
4065        }
4066    }
4067
4068    /// # Panics
4069    ///
4070    /// Panics if the python typing was not followed.
4071    pub fn extract(self, py: Python<'_>) -> PreRemoveEdgeFromGroupContext {
4072        let group: PyGroup = self
4073            .group
4074            .extract(py)
4075            .expect("PyGroup should be extractable");
4076
4077        PreRemoveEdgeFromGroupContext {
4078            group: group.into(),
4079            edge_index: self
4080                .edge_index
4081                .extract(py)
4082                .expect("edge_index should be extractable"),
4083        }
4084    }
4085}
4086
4087#[pymethods]
4088impl PyPreRemoveEdgeFromGroupContext {
4089    #[new]
4090    pub const fn new(group: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
4091        Self { group, edge_index }
4092    }
4093
4094    #[getter]
4095    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
4096        self.group.clone_ref(py)
4097    }
4098
4099    #[getter]
4100    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
4101        self.edge_index.clone_ref(py)
4102    }
4103}
4104
4105#[pyclass(frozen)]
4106#[derive(Debug)]
4107pub struct PyPostRemoveEdgeFromGroupContext {
4108    group: Py<PyAny>,
4109    edge_index: Py<PyAny>,
4110}
4111
4112impl Clone for PyPostRemoveEdgeFromGroupContext {
4113    fn clone(&self) -> Self {
4114        Python::attach(|py| Self {
4115            group: self.group.clone_ref(py),
4116            edge_index: self.edge_index.clone_ref(py),
4117        })
4118    }
4119}
4120
4121impl PyPostRemoveEdgeFromGroupContext {
4122    /// # Panics
4123    ///
4124    /// Panics if the python typing was not followed.
4125    pub fn bind(py: Python<'_>, context: PostRemoveEdgeFromGroupContext) -> Self {
4126        Self {
4127            group: PyGroup::from(context.group)
4128                .into_py_any(py)
4129                .expect("PyGroup should be creatable"),
4130            edge_index: context
4131                .edge_index
4132                .into_py_any(py)
4133                .expect("edge_index should be creatable"),
4134        }
4135    }
4136}
4137
4138#[pymethods]
4139impl PyPostRemoveEdgeFromGroupContext {
4140    #[new]
4141    pub const fn new(group: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
4142        Self { group, edge_index }
4143    }
4144
4145    #[getter]
4146    pub fn group(&self, py: Python<'_>) -> Py<PyAny> {
4147        self.group.clone_ref(py)
4148    }
4149
4150    #[getter]
4151    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
4152        self.edge_index.clone_ref(py)
4153    }
4154}
4155
4156#[pyclass(frozen)]
4157#[derive(Debug)]
4158pub struct PyPreRemoveEdgeFromGroupsContext {
4159    groups: Py<PyAny>,
4160    edge_index: Py<PyAny>,
4161}
4162
4163impl Clone for PyPreRemoveEdgeFromGroupsContext {
4164    fn clone(&self) -> Self {
4165        Python::attach(|py| Self {
4166            groups: self.groups.clone_ref(py),
4167            edge_index: self.edge_index.clone_ref(py),
4168        })
4169    }
4170}
4171
4172impl PyPreRemoveEdgeFromGroupsContext {
4173    /// # Panics
4174    ///
4175    /// Panics if the python typing was not followed.
4176    pub fn bind(py: Python<'_>, context: PreRemoveEdgeFromGroupsContext) -> Self {
4177        let groups: Vec<PyGroup> = context.groups.deep_into();
4178
4179        Self {
4180            groups: groups.into_py_any(py).expect("groups should be creatable"),
4181            edge_index: context
4182                .edge_index
4183                .into_py_any(py)
4184                .expect("edge_index should be creatable"),
4185        }
4186    }
4187
4188    /// # Panics
4189    ///
4190    /// Panics if the python typing was not followed.
4191    pub fn extract(self, py: Python<'_>) -> PreRemoveEdgeFromGroupsContext {
4192        let groups: Vec<PyGroup> = self
4193            .groups
4194            .extract(py)
4195            .expect("groups should be extractable");
4196
4197        PreRemoveEdgeFromGroupsContext {
4198            groups: groups.deep_into(),
4199            edge_index: self
4200                .edge_index
4201                .extract(py)
4202                .expect("edge_index should be extractable"),
4203        }
4204    }
4205}
4206
4207#[pymethods]
4208impl PyPreRemoveEdgeFromGroupsContext {
4209    #[new]
4210    pub const fn new(groups: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
4211        Self { groups, edge_index }
4212    }
4213
4214    #[getter]
4215    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
4216        self.groups.clone_ref(py)
4217    }
4218
4219    #[getter]
4220    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
4221        self.edge_index.clone_ref(py)
4222    }
4223}
4224
4225#[pyclass(frozen)]
4226#[derive(Debug)]
4227pub struct PyPostRemoveEdgeFromGroupsContext {
4228    groups: Py<PyAny>,
4229    edge_index: Py<PyAny>,
4230}
4231
4232impl Clone for PyPostRemoveEdgeFromGroupsContext {
4233    fn clone(&self) -> Self {
4234        Python::attach(|py| Self {
4235            groups: self.groups.clone_ref(py),
4236            edge_index: self.edge_index.clone_ref(py),
4237        })
4238    }
4239}
4240
4241impl PyPostRemoveEdgeFromGroupsContext {
4242    /// # Panics
4243    ///
4244    /// Panics if the python typing was not followed.
4245    pub fn bind(py: Python<'_>, context: PostRemoveEdgeFromGroupsContext) -> Self {
4246        let groups: Vec<PyGroup> = context.groups.deep_into();
4247
4248        Self {
4249            groups: groups.into_py_any(py).expect("groups should be creatable"),
4250            edge_index: context
4251                .edge_index
4252                .into_py_any(py)
4253                .expect("edge_index should be creatable"),
4254        }
4255    }
4256}
4257
4258#[pymethods]
4259impl PyPostRemoveEdgeFromGroupsContext {
4260    #[new]
4261    pub const fn new(groups: Py<PyAny>, edge_index: Py<PyAny>) -> Self {
4262        Self { groups, edge_index }
4263    }
4264
4265    #[getter]
4266    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
4267        self.groups.clone_ref(py)
4268    }
4269
4270    #[getter]
4271    pub fn edge_index(&self, py: Python<'_>) -> Py<PyAny> {
4272        self.edge_index.clone_ref(py)
4273    }
4274}
4275
4276#[pyclass(frozen)]
4277#[derive(Debug)]
4278pub struct PyPreRemoveEdgesFromGroupsContext {
4279    groups: Py<PyAny>,
4280    edge_indices: Py<PyAny>,
4281}
4282
4283impl Clone for PyPreRemoveEdgesFromGroupsContext {
4284    fn clone(&self) -> Self {
4285        Python::attach(|py| Self {
4286            groups: self.groups.clone_ref(py),
4287            edge_indices: self.edge_indices.clone_ref(py),
4288        })
4289    }
4290}
4291
4292impl PyPreRemoveEdgesFromGroupsContext {
4293    /// # Panics
4294    ///
4295    /// Panics if the python typing was not followed.
4296    pub fn bind(py: Python<'_>, context: PreRemoveEdgesFromGroupsContext) -> Self {
4297        let groups: Vec<PyGroup> = context.groups.deep_into();
4298
4299        Self {
4300            groups: groups.into_py_any(py).expect("groups should be creatable"),
4301            edge_indices: context
4302                .edge_indices
4303                .into_py_any(py)
4304                .expect("edge_indices should be creatable"),
4305        }
4306    }
4307
4308    /// # Panics
4309    ///
4310    /// Panics if the python typing was not followed.
4311    pub fn extract(self, py: Python<'_>) -> PreRemoveEdgesFromGroupsContext {
4312        let groups: Vec<PyGroup> = self
4313            .groups
4314            .extract(py)
4315            .expect("groups should be extractable");
4316
4317        PreRemoveEdgesFromGroupsContext {
4318            groups: groups.deep_into(),
4319            edge_indices: self
4320                .edge_indices
4321                .extract(py)
4322                .expect("edge_indices should be extractable"),
4323        }
4324    }
4325}
4326
4327#[pymethods]
4328impl PyPreRemoveEdgesFromGroupsContext {
4329    #[new]
4330    pub const fn new(groups: Py<PyAny>, edge_indices: Py<PyAny>) -> Self {
4331        Self {
4332            groups,
4333            edge_indices,
4334        }
4335    }
4336
4337    #[getter]
4338    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
4339        self.groups.clone_ref(py)
4340    }
4341
4342    #[getter]
4343    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
4344        self.edge_indices.clone_ref(py)
4345    }
4346}
4347
4348#[pyclass(frozen)]
4349#[derive(Debug)]
4350pub struct PyPostRemoveEdgesFromGroupsContext {
4351    groups: Py<PyAny>,
4352    edge_indices: Py<PyAny>,
4353}
4354
4355impl Clone for PyPostRemoveEdgesFromGroupsContext {
4356    fn clone(&self) -> Self {
4357        Python::attach(|py| Self {
4358            groups: self.groups.clone_ref(py),
4359            edge_indices: self.edge_indices.clone_ref(py),
4360        })
4361    }
4362}
4363
4364impl PyPostRemoveEdgesFromGroupsContext {
4365    /// # Panics
4366    ///
4367    /// Panics if the python typing was not followed.
4368    pub fn bind(py: Python<'_>, context: PostRemoveEdgesFromGroupsContext) -> Self {
4369        let groups: Vec<PyGroup> = context.groups.deep_into();
4370
4371        Self {
4372            groups: groups.into_py_any(py).expect("groups should be creatable"),
4373            edge_indices: context
4374                .edge_indices
4375                .into_py_any(py)
4376                .expect("edge_indices should be creatable"),
4377        }
4378    }
4379}
4380
4381#[pymethods]
4382impl PyPostRemoveEdgesFromGroupsContext {
4383    #[new]
4384    pub const fn new(groups: Py<PyAny>, edge_indices: Py<PyAny>) -> Self {
4385        Self {
4386            groups,
4387            edge_indices,
4388        }
4389    }
4390
4391    #[getter]
4392    pub fn groups(&self, py: Python<'_>) -> Py<PyAny> {
4393        self.groups.clone_ref(py)
4394    }
4395
4396    #[getter]
4397    pub fn edge_indices(&self, py: Python<'_>) -> Py<PyAny> {
4398        self.edge_indices.clone_ref(py)
4399    }
4400}
4401
4402#[typetag::serde]
4403impl Plugin for PyPlugin {
4404    impl_pre_hook!(pre_set_schema, PyPreSetSchemaContext, PreSetSchemaContext);
4405
4406    impl_post_hook!(post_set_schema);
4407
4408    impl_post_hook!(pre_freeze_schema);
4409
4410    impl_post_hook!(post_freeze_schema);
4411
4412    impl_post_hook!(pre_unfreeze_schema);
4413
4414    impl_post_hook!(post_unfreeze_schema);
4415
4416    impl_pre_hook!(pre_add_node, PyPreAddNodeContext, PreAddNodeContext);
4417
4418    impl_post_hook!(post_add_node, PyPostAddNodeContext, PostAddNodeContext);
4419
4420    impl_pre_hook!(
4421        pre_add_node_with_group,
4422        PyPreAddNodeWithGroupContext,
4423        PreAddNodeWithGroupContext
4424    );
4425
4426    impl_post_hook!(
4427        post_add_node_with_group,
4428        PyPostAddNodeWithGroupContext,
4429        PostAddNodeWithGroupContext
4430    );
4431
4432    impl_pre_hook!(
4433        pre_add_node_with_groups,
4434        PyPreAddNodeWithGroupsContext,
4435        PreAddNodeWithGroupsContext
4436    );
4437
4438    impl_post_hook!(
4439        post_add_node_with_groups,
4440        PyPostAddNodeWithGroupsContext,
4441        PostAddNodeWithGroupsContext
4442    );
4443
4444    impl_pre_hook!(
4445        pre_remove_node,
4446        PyPreRemoveNodeContext,
4447        PreRemoveNodeContext
4448    );
4449
4450    impl_post_hook!(
4451        post_remove_node,
4452        PyPostRemoveNodeContext,
4453        PostRemoveNodeContext
4454    );
4455
4456    impl_pre_hook!(pre_add_nodes, PyPreAddNodesContext, PreAddNodesContext);
4457
4458    impl_post_hook!(post_add_nodes, PyPostAddNodesContext, PostAddNodesContext);
4459
4460    impl_pre_hook!(
4461        pre_add_nodes_with_group,
4462        PyPreAddNodesWithGroupContext,
4463        PreAddNodesWithGroupContext
4464    );
4465
4466    impl_post_hook!(
4467        post_add_nodes_with_group,
4468        PyPostAddNodesWithGroupContext,
4469        PostAddNodesWithGroupContext
4470    );
4471
4472    impl_pre_hook!(
4473        pre_add_nodes_with_groups,
4474        PyPreAddNodesWithGroupsContext,
4475        PreAddNodesWithGroupsContext
4476    );
4477
4478    impl_post_hook!(
4479        post_add_nodes_with_groups,
4480        PyPostAddNodesWithGroupsContext,
4481        PostAddNodesWithGroupsContext
4482    );
4483
4484    impl_pre_hook!(
4485        pre_add_nodes_dataframes,
4486        PyPreAddNodesDataframesContext,
4487        PreAddNodesDataframesContext
4488    );
4489
4490    impl_post_hook!(
4491        post_add_nodes_dataframes,
4492        PyPostAddNodesDataframesContext,
4493        PostAddNodesDataframesContext
4494    );
4495
4496    impl_pre_hook!(
4497        pre_add_nodes_dataframes_with_group,
4498        PyPreAddNodesDataframesWithGroupContext,
4499        PreAddNodesDataframesWithGroupContext
4500    );
4501
4502    impl_post_hook!(
4503        post_add_nodes_dataframes_with_group,
4504        PyPostAddNodesDataframesWithGroupContext,
4505        PostAddNodesDataframesWithGroupContext
4506    );
4507
4508    impl_pre_hook!(
4509        pre_add_nodes_dataframes_with_groups,
4510        PyPreAddNodesDataframesWithGroupsContext,
4511        PreAddNodesDataframesWithGroupsContext
4512    );
4513
4514    impl_post_hook!(
4515        post_add_nodes_dataframes_with_groups,
4516        PyPostAddNodesDataframesWithGroupsContext,
4517        PostAddNodesDataframesWithGroupsContext
4518    );
4519
4520    impl_pre_hook!(pre_add_edge, PyPreAddEdgeContext, PreAddEdgeContext);
4521
4522    impl_post_hook!(post_add_edge, PyPostAddEdgeContext, PostAddEdgeContext);
4523
4524    impl_pre_hook!(
4525        pre_add_edge_with_group,
4526        PyPreAddEdgeWithGroupContext,
4527        PreAddEdgeWithGroupContext
4528    );
4529
4530    impl_post_hook!(
4531        post_add_edge_with_group,
4532        PyPostAddEdgeWithGroupContext,
4533        PostAddEdgeWithGroupContext
4534    );
4535
4536    impl_pre_hook!(
4537        pre_add_edge_with_groups,
4538        PyPreAddEdgeWithGroupsContext,
4539        PreAddEdgeWithGroupsContext
4540    );
4541
4542    impl_post_hook!(
4543        post_add_edge_with_groups,
4544        PyPostAddEdgeWithGroupsContext,
4545        PostAddEdgeWithGroupsContext
4546    );
4547
4548    impl_pre_hook!(
4549        pre_remove_edge,
4550        PyPreRemoveEdgeContext,
4551        PreRemoveEdgeContext
4552    );
4553
4554    impl_post_hook!(
4555        post_remove_edge,
4556        PyPostRemoveEdgeContext,
4557        PostRemoveEdgeContext
4558    );
4559
4560    impl_pre_hook!(pre_add_edges, PyPreAddEdgesContext, PreAddEdgesContext);
4561
4562    impl_post_hook!(post_add_edges, PyPostAddEdgesContext, PostAddEdgesContext);
4563
4564    impl_pre_hook!(
4565        pre_add_edges_with_group,
4566        PyPreAddEdgesWithGroupContext,
4567        PreAddEdgesWithGroupContext
4568    );
4569
4570    impl_post_hook!(
4571        post_add_edges_with_group,
4572        PyPostAddEdgesWithGroupContext,
4573        PostAddEdgesWithGroupContext
4574    );
4575
4576    impl_pre_hook!(
4577        pre_add_edges_with_groups,
4578        PyPreAddEdgesWithGroupsContext,
4579        PreAddEdgesWithGroupsContext
4580    );
4581
4582    impl_post_hook!(
4583        post_add_edges_with_groups,
4584        PyPostAddEdgesWithGroupsContext,
4585        PostAddEdgesWithGroupsContext
4586    );
4587
4588    impl_pre_hook!(
4589        pre_add_edges_dataframes,
4590        PyPreAddEdgesDataframesContext,
4591        PreAddEdgesDataframesContext
4592    );
4593
4594    impl_post_hook!(
4595        post_add_edges_dataframes,
4596        PyPostAddEdgesDataframesContext,
4597        PostAddEdgesDataframesContext
4598    );
4599
4600    impl_pre_hook!(
4601        pre_add_edges_dataframes_with_group,
4602        PyPreAddEdgesDataframesWithGroupContext,
4603        PreAddEdgesDataframesWithGroupContext
4604    );
4605
4606    impl_post_hook!(
4607        post_add_edges_dataframes_with_group,
4608        PyPostAddEdgesDataframesWithGroupContext,
4609        PostAddEdgesDataframesWithGroupContext
4610    );
4611
4612    impl_pre_hook!(
4613        pre_add_edges_dataframes_with_groups,
4614        PyPreAddEdgesDataframesWithGroupsContext,
4615        PreAddEdgesDataframesWithGroupsContext
4616    );
4617
4618    impl_post_hook!(
4619        post_add_edges_dataframes_with_groups,
4620        PyPostAddEdgesDataframesWithGroupsContext,
4621        PostAddEdgesDataframesWithGroupsContext
4622    );
4623
4624    impl_pre_hook!(pre_add_group, PyPreAddGroupContext, PreAddGroupContext);
4625
4626    impl_post_hook!(post_add_group, PyPostAddGroupContext, PostAddGroupContext);
4627
4628    impl_pre_hook!(
4629        pre_remove_group,
4630        PyPreRemoveGroupContext,
4631        PreRemoveGroupContext
4632    );
4633
4634    impl_post_hook!(
4635        post_remove_group,
4636        PyPostRemoveGroupContext,
4637        PostRemoveGroupContext
4638    );
4639
4640    impl_pre_hook!(
4641        pre_add_node_to_group,
4642        PyPreAddNodeToGroupContext,
4643        PreAddNodeToGroupContext
4644    );
4645
4646    impl_post_hook!(
4647        post_add_node_to_group,
4648        PyPostAddNodeToGroupContext,
4649        PostAddNodeToGroupContext
4650    );
4651
4652    impl_pre_hook!(
4653        pre_add_node_to_groups,
4654        PyPreAddNodeToGroupsContext,
4655        PreAddNodeToGroupsContext
4656    );
4657
4658    impl_post_hook!(
4659        post_add_node_to_groups,
4660        PyPostAddNodeToGroupsContext,
4661        PostAddNodeToGroupsContext
4662    );
4663
4664    impl_pre_hook!(
4665        pre_add_nodes_to_groups,
4666        PyPreAddNodesToGroupsContext,
4667        PreAddNodesToGroupsContext
4668    );
4669
4670    impl_post_hook!(
4671        post_add_nodes_to_groups,
4672        PyPostAddNodesToGroupsContext,
4673        PostAddNodesToGroupsContext
4674    );
4675
4676    impl_pre_hook!(
4677        pre_add_edge_to_group,
4678        PyPreAddEdgeToGroupContext,
4679        PreAddEdgeToGroupContext
4680    );
4681
4682    impl_post_hook!(
4683        post_add_edge_to_group,
4684        PyPostAddEdgeToGroupContext,
4685        PostAddEdgeToGroupContext
4686    );
4687
4688    impl_pre_hook!(
4689        pre_add_edge_to_groups,
4690        PyPreAddEdgeToGroupsContext,
4691        PreAddEdgeToGroupsContext
4692    );
4693
4694    impl_post_hook!(
4695        post_add_edge_to_groups,
4696        PyPostAddEdgeToGroupsContext,
4697        PostAddEdgeToGroupsContext
4698    );
4699
4700    impl_pre_hook!(
4701        pre_add_edges_to_groups,
4702        PyPreAddEdgesToGroupsContext,
4703        PreAddEdgesToGroupsContext
4704    );
4705
4706    impl_post_hook!(
4707        post_add_edges_to_groups,
4708        PyPostAddEdgesToGroupsContext,
4709        PostAddEdgesToGroupsContext
4710    );
4711
4712    impl_pre_hook!(
4713        pre_remove_node_from_group,
4714        PyPreRemoveNodeFromGroupContext,
4715        PreRemoveNodeFromGroupContext
4716    );
4717
4718    impl_post_hook!(
4719        post_remove_node_from_group,
4720        PyPostRemoveNodeFromGroupContext,
4721        PostRemoveNodeFromGroupContext
4722    );
4723
4724    impl_pre_hook!(
4725        pre_remove_node_from_groups,
4726        PyPreRemoveNodeFromGroupsContext,
4727        PreRemoveNodeFromGroupsContext
4728    );
4729
4730    impl_post_hook!(
4731        post_remove_node_from_groups,
4732        PyPostRemoveNodeFromGroupsContext,
4733        PostRemoveNodeFromGroupsContext
4734    );
4735
4736    impl_pre_hook!(
4737        pre_remove_nodes_from_groups,
4738        PyPreRemoveNodesFromGroupsContext,
4739        PreRemoveNodesFromGroupsContext
4740    );
4741
4742    impl_post_hook!(
4743        post_remove_nodes_from_groups,
4744        PyPostRemoveNodesFromGroupsContext,
4745        PostRemoveNodesFromGroupsContext
4746    );
4747
4748    impl_pre_hook!(
4749        pre_remove_edge_from_group,
4750        PyPreRemoveEdgeFromGroupContext,
4751        PreRemoveEdgeFromGroupContext
4752    );
4753
4754    impl_post_hook!(
4755        post_remove_edge_from_group,
4756        PyPostRemoveEdgeFromGroupContext,
4757        PostRemoveEdgeFromGroupContext
4758    );
4759
4760    impl_pre_hook!(
4761        pre_remove_edge_from_groups,
4762        PyPreRemoveEdgeFromGroupsContext,
4763        PreRemoveEdgeFromGroupsContext
4764    );
4765
4766    impl_post_hook!(
4767        post_remove_edge_from_groups,
4768        PyPostRemoveEdgeFromGroupsContext,
4769        PostRemoveEdgeFromGroupsContext
4770    );
4771
4772    impl_pre_hook!(
4773        pre_remove_edges_from_groups,
4774        PyPreRemoveEdgesFromGroupsContext,
4775        PreRemoveEdgesFromGroupsContext
4776    );
4777
4778    impl_post_hook!(
4779        post_remove_edges_from_groups,
4780        PyPostRemoveEdgesFromGroupsContext,
4781        PostRemoveEdgesFromGroupsContext
4782    );
4783
4784    impl_post_hook!(pre_clear);
4785
4786    impl_post_hook!(post_clear);
4787
4788    fn clone_box(&self) -> Box<dyn Plugin> {
4789        Python::attach(|py| Box::new(Self(self.0.clone_ref(py))))
4790    }
4791
4792    fn initialize(&self, graphrecord: &mut GraphRecord) -> GraphRecordResult<()> {
4793        Python::attach(|py| {
4794            PyGraphRecord::scope_mut(py, graphrecord, |py, graphrecord| {
4795                self.0
4796                    .call_method1(py, "initialize", (graphrecord,))
4797                    .map_err(|err| GraphRecordError::PluginFailure {
4798                        message: err.to_string(),
4799                    })?;
4800
4801                Ok(())
4802            })
4803        })
4804    }
4805
4806    fn finalize(&self, graphrecord: &mut GraphRecord) -> GraphRecordResult<()> {
4807        Python::attach(|py| {
4808            PyGraphRecord::scope_mut(py, graphrecord, |py, graphrecord| {
4809                self.0
4810                    .call_method1(py, "finalize", (graphrecord,))
4811                    .map_err(|err| GraphRecordError::PluginFailure {
4812                        message: err.to_string(),
4813                    })?;
4814
4815                Ok(())
4816            })
4817        })
4818    }
4819}