MCPcopy Index your code
hub / github.com/pydata/xarray / test_merge_dataarray

Function test_merge_dataarray

xarray/tests/test_units.py:1068–1147  ·  view source on GitHub ↗
(variant, unit, error, dtype)

Source from the content-addressed store, hash-verified

1066 ),
1067)
1068def test_merge_dataarray(variant, unit, error, dtype):
1069 original_unit = unit_registry.m
1070
1071 variants = {
1072 "data": ((original_unit, unit), (1, 1), (1, 1)),
1073 "dims": ((1, 1), (original_unit, unit), (1, 1)),
1074 "coords": ((1, 1), (1, 1), (original_unit, unit)),
1075 }
1076 (
1077 (data_unit1, data_unit2),
1078 (dim_unit1, dim_unit2),
1079 (coord_unit1, coord_unit2),
1080 ) = variants[variant]
1081
1082 array1 = np.linspace(0, 1, 2 * 3).reshape(2, 3).astype(dtype) * data_unit1
1083 x1 = np.arange(2) * dim_unit1
1084 y1 = np.arange(3) * dim_unit1
1085 u1 = np.linspace(10, 20, 2) * coord_unit1
1086 v1 = np.linspace(10, 20, 3) * coord_unit1
1087
1088 array2 = np.linspace(1, 2, 2 * 4).reshape(2, 4).astype(dtype) * data_unit2
1089 x2 = np.arange(2, 4) * dim_unit2
1090 z2 = np.arange(4) * dim_unit1
1091 u2 = np.linspace(20, 30, 2) * coord_unit2
1092 w2 = np.linspace(10, 20, 4) * coord_unit1
1093
1094 array3 = np.linspace(0, 2, 3 * 4).reshape(3, 4).astype(dtype) * data_unit2
1095 y3 = np.arange(3, 6) * dim_unit2
1096 z3 = np.arange(4, 8) * dim_unit2
1097 v3 = np.linspace(10, 20, 3) * coord_unit2
1098 w3 = np.linspace(10, 20, 4) * coord_unit2
1099
1100 arr1 = xr.DataArray(
1101 name="a",
1102 data=array1,
1103 coords={"x": x1, "y": y1, "u": ("x", u1), "v": ("y", v1)},
1104 dims=("x", "y"),
1105 )
1106 arr2 = xr.DataArray(
1107 name="a",
1108 data=array2,
1109 coords={"x": x2, "z": z2, "u": ("x", u2), "w": ("z", w2)},
1110 dims=("x", "z"),
1111 )
1112 arr3 = xr.DataArray(
1113 name="a",
1114 data=array3,
1115 coords={"y": y3, "z": z3, "v": ("y", v3), "w": ("z", w3)},
1116 dims=("y", "z"),
1117 )
1118
1119 func = function(xr.merge, compat="no_conflicts", join="outer")
1120 if error is not None:
1121 with pytest.raises(error):
1122 func([arr1, arr2, arr3])
1123
1124 return
1125

Callers

nothing calls this directly

Calls 10

assert_allcloseFunction · 0.90
functionClass · 0.85
strip_unitsFunction · 0.85
convert_unitsFunction · 0.85
attach_unitsFunction · 0.85
assert_units_equalFunction · 0.85
linspaceMethod · 0.80
arangeMethod · 0.80
funcFunction · 0.70
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…