APS-2BM-MIC / ipython-user2bmb

ipython configurations for the tomography instrument
2 stars 5 forks source link

Suggestion: avoiding calling RE inside a function #8

Closed danielballan closed 6 years ago

danielballan commented 6 years ago

We advise you to avoid calling RE from inside a function, as is done here. We can see this for demo purposes, but it's still good to avoid having this things floating around, especially in an interactive namespace. They can lead to unexpected and confusion behavior; the RunEngine should always be called directly. If brevity is the goal, it's better to use functools.partial to make a succinct plan:

Before:

def demo():
    RE(mona_core(detectors, adsimdet.cam.acquire, num=3), md=metadata)
demo()

After:

import functools
demo = functools.partial(mona_core, detectors, adsimdet.cam.acquire, num=3, md=metadata)
RE(demo())

where mona_core must be modified to accept an md argument.

prjemian commented 6 years ago

I agree.

prjemian commented 6 years ago

will resolve as part of #3