napari-point-proofread 0.4.0__py3-none-any.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.
@@ -0,0 +1,7 @@
1
+ try:
2
+ from ._version import version as __version__
3
+ except ImportError:
4
+ __version__ = 'unknown'
5
+
6
+
7
+ from ._widget import MainWidget, PredictionWidget, threshold_prob
@@ -0,0 +1,65 @@
1
+ """I/O helpers for napari-point-proofread."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from pathlib import Path
6
+ from typing import Any
7
+
8
+ import numpy as np
9
+ from napari_builtins.io import write_csv
10
+
11
+
12
+ def _has_real_extension(path_obj: Path) -> bool:
13
+ """Return True when the filename appears to include a real extension.
14
+
15
+ Pathlib treats any trailing ``.<text>`` as a suffix, even when users type
16
+ dataset names such as ``P2.4_sample`` that are not file extensions.
17
+ """
18
+ suffix = path_obj.suffix
19
+ if suffix == '':
20
+ return False
21
+
22
+ ext = suffix[1:]
23
+ return 1 <= len(ext) <= 6 and ext.isalnum()
24
+
25
+
26
+ def write_points_csv_preserve_types(
27
+ path: str, data: Any, meta: dict
28
+ ) -> list[str]:
29
+ """Write points CSV while preserving integer-like property columns.
30
+
31
+ Napari's built-in points writer concatenates coordinates and properties into
32
+ one NumPy table, which upcasts integer properties to float. This writer
33
+ writes each column separately and preserves integer-like values.
34
+ """
35
+ path_obj = Path(path)
36
+
37
+ if path_obj.suffix.lower() == '.csv':
38
+ pass
39
+ elif not _has_real_extension(path_obj):
40
+ path_obj = Path(f'{path_obj}.csv')
41
+ else:
42
+ return [] # Return empty list if it fails
43
+
44
+ properties = meta.get('properties', {})
45
+
46
+ # Construct columns without merging their dtypes
47
+ column_names = ['index']
48
+ columns = [np.arange(data.shape[0], dtype=int)]
49
+
50
+ # Coordinate columns
51
+ for n in range(data.shape[1]):
52
+ column_names.append(f'axis-{n!s}')
53
+ columns.append(data[:, n])
54
+
55
+ # Feature columns
56
+ for name, values in properties.items():
57
+ column_names.append(name)
58
+ columns.append(values)
59
+
60
+ # Build rows while preserving individual column values
61
+ table = zip(*columns)
62
+
63
+ write_csv(path_obj, table, column_names)
64
+
65
+ return [str(path_obj)]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.4.0'
22
+ __version_tuple__ = version_tuple = (0, 4, 0)
23
+
24
+ __commit_id__ = commit_id = None