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.

empty_like for object array raises warning

See original GitHub issue
    import zarr
    z = zarr.empty(shape=(2,), dtype="array:u1")
    z[0] = [0, 1, 2]
    z[1] = [0, 0]
    print(z, z[:])
    y = zarr.empty_like(z) # Emits warning
    y[0] = [0, 1, 2]
    y[1] = [0, 0]
    print(y, y[:])

Gives:

<zarr.core.Array (2,) object> [array([0, 1, 2], dtype=uint8) array([0, 0], dtype=uint8)]
/home/jk/.local/lib/python3.5/site-packages/zarr/storage.py:372: FutureWarning: missing object_codec for object array; this will raise a ValueError in version 3.0
  'ValueError in version 3.0', FutureWarning)
<zarr.core.Array (2,) object> [array([0, 1, 2], dtype=uint8) array([0, 0], dtype=uint8)]

Problem description

It seems that empty_like is somehow not copying the codec? However, the array seems to behave perfectly well as a object array, so I’m not sure what’s happening.

Version and installation information

Please provide the following:

  • Value of zarr.__version__: 2.2.0
  • Value of numcodecs.__version__: 0.5.3
  • Version of Python interpreter: 3.5.2
  • Operating system (Linux/Windows/Mac): Linux
  • How Zarr was installed (e.g., “using pip into virtual environment”, or “using conda”):pip

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hyanwongcommented, Jun 25, 2019

Yep thanks. Was ignoring it anyway 😃

1reaction
alimanfoocommented, Jun 25, 2019

Thanks Jerome, this looks like just an API inconsistency, I didn’t properly consider the ..._like creation functions when writing the logic for how the object_codec keyword argument is handled. We should fix this so that no warning is emitted. For now you can ignore the warning, the array should be fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Controlled" creation of object arrays #15047 - numpy ... - GitHub
Auto-creation of object arrays was recently deprecated in numpy. ... I'm still not clear why the warnings were not raised in the release ......
Read more >
Why does console.log display array different than alert?
When constructing an object and printing that object to the console, console.log() will output the object's own properties and their values.
Read more >
Function object, NFE - The Modern JavaScript Tutorial
In that case, the name property is empty, like here: // function created inside array let arr = [function() {}]; alert( arr[0].name ) ......
Read more >
Guide to NumPy
trying to set this attribute raises an Error. flat. Return an iterator object (numpy.flatiter) that acts like a 1-d version of the array....
Read more >
NumPyBook - Linguagem de Programação. - 19 - Passei Direto
N −1 slice objects) it does exactly what you would expect (concatenation of ... Use of this routine increases the chance that array...
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