@@ -47,49 +47,54 @@ names : list of str
47
47
descriptions : list of str
48
48
Feature descriptions"# ;
49
49
50
- const METHOD_CALL_DOC : & str = r#"__call__(self, t, m, sigma=None, *, sorted=None, check=True, fill_value=None )
50
+ const METHOD_CALL_DOC : & str = r#"__call__(self, t, m, sigma=None, *, fill_value=None, sorted=None, check=True, cast=False )
51
51
Extract features and return them as a numpy array
52
52
53
53
Parameters
54
54
----------
55
55
t : numpy.ndarray of np.float32 or np.float64 dtype
56
56
Time moments
57
- m : numpy.ndarray of the same dtype and size as t
57
+ m : numpy.ndarray
58
58
Signal in magnitude or fluxes. Refer to the feature description to
59
59
decide which would work better in your case
60
- sigma : numpy.ndarray of the same dtype and size as t , optional
60
+ sigma : numpy.ndarray, optional
61
61
Observation error, if None it is assumed to be unity
62
+ fill_value : float or None, optional
63
+ Value to fill invalid feature values, for example if count of
64
+ observations is not enough to find a proper value.
65
+ None causes exception for invalid features
62
66
sorted : bool or None, optional
63
67
Specifies if input array are sorted by time moments.
64
68
True is for certainly sorted, False is for unsorted.
65
69
If None is specified than sorting is checked and an exception is
66
70
raised for unsorted `t`
67
71
check : bool, optional
68
72
Check all input arrays for NaNs, `t` and `m` for infinite values
69
- fill_value : float or None , optional
70
- Value to fill invalid feature values, for example if count of
71
- observations is not enough to find a proper value .
72
- None causes exception for invalid features
73
-
73
+ cast : bool , optional
74
+ Allows non-numpy input and casting of arrays to a common dtype.
75
+ If `False`, inputs must be `np.ndarray` instances with matched dtypes .
76
+ Casting provides more flexibility with input types at the cost of
77
+ performance.
74
78
Returns
75
79
-------
76
80
ndarray of np.float32 or np.float64
77
81
Extracted feature array"# ;
78
82
79
83
macro_const ! {
80
84
const METHOD_MANY_DOC : & str = r#"
81
- many(self, lcs, *, sorted=None, check=True, fill_value=None , n_jobs=-1)
85
+ many(self, lcs, *, fill_value=None, sorted=None, check=True, cast=False , n_jobs=-1)
82
86
Parallel light curve feature extraction
83
87
84
88
It is a parallel executed equivalent of
85
- >>> def many(self, lcs, *, sorted =None, check=True, fill_value=None ):
89
+ >>> def many(self, lcs, *, fill_value =None, sorted=None, check=True ):
86
90
... return np.stack(
87
91
... [
88
92
... self(
89
93
... *lc,
94
+ ... fill_value=fill_value,
90
95
... sorted=sorted,
91
96
... check=check,
92
- ... fill_value=fill_value
97
+ ... cast=False,
93
98
... )
94
99
... for lc in lcs
95
100
... ]
@@ -101,13 +106,13 @@ many(self, lcs, *, sorted=None, check=True, fill_value=None, n_jobs=-1)
101
106
A collection of light curves packed into three-tuples, all light curves
102
107
must be represented by numpy.ndarray of the same dtype. See __call__
103
108
documentation for details
109
+ fill_value : float or None, optional
110
+ Fill invalid values by this or raise an exception if None
104
111
sorted : bool or None, optional
105
112
Specifies if input array are sorted by time moments, see __call__
106
113
documentation for details
107
114
check : bool, optional
108
115
Check all input arrays for NaNs, `t` and `m` for infinite values
109
- fill_value : float or None, optional
110
- Fill invalid values by this or raise an exception if None
111
116
n_jobs : int
112
117
Number of tasks to run in paralell. Default is -1 which means run as
113
118
many jobs as CPU count. See rayon rust crate documentation for
@@ -440,19 +445,21 @@ impl PyFeatureEvaluator {
440
445
m,
441
446
sigma = None ,
442
447
* ,
448
+ fill_value = None ,
443
449
sorted = None ,
444
450
check = true ,
445
- fill_value = None
451
+ cast = false ,
446
452
) ) ]
447
453
fn __call__ < ' py > (
448
454
& self ,
449
455
py : Python < ' py > ,
450
456
t : Bound < ' py , PyAny > ,
451
457
m : Bound < ' py , PyAny > ,
452
458
sigma : Option < Bound < ' py , PyAny > > ,
459
+ fill_value : Option < f64 > ,
453
460
sorted : Option < bool > ,
454
461
check : bool ,
455
- fill_value : Option < f64 > ,
462
+ cast : bool ,
456
463
) -> Res < Bound < ' py , PyUntypedArray > > {
457
464
if let Some ( sigma) = sigma {
458
465
dtype_dispatch ! (
@@ -484,7 +491,8 @@ impl PyFeatureEvaluator {
484
491
} ,
485
492
t,
486
493
=m,
487
- =sigma
494
+ =sigma;
495
+ cast=cast
488
496
)
489
497
} else {
490
498
dtype_dispatch ! (
@@ -515,20 +523,21 @@ impl PyFeatureEvaluator {
515
523
)
516
524
} ,
517
525
t,
518
- =m,
526
+ =m;
527
+ cast=cast
519
528
)
520
529
}
521
530
}
522
531
523
532
#[ doc = METHOD_MANY_DOC ! ( ) ]
524
- #[ pyo3( signature = ( lcs, * , sorted =None , check= true , fill_value= None , n_jobs=-1 ) ) ]
533
+ #[ pyo3( signature = ( lcs, * , fill_value =None , sorted= None , check= true , n_jobs=-1 ) ) ]
525
534
fn many < ' py > (
526
535
& self ,
527
536
py : Python < ' py > ,
528
537
lcs : PyLcs < ' py > ,
538
+ fill_value : Option < f64 > ,
529
539
sorted : Option < bool > ,
530
540
check : bool ,
531
- fill_value : Option < f64 > ,
532
541
n_jobs : i64 ,
533
542
) -> Res < Bound < ' py , PyUntypedArray > > {
534
543
if lcs. is_empty ( ) {
@@ -766,7 +775,7 @@ const SUPPORTED_ALGORITHMS_CURVE_FIT: [&str; N_ALGO_CURVE_FIT] = [
766
775
] ;
767
776
768
777
macro_const ! {
769
- const FIT_METHOD_MODEL_DOC : & str = r#"model(t, params)
778
+ const FIT_METHOD_MODEL_DOC : & str = r#"model(t, params, *, cast=False )
770
779
Underlying parametric model function
771
780
772
781
Parameters
@@ -777,6 +786,8 @@ macro_const! {
777
786
Parameters of the model, this array can be longer than actual parameter
778
787
list, the beginning part of the array will be used in this case, see
779
788
Examples section in the class documentation.
789
+ cast : bool, optional
790
+ Cast inputs to np.ndarray of the same dtype
780
791
781
792
Returns
782
793
-------
@@ -1015,14 +1026,16 @@ macro_rules! fit_evaluator {
1015
1026
1016
1027
#[ doc = FIT_METHOD_MODEL_DOC !( ) ]
1017
1028
#[ staticmethod]
1029
+ #[ pyo3( signature = ( t, params, * , cast=false ) ) ]
1018
1030
fn model<' py>(
1019
1031
py: Python <' py>,
1020
1032
t: Bound <' py, PyAny >,
1021
1033
params: Bound <' py, PyAny >,
1034
+ cast: bool
1022
1035
) -> Res <Bound <' py, PyUntypedArray >> {
1023
1036
dtype_dispatch!( {
1024
1037
|t, params| Ok ( Self :: model_impl( t, params) . into_pyarray( py) . as_untyped( ) . clone( ) )
1025
- } ( t, !=params) )
1038
+ } ( t, !=params; cast=cast ) )
1026
1039
}
1027
1040
1028
1041
#[ classattr]
@@ -1706,17 +1719,20 @@ impl Periodogram {
1706
1719
}
1707
1720
1708
1721
/// Angular frequencies and periodogram values
1722
+ #[ pyo3( signature = ( t, m, * , cast=false ) ) ]
1709
1723
fn freq_power < ' py > (
1710
1724
& self ,
1711
1725
py : Python < ' py > ,
1712
1726
t : Bound < PyAny > ,
1713
1727
m : Bound < PyAny > ,
1728
+ cast : bool ,
1714
1729
) -> Res < ( Bound < ' py , PyUntypedArray > , Bound < ' py , PyUntypedArray > ) > {
1715
1730
dtype_dispatch ! (
1716
1731
|t, m| Ok ( Self :: freq_power_impl( & self . eval_f32, py, t, m) ) ,
1717
1732
|t, m| Ok ( Self :: freq_power_impl( & self . eval_f64, py, t, m) ) ,
1718
1733
t,
1719
- =m
1734
+ =m;
1735
+ cast=cast
1720
1736
)
1721
1737
}
1722
1738
@@ -1753,7 +1769,7 @@ transform : None, optional
1753
1769
constructors
1754
1770
1755
1771
{common}
1756
- freq_power(t, m)
1772
+ freq_power(t, m, *, cast=False )
1757
1773
Get periodogram
1758
1774
1759
1775
Parameters
@@ -1762,6 +1778,8 @@ freq_power(t, m)
1762
1778
Time array
1763
1779
m : np.ndarray of np.float32 or np.float64
1764
1780
Magnitude (flux) array
1781
+ cast : bool, optional
1782
+ Cast inputs to np.ndarray objects of the same dtype
1765
1783
1766
1784
Returns
1767
1785
-------
0 commit comments