Skip to content

Commit d08e5be

Browse files
committed
Fixed multiprocessing bugs
1 parent 00b4bf2 commit d08e5be

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

py/optimize_impl/analysis.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,28 @@ def generate_histogram(
4040
log=False
4141
):
4242
# Set width and height of figure
43-
matplotlib.rcParams['figure.figsize'] = (width, height)
43+
matplotlib.rcParams['figure.figsize'] = (width, height)
4444

4545
# Set percentage or absolute scale for y axis
46-
if use_percentage:
47-
hist = seaborn.histplot(X, bins = 21, stat='percent', binrange=binrange)
48-
hist.yaxis.set_major_formatter(mtick.PercentFormatter(decimals=0))
49-
plt.ylim(0, ylim)
50-
else:
51-
hist = seaborn.histplot(X, bins = 21, binrange=binrange)
46+
fig, ax = plt.subplots(1)
47+
if use_percentage:
48+
hist = seaborn.histplot(X, bins = 21, stat='percent', binrange=binrange, ax=ax)
49+
hist.yaxis.set_major_formatter(mtick.PercentFormatter(decimals=0))
50+
ax.set_ylim(0, ylim)
51+
else:
52+
hist = seaborn.histplot(X, bins = 21, binrange=binrange)
5253

5354
# Set axes labels
54-
hist.set_xlabel(label, fontsize=50)
55-
hist.set_ylabel("")
56-
hist.tick_params(labelsize=30)
55+
hist.set_xlabel(label, fontsize=50)
56+
hist.set_ylabel("")
57+
hist.tick_params(labelsize=30)
5758

5859
# Optionally use log scale
59-
if log:
60-
hist.set_xscale('log')
60+
if log:
61+
hist.set_xscale('log')
6162

6263
# Save figure to file
63-
plt.savefig(output_path, bbox_inches='tight')
64+
fig.savefig(output_path, bbox_inches='tight')
6465

6566
def generate_comparison_histogram(
6667
X,

scripts/script_util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def count_running_processes(p_list):
350350
def run_many(method, args):
351351
args_list = [(args, fname) for fname in args['fname']]
352352
with multiprocessing.Pool(processes=args['num_processes']) as pool:
353-
pool.starmap(method, args_list)
353+
pool.starmap(method, args_list, chunksize=1)
354354

355355
return
356356

src/optimization/layout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ get_consistent_layout(
768768
}
769769

770770
// Pullback cut on the original mesh to the overlay
771-
bool is_original_cut = false;
771+
bool is_original_cut = !(is_cut_orig.empty());
772772
std::vector<bool> is_cut_poly;
773773
if (is_original_cut) {
774774
is_cut_poly = pullback_cut_to_overlay(m_o, is_cut_orig, true);

0 commit comments

Comments
 (0)