Skip to content
New issue

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

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

Already on GitHub? # to your account

derived Debug for Iter and IterMut #1353

Merged
merged 2 commits into from
Mar 10, 2024
Merged

derived Debug for Iter and IterMut #1353

merged 2 commits into from
Mar 10, 2024

Conversation

biskwikman
Copy link
Contributor

@biskwikman biskwikman commented Jan 29, 2024

My attempt to implement Debug for Iter, I also did so for IterMut.
#1204

Example:

input:

fn main() {
    let foo = ndarray::Array1::<f64>::zeros(10);
    println!("{:?}", std::iter::zip(0..foo.len(), &foo));
}

output:

Zip { a: 0..10, b: Iter { inner: Slice(Iter([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])) } }

@nilgoyette
Copy link
Collaborator

Update the description with one output example. Also, you left several lines of commented code.

@nilgoyette
Copy link
Collaborator

I see 2 problems:

  • Please also add the output of a 2D arrays so we know how it will be printed
  • Iter { inner: Slice(Iter([...])) } } is uselessly descriptive. The user doesn't want to know the technical architecture of ndarray, he simply wants to print the values in the iterator. I think you will be forced to code the function instead of using #[derive(Debug)] in order to control what you print.

@bluss
Copy link
Member

bluss commented Mar 10, 2024

Rebased. It can be prettier and more logical but it's just a Debug fmt, so it can change later. Thanks, this is a good start for this.

@bluss bluss enabled auto-merge March 10, 2024 08:39
@bluss bluss added this pull request to the merge queue Mar 10, 2024
Merged via the queue into rust-ndarray:master with commit 3ed2022 Mar 10, 2024
8 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants