msimet / Stile

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

Proposed API change for results & plotting in SysTests #115

Open msimet opened 6 years ago

msimet commented 6 years ago

After staring at this code this week, thinking about the things I'd like it to be able to do, etc, I think it would make sense to slightly revise our API. Here's how it currently works:

object = stile.SysTest()
results = object(data)
plot = object.plot(data)

or, to get data out of the WhiskerPlots/ScatterPlots:

object = stile.SysTest()
results = object(data)
arr = object.getData()

What I'd propose, instead, is making a new Results object that would carry its own plotting methods, as well as an ability to write out data, etc. This also could make issue #97 (parallelization, and implicitly accumulating results from a catalog in multiple chunks) easier, because you could pass this Results object and accumulate more data onto it, or possibly combine Results objects. And all the info about the results are stored by this object, instead of a combination of the results object and the test object, which is how it currently works. That would make the workflow:

object = stile.SysTest()
results = object(data)
plot = results.plot(data)``

or

object = stile.SysTest()
results = object(data)
arr = results.getData()

I would propose making two kinds of Results object, one that inherits from numpy.ndarray and one from matplotlib.figure.Figure, since our two main kinds of results are arrays and plots and it would be nice to preserve all the operations you could do on those items if we don't need to overwrite them for Stile purposes.