MCPcopy Create free account
hub / github.com/numpy/numpy / _compare

Method _compare

numpy/lib/_version.py:114–134  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

112 return vercmp
113
114 def _compare(self, other):
115 if not isinstance(other, (str, NumpyVersion)):
116 raise ValueError("Invalid object to compare with NumpyVersion.")
117
118 if isinstance(other, str):
119 other = NumpyVersion(other)
120
121 vercmp = self._compare_version(other)
122 if vercmp == 0:
123 # Same x.y.z version, check for alpha/beta/rc
124 vercmp = self._compare_pre_release(other)
125 if vercmp == 0:
126 # Same version and same pre-release, check if dev version
127 if self.is_devversion is other.is_devversion:
128 vercmp = 0
129 elif self.is_devversion:
130 vercmp = -1
131 else:
132 vercmp = 1
133
134 return vercmp
135
136 def __lt__(self, other):
137 return self._compare(other) < 0

Callers 6

__lt__Method · 0.95
__le__Method · 0.95
__eq__Method · 0.95
__ne__Method · 0.95
__gt__Method · 0.95
__ge__Method · 0.95

Calls 3

_compare_versionMethod · 0.95
_compare_pre_releaseMethod · 0.95
NumpyVersionClass · 0.85

Tested by

no test coverage detected