-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathconf.py
633 lines (519 loc) · 24.6 KB
/
conf.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
"""Configuration file for the Sphinx documentation builder."""
import os
import sys
from pathlib import Path
import aeon
# -- Project information -----------------------------------------------------
project = "aeon"
copyright = "The aeon developers (BSD-3 License)"
author = "aeon developers"
version = aeon.__version__
release = aeon.__version__
github_tag = f"v{version}"
# -- Path setup --------------------------------------------------------------
sys.path.append(str(Path(__file__).parent / "_sphinxext"))
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here.
on_readthedocs = os.environ.get("READTHEDOCS") == "True"
if not on_readthedocs:
sys.path.insert(0, os.path.abspath(""))
else:
rtd_version = os.environ.get("READTHEDOCS_VERSION")
if rtd_version == "latest":
github_tag = "main"
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autosectionlabel",
"sphinx.ext.intersphinx",
"sphinx.ext.linkcode", # link to GitHub source code via linkcode_resolve()
"sphinxext.opengraph",
"numpydoc",
"nbsphinx", # integrates example notebooks
"sphinx_design",
"sphinx_issues",
"sphinx_copybutton",
"versionwarning.extension",
"myst_parser",
# local extensions
"sphinx_remove_toctrees",
]
# Notebook thumbnails
nbsphinx_thumbnails = {
"examples/02_classification": "examples/img/tsc.png",
}
# Use bootstrap CSS from theme.
panels_add_bootstrap_css = False
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
source_suffix = {
".rst": "restructuredtext",
".md": "markdown",
}
# The main toctree document.
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = "en"
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [
"_build",
".ipynb_checkpoints",
"Thumbs.db",
".DS_Store",
]
add_module_names = False
# see http://stackoverflow.com/q/12206334/562769
numpydoc_show_class_members = True
# this is needed for some reason...
# see https://github.com/numpy/numpydoc/issues/69
numpydoc_class_members_toctree = False
numpydoc_validation_checks = {
"all",
"GL01", # docstring starts after opening quotes
"ES01", # no extended summary
"SA01", # no see also section
"EX01", # no examples
}
# generate autosummary even if no references
autosummary_generate = True
# Members and inherited-members default to showing methods and attributes from a
# class or those inherited.
# Member-order orders the documentation in the order of how the members are defined in
# the source code.
autodoc_default_options = {
"members": True,
"inherited-members": True,
"member-order": "bysource",
}
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = False
# Link to GitHub repo for github_issues extension
issues_github_path = "aeon-toolkit/aeon"
# sphinx-copybutton configuration
copybutton_exclude = ".linenos, .gp, .go"
# sphinx-remove-toctrees (and in-built alternative) configuration
# see https://github.com/pradyunsg/furo/pull/674
# we use an in-built alternative currently due to a bug. See sphinx_remove_toctrees.py
# extension issue https://github.com/executablebooks/sphinx-remove-toctrees/issues/9
remove_from_toctrees = ["api_reference/auto_generated/*"]
# MyST Parser configuration
# When building HTML using the sphinx.ext.mathjax (enabled by default),
# Myst-Parser injects the tex2jax_ignore (MathJax v2) and mathjax_ignore (MathJax v3)
# classes in to the top-level section of each MyST document, and adds some default
# configuration. This ensures that MathJax processes only math, identified by the
# dollarmath and amsmath extensions, or specified in math directives. We here silence
# the corresponding warning that this override happens.
suppress_warnings = ["myst.mathjax"]
# "colon_fence" and "html_image" recommended by sphinx_design when using the MyST Parser
myst_enable_extensions = ["colon_fence", "html_image", "attrs_inline"]
myst_heading_anchors = 4
def linkcode_resolve(domain, info):
"""Return URL to source code corresponding.
Parameters
----------
domain : str
info : dict
Returns
-------
url : str
"""
def find_source():
# try to find the file and line number, based on code from numpy:
# https://github.com/numpy/numpy/blob/main/doc/source/conf.py#L286
obj = sys.modules[info["module"]]
for part in info["fullname"].split("."):
obj = getattr(obj, part)
import inspect
import os
if inspect.isfunction(obj):
obj = inspect.unwrap(obj)
fn = inspect.getsourcefile(obj)
fn = os.path.relpath(fn, start=os.path.dirname(aeon.__file__))
source, lineno = inspect.getsourcelines(obj)
return fn, lineno, lineno + len(source) - 1
if domain != "py" or not info["module"]:
return None
try:
filename = "aeon/%s#L%d-L%d" % find_source()
except Exception:
filename = info["module"].replace(".", "/") + ".py"
return "https://github.com/aeon-toolkit/aeon/blob/{}/{}".format(
github_tag,
filename,
)
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML.
html_theme = "furo"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"announcement": "<em>Announcement</em>: aeon is taking part in the Google Summer of Code (GSoC) 2025! See the home page for more information.", # noqa: E501
"sidebar_hide_name": True,
"top_of_page_button": "edit",
"source_repository": "https://github.com/aeon-toolkit/aeon/",
"source_branch": "main",
"source_directory": "docs/",
"light_css_variables": {
"color-brand-primary": "#005E80",
"color-brand-content": "#F05F05",
},
"dark_css_variables": {
"color-brand-primary": "#00ACEB",
"color-brand-content": "#FB9456",
},
"footer_icons": [
{
"name": "Slack",
"url": "https://join.slack.com/t/aeon-toolkit/shared_invite/zt-22vwvut29-HDpCu~7VBUozyfL_8j3dLA", # noqa: E501
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
<path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zM361.5 580.2c0 27.8-22.5 50.4-50.3 50.4-13.3 0-26.1-5.3-35.6-14.8-9.4-9.5-14.7-22.3-14.7-35.6 0-27.8 22.5-50.4 50.3-50.4h50.3v50.4zm134 134.4c0 27.8-22.5 50.4-50.3 50.4-27.8 0-50.3-22.6-50.3-50.4V580.2c0-27.8 22.5-50.4 50.3-50.4 13.3 0 26.1 5.3 35.6 14.8s14.7 22.3 14.7 35.6v134.4zm-50.2-218.4h-134c-27.8 0-50.3-22.6-50.3-50.4 0-27.8 22.5-50.4 50.3-50.4h134c27.8 0 50.3 22.6 50.3 50.4-.1 27.9-22.6 50.4-50.3 50.4zm0-134.4c-13.3 0-26.1-5.3-35.6-14.8S395 324.8 395 311.4c0-27.8 22.5-50.4 50.3-50.4 27.8 0 50.3 22.6 50.3 50.4v50.4h-50.3zm83.7-50.4c0-27.8 22.5-50.4 50.3-50.4 27.8 0 50.3 22.6 50.3 50.4v134.4c0 27.8-22.5 50.4-50.3 50.4-27.8 0-50.3-22.6-50.3-50.4V311.4zM579.3 765c-27.8 0-50.3-22.6-50.3-50.4v-50.4h50.3c27.8 0 50.3 22.6 50.3 50.4 0 27.8-22.5 50.4-50.3 50.4zm134-134.4h-134c-13.3 0-26.1-5.3-35.6-14.8S529 593.6 529 580.2c0-27.8 22.5-50.4 50.3-50.4h134c27.8 0 50.3 22.6 50.3 50.4 0 27.8-22.5 50.4-50.3 50.4zm0-134.4H663v-50.4c0-27.8 22.5-50.4 50.3-50.4s50.3 22.6 50.3 50.4c0 27.8-22.5 50.4-50.3 50.4z"></path>
</svg>
""", # noqa: E501
"class": "",
},
{
"name": "LinkedIn",
"url": "https://www.linkedin.com/company/aeon-toolkit/",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
<path d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zM349.3 793.7H230.6V411.9h118.7v381.8zm-59.3-434a68.8 68.8 0 1 1 68.8-68.8c-.1 38-30.9 68.8-68.8 68.8zm503.7 434H675.1V608c0-44.3-.8-101.2-61.7-101.2-61.7 0-71.2 48.2-71.2 98v188.9H423.7V411.9h113.8v52.2h1.6c15.8-30 54.5-61.7 112.3-61.7 120.2 0 142.3 79.1 142.3 181.9v209.4z"></path>
</svg>
""", # noqa: E501
"class": "",
},
{
"name": "Twitter",
"url": "https://twitter.com/aeon_toolkit",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
<path d="M928 254.3c-30.6 13.2-63.9 22.7-98.2 26.4a170.1 170.1 0 0 0 75-94 336.64 336.64 0 0 1-108.2 41.2A170.1 170.1 0 0 0 672 174c-94.5 0-170.5 76.6-170.5 170.6 0 13.2 1.6 26.4 4.2 39.1-141.5-7.4-267.7-75-351.6-178.5a169.32 169.32 0 0 0-23.2 86.1c0 59.2 30.1 111.4 76 142.1a172 172 0 0 1-77.1-21.7v2.1c0 82.9 58.6 151.6 136.7 167.4a180.6 180.6 0 0 1-44.9 5.8c-11.1 0-21.6-1.1-32.2-2.6C211 652 273.9 701.1 348.8 702.7c-58.6 45.9-132 72.9-211.7 72.9-14.3 0-27.5-.5-41.2-2.1C171.5 822 261.2 850 357.8 850 671.4 850 843 590.2 843 364.7c0-7.4 0-14.8-.5-22.2 33.2-24.3 62.3-54.4 85.5-88.2z"></path>
</svg>
""", # noqa: E501
"class": "",
},
{
"name": "GitHub",
"url": "https://github.com/aeon-toolkit/aeon",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 1024 1024" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
<path d="M511.6 76.3C264.3 76.2 64 276.4 64 523.5 64 718.9 189.3 885 363.8 946c23.5 5.9 19.9-10.8 19.9-22.2v-77.5c-135.7 15.9-141.2-73.9-150.3-88.9C215 726 171.5 718 184.5 703c30.9-15.9 62.4 4 98.9 57.9 26.4 39.1 77.9 32.5 104 26 5.7-23.5 17.9-44.5 34.7-60.8-140.6-25.2-199.2-111-199.2-213 0-49.5 16.3-95 48.3-131.7-20.4-60.5 1.9-112.3 4.9-120 58.1-5.2 118.5 41.6 123.2 45.3 33-8.9 70.7-13.6 112.9-13.6 42.4 0 80.2 4.9 113.5 13.9 11.3-8.6 67.3-48.8 121.3-43.9 2.9 7.7 24.7 58.3 5.5 118 32.4 36.8 48.9 82.7 48.9 132.3 0 102.2-59 188.1-200 212.9a127.5 127.5 0 0 1 38.1 91v112.5c.8 9 0 17.9 15 17.9 177.1-59.7 304.6-227 304.6-424.1 0-247.2-200.4-447.3-447.5-447.3z"></path>
</svg>
""", # noqa: E501
"class": "",
},
{
"name": "ReadTheDocs",
"url": "https://readthedocs.org/projects/aeon-toolkit/",
"html": """
<svg stroke="currentColor" fill="currentColor" stroke-width="0" role="img" viewBox="0 0 24 24" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg">
<path d="M7.732 0a59.316 59.316 0 0 0-4.977.218V24a62.933 62.933 0 0 1 3.619-.687c.17-.028.34-.053.509-.078.215-.033.43-.066.644-.096l.205-.03zm1.18.003V22.96a61.042 61.042 0 0 1 12.333-.213V1.485A60.859 60.859 0 0 0 8.912.003zm1.707 1.81a.59.59 0 0 1 .015 0c3.06.088 6.125.404 9.167.95a.59.59 0 0 1 .476.686.59.59 0 0 1-.569.484.59.59 0 0 1-.116-.009 60.622 60.622 0 0 0-8.992-.931.59.59 0 0 1-.573-.607.59.59 0 0 1 .592-.572zm-4.212.028a.59.59 0 0 1 .578.565.59.59 0 0 1-.564.614 59.74 59.74 0 0 0-2.355.144.59.59 0 0 1-.04.002.59.59 0 0 1-.595-.542.59.59 0 0 1 .54-.635c.8-.065 1.6-.114 2.401-.148a.59.59 0 0 1 .035 0zm4.202 2.834a.59.59 0 0 1 .015 0 61.6 61.6 0 0 1 9.167.8.59.59 0 0 1 .488.677.59.59 0 0 1-.602.494.59.59 0 0 1-.076-.006 60.376 60.376 0 0 0-8.99-.786.59.59 0 0 1-.584-.596.59.59 0 0 1 .582-.583zm-4.211.097a.59.59 0 0 1 .587.555.59.59 0 0 1-.554.622c-.786.046-1.572.107-2.356.184a.59.59 0 0 1-.04.003.59.59 0 0 1-.603-.533.59.59 0 0 1 .53-.644c.8-.078 1.599-.14 2.4-.187a.59.59 0 0 1 .036 0zM10.6 7.535a.59.59 0 0 1 .015 0c3.06-.013 6.125.204 9.167.65a.59.59 0 0 1 .498.67.59.59 0 0 1-.593.504.59.59 0 0 1-.076-.006 60.142 60.142 0 0 0-8.992-.638.59.59 0 0 1-.592-.588.59.59 0 0 1 .573-.592zm1.153 2.846a61.093 61.093 0 0 1 8.02.515.59.59 0 0 1 .509.66.59.59 0 0 1-.586.514.59.59 0 0 1-.076-.005 59.982 59.982 0 0 0-8.99-.492.59.59 0 0 1-.603-.577.59.59 0 0 1 .578-.603c.382-.008.765-.012 1.148-.012zm1.139 2.832a60.92 60.92 0 0 1 6.871.394.59.59 0 0 1 .52.652.59.59 0 0 1-.577.523.59.59 0 0 1-.076-.004 59.936 59.936 0 0 0-8.991-.344.59.59 0 0 1-.61-.568.59.59 0 0 1 .567-.611c.765-.028 1.53-.042 2.296-.042z"></path>
</svg>
""", # noqa: E501
"class": "",
},
],
}
# logos
html_logo = "images/logo/aeon-logo-blue-2-compact.png"
html_favicon = "images/logo/aeon-favicon.ico"
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
html_css_files = [
"css/custom.css",
]
html_show_sourcelink = False
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = "aeondoc"
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# 'preamble': '',
# Latex figure (float) alignment
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
master_doc,
"aeon.tex",
"aeon Documentation",
"aeon developers",
"manual",
),
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, "aeon", "aeon Documentation", [author], 1)]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"aeon",
"aeon Documentation",
author,
"aeon",
"One line description of project.",
"Miscellaneous",
),
]
def _make_estimator_overview(app):
"""Make estimator overview table."""
import pandas as pd
from aeon.utils.discovery import all_estimators
def _does_not_start_with_underscore(input_string):
return not input_string.startswith("_")
# Columns for the output table
base_columns = ["Estimator name", "Module", "Method family"]
capabilities_to_include = {
"multivariate": "Mult.",
"unequal_length": "Uneq.",
"missing_values": "Miss.",
}
# Initialize data dictionary with base columns
data = {col: [] for col in base_columns}
# Add abbreviated columns
data.update({abbrevation: [] for abbrevation in capabilities_to_include.values()})
for estimator_name, estimator_class in all_estimators(include_sklearn=False):
algorithm_type = "::".join(str(estimator_class).split(".")[1:-2])
# fetch tags
tag_dict = estimator_class.get_class_tags()
# includes part of class string
modpath = str(estimator_class)[8:-2]
path_parts = modpath.split(".")
# joins strings excluding starting with '_'
clean_path = ".".join(list(filter(_does_not_start_with_underscore, path_parts)))
# adds html link reference
estimator_name_as_link = str(
'<a href="api_reference/auto_generated/'
+ clean_path
+ '.html">'
+ estimator_name
+ "</a>"
)
algorithm_type = algorithm_type.split("::")
data["Estimator name"].append(estimator_name_as_link)
data["Module"].append(algorithm_type[0])
if len(algorithm_type) > 1:
data["Method family"].append("/".join(algorithm_type[1:]))
else:
data["Method family"].append("N/A")
for capability_name, abbrevation in capabilities_to_include.items():
_val = tag_dict.get(f"capability:{capability_name}")
# For case where tag is not included output as not supported
if not _val or _val is None:
data[abbrevation].append("\u274c")
else:
data[abbrevation].append("\u2705")
df = pd.DataFrame(data).sort_values(
by=["Module", "Method family", "Estimator name"]
)
df_str = """
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css"
href="https://cdn.datatables.net/1.13.7/css/jquery.dataTables.min.css">
<style>
.dataTables_wrapper {
padding: 10px 0;
}
.dataTables_wrapper table.dataTable tbody tr {
background-color: var(--color-background-primary);
color: var(--color-foreground-primary);
}
.dataTables_wrapper table.dataTable tbody tr.odd {
background-color: var(--color-background-secondary);
}
.dataTables_wrapper table.dataTable tbody tr:hover {
background-color: var(--color-background-hover);
}
.dataTables_wrapper table.dataTable a {
color: var(--color-brand-content);
}
.dataTables_length select {
background-color: var(--color-background-primary) !important;
color: var(--color-foreground-primary) !important;
border: 1px solid var(--color-background-border) !important;
}
.dataTables_length select option {
background-color: var(--color-background-primary);
color: var(--color-foreground-primary);
}
.dataTables_length select option:checked {
background-color: var(--color-background-hover);
color: var(--color-foreground-primary);
}
.dataTables_length select:focus {
outline-color: var(--color-background-border);
}
</style>
"""
df_str += df.to_markdown(index=False, tablefmt="github")
df_str += """
<!-- DataTables JS -->
<script type="text/javascript"
src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script type="text/javascript"
src="https://cdn.datatables.net/1.13.7/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function() {
$('table').DataTable({
pageLength: 10,
order: [[1, 'asc'], [2, 'asc'], [0, 'asc']],
language: {
search: 'Search:',
lengthMenu: 'Show _MENU_ entries'
}
});
});
</script>
"""
with open("estimator_overview_table.md", "w", encoding="utf-8") as file:
file.write(df_str)
def _add_estimator_capabilities_table(app, pagename, templatename, context, doctree):
"""Add estimator capabilities table to HTML page."""
if "title" not in context or "body" not in context:
return
if '<span class="caption-text">Capabilities</span>' in context["body"]:
return
from aeon.utils.discovery import all_estimators
estimators = all_estimators(include_sklearn=False)
for estimator_name, estimator_class in estimators:
if estimator_name == context["title"]:
tags = estimator_class.get_class_tags()
capabilities = {
key.split(":")[1]: value
for key, value in tags.items()
if key.startswith("capability:")
}
html_output = """
<div class="table-wrapper docutils container" id="id3">
<table class="docutils align-default" id="id3">
<caption>
<span class="caption-text">Capabilities</span>
<a class="headerlink" href="#id3" title="Link to this table">¶</a>
</caption>
<tbody>
"""
for idx, (key, value) in enumerate(capabilities.items()):
row_class = "row-odd" if idx % 2 == 0 else "row-even"
formatted_key = key.replace("_", " ").title()
if value is True:
formatted_value = "Yes"
elif value is False:
formatted_value = "No"
elif value is None:
formatted_value = "Not Set"
else:
formatted_value = str(value)
html_output += f"""
<tr class="{row_class}">
<th class="stub"><p>{formatted_key}</p></th>
<td><p>{formatted_value}</p></td>
</tr>
"""
html_output += """
</tbody>
</table>
</div>
"""
html_content = context["body"]
# Function to insert table into HTML content
# Look for existing NOTES section outside methods
start_methods = html_content.find('<dl class="py method">')
section_before_methods = html_content[:start_methods]
# Look for Notes section
notes_heading = '<p class="rubric">Notes</p>'
notes_pos = section_before_methods.find(notes_heading)
if notes_pos != -1:
# Notes exists, insert table after it
insert_pos = notes_pos + len(notes_heading)
context["body"] = (
html_content[:insert_pos]
+ "\n"
+ html_output
+ html_content[insert_pos:]
)
else:
# Need to create Notes section
# Find position before References or Examples or Methods
# whichever comes first
ref_pos = section_before_methods.find(
'<p class="rubric">References</p>'
)
ex_pos = section_before_methods.find('<p class="rubric">Examples</p>')
positions = [
pos for pos in [ref_pos, ex_pos, start_methods] if pos != -1
]
insert_pos = min(positions) if positions else start_methods
new_section = f'\n<p class="rubric">Notes</p>\n{html_output}\n'
context["body"] = (
html_content[:insert_pos] + new_section + html_content[insert_pos:]
)
def setup(app):
"""Set up sphinx builder.
Parameters
----------
app : Sphinx application object
"""
app.connect("builder-inited", _make_estimator_overview)
app.connect("html-page-context", _add_estimator_capabilities_table)
# -- Extension configuration -------------------------------------------------
# -- Options for nbsphinx extension ---------------------------------------
nbsphinx_execute = "never" # always # whether to run notebooks
nbsphinx_allow_errors = False # False
nbsphinx_timeout = 600 # seconds, set to -1 to disable timeout
# add Binder launch buttom at the top
current_file = "{{ env.doc2path( env.docname, base=None) }}"
# make sure Binder points to latest stable release, not main
binder_url = f"https://mybinder.org/v2/gh/aeon-toolkit/aeon/{github_tag}?filepath={current_file}" # noqa
nbsphinx_prolog = f"""
.. |binder| image:: https://mybinder.org/badge_logo.svg
.. _Binder: {binder_url}
|Binder|_
"""
# add link to original notebook at the bottom
notebook_url = f"https://github.com/aeon-toolkit/aeon/tree/{github_tag}/{current_file}"
nbsphinx_epilog = f"""
----
Generated using nbsphinx_. The Jupyter notebook can be found here_.
.. _here: {notebook_url}
.. _nbsphinx: https://nbsphinx.readthedocs.io/
"""
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy/", None),
"matplotlib": ("https://matplotlib.org/stable/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
"joblib": ("https://joblib.readthedocs.io/en/latest/", None),
"scikit-learn": ("https://scikit-learn.org/stable/", None),
"statsmodels": ("https://www.statsmodels.org/stable/", None),
}
# -- Options for _todo extension ----------------------------------------------
todo_include_todos = False