Skip to content
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
2 changes: 1 addition & 1 deletion lib/iris/_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

try: # Python 3
from collections.abc import Iterable, Mapping
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Iterable, Mapping
import operator

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from collections import OrderedDict
try: # Python 3
from collections.abc import Iterable
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Iterable
from functools import wraps

Expand Down
20 changes: 14 additions & 6 deletions lib/iris/analysis/maths.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2010 - 2017, Met Office
# (C) British Crown Copyright 2010 - 2019, Met Office
#
# This file is part of Iris.
#
Expand All @@ -22,10 +22,11 @@
from __future__ import (absolute_import, division, print_function)
from six.moves import (filter, input, map, range, zip) # noqa

import warnings
import inspect
import math
import operator
import inspect
import six
import warnings

import cf_units
import numpy as np
Expand Down Expand Up @@ -917,9 +918,16 @@ def ws_units_func(u_cube, v_cube):
if hasattr(data_func, 'nin'):
self.nin = data_func.nin
else:
(args, varargs, keywords, defaults) = inspect.getargspec(data_func)
self.nin = len(args) - (
len(defaults) if defaults is not None else 0)
if six.PY2:
(args, _, _, defaults) = inspect.getargspec(data_func)
self.nin = len(args) - (
len(defaults) if defaults is not None else 0)
else:
sig = inspect.signature(data_func)
args = [param for param in sig.parameters.values()
if (param.kind != param.KEYWORD_ONLY and
param.default is param.empty)]
self.nin = len(args)

if self.nin not in [1, 2]:
msg = ('{} requires {} input data arrays, the IFunc class '
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from collections import namedtuple
try: # Python 3
from collections.abc import Iterator
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Iterator
import copy
from itertools import chain
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Mapping,
MutableMapping,
Iterator)
except: # Python 2.7
except ImportError: # Python 2.7
from collections import (Iterable,
Container,
Mapping,
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

try: # Python 3
from collections.abc import Iterable, MutableMapping
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Iterable, MutableMapping
import os
import re
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/io/format_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

try: # Python 3
from collections.abc import Callable
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Callable
import functools
import os
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/iterate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

try: # Python 3
from collections.abc import Iterator
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Iterator
import itertools
import warnings
Expand Down
7 changes: 3 additions & 4 deletions lib/iris/tests/test_basic_maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,14 +596,13 @@ def vec_mag(u, v):
def vec_mag_data_func(u_data, v_data):
return np.sqrt( u_data**2 + v_data**2 )

vec_mag_ifunc = iris.analysis.maths.IFunc(vec_mag_data_func, lambda a,b: (a + b).units)
vec_mag_ifunc = iris.analysis.maths.IFunc(vec_mag_data_func,
lambda a, b: (a + b).units)
b2 = vec_mag_ifunc(a, c)

self.assertArrayAlmostEqual(b.data, b2.data)

cs_ifunc = iris.analysis.maths.IFunc(np.cumsum,
lambda a: a.units
)
cs_ifunc = iris.analysis.maths.IFunc(np.cumsum, lambda a: a.units)

b = cs_ifunc(a, axis=1)
ans = a.data.copy()
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

try: # Python 3
from collections.abc import Iterable
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Iterable
import datetime
import itertools
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

try: # Python 3
from collections.abc import Hashable
except: # Python 2.7
except ImportError: # Python 2.7
from collections import Hashable
import abc
from contextlib import contextmanager
Expand Down