-
Notifications
You must be signed in to change notification settings - Fork 283
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
Remove cube iter #3656
Remove cube iter #3656
Conversation
@jonseddon this looks good, thanks for putting it together! I wonder whether it would be worth a comment to this in the Iris user guide - probably in §5.2 - cube iteration? It could be reasonably simple - something like the following, for example:
|
@DPeterK Thanks! Good suggestion. That's added now and the documentation's building successfully. |
@@ -103,6 +103,9 @@ same way as loading with constraints: | |||
|
|||
Cube iteration | |||
^^^^^^^^^^^^^^^ | |||
It is not possible to directly iterate over an Iris cube. That is, you cannot call `cube.next()` as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's very good (modern) Python usage to call a next
method directly. Cubes were once iterable by virtue of being indexable #273, but they never did have an actual 'next' function anyway.
So, I think it would be better here to talk about next(cube)
, or list(cube)
or for x in cube
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jonseddon! I think the update to the userguide sounds good 👍 |
I'm 👍 , think this is good to go. Any final comment @lbdreyer -- is this what you were expecting ? |
Looks good to me 👍 |
* master: Remove TestGribMessage (SciTools#3672) Removed iris.tests.integration.test_grib_load and related CML files. (SciTools#3670) Removed grib-specific test to iris-grib. (SciTools#3671) Fixed asv project name to 'scitools-iris'. (SciTools#3660) Remove cube iter (SciTools#3656) Remove test_grib_save.py (SciTools#3669) Remove test_grib2 integration tests (SciTools#3664) Remove uri callback test which is moved to iris-grib (SciTools#3665) 2v4 mergeback picks (SciTools#3668) Remove test_grib_save_rules.py which has been moved to iris-grib (SciTools#3666) Removed ununused skipIf. (SciTools#3632) Remove grib-specific test. (SciTools#3663) Remove obsolete test. (SciTools#3662) remove redundant tests (SciTools#3650) Fixed tests since Numpy 1.18 deprecation of non-int num arguments for linspace. (SciTools#3655)
* Fixed tests since Numpy 1.18 deprecation of non-int num arguments for linspace. (#3655) * remove redundant tests (#3650) * Remove obsolete test. (#3662) * Remove grib-specific test. (#3663) * Removed ununused skipIf. (#3632) * Remove test_grib_save_rules.py which has been moved to iris-grib (#3666) * 2v4 mergeback picks (#3668) * Stop PPDataProxy accessing the file when no data is needed. (#3659) * Add 2.4 whatsnew into full whatsnew list. Co-authored-by: Martin Yeo <[email protected]> * Remove uri callback test which is moved to iris-grib (#3665) * Remove test_grib2 integration tests (#3664) * Remove test_grib_save.py (#3669) * Remove cube iter (#3656) * Fixed asv project name to 'scitools-iris'. (#3660) * Removed grib-specific test to iris-grib. (#3671) * Removed iris.tests.integration.test_grib_load and related CML files. (#3670) * Remove TestGribMessage (#3672) * Switched use of datetime.weekday() to datetime.dayofwk. (#3687) * New image hashes for mpl 3x2 (#3682) * New image hash for iris.test.test_plot.TestSymbols.test_cloud_cover with matplotlib 3.2.0. * Further images changes for mpl3x2. * Yet more updated image results. * Correct and improve dev-guide section on fixing graphics-tests. (#3683) * Correct and improve dev-guide section on fixing graphics-tests. * Review changes + general rethink. * Reduce duplication between 'graphics-tests' and general 'tests' page. * Update docs/iris/src/developers_guide/graphics_tests.rst Co-Authored-By: Martin Yeo <[email protected]> * Update docs/iris/src/developers_guide/graphics_tests.rst Co-Authored-By: Martin Yeo <[email protected]> * Update docs/iris/src/developers_guide/graphics_tests.rst Co-Authored-By: Martin Yeo <[email protected]> * Update docs/iris/src/developers_guide/graphics_tests.rst Co-Authored-By: Martin Yeo <[email protected]> * Update docs/iris/src/developers_guide/graphics_tests.rst Co-Authored-By: Martin Yeo <[email protected]> Co-authored-by: Martin Yeo <[email protected]> Co-authored-by: Martin Yeo <[email protected]> Co-authored-by: Bill Little <[email protected]> Co-authored-by: lbdreyer <[email protected]> Co-authored-by: Jon Seddon <[email protected]>
… default_units_patch * 'default_units' of https://github.com/SciTools/iris: Unify saving behaviour of "unknown" and "no_unit" (SciTools#3711) Change default loading unit from "1" to "unknown" (correct branch) (SciTools#3709) Change default units to "unknown" for all DimensionalMetadata (SciTools#3713) Update docs CubeList.extract method (SciTools#3694) Correct and improve dev-guide section on fixing graphics-tests. (SciTools#3683) New image hashes for mpl 3x2 (SciTools#3682) Switched use of datetime.weekday() to datetime.dayofwk. (SciTools#3687) Remove TestGribMessage (SciTools#3672) Removed iris.tests.integration.test_grib_load and related CML files. (SciTools#3670) Removed grib-specific test to iris-grib. (SciTools#3671) Fixed asv project name to 'scitools-iris'. (SciTools#3660) Remove cube iter (SciTools#3656) Remove test_grib_save.py (SciTools#3669) Remove test_grib2 integration tests (SciTools#3664) Remove uri callback test which is moved to iris-grib (SciTools#3665) 2v4 mergeback picks (SciTools#3668) Remove test_grib_save_rules.py which has been moved to iris-grib (SciTools#3666) Removed ununused skipIf. (SciTools#3632) Remove grib-specific test. (SciTools#3663) Remove obsolete test. (SciTools#3662)
This change has been discussed with @lbdreyer. A TypeError with a useful message is still raised by Python if a Cube is iterated over but
isinstance(cube, collections.Iterable)
now behaves as would be expected. This behaviour is documented in https://docs.python.org/3/reference/datamodel.html#special-method-names.