def func(x, z=None): if not hasattr(mask, '__call__'): _mask = mask else: _mask = mask(x, z) if z is None and hasattr(x, '_x') and hasattr(x, '_y'): from copy import copy m = copy(x) mon = True else: from mystic.monitors import Monitor m = Monitor() m._x, m._y = x, z mon = False ax = True if hasattr(m._x, 'tolist') else False ay = True if hasattr(m._y, 'tolist') else False from numpy import asarray m._x = asarray(m._x)[_mask] m._y = asarray(m._y)[_mask] if not ax: m._x = m._x.tolist() if not ay: m._y = m._y.tolist() if mon: try: ai = True if hasattr(m._id, 'tolist') else False m._id = array(m._id)[_mask] if not ai: m._id = m._id.tolist() except IndexError: pass #XXX: m._id = [] return m return m._x, m._y
def write_monitor(steps, energy, id=[]): from mystic.monitors import Monitor mon = Monitor() mon._x = steps[:] mon._y = energy[:] mon._id = id[:] return mon
def write_monitor(steps, energy, id=[]): from mystic.monitors import Monitor mon = Monitor() mon._x = steps[:] mon._y = energy[:] mon._id = id[:] return mon