in causalml/inference/tree/_tree/_tree.pyx [0:0]
def _check_value_ndarray(value_ndarray, expected_dtype, expected_shape):
if value_ndarray.shape != expected_shape:
raise ValueError(
"Wrong shape for value array from the pickle: "
f"expected {expected_shape}, got {value_ndarray.shape}"
)
if not value_ndarray.flags.c_contiguous:
raise ValueError(
"value array from the pickle should be a C-contiguous array"
)
if value_ndarray.dtype == expected_dtype:
return value_ndarray
# Handles different endianness
if value_ndarray.dtype.str.endswith('f8'):
return value_ndarray.astype(expected_dtype, casting='equiv')
raise ValueError(
"value array from the pickle has an incompatible dtype:\n"
f"- expected: {expected_dtype}\n"
f"- got: {value_ndarray.dtype}"
)