Two DataArrays are broadcast equal if they are equal after broadcasting them against each other such that they have the same dimensions. Parameters ---------- other : DataArray DataArray to compare to. Returns ------- equa
(self, other: Self)
| 4705 | ) |
| 4706 | |
| 4707 | def broadcast_equals(self, other: Self) -> bool: |
| 4708 | """Two DataArrays are broadcast equal if they are equal after |
| 4709 | broadcasting them against each other such that they have the same |
| 4710 | dimensions. |
| 4711 | |
| 4712 | Parameters |
| 4713 | ---------- |
| 4714 | other : DataArray |
| 4715 | DataArray to compare to. |
| 4716 | |
| 4717 | Returns |
| 4718 | ------- |
| 4719 | equal : bool |
| 4720 | True if the two DataArrays are broadcast equal. |
| 4721 | |
| 4722 | See Also |
| 4723 | -------- |
| 4724 | DataArray.equals |
| 4725 | DataArray.identical |
| 4726 | |
| 4727 | Examples |
| 4728 | -------- |
| 4729 | >>> a = xr.DataArray([1, 2], dims="X") |
| 4730 | >>> b = xr.DataArray([[1, 1], [2, 2]], dims=["X", "Y"]) |
| 4731 | >>> a |
| 4732 | <xarray.DataArray (X: 2)> Size: 16B |
| 4733 | array([1, 2]) |
| 4734 | Dimensions without coordinates: X |
| 4735 | >>> b |
| 4736 | <xarray.DataArray (X: 2, Y: 2)> Size: 32B |
| 4737 | array([[1, 1], |
| 4738 | [2, 2]]) |
| 4739 | Dimensions without coordinates: X, Y |
| 4740 | |
| 4741 | .equals returns True if two DataArrays have the same values, dimensions, and coordinates. .broadcast_equals returns True if the results of broadcasting two DataArrays against each other have the same values, dimensions, and coordinates. |
| 4742 | |
| 4743 | >>> a.equals(b) |
| 4744 | False |
| 4745 | >>> a2, b2 = xr.broadcast(a, b) |
| 4746 | >>> a2.equals(b2) |
| 4747 | True |
| 4748 | >>> a.broadcast_equals(b) |
| 4749 | True |
| 4750 | """ |
| 4751 | try: |
| 4752 | return self._all_compat(other, "broadcast_equals") |
| 4753 | except (TypeError, AttributeError): |
| 4754 | return False |
| 4755 | |
| 4756 | def equals(self, other: Self) -> bool: |
| 4757 | """True if two DataArrays have the same dimensions, coordinates and |