dclab 0.67.0__cp314-cp314-macosx_10_13_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dclab might be problematic. Click here for more details.

Files changed (142) hide show
  1. dclab/__init__.py +41 -0
  2. dclab/_version.py +34 -0
  3. dclab/cached.py +97 -0
  4. dclab/cli/__init__.py +10 -0
  5. dclab/cli/common.py +237 -0
  6. dclab/cli/task_compress.py +126 -0
  7. dclab/cli/task_condense.py +223 -0
  8. dclab/cli/task_join.py +229 -0
  9. dclab/cli/task_repack.py +98 -0
  10. dclab/cli/task_split.py +154 -0
  11. dclab/cli/task_tdms2rtdc.py +186 -0
  12. dclab/cli/task_verify_dataset.py +75 -0
  13. dclab/definitions/__init__.py +79 -0
  14. dclab/definitions/feat_const.py +202 -0
  15. dclab/definitions/feat_logic.py +182 -0
  16. dclab/definitions/meta_const.py +252 -0
  17. dclab/definitions/meta_logic.py +111 -0
  18. dclab/definitions/meta_parse.py +94 -0
  19. dclab/downsampling.cpython-314-darwin.so +0 -0
  20. dclab/downsampling.pyx +230 -0
  21. dclab/external/__init__.py +4 -0
  22. dclab/external/packaging/LICENSE +3 -0
  23. dclab/external/packaging/LICENSE.APACHE +177 -0
  24. dclab/external/packaging/LICENSE.BSD +23 -0
  25. dclab/external/packaging/__init__.py +6 -0
  26. dclab/external/packaging/_structures.py +61 -0
  27. dclab/external/packaging/version.py +505 -0
  28. dclab/external/skimage/LICENSE +28 -0
  29. dclab/external/skimage/__init__.py +2 -0
  30. dclab/external/skimage/_find_contours.py +216 -0
  31. dclab/external/skimage/_find_contours_cy.cpython-314-darwin.so +0 -0
  32. dclab/external/skimage/_find_contours_cy.pyx +188 -0
  33. dclab/external/skimage/_pnpoly.cpython-314-darwin.so +0 -0
  34. dclab/external/skimage/_pnpoly.pyx +99 -0
  35. dclab/external/skimage/_shared/__init__.py +1 -0
  36. dclab/external/skimage/_shared/geometry.cpython-314-darwin.so +0 -0
  37. dclab/external/skimage/_shared/geometry.pxd +6 -0
  38. dclab/external/skimage/_shared/geometry.pyx +55 -0
  39. dclab/external/skimage/measure.py +7 -0
  40. dclab/external/skimage/pnpoly.py +53 -0
  41. dclab/external/statsmodels/LICENSE +35 -0
  42. dclab/external/statsmodels/__init__.py +6 -0
  43. dclab/external/statsmodels/nonparametric/__init__.py +1 -0
  44. dclab/external/statsmodels/nonparametric/_kernel_base.py +203 -0
  45. dclab/external/statsmodels/nonparametric/kernel_density.py +165 -0
  46. dclab/external/statsmodels/nonparametric/kernels.py +36 -0
  47. dclab/features/__init__.py +9 -0
  48. dclab/features/bright.py +81 -0
  49. dclab/features/bright_bc.py +93 -0
  50. dclab/features/bright_perc.py +63 -0
  51. dclab/features/contour.py +161 -0
  52. dclab/features/emodulus/__init__.py +339 -0
  53. dclab/features/emodulus/load.py +252 -0
  54. dclab/features/emodulus/lut_HE-2D-FEM-22.txt +16432 -0
  55. dclab/features/emodulus/lut_HE-3D-FEM-22.txt +1276 -0
  56. dclab/features/emodulus/lut_LE-2D-FEM-19.txt +13082 -0
  57. dclab/features/emodulus/pxcorr.py +135 -0
  58. dclab/features/emodulus/scale_linear.py +247 -0
  59. dclab/features/emodulus/viscosity.py +260 -0
  60. dclab/features/fl_crosstalk.py +95 -0
  61. dclab/features/inert_ratio.py +377 -0
  62. dclab/features/volume.py +242 -0
  63. dclab/http_utils.py +322 -0
  64. dclab/isoelastics/__init__.py +468 -0
  65. dclab/isoelastics/iso_HE-2D-FEM-22-area_um-deform.txt +2440 -0
  66. dclab/isoelastics/iso_HE-2D-FEM-22-volume-deform.txt +2635 -0
  67. dclab/isoelastics/iso_HE-3D-FEM-22-area_um-deform.txt +1930 -0
  68. dclab/isoelastics/iso_HE-3D-FEM-22-volume-deform.txt +2221 -0
  69. dclab/isoelastics/iso_LE-2D-FEM-19-area_um-deform.txt +2151 -0
  70. dclab/isoelastics/iso_LE-2D-FEM-19-volume-deform.txt +2250 -0
  71. dclab/isoelastics/iso_LE-2D-ana-18-area_um-deform.txt +1266 -0
  72. dclab/kde/__init__.py +1 -0
  73. dclab/kde/base.py +459 -0
  74. dclab/kde/contours.py +222 -0
  75. dclab/kde/methods.py +313 -0
  76. dclab/kde_contours.py +10 -0
  77. dclab/kde_methods.py +11 -0
  78. dclab/lme4/__init__.py +5 -0
  79. dclab/lme4/lme4_template.R +94 -0
  80. dclab/lme4/rsetup.py +204 -0
  81. dclab/lme4/wrapr.py +386 -0
  82. dclab/polygon_filter.py +398 -0
  83. dclab/rtdc_dataset/__init__.py +15 -0
  84. dclab/rtdc_dataset/check.py +902 -0
  85. dclab/rtdc_dataset/config.py +533 -0
  86. dclab/rtdc_dataset/copier.py +353 -0
  87. dclab/rtdc_dataset/core.py +896 -0
  88. dclab/rtdc_dataset/export.py +867 -0
  89. dclab/rtdc_dataset/feat_anc_core/__init__.py +24 -0
  90. dclab/rtdc_dataset/feat_anc_core/af_basic.py +75 -0
  91. dclab/rtdc_dataset/feat_anc_core/af_emodulus.py +160 -0
  92. dclab/rtdc_dataset/feat_anc_core/af_fl_max_ctc.py +133 -0
  93. dclab/rtdc_dataset/feat_anc_core/af_image_contour.py +113 -0
  94. dclab/rtdc_dataset/feat_anc_core/af_ml_class.py +102 -0
  95. dclab/rtdc_dataset/feat_anc_core/ancillary_feature.py +320 -0
  96. dclab/rtdc_dataset/feat_anc_ml/__init__.py +32 -0
  97. dclab/rtdc_dataset/feat_anc_plugin/__init__.py +3 -0
  98. dclab/rtdc_dataset/feat_anc_plugin/plugin_feature.py +329 -0
  99. dclab/rtdc_dataset/feat_basin.py +762 -0
  100. dclab/rtdc_dataset/feat_temp.py +102 -0
  101. dclab/rtdc_dataset/filter.py +263 -0
  102. dclab/rtdc_dataset/fmt_dcor/__init__.py +7 -0
  103. dclab/rtdc_dataset/fmt_dcor/access_token.py +52 -0
  104. dclab/rtdc_dataset/fmt_dcor/api.py +173 -0
  105. dclab/rtdc_dataset/fmt_dcor/base.py +299 -0
  106. dclab/rtdc_dataset/fmt_dcor/basin.py +73 -0
  107. dclab/rtdc_dataset/fmt_dcor/logs.py +26 -0
  108. dclab/rtdc_dataset/fmt_dcor/tables.py +66 -0
  109. dclab/rtdc_dataset/fmt_dict.py +103 -0
  110. dclab/rtdc_dataset/fmt_hdf5/__init__.py +6 -0
  111. dclab/rtdc_dataset/fmt_hdf5/base.py +192 -0
  112. dclab/rtdc_dataset/fmt_hdf5/basin.py +30 -0
  113. dclab/rtdc_dataset/fmt_hdf5/events.py +276 -0
  114. dclab/rtdc_dataset/fmt_hdf5/feat_defect.py +164 -0
  115. dclab/rtdc_dataset/fmt_hdf5/logs.py +33 -0
  116. dclab/rtdc_dataset/fmt_hdf5/tables.py +60 -0
  117. dclab/rtdc_dataset/fmt_hierarchy/__init__.py +11 -0
  118. dclab/rtdc_dataset/fmt_hierarchy/base.py +278 -0
  119. dclab/rtdc_dataset/fmt_hierarchy/events.py +146 -0
  120. dclab/rtdc_dataset/fmt_hierarchy/hfilter.py +140 -0
  121. dclab/rtdc_dataset/fmt_hierarchy/mapper.py +134 -0
  122. dclab/rtdc_dataset/fmt_http.py +102 -0
  123. dclab/rtdc_dataset/fmt_s3.py +354 -0
  124. dclab/rtdc_dataset/fmt_tdms/__init__.py +476 -0
  125. dclab/rtdc_dataset/fmt_tdms/event_contour.py +264 -0
  126. dclab/rtdc_dataset/fmt_tdms/event_image.py +220 -0
  127. dclab/rtdc_dataset/fmt_tdms/event_mask.py +62 -0
  128. dclab/rtdc_dataset/fmt_tdms/event_trace.py +146 -0
  129. dclab/rtdc_dataset/fmt_tdms/exc.py +37 -0
  130. dclab/rtdc_dataset/fmt_tdms/naming.py +151 -0
  131. dclab/rtdc_dataset/load.py +77 -0
  132. dclab/rtdc_dataset/meta_table.py +25 -0
  133. dclab/rtdc_dataset/writer.py +1019 -0
  134. dclab/statistics.py +226 -0
  135. dclab/util.py +176 -0
  136. dclab/warn.py +15 -0
  137. dclab-0.67.0.dist-info/METADATA +153 -0
  138. dclab-0.67.0.dist-info/RECORD +142 -0
  139. dclab-0.67.0.dist-info/WHEEL +6 -0
  140. dclab-0.67.0.dist-info/entry_points.txt +8 -0
  141. dclab-0.67.0.dist-info/licenses/LICENSE +283 -0
  142. dclab-0.67.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,61 @@
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+
5
+
6
+ class InfinityType:
7
+ def __repr__(self) -> str:
8
+ return "Infinity"
9
+
10
+ def __hash__(self) -> int:
11
+ return hash(repr(self))
12
+
13
+ def __lt__(self, other: object) -> bool:
14
+ return False
15
+
16
+ def __le__(self, other: object) -> bool:
17
+ return False
18
+
19
+ def __eq__(self, other: object) -> bool:
20
+ return isinstance(other, self.__class__)
21
+
22
+ def __gt__(self, other: object) -> bool:
23
+ return True
24
+
25
+ def __ge__(self, other: object) -> bool:
26
+ return True
27
+
28
+ def __neg__(self: object) -> "NegativeInfinityType":
29
+ return NegativeInfinity
30
+
31
+
32
+ Infinity = InfinityType()
33
+
34
+
35
+ class NegativeInfinityType:
36
+ def __repr__(self) -> str:
37
+ return "-Infinity"
38
+
39
+ def __hash__(self) -> int:
40
+ return hash(repr(self))
41
+
42
+ def __lt__(self, other: object) -> bool:
43
+ return True
44
+
45
+ def __le__(self, other: object) -> bool:
46
+ return True
47
+
48
+ def __eq__(self, other: object) -> bool:
49
+ return isinstance(other, self.__class__)
50
+
51
+ def __gt__(self, other: object) -> bool:
52
+ return False
53
+
54
+ def __ge__(self, other: object) -> bool:
55
+ return False
56
+
57
+ def __neg__(self: object) -> InfinityType:
58
+ return Infinity
59
+
60
+
61
+ NegativeInfinity = NegativeInfinityType()
@@ -0,0 +1,505 @@
1
+ # This file is dual licensed under the terms of the Apache License, Version
2
+ # 2.0, and the BSD License. See the LICENSE file in the root of this repository
3
+ # for complete details.
4
+ # flake8: noqa: E501
5
+
6
+ import collections
7
+ import itertools
8
+ import re
9
+ import warnings
10
+ from typing import Callable, Iterator, List, Optional, SupportsInt, Tuple, Union
11
+
12
+ from ._structures import Infinity, InfinityType, NegativeInfinity, NegativeInfinityType
13
+
14
+ __all__ = ["parse", "Version", "LegacyVersion", "InvalidVersion", "VERSION_PATTERN"]
15
+
16
+ InfiniteTypes = Union[InfinityType, NegativeInfinityType]
17
+ PrePostDevType = Union[InfiniteTypes, Tuple[str, int]]
18
+ SubLocalType = Union[InfiniteTypes, int, str]
19
+ LocalType = Union[
20
+ NegativeInfinityType,
21
+ Tuple[
22
+ Union[
23
+ SubLocalType,
24
+ Tuple[SubLocalType, str],
25
+ Tuple[NegativeInfinityType, SubLocalType],
26
+ ],
27
+ ...,
28
+ ],
29
+ ]
30
+ CmpKey = Tuple[
31
+ int, Tuple[int, ...], PrePostDevType, PrePostDevType, PrePostDevType, LocalType
32
+ ]
33
+ LegacyCmpKey = Tuple[int, Tuple[str, ...]]
34
+ VersionComparisonMethod = Callable[
35
+ [Union[CmpKey, LegacyCmpKey], Union[CmpKey, LegacyCmpKey]], bool
36
+ ]
37
+
38
+ _Version = collections.namedtuple(
39
+ "_Version", ["epoch", "release", "dev", "pre", "post", "local"]
40
+ )
41
+
42
+
43
+ def parse(version: str) -> Union["LegacyVersion", "Version"]:
44
+ """
45
+ Parse the given version string and return either a :class:`Version` object
46
+ or a :class:`LegacyVersion` object depending on if the given version is
47
+ a valid PEP 440 version or a legacy version.
48
+ """
49
+ try:
50
+ return Version(version)
51
+ except InvalidVersion:
52
+ return LegacyVersion(version)
53
+
54
+
55
+ class InvalidVersion(ValueError):
56
+ """
57
+ An invalid version was found, users should refer to PEP 440.
58
+ """
59
+
60
+
61
+ class _BaseVersion:
62
+ _key: Union[CmpKey, LegacyCmpKey]
63
+
64
+ def __hash__(self) -> int:
65
+ return hash(self._key)
66
+
67
+ # Please keep the duplicated `isinstance` check
68
+ # in the six comparisons hereunder
69
+ # unless you find a way to avoid adding overhead function calls.
70
+ def __lt__(self, other: "_BaseVersion") -> bool:
71
+ if not isinstance(other, _BaseVersion):
72
+ return NotImplemented
73
+
74
+ return self._key < other._key
75
+
76
+ def __le__(self, other: "_BaseVersion") -> bool:
77
+ if not isinstance(other, _BaseVersion):
78
+ return NotImplemented
79
+
80
+ return self._key <= other._key
81
+
82
+ def __eq__(self, other: object) -> bool:
83
+ if not isinstance(other, _BaseVersion):
84
+ return NotImplemented
85
+
86
+ return self._key == other._key
87
+
88
+ def __ge__(self, other: "_BaseVersion") -> bool:
89
+ if not isinstance(other, _BaseVersion):
90
+ return NotImplemented
91
+
92
+ return self._key >= other._key
93
+
94
+ def __gt__(self, other: "_BaseVersion") -> bool:
95
+ if not isinstance(other, _BaseVersion):
96
+ return NotImplemented
97
+
98
+ return self._key > other._key
99
+
100
+ def __ne__(self, other: object) -> bool:
101
+ if not isinstance(other, _BaseVersion):
102
+ return NotImplemented
103
+
104
+ return self._key != other._key
105
+
106
+
107
+ class LegacyVersion(_BaseVersion):
108
+ def __init__(self, version: str) -> None:
109
+ self._version = str(version)
110
+ self._key = _legacy_cmpkey(self._version)
111
+
112
+ warnings.warn(
113
+ "Creating a LegacyVersion has been deprecated and will be "
114
+ "removed in the next major release",
115
+ DeprecationWarning,
116
+ )
117
+
118
+ def __str__(self) -> str:
119
+ return self._version
120
+
121
+ def __repr__(self) -> str:
122
+ return f"<LegacyVersion('{self}')>"
123
+
124
+ @property
125
+ def public(self) -> str:
126
+ return self._version
127
+
128
+ @property
129
+ def base_version(self) -> str:
130
+ return self._version
131
+
132
+ @property
133
+ def epoch(self) -> int:
134
+ return -1
135
+
136
+ @property
137
+ def release(self) -> None:
138
+ return None
139
+
140
+ @property
141
+ def pre(self) -> None:
142
+ return None
143
+
144
+ @property
145
+ def post(self) -> None:
146
+ return None
147
+
148
+ @property
149
+ def dev(self) -> None:
150
+ return None
151
+
152
+ @property
153
+ def local(self) -> None:
154
+ return None
155
+
156
+ @property
157
+ def is_prerelease(self) -> bool:
158
+ return False
159
+
160
+ @property
161
+ def is_postrelease(self) -> bool:
162
+ return False
163
+
164
+ @property
165
+ def is_devrelease(self) -> bool:
166
+ return False
167
+
168
+
169
+ _legacy_version_component_re = re.compile(r"(\d+ | [a-z]+ | \.| -)", re.VERBOSE)
170
+
171
+ _legacy_version_replacement_map = {
172
+ "pre": "c",
173
+ "preview": "c",
174
+ "-": "final-",
175
+ "rc": "c",
176
+ "dev": "@",
177
+ }
178
+
179
+
180
+ def _parse_version_parts(s: str) -> Iterator[str]:
181
+ for part in _legacy_version_component_re.split(s):
182
+ part = _legacy_version_replacement_map.get(part, part)
183
+
184
+ if not part or part == ".":
185
+ continue
186
+
187
+ if part[:1] in "0123456789":
188
+ # pad for numeric comparison
189
+ yield part.zfill(8)
190
+ else:
191
+ yield "*" + part
192
+
193
+ # ensure that alpha/beta/candidate are before final
194
+ yield "*final"
195
+
196
+
197
+ def _legacy_cmpkey(version: str) -> LegacyCmpKey:
198
+
199
+ # We hardcode an epoch of -1 here. A PEP 440 version can only have a epoch
200
+ # greater than or equal to 0. This will effectively put the LegacyVersion,
201
+ # which uses the defacto standard originally implemented by setuptools,
202
+ # as before all PEP 440 versions.
203
+ epoch = -1
204
+
205
+ # This scheme is taken from pkg_resources.parse_version setuptools prior to
206
+ # its adoption of the packaging library.
207
+ parts: List[str] = []
208
+ for part in _parse_version_parts(version.lower()):
209
+ if part.startswith("*"):
210
+ # remove "-" before a prerelease tag
211
+ if part < "*final":
212
+ while parts and parts[-1] == "*final-":
213
+ parts.pop()
214
+
215
+ # remove trailing zeros from each series of numeric parts
216
+ while parts and parts[-1] == "00000000":
217
+ parts.pop()
218
+
219
+ parts.append(part)
220
+
221
+ return epoch, tuple(parts)
222
+
223
+
224
+ # Deliberately not anchored to the start and end of the string, to make it
225
+ # easier for 3rd party code to reuse
226
+ VERSION_PATTERN = r"""
227
+ v?
228
+ (?:
229
+ (?:(?P<epoch>[0-9]+)!)? # epoch
230
+ (?P<release>[0-9]+(?:\.[0-9]+)*) # release segment
231
+ (?P<pre> # pre-release
232
+ [-_\.]?
233
+ (?P<pre_l>(a|b|c|rc|alpha|beta|pre|preview))
234
+ [-_\.]?
235
+ (?P<pre_n>[0-9]+)?
236
+ )?
237
+ (?P<post> # post release
238
+ (?:-(?P<post_n1>[0-9]+))
239
+ |
240
+ (?:
241
+ [-_\.]?
242
+ (?P<post_l>post|rev|r)
243
+ [-_\.]?
244
+ (?P<post_n2>[0-9]+)?
245
+ )
246
+ )?
247
+ (?P<dev> # dev release
248
+ [-_\.]?
249
+ (?P<dev_l>dev)
250
+ [-_\.]?
251
+ (?P<dev_n>[0-9]+)?
252
+ )?
253
+ )
254
+ (?:\+(?P<local>[a-z0-9]+(?:[-_\.][a-z0-9]+)*))? # local version
255
+ """
256
+
257
+
258
+ class Version(_BaseVersion):
259
+
260
+ _regex = re.compile(r"^\s*" + VERSION_PATTERN + r"\s*$", re.VERBOSE | re.IGNORECASE)
261
+
262
+ def __init__(self, version: str) -> None:
263
+
264
+ # Validate the version and parse it into pieces
265
+ match = self._regex.search(version)
266
+ if not match:
267
+ raise InvalidVersion(f"Invalid version: '{version}'")
268
+
269
+ # Store the parsed out pieces of the version
270
+ self._version = _Version(
271
+ epoch=int(match.group("epoch")) if match.group("epoch") else 0,
272
+ release=tuple(int(i) for i in match.group("release").split(".")),
273
+ pre=_parse_letter_version(match.group("pre_l"), match.group("pre_n")),
274
+ post=_parse_letter_version(
275
+ match.group("post_l"), match.group("post_n1") or match.group("post_n2")
276
+ ),
277
+ dev=_parse_letter_version(match.group("dev_l"), match.group("dev_n")),
278
+ local=_parse_local_version(match.group("local")),
279
+ )
280
+
281
+ # Generate a key which will be used for sorting
282
+ self._key = _cmpkey(
283
+ self._version.epoch,
284
+ self._version.release,
285
+ self._version.pre,
286
+ self._version.post,
287
+ self._version.dev,
288
+ self._version.local,
289
+ )
290
+
291
+ def __repr__(self) -> str:
292
+ return f"<Version('{self}')>"
293
+
294
+ def __str__(self) -> str:
295
+ parts = []
296
+
297
+ # Epoch
298
+ if self.epoch != 0:
299
+ parts.append(f"{self.epoch}!")
300
+
301
+ # Release segment
302
+ parts.append(".".join(str(x) for x in self.release))
303
+
304
+ # Pre-release
305
+ if self.pre is not None:
306
+ parts.append("".join(str(x) for x in self.pre))
307
+
308
+ # Post-release
309
+ if self.post is not None:
310
+ parts.append(f".post{self.post}")
311
+
312
+ # Development release
313
+ if self.dev is not None:
314
+ parts.append(f".dev{self.dev}")
315
+
316
+ # Local version segment
317
+ if self.local is not None:
318
+ parts.append(f"+{self.local}")
319
+
320
+ return "".join(parts)
321
+
322
+ @property
323
+ def epoch(self) -> int:
324
+ _epoch: int = self._version.epoch
325
+ return _epoch
326
+
327
+ @property
328
+ def release(self) -> Tuple[int, ...]:
329
+ _release: Tuple[int, ...] = self._version.release
330
+ return _release
331
+
332
+ @property
333
+ def pre(self) -> Optional[Tuple[str, int]]:
334
+ _pre: Optional[Tuple[str, int]] = self._version.pre
335
+ return _pre
336
+
337
+ @property
338
+ def post(self) -> Optional[int]:
339
+ return self._version.post[1] if self._version.post else None
340
+
341
+ @property
342
+ def dev(self) -> Optional[int]:
343
+ return self._version.dev[1] if self._version.dev else None
344
+
345
+ @property
346
+ def local(self) -> Optional[str]:
347
+ if self._version.local:
348
+ return ".".join(str(x) for x in self._version.local)
349
+ else:
350
+ return None
351
+
352
+ @property
353
+ def public(self) -> str:
354
+ return str(self).split("+", 1)[0]
355
+
356
+ @property
357
+ def base_version(self) -> str:
358
+ parts = []
359
+
360
+ # Epoch
361
+ if self.epoch != 0:
362
+ parts.append(f"{self.epoch}!")
363
+
364
+ # Release segment
365
+ parts.append(".".join(str(x) for x in self.release))
366
+
367
+ return "".join(parts)
368
+
369
+ @property
370
+ def is_prerelease(self) -> bool:
371
+ return self.dev is not None or self.pre is not None
372
+
373
+ @property
374
+ def is_postrelease(self) -> bool:
375
+ return self.post is not None
376
+
377
+ @property
378
+ def is_devrelease(self) -> bool:
379
+ return self.dev is not None
380
+
381
+ @property
382
+ def major(self) -> int:
383
+ return self.release[0] if len(self.release) >= 1 else 0
384
+
385
+ @property
386
+ def minor(self) -> int:
387
+ return self.release[1] if len(self.release) >= 2 else 0
388
+
389
+ @property
390
+ def micro(self) -> int:
391
+ return self.release[2] if len(self.release) >= 3 else 0
392
+
393
+
394
+ def _parse_letter_version(
395
+ letter: str, number: Union[str, bytes, SupportsInt]
396
+ ) -> Optional[Tuple[str, int]]:
397
+
398
+ if letter:
399
+ # We consider there to be an implicit 0 in a pre-release if there is
400
+ # not a numeral associated with it.
401
+ if number is None:
402
+ number = 0
403
+
404
+ # We normalize any letters to their lower case form
405
+ letter = letter.lower()
406
+
407
+ # We consider some words to be alternate spellings of other words and
408
+ # in those cases we want to normalize the spellings to our preferred
409
+ # spelling.
410
+ if letter == "alpha":
411
+ letter = "a"
412
+ elif letter == "beta":
413
+ letter = "b"
414
+ elif letter in ["c", "pre", "preview"]:
415
+ letter = "rc"
416
+ elif letter in ["rev", "r"]:
417
+ letter = "post"
418
+
419
+ return letter, int(number)
420
+ if not letter and number:
421
+ # We assume if we are given a number, but we are not given a letter
422
+ # then this is using the implicit post release syntax (e.g. 1.0-1)
423
+ letter = "post"
424
+
425
+ return letter, int(number)
426
+
427
+ return None
428
+
429
+
430
+ _local_version_separators = re.compile(r"[\._-]")
431
+
432
+
433
+ def _parse_local_version(local: str) -> Optional[LocalType]:
434
+ """
435
+ Takes a string like abc.1.twelve and turns it into ("abc", 1, "twelve").
436
+ """
437
+ if local is not None:
438
+ return tuple(
439
+ part.lower() if not part.isdigit() else int(part)
440
+ for part in _local_version_separators.split(local)
441
+ )
442
+ return None
443
+
444
+
445
+ def _cmpkey(
446
+ epoch: int,
447
+ release: Tuple[int, ...],
448
+ pre: Optional[Tuple[str, int]],
449
+ post: Optional[Tuple[str, int]],
450
+ dev: Optional[Tuple[str, int]],
451
+ local: Optional[Tuple[SubLocalType]],
452
+ ) -> CmpKey:
453
+
454
+ # When we compare a release version, we want to compare it with all of the
455
+ # trailing zeros removed. So we'll use a reverse the list, drop all the now
456
+ # leading zeros until we come to something non zero, then take the rest
457
+ # re-reverse it back into the correct order and make it a tuple and use
458
+ # that for our sorting key.
459
+ _release = tuple(
460
+ reversed(list(itertools.dropwhile(lambda x: x == 0, reversed(release))))
461
+ )
462
+
463
+ # We need to "trick" the sorting algorithm to put 1.0.dev0 before 1.0a0.
464
+ # We'll do this by abusing the pre segment, but we _only_ want to do this
465
+ # if there is not a pre or a post segment. If we have one of those then
466
+ # the normal sorting rules will handle this case correctly.
467
+ if pre is None and post is None and dev is not None:
468
+ _pre: PrePostDevType = NegativeInfinity
469
+ # Versions without a pre-release (except as noted above) should sort after
470
+ # those with one.
471
+ elif pre is None:
472
+ _pre = Infinity
473
+ else:
474
+ _pre = pre
475
+
476
+ # Versions without a post segment should sort before those with one.
477
+ if post is None:
478
+ _post: PrePostDevType = NegativeInfinity
479
+
480
+ else:
481
+ _post = post
482
+
483
+ # Versions without a development segment should sort after those with one.
484
+ if dev is None:
485
+ _dev: PrePostDevType = Infinity
486
+
487
+ else:
488
+ _dev = dev
489
+
490
+ if local is None:
491
+ # Versions without a local segment should sort before those with one.
492
+ _local: LocalType = NegativeInfinity
493
+ else:
494
+ # Versions with a local segment need that segment parsed to implement
495
+ # the sorting rules in PEP440.
496
+ # - Alpha numeric segments sort before numeric segments
497
+ # - Alpha numeric segments sort lexicographically
498
+ # - Numeric segments sort numerically
499
+ # - Shorter versions sort before longer versions when the prefixes
500
+ # match exactly
501
+ _local = tuple(
502
+ (i, "") if isinstance(i, int) else (NegativeInfinity, i) for i in local
503
+ )
504
+
505
+ return epoch, _release, _pre, _post, _dev, _local
@@ -0,0 +1,28 @@
1
+ Copyright (C) 2011, the scikit-image team
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are
6
+ met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+ 2. Redistributions in binary form must reproduce the above copyright
11
+ notice, this list of conditions and the following disclaimer in
12
+ the documentation and/or other materials provided with the
13
+ distribution.
14
+ 3. Neither the name of skimage nor the names of its contributors may be
15
+ used to endorse or promote products derived from this software without
16
+ specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19
+ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
22
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
27
+ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ from . import _shared # noqa: F401
2
+ from . import measure # noqa: F401