Skip to content

Conversation

@stephenworsley
Copy link
Contributor

Closes #3751.

@stephenworsley
Copy link
Contributor Author

There still seem to be a few tests failing. I'm not sure if these are due to changes in cftime. The one i've looked into is system_test_supported_filetypes in iris.tests.system_test.SystemInitialTest where it seems that time point is now being loaded from pp as an integer rather than a float. While I haven't found the ultimate cause for this change, I have found a part of the Iris code which seems like it could be responsible for such a discrepancy.

def date2hours(t):
epoch_hours = _epoch_date_hours(epoch_hours_unit, t)
if t.minute == 0 and t.second == 0:
epoch_hours = round(epoch_hours)
return epoch_hours
def date2year(t_in):
return t_in.year
# Check whether inputs are all scalar, for faster handling of scalar cases.
do_vector = len(t1_dims) + len(t2_dims) + len(lbft_dims) > 0
if do_vector:
# Reform the input values so they have all the same number of
# dimensions, transposing where necessary (based on the dimension
# mappings) so that the dimensions are common across each array.
# Note: this does not _guarantee_ that the arrays are broadcastable,
# but subsequent arithmetic makes this assumption.
t1, t2, lbft = _reshape_vector_args(
[(t1, t1_dims), (t2, t2_dims), (lbft, lbft_dims)]
)
date2hours = np.vectorize(date2hours)
date2year = np.vectorize(date2year)

In the above code, round() will give an int while np.vectorize(round)() will preserve type. There will therefore be a discrepancy on load depending on dimensionality.

@stephenworsley stephenworsley changed the title Unpin cftime Unpin cftime (WIP) Jul 21, 2020
@stephenworsley stephenworsley changed the title Unpin cftime (WIP) Unpin cftime Jul 23, 2020
@bjlittle
Copy link
Member

@stephenworsley Awesome, thanks for following through on this, and raising this issue with the cftime community (Unidata/cftime#182), who responded with at 1.2.1 patch fix, see their changlog.

👍 🎉

@bjlittle bjlittle merged commit 11bbbeb into SciTools:master Jul 23, 2020
tkknight added a commit to tkknight/iris that referenced this pull request Jul 26, 2020
* pin_for_temp_fix_for_readthedocs:
  pin matplotlib<3.3
  moved to oceanography section of gallery (SciTools#3761)
  unpin cftime (SciTools#3757)
  flake8 outstanding files (SciTools#3755)
  Numpy rounding fix (SciTools#3758)
tkknight added a commit to tkknight/iris that referenced this pull request Jul 30, 2020
* master:
  pin matplotlib<3.3 (SciTools#3763)
  moved to oceanography section of gallery (SciTools#3761)
  unpin cftime (SciTools#3757)
  flake8 outstanding files (SciTools#3755)
  Numpy rounding fix (SciTools#3758)
abooton pushed a commit to abooton/iris that referenced this pull request Aug 13, 2020
tkknight added a commit to tkknight/iris that referenced this pull request Aug 15, 2020
* master:
  remove duplicate whats new entries from the last release (SciTools#3773)
  whatsnew latest update (SciTools#3771)
  whatsnew overhaul (SciTools#3769)
  Gallery code consistency (SciTools#3766)
  enabled pdf creation (SciTools#3765)
  pin matplotlib<3.3 (SciTools#3763)
  moved to oceanography section of gallery (SciTools#3761)
  unpin cftime (SciTools#3757)
  flake8 outstanding files (SciTools#3755)
  Numpy rounding fix (SciTools#3758)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unpin cftime

2 participants