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

Update docs CubeList.extract method #3694

Merged
merged 1 commit into from
Apr 3, 2020
Merged

Conversation

lbdreyer
Copy link
Member

@lbdreyer lbdreyer commented Apr 3, 2020

This originated from a support query. The user was using cubelist.extract_strict() with a single constraint and was confused why this was returning a cube rather than a cubelist. The pertinent lines are these:

iris/lib/iris/cube.py

Lines 324 to 325 in cbfbbb2

if strict and len(constraints) == 1:
result = result[0]

I think we need to highlight the fact that using strict=True and one constraint returns a single cube.

@pp-mo pp-mo merged commit f5feb28 into SciTools:master Apr 3, 2020
@pp-mo
Copy link
Member

pp-mo commented Apr 3, 2020

I'm 👍 on what you've done here.
But I do wish it was never written like this in the first place. We don't tend to return different types of things in different cases + I think it is a bad practice generally.
As it's really cheap, I'm going to suggest we fix this for Iris 3.0

@lbdreyer
Copy link
Member Author

lbdreyer commented Apr 3, 2020

Thanks @pp-mo !

But I do wish it was never written like this in the first place

I do agree with this. I found the behaviour to be quite surprising

stephenworsley added a commit to stephenworsley/iris that referenced this pull request Jun 8, 2020
… 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)
tkknight pushed a commit to tkknight/iris that referenced this pull request Jun 29, 2020
@lbdreyer lbdreyer deleted the extract_docs branch June 23, 2021 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants