Commit a8dc1243 authored by Cresson Remi's avatar Cresson Remi
Browse files

ADD: docstring with variable typing hints

1 merge request!38ADD: docstring in core
Pipeline #36141 passed with stages
in 5 minutes and 25 seconds
Showing with 12 additions and 5 deletions
+12 -5
......@@ -30,6 +30,7 @@ The `get_timestamp` method converts a `datetime.datetime` instance into a number
ts = get_timestamp(dt) # 1606780800.0
```
"""
from __future__ import annotations
import datetime
......
......@@ -20,6 +20,7 @@ sr = scenes.deepnets.sr4rs(s2_image) # pyotb.core.otbObject
sr.write("sr.tif")
```
"""
from __future__ import annotations
import os
import zipfile
import pyotb
......
......@@ -61,6 +61,7 @@ theia.download_in_range(bbox, trange, "/tmp/download/", "LEVEL2A")
```
"""
from __future__ import annotations
import datetime
import hashlib
import io
......
......@@ -43,14 +43,16 @@ scenes_results = index.find(vec, "01/01/2020" "01/01/2022")
```
"""
from __future__ import annotations
import datetime
import rtree
from scenes.core import Scene
from scenes.dates import get_timestamp, any2datetime, MINDATE, MAXDATE
from scenes.vector import reproject_ogr_layer, get_bbox_wgs84, ogr_open
from scenes.spatial import poly_overlap
from scenes.spatial import poly_overlap, BoundingBox
def _bbox(bbox_wgs84, date_min, date_max):
def _bbox(bbox_wgs84: BoundingBox, date_min: datetime.datetime | str, date_max: datetime.datetime | str) -> tuple:
"""
Return a bounding box in the domain (lat, lon, time)
......@@ -71,7 +73,7 @@ class Index:
"""
Stores an indexation structure for a list of Scenes
"""
def __init__(self, scenes_list):
def __init__(self, scenes_list: list[Scene]):
"""
Args:
scenes_list: list of scenes
......@@ -90,7 +92,8 @@ class Index:
new_bbox = _bbox(bbox_wgs84=scene.bbox_wgs84, date_min=dt_min, date_max=dt_max)
self.index.insert(scene_idx, new_bbox)
def find_indices(self, vector_or_bbox, date_min=None, date_max=None):
def find_indices(self, vector_or_bbox: str | BoundingBox, date_min: datetime.datetime | str = None,
date_max: datetime.datetime | str = None) -> list[int]:
"""
Search the intersecting scenes, and return their indices
......@@ -133,7 +136,8 @@ class Index:
return filtered_indices
return results_indices
def find(self, vector_or_bbox, date_min=None, date_max=None):
def find(self, vector_or_bbox: str | BoundingBox, date_min: datetime.datetime | str = None,
date_max: datetime.datetime | str = None) -> list[Scene]:
"""
Search the intersecting scenes, and return them
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment