Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
/// These methods transfers ownership of the Rust allocation into a suitable Python object
/// and uses the memory as the internal buffer backing the NumPy array.
///
/// Please note that some destructive methods like [`resize`][Self::resize] will fail
/// Please note that some destructive methods like [`resize`][PyArrayMethods::resize] will fail
/// when used with this kind of array as NumPy cannot reallocate the internal buffer.
///
/// - Allocated by NumPy: Constructed via other methods, like [`ToPyArray`] or
Expand Down Expand Up @@ -94,6 +94,7 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
/// });
/// ```
///
/// [`PyObject`]: pyo3::ffi::PyObject
/// [ndarray]: https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html
/// [pyo3-memory]: https://pyo3.rs/main/memory.html
#[repr(transparent)]
Expand Down Expand Up @@ -183,7 +184,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
/// into Python's heap, which NumPy will automatically zero-initialize.
///
/// However, the elements themselves will not be valid and should be initialized manually
/// using raw pointers obtained via [`uget_raw`][Self::uget_raw]. Before that, all methods
/// using raw pointers obtained via [`uget_raw`][PyArrayMethods::uget_raw]. Before that, all methods
/// which produce references to the elements invoke undefined behaviour. In particular,
/// zero-initialized pointers are _not_ valid instances of `PyObject`.
///
Expand Down Expand Up @@ -721,7 +722,7 @@ pub trait PyArrayMethods<'py, T, D>: PyUntypedArrayMethods<'py> + Sized {
/// Returns a pointer to the first element of the array.
fn data(&self) -> *mut T;

/// Same as [`shape`][PyUntypedArray::shape], but returns `D` instead of `&[usize]`.
/// Same as [`shape`][PyUntypedArrayMethods::shape], but returns `D` instead of `&[usize]`.
#[inline(always)]
fn dims(&self) -> D
where
Expand Down
6 changes: 3 additions & 3 deletions src/borrow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
//!
//! This does limit the set of programs that can be written using safe Rust in way similar to rustc itself
//! which ensures that all accepted programs are memory safe but does not necessarily accept all memory safe programs.
//! However, the unsafe method [`PyArray::as_array_mut`] can be used as an escape hatch.
//! However, the unsafe method [`PyArrayMethods::as_array_mut`] can be used as an escape hatch.
//! More involved cases like the example from above may be supported in the future.
//!
//! [base]: https://numpy.org/doc/stable/reference/c-api/types-and-structures.html#c.NPY_AO.base
Expand Down Expand Up @@ -529,7 +529,7 @@ where
///
/// Calling this will prevent any further [PyReadwriteArray]s from being taken out. Python
/// space can reset this flag, unless the additional flag [`OWNDATA`][owndata] is unset. Such
/// an array can be created from Rust space by using [PyArray::borrow_from_array_bound].
/// an array can be created from Rust space by using [PyArray::borrow_from_array].
///
/// [writeable]: https://numpy.org/doc/stable/reference/c-api/array.html#c.NPY_ARRAY_WRITEABLE
/// [owndata]: https://numpy.org/doc/stable/reference/c-api/array.html#c.NPY_ARRAY_OWNDATA
Expand Down Expand Up @@ -604,7 +604,7 @@ where
{
/// Extends or truncates the dimensions of an array.
///
/// Safe wrapper for [`PyArray::resize`].
/// Safe wrapper for [`PyArrayMethods::resize`].
///
/// Note that as this mutates a pointed-to object, the [`PyReadwriteArray`] must be the only
/// Python reference to the object. There cannot be `PyArray` pointers or even `Bound<PyAny>`
Expand Down
2 changes: 1 addition & 1 deletion src/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<U: Unit> fmt::Debug for Datetime<U> {
}
}

/// Corresponds to the [`timedelta64`][scalars-datetime64] scalar type
/// Corresponds to the [`timedelta64`][scalars-timedelta64] scalar type
///
/// [scalars-timedelta64]: https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.timedelta64
#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand Down
4 changes: 2 additions & 2 deletions src/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
///
/// Equivalent to [`numpy.dtype.itemsize`][dtype-itemsize].
///
/// [dtype-itemsiize]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.itemsize.html
/// [dtype-itemsize]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.itemsize.html
fn itemsize(&self) -> usize;

/// Returns the required alignment (bytes) of this type descriptor according to the compiler.
Expand Down Expand Up @@ -296,7 +296,7 @@ pub trait PyArrayDescrMethods<'py>: Sealed {
/// This method will return an error if this type descriptor is not structured,
/// or if it does not contain a field with a given name.
///
/// The list of all names can be found via [`PyArrayDescr::names`].
/// The list of all names can be found via [`PyArrayDescrMethods::names`].
///
/// Equivalent to retrieving a single item from [`numpy.dtype.fields`][dtype-fields].
///
Expand Down
2 changes: 1 addition & 1 deletion src/untyped_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ pub trait PyUntypedArrayMethods<'py>: Sealed {

/// Returns a slice which contains dimensions of the array.
///
/// See also [`ndarray.shape`][ndaray-shape] and [`PyArray_DIMS`][PyArray_DIMS].
/// See also [`ndarray.shape`][ndarray-shape] and [`PyArray_DIMS`][PyArray_DIMS].
///
/// # Example
///
Expand Down
7 changes: 5 additions & 2 deletions x.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
from pathlib import Path


def run(*args):
subprocess.run([*args], check=True)
def run(*args, env=None):
if env is not None:
env = {**os.environ, **env}
subprocess.run([*args], check=True, env=env)


def can_run(*args):
Expand Down Expand Up @@ -55,6 +57,7 @@ def default(args):


def check(args):
run("cargo", "doc", "--no-deps", env={"RUSTDOCFLAGS": "--deny warnings"})
run("cargo", "fmt", "--", "--check")
run("cargo", "clippy", "--all-features", "--tests", "--", *DENY_WARNINGS)

Expand Down
Loading