Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

bcolz.zeros cannot handle structured data type (ValueError: too many values to unpack (expected 2)) #406

Open
GuillaumeTong opened this issue Jul 17, 2020 · 0 comments

Comments

@GuillaumeTong
Copy link

When creating a table using bcolz.zeros, data types in the form of (column_name, base_dtype, shape) such as below will cause a ValueError:

b = bcolz.zeros(3, [('a', 'i'), ('b', 'f', (3, ))])
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition with Anaconda plugin 2020.1.1\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_exec2.py", line 1, in Exec
    def Exec(exp, global_vars, local_vars=None):
  File "<input>", line 1, in <module>
  File "C:\Users\guillaume\anaconda3\envs\query-fpp\lib\site-packages\bcolz\toplevel.py", line 296, in zeros
    def zeros(shape, dtype=np.float, **kwargs):
  File "C:\Users\guillaume\anaconda3\envs\query-fpp\lib\site-packages\bcolz\toplevel.py", line 214, in fill
    def fill(shape, dflt=None, dtype=np.float, **kwargs):
ValueError: too many values to unpack (expected 2)

I tried to specify the dimensions in the dtype string, but it also raises the same error:

b = bcolz.zeros(3, [('a', 'i'), ('b', '(3, )f' )])

FYI, here is my current workaround (potentially less fast):

b = bcolz.fromiter(
    iterable=(np.zeros(1, dtype=[('a', 'i'), ('b', 'f', (3, ))])[0] for _ in range(3)),
    dtype=[('a', 'i'), ('b', 'f', (3, ))],
    count=3,
)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant