Skip to content

Commit d981a8d

Browse files
committed
Rename constant to increase readability
1 parent 4dd37aa commit d981a8d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/array_like.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::array::PyArrayMethods;
1313
use crate::{get_array_module, Element, IntoPyArray, PyArray, PyReadonlyArray, PyUntypedArray};
1414

1515
pub trait Coerce: Sealed {
16-
const VAL: bool;
16+
const ALLOW_TYPE_CHANGE: bool;
1717
}
1818

1919
mod sealed {
@@ -29,7 +29,7 @@ pub struct TypeMustMatch;
2929
impl Sealed for TypeMustMatch {}
3030

3131
impl Coerce for TypeMustMatch {
32-
const VAL: bool = false;
32+
const ALLOW_TYPE_CHANGE: bool = false;
3333
}
3434

3535
/// Marker type to indicate that the element type received via [`PyArrayLike`] can be cast to the specified type by NumPy's [`asarray`](https://numpy.org/doc/stable/reference/generated/numpy.asarray.html).
@@ -39,7 +39,7 @@ pub struct AllowTypeChange;
3939
impl Sealed for AllowTypeChange {}
4040

4141
impl Coerce for AllowTypeChange {
42-
const VAL: bool = true;
42+
const ALLOW_TYPE_CHANGE: bool = true;
4343
}
4444

4545
/// Receiver for arrays or array-like types.
@@ -153,7 +153,9 @@ where
153153

154154
// If the input is already an ndarray and `TypeMustMatch` is used then no type conversion
155155
// should be performed.
156-
if (C::VAL || ob.cast::<PyUntypedArray>().is_err()) && matches!(D::NDIM, None | Some(1)) {
156+
if (C::ALLOW_TYPE_CHANGE || ob.cast::<PyUntypedArray>().is_err())
157+
&& matches!(D::NDIM, None | Some(1))
158+
{
157159
if let Ok(vec) = ob.extract::<Vec<T>>() {
158160
let array = Array1::from(vec)
159161
.into_dimensionality()
@@ -172,7 +174,7 @@ where
172174
})?
173175
.bind(py);
174176

175-
let kwargs = if C::VAL {
177+
let kwargs = if C::ALLOW_TYPE_CHANGE {
176178
let kwargs = PyDict::new(py);
177179
kwargs.set_item(intern!(py, "dtype"), T::get_dtype(py))?;
178180
Some(kwargs)

0 commit comments

Comments
 (0)