>>> target = ndtest((3, 4))
>>> value = ndtest((2, 3)).rename({0: None, 1: None}).ignore_labels()
>>> target['a1':, 'b1':] = value
ValueError: cannot reshape array of size 6 into shape (1,1)
The underlying issue is that the value cannot be broadcasted to the target axes:
>>> value.broadcast_with(target['a1':, 'b1':].axes)
ValueError: cannot reshape array of size 6 into shape (1,1)
Unsure what it would take to fix this though.
I discovered this in MOSES via target[target_key] = excel_sheet[source_key] which displays a warning:
FutureWarning:
Setting a subset of an array with float64 dtype with a value with Range dtype.
It will be converted to float64 like in previous larray versions but this is
not a safe operation (some information could be lost in the conversion).
If you want to keep doing this conversion and silence this warning, please
convert the value explicitly using value.astype(<target_array_type>).
This warning will become an error in a future version of larray.
but using target[target_key] = excel_sheet[source_key].astype('float') triggers the bug.
I think that since Range objects implement an __larray__ method, the warning should have been different (should mention object dtype in the case of MOSES because the value contains None => nans), instead of "Range dtype" because it should have converted the Range to an Array via asarray. Would not have solved the warning (because of the object dtype) nor the broadcasting problem but at least it would have done what it should 😉
The underlying issue is that the value cannot be broadcasted to the target axes:
Unsure what it would take to fix this though.
I discovered this in MOSES via
target[target_key] = excel_sheet[source_key]which displays a warning:but using
target[target_key] = excel_sheet[source_key].astype('float')triggers the bug.I think that since Range objects implement an
__larray__method, the warning should have been different (should mention object dtype in the case of MOSES because the value contains None => nans), instead of "Range dtype" because it should have converted the Range to an Array via asarray. Would not have solved the warning (because of the object dtype) nor the broadcasting problem but at least it would have done what it should 😉