mergeron 2024.738930.0__py3-none-any.whl → 2024.738936.2__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.

Files changed (30) hide show
  1. mergeron/core/__init__.py +1 -1
  2. mergeron/core/guidelines_standards.py +247 -57
  3. mergeron/core/proportions_tests.py +19 -19
  4. mergeron/core/pseudorandom_numbers.py +30 -29
  5. mergeron/examples/__init__.py +1 -1
  6. mergeron/examples/concentration_as_diversion.py +75 -88
  7. mergeron/examples/investigations_stats_obs_tables.py +119 -111
  8. mergeron/examples/investigations_stats_sim_tables.py +108 -87
  9. mergeron/examples/plotSafeHarbs_symbolically.py +2 -2
  10. mergeron/examples/safeharbor_boundaries_for_mergers_with_asymmetric_shares.py +35 -28
  11. mergeron/examples/safeharbor_boundaries_for_symmetric_firm_mergers.py +6 -13
  12. mergeron/examples/sound_guppi_safeharbor.py +23 -18
  13. mergeron/examples/testIntrinsicClearanceRates.py +5 -5
  14. mergeron/examples/visualize_empirical_margin_distribution.py +1 -1
  15. mergeron/examples/{visualize_guidelines_tests_scatterplots.py → visualize_guidelines_tests.py} +42 -48
  16. mergeron/ext/__init__.py +1 -1
  17. mergeron/gen/__init__.py +1 -1
  18. mergeron/gen/data_generation.py +25 -24
  19. mergeron/gen/guidelines_tests.py +47 -47
  20. mergeron/gen/investigations_stats.py +98 -46
  21. mergeron/jinja_LaTex_templates/clrrate_cis_summary_table_template.tex.jinja2 +2 -3
  22. mergeron/jinja_LaTex_templates/ftcinvdata_byhhianddelta_table_template.tex.jinja2 +2 -3
  23. mergeron/jinja_LaTex_templates/ftcinvdata_summary_table_template.tex.jinja2 +1 -2
  24. mergeron/jinja_LaTex_templates/ftcinvdata_summarypaired_table_template.tex.jinja2 +13 -14
  25. mergeron/jinja_LaTex_templates/mergeron.cls +161 -0
  26. mergeron/jinja_LaTex_templates/mergeron_table_collection_template.tex.jinja2 +90 -0
  27. {mergeron-2024.738930.0.dist-info → mergeron-2024.738936.2.dist-info}/METADATA +15 -18
  28. mergeron-2024.738936.2.dist-info/RECORD +41 -0
  29. mergeron-2024.738930.0.dist-info/RECORD +0 -39
  30. {mergeron-2024.738930.0.dist-info → mergeron-2024.738936.2.dist-info}/WHEEL +0 -0
@@ -11,7 +11,7 @@ from collections.abc import Mapping, Sequence
11
11
  from datetime import datetime, timedelta
12
12
  from io import TextIOWrapper
13
13
  from pathlib import Path
14
- from typing import Any, Literal
14
+ from typing import Any
15
15
 
16
16
  import numpy as np
17
17
  import re2 as re # type: ignore
@@ -19,6 +19,7 @@ import tables as ptb # type: ignore
19
19
  from attrs import evolve
20
20
 
21
21
  import mergeron.core.ftc_merger_investigations_data as fid
22
+ import mergeron.core.guidelines_standards as gsf
22
23
  import mergeron.gen.data_generation as dgl
23
24
  import mergeron.gen.guidelines_tests as gtl
24
25
  import mergeron.gen.investigations_stats as isl
@@ -29,25 +30,25 @@ from mergeron.core.proportions_tests import propn_ci
29
30
  if not sys.warnoptions:
30
31
  warnings.simplefilter("ignore") # , category="RuntimeWarning")
31
32
 
32
- dottex_format_str = "BenchmarkingGUPPISafeharbor_DRAFT_FTC{}RateCITables_{}_{}_SYM.tex"
33
+ dottex_format_str = "FTC{}RateCITables_{}_{}_SYM.tex"
33
34
  stats_table_content = isl.StatsContainer()
34
35
  stats_table_design = isl.latex_jinja_env.get_template(
35
36
  "clrrate_cis_summary_table_template.tex.jinja2"
36
37
  )
37
38
 
38
39
 
39
- def inv_stats_sim_setup(
40
+ def invres_stats_sim_setup(
40
41
  _invdata: fid.INVData,
41
42
  _data_period: str,
42
43
  _merger_class: isl.INDGRPConstants | isl.EVIDENConstants,
43
- _inv_parm_vec: Sequence[float],
44
+ _invres_parm_vec: gsf.GuidelinesSTD,
44
45
  _sample_spec: dgl.MarketSampleSpec,
45
- _inv_stats_kwargs: Mapping[str, Any] | None = None,
46
+ _invres_stats_kwargs: Mapping[str, Any] | None = None,
46
47
  /,
47
- ) -> None:
48
+ ) -> str:
48
49
  _table_ind_group = (
49
50
  _merger_class
50
- if _merger_class == isl.INDGRPConstants.IIC
51
+ if isinstance(_merger_class, isl.INDGRPConstants)
51
52
  else isl.INDGRPConstants.ALL
52
53
  )
53
54
  _table_evid_cond = (
@@ -56,18 +57,25 @@ def inv_stats_sim_setup(
56
57
  else isl.EVIDENConstants.UR
57
58
  )
58
59
 
59
- _inv_stats_kwargs = _inv_stats_kwargs or {"sim_inv_sel": isl.PolicySelector.ENFT}
60
- _sim_inv_sel = _inv_stats_kwargs["sim_inv_sel"]
61
- _inv_sel, _guppi_wgtng_policy, _divr_wgtng_policy = _sim_inv_sel
60
+ _invres_stats_kwargs = _invres_stats_kwargs or {
61
+ "sim_test_regime": isl.PolicySelector.ENFT
62
+ }
63
+ _sim_test_regime = _invres_stats_kwargs["sim_test_regime"]
64
+ _test_regime, _guppi_wgtng_policy, _divr_wgtng_policy = _sim_test_regime
62
65
 
63
66
  # Get observed rates
64
67
  (
65
- _inv_cnts_obs_byfirmcount_array,
66
- _inv_cnts_obs_bydelta_array,
67
- _inv_cnts_obs_byconczone_array,
68
+ _invres_cnts_obs_byfirmcount_array,
69
+ _invres_cnts_obs_bydelta_array,
70
+ _invres_cnts_obs_byconczone_array,
68
71
  ) = (
69
- isl.inv_stats_cnts_by_group(
70
- _invdata, _data_period, _table_ind_group, _table_evid_cond, _grp, _inv_sel
72
+ isl.invres_stats_cnts_by_group(
73
+ _invdata,
74
+ _data_period,
75
+ _table_ind_group,
76
+ _table_evid_cond,
77
+ _grp,
78
+ _test_regime,
71
79
  )
72
80
  for _grp in (
73
81
  isl.StatsGrpSelector.FC,
@@ -82,17 +90,19 @@ def inv_stats_sim_setup(
82
90
  dgl.RECConstants.INOUT,
83
91
  dgl.SHRConstants.DIR_FLAT,
84
92
  None,
85
- _inv_cnts_obs_byfirmcount_array[:-1, 1],
93
+ _invres_cnts_obs_byfirmcount_array[:-1, 1],
86
94
  ),
87
95
  )
88
96
 
89
97
  # Generate simulated rates
90
98
  _start_time = datetime.now()
91
99
  (
92
- _inv_cnts_sim_byfirmcount_array,
93
- _inv_cnts_sim_bydelta_array,
94
- _inv_cnts_sim_byconczone_array,
95
- ) = gtl.sim_inv_cnts_ll(_inv_parm_vec, _sample_spec_here, _inv_stats_kwargs)
100
+ _invres_cnts_sim_byfirmcount_array,
101
+ _invres_cnts_sim_bydelta_array,
102
+ _invres_cnts_sim_byconczone_array,
103
+ ) = gtl.sim_invres_cnts_ll(
104
+ _invres_parm_vec, _sample_spec_here, _invres_stats_kwargs
105
+ )
96
106
  _total_duration = datetime.now() - _start_time
97
107
 
98
108
  print(
@@ -102,16 +112,16 @@ def inv_stats_sim_setup(
102
112
  # Prepare and write/print output tables
103
113
  _stats_group_dict = {
104
114
  isl.StatsGrpSelector.FC: {
105
- "desc": f"{_inv_sel.capitalize()} rates by firm count",
115
+ "desc": f"{_test_regime.capitalize()} rates by firm count",
106
116
  "title_str": "By Number of Significant Competitors",
107
117
  "hval": "Firm Count",
108
118
  "hcol_width": 54,
109
119
  "notewidth": 0.63,
110
- "obs_array": _inv_cnts_obs_byfirmcount_array,
111
- "sim_array": _inv_cnts_sim_byfirmcount_array,
120
+ "obs_array": _invres_cnts_obs_byfirmcount_array,
121
+ "sim_array": _invres_cnts_sim_byfirmcount_array,
112
122
  },
113
123
  isl.StatsGrpSelector.DL: {
114
- "desc": Rf"{_inv_sel.capitalize()} rates by range of $\Delta HHI$",
124
+ "desc": Rf"{_test_regime.capitalize()} rates by range of $\Delta HHI$",
115
125
  "title_str": R"By Change in Concentration (\Deltah{})",
116
126
  "hval": R"$\Delta HHI$",
117
127
  "hval_plus": R"{ $[\Delta_L, \Delta_H)$ }",
@@ -126,11 +136,11 @@ def inv_stats_sim_setup(
126
136
  isl.LTX_ARRAY_LINEEND,
127
137
  isl.LTX_ARRAY_LINEEND,
128
138
  )),
129
- "obs_array": _inv_cnts_obs_bydelta_array,
130
- "sim_array": _inv_cnts_sim_bydelta_array,
139
+ "obs_array": _invres_cnts_obs_bydelta_array,
140
+ "sim_array": _invres_cnts_sim_bydelta_array,
131
141
  },
132
142
  isl.StatsGrpSelector.ZN: {
133
- "desc": f"{_inv_sel.capitalize()} rates by Approximate Presumption Zone",
143
+ "desc": f"{_test_regime.capitalize()} rates by Approximate Presumption Zone",
134
144
  "title_str": "{} {}".format(
135
145
  R"By Approximate \textit{2010 Guidelines}",
136
146
  "Concentration-Based Standards",
@@ -138,39 +148,41 @@ def inv_stats_sim_setup(
138
148
  "hval": "Approximate Standard",
139
149
  "hcol_width": 190,
140
150
  "notewidth": 0.96,
141
- "obs_array": _inv_cnts_obs_byconczone_array,
142
- "sim_array": _inv_cnts_sim_byconczone_array,
151
+ "obs_array": _invres_cnts_obs_byconczone_array,
152
+ "sim_array": _invres_cnts_sim_byconczone_array,
143
153
  },
144
154
  }
145
155
 
146
- with (
147
- DATA_DIR
148
- / dottex_format_str.format(
149
- _inv_sel.capitalize(),
150
- _merger_class.replace(" ", ""),
151
- _data_period.split("-")[1],
152
- )
153
- ).open("w", encoding="UTF-8") as _stats_table_dottex:
156
+ _stats_table_name = dottex_format_str.format(
157
+ _test_regime.capitalize(),
158
+ _merger_class.replace(" ", ""),
159
+ _data_period.split("-")[1],
160
+ )
161
+ with (DATA_DIR / _stats_table_name).open(
162
+ "w", encoding="UTF-8"
163
+ ) as _stats_table_file:
154
164
  for _stats_group_key in _stats_group_dict:
155
- inv_stats_sim_render(
165
+ invres_stats_sim_render(
156
166
  _data_period,
157
167
  _merger_class,
158
168
  _stats_group_key,
159
169
  _stats_group_dict[_stats_group_key],
160
- _inv_parm_vec,
161
- _inv_stats_kwargs["sim_inv_sel"],
162
- _stats_table_dottex,
170
+ _invres_parm_vec,
171
+ _invres_stats_kwargs["sim_test_regime"],
172
+ _stats_table_file,
163
173
  )
164
174
 
175
+ return _stats_table_name
176
+
165
177
 
166
- def inv_stats_sim_render(
178
+ def invres_stats_sim_render(
167
179
  _data_period: str,
168
180
  _merger_class: isl.INDGRPConstants | isl.EVIDENConstants,
169
181
  _stats_group: isl.StatsGrpSelector,
170
182
  _stats_group_dict_sub: Mapping[str, Any],
171
- _inv_parm_vec: Sequence[float],
172
- _sim_inv_sel: gtl.UPPTestSpec,
173
- _stats_table_dottex: TextIOWrapper,
183
+ _invres_parm_vec: gsf.GuidelinesSTD,
184
+ _sim_test_regime: gtl.UPPTestRegime,
185
+ _stats_table_file: TextIOWrapper,
174
186
  /,
175
187
  ) -> None:
176
188
  _stats_table_content = isl.StatsContainer()
@@ -180,21 +192,21 @@ def inv_stats_sim_render(
180
192
  for _g, _h in (("obs_array", -2), ("sim_array", -5))
181
193
  )
182
194
 
183
- _inv_sel, _, _ = _sim_inv_sel
195
+ _invres_select, _, _ = _sim_test_regime
184
196
  (
185
- _stats_table_content.clrenf_sel,
197
+ _stats_table_content.test_regime,
186
198
  _stats_table_content.obs_merger_class,
187
199
  _stats_table_content.obs_period,
188
- ) = (_inv_sel.capitalize(), _merger_class, _data_period.split("-"))
200
+ ) = (_invres_select.capitalize(), _merger_class, _data_period.split("-"))
189
201
 
190
- _r_bar, _d_bar, _g_bar, _cmcr_bar, _ipr_bar = _inv_parm_vec
202
+ _r_bar = _invres_parm_vec.rec
191
203
  (
192
204
  _stats_table_content.rbar,
193
- _stats_table_content.dbar,
194
205
  _stats_table_content.guppi_bound,
195
- _stats_table_content.ipr_bound,
206
+ _stats_table_content.dbar,
196
207
  _stats_table_content.cmcr_bound,
197
- ) = (rf"{_s * 100:.1f}\%" for _s in _inv_parm_vec)
208
+ _stats_table_content.ipr_bound,
209
+ ) = (rf"{_s * 100:.1f}\%" for _s in _invres_parm_vec[1:])
198
210
 
199
211
  # Prepare and write/print output tables
200
212
  _stats_cis_wilson_notestr = " ".join((
@@ -202,7 +214,7 @@ def inv_stats_sim_render(
202
214
  R"estimated by the Wilson method, given the",
203
215
  "reported numbers of investigated mergers and cleared mergers",
204
216
  _stats_group_dict_sub["desc"].replace(
205
- f"{_stats_table_content.clrenf_sel} rates ", ""
217
+ f"{_stats_table_content.test_regime} rates ", ""
206
218
  ),
207
219
  isl.LTX_ARRAY_LINEEND,
208
220
  ))
@@ -212,7 +224,7 @@ def inv_stats_sim_render(
212
224
  propn_ci(0.50 * _eg_count, _eg_count, method="Exact")
213
225
  )
214
226
  _stats_sim_notestr = " ".join((
215
- Rf"\(\cdot\) Simulated {_stats_table_content.clrenf_sel} rates are estimated by",
227
+ Rf"\(\cdot\) Simulated {_stats_table_content.test_regime} rates are estimated by",
216
228
  "Monte Carlo integration over generated data representing",
217
229
  Rf"{_sim_sample_sz:,d} hypothetical mergers. Thus,",
218
230
  R"for a subset of simulations with a relative frequency",
@@ -231,8 +243,8 @@ def inv_stats_sim_render(
231
243
  del _relfreq_eg, _eg_count, _stats_sim_ci_eg
232
244
 
233
245
  print(
234
- f"Observed {_inv_sel} proportion [95% CI]",
235
- _stats_group_dict_sub["desc"].replace(f"{_inv_sel} rates ", ""),
246
+ f"Observed {_invres_select} proportion [95% CI]",
247
+ _stats_group_dict_sub["desc"].replace(f"{_invres_select} rates ", ""),
236
248
  )
237
249
  print(f"\t with sample size (observed): {_obs_sample_sz:,d};")
238
250
 
@@ -241,7 +253,7 @@ def inv_stats_sim_render(
241
253
  _stats_table_content.stats_cis_notewidth = _stats_group_dict_sub["notewidth"]
242
254
  _stats_cis_numobs_notestr = " ".join((
243
255
  R"\(\cdot\) Estimates for Proportion {} are based on".format(
244
- "Enforced" if _inv_sel == isl.PolicySelector.ENFT else "Cleared"
256
+ "Enforced" if _invres_select == isl.PolicySelector.ENFT else "Cleared"
245
257
  ),
246
258
  f"{_obs_sample_sz:,d} total observations (investigated mergers).",
247
259
  ))
@@ -260,10 +272,10 @@ def inv_stats_sim_render(
260
272
  _stats_table_content.stats_cis_notestr += "".join((isl.LTX_ARRAY_LINEEND, _nsp))
261
273
  del _nsp
262
274
 
263
- _inv_stats_report_func = (
264
- isl.latex_tbl_inv_stats_byzone
275
+ _invres_stats_report_func = (
276
+ isl.latex_tbl_invres_stats_byzone
265
277
  if _stats_group == isl.StatsGrpSelector.ZN
266
- else isl.latex_tbl_inv_stats_1dim
278
+ else isl.latex_tbl_invres_stats_1dim
267
279
  )
268
280
  _sort_order = (
269
281
  isl.SortSelector.UCH
@@ -271,15 +283,16 @@ def inv_stats_sim_render(
271
283
  else isl.SortSelector.REV
272
284
  )
273
285
 
274
- _inv_stats_hdr_list, _inv_stats_dat_list = _inv_stats_report_func(
286
+ _invres_stats_hdr_list, _invres_stats_dat_list = _invres_stats_report_func(
275
287
  _stats_group_dict_sub["obs_array"],
276
288
  return_type_sel=isl.StatsReturnSelector.RIN,
277
289
  sort_order=_sort_order,
278
290
  )
291
+
279
292
  if _stats_group == isl.StatsGrpSelector.FC:
280
- del _inv_stats_hdr_list[-2], _inv_stats_dat_list[-2]
293
+ del _invres_stats_hdr_list[-2], _invres_stats_dat_list[-2]
281
294
 
282
- _stats_table_content.stats_numrows = len(_inv_stats_hdr_list)
295
+ _stats_table_content.stats_numrows = len(_invres_stats_hdr_list)
283
296
  _stats_table_content.hdrcol_cis_width = f'{_stats_group_dict_sub["hcol_width"]}pt'
284
297
 
285
298
  _hs1 = _stats_group_dict_sub["hval"]
@@ -299,23 +312,26 @@ def inv_stats_sim_render(
299
312
  del _hs1, _hs2
300
313
 
301
314
  _stats_table_content.stats_hdrstr = "".join([
302
- f"{g} {isl.LTX_ARRAY_LINEEND}" for g in _inv_stats_hdr_list
315
+ f"{g} {isl.LTX_ARRAY_LINEEND}" for g in _invres_stats_hdr_list
303
316
  ])
304
317
  _stats_table_content.stats_cis = "".join([
305
- f"{' & '.join(g)} {isl.LTX_ARRAY_LINEEND}" for g in _inv_stats_dat_list
318
+ f"{' & '.join(g)} {isl.LTX_ARRAY_LINEEND}" for g in _invres_stats_dat_list
306
319
  ])
307
320
  # Print to console
308
- isl.stats_print_rows(_inv_stats_hdr_list, _inv_stats_dat_list)
309
- del _inv_stats_hdr_list, _inv_stats_dat_list
321
+ isl.stats_print_rows(_invres_stats_hdr_list, _invres_stats_dat_list)
322
+ del _invres_stats_hdr_list, _invres_stats_dat_list
310
323
 
311
- print(f"Simulated {_inv_sel} rates {_stats_group}:")
324
+ print(f"Simulated {_invres_select} rates {_stats_group}:")
312
325
  print(f"\t with generated data size = {_sim_sample_sz:,d}:")
313
326
 
314
- _stats_sim_hdr_list, _stats_sim_dat_list = _inv_stats_report_func(
327
+ _stats_sim_hdr_list, _stats_sim_dat_list = _invres_stats_report_func(
315
328
  _stats_group_dict_sub["sim_array"],
316
329
  return_type_sel=isl.StatsReturnSelector.RPT,
317
330
  sort_order=_sort_order,
318
331
  )
332
+
333
+ # Exclude results of IPR tests
334
+ _stats_sim_dat_list = [_f[:-1] for _f in _stats_sim_dat_list]
319
335
  _stats_table_content.stats_sim = "".join([
320
336
  f"{' & '.join(g)} {isl.LTX_ARRAY_LINEEND}" for g in _stats_sim_dat_list
321
337
  ])
@@ -328,10 +344,8 @@ def inv_stats_sim_render(
328
344
  "clrrate_cis_summary_table_template.tex.jinja2"
329
345
  )
330
346
  # Write to dottex
331
- _stats_table_dottex.write(
332
- _stats_table_design.render(tmpl_data=_stats_table_content)
333
- )
334
- print("\n", file=_stats_table_dottex)
347
+ _stats_table_file.write(_stats_table_design.render(tmpl_data=_stats_table_content))
348
+ print("\n", file=_stats_table_file)
335
349
 
336
350
 
337
351
  if __name__ == "__main__":
@@ -352,9 +366,9 @@ if __name__ == "__main__":
352
366
  pcm_dist_type, pcm_dist_parms = dgl.PCMConstants.EMPR, np.empty(2)
353
367
 
354
368
  save_data_to_file_flag = False
355
- save_data_to_file: Literal[False] | tuple[Literal[True], ptb.File, str] = False
369
+ save_data_to_file: gtl.SaveData = False
356
370
  if save_data_to_file_flag:
357
- h5path = DATA_DIR.joinpath(f"{Path(__file__).stem}.h5")
371
+ h5path = DATA_DIR / Path(__file__).with_suffix(".h5").name
358
372
  blosc_filters = ptb.Filters(complevel=3, complib="blosc:lz4", fletcher32=True)
359
373
  h5datafile = ptb.open_file(
360
374
  str(h5path),
@@ -364,33 +378,34 @@ if __name__ == "__main__":
364
378
  )
365
379
  save_data_to_file = (True, h5datafile, "/")
366
380
 
367
- sim_inv_sel = (
381
+ sim_test_regime = (
368
382
  (isl.PolicySelector.CLRN, gtl.GUPPIWghtngSelector.MAX, None),
369
383
  (isl.PolicySelector.ENFT, gtl.GUPPIWghtngSelector.OSD, None),
370
384
  )[1]
371
- inv_stats_kwargs = {"sim_inv_sel": sim_inv_sel}
385
+ invres_stats_kwargs = {"sim_test_regime": sim_test_regime}
372
386
 
387
+ table_dottex_namelist = ()
373
388
  for merger_class in merger_classes:
374
389
  for study_period in data_periods:
375
390
  if study_period == data_periods[1]:
376
391
  continue
377
392
 
378
393
  print(
379
- f"{sim_inv_sel[0].capitalize()} rates and c.i.s",
394
+ f"{sim_test_regime[0].capitalize()} rates and c.i.s",
380
395
  f"for the class of mergers, '{merger_class}',",
381
396
  f"for study period, {study_period}:",
382
397
  )
383
398
  stats_table_content.obs_period = study_period.split("-")
384
399
 
385
- clrenf_parm_vec = (
386
- GuidelinesStandards(2010).presumption[2:]
400
+ invres_parm_vec = (
401
+ GuidelinesStandards(2010).presumption
387
402
  if study_period.split("-")[1] == data_periods[1].split("-")[1]
388
- else GuidelinesStandards(1992).presumption[2:]
403
+ else GuidelinesStandards(1992).presumption
389
404
  )
390
405
 
391
406
  mkt_sample_spec = dgl.MarketSampleSpec(
392
407
  sample_sz_base,
393
- clrenf_parm_vec[0],
408
+ invres_parm_vec.rec,
394
409
  pr_sym_spec,
395
410
  pcm_spec=dgl.PCMSpec(
396
411
  pcm_dist_type, dgl.FM2Constants.MNL, pcm_dist_parms
@@ -402,16 +417,22 @@ if __name__ == "__main__":
402
417
  if save_data_to_file:
403
418
  h5hier_pat = re.compile(r"\W")
404
419
  h5hier = f"/{h5hier_pat.sub('_', f'{merger_class} {study_period}')}"
405
- save_data_to_file = save_data_to_file[:-1] + (h5hier,)
420
+ save_data_to_file = (True, save_data_to_file[1], h5hier)
406
421
 
407
- inv_stats_sim_setup(
422
+ table_dottex_name = invres_stats_sim_setup(
408
423
  invdata_array_dict,
409
424
  study_period,
410
425
  merger_class,
411
- clrenf_parm_vec,
426
+ invres_parm_vec,
412
427
  mkt_sample_spec,
413
- inv_stats_kwargs,
428
+ invres_stats_kwargs,
414
429
  )
430
+ table_dottex_namelist += (table_dottex_name,)
431
+
432
+ isl.render_table_pdf(
433
+ table_dottex_namelist,
434
+ dottex_format_str.format(f"{sim_test_regime[0]}".capitalize(), "All", "All"),
435
+ )
415
436
 
416
437
  if save_data_to_file:
417
- h5datafile.close()
438
+ save_data_to_file[1].close()
@@ -1,7 +1,7 @@
1
1
  """
2
2
 
3
- Solve for, and plot, weighted-average GUPPI boundaries using sympy,
4
- as a check against the numerical solutions in mergeron.core.guidelines_standards
3
+ Solve for, and plot, weighted-average GUPPI boundaries using sympy,
4
+ as a check against the numerical solutions in mergeron.core.guidelines_standards
5
5
 
6
6
  """
7
7
 
@@ -1,6 +1,6 @@
1
1
  """
2
2
 
3
- Draw boundaries for various standards from 1992 and 2010 Guidelines.
3
+ Draw boundaries for various standards from U.S. Horizontal Merger Guidelines.
4
4
  """
5
5
 
6
6
  from itertools import product as iterprod
@@ -9,6 +9,7 @@ from typing import Literal
9
9
 
10
10
  import matplotlib.axis
11
11
  from matplotlib import cm as colormgr
12
+ from matplotlib import colormaps
12
13
  from matplotlib import colors as mcolors
13
14
  from matplotlib.ticker import StrMethodFormatter
14
15
  from numpy import (
@@ -24,9 +25,9 @@ from numpy import (
24
25
  )
25
26
 
26
27
  import mergeron.core.guidelines_standards as gsf
28
+ from mergeron import DATA_DIR
27
29
 
28
- mod_path = Path(__file__)
29
- data_path = Path.home() / mod_path.parents[1].stem
30
+ PROG_PATH = Path(__file__)
30
31
 
31
32
 
32
33
  def plot_delta_boundaries(
@@ -39,9 +40,9 @@ def plot_delta_boundaries(
39
40
  raise ValueError(f"Recapture specification must be one of, {_recspecs!r}")
40
41
 
41
42
  print("ΔHHI safeharbor boundary")
42
- _plt, _my_fig1, _ax1, _set_axis_def = gsf.boundary_plot()
43
+ _plt, _my_fig1, _ax1, _ = gsf.boundary_plot()
43
44
 
44
- _dh_bar, _f_count_post, _r_bar, _guppi_bench, _divr_bench = get_hmg_standards_plus(
45
+ _dh_bar, _r_bar, _guppi_bench, _divr_bench, _, _ = get_hmg_standards_by_key(
45
46
  _guppi_bench_key
46
47
  )
47
48
 
@@ -97,7 +98,7 @@ def plot_delta_boundaries(
97
98
  _guppi_bdry_env_xs[::-1],
98
99
  linewidth=0.5,
99
100
  linestyle="--",
100
- color=colormgr.cividis(_m_star),
101
+ color=colormaps["cividis"](_m_star),
101
102
  zorder=3,
102
103
  )
103
104
  del _symshr, _dstar, _m_star, _guppi_bdry_env_xs
@@ -124,12 +125,16 @@ def plot_delta_boundaries(
124
125
  alpha=0.7,
125
126
  rasterized=True,
126
127
  )
128
+ del (
129
+ _dh_safeharb,
130
+ _dh_prob,
131
+ _dh_dat_x,
132
+ _dh_dat_y,
133
+ ) # , _dh_dat_x_pla, _dh_dat_y_pla
127
134
 
128
- _my_fig1.savefig(
129
- data_path.joinpath(f"{mod_path.stem}_DH100_deltaHHI_only.pdf"), dpi=600
130
- )
131
- del _plt, _my_fig1, _ax1, _set_axis_def, _dh_safeharb, _dh_prob
132
- del _dh_dat_x, _dh_dat_y # , _dh_dat_x_pla, _dh_dat_y_pla
135
+ _my_fig1.savefig((DATA_DIR / f"{PROG_PATH.stem}_DH100_deltaHHI_only.pdf"), dpi=600)
136
+
137
+ del _plt, _my_fig1, _ax1
133
138
 
134
139
 
135
140
  def plot_guppi_boundaries( # noqa PLR0915
@@ -140,7 +145,7 @@ def plot_guppi_boundaries( # noqa PLR0915
140
145
  if recapture_spec not in (_recspecs := ("inside-out", "proportional")):
141
146
  raise ValueError(f"Recapture specification must be one of, {_recspecs!r}")
142
147
 
143
- _dh_bar, _f_count_post, _r_bar, _guppi_bench, _divr_bench = get_hmg_standards_plus(
148
+ _dh_bar, _r_bar, _guppi_bench, _divr_bench, _, _ = get_hmg_standards_by_key(
144
149
  _guppi_bench_key
145
150
  )
146
151
 
@@ -163,7 +168,7 @@ def plot_guppi_boundaries( # noqa PLR0915
163
168
  wspace=0.0,
164
169
  )
165
170
  _ax1 = _my_fig1.add_subplot(_fig1_grid[0, 0])
166
- _ax1 = _set_axis_def(_plt, _ax1)
171
+ _ax1 = _set_axis_def(_ax1)
167
172
  _ax1.set_aspect(1.0)
168
173
  _ax1.set_facecolor("#F6F6F6")
169
174
 
@@ -211,7 +216,7 @@ def plot_guppi_boundaries( # noqa PLR0915
211
216
  _s2_vals,
212
217
  linestyle="--",
213
218
  linewidth=0.75,
214
- color=colormgr.cividis(_m_star),
219
+ color=colormaps["cividis"](_m_star),
215
220
  zorder=3,
216
221
  )
217
222
  else:
@@ -232,7 +237,7 @@ def plot_guppi_boundaries( # noqa PLR0915
232
237
  _s2_vals,
233
238
  linestyle="--",
234
239
  linewidth=0.5,
235
- color=colormgr.cividis(_m_star),
240
+ color=colormaps["cividis"](_m_star),
236
241
  zorder=3,
237
242
  )
238
243
  # Print inner boundary, color-coded m_1
@@ -241,7 +246,7 @@ def plot_guppi_boundaries( # noqa PLR0915
241
246
  _s1_vals[::-1],
242
247
  linestyle="--",
243
248
  linewidth=0.5,
244
- color=colormgr.cividis(_m_star),
249
+ color=colormaps["cividis"](_m_star),
245
250
  zorder=3,
246
251
  )
247
252
 
@@ -286,7 +291,6 @@ def plot_guppi_boundaries( # noqa PLR0915
286
291
  fontsize=4,
287
292
  zorder=5.1,
288
293
  )
289
- del _m_star
290
294
 
291
295
  # Examples of hypothetical combinations
292
296
  if not _pcm_same_flag:
@@ -328,7 +332,7 @@ def plot_guppi_boundaries( # noqa PLR0915
328
332
  _y_drt,
329
333
  linestyle="-",
330
334
  linewidth=0.75,
331
- color=colormgr.cividis(_m_star_bench),
335
+ color=colormaps["cividis"](_m_star_bench),
332
336
  zorder=4,
333
337
  )
334
338
 
@@ -377,7 +381,7 @@ def plot_guppi_boundaries( # noqa PLR0915
377
381
  xerr=_ebar_array,
378
382
  yerr=_ebar_array,
379
383
  fmt=".",
380
- mfc=colormgr.cividis(_guppi_bench / _r_bar),
384
+ mfc=colormaps["cividis"](_guppi_bench / _r_bar),
381
385
  mec="None",
382
386
  alpha=0.9,
383
387
  zorder=5,
@@ -386,7 +390,7 @@ def plot_guppi_boundaries( # noqa PLR0915
386
390
  # https://stackoverflow.com/questions/22995797/
387
391
  for _ix in range(2):
388
392
  _ebar_plot[-1][_ix].set(
389
- color=colormgr.cividis(_guppi_bench / _r_bar),
393
+ color=colormaps["cividis"](_guppi_bench / _r_bar),
390
394
  linestyle="--",
391
395
  linewidth=0.5,
392
396
  alpha=0.9,
@@ -421,12 +425,12 @@ def plot_guppi_boundaries( # noqa PLR0915
421
425
  _cm_plot.outline.set_visible(False)
422
426
 
423
427
  _fig1_savename = "_".join((
424
- f"{mod_path.stem}",
428
+ f"{PROG_PATH.stem}",
425
429
  f"pcmSame{_pcm_same_flag}",
426
430
  f"{_guppi_bench_key}",
427
431
  f"rbar{_recapture_spec.upper()}",
428
432
  ))
429
- _my_fig1.savefig(data_path.joinpath(f"{_fig1_savename}.pdf"), dpi=600)
433
+ _my_fig1.savefig((DATA_DIR / f"{_fig1_savename}.pdf"), dpi=600)
430
434
  del _my_fig1, _ax1, _ebar_plot, _fig1_savename
431
435
  del _dh_dat_x, _dh_dat_y
432
436
 
@@ -437,23 +441,26 @@ def grad_est(_ax: matplotlib.axis.Axis, _pt_xs: tuple, _pt_ys: tuple) -> float:
437
441
  "Expecting only 2 points for calculation of line-gradient; got {_pt_len}."
438
442
  )
439
443
  _pt1, _pt2 = (
440
- _ax.transData.transform_point((_pt_xs[_i], _pt_ys[_i])) for _i in range(2)
444
+ _ax.transData.transform_point((_pt_xs[_i], _pt_ys[_i])) # type: ignore
445
+ for _i in range(2)
441
446
  )
442
447
  return (_pt2[1] - _pt1[1]) / (_pt2[0] - _pt1[0])
443
448
 
444
449
 
445
- def get_hmg_standards_plus(_guppi_bench_key: str, /) -> tuple:
450
+ def get_hmg_standards_by_key(_guppi_bench_key: str, /) -> tuple:
446
451
  match _guppi_bench_key:
447
452
  case "DOJATR":
448
453
  return (
449
- *(_tmp := gsf.GuidelinesStandards(2010).safeharbor[:3]),
450
- _tmp[-1],
454
+ *(_tmp := gsf.GuidelinesStandards(2010).safeharbor[:2]),
451
455
  0.05,
456
+ _tmp[-1],
457
+ None,
458
+ None,
452
459
  )
453
460
  case "DH100":
454
- return gsf.GuidelinesStandards(2010).safeharbor[:-2]
461
+ return gsf.GuidelinesStandards(2010).safeharbor
455
462
  case "DH50":
456
- return gsf.GuidelinesStandards(1992).safeharbor[:-2]
463
+ return gsf.GuidelinesStandards(1992).safeharbor
457
464
  case _:
458
465
  raise ValueError(
459
466
  f"GUPPI benchmark key must be one of, {guppi_benchmark_keys!r}"