dask: `Data.where` by davidhassell · Pull Request #260 · NCAS-CMS/cf-python

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially my thought as follows would be premature optimisation, so maybe if anything it could be a tentative TODODASK comment, but could this logic be refactored to avoid the need to calculate the shape of the data in the cases across where x has only size-1 dimensions? In other words, to essentially change the short-circuiting on the if check here to:

if n != m and n != 1:
if n != 1 n != m:

in case x is trivial and data is not, notably if it is large so expensive to get its shape? Would that even be worthwhile or could it e.g. be a niche case with general usage of the where method (not sure right now, thinking aloud here)?