question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement `Array.__iter__`

See original GitHub issue

This came up recently in https://github.com/pandas-dev/pandas/issues/38645 and I took a greedy stab at implementing it in: https://github.com/dask/dask/pull/7888

I abandoned that PR because a bunch of tests failed and I feel like it’s at least a little surprising to have list(array) return a list of real values. It seems too easy to do by mistake.

For context, currently on main if you call list(array) you get an array of getitem calls with the same length as the 0th dimension of the array. It’s possible that is already the best solution. In which case we can probably close this.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
davidhassellcommented, Jul 16, 2021

Hello, I’ve been following this with interest, and also agree that the “array of getitem calls with the same length as the 0th” is what I would expect to occur (i.e. not returning computed numpy arrays).

Thanks, David

2reactions
jsignellcommented, Jul 15, 2021

On main you get

ValueError: Arrays chunk sizes are unknown: (nan,)

A possible solution: https://docs.dask.org/en/latest/array-chunks.html#unknown-chunks
Summary: to compute chunks sizes, use

   x.compute_chunk_sizes()  # for Dask Array `x`
   ddf.to_dask_array(lengths=True)  # for Dask DataFrame `ddf`

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Default iterator implementation for array of Object (T[])?
Closest thing to a default implementation in the JDK: Arrays.asList(array).iterator(). Simple custom implementation:
Read more >
Array.prototype[@@iterator]() - JavaScript - MDN Web Docs
The @@iterator method of an Array object implements the iterable protocol and allows arrays to be consumed by most syntaxes expecting ...
Read more >
An example of implementing Iterable and Iterator in Java
Implementing an iterator over some collection, in this case an array. // * Implementing the Iterable interface, which enables your collection.
Read more >
How to convert Java Array to Iterable? - Tutorialspoint
To make an array iterable either you need to convert it to a stream or as a list using the asList() or stream()...
Read more >
How Does an Array Iterator Works in Java? - eduCBA
Java Array Iterator defined as iterating all the array elements by applying different looping logic on the array. Arrays are used to store...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found