Poor error message on Dataset.sum(axis=...)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
MCVE Code Sample
I'm attaching the relevant .nc file.
foo = xr.open_dataset('ll_means.nc')
print(foo)
foo.sum(axis=1) # or foo.sum(axis=0)
Instead of getting a sum (either across the data variables or across the dimension shared between the variables), I get the error in the title: ValueError: cannot supply both 'axis' and 'dim' arguments even though I did not supply a dim argument. Furthermore, I get this error even when passing dim=None.
It's possible that I am doing something wrong, and it is just the error message that is bad, and not the behavior. I don't know enough to tell.
Expected Output
TBQH, I didn't know whether this would sum across the (single) dimension of this dataset, or if it would sum across the data variables along that dimension. I was experimenting to try to figure this out.
What I am trying to do is sum across the data variables, "perpendicular" to a dimension, instead of along it.
Problem Description
I assumed that summing across one of the axes would sum across the data variables, but perhaps that was a bad assumption. At any rate, the current behavior is undesirable.
Output of xr.show_versions()
xarray: 0.12.3
pandas: 0.25.1
numpy: 1.17.1
scipy: 1.3.1
netCDF4: 1.5.2
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.1.1
cartopy: None
seaborn: 0.9.0
numbagg: None
setuptools: 41.2.0
pip: 19.3.1
conda: None
pytest: None
IPython: 7.8.0
sphinx: None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the MCVE entry point, Dataset.sum(axis=...), using the attached ll_means.nc file and the reported axis=0, axis=1, and dim=None calls. Determine whether the issue is the operation or only the error message; done means the requested behavior is defined and the resulting error or sum is consistent with that definition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100