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

Column to be initialized by iterator #5493

Open
bsipocz opened this issue Nov 22, 2016 · 2 comments
Open

Column to be initialized by iterator #5493

bsipocz opened this issue Nov 22, 2016 · 2 comments

Comments

@bsipocz
Copy link
Member

bsipocz commented Nov 22, 2016

To create a single Column from a nested list, I do something along these lines:

import itertools
from astropy.table import Column

a = [[x] * x for x in range(1, 5)]
Column(list(itertools.chain(*a)))

I wonder whether it would make any sense to modify Column to directly accept iterators as initialization? I tried to find issues where this was discussed, and I guess probably this is upstream as np arrays work exactly the same.

@taldcroft
Copy link
Member

In theory one might allow this via np.fromiter. In this case it is required to provide a dtype.

One question is whether there is a good reason np.array does not allow initialization from iterators and forces going through fromiter.

@mhvk
Copy link
Contributor

mhvk commented Nov 22, 2016

One question is whether there is a good reason np.array does not allow initialization from iterators and forces going through fromiter.

There is a PR: numpy/numpy#5863, but the discussion has not been in favour: http://numpy-discussion.10968.n7.nabble.com/FeatureRequest-support-for-array-construction-from-iterators-td41729.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants