Skip to content

Commit 7a09fef

Browse files
Merge pull request #780 from sadielbartholomew/fieldlist-bug
Return a `FieldList` with `example_fields()`
2 parents e8ccc60 + 1e5f76c commit 7a09fef

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Changelog.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2+
version NEXTRELEASE
3+
-------------------
4+
5+
**2024-??-??**
6+
7+
* Fix bug where `cf.example_fields` returned a `list`
8+
of Fields rather than a `Fieldlist`
9+
(https://github.com/NCAS-CMS/cf-python/issues/725)
10+
11+
----
12+
113
version 3.16.2
214
--------------
315

cf/examplefield.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import cfdm
22

33
from .cfimplementation import implementation
4+
from .fieldlist import FieldList
45

56
_implementation = implementation()
67

@@ -13,7 +14,7 @@ def example_field(n, _implementation=_implementation):
1314

1415

1516
def example_fields(*n, _func=example_field):
16-
return cfdm.example_fields(*n, _func=_func)
17+
return FieldList(cfdm.example_fields(*n, _func=_func))
1718

1819

1920
example_fields.__doc__ = cfdm.example_fields.__doc__.replace("cfdm.", "cf.")

cf/test/test_functions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ class functionTest(unittest.TestCase):
1717
def setUp(self):
1818
self.test_only = ()
1919

20-
def test_example_field(self):
21-
for f in cf.example_fields():
20+
def test_example_field_example_fields(self):
21+
e = cf.example_fields()
22+
self.assertIsInstance(e, cf.FieldList)
23+
24+
for f in e:
25+
self.assertIsInstance(f, cf.Field)
2226
f.dump(display=False)
2327

2428
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)