Skip to content

Commit

Permalink
tensor to andy and add cmap for geo.py test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nilsleh committed Feb 27, 2022
1 parent 8156005 commit aa4a42b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 14 additions & 0 deletions tests/datasets/test_cdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ def dataset(
monkeypatch.setattr( # type: ignore[attr-defined]
torchgeo.datasets.cdl, "download_url", download_url
)

cmap = {
0: (0, 0, 0, 0),
1: (255, 211, 0, 255),
2: (255, 38, 38, 255),
3: (0, 168, 228, 255),
4: (255, 158, 11, 255),
5: (38, 112, 0, 255),
6: (255, 255, 0, 255),
7: (0, 0, 0, 255),
8: (0, 0, 0, 255),
}
monkeypatch.setattr(CDL, "cmap", cmap) # type: ignore[attr-defined]

md5s = [
(2021, "0693f0bb10deb79c69bcafe4aa1635b7"),
(2020, "7695292902a8672d16ac034d4d560d84"),
Expand Down
3 changes: 1 addition & 2 deletions torchgeo/datasets/cdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import matplotlib.pyplot as plt
import numpy as np
from rasterio.crs import CRS
from torch import Tensor

from .geo import RasterDataset
from .utils import download_url, extract_archive
Expand Down Expand Up @@ -401,7 +400,7 @@ def _extract(self) -> None:

def plot( # type: ignore[override]
self,
sample: Dict[str, Tensor],
sample: Dict[str, Any],
show_titles: bool = True,
suptitle: Optional[str] = None,
) -> plt.Figure:
Expand Down

0 comments on commit aa4a42b

Please sign in to comment.