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.

Slicing bug with xarray

See original GitHub issue

I found a subtle bug when slicing Images created with xarray, where an incorrect position is returned. Unfortunately, I am unable to demonstrate this with synthetic data, but the following notebook illustrates the problem:

https://gist.github.com/drs251/f97801aa7d6f92b11c9c71c6a7c4085a

EDIT: I found out how to reproduce it: the key is that the frames have to be non-square:

import numpy as np
import xarray as xr
import holoviews as hv
hv.notebook_extension()

x = np.linspace(-3, 7, 533)
y = np.linspace(-5, 8, 894)
z = np.exp(-1*(x**2 + y[:, np.newaxis]**2))
p = np.arange(5)
zz = np.dstack([z, z, z, z, z])
array = xr.DataArray(zz, coords=[y, x, p], dims=['x', 'y', 'p'])
array.name = "intensity"

image = hv.Dataset(array).to(hv.Image, kdims=["x", "y"])
image[0, -1:1, -1:1]

The slice should be nicely centered on the maximum, but it’s not.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:36 (36 by maintainers)

github_iconTop GitHub Comments

1reaction
philippjfrcommented, Jan 31, 2018

Great you figured it out!

Sorry for all the problems I caused. Totally my mistake.

No, I’d say that’s a real issue and as you show for xarray we should ignore the matplotlibrc and specify an explicit origin. If you’re up for contributing, adding an explicit origin=‘upper’ here https://github.com/ioam/holoviews/blob/master/holoviews/plotting/mpl/raster.py#L160 would be appreciated otherwise I’ll try to get around to it soon.

0reactions
philippjfrcommented, Feb 5, 2018

I’ve opened an issue for the matplotlib origin thing, and the original bug mentioned in this issue has been fixed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

slice in xarray gives error 'float' object cannot be interpreted as ...
I am trying to slice data by longtitude using xarray . The data is in a netcdf file I created from measurements I...
Read more >
What's New — xray 0.5.0 documentation - Xarray
Fixed a bug where data netCDF variables read from disk with engine='scipy' could still be associated with the file on disk, even after...
Read more >
What's New — xarray 0.8.0 documentation - PyData |
Fix a bug where xarray.ufuncs that take two arguments would incorrectly use to ... Silenced spurious warnings about all-NaN slices when using nan-aware ......
Read more >
Introduction to cf_xarray - CF Xarray - Read the Docs
Slicing works will expand a single key like X to multiple dimensions if those ... coarsen works but everything later will break because...
Read more >
pydata/xarray - Gitter
How can I do an indexing with a slice between two dataarrays? Deepak Cherian. @dcherian ... I haven't used it much so bugs...
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