Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
version NEXT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for this, since as discussed last week it would be best to decide the version numbered name at release-time.

------------

**2024-??-??**

* Fix misleading error message when it is not possible to create area
weights requested from `cf.Field.collapse`
(https://github.com/NCAS-CMS/cf-python/issues/731)

----

version 3.16.1
--------------

Expand Down Expand Up @@ -29,6 +40,8 @@ version 3.16.1
(https://github.com/NCAS-CMS/cf-python/issues/713)
* Changed dependency: ``1.11.1.0<=cfdm<1.11.2.0``

----

version 3.16.0
--------------

Expand Down
23 changes: 11 additions & 12 deletions cf/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -3836,18 +3836,17 @@ def weights(
# Found area weights from X and Y dimension
# coordinates
area_weights = True
else:
Weights.polygon_area(
self,
None,
comp,
weights_axes,
measure=measure,
radius=radius,
great_circle=great_circle,
methods=methods,
auto=False,
)
elif Weights.polygon_area(
self,
None,
comp,
weights_axes,
measure=measure,
radius=radius,
great_circle=great_circle,
methods=methods,
auto=True,
):
# Found area weights from UGRID/geometry cells
area_weights = True

Expand Down
10 changes: 10 additions & 0 deletions cf/test/test_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ def test_weights_cell_measures_coordinates(self):
with self.assertRaises(ValueError):
w = f.weights("area", cell_measures=False, coordinates=False)

def test_weights_exceptions(self):
f = cf.example_field(0)
f.coordinate("X").del_bounds()
f.coordinate("Y").del_bounds()

with self.assertRaisesRegex(
ValueError, "Can't create weights: Unable to find cell areas"
):
f.weights("area")


if __name__ == "__main__":
print("Run date:", datetime.datetime.now())
Expand Down