mergeron 2024.738936.0__py3-none-any.whl → 2024.738940.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of mergeron might be problematic. Click here for more details.

@@ -41,7 +41,7 @@ def propn_ci(
41
41
  ]:
42
42
  """Returns point estimates and confidence interval for a proportion
43
43
 
44
- Methods "Clopper-Pearson" and "Exact" are synoymous [2]_. Similarly,
44
+ Methods "Clopper-Pearson" and "Exact" are synoymous [3]_. Similarly,
45
45
  "Wilson" and "Score" are synonyms here.
46
46
 
47
47
  Parameters
@@ -66,7 +66,7 @@ def propn_ci(
66
66
  References
67
67
  ----------
68
68
 
69
- .. [2] Alan Agresti & Brent A. Coull (1998) Approximate is Better
69
+ .. [3] Alan Agresti & Brent A. Coull (1998) Approximate is Better
70
70
  than “Exact” for Interval Estimation of Binomial Proportions,
71
71
  The American Statistician, 52:2, 119-126,
72
72
  https://doi.org/10.1080/00031305.1998.10480550
@@ -200,9 +200,9 @@ def propn_diff_ci(
200
200
  ) -> tuple[float, float, float, float]:
201
201
  R"""Confidence intervals for differences in binomial proportions.
202
202
 
203
- Methods available are Agresti-Caffo [3]_, Mee [4]_, Meitinen-Nurminen [4]_ [5]_
204
- and Newcombe (aka, Score method) [4]_. See also, source code for the
205
- R-language function BinomDiffCI, in the module StatsAndCIs [6]_.
203
+ Methods available are Agresti-Caffo [4]_, Mee [5]_, Meitinen-Nurminen [5]_ [6]_
204
+ and Newcombe (aka, Score method) [5]_. See also, source code for the
205
+ R-language function BinomDiffCI, in the module StatsAndCIs [7]_.
206
206
 
207
207
  Parameters
208
208
  ----------
@@ -222,19 +222,19 @@ def propn_diff_ci(
222
222
  References
223
223
  ----------
224
224
 
225
- .. [3] Agresti, A., & Caffo, T. (2000). Simple and Effective
225
+ .. [4] Agresti, A., & Caffo, T. (2000). Simple and Effective
226
226
  Confidence Intervals for Proportions and Differences of Proportions
227
227
  Result from Adding Two Successes and Two Failures.
228
228
  The American Statistician, 54(4), 280--288. https://doi.org/10.2307/2685779
229
229
 
230
- .. [4] Newcombe, R.G. (1998). Two-sided confidence intervals for
230
+ .. [5] Newcombe, R.G. (1998). Two-sided confidence intervals for
231
231
  the single proportion: comparison of seven methods. Statist. Med., 17: 857-872.
232
232
  https://doi.org/10.1002/(SICI)1097-0258(19980430)17:8%3C857::AID-SIM777%3E3.0.CO;2-E
233
233
 
234
- .. [5] Miettinen, O. and Nurminen, M. (1985). Comparative analysis of two rates.
234
+ .. [6] Miettinen, O. and Nurminen, M. (1985). Comparative analysis of two rates.
235
235
  Statist. Med., 4: 213-226. https://doi.org/10.1002/sim.4780040211; Appendix I
236
236
 
237
- .. [6] StatsAndCIs.r, function BinomDiffCI, method, "mn"
237
+ .. [7] StatsAndCIs.r, function BinomDiffCI, method, "mn"
238
238
  https://github.com/cran/DescTools/blob/master/R/StatsAndCIs.r
239
239
  (R source code is distributed under the CC-BY license.)
240
240
 
@@ -78,8 +78,7 @@ def gen_seed_seq_list_default(
78
78
 
79
79
  References
80
80
  ----------
81
- *See*,
82
- https://numpy.org/doc/stable/reference/random/parallel.html
81
+ *See*, https://numpy.org/doc/stable/reference/random/parallel.html
83
82
 
84
83
 
85
84
  """
@@ -20,116 +20,117 @@ systems.
20
20
 
21
21
  from __future__ import annotations
22
22
 
23
- from collections import OrderedDict
24
23
  from collections.abc import Mapping, Sequence
25
24
  from datetime import datetime
26
25
  from math import sqrt
27
26
  from pathlib import Path
28
27
  from typing import Any, Literal
29
28
 
30
- import matplotlib.axis
29
+ import matplotlib.axes as mpa
31
30
  from joblib import Parallel, cpu_count, delayed
32
31
  from numpy import pi
33
32
  from xlsxwriter import Workbook
34
33
 
35
34
  import mergeron.core.excel_helper as xlh
36
- import mergeron.core.guidelines_standards as gsf
35
+ import mergeron.core.guidelines_standards as gsl
37
36
  import mergeron.ext.tol_colors as ptcolor
38
37
  from mergeron import DATA_DIR
39
38
 
40
39
  PROG_PATH = Path(__file__)
41
40
 
42
- recapture_spec = "inside-out"
41
+ RECAPTURE_SPEC = "inside-out"
43
42
  # Map boundary forms to titles and generating-function names, with
44
43
  # additional parameters as relevant
45
- bdry_specs_dict: Mapping[str, Mapping[str, Any]] = OrderedDict({
44
+ BDRY_SPECS_DICT: Mapping[str, Mapping[str, Any]] = {
46
45
  "ΔHHI": {
47
- "title_str": "ΔHHI boundary boundary",
46
+ "title_str": "ΔHHI boundary",
47
+ "sheet_name": "ΔHHI",
48
48
  "func_str": R"\Delta HHI",
49
- "func": gsf.delta_hhi_boundary,
49
+ "func": gsl.delta_hhi_boundary,
50
50
  },
51
51
  "OSWAG Own-shr-wtd Div Ratio Index": {
52
52
  "title_str": "Aggregated-diversion-ratio boundary, own-share wtd. avg.",
53
+ "sheet_name": "OSWAG, wtd avg",
53
54
  "func_str": R"(s_1 d_{12} + s_2 d_{21}) / s_M",
54
- "func": gsf.shrratio_mgnsym_boundary_wtd_avg,
55
- "func_kwargs": {"wgtng_policy": "own-share", "recapture_spec": recapture_spec},
55
+ "func": gsl.shrratio_boundary_wtd_avg,
56
+ "func_kwargs": {"wgtng_policy": "own-share", "recapture_spec": RECAPTURE_SPEC},
56
57
  },
57
58
  "OSWAG Own-shr-wtd Div Ratio Distance": {
58
59
  "title_str": "Aggregated-diversion-ratio boundary, own-shr. wtd. distance",
60
+ "sheet_name": "OSWAG, distance",
59
61
  "func_str": R"\surd (s_1 d_{12}^2 / s_M + s_2 d_{21}^2 / s_M)",
60
- "func": gsf.shrratio_mgnsym_boundary_wtd_avg,
62
+ "func": gsl.shrratio_boundary_wtd_avg,
61
63
  "func_kwargs": {
62
64
  "wgtng_policy": "own-share",
63
- "recapture_spec": recapture_spec,
64
- "avg_method": "root-mean-square",
65
- },
66
- },
67
- "OSWAG Own-shr-wtd Div Ratio Real Distance": {
68
- "title_str": "Aggregated-diversion-ratio boundary, own-shr. wtd. (really) distance ",
69
- "func_str": R"\surd (d_{12}^{s_1 / s_M} + d_{21}^{s_2 / s_M})",
70
- "func": gsf.shrratio_mgnsym_boundary_wtd_avg,
71
- "func_kwargs": {
72
- "wgtng_policy": "own-share",
73
- "recapture_spec": recapture_spec,
65
+ "recapture_spec": RECAPTURE_SPEC,
74
66
  "avg_method": "distance",
75
67
  },
76
68
  },
77
69
  "OSWAG Min Div Ratio": {
78
70
  "title_str": "Aggregated-diversion-ratio boundary, minimum",
71
+ "sheet_name": "OSWAG, minimum",
79
72
  "func_str": R"\min (d_{12}, d_{21})",
80
- "func": gsf.shrratio_mgnsym_boundary_min,
81
- "func_kwargs": {"recapture_spec": recapture_spec},
73
+ "func": gsl.shrratio_boundary_min,
74
+ "func_kwargs": {"recapture_spec": RECAPTURE_SPEC},
82
75
  },
83
76
  "SAG Combined Share": {
84
77
  "title_str": "Combined Share boundary",
78
+ "sheet_name": "SAG, combined-share",
85
79
  "func_str": R"s_M",
86
- "func": gsf.combined_share_boundary,
80
+ "func": gsl.combined_share_boundary,
87
81
  },
88
82
  "SAG Div Ratio Distance": {
89
83
  "title_str": "Aggregated-diversion-ratio boundary, distance",
84
+ "sheet_name": "SAG, distance",
90
85
  "func_str": R"\surd (d_{12}^2 / 2 + d_{21}^2 / 2)",
91
- "func": gsf.shrratio_mgnsym_boundary_avg,
86
+ "func": gsl.shrratio_boundary_wtd_avg,
92
87
  "func_kwargs": {
93
- "recapture_spec": recapture_spec,
94
- "avg_method": "root-mean-square",
88
+ "wgtng_policy": None,
89
+ "recapture_spec": RECAPTURE_SPEC,
90
+ "avg_method": "distance",
95
91
  },
96
92
  },
97
93
  "SAG Average Div Ratio": {
98
94
  "title_str": "Aggregated-diversion-ratio boundary, simple average",
95
+ "sheet_name": "SAG, average",
99
96
  "func_str": R"(d_{12} + d_{21}) / 2",
100
- "func": gsf.shrratio_mgnsym_boundary_xact_avg,
101
- "func_kwargs": {"recapture_spec": recapture_spec},
97
+ "func": gsl.shrratio_boundary_xact_avg,
98
+ "func_kwargs": {"recapture_spec": RECAPTURE_SPEC},
102
99
  },
103
100
  "CPSWAG Premerger HHI-contribution": {
104
101
  "title_str": "Premerger HHI-contribution boundary",
102
+ "sheet_name": "CPSWAG, HHI-contrib-pre",
105
103
  "func_str": R"HHI_M^{pre}",
106
- "func": gsf.hhi_pre_contrib_boundary,
104
+ "func": gsl.hhi_pre_contrib_boundary,
107
105
  },
108
106
  "CPSWAG Cross-product-shr-wtd Div Ratio Index": {
109
107
  "title_str": "Aggregated-diversion-ratio boundary, cross-product-share wtd. avg.",
108
+ "sheet_name": "CPSWAG, wtd avg",
110
109
  "func_str": R"(s_2 d_{12} / s_M + s_1 d_{21} / s_M)",
111
- "func": gsf.shrratio_mgnsym_boundary_wtd_avg,
110
+ "func": gsl.shrratio_boundary_wtd_avg,
112
111
  "func_kwargs": {
113
112
  "wgtng_policy": "cross-product-share",
114
- "recapture_spec": recapture_spec,
113
+ "recapture_spec": RECAPTURE_SPEC,
115
114
  },
116
115
  },
117
116
  "CPSWAG Cross-product-shr-wtd Div Ratio Distance": {
118
117
  "title_str": "Aggregated-diversion-ratio boundary, cross-prod-shr. wtd. distance",
118
+ "sheet_name": "CPSWAG, distance",
119
119
  "func_str": R"\surd (s_2 d_{12}^2 / s_M + s_1 d_{21}^2 / s_M)",
120
- "func": gsf.shrratio_mgnsym_boundary_wtd_avg,
120
+ "func": gsl.shrratio_boundary_wtd_avg,
121
121
  "func_kwargs": {
122
122
  "wgtng_policy": "cross-product-share",
123
- "recapture_spec": recapture_spec,
124
- "avg_method": "root-mean-square",
123
+ "recapture_spec": RECAPTURE_SPEC,
124
+ "avg_method": "distance",
125
125
  },
126
126
  },
127
127
  "CPSWAG Max Div Ratio": {
128
128
  "title_str": "Aggregated-diversion-ratio boundary, maximum",
129
+ "sheet_name": "CPSWAG, maximum",
129
130
  "func_str": R"\max (d_{12}, d_{21})",
130
- "func": gsf.shrratio_mgnsym_boundary_max,
131
+ "func": gsl.shrratio_boundary_max,
131
132
  },
132
- })
133
+ }
133
134
 
134
135
 
135
136
  def tabulate_boundary_stats(_gpubyr: Literal[1992, 2010, 2023], /) -> None:
@@ -141,8 +142,10 @@ def tabulate_boundary_stats(_gpubyr: Literal[1992, 2010, 2023], /) -> None:
141
142
  are drawn
142
143
 
143
144
  """
144
- gso = gsf.GuidelinesStandards(_gpubyr)
145
- _dhhi_val, _, _r_val, _g_val, *_ = gso.presumption
145
+ gso = gsl.GuidelinesStandards(_gpubyr)
146
+ _dhhi_val, _r_val, _g_val = (
147
+ getattr(gso.presumption, _f) for _f in ("delta", "rec", "guppi")
148
+ )
146
149
 
147
150
  _dhhi_seq = (
148
151
  (0.01, 0.02, 0.03125, 0.05, _dhhi_val)
@@ -153,7 +156,7 @@ def tabulate_boundary_stats(_gpubyr: Literal[1992, 2010, 2023], /) -> None:
153
156
  _bdry_approx_data_dict = {
154
157
  "Criterion": {
155
158
  _k: R"\({} < {}\)".format(
156
- bdry_specs_dict[_k]["func_str"],
159
+ BDRY_SPECS_DICT[_k]["func_str"],
157
160
  R"\safeharb{d}"
158
161
  if "Div Ratio" in _k
159
162
  else (
@@ -162,7 +165,7 @@ def tabulate_boundary_stats(_gpubyr: Literal[1992, 2010, 2023], /) -> None:
162
165
  else R"\safeharb{H}"
163
166
  ),
164
167
  )
165
- for _k in bdry_specs_dict
168
+ for _k in BDRY_SPECS_DICT
166
169
  if not _k.endswith("Distance")
167
170
  }
168
171
  }
@@ -197,7 +200,7 @@ def _dhhi_stats(
197
200
 
198
201
  _delta_val = _s_mid / (1 - _s_mid)
199
202
  if _dhhi_val * 1e4 in (50, 100, 200):
200
- _delta_val = gsf.round_cust(_r_val * _delta_val) / _r_val
203
+ _delta_val = gsl.round_cust(_r_val * _delta_val) / _r_val
201
204
  _divr_val = _r_val * _delta_val
202
205
 
203
206
  print(
@@ -209,7 +212,7 @@ def _dhhi_stats(
209
212
 
210
213
  _bdry_stats = Parallel(n_jobs=cpu_count() // 2)(
211
214
  delayed(_bdry_stats_col)(_bdry_spec, _dhhi_val, _delta_val, _r_val)
212
- for _bdry_spec in bdry_specs_dict
215
+ for _bdry_spec in BDRY_SPECS_DICT
213
216
  )
214
217
 
215
218
  _bounds_string = R"{{ {} \\ {} }}".format(
@@ -222,7 +225,7 @@ def _dhhi_stats(
222
225
  def _bdry_stats_col(
223
226
  _bdry_spec: str, _dhhi_val: float, _delta_val: float, _r_val: float, /
224
227
  ) -> tuple[str, str]:
225
- _dhhi_prob = 2 * gsf.dh_area(_dhhi_val)
228
+ _dhhi_prob = 2 * gsl.dh_area(_dhhi_val)
226
229
  _cs_prob = 2 * _dhhi_val
227
230
  _hhi_m_pre_prob = pi * _dhhi_val / 2
228
231
 
@@ -234,9 +237,9 @@ def _bdry_stats_col(
234
237
  case "CPSWAG Premerger HHI-contribution":
235
238
  return _bdry_spec, f"{_hhi_m_pre_prob:6.5f}"
236
239
  case _ if "Div Ratio" in _bdry_spec:
237
- _gbd_func = bdry_specs_dict[_bdry_spec]["func"]
240
+ _gbd_func = BDRY_SPECS_DICT[_bdry_spec]["func"]
238
241
  _, _within_bdry_area = _gbd_func(
239
- _delta_val, _r_val, **bdry_specs_dict[_bdry_spec].get("func_kwargs", {})
242
+ _delta_val, _r_val, **BDRY_SPECS_DICT[_bdry_spec].get("func_kwargs", {})
240
243
  )
241
244
  _within_bdry_prob = 2 * _within_bdry_area
242
245
  _within_conc_bdry_prob = (
@@ -259,12 +262,13 @@ def plot_and_save_boundary_coords(
259
262
  /,
260
263
  layout: Literal["collected", "distributed"] = "collected",
261
264
  ) -> None:
262
- gso = gsf.GuidelinesStandards(_gpubyr)
265
+ gso = gsl.GuidelinesStandards(_gpubyr)
263
266
 
264
- _hmg_standards_strings = {
267
+ _hmg_standards_strings_dict = {
265
268
  "distributed": ("presumption", "inferred presumption", "safeharbor"),
266
269
  "collected": ("safeharbor", "inferred_presumption", "presumption"),
267
- }.get(layout, ())
270
+ }
271
+ _hmg_standards_strings = _hmg_standards_strings_dict.get(layout, ())
268
272
  if not _hmg_standards_strings:
269
273
  raise ValueError(
270
274
  f"Layout parameter value, {layout!r} is invalid. "
@@ -272,14 +276,14 @@ def plot_and_save_boundary_coords(
272
276
  )
273
277
 
274
278
  # Initialize plot area
275
- _plt, _my_fig1, _ax1, _set_axis_def = gsf.boundary_plot()
279
+ _plt, _my_fig1, _ax1, _set_axis_def = gsl.boundary_plot()
276
280
 
277
281
  _divr_agg_methods = ("OSWAG", "SAG", "CPSWAG")
278
282
 
279
283
  for _divr_agg_method, _hmg_standards_str in zip(
280
284
  _divr_agg_methods, _hmg_standards_strings, strict=True
281
285
  ):
282
- _r_bar, _g_bar = gso.presumption[2:4]
286
+ _r_bar, _g_bar = (getattr(gso.presumption, _f) for _f in ("rec", "guppi"))
283
287
  _dhhi_val = getattr(gso, _hmg_standards_str)[0]
284
288
  _divr_val = (
285
289
  _g_bar
@@ -301,43 +305,29 @@ def plot_and_save_boundary_coords(
301
305
  str, Sequence[tuple[float]]
302
306
  ] = {} #: Container for boundary coordinates data, by boundary
303
307
 
304
- for _bdry_spec_key in bdry_specs_dict:
305
- _bdry_spec = (_bdry_spec_key, bdry_specs_dict[_bdry_spec_key])
308
+ for _bdry_spec_key in BDRY_SPECS_DICT:
309
+ _bdry_spec = (_bdry_spec_key, BDRY_SPECS_DICT[_bdry_spec_key])
306
310
 
307
311
  if _bdry_spec_key == "ΔHHI":
308
- if any((
309
- _hmg_standards_str == "inferred_presumption",
310
- _hmg_standards_str == "safeharbor" and layout == "collected",
311
- _hmg_standards_str == "presumption" and _divr_agg_method != "OSWAG",
312
- )):
312
+ if _hmg_standards_str != _hmg_standards_strings_dict[layout][0]:
313
313
  continue
314
314
 
315
315
  _dh_s1, _dh_s2 = gen_plot_boundary(
316
316
  _bndry_data_dict, gso, _hmg_standards_str, _bdry_spec, _ax1
317
317
  )
318
318
 
319
- if _hmg_standards_str == "safeharbor":
320
- _ax1.fill_between(
321
- (0, *tuple(_dh_s1), 1),
322
- (1, *tuple(_dh_s2), 0),
323
- edgecolor=None,
324
- facecolor="#64bb64", # "#64ff64"
325
- alpha=0.7,
326
- rasterized=True,
327
- )
328
-
329
319
  del _dh_s1, _dh_s2
330
320
 
331
321
  elif _bdry_spec_key.startswith(
332
322
  _divr_agg_method
333
- ) and not _bdry_spec_key.endswith("Distance"):
323
+ ): # and not _bdry_spec_key.endswith("Distance"):
334
324
  gen_plot_boundary(
335
325
  _bndry_data_dict, gso, _hmg_standards_str, _bdry_spec, _ax1
336
326
  )
337
327
 
338
328
  _fig_leg = _ax1.legend(
339
329
  loc="upper right",
340
- bbox_to_anchor=(0.995, 0.995),
330
+ bbox_to_anchor=(0.995, 0.999),
341
331
  shadow=True,
342
332
  fancybox=False,
343
333
  frameon=False,
@@ -346,9 +336,6 @@ def plot_and_save_boundary_coords(
346
336
  _fig_leg.set_in_layout(False)
347
337
 
348
338
  for _bndry_name in _bndry_data_dict:
349
- if _bndry_name == "ΔHHI": # _divr_agg_method != "OSWAG" and
350
- continue
351
-
352
339
  boundary_data_to_worksheet(
353
340
  _bndry_name,
354
341
  _dhhi_val_str,
@@ -361,15 +348,14 @@ def plot_and_save_boundary_coords(
361
348
  _fig_savepath = DATA_DIR / rf"{PROG_PATH.stem}_{_gpubyr}.pdf"
362
349
  _my_fig1.savefig(_fig_savepath)
363
350
  print()
364
- del _divr_agg_method
365
351
 
366
352
 
367
353
  def gen_plot_boundary(
368
354
  _bndry_data_dict: Mapping[str, Sequence[tuple[float]]],
369
- _gso: gsf.GuidelinesStandards,
355
+ _gso: gsl.GuidelinesStandards,
370
356
  _gs_str: str,
371
357
  _bdry_spec: tuple[str, Mapping[str, Any]],
372
- _ax1: matplotlib.axes.Axes,
358
+ _ax1: mpa.Axes,
373
359
  /,
374
360
  ) -> tuple[tuple[float], tuple[float]]:
375
361
  """
@@ -380,7 +366,7 @@ def gen_plot_boundary(
380
366
  _bndry_data_dict
381
367
  mapping for storing boundary coordinates for each plotted boundary
382
368
  _gso
383
- gsf.GuidelinesStandards instance of tuples listing
369
+ gsl.GuidelinesStandards instance of tuples listing
384
370
  concentration standard, default recapture-rate, GUPPI bound,
385
371
  and diversion ratio bound for "safeharbor", "weak presumption",
386
372
  and "presumption", where "weak presumption" represents an alternative
@@ -392,7 +378,7 @@ def gen_plot_boundary(
392
378
  a mapping detailing the boundary function specification including
393
379
  boundary function name and keyword parameters
394
380
  _ax1
395
- matplotlib axis object for plots
381
+ matplotlib Axes object for plots
396
382
 
397
383
  Returns
398
384
  -------
@@ -406,10 +392,14 @@ def gen_plot_boundary(
406
392
  _pt_mdco: ptcolor.Mcset = ptcolor.tol_cset("medium-contrast") # type: ignore
407
393
 
408
394
  _plot_line_width = 1.0
395
+ _plot_line_alpha = 0.8
409
396
  _plot_line_color = _pt_mdco.black
410
397
  _plot_line_style = {"OSWAG": "-", "SAG": "-.", "CPSWAG": "--"}.get(
411
398
  _bdry_spec_str.split(" ")[0], "-"
412
399
  )
400
+ if _bdry_spec_str.startswith("ΔHHI"):
401
+ _plot_line_width = 0.5
402
+ _plot_line_alpha = 1.0
413
403
  _zrdr = 5
414
404
 
415
405
  if not _bdry_spec_str.startswith("ΔHHI"):
@@ -425,12 +415,12 @@ def gen_plot_boundary(
425
415
  case _:
426
416
  _plot_line_color = _pt_mdco.dark_red
427
417
 
428
- _dh_bar = _gso.safeharbor[0]
429
- _g_val = _gso.safeharbor[3]
418
+ _dh_bar = _gso.safeharbor.divr
419
+ _g_val = _gso.safeharbor.guppi
430
420
 
431
- _r_bar = _gso.presumption[2]
421
+ _r_bar = _gso.presumption.rec
432
422
 
433
- _dhhi_val = getattr(_gso, _gs_str)[0] # _gso.presumption[0]
423
+ _dhhi_val = getattr(_gso, _gs_str).delta
434
424
  _s_mid = sqrt(_dhhi_val / 2)
435
425
  _delta_val = _g_val / _r_bar if _gs_str == "safeharbor" else _s_mid / (1 - _s_mid)
436
426
 
@@ -456,7 +446,9 @@ def gen_plot_boundary(
456
446
  _plot_label_uom,
457
447
  )
458
448
 
459
- _bndry_data_dict |= {_bdry_spec_str: (_bdry_data, _bdry_area)} # type: ignore
449
+ _bndry_data_dict |= {
450
+ _bdry_spec_str: (_bdry_spec_dict["sheet_name"], _bdry_data, _bdry_area)
451
+ } # type: ignore
460
452
  _bdry_s1, _bdry_s2 = zip(*_bdry_data, strict=True)
461
453
 
462
454
  _ax1.plot(
@@ -466,36 +458,32 @@ def gen_plot_boundary(
466
458
  color=_plot_line_color,
467
459
  linestyle=_plot_line_style,
468
460
  linewidth=_plot_line_width,
461
+ alpha=_plot_line_alpha,
469
462
  zorder=_zrdr,
470
463
  )
471
464
 
472
465
  print("\t", _bdry_spec_str, f"{_bdry_s2[0]:.1%}")
473
- match _bdry_spec_str:
474
- case "ΔHHI":
475
- _plot_annotator(
476
- _ax1,
477
- f"({_bdry_s1[0]:.1%}, {_bdry_s2[0]:.1%})",
478
- (_bdry_s1[0], _bdry_s2[0]),
479
- (0.005, 0),
480
- "left",
481
- )
482
- case _ if _bdry_spec_str.startswith("SAG") or _bdry_spec_str in (
483
- "CPSWAG Premerger HHI-contribution",
484
- "CPSWAG Max Div Ratio",
485
- ):
486
- _plot_annotator(
487
- _ax1,
488
- f"{_bdry_s2[0]:.1%}",
489
- (_bdry_s1[0], _bdry_s2[0]),
490
- (-0.005, 0),
491
- "right",
492
- )
466
+ if _bdry_spec_str.startswith(("ΔHHI", "OSWAG Min")):
467
+ _plot_annotator(
468
+ _ax1,
469
+ f"({_bdry_s1[1]:.1%}, {_bdry_s2[1]:.1%})",
470
+ (_bdry_s1[1], _bdry_s2[1]),
471
+ (0.005, 0),
472
+ "left",
473
+ )
474
+ elif _bdry_spec_str.startswith("SAG") or _bdry_spec_str in (
475
+ "CPSWAG Premerger HHI-contribution",
476
+ "CPSWAG Max Div Ratio",
477
+ ):
478
+ _plot_annotator(
479
+ _ax1, f"{_bdry_s2[0]:.1%}", (_bdry_s1[0], _bdry_s2[0]), (-0.005, 0), "right"
480
+ )
493
481
 
494
482
  return _bdry_s1, _bdry_s2
495
483
 
496
484
 
497
485
  def _plot_annotator(
498
- _ax: matplotlib.axes.Axes,
486
+ _ax: mpa.Axes,
499
487
  _a_str: str,
500
488
  _data_pt: tuple[float, float],
501
489
  _note_offset: tuple[float, float],
@@ -546,9 +534,9 @@ def boundary_data_to_worksheet(
546
534
  Specified Excel Workbook
547
535
 
548
536
  """
549
- _xl_sheet = _xl_book.add_worksheet(
550
- f"{_bndry_name.replace('Boundary', '').strip()}"[:31]
551
- )
537
+ _sheet_name, _bndry_points, _bndry_area = _bndry_data_dict[_bndry_name]
538
+
539
+ _xl_sheet = _xl_book.add_worksheet(_sheet_name)
552
540
 
553
541
  _xl_sheet.write("A1", "Sound GUPPI Safeharbor")
554
542
  _xl_sheet.write("A2", "Merger Screens for Unilateral Effects")
@@ -574,7 +562,6 @@ def boundary_data_to_worksheet(
574
562
  )
575
563
  _xl_sheet.set_footer(f"&L{_left_footer}")
576
564
 
577
- _bndry_points, _bndry_area = _bndry_data_dict[_bndry_name]
578
565
  xlh.scalar_to_sheet(_xl_book, _xl_sheet, "B7", _bndry_area, xlh.CFmt.AREA_NUM)
579
566
 
580
567
  _results_header_row = 9
@@ -596,7 +583,7 @@ def boundary_data_to_worksheet(
596
583
  _xl_sheet,
597
584
  _bndry_points,
598
585
  _results_top_row,
599
- cell_format=xlh.CFmt.PCT_NUM,
586
+ cell_format=xlh.CFmt.PCT_NUM, # type: ignore
600
587
  )
601
588
 
602
589
  # Draw a bottom border