LabelArray-aware implementation of np.where.
(cond, trues, falses)
| 827 | |
| 828 | @expect_types(trues=LabelArray, falses=LabelArray) |
| 829 | def labelarray_where(cond, trues, falses): |
| 830 | """LabelArray-aware implementation of np.where. |
| 831 | """ |
| 832 | if trues.missing_value != falses.missing_value: |
| 833 | raise ValueError( |
| 834 | "Can't compute where on arrays with different missing values." |
| 835 | ) |
| 836 | |
| 837 | strs = np.where(cond, trues.as_string_array(), falses.as_string_array()) |
| 838 | return LabelArray(strs, missing_value=trues.missing_value) |