-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/wri/cities-cif into feature…
…/era5
- Loading branch information
Showing
4 changed files
with
135 additions
and
102 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
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,58 @@ | ||
import numpy as np | ||
|
||
from .conftest import ( | ||
LARGE_ZONES, | ||
ZONES, | ||
MockGroupByLayer, | ||
MockLargeGroupByLayer, | ||
MockLargeLayer, | ||
MockLayer, | ||
MockMaskLayer, | ||
) | ||
from .fixtures.bbox_constants import * | ||
|
||
|
||
def test_count(): | ||
counts = MockLayer().groupby(ZONES).count() | ||
assert counts.size == 100 | ||
assert all([count == 100 for count in counts]) | ||
|
||
|
||
def test_mean(): | ||
means = MockLayer().groupby(ZONES).mean() | ||
assert means.size == 100 | ||
assert all([mean == i for i, mean in enumerate(means)]) | ||
|
||
|
||
def test_fishnetted_count(): | ||
counts = MockLargeLayer().groupby(LARGE_ZONES).count() | ||
assert counts.size == 100 | ||
assert all([count == 100 for count in counts]) | ||
|
||
|
||
def test_fishnetted_mean(): | ||
means = MockLargeLayer().groupby(LARGE_ZONES).mean() | ||
assert means.size == 100 | ||
assert all([mean == i for i, mean in enumerate(means)]) | ||
|
||
|
||
def test_masks(): | ||
counts = MockLayer().mask(MockMaskLayer()).groupby(ZONES).count() | ||
assert counts.size == 100 | ||
for i, count in enumerate(counts): | ||
if i % 2 == 0: | ||
assert np.isnan(count) | ||
else: | ||
assert count == 100 | ||
|
||
|
||
def test_group_by_layer(): | ||
counts = MockLayer().groupby(ZONES, layer=MockGroupByLayer()).count() | ||
assert all([count == {1: 50.0, 2: 50.0} for count in counts]) | ||
|
||
|
||
def test_group_by_large_layer(): | ||
counts = ( | ||
MockLargeLayer().groupby(LARGE_ZONES, layer=MockLargeGroupByLayer()).count() | ||
) | ||
assert all([count == {1: 50.0, 2: 50.0} for count in counts]) |