Skip to content

Commit

Permalink
DAS-2067 - Add overload for xarray.testing.assert_equal and xarray.te…
Browse files Browse the repository at this point in the history
…sting.assert_identical.
  • Loading branch information
owenlittlejohns committed Apr 24, 2024
1 parent 63e2836 commit 970b10d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion xarray/testing/assertions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import functools
import warnings
from collections.abc import Hashable
from typing import Union
from typing import Union, overload

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -95,6 +95,14 @@ def assert_isomorphic(a: DataTree, b: DataTree, from_root: bool = False):
raise TypeError(f"{type(a)} not of type DataTree")


@overload
def assert_equal(a, b): ...


@overload
def assert_equal(a: DataTree, b: DataTree, from_root: bool = True): ...


@ensure_warnings
def assert_equal(a, b, from_root=True):
"""Like :py:func:`numpy.testing.assert_array_equal`, but for xarray
Expand Down Expand Up @@ -145,6 +153,14 @@ def assert_equal(a, b, from_root=True):
raise TypeError(f"{type(a)} not supported by assertion comparison")


@overload
def assert_identical(a, b): ...


@overload
def assert_identical(a: DataTree, b: DataTree, from_root: bool = True): ...


@ensure_warnings
def assert_identical(a, b, from_root=True):
"""Like :py:func:`xarray.testing.assert_equal`, but also matches the
Expand Down

0 comments on commit 970b10d

Please sign in to comment.