Skip to content

Commit f4f22f3

Browse files
committed
documentation update
1 parent 5f30ee1 commit f4f22f3

28 files changed

Lines changed: 1178 additions & 1405 deletions

‎docs/README.md‎

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# XANESNET Documentation
22

3-
This directory contains the [Sphinx](https://www.sphinx-doc.org/) sources for
4-
the XANESNET API reference and user guide.
3+
This directory contains the [Sphinx](https://www.sphinx-doc.org/) sources for the XANESNET API reference and user guide.
54

65
## Building
76

@@ -18,8 +17,7 @@ cd docs
1817
make html
1918
```
2019

21-
The rendered site is written to `build/html/index.html`. Open it in a browser
22-
to navigate the docs.
20+
The rendered site is written to `build/html/index.html`. Open it in a browser to navigate the docs.
2321

2422
To start from a clean state:
2523

@@ -29,59 +27,61 @@ make clean && make html
2927

3028
## Regenerating the API reference
3129

32-
The per-module `.rst` stubs under `source/api/` are produced by `sphinx-apidoc`
33-
from in-source Google-style docstrings. They are checked into the repository
34-
so that builds work without first running `sphinx-apidoc`, but they need to
35-
be refreshed whenever modules are added, removed, or renamed:
30+
The per-module `.rst` stubs under `source/api/` are produced by `sphinx-apidoc` from in-source Google-style docstrings.
31+
They are checked into the repository so that builds work without first running `sphinx-apidoc`,
32+
but they need to be refreshed whenever modules are added, removed, or renamed:
3633

3734
```bash
3835
cd docs
3936
sphinx-apidoc -o source/api ../xanesnet --separate --module-first --force
4037
```
4138

42-
This rewrites `source/api/modules.rst` and every `source/api/xanesnet.*.rst`
43-
file. Hand-maintained pages under `source/index.rst` and `source/user-guide/`
44-
are not touched.
39+
This rewrites `source/api/modules.rst` and every `source/api/xanesnet.*.rst` file.
40+
Hand-maintained pages under `source/index.rst` and `source/user-guide/` are not touched.
4541

4642
## Layout
4743

4844
```
4945
docs/
50-
├── Makefile # `make html`, `make clean`, ...
51-
├── make.bat # Windows equivalent
52-
├── README.md # this file
53-
├── source/
54-
│ ├── conf.py # Sphinx configuration
55-
│ ├── index.rst # landing page
56-
│ ├── images/ # figures for the landing page
57-
│ ├── user-guide/ # narrative documentation
58-
│ │ ├── intro.rst
59-
│ │ ├── install.rst
60-
│ │ ├── user-interface.rst
61-
│ │ ├── running.rst
62-
│ │ ├── input.rst
63-
│ │ ├── descriptors.rst
64-
│ │ └── models.rst
65-
│ └── api/ # API reference (mostly autogenerated)
66-
│ ├── modules.rst
67-
│ └── xanesnet.*.rst
68-
└── build/ # build output (gitignored)
46+
|-- Makefile # `make html`, `make clean`, ...
47+
|-- make.bat
48+
|-- README.md
49+
|-- source/
50+
| |-- conf.py # Sphinx configuration
51+
| |-- index.rst # landing page
52+
| |-- images/
53+
| |-- user-guide/
54+
| | |-- intro.rst
55+
| | |-- install.rst
56+
| | |-- running.rst
57+
| | |-- input.rst
58+
| | |-- datasources.rst
59+
| | |-- datasets.rst
60+
| | |-- descriptors.rst
61+
| | |-- graphs.rst
62+
| | |-- encodings.rst
63+
| | |-- models.rst
64+
| | |-- batch-processors.rst
65+
| | |-- training.rst
66+
| | |-- losses.rst
67+
| | |-- regularizers.rst
68+
| | |-- early-stoppers.rst
69+
| | |-- optimizers.rst
70+
| | |-- lr-schedulers.rst
71+
| | |-- activations.rst
72+
| | |-- strategies.rst
73+
| | |-- inference.rst
74+
| | |-- analysis.rst
75+
| | |-- config-editor.rst
76+
| |-- api/ # API reference
77+
| |-- modules.rst
78+
| |-- xanesnet.*.rst
79+
|-- build/ # build output
6980
```
7081

7182
## Conventions
7283

7384
- The theme is [sphinx-rtd-theme](https://sphinx-rtd-theme.readthedocs.io/).
7485
- Docstrings are Google-style, parsed by `sphinx.ext.napoleon`.
75-
- Type hints in signatures are rendered into the description by
76-
`sphinx-autodoc-typehints`.
86+
- Type hints in signatures are rendered into the description by `sphinx-autodoc-typehints`.
7787
- `autosummary_generate = True` is on so summary tables fill themselves in.
78-
79-
## Troubleshooting
80-
81-
- *`ModuleNotFoundError` during build*: the `xanesnet` package must be
82-
importable. Install the project (`pip install -e .`) into the same
83-
environment as Sphinx.
84-
- *Many "duplicate object description" warnings*: usually means a module was
85-
renamed or moved; rerun `sphinx-apidoc` (see above) to refresh the stubs.
86-
- *`pymatgen` forward-reference warnings*: these come from optional
87-
third-party type hints and are intentionally suppressed in `conf.py`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
xanesnet.strategies.kfold module
2+
================================
3+
4+
.. automodule:: xanesnet.strategies.kfold
5+
:members:
6+
:show-inheritance:
7+
:undoc-members:

‎docs/source/api/xanesnet.strategies.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Submodules
1515
xanesnet.strategies.base
1616
xanesnet.strategies.bootstrap
1717
xanesnet.strategies.deep_ensemble
18+
xanesnet.strategies.kfold
1819
xanesnet.strategies.registry
1920
xanesnet.strategies.single
2021
xanesnet.strategies.snapshot_ensemble

‎docs/source/conf.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"sphinx.ext.napoleon",
2828
# Viewcode: adds links to highlighted source code
2929
"sphinx.ext.viewcode",
30-
# Intersphinx: cross-reference other projects (Python, NumPy, PyTorch, …)
30+
# Intersphinx: cross-reference other projects (Python, NumPy, PyTorch, ...)
3131
"sphinx.ext.intersphinx",
3232
# Autosummary: generate summary tables for modules/classes
3333
"sphinx.ext.autosummary",

‎docs/source/index.rst‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,42 @@ X A N E S N E T
44

55
.. image:: images/xanesnet_graphic.png
66
:align: center
7+
:alt: XANESNET logo
78

89
|
910
10-
XANESNET is an open-source toolbox for the rapid and automated analysis and
11-
prediction of X-ray spectroscopy data. The software is collaboratively
12-
developed by
13-
`Hendrik Junkawitsch <https://github.com/HendrikJunkawitsch>`_, the `Penfold Group <http://penfoldgroup.co.uk>`_, and the
14-
`Research Software Engineering (RSE) team <https://rse.ncldata.dev/>`_ at
15-
`Newcastle University <https://ncl.ac.uk>`_.
11+
XANESNET is an open-source toolbox for the automated prediction and analysis of X-ray spectroscopy data.
12+
The software is collaboratively developed by `Hendrik Junkawitsch <https://github.com/HendrikJunkawitsch>`_,
13+
the `Penfold Group <http://penfoldgroup.co.uk>`_, and the `Research Software Engineering (RSE) team <https://rse.ncldata.dev/>`_ at `Newcastle University <https://ncl.ac.uk>`_.
1614

17-
This documentation provides a user guide for running XANESNET and an API
18-
reference generated from in-source docstrings.
15+
This documentation provides a user guide for running XANESNET and an :doc:`api/modules` reference generated from in-source docstrings.
1916

2017
.. toctree::
2118
:maxdepth: 2
2219
:caption: User Guide
2320

2421
user-guide/intro
2522
user-guide/install
26-
user-guide/user-interface
2723
user-guide/running
2824
user-guide/input
29-
user-guide/descriptors
25+
user-guide/datasources
3026
user-guide/datasets
27+
user-guide/descriptors
28+
user-guide/graphs
29+
user-guide/encodings
3130
user-guide/models
31+
user-guide/batch-processors
32+
user-guide/training
33+
user-guide/losses
34+
user-guide/regularizers
35+
user-guide/early-stoppers
36+
user-guide/optimizers
37+
user-guide/lr-schedulers
38+
user-guide/activations
3239
user-guide/strategies
40+
user-guide/inference
41+
user-guide/analysis
42+
user-guide/config-editor
3343

3444
.. toctree::
3545
:maxdepth: 2
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Activations
2+
===========
3+
4+
Activation functions are model-level components used by :doc:`models`.
5+
They might be used in various models.
6+
7+
Available implementations
8+
--------------------------
9+
10+
The activation registry provides:
11+
12+
* ``relu`` (:class:`~torch.nn.ReLU`)
13+
* ``prelu`` (:class:`~torch.nn.PReLU`)
14+
* ``tanh`` (:class:`~torch.nn.Tanh`)
15+
* ``sigmoid`` (:class:`~torch.nn.Sigmoid`)
16+
* ``elu`` (:class:`~torch.nn.ELU`)
17+
* ``leakyrelu`` (:class:`~torch.nn.LeakyReLU`)
18+
* ``selu`` (:class:`~torch.nn.SELU`)
19+
* ``silu`` (:class:`~torch.nn.SiLU`)
20+
* ``gelu`` (:class:`~torch.nn.GELU`)
21+
22+
Example
23+
-------
24+
25+
.. code-block:: yaml
26+
27+
model:
28+
model_type: mlp
29+
activation: gelu
30+
31+
API reference
32+
-------------
33+
34+
See :mod:`xanesnet.components.activation` for the XANESNET activation registry.
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
Analysis configuration
2+
======================
3+
4+
The analysis workflow reads saved predictions from :doc:`inference`.
5+
It selects samples, computes per-sample values, reduces them to summaries, and writes reports and figures.
6+
The pipeline is independent of model training and inference.
7+
8+
An analysis configuration requires five lists:
9+
10+
* ``selectors`` choose samples or sample groups.
11+
* ``collectors`` compute values for each selected sample.
12+
* ``aggregators`` reduce collected values to summaries.
13+
* ``reporters`` write structured results.
14+
* ``plotters`` write figures and table outputs.
15+
16+
Analysis pipeline
17+
-----------------
18+
19+
Analysis starts with one prediction reader for each inference run.
20+
The readers provide prediction records and, when the inference datasource can be loaded, matching structures.
21+
22+
1. Selectors create the sample streams to analyse. Each configured selector is applied independently to each prediction reader.
23+
Use a ``chain`` selector when several filters must be applied in sequence.
24+
2. Collectors process every sample in each selected stream. Their per-sample values are written to JSONL files under the analysis run's ``aux/`` directory.
25+
3. Aggregators read the selector streams and collector values and reduce them to summary results such as errors, distributions, rankings, or per-channel statistics.
26+
4. Reporters and plotters consume the combined analysis results. Reporters write structured files, while plotters create figures and tables.
27+
28+
With this pipeline it is easily possible to analyze and compare multiple inference runs.
29+
30+
Available implementations
31+
--------------------------
32+
33+
Selectors
34+
~~~~~~~~~
35+
36+
* ``all`` and ``none`` (:class:`~xanesnet.analysis.selectors.identity.IdentitySelector`) keep all samples.
37+
* ``index_list`` (:class:`~xanesnet.analysis.selectors.by_index.IndexSelector`) selects explicit zero-based indices.
38+
* ``index_range`` (:class:`~xanesnet.analysis.selectors.by_range.IndexRangeSelector`) selects an inclusive ``start`` to exclusive ``end`` range.
39+
* ``random`` (:class:`~xanesnet.analysis.selectors.bernoulli.BernoulliSelector`) keeps samples with probability ``p``.
40+
* ``element`` (:class:`~xanesnet.analysis.selectors.by_element.ElementSelector`) selects target sites by chemical element.
41+
* ``structure_cluster`` (:class:`~xanesnet.analysis.selectors.structure_cluster.StructureClusterSelector`) partitions structures using a descriptor.
42+
* ``chain`` (:class:`~xanesnet.analysis.selectors.chain.ChainSelector`) applies an ordered sequence of selectors.
43+
44+
Collectors
45+
~~~~~~~~~~
46+
47+
* ``loss`` (:class:`~xanesnet.analysis.collectors.loss.LossCollector`) computes a configured loss for each sample and can collect an energy-resolved vector.
48+
* ``descriptor`` (:class:`~xanesnet.analysis.collectors.descriptor.DescriptorCollector`) computes a descriptor for each matched structure.
49+
50+
Aggregators
51+
~~~~~~~~~~~
52+
53+
* ``scalar`` (:class:`~xanesnet.analysis.aggregators.scalar.ScalarAggregator`) computes scalar summary statistics.
54+
* ``vector`` (:class:`~xanesnet.analysis.aggregators.vector.VectorAggregator`) summarises vector values such as energy-resolved losses.
55+
* ``spectrum`` (:class:`~xanesnet.analysis.aggregators.spectrum.SpectrumAggregator`) computes per-channel prediction and target statistics.
56+
* ``ranking`` (:class:`~xanesnet.analysis.aggregators.ranking.RankingAggregator`) selects best and worst samples using a collected value.
57+
* ``bias_variance`` (:class:`~xanesnet.analysis.aggregators.bias_variance.BiasVarianceAggregator`) computes a per-channel bias and variance decomposition.
58+
59+
Reporters
60+
~~~~~~~~~
61+
62+
* ``scalar`` (:class:`~xanesnet.analysis.reporters.scalar.ScalarReporter`) writes per-sample scalar values as CSV files.
63+
* ``statistics`` (:class:`~xanesnet.analysis.reporters.statistics.StatisticsReporter`) writes aggregated values as YAML or JSON.
64+
65+
Plotters
66+
~~~~~~~~
67+
68+
* ``scalar`` (:class:`~xanesnet.analysis.plotters.scalar.ScalarPlotter`) plots scalar-value distributions.
69+
* ``spectra_all`` (:class:`~xanesnet.analysis.plotters.spectra.AllSpectraPlotter`) plots selected prediction and target spectra.
70+
* ``spectra_comparison`` (:class:`~xanesnet.analysis.plotters.spectra_comparison.SpectraComparisonPlotter`) compares best and worst samples using ``sort_key``.
71+
* ``stat_table`` (:class:`~xanesnet.analysis.plotters.stat_table.StatTablePlotter`) writes PDF tables of aggregated statistics.
72+
* ``stat_table_latex`` (:class:`~xanesnet.analysis.plotters.stat_table_latex.StatTableLatexPlotter`) writes LaTeX sources and optional PDFs.
73+
* ``energy_resolved_loss`` (:class:`~xanesnet.analysis.plotters.energy_resolved.EnergyResolvedLossPlotter`) plots energy-resolved loss curves.
74+
* ``mean_spectrum`` (:class:`~xanesnet.analysis.plotters.mean_spectrum.MeanSpectrumPlotter`) plots mean spectra and best or worst tail means.
75+
* ``parity`` (:class:`~xanesnet.analysis.plotters.parity.ParityPlotter`) plots predicted-versus-target intensity parity.
76+
* ``bias_variance`` (:class:`~xanesnet.analysis.plotters.bias_variance.BiasVariancePlotter`) plots per-channel bias and variance.
77+
* ``error_correlation`` (:class:`~xanesnet.analysis.plotters.error_correlation.ErrorCorrelationPlotter`) plots pairwise error correlations using ``sort_key``.
78+
* ``pca`` (:class:`~xanesnet.analysis.plotters.pca.PcaPlotter`) plots structure groups in descriptor PCA space.
79+
* ``selector_overview`` (:class:`~xanesnet.analysis.plotters.selector_overview.SelectorOverviewPlotter`) compares selector groups using ``err_key``.
80+
81+
Common configuration
82+
--------------------
83+
84+
The optional top-level fields are ``seed`` and ``preload``.
85+
``preload`` loads prediction records and matched structures during setup instead of reading them on demand.
86+
This can speed up analysis significantly for small test datasets.
87+
88+
Examples
89+
--------
90+
91+
Independent selector streams:
92+
93+
.. code-block:: yaml
94+
95+
selectors:
96+
- selector_type: element
97+
elements: [Fe]
98+
- selector_type: random
99+
p: 0.1
100+
101+
Sequential filtering:
102+
103+
.. code-block:: yaml
104+
105+
selectors:
106+
- selector_type: chain
107+
chain:
108+
- selector_type: element
109+
elements: [Fe]
110+
- selector_type: random
111+
p: 0.1
112+
113+
A complete combination of analysis components is shown in ``configs/analyze_example.yaml``.
114+
115+
API reference
116+
-------------
117+
118+
See also :mod:`xanesnet.analysis` and the schemas under ``xanesnet/schemas/analysis/`` for complete fields and defaults.

0 commit comments

Comments
 (0)