Skip to content

Commit 7935102

Browse files
authored
Merge pull request #195 from siapy/fix
chore: remove unnecessary blank line in pyproject.toml
2 parents eeacab2 + 5677b4f commit 7935102

30 files changed

+1203
-558
lines changed

.github/copilot-instructions.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# SiaPy Style Guide
2+
3+
## Type Hints & Python Version
4+
5+
- Use Python 3.10+ type hints (prefer `x | y` over `Union[x, y]`)
6+
- Include type hints for all functions and class members
7+
8+
## Code Style
9+
10+
- 4-space indentation (PEP 8)
11+
- No docstrings needed
12+
- Define `__all__` directly under imports
13+
14+
## Class Design
15+
16+
- Use dataclasses for data-oriented classes
17+
- Use pydantic for data validation
18+
- Prefer property decorators for read-only access
19+
20+
## Method Naming
21+
22+
- Properties: simple noun (e.g. `name`, `value`)
23+
- Expensive getters: prefix with `get_` (e.g. `get_statistics()`)
24+
- Constructors: prefix with `from_` (e.g. `from_point()`)
25+
- Data converters: prefix with `to_` (e.g. `to_numpy()`)
26+
- File loaders: prefix with `open_` (e.g. `open_shapefile()`)
27+
- File savers: prefix with `save_` (e.g. `save_to_csv()`)
28+
- Actions/operations: use verbs (e.g. `calculate()`, `process()`)
29+
- Batch operations: use plural nouns (e.g. `process_items()`)
30+
- Boolean queries: prefix with `is_`, `has_` or `can_` (e.g. `is_valid()`, `has_data()`)
31+
- Factory methods: prefix with `create_` (e.g. `create_instance()`)
32+
33+
## Class Organization
34+
35+
1. Dunder methods
36+
2. Class methods
37+
3. Properties
38+
4. Instance methods
39+
40+
## Error Handling
41+
42+
- Use custom exceptions from `siapy.core.exceptions`:
43+
- InvalidFilepathError
44+
- InvalidInputError
45+
- InvalidTypeError
46+
- ProcessingError
47+
- ConfigurationError
48+
- MethodNotImplementedError
49+
- DirectInitializationError
50+
51+
## Other
52+
53+
- Use `from siapy.core import logger` for logging
54+
- Use Protocol/ABC for interfaces where appropriate

docs/api/entities/shapefiles.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/api/entities/shapes.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/api/entities/shapes/shape.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
::: siapy.entities.shapes.shape

mkdocs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ nav:
8888
- Rasterio Library: api/entities/images/rasterio_lib.md
8989
- Spectral Library: api/entities/images/spectral_lib.md
9090
- Spectral Images: api/entities/images/spimage.md
91+
- Shape: api/entities/shapes/shape.md
9192
- Image Sets: api/entities/imagesets.md
9293
- Pixels: api/entities/pixels.md
93-
- Shapefiles: api/entities/shapefiles.md
94-
- Shapes: api/entities/shapes.md
9594
- Signatures: api/entities/signatures.md
9695
- Features:
9796
- Features: api/features/features.md

pdm.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ dependencies = [
4444
"rasterio>=1.4.3",
4545
"xarray>=2025.1.2",
4646
"rioxarray>=0.18.2",
47+
"shapely>=2.0.7",
4748
]
4849

4950
[dependency-groups]
@@ -109,7 +110,6 @@ ignore_missing_imports = true
109110
module = "geopandas.*"
110111
ignore_missing_imports = true
111112

112-
113113
[[tool.mypy.overrides]]
114114
module = "rasterio.*"
115115
ignore_missing_imports = true

siapy/core/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
__all__ = [
1313
"SpectralLibType",
14+
"XarrayType",
1415
"ImageType",
1516
"ImageSizeType",
1617
"ImageDataType",

siapy/datasets/tabular.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class MetaDataEntity(BaseModel):
2222
shape_idx: int
2323
shape_type: str
2424
shape_label: str | None
25+
geometry_idx: int
2526

2627

2728
class TabularDataEntity(MetaDataEntity):
@@ -61,17 +62,20 @@ def process_image_data(self):
6162
self.data_entities.clear()
6263
for image_idx, image in enumerate(self.image_set):
6364
for shape_idx, shape in enumerate(image.geometric_shapes.shapes):
64-
signatures = image.to_signatures(shape.convex_hull())
65-
entity = TabularDataEntity(
66-
image_idx=image_idx,
67-
shape_idx=shape_idx,
68-
image_filepath=image.filepath,
69-
camera_id=image.camera_id,
70-
shape_type=shape.shape_type,
71-
shape_label=shape.label,
72-
signatures=signatures,
73-
)
74-
self.data_entities.append(entity)
65+
convex_hulls = shape.get_pixels_within_convex_hull()
66+
for geometry_idx, pixels in enumerate(convex_hulls):
67+
signatures = image.to_signatures(pixels)
68+
entity = TabularDataEntity(
69+
image_idx=image_idx,
70+
shape_idx=shape_idx,
71+
geometry_idx=geometry_idx,
72+
image_filepath=image.filepath,
73+
camera_id=image.camera_id,
74+
shape_type=shape.shape_type,
75+
shape_label=shape.label,
76+
signatures=signatures,
77+
)
78+
self.data_entities.append(entity)
7579

7680
def generate_dataset_data(self, mean_signatures=True) -> TabularDatasetData:
7781
self._check_data_entities()
@@ -92,6 +96,7 @@ def generate_dataset_data(self, mean_signatures=True) -> TabularDatasetData:
9296
"shape_idx": [str(entity.shape_idx)] * signatures_len,
9397
"shape_type": [entity.shape_type] * signatures_len,
9498
"shape_label": [entity.shape_label] * signatures_len,
99+
"geometry_idx": [str(entity.geometry_idx)] * signatures_len,
95100
}
96101
)
97102

siapy/entities/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from .images import SpectralImage
22
from .imagesets import SpectralImageSet
33
from .pixels import Pixels
4-
from .shapes import Shapefile
4+
from .shapes import Shape
55
from .signatures import Signatures
66

77
__all__ = [
88
"SpectralImage",
99
"SpectralImageSet",
1010
"Pixels",
1111
"Signatures",
12-
"Shapefile",
12+
"Shape",
1313
]

0 commit comments

Comments
 (0)