Skip to content

Commit 7528092

Browse files
committed
API: Rename split_re_im to split_complex
As agreed with ethanhs and jturner314
1 parent 892dab3 commit 7528092

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/impl_raw_views.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ where
156156
{
157157
/// Splits the view into views of the real and imaginary components of the
158158
/// elements.
159-
pub fn split_re_im(self) -> Complex<RawArrayView<T, D>> {
159+
pub fn split_complex(self) -> Complex<RawArrayView<T, D>> {
160160
// Check that the size and alignment of `Complex<T>` are as expected.
161161
// These assertions should always pass, for arbitrary `T`.
162162
assert_eq!(
@@ -375,8 +375,8 @@ where
375375
{
376376
/// Splits the view into views of the real and imaginary components of the
377377
/// elements.
378-
pub fn split_re_im(self) -> Complex<RawArrayViewMut<T, D>> {
379-
let Complex { re, im } = self.into_raw_view().split_re_im();
378+
pub fn split_complex(self) -> Complex<RawArrayViewMut<T, D>> {
379+
let Complex { re, im } = self.into_raw_view().split_complex();
380380
unsafe {
381381
Complex {
382382
re: RawArrayViewMut::new(re.ptr, re.dim, re.strides),

src/impl_views/splitting.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ where
112112
/// [Complex64::new(5., 6.), Complex64::new(7., 8.)],
113113
/// [Complex64::new(9., 10.), Complex64::new(11., 12.)],
114114
/// ];
115-
/// let Complex { re, im } = arr.view().split_re_im();
115+
/// let Complex { re, im } = arr.view().split_complex();
116116
/// assert_eq!(re, array![[1., 3.], [5., 7.], [9., 11.]]);
117117
/// assert_eq!(im, array![[2., 4.], [6., 8.], [10., 12.]]);
118118
/// ```
119-
pub fn split_re_im(self) -> Complex<ArrayView<'a, T, D>> {
119+
pub fn split_complex(self) -> Complex<ArrayView<'a, T, D>> {
120120
unsafe {
121-
let Complex { re, im } = self.into_raw_view().split_re_im();
121+
let Complex { re, im } = self.into_raw_view().split_complex();
122122
Complex {
123123
re: re.deref_into_view(),
124124
im: im.deref_into_view(),
@@ -185,7 +185,7 @@ where
185185
/// [Complex64::new(9., 10.), Complex64::new(11., 12.)],
186186
/// ];
187187
///
188-
/// let Complex { mut re, mut im } = arr.view_mut().split_re_im();
188+
/// let Complex { mut re, mut im } = arr.view_mut().split_complex();
189189
/// assert_eq!(re, array![[1., 3.], [5., 7.], [9., 11.]]);
190190
/// assert_eq!(im, array![[2., 4.], [6., 8.], [10., 12.]]);
191191
///
@@ -195,9 +195,9 @@ where
195195
/// assert_eq!(arr[[0, 1]], Complex64::new(13., 4.));
196196
/// assert_eq!(arr[[2, 0]], Complex64::new(9., 14.));
197197
/// ```
198-
pub fn split_re_im(self) -> Complex<ArrayViewMut<'a, T, D>> {
198+
pub fn split_complex(self) -> Complex<ArrayViewMut<'a, T, D>> {
199199
unsafe {
200-
let Complex { re, im } = self.into_raw_view_mut().split_re_im();
200+
let Complex { re, im } = self.into_raw_view_mut().split_complex();
201201
Complex {
202202
re: re.deref_into_view_mut(),
203203
im: im.deref_into_view_mut(),

tests/array.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -2541,17 +2541,17 @@ fn test_remove_index_oob3() {
25412541
}
25422542

25432543
#[test]
2544-
fn test_split_re_im_view() {
2544+
fn test_split_complex_view() {
25452545
let a = Array3::from_shape_fn((3, 4, 5), |(i, j, k)| {
25462546
Complex::<f32>::new(i as f32 * j as f32, k as f32)
25472547
});
2548-
let Complex { re, im } = a.view().split_re_im();
2548+
let Complex { re, im } = a.view().split_complex();
25492549
assert_relative_eq!(re.sum(), 90.);
25502550
assert_relative_eq!(im.sum(), 120.);
25512551
}
25522552

25532553
#[test]
2554-
fn test_split_re_im_view_roundtrip() {
2554+
fn test_split_complex_view_roundtrip() {
25552555
let a_re = Array3::from_shape_fn((3,1,5), |(i, j, _k)| {
25562556
i * j
25572557
});
@@ -2561,49 +2561,49 @@ fn test_split_re_im_view_roundtrip() {
25612561
let a = Array3::from_shape_fn((3,1,5), |(i,j,k)| {
25622562
Complex::new(a_re[[i,j,k]], a_im[[i,j,k]])
25632563
});
2564-
let Complex { re, im } = a.view().split_re_im();
2564+
let Complex { re, im } = a.view().split_complex();
25652565
assert_eq!(a_re, re);
25662566
assert_eq!(a_im, im);
25672567
}
25682568

25692569
#[test]
2570-
fn test_split_re_im_view_mut() {
2570+
fn test_split_complex_view_mut() {
25712571
let eye_scalar = Array2::<u32>::eye(4);
25722572
let eye_complex = Array2::<Complex<u32>>::eye(4);
25732573
let mut a = Array2::<Complex<u32>>::zeros((4, 4));
2574-
let Complex { mut re, im } = a.view_mut().split_re_im();
2574+
let Complex { mut re, im } = a.view_mut().split_complex();
25752575
re.assign(&eye_scalar);
25762576
assert_eq!(im.sum(), 0);
25772577
assert_eq!(a, eye_complex);
25782578
}
25792579

25802580
#[test]
2581-
fn test_split_re_im_zerod() {
2581+
fn test_split_complex_zerod() {
25822582
let mut a = Array0::from_elem((), Complex::new(42, 32));
2583-
let Complex { re, im } = a.view().split_re_im();
2583+
let Complex { re, im } = a.view().split_complex();
25842584
assert_eq!(re.get(()), Some(&42));
25852585
assert_eq!(im.get(()), Some(&32));
2586-
let cmplx = a.view_mut().split_re_im();
2586+
let cmplx = a.view_mut().split_complex();
25872587
cmplx.re.assign_to(cmplx.im);
25882588
assert_eq!(a.get(()).unwrap().im, 42);
25892589
}
25902590

25912591
#[test]
2592-
fn test_split_re_im_permuted() {
2592+
fn test_split_complex_permuted() {
25932593
let a = Array3::from_shape_fn((3, 4, 5), |(i, j, k)| {
25942594
Complex::new(i * k + j, k)
25952595
});
25962596
let permuted = a.view().permuted_axes([1,0,2]);
2597-
let Complex { re, im } = permuted.split_re_im();
2597+
let Complex { re, im } = permuted.split_complex();
25982598
assert_eq!(re.get((3,2,4)).unwrap(), &11);
25992599
assert_eq!(im.get((3,2,4)).unwrap(), &4);
26002600
}
26012601

26022602
#[test]
2603-
fn test_split_re_im_invert_axis() {
2603+
fn test_split_complex_invert_axis() {
26042604
let mut a = Array::from_shape_fn((2, 3, 2), |(i, j, k)| Complex::new(i as f64 + j as f64, i as f64 + k as f64));
26052605
a.invert_axis(Axis(1));
2606-
let cmplx = a.view().split_re_im();
2606+
let cmplx = a.view().split_complex();
26072607
assert_eq!(cmplx.re, a.mapv(|z| z.re));
26082608
assert_eq!(cmplx.im, a.mapv(|z| z.im));
26092609
}

0 commit comments

Comments
 (0)