Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
_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 <spencerkclark@gmail.com> * 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 <spencerkclark@gmail.com> Co-authored-by: Illviljan <14371165+Illviljan@users.noreply.github.com> Co-authored-by: Spencer Clark <spencerkclark@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information