Skip to content

Commit

Permalink
Rename bbox -> bounds (#2199)
Browse files Browse the repository at this point in the history
* Rename bbox -> geo_bbox

* Rename to bounds

* Undo rename in data.py
  • Loading branch information
ashnair1 authored Aug 6, 2024
1 parent 3b2dc68 commit ddd16cb
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/datamodules/test_geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(

def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
image = torch.arange(3 * 2 * 2).view(3, 2, 2)
return {'image': image, 'crs': CRS.from_epsg(4326), 'bbox': query}
return {'image': image, 'crs': CRS.from_epsg(4326), 'bounds': query}

def plot(self, *args: Any, **kwargs: Any) -> Figure:
return plt.figure()
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datamodules/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def transfer_batch_to_device(
"""
# Non-Tensor values cannot be moved to a device
del batch['crs']
del batch['bbox']
del batch['bounds']

batch = super().transfer_batch_to_device(batch, device, dataloader_idx)
return batch
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/agrifieldnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:

sample = {
'crs': self.crs,
'bbox': query,
'bounds': query,
'image': image.float(),
'mask': mask.long(),
}
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/chesapeake.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
hits = self.index.intersection(tuple(query), objects=True)
filepaths = cast(list[dict[str, str]], [hit.object for hit in hits])

sample = {'image': [], 'mask': [], 'crs': self.crs, 'bbox': query}
sample = {'image': [], 'mask': [], 'crs': self.crs, 'bounds': query}

if len(filepaths) == 0:
raise IndexError(
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/eddmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
f'query: {query} not found in index with bounds: {self.bounds}'
)

sample = {'crs': self.crs, 'bbox': bboxes}
sample = {'crs': self.crs, 'bounds': bboxes}

return sample
2 changes: 1 addition & 1 deletion torchgeo/datasets/enviroatlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
hits = self.index.intersection(tuple(query), objects=True)
filepaths = cast(list[dict[str, str]], [hit.object for hit in hits])

sample = {'image': [], 'mask': [], 'crs': self.crs, 'bbox': query}
sample = {'image': [], 'mask': [], 'crs': self.crs, 'bounds': query}

if len(filepaths) == 0:
raise IndexError(
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/gbif.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
f'query: {query} not found in index with bounds: {self.bounds}'
)

sample = {'crs': self.crs, 'bbox': bboxes}
sample = {'crs': self.crs, 'bounds': bboxes}

return sample
4 changes: 2 additions & 2 deletions torchgeo/datasets/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
else:
data = self._merge_files(filepaths, query, self.band_indexes)

sample = {'crs': self.crs, 'bbox': query}
sample = {'crs': self.crs, 'bounds': query}

data = data.to(self.dtype)
if self.is_image:
Expand Down Expand Up @@ -776,7 +776,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
masks = array_to_tensor(masks)

masks = masks.to(self.dtype)
sample = {'mask': masks, 'crs': self.crs, 'bbox': query}
sample = {'mask': masks, 'crs': self.crs, 'bounds': query}

if self.transforms is not None:
sample = self.transforms(sample)
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/globbiomass.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:

mask = torch.cat((mask, std_err_mask), dim=0)

sample = {'mask': mask, 'crs': self.crs, 'bbox': query}
sample = {'mask': mask, 'crs': self.crs, 'bounds': query}

if self.transforms is not None:
sample = self.transforms(sample)
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/inaturalist.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
f'query: {query} not found in index with bounds: {self.bounds}'
)

sample = {'crs': self.crs, 'bbox': bboxes}
sample = {'crs': self.crs, 'bounds': bboxes}

return sample
2 changes: 1 addition & 1 deletion torchgeo/datasets/landcoverai.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
mask = self._merge_files(mask_filepaths, query, self.band_indexes)
sample = {
'crs': self.crs,
'bbox': query,
'bounds': query,
'image': img.float(),
'mask': mask.long(),
}
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/openbuildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:
else:
masks = torch.zeros(size=(1, round(height), round(width)))

sample = {'mask': masks, 'crs': self.crs, 'bbox': query}
sample = {'mask': masks, 'crs': self.crs, 'bounds': query}

if self.transforms is not None:
sample = self.transforms(sample)
Expand Down
2 changes: 1 addition & 1 deletion torchgeo/datasets/south_africa_crop_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def __getitem__(self, query: BoundingBox) -> dict[str, Any]:

sample = {
'crs': self.crs,
'bbox': query,
'bounds': query,
'image': image.float(),
'mask': mask.long(),
}
Expand Down

0 comments on commit ddd16cb

Please sign in to comment.