-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test for regression task and commit within factor metric
- Loading branch information
Showing
2 changed files
with
95 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
import torch | ||
|
||
from rslearn.const import WGS84_PROJECTION | ||
from rslearn.train.tasks.regression import RegressionTask | ||
from rslearn.utils.feature import Feature | ||
|
||
|
||
def test_process_output() -> None: | ||
"""Ensure that RegressionTask.process_output produces correct Feature.""" | ||
property_name = "property_name" | ||
scale_factor = 0.01 | ||
task = RegressionTask( | ||
property_name=property_name, | ||
scale_factor=scale_factor, | ||
) | ||
expected_value = 5 | ||
raw_output = torch.tensor(expected_value * scale_factor) | ||
metadata = dict( | ||
projection=WGS84_PROJECTION, | ||
bounds=[0, 0, 1, 1], | ||
) | ||
features = task.process_output(raw_output, metadata) | ||
assert len(features) == 1 | ||
feature = features[0] | ||
assert isinstance(feature, Feature) | ||
assert feature.properties[property_name] == pytest.approx(expected_value) |