From 901e0892ce69da506d05dce5afb314ab0984de2c Mon Sep 17 00:00:00 2001 From: William Heymann Date: Tue, 24 Sep 2019 14:33:20 +0200 Subject: [PATCH] Fixed a syntax error with fractionations related to the unit change Renamed scoop_match.py to __main__.py to make it easier to run Now you can use python -m CADETMatch --match -j /path/to/file.json --- CADETMatch.egg-info/SOURCES.txt | 2 +- CADETMatch/CADETMatch.pyproj | 5 +++-- CADETMatch/{scoop_match.py => __main__.py} | 8 ++++++-- CADETMatch/scores/fractionation.py | 2 +- CADETMatch/scores/fractionationCombine.py | 2 +- CADETMatch/scores/fractionationMeanVariance.py | 2 +- CADETMatch/scores/fractionationMoment.py | 2 +- CADETMatch/scores/fractionationSlide.py | 2 +- 8 files changed, 15 insertions(+), 10 deletions(-) rename CADETMatch/{scoop_match.py => __main__.py} (91%) diff --git a/CADETMatch.egg-info/SOURCES.txt b/CADETMatch.egg-info/SOURCES.txt index 78f954d..86adbbc 100644 --- a/CADETMatch.egg-info/SOURCES.txt +++ b/CADETMatch.egg-info/SOURCES.txt @@ -2,6 +2,7 @@ README.md setup.cfg setup.py CADETMatch/__init__.py +CADETMatch/__main__.py CADETMatch/autocorr.py CADETMatch/cache.py CADETMatch/calc_coeff.py @@ -25,7 +26,6 @@ CADETMatch/nsga2_simple.py CADETMatch/nsga3_selection.py CADETMatch/pareto.py CADETMatch/plugins.py -CADETMatch/scoop_match.py CADETMatch/score.py CADETMatch/similarityDecay.py CADETMatch/synthetic_error.py diff --git a/CADETMatch/CADETMatch.pyproj b/CADETMatch/CADETMatch.pyproj index 1506bf0..33f9a18 100644 --- a/CADETMatch/CADETMatch.pyproj +++ b/CADETMatch/CADETMatch.pyproj @@ -16,7 +16,8 @@ Standard Python launcher "F:\temp\example\fit\example.json" 2 False - -m scoop -n 6 + + true @@ -95,7 +96,7 @@ Code - + Code diff --git a/CADETMatch/scoop_match.py b/CADETMatch/__main__.py similarity index 91% rename from CADETMatch/scoop_match.py rename to CADETMatch/__main__.py index 7f0f94a..794f1c0 100644 --- a/CADETMatch/scoop_match.py +++ b/CADETMatch/__main__.py @@ -43,13 +43,17 @@ def makeParser(): action='store_true') parser.add_argument('-n', - help="Number of scoop processes to use. Use 1 for debugging") + help="Number of scoop processes to use. Use 1 for debugging", + default=0) return parser def run_command(module, json, number_of_jobs, additional=None): - command = [sys.executable, '-m', 'scoop', '-n', str(number_of_jobs), module.__file__, str(json)] + command = [sys.executable, '-m', 'scoop'] + if int(number_of_jobs) > 0: + command.extend(['-n', str(number_of_jobs)]) + command.extend([module.__file__, str(json)]) if additional is not None: command.extend(additional) diff --git a/CADETMatch/scores/fractionation.py b/CADETMatch/scores/fractionation.py index 6287e86..a424d51 100644 --- a/CADETMatch/scores/fractionation.py +++ b/CADETMatch/scores/fractionation.py @@ -32,7 +32,7 @@ def run(sim_data, feature): selected = (times >= start) & (times <= stop) local_times = times[selected] - local_values = simulation.root.output.solution[feature['unit']["solution_outlet_comp_%03d" % component][selected] + local_values = simulation.root.output.solution[feature['unit']]["solution_outlet_comp_%03d" % component][selected] sim_value = numpy.trapz(local_values, local_times) diff --git a/CADETMatch/scores/fractionationCombine.py b/CADETMatch/scores/fractionationCombine.py index 8c12717..b5b711a 100644 --- a/CADETMatch/scores/fractionationCombine.py +++ b/CADETMatch/scores/fractionationCombine.py @@ -40,7 +40,7 @@ def run(sim_data, feature): selected = (times >= start) & (times <= stop) local_times = times[selected] - local_values = simulation.root.output.solution[feature['unit']["solution_outlet_comp_%03d" % component][selected] + local_values = simulation.root.output.solution[feature['unit']]["solution_outlet_comp_%03d" % component][selected] sim_value = numpy.trapz(local_values, local_times) diff --git a/CADETMatch/scores/fractionationMeanVariance.py b/CADETMatch/scores/fractionationMeanVariance.py index 715cd02..b18fa74 100644 --- a/CADETMatch/scores/fractionationMeanVariance.py +++ b/CADETMatch/scores/fractionationMeanVariance.py @@ -35,7 +35,7 @@ def run(sim_data, feature): for (start, stop, component, values, func_mean_time, func_variance_time, func_mean_value, func_variance_value) in funcs: time_center = (start + stop)/2.0 - sim_values = util.fractionate(start, stop, times, simulation.root.output.solution[feature['unit']["solution_outlet_comp_%03d" % component]) + sim_values = util.fractionate(start, stop, times, simulation.root.output.solution[feature['unit']]["solution_outlet_comp_%03d" % component]) mean_sim_time, variance_sim_time, skew_sim_time, mean_sim_value, variance_sim_value, skew_sim_value = util.fracStat(time_center, sim_values) diff --git a/CADETMatch/scores/fractionationMoment.py b/CADETMatch/scores/fractionationMoment.py index 8991a48..4c5f73a 100644 --- a/CADETMatch/scores/fractionationMoment.py +++ b/CADETMatch/scores/fractionationMoment.py @@ -35,7 +35,7 @@ def run(sim_data, feature): for (start, stop, component, values, func_mean_time, func_variance_time, func_skew_time, func_mean_value, func_variance_value, func_skew_value) in funcs: time_center = (start + stop)/2.0 - sim_values = util.fractionate(start, stop, times, simulation.root.output.solution[feature['unit']["solution_outlet_comp_%03d" % component]) + sim_values = util.fractionate(start, stop, times, simulation.root.output.solution[feature['unit']]["solution_outlet_comp_%03d" % component]) mean_sim_time, variance_sim_time, skew_sim_time, mean_sim_value, variance_sim_value, skew_sim_value = util.fracStat(time_center, sim_values) diff --git a/CADETMatch/scores/fractionationSlide.py b/CADETMatch/scores/fractionationSlide.py index 00d144c..edf099f 100644 --- a/CADETMatch/scores/fractionationSlide.py +++ b/CADETMatch/scores/fractionationSlide.py @@ -75,7 +75,7 @@ def run(sim_data, feature): for component, value_func in funcs: exp_values = numpy.array(data[str(component)]) - sim_value = simulation.root.output.solution[feature['unit']["solution_outlet_comp_%03d" % component] + sim_value = simulation.root.output.solution[feature['unit']]["solution_outlet_comp_%03d" % component] rollLeft, rollRight, searchMax = rollRange(times, sim_value, searchIndexStart, searchIndexStop)