NCAS-CMS / NCAS-CMS/cf-python

coordinate equality raises a stack trace instead of a False

Open
#806 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
150
Forks
23
Avg merge
1d 11h
Merged PRs (30d)
2

Description

I am comparing coordinates for equality (don't ask why).

MWE of the problem, given a field with Z and Y dimensions:

zz = f.dimension_coordinate('Z')
yy = f.dimension_coordiante('Y')
zz == yy # raises an error instead of simply raising False:
               # ValueError: Can't compare <Units: m> to <Units: degrees_north>

Platform: Linux-3.10.0-1160.119.1.el7.x86_64-x86_64-with-glibc2.17
HDF5 library: 1.14.3
netcdf library: 4.9.2
udunits2 library: /home/users/lawrence/.conda/envs/mampy24b/lib/libudunits2.so.0
esmpy/ESMF: not available
Python: 3.12.4
dask: 2024.7.0
netCDF4: 1.7.1
h5netcdf: 1.3.0
h5py: 3.11.0
s3fs: 2024.6.1
psutil: 6.0.0
packaging: 24.1
numpy: 2.0.0
scipy: 1.14.0
matplotlib: 3.9.1
cftime: 1.6.4
cfunits: 3.3.7
cfplot: 3.3.0
cfdm: 1.11.2.0
cf: 3.17.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the MWE with Z and Y dimension coordinates and the equality comparison. Trace the coordinate equality and unit-comparison behavior, then add a regression test showing that coordinates with incompatible units return False rather than raising a ValueError.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.