Skip to content

Commit

Permalink
Mark features added in microsoft#144 as new (microsoft#328)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjstewart authored Dec 24, 2021
1 parent 2ce90ee commit 29f6fd1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ def __and__(self, other: "GeoDataset") -> "IntersectionDataset":
Raises:
ValueError: if other is not a :class:`GeoDataset`
.. versionadded: 0.2
"""
return IntersectionDataset(self, other)

Expand All @@ -148,6 +150,8 @@ def __or__(self, other: "GeoDataset") -> "UnionDataset":
Raises:
ValueError: if other is not a :class:`GeoDataset`
.. versionadded: 0.2
"""
return UnionDataset(self, other)

Expand Down Expand Up @@ -222,6 +226,8 @@ def crs(self) -> CRS:
Returns:
the :term:`coordinate reference system (CRS)`
.. versionadded: 0.2
"""
return self._crs

Expand All @@ -233,6 +239,8 @@ def crs(self, new_crs: CRS) -> None:
Args:
new_crs: new :term:`coordinate reference system (CRS)`
.. versionadded: 0.2
"""
if new_crs == self._crs:
return
Expand Down Expand Up @@ -810,6 +818,8 @@ class IntersectionDataset(GeoDataset):
.. code-block:: python
dataset = landsat & cdl
.. versionadded: 0.2
"""

def __init__(
Expand Down Expand Up @@ -920,6 +930,8 @@ class UnionDataset(GeoDataset):
.. code-block:: python
dataset = landsat7 | landsat8
.. versionadded: 0.2
"""

def __init__(
Expand Down
16 changes: 16 additions & 0 deletions torchgeo/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ def __post_init__(self) -> None:
Raises:
ValueError: if bounding box is invalid
(minx > maxx, miny > maxy, or mint > maxt)
.. versionadded: 0.2
"""
if self.minx > self.maxx:
raise ValueError(
Expand Down Expand Up @@ -274,6 +276,8 @@ def __contains__(self, other: "BoundingBox") -> bool:
Returns:
True if other is within this bounding box, else False
.. versionadded: 0.2
"""
return (
(self.minx <= other.minx <= self.maxx)
Expand All @@ -292,6 +296,8 @@ def __or__(self, other: "BoundingBox") -> "BoundingBox":
Returns:
the minimum bounding box that contains both self and other
.. versionadded: 0.2
"""
return BoundingBox(
min(self.minx, other.minx),
Expand All @@ -313,6 +319,8 @@ def __and__(self, other: "BoundingBox") -> "BoundingBox":
Raises:
ValueError: if self and other do not intersect
.. versionadded: 0.2
"""
try:
return BoundingBox(
Expand Down Expand Up @@ -429,6 +437,8 @@ def _list_dict_to_dict_list(samples: Iterable[Dict[Any, Any]]) -> Dict[Any, List
Returns:
a dictionary of lists
.. versionadded: 0.2
"""
collated = collections.defaultdict(list)
for sample in samples:
Expand All @@ -448,6 +458,8 @@ def stack_samples(samples: Iterable[Dict[Any, Any]]) -> Dict[Any, Any]:
Returns:
a single sample
.. versionadded: 0.2
"""
collated: Dict[Any, Any] = _list_dict_to_dict_list(samples)
for key, value in collated.items():
Expand All @@ -466,6 +478,8 @@ def concat_samples(samples: Iterable[Dict[Any, Any]]) -> Dict[Any, Any]:
Returns:
a single sample
.. versionadded: 0.2
"""
collated: Dict[Any, Any] = _list_dict_to_dict_list(samples)
for key, value in collated.items():
Expand All @@ -486,6 +500,8 @@ def merge_samples(samples: Iterable[Dict[Any, Any]]) -> Dict[Any, Any]:
Returns:
a single sample
.. versionadded: 0.2
"""
collated: Dict[Any, Any] = {}
for sample in samples:
Expand Down

0 comments on commit 29f6fd1

Please sign in to comment.