Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code tidy #829

Merged
merged 2 commits into from
Nov 4, 2024
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
31 changes: 12 additions & 19 deletions Changelog.rst
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
version NEXTVERSION + 1
-----------------------

**2024-??-??**

* Allow access to netCDF-4 files in S3 object stores
(https://github.com/NCAS-CMS/cf-python/issues/712)
* New class `cf.H5netcdfArray`
* New class `cf.NetCDF4Array`
* New class `cf.CFAH5netcdfArray`
* New class `cf.CFANetCDF4Array`
* New dependency: ``h5netcdf>=1.3.0``
* New dependency: ``h5py>=3.10.0``
* New dependency: ``s3fs>=2024.2.0``
* Changed dependency: ``1.11.2.0<=cfdm<1.11.3.0``
* Changed dependency: ``cfunits>=3.3.7``

----

version NEXTVERSION
-------------------

Expand All @@ -33,6 +14,12 @@ version NEXTVERSION
* New keyword parameter to `cf.Field.derivative`:
``ignore_coordinate_units``
(https://github.com/NCAS-CMS/cf-python/issues/807)
* Allow access to netCDF-4 files in S3 object stores
(https://github.com/NCAS-CMS/cf-python/issues/712)
* New class `cf.H5netcdfArray`
* New class `cf.NetCDF4Array`
* New class `cf.CFAH5netcdfArray`
* New class `cf.CFANetCDF4Array`
* Fix bug that sometimes puts an incorrect ``radian-1`` or
``radian-2`` in the returned units of the differential operator
methods and functions
Expand All @@ -46,6 +33,12 @@ version NEXTVERSION
* Fix bug where `cf.normalize_slice` doesn't correctly
handle certain cyclic slices
(https://github.com/NCAS-CMS/cf-python/issues/774)
* New dependency: ``h5netcdf>=1.3.0``
* New dependency: ``h5py>=3.10.0``
* New dependency: ``s3fs>=2024.2.0``
* Changed dependency: ``1.11.2.0<=cfdm<1.11.3.0``
* Changed dependency: ``cfunits>=3.3.7``


----

Expand Down
4 changes: 0 additions & 4 deletions cf/test/test_Data.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,6 @@ def test_Data__getitem__(self):
f = cf.Data([-999, 35], mask=[True, False]).reshape(2, 1)
self.assertTrue(e.equals(f))

# REVIEW: getitem: `test_Data__getitem__`: Chained subspaces reading from disk
# Chained subspaces reading from disk
f = cf.read(self.filename)[0]
d = f.data
Expand Down Expand Up @@ -3290,7 +3289,6 @@ def test_Data_rechunk(self):
self.assertEqual(e.chunks, ((4,), (5,)))
self.assertTrue(e.equals(d))

# REVIEW: getitem: `test_Data_rechunk`: rechunking after a __getitem__
# Test rechunking after a __getitem__
e = d[:2].rechunk((2, 5))
self.assertTrue(e.equals(d[:2]))
Expand Down Expand Up @@ -4520,7 +4518,6 @@ def test_Data__str__(self):
for element in elements0:
self.assertNotIn(element, d._get_cached_elements())

# REVIEW: getitem: `test_Data_cull_graph`: prevent new asanyarray layer
def test_Data_cull_graph(self):
"""Test `Data.cull`"""
# Note: The number of layers in the culled graphs include a
Expand Down Expand Up @@ -4779,7 +4776,6 @@ def test_Data_pad_missing(self):
with self.assertRaises(ValueError):
d.pad_missing(99, to_size=99)

# REVIEW: getitem: `test_Data_is_masked`: test `Data.is_masked`
def test_Data_is_masked(self):
"""Test Data.is_masked."""
d = cf.Data(np.arange(6).reshape(2, 3))
Expand Down
2 changes: 0 additions & 2 deletions cf/test/test_Field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1466,7 +1466,6 @@ def test_Field_indices(self):
shape = (1, 1, 1)

self.assertEqual(g.shape, shape)
# REVIEW: getitem: `test_Field_indices`: make sure works when 'g.array' is not masked
self.assertEqual(np.ma.compressed(g.array), 29)
if mode != "full":
self.assertEqual(g.construct("longitude").array, 83)
Expand All @@ -1485,7 +1484,6 @@ def test_Field_indices(self):
shape = (1, 2, 2)

self.assertEqual(g.shape, shape)
# REVIEW: getitem: `test_Field_indices`: make sure works when 'g.array' is not masked
self.assertTrue((np.ma.compressed(g.array) == [4, 29]).all())

# Add 2-d auxiliary coordinates with bounds, so we can
Expand Down
1 change: 0 additions & 1 deletion cf/test/test_FullArray.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REVIEW: getitem: `test_FullArray`: new test module
import datetime
import faulthandler
import unittest
Expand Down
8 changes: 0 additions & 8 deletions cf/test/test_NetCDF4Array.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import cf

# REVIEW: h5: `test_NetCDF4Array.py`: renamed 'NetCDFArray' to 'NetCDF4Array'
n_tmpfiles = 1
tmpfiles = [
tempfile.mkstemp("_test_NetCDF4Array.nc", dir=os.getcwd())[1]
Expand Down Expand Up @@ -41,7 +40,6 @@ class NetCDF4ArrayTest(unittest.TestCase):
dtype=np.dtype(float),
)

# REVIEW: h5: `test_NetCDF4Array`: renamed 'NetCDFArray' to 'NetCDF4Array'
def test_NetCDF4Array_del_file_location(self):
a = cf.NetCDF4Array(("/data1/file1", "/data2/file2"), ("tas1", "tas2"))
b = a.del_file_location("/data1")
Expand All @@ -62,7 +60,6 @@ def test_NetCDF4Array_del_file_location(self):
with self.assertRaises(ValueError):
b.del_file_location("/data1/")

# REVIEW: h5: `test_NetCDF4Array`: renamed 'NetCDFArray' to 'NetCDF4Array'
def test_NetCDF4Array_file_locations(self):
a = cf.NetCDF4Array("/data1/file1")
self.assertEqual(a.file_locations(), ("/data1",))
Expand All @@ -73,7 +70,6 @@ def test_NetCDF4Array_file_locations(self):
a = cf.NetCDF4Array(("/data1/file1", "/data2/file2", "/data1/file2"))
self.assertEqual(a.file_locations(), ("/data1", "/data2", "/data1"))

# REVIEW: h5: `test_NetCDF4Array`: renamed 'NetCDFArray' to 'NetCDF4Array'
def test_NetCDF4Array_add_file_location(self):
a = cf.NetCDF4Array("/data1/file1", "tas")
b = a.add_file_location("/home/user")
Expand Down Expand Up @@ -109,15 +105,13 @@ def test_NetCDF4Array_add_file_location(self):
self.assertEqual(b.get_filenames(), a.get_filenames())
self.assertEqual(b.get_addresses(), a.get_addresses())

# REVIEW: h5: `test_NetCDF4Array`: renamed 'NetCDFArray' to 'NetCDF4Array'
def test_NetCDF4Array__dask_tokenize__(self):
a = cf.NetCDF4Array("/data1/file1", "tas", shape=(12, 2), mask=False)
self.assertEqual(tokenize(a), tokenize(a.copy()))

b = cf.NetCDF4Array("/home/file2", "tas", shape=(12, 2))
self.assertNotEqual(tokenize(a), tokenize(b))

# REVIEW: h5: `test_NetCDF4Array`: renamed 'NetCDFArray' to 'NetCDF4Array'
def test_NetCDF4Array_multiple_files(self):
f = cf.example_field(0)
cf.write(f, tmpfile1)
Expand All @@ -135,7 +129,6 @@ def test_NetCDF4Array_multiple_files(self):
self.assertEqual(len(n.get_filenames()), 2)
self.assertTrue((n[...] == f.array).all())

# REVIEW: getitem: `test_NetCDF4Array`: test `NetCDF4Array.shape`
def test_NetCDF4Array_shape(self):
shape = (12, 73, 96)
a = cf.NetCDF4Array("/home/file2", "tas", shape=shape)
Expand All @@ -145,7 +138,6 @@ def test_NetCDF4Array_shape(self):
self.assertEqual(a.shape, (shape[0] // 2,) + shape[1:])
self.assertEqual(a.original_shape, shape)

# REVIEW: getitem: `test_NetCDF4Array`: test `NetCDF4Array.index`
def test_NetCDF4Array_index(self):
shape = (12, 73, 96)
a = cf.NetCDF4Array("/home/file2", "tas", shape=shape)
Expand Down
1 change: 0 additions & 1 deletion cf/test/test_active_storage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# REVIEW: h5: `test_active_storage.py`: new test module
import atexit
import datetime
import faulthandler
Expand Down
1 change: 0 additions & 1 deletion cf/test/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def test_aliases(self):
self.assertEqual(cf.tempdir(), cf.TEMPDIR())
self.assertEqual(cf.chunksize(), cf.CHUNKSIZE())

# REVIEW: active: `test_configuration`: test `cf.active_storage`, cf.active_storage_url`, cf.active_storage_max_requests`
def test_configuration(self):
# This test assumes 'total_memory' remains constant throughout
# the test run, which should be true generally in any
Expand Down
2 changes: 0 additions & 2 deletions cf/test/test_read_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def test_write_filename(self):

self.assertTrue((a == g[0].array).all())

# REVIEW: h5: `test_read_mask`: rename numpy to np
def test_read_mask(self):
f = self.f0.copy()

Expand Down Expand Up @@ -561,7 +560,6 @@ def test_read_write_netCDF4_compress_shuffle(self):
f"Bad read/write with lossless compression: {fmt}",
)

# REVIEW: h5: `test_write_datatype`: rename numpy to np
def test_write_datatype(self):
f = cf.read(self.filename)[0]
self.assertEqual(f.dtype, np.dtype(float))
Expand Down
Loading