msimet / Stile

Stile: the Systematics Tests In Lensing pipeline
BSD 3-Clause "New" or "Revised" License
9 stars 6 forks source link

Binning interface update? #82

Open msimet opened 8 years ago

msimet commented 8 years ago

At the moment, we have a set of binning objects that bin the data. If you just have one, it's pretty straightforward. You make an object, and the object is iterable, with one iterated object per bin in the binning scheme.

bin_scheme = stile.BinStep(...)  # or some other kind of binning scheme
for bin in bin_scheme:
    binned_data = bin(data)
    (...stuff...)

If you have multiple bins you'd like to apply--say, bins in magnitude and resolution--there's a function called ExpandBinList to iterate in the correct order:

mag_scheme = stile.BinStep(...)
res_scheme = stile.BinList(...)
for bin_set in stile.ExpandBinList(mag_scheme, res_scheme):
    binned_data = data
    for bin in bin_set:
        binned_data = bin(binned_data)
    (...stuff...)

I'm wondering if it would be better to have this work as:

mag_scheme = stile.BinStep(...)
res_scheme = stile.BinList(...)
for bin_set in stile.ExpandBinList(mag_scheme, res_scheme):
    binned_data = bin_set(data)
    (...stuff...)

instead, that is, to do the loop over the iterated objects from each input scheme automatically.

This is a break in the interface design, but I'm not sure anybody is using this interface yet, so I don't know how much of a problem it would cause. Thoughts?