Small changes in looper.
epsi-builds/msspec_python3/pipeline/head This commit looks good
Details
epsi-builds/msspec_python3/pipeline/head This commit looks good
Details
This commit is contained in:
parent
605f3fda0e
commit
1899020178
|
@ -134,7 +134,7 @@ class SweepRange:
|
||||||
row[key] = value
|
row[key] = value
|
||||||
else:
|
else:
|
||||||
idx = int(i/(self.ntot/self.cn[isweep])) % len(sweep)
|
idx = int(i/(self.ntot/self.cn[isweep])) % len(sweep)
|
||||||
|
|
||||||
# If this sweep has links, add also all values from its
|
# If this sweep has links, add also all values from its
|
||||||
# children
|
# children
|
||||||
children = self.links.get(sweep, [])
|
children = self.links.get(sweep, [])
|
||||||
|
@ -168,7 +168,7 @@ class SweepRange:
|
||||||
|
|
||||||
class Looper:
|
class Looper:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
self.data = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pipeline(self):
|
def pipeline(self):
|
||||||
|
@ -184,7 +184,7 @@ class Looper:
|
||||||
def _wrapper(self, x):
|
def _wrapper(self, x):
|
||||||
logger.debug("Pipeline called with {}".format(x))
|
logger.debug("Pipeline called with {}".format(x))
|
||||||
return self.pipeline(**x)
|
return self.pipeline(**x)
|
||||||
|
|
||||||
def run(self, *sweeps, ncpu=1, passindex=False):
|
def run(self, *sweeps, ncpu=1, passindex=False):
|
||||||
logger.info("Loop starts...")
|
logger.info("Loop starts...")
|
||||||
# prepare the list of inputs
|
# prepare the list of inputs
|
||||||
|
@ -213,7 +213,7 @@ class Looper:
|
||||||
logger.info(("Parallel processing over {:d} cpu (chunksize={:d})..."
|
logger.info(("Parallel processing over {:d} cpu (chunksize={:d})..."
|
||||||
"").format(ncpu, chunksize))
|
"").format(ncpu, chunksize))
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
|
||||||
pool = mp.Pool(processes=ncpu)
|
pool = mp.Pool(processes=ncpu)
|
||||||
data = pool.map(self._wrapper, items, chunksize=chunksize)
|
data = pool.map(self._wrapper, items, chunksize=chunksize)
|
||||||
pool.close()
|
pool.close()
|
||||||
|
@ -235,6 +235,7 @@ class Looper:
|
||||||
|
|
||||||
df = pd.DataFrame(dfdata, columns=columns)
|
df = pd.DataFrame(dfdata, columns=columns)
|
||||||
|
|
||||||
|
self.data = df
|
||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,4 +285,4 @@ if __name__ == "__main__":
|
||||||
data = looper.run(emitter, emitter_plane, uij, theta, levels, ncpu=1,
|
data = looper.run(emitter, emitter_plane, uij, theta, levels, ncpu=1,
|
||||||
passindex=True)
|
passindex=True)
|
||||||
|
|
||||||
print(data)
|
print(data[data.emitter_plane.eq(0)].theta.unique())
|
||||||
|
|
Loading…
Reference in New Issue