Skip to content

Commit 3a406b4

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent e2032e0 commit 3a406b4

22 files changed

+291
-277
lines changed

.tools/create_algo_selection_code.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,13 @@ def create_dataclass_code(
285285
fields = "\n".join(field_strings)
286286

287287
# get code for the properties to select children
288-
child_template = textwrap.dedent("""
288+
child_template = textwrap.dedent(
289+
"""
289290
@property
290291
def {new_category}(self) -> {class_name}:
291292
return {class_name}()
292-
""")
293+
"""
294+
)
293295
child_template = textwrap.indent(child_template, " ")
294296
child_strings = []
295297
for new_category, categories in children.items():
@@ -373,7 +375,8 @@ def _get_imports(modules: list[ModuleType]) -> str:
373375

374376
def _get_base_class_code() -> str:
375377
"""Get the source code for the AlgoSelection class."""
376-
out = textwrap.dedent("""
378+
out = textwrap.dedent(
379+
"""
377380
@dataclass(frozen=True)
378381
class AlgoSelection:
379382
@@ -412,7 +415,8 @@ def _all_algorithms_dict(self) -> dict[str, Type[Algorithm]]:
412415
def _available_algorithms_dict(self) -> dict[str, Type[Algorithm]]:
413416
return {str(a.name): a for a in self._available()}
414417
415-
""")
418+
"""
419+
)
416420
return out
417421

418422

@@ -432,14 +436,16 @@ def _get_docstring_code() -> str:
432436

433437
def _get_instantiation_code() -> str:
434438
"""Get the source code for instantiating some classes at the end of the module."""
435-
out = textwrap.dedent("""
439+
out = textwrap.dedent(
440+
"""
436441
algos = Algorithms()
437442
global_algos = GlobalAlgorithms()
438443
439444
ALL_ALGORITHMS = algos._all_algorithms_dict
440445
AVAILABLE_ALGORITHMS = algos._available_algorithms_dict
441446
GLOBAL_ALGORITHMS = global_algos._available_algorithms_dict
442-
""")
447+
"""
448+
)
443449
return out
444450

445451

docs/source/conf.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,18 @@
247247
{
248248
"name": "GitHub",
249249
"url": "https://github.com/optimagic-dev/optimagic",
250-
"html": """
251-
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
252-
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
253-
</svg>
254-
""",
250+
"html": """<svg stroke="currentColor" fill="currentColor" stroke-width="0"
251+
viewBox="0 0 16 16"> <path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58
252+
0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-
253+
1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-
254+
.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87
255+
2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95
256+
0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21
257+
2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82
258+
2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87
259+
3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0
260+
.21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
261+
</svg>""",
255262
"class": "",
256263
},
257264
{

src/estimagic/estimate_ml.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ def estimate_ml(
153153
LikelihoodResult: A LikelihoodResult object.
154154
155155
"""
156-
157156
# ==================================================================================
158157
# handle deprecations
159158
# ==================================================================================

src/estimagic/estimation_table.py

Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,14 @@ def _render_latex(
316316
"""See docstring of render_latex for more information."""
317317
if not pd.__version__ >= "1.4.0":
318318
raise ValueError(
319-
r"""render_latex or estimation_table with return_type="latex" requires
320-
pandas 1.4.0 or higher. Update to a newer version of pandas or use
321-
estimation_table with return_type="render_inputs" and manually render those
322-
results using the DataFrame.to_latex method.
323-
"""
319+
r"""render_latex or estimation_table with return_type="latex" requires pandas
320+
1.4.0 or higher.
321+
322+
Update to a newer version of pandas or use estimation_table with
323+
return_type="render_inputs" and manually render those results using the
324+
DataFrame.to_latex method.
325+
326+
"""
324327
)
325328
if siunitx_warning:
326329
warn(
@@ -458,11 +461,14 @@ def render_html(
458461
"""
459462
if not pd.__version__ >= "1.4.0":
460463
raise ValueError(
461-
r"""render_html or estimation_table with return_type="html" requires
462-
pandas 1.4.0 or higher. Update to a newer version of pandas or use
463-
estimation_table with return_type="render_inputs" and manually render those
464-
results using the DataFrame.to_html method.
465-
"""
464+
r"""render_html or estimation_table with return_type="html" requires pandas
465+
1.4.0 or higher.
466+
467+
Update to a newer version of pandas or use estimation_table with
468+
return_type="render_inputs" and manually render those results using the
469+
DataFrame.to_html method.
470+
471+
"""
466472
)
467473
n_levels = body.index.nlevels
468474
n_columns = len(body.columns)
@@ -484,7 +490,8 @@ def render_html(
484490
html_str = body_styler.to_html(**default_options).split("</tbody>\n</table>")[0]
485491
if show_footer:
486492
stats_str = """<tr><td colspan="{}" style="border-bottom: 1px solid black">
487-
</td></tr>""".format(n_levels + n_columns)
493+
</td></tr>"""\
494+
.format(n_levels + n_columns)
488495
stats_str += (
489496
footer.style.to_html(**default_options)
490497
.split("</thead>\n")[1]
@@ -805,7 +812,6 @@ def _get_cols_to_format(show_inference, confidence_intervals):
805812

806813
def _apply_number_formatting_frames(dfs, columns, number_format, add_trailing_zeros):
807814
"""Apply string formatter to specific columns of a list of DataFrames."""
808-
809815
raw_formatted = [
810816
_apply_number_format(df[columns], number_format, format_integers=False)
811817
for df in dfs
@@ -936,9 +942,13 @@ def _customize_col_groups(default_col_groups, custom_col_groups):
936942
if not default_col_groups:
937943
if not isinstance(custom_col_groups, list):
938944
raise ValueError(
939-
"""With unique model names, multiple models can't be grouped
940-
under common group name. Provide list of unique group names instead,
941-
if you wish to add column level."""
945+
"""With unique model names, multiple models can't be grouped under
946+
common group name.
947+
948+
Provide list of unique group names instead, if you wish to add
949+
column level.
950+
951+
"""
942952
)
943953
col_groups = custom_col_groups
944954
else:
@@ -1279,8 +1289,9 @@ def _generate_notes_latex(
12791289
respectively."""
12801290
)
12811291
for n in custom_notes:
1282-
notes_text += """
1283-
{}\\multicolumn{{{}}}{{r}}\\textit{{{}}}\\\\\n""".format(
1292+
notes_text +=\
1293+
"""{}\\multicolumn{{{}}}{{r}}\\textit{{{}}}\\\\\n."""
1294+
.format(
12841295
amp_n, n_columns, n
12851296
)
12861297
elif isinstance(custom_notes, str):
@@ -1315,11 +1326,13 @@ def _generate_notes_html(
13151326
n_columns = len(df.columns)
13161327
significance_levels = sorted(significance_levels)
13171328
notes_text = """<tr><td colspan="{}" style="border-bottom: 1px solid black">
1318-
</td></tr>""".format(n_columns + n_levels)
1329+
</td></tr>"""\
1330+
.format(n_columns + n_levels)
13191331
if append_notes:
1320-
notes_text += """
1321-
<tr><td style="text-align: left">{}</td><td colspan="{}"
1322-
style="text-align: right">""".format(notes_label, n_columns + n_levels - 1)
1332+
notes_text +=\
1333+
"""<tr><td style="text-align: left">{}</td><td colspan="{}"
1334+
style="text-align: right">"""
1335+
.format(notes_label, n_columns + n_levels - 1)
13231336
for i in range(len(significance_levels) - 1):
13241337
stars = "*" * (len(significance_levels) - i)
13251338
notes_text += f"<sup>{stars}</sup>p&lt;{significance_levels[i]}; "
@@ -1335,19 +1348,21 @@ def _generate_notes_html(
13351348
{not_str_notes} are of types {not_str_notes_types}
13361349
respectively."""
13371350
)
1338-
notes_text += """
1339-
<tr><td></td><td colspan="{}"style="text-align: right">{}</td></tr>
1340-
""".format(n_columns + n_levels - 1, custom_notes[0])
1351+
notes_text +=\
1352+
"""<tr><td></td><td colspan="{}"style="text-align:
1353+
right">{}</td></tr>"""
1354+
.format(n_columns + n_levels - 1, custom_notes[0])
13411355
if len(custom_notes) > 1:
13421356
for i in range(1, len(custom_notes)):
1343-
notes_text += """
1344-
<tr><td></td><td colspan="{}"style="text-align: right">
1345-
{}</td></tr>
1346-
""".format(n_columns + n_levels - 1, custom_notes[i])
1357+
notes_text +=\
1358+
"""<tr><td></td><td colspan="{}"style="text-align:
1359+
right"> {}</td></tr>"""
1360+
.format(n_columns + n_levels - 1, custom_notes[i])
13471361
elif isinstance(custom_notes, str):
1348-
notes_text += """
1349-
<tr><td></td><td colspan="{}"style="text-align: right">{}</td></tr>
1350-
""".format(n_columns + n_levels - 1, custom_notes)
1362+
notes_text +=\
1363+
"""<tr><td></td><td colspan="{}"style="text-align:
1364+
right">{}</td></tr>"""
1365+
.format(n_columns + n_levels - 1, custom_notes)
13511366
else:
13521367
raise TypeError(
13531368
f"""Custom notes can be either a string or a list of strings,

src/optimagic/benchmarking/benchmark_reports.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ def traceback_report(problems, results, return_type="dataframe"):
151151
algorithms for problems where they stopped with an error.
152152
153153
"""
154-
155154
if return_type == "text":
156155
report = []
157156
for result in results.values():

src/optimagic/differentiation/derivatives.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ def second_derivative(
482482
NumdiffResult: A numerical differentiation result.
483483
484484
"""
485-
486485
# ==================================================================================
487486
# handle deprecations
488487
# ==================================================================================

src/optimagic/optimization/internal_optimization_problem.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,6 @@ def _process_jac_value(
872872
The Jacobian value for the algorithm.
873873
874874
"""
875-
876875
out_value = converter.derivative_to_internal(value, x)
877876
if direction == Direction.MAXIMIZE:
878877
out_value = -out_value

src/optimagic/optimization/multistart.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,6 @@ def update_convergence_state(
413413
bool: A bool that indicates if the optimizer has converged.
414414
415415
"""
416-
417416
# ==================================================================================
418417
# unpack some variables
419418
# ==================================================================================

src/optimagic/optimization/optimize.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ def minimize(
430430
multistart_options: Deprecated. Use multistart instead.
431431
432432
"""
433-
434433
problem = create_optimization_problem(
435434
direction=Direction.MINIMIZE,
436435
fun=fun,

src/optimagic/optimizers/bayesian_optimizer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ def _process_acquisition_function(
240240
instance, a class inheriting from AcquisitionFunction, or None.
241241
242242
"""
243-
244243
from bayes_opt import acquisition
245244

246245
acquisition_function_aliases = {

0 commit comments

Comments
 (0)