Skip to content

np.array([], dtype=object) triggers error when copied with copy.deepcopy() #8536

@aojeda

Description

@aojeda

The following code fails with numpy 1.12.0 (this is the only version we have tested).

>>> arr = np.array([], dtype=object)
>>> copy.deepcopy(arr)
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/IPython/core/interactiveshell.py", line 2821, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-16-e314fe8a32a6>", line 1, in <module>
    copy.deepcopy(arr)
  File "/usr/lib/python3.4/copy.py", line 166, in deepcopy
    y = copier(memo)
ValueError: Iteration of zero-sized operands is not enabled

Note that this code already works if the dtype was not object but, e.g., int or str.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions