MCPcopy Create free account
hub / github.com/NCAR/wrf-python / func

Function func

src/wrf/coordpair.py:18–48  ·  view source on GitHub ↗

Operator implementation. Operator action is performed across the same class attributes when the *other* object is a :class:`CoordPair`. If the *other* object is a scalar value, the operator action is performed across all attributes with the scalar value. Arg

(self, other)

Source from the content-addressed store, hash-verified

16
17 """
18 def func(self, other):
19 """Operator implementation.
20
21 Operator action is performed across the same class attributes when
22 the *other* object is a :class:`CoordPair`. If the *other* object is
23 a scalar value, the operator action is performed across all
24 attributes with the scalar value.
25
26 Args:
27
28 other (:class:`CoordPair` or scalar): A separate :class:`CoordPair`
29 object or scalar value.
30
31 Returns:
32
33 :class:`CoordPair`: A new :class:`CoordPair` object that is the
34 result of the operator action.
35
36 """
37 if isinstance(other, CoordPair):
38 args = [None if getattr(self, attr) is None or
39 getattr(other, attr) is None else
40 getattr(getattr(self, attr), operator)(getattr(other,
41 attr))
42 for attr in ("x", "y", "lat", "lon")]
43 else:
44 args = [None if getattr(self, attr) is None
45 else getattr(getattr(self, attr), operator)(other)
46 for attr in ("x", "y", "lat", "lon")]
47
48 return CoordPair(*args)
49
50 return func
51

Callers 4

_llxy_mappingFunction · 0.70
viewitemsFunction · 0.70
viewkeysFunction · 0.70
viewvaluesFunction · 0.70

Calls 1

CoordPairClass · 0.85

Tested by

no test coverage detected