@@ -40,6 +40,18 @@ pub struct PySignal {
40
40
pub ( crate ) signal : SignalKind ,
41
41
}
42
42
43
+ impl PySignal {
44
+ pub fn new < T > ( signal : T , interpolation : PyInterp ) -> Self
45
+ where
46
+ T : Into < SignalKind > ,
47
+ {
48
+ Self {
49
+ interpolation,
50
+ signal : signal. into ( ) ,
51
+ }
52
+ }
53
+ }
54
+
43
55
#[ pymethods]
44
56
impl PySignal {
45
57
#[ getter]
@@ -106,31 +118,21 @@ macro_rules! impl_signals {
106
118
#[ derive( Debug , Copy , Clone ) ]
107
119
pub struct [ <$ty_name Signal >] ;
108
120
109
- impl [ <$ty_name Signal >] {
110
- #[ inline]
111
- pub fn super_type( signal: SignalKind ) -> PySignal {
112
- PySignal {
113
- interpolation: PyInterp :: Linear ,
114
- signal,
115
- }
116
- }
117
- }
118
-
119
121
#[ pymethods]
120
122
impl [ <$ty_name Signal >] {
121
123
/// Create a new empty signal
122
124
#[ new]
123
125
#[ pyo3( signature = ( ) ) ]
124
126
fn new( ) -> ( Self , PySignal ) {
125
- ( Self , Self :: super_type ( Signal :: <$ty>:: new( ) . into ( ) ) )
127
+ ( Self , PySignal :: new ( Signal :: <$ty>:: new( ) , PyInterp :: Linear ) )
126
128
}
127
129
128
130
/// Create a new signal with constant value
129
131
#[ classmethod]
130
132
fn constant( _: & PyType , py: Python <' _>, value: $ty) -> PyResult <Py <Self >> {
131
133
Py :: new(
132
134
py,
133
- ( Self , Self :: super_type ( Signal :: constant( value) . into ( ) ) )
135
+ ( Self , PySignal :: new ( Signal :: constant( value) , PyInterp :: Linear ) )
134
136
)
135
137
}
136
138
@@ -144,7 +146,7 @@ macro_rules! impl_signals {
144
146
Python :: with_gil( |py| {
145
147
Py :: new(
146
148
py,
147
- ( Self , Self :: super_type ( ret. into ( ) ) )
149
+ ( Self , PySignal :: new ( ret, PyInterp :: Linear ) )
148
150
)
149
151
} )
150
152
}
0 commit comments