@@ -87,7 +87,7 @@ impl Coerce for AllowTypeChange {
8787/// let np = get_array_module(py).unwrap();
8888/// let sum_up = wrap_pyfunction!(sum_up)(py).unwrap();
8989///
90- /// py_run!(py, np sum_up, r"assert sum_up(( 1., 2., 3.)) == 6");
90+ /// py_run!(py, np sum_up, r"assert sum_up(np.array([ 1., 2., 3.] )) == 6");
9191/// });
9292/// ```
9393///
@@ -107,6 +107,7 @@ impl Coerce for AllowTypeChange {
107107/// let np = get_array_module(py).unwrap();
108108/// let sum_up = wrap_pyfunction!(sum_up)(py).unwrap();
109109///
110+ /// py_run!(py, np sum_up, r"assert sum_up(np.array([1.5, 2.5])) == 3");
110111/// py_run!(py, np sum_up, r"assert sum_up((1.5, 2.5)) == 3");
111112/// });
112113/// ```
@@ -150,7 +151,7 @@ where
150151 // If the input is already an ndarray and `TypeMustMatch` is used then no type conversion
151152 // should be performed.
152153 if ( C :: ALLOW_TYPE_CHANGE || ob. cast :: < PyUntypedArray > ( ) . is_err ( ) )
153- && matches ! ( D :: NDIM , None | Some ( 1 ) )
154+ && matches ! ( D :: NDIM , Some ( 1 ) )
154155 {
155156 if let Ok ( vec) = ob. extract :: < Vec < T > > ( ) {
156157 let array = Array1 :: from ( vec)
@@ -162,7 +163,7 @@ where
162163 }
163164 }
164165
165- let ( dtype, flags) = if C :: ALLOW_TYPE_CHANGE {
166+ let ( dtype, flags) = if C :: ALLOW_TYPE_CHANGE || ob . cast :: < PyUntypedArray > ( ) . is_err ( ) {
166167 ( Some ( T :: get_dtype ( py) ) , NPY_ARRAY_FORCECAST )
167168 } else {
168169 ( None , 0 )
0 commit comments