Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecations from 0.15.x #1409

Merged
merged 9 commits into from
Aug 2, 2024
29 changes: 0 additions & 29 deletions ndarray-rand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,32 +310,3 @@ fn get_rng() -> SmallRng
{
SmallRng::from_rng(thread_rng()).expect("create SmallRng from thread_rng failed")
}

/// A wrapper type that allows casting f64 distributions to f32
///
/// ```
/// use ndarray::Array;
/// use ndarray_rand::{RandomExt, F32};
/// use ndarray_rand::rand_distr::Normal;
///
/// # fn main() {
/// let distribution_f64 = Normal::new(0., 1.).expect("Failed to create normal distribution");
/// let a = Array::random((2, 5), F32(distribution_f64));
/// println!("{:8.4}", a);
/// // Example Output:
/// // [[ -0.6910, 1.1730, 1.0902, -0.4092, -1.7340],
/// // [ -0.6810, 0.1678, -0.9487, 0.3150, 1.2981]]
/// # }
#[derive(Copy, Clone, Debug)]
#[deprecated(since = "0.14.0", note = "Redundant with rand 0.8")]
pub struct F32<S>(pub S);

#[allow(deprecated)]
impl<S> Distribution<f32> for F32<S>
where S: Distribution<f64>
{
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f32
{
self.0.sample(rng) as f32
}
}
47 changes: 0 additions & 47 deletions src/data_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ pub unsafe trait RawData: Sized
/// The array element type.
type Elem;

#[doc(hidden)]
// This method is only used for debugging
#[deprecated(note = "Unused", since = "0.15.2")]
fn _data_slice(&self) -> Option<&[Self::Elem]>;

#[doc(hidden)]
fn _is_pointer_inbounds(&self, ptr: *const Self::Elem) -> bool;

Expand Down Expand Up @@ -177,12 +172,6 @@ unsafe impl<A> RawData for RawViewRepr<*const A>
{
type Elem = A;

#[inline]
fn _data_slice(&self) -> Option<&[A]>
{
None
}

#[inline(always)]
fn _is_pointer_inbounds(&self, _ptr: *const Self::Elem) -> bool
{
Expand All @@ -204,12 +193,6 @@ unsafe impl<A> RawData for RawViewRepr<*mut A>
{
type Elem = A;

#[inline]
fn _data_slice(&self) -> Option<&[A]>
{
None
}

#[inline(always)]
fn _is_pointer_inbounds(&self, _ptr: *const Self::Elem) -> bool
{
Expand Down Expand Up @@ -247,10 +230,6 @@ unsafe impl<A> RawDataClone for RawViewRepr<*mut A>
unsafe impl<A> RawData for OwnedArcRepr<A>
{
type Elem = A;
fn _data_slice(&self) -> Option<&[A]>
{
Some(self.0.as_slice())
}

fn _is_pointer_inbounds(&self, self_ptr: *const Self::Elem) -> bool
{
Expand Down Expand Up @@ -353,11 +332,6 @@ unsafe impl<A> RawData for OwnedRepr<A>
{
type Elem = A;

fn _data_slice(&self) -> Option<&[A]>
{
Some(self.as_slice())
}

fn _is_pointer_inbounds(&self, self_ptr: *const Self::Elem) -> bool
{
let slc = self.as_slice();
Expand Down Expand Up @@ -437,12 +411,6 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a A>
{
type Elem = A;

#[inline]
fn _data_slice(&self) -> Option<&[A]>
{
None
}

#[inline(always)]
fn _is_pointer_inbounds(&self, _ptr: *const Self::Elem) -> bool
{
Expand Down Expand Up @@ -481,12 +449,6 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a mut A>
{
type Elem = A;

#[inline]
fn _data_slice(&self) -> Option<&[A]>
{
None
}

#[inline(always)]
fn _is_pointer_inbounds(&self, _ptr: *const Self::Elem) -> bool
{
Expand Down Expand Up @@ -603,15 +565,6 @@ unsafe impl<'a, A> RawData for CowRepr<'a, A>
{
type Elem = A;

fn _data_slice(&self) -> Option<&[A]>
{
#[allow(deprecated)]
match self {
CowRepr::View(view) => view._data_slice(),
CowRepr::Owned(data) => data._data_slice(),
}
}

#[inline]
fn _is_pointer_inbounds(&self, ptr: *const Self::Elem) -> bool
{
Expand Down
31 changes: 1 addition & 30 deletions src/dimension/axes.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{Axis, Dimension, Ix, Ixs};
use crate::{Axis, Dimension, Ixs};

/// Create a new Axes iterator
pub(crate) fn axes_of<'a, D>(d: &'a D, strides: &'a D) -> Axes<'a, D>
Expand Down Expand Up @@ -58,35 +58,6 @@ pub struct AxisDescription
}

copy_and_clone!(AxisDescription);

// AxisDescription can't really be empty
// https://github.com/rust-ndarray/ndarray/pull/642#discussion_r296051702
#[allow(clippy::len_without_is_empty)]
impl AxisDescription
{
/// Return axis
#[deprecated(note = "Use .axis field instead", since = "0.15.0")]
#[inline(always)]
pub fn axis(self) -> Axis
{
self.axis
}
/// Return length
#[deprecated(note = "Use .len field instead", since = "0.15.0")]
#[inline(always)]
pub fn len(self) -> Ix
{
self.len
}
/// Return stride
#[deprecated(note = "Use .stride field instead", since = "0.15.0")]
#[inline(always)]
pub fn stride(self) -> Ixs
{
self.stride
}
}

copy_and_clone!(['a, D] Axes<'a, D>);

impl<'a, D> Iterator for Axes<'a, D>
Expand Down
62 changes: 0 additions & 62 deletions src/impl_constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,66 +625,4 @@ where
}
array
}

#[deprecated(
note = "This method is hard to use correctly. Use `uninit` instead.",
since = "0.15.0"
)]
#[allow(clippy::uninit_vec)] // this is explicitly intended to create uninitialized memory
/// Create an array with uninitialized elements, shape `shape`.
///
/// Prefer to use [`uninit()`](ArrayBase::uninit) if possible, because it is
/// easier to use correctly.
///
/// **Panics** if the number of elements in `shape` would overflow isize.
///
/// ### Safety
///
/// Accessing uninitialized values is undefined behaviour. You must overwrite *all* the elements
/// in the array after it is created; for example using
/// [`raw_view_mut`](ArrayBase::raw_view_mut) or other low-level element access.
///
/// The contents of the array is indeterminate before initialization and it
/// is an error to perform operations that use the previous values. For
/// example it would not be legal to use `a += 1.;` on such an array.
///
/// This constructor is limited to elements where `A: Copy` (no destructors)
/// to avoid users shooting themselves too hard in the foot.
///
/// (Also note that the constructors `from_shape_vec` and
/// `from_shape_vec_unchecked` allow the user yet more control, in the sense
/// that Arrays can be created from arbitrary vectors.)
pub unsafe fn uninitialized<Sh>(shape: Sh) -> Self
where
A: Copy,
Sh: ShapeBuilder<Dim = D>,
{
let shape = shape.into_shape_with_order();
let size = size_of_shape_checked_unwrap!(&shape.dim);
let mut v = Vec::with_capacity(size);
v.set_len(size);
Self::from_shape_vec_unchecked(shape, v)
}
}

impl<S, A, D> ArrayBase<S, D>
where
S: DataOwned<Elem = MaybeUninit<A>>,
D: Dimension,
{
/// Create an array with uninitialized elements, shape `shape`.
///
/// This method has been renamed to `uninit`
#[deprecated(note = "Renamed to `uninit`", since = "0.15.0")]
pub fn maybe_uninit<Sh>(shape: Sh) -> Self
where Sh: ShapeBuilder<Dim = D>
{
unsafe {
let shape = shape.into_shape_with_order();
let size = size_of_shape_checked_unwrap!(&shape.dim);
let mut v = Vec::with_capacity(size);
v.set_len(size);
Self::from_shape_vec_unchecked(shape, v)
}
}
}
57 changes: 2 additions & 55 deletions src/impl_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,13 +1119,6 @@ where
Lanes::new(self.view(), Axis(n - 1))
}

#[deprecated(note = "Renamed to .rows()", since = "0.15.0")]
pub fn genrows(&self) -> Lanes<'_, A, D::Smaller>
where S: Data
{
self.rows()
}

/// Return a producer and iterable that traverses over the *generalized*
/// rows of the array and yields mutable array views.
///
Expand All @@ -1140,13 +1133,6 @@ where
LanesMut::new(self.view_mut(), Axis(n - 1))
}

#[deprecated(note = "Renamed to .rows_mut()", since = "0.15.0")]
pub fn genrows_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
where S: DataMut
{
self.rows_mut()
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array. For a 2D array these are the regular columns.
///
Expand Down Expand Up @@ -1179,17 +1165,6 @@ where
Lanes::new(self.view(), Axis(0))
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array. For a 2D array these are the regular columns.
///
/// Renamed to `.columns()`
#[deprecated(note = "Renamed to .columns()", since = "0.15.0")]
pub fn gencolumns(&self) -> Lanes<'_, A, D::Smaller>
where S: Data
{
self.columns()
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array and yields mutable array views.
///
Expand All @@ -1200,17 +1175,6 @@ where
LanesMut::new(self.view_mut(), Axis(0))
}

/// Return a producer and iterable that traverses over the *generalized*
/// columns of the array and yields mutable array views.
///
/// Renamed to `.columns_mut()`
#[deprecated(note = "Renamed to .columns_mut()", since = "0.15.0")]
pub fn gencolumns_mut(&mut self) -> LanesMut<'_, A, D::Smaller>
where S: DataMut
{
self.columns_mut()
}

/// Return a producer and iterable that traverses over all 1D lanes
/// pointing in the direction of `axis`.
///
Expand Down Expand Up @@ -1991,7 +1955,7 @@ where
/// [3., 4.]])
/// );
/// ```
#[deprecated = "Use `.into_shape_with_order()` or `.to_shape()`"]
#[deprecated(note = "Use `.into_shape_with_order()` or `.to_shape()`", since = "0.16.0")]
pub fn into_shape<E>(self, shape: E) -> Result<ArrayBase<S, E::Dim>, ShapeError>
where E: IntoDimension
{
Expand Down Expand Up @@ -2100,10 +2064,7 @@ where
/// );
/// ```
#[track_caller]
#[deprecated(
note = "Obsolete, use `to_shape` or `into_shape_with_order` instead.",
since = "0.15.2"
)]
#[deprecated(note = "Use `.into_shape_with_order()` or `.to_shape()`", since = "0.16.0")]
pub fn reshape<E>(&self, shape: E) -> ArrayBase<S, E::Dim>
where
S: DataShared + DataOwned,
Expand Down Expand Up @@ -2942,20 +2903,6 @@ where
self.fold((), move |(), elt| f(elt))
}

/// Visit each element in the array by calling `f` by reference
/// on each element.
///
/// Elements are visited in arbitrary order.
#[deprecated(note = "Renamed to .for_each()", since = "0.15.0")]
pub fn visit<'a, F>(&'a self, f: F)
where
F: FnMut(&'a A),
A: 'a,
S: Data,
{
self.for_each(f)
}

/// Fold along an axis.
///
/// Combine the elements of each subview with the previous using the `fold`
Expand Down
2 changes: 1 addition & 1 deletion src/impl_owned_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ where D: Dimension
/// Depending on slicing and strides, the logically first element of the
/// array can be located at an offset. Because of this, prefer to use
/// `.into_raw_vec_and_offset()` instead.
#[deprecated(note = "Use .into_raw_vec_and_offset() instead")]
#[deprecated(note = "Use .into_raw_vec_and_offset() instead", since = "0.16.0")]
pub fn into_raw_vec(self) -> Vec<A>
{
self.into_raw_vec_and_offset().0
Expand Down
3 changes: 1 addition & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ pub use crate::linalg_traits::LinalgScalar;
#[cfg(feature = "std")]
pub use crate::linalg_traits::NdFloat;

#[allow(deprecated)] // stack_new_axis
pub use crate::stacking::{concatenate, stack, stack_new_axis};
pub use crate::stacking::{concatenate, stack};

pub use crate::impl_views::IndexLonger;
pub use crate::math_cell::MathCell;
Expand Down
10 changes: 0 additions & 10 deletions src/numeric/impl_numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,6 @@ where
sum
}

/// Return the sum of all elements in the array.
///
/// *This method has been renamed to `.sum()`*
#[deprecated(note = "renamed to `sum`", since = "0.15.0")]
pub fn scalar_sum(&self) -> A
where A: Clone + Add<Output = A> + num_traits::Zero
{
self.sum()
}

/// Returns the [arithmetic mean] x̅ of all elements in the array:
///
/// ```text
Expand Down
Loading