|
17 | 17 | Iterable,
|
18 | 18 | Mapping,
|
19 | 19 | Sequence,
|
| 20 | + overload, |
20 | 21 | )
|
21 | 22 |
|
22 | 23 | import numpy as np
|
@@ -1845,26 +1846,31 @@ def where(cond, x, y, keep_attrs=None):
|
1845 | 1846 | )
|
1846 | 1847 |
|
1847 | 1848 |
|
1848 |
| -# These overloads seem not to work — mypy says it can't find a matching overload for |
1849 |
| -# `DataArray` & `DataArray`, despite that being in the first overload. Would be nice to |
1850 |
| -# have overloaded functions rather than just `T_Xarray` for everything. |
| 1849 | +@overload |
| 1850 | +def polyval(coord: DataArray, coeffs: DataArray, degree_dim: Hashable) -> DataArray: |
| 1851 | + ... |
1851 | 1852 |
|
1852 |
| -# @overload |
1853 |
| -# def polyval(coord: DataArray, coeffs: DataArray, degree_dim: Hashable) -> DataArray: |
1854 |
| -# ... |
1855 | 1853 |
|
| 1854 | +@overload |
| 1855 | +def polyval(coord: DataArray, coeffs: Dataset, degree_dim: Hashable) -> Dataset: |
| 1856 | + ... |
1856 | 1857 |
|
1857 |
| -# @overload |
1858 |
| -# def polyval(coord: T_Xarray, coeffs: Dataset, degree_dim: Hashable) -> Dataset: |
1859 |
| -# ... |
1860 | 1858 |
|
| 1859 | +@overload |
| 1860 | +def polyval(coord: Dataset, coeffs: DataArray, degree_dim: Hashable) -> Dataset: |
| 1861 | + ... |
1861 | 1862 |
|
1862 |
| -# @overload |
1863 |
| -# def polyval(coord: Dataset, coeffs: T_Xarray, degree_dim: Hashable) -> Dataset: |
1864 |
| -# ... |
| 1863 | + |
| 1864 | +@overload |
| 1865 | +def polyval(coord: Dataset, coeffs: Dataset, degree_dim: Hashable) -> Dataset: |
| 1866 | + ... |
1865 | 1867 |
|
1866 | 1868 |
|
1867 |
| -def polyval(coord: T_Xarray, coeffs: T_Xarray, degree_dim="degree") -> T_Xarray: |
| 1869 | +def polyval( |
| 1870 | + coord: Dataset | DataArray, |
| 1871 | + coeffs: Dataset | DataArray, |
| 1872 | + degree_dim: Hashable = "degree", |
| 1873 | +) -> Dataset | DataArray: |
1868 | 1874 | """Evaluate a polynomial at specific values
|
1869 | 1875 |
|
1870 | 1876 | Parameters
|
@@ -1899,7 +1905,7 @@ def polyval(coord: T_Xarray, coeffs: T_Xarray, degree_dim="degree") -> T_Xarray:
|
1899 | 1905 | coeffs = coeffs.reindex(
|
1900 | 1906 | {degree_dim: np.arange(max_deg + 1)}, fill_value=0, copy=False
|
1901 | 1907 | )
|
1902 |
| - coord = _ensure_numeric(coord) |
| 1908 | + coord = _ensure_numeric(coord) # type: ignore # https://github.com/python/mypy/issues/1533 ? |
1903 | 1909 |
|
1904 | 1910 | # using Horner's method
|
1905 | 1911 | # https://en.wikipedia.org/wiki/Horner%27s_method
|
|
0 commit comments