Commit aeb00f9
_season_from_months can now handle np.nan (#5876)
* _season_from_months can now handle np.nan
_season_from_months can now handle np.nan and values outside of [1,12]
I passed these tests:
def test_season():
months = np.array([ 1, 2, 3, 4, 5, np.nan])
assert ( _season_from_months(months) == np.array(['DJF', 'DJF', 'MAM', 'MAM', 'MAM', 'na']) ).all()
months = np.array([ 1, 100, 3, 13, 0, -5])
assert ( _season_from_months(months) == np.array(['DJF', 'na', 'MAM', 'na', 'na', 'na']) ).all()
months = np.array(range(1, 13))
assert ( _season_from_months(months) == np.array(['DJF', 'DJF', 'MAM', 'MAM', 'MAM', 'JJA', 'JJA', 'JJA', 'SON', 'SON', 'SON', 'DJF']) ).all()
test_season()
* Run black
* Remove duplicated import
* returns np.nan and removed the useless attribution
returns np.nan and removed the useless attribution when month is not in [1,12]
* added test
* applied black recommendations
* Apply suggestions from code review
finally, NaT is output as a "nan" string
Co-authored-by: Spencer Clark <[email protected]>
* update whatsnew
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Correction on the credits
Co-authored-by: Spencer Clark <[email protected]>
Co-authored-by: Illviljan <[email protected]>
Co-authored-by: Spencer Clark <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>1 parent 5c08ab2 commit aeb00f9
File tree
3 files changed
+19
-2
lines changed- doc
- xarray
- core
- tests
3 files changed
+19
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
56 | 60 | | |
57 | 61 | | |
58 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
22 | 33 | | |
23 | 34 | | |
24 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
| |||
237 | 238 | | |
238 | 239 | | |
239 | 240 | | |
| 241 | + | |
240 | 242 | | |
241 | 243 | | |
242 | 244 | | |
| |||
0 commit comments