Skip to content

Commit d2324b4

Browse files
authored
Merge pull request #24 from ycexiao/init-doc
docs: initialize the documentation
2 parents a499129 + dd7446d commit d2324b4

6 files changed

Lines changed: 86 additions & 171 deletions

File tree

docs/source/api/pdfbl.sequential.example_package.rst

Lines changed: 0 additions & 31 deletions
This file was deleted.

docs/source/api/pdfbl.sequential.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,25 @@
1010
:undoc-members:
1111
:show-inheritance:
1212

13-
Subpackages
14-
-----------
15-
16-
.. toctree::
17-
pdfbl.sequential.example_package
1813

1914
Submodules
2015
----------
2116

22-
|module|
23-
--------
17+
pdfbl.sequential.pdfadapter module
18+
----------------------------------
19+
20+
.. automodule:: pdfbl.sequential.pdfadapter
21+
:members:
22+
:undoc-members:
23+
:show-inheritance:
24+
:no-index:
25+
2426

25-
.. |module| replace:: pdfbl.sequential.example_submodule module
27+
pdfbl.sequential.sequential_cmi_runner module
28+
---------------------------------------------
2629

27-
.. automodule:: pdfbl.sequential.example_submodule
30+
.. automodule:: pdfbl.sequential.sequential_cmi_runner
2831
:members:
2932
:undoc-members:
3033
:show-inheritance:
34+
:no-index:

docs/source/getting-started.rst

Lines changed: 2 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,72 +8,5 @@
88
Getting started
99
================
1010

11-
Here are some example templates provided to help you get started with writing your documentation. You can use these templates to create your own documentation.
12-
13-
Reuse ``.rst`` files across multiple pages
14-
------------------------------------------
15-
16-
Here is how you can reuse a reusable block of ``.rst`` files across multiple pages:
17-
18-
.. include:: snippets/example-table.rst
19-
20-
.. warning::
21-
22-
Ensure that the ``.rst`` file you are including is not too long. If it is too long, it may be better to split it into multiple files and include them separately.
23-
24-
Refer to a specific section in the documentation
25-
------------------------------------------------
26-
27-
You can use the ``ref`` tag to refer to a specific section in the documentation. For example, you can refer to the section below using the ``:ref:`` tag as shown :ref:`here <attach-image>`.
28-
29-
.. note::
30-
31-
Please check the raw ``.rst`` file of this page to see the exact use of the ``:ref:`` tag.
32-
33-
Embed your code snippets in the documentation
34-
---------------------------------------------
35-
36-
Here is how you can write a block of code in the documentation. You can use the ``code-block`` directive to write a block of code in the documentation. For example, you can write a block of code as shown below:
37-
38-
.. code-block:: bash
39-
40-
# Create a new environment, without build dependencies (pure Python package)
41-
conda create -n <package_name>-env python=3.13 \
42-
--file requirements/tests.txt \
43-
--file requirements/conda.txt
44-
45-
# Create a new environment, with build dependencies (non-pure Python package)
46-
conda create -n <package_name>-env python=3.13 \
47-
--file requirements/tests.txt \
48-
--file requirements/conda.txt \
49-
--file requirements/build.txt
50-
51-
# Activate the environment
52-
conda activate <package_name>_env
53-
54-
# Install your package locally
55-
# `--no-deps` to NOT install packages again from `requirements.pip.txt`
56-
pip install -e . --no-deps
57-
58-
# Run pytest locally
59-
pytest
60-
61-
# ... run example tutorials
62-
63-
.. _attach-image:
64-
65-
Attach an image to the documentation
66-
------------------------------------
67-
68-
Here is how you attach an image to the documentation. The ``/docs/source/img/scikit-package-logo-text.png`` example image is provided in the template.
69-
70-
.. image:: ./img/scikit-package-logo-text.png
71-
:alt: codecov-in-pr-comment
72-
:width: 400px
73-
:align: center
74-
75-
76-
Other useful directives
77-
-----------------------
78-
79-
Here is how you can do menu selection :menuselection:`Admin --> Settings` and display labels for buttons like :guilabel:`Privacy level`.
11+
Welcome to the ``pdfbl.sequential`` documentation! Please see our GitHub page
12+
`here <https://github.com/PDF-bl/pdfbl.sequential>`_ for more information.

docs/source/snippets/example-table.rst

Lines changed: 0 additions & 28 deletions
This file was deleted.

news/init-doc.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* No news added: Initialize the documentation.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/pdfbl/sequential/pdfadapter.py

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,26 @@ class PDFAdapter:
2828
2929
Methods
3030
-------
31-
init_profile(profile_path, qmin=None, qmax=None, xmin=None, xmax=None,
32-
dx=None)
31+
init_profile(profile_path, qmin=None, qmax=None, xmin=None, xmax=None, dx=None)
3332
Load and initialize the PDF profile from the given file path with
3433
some optional parameters.
35-
init_structures(structure_paths, run_parallel=True)
34+
init_structures(structure_paths : list[str], run_parallel=True)
3635
Load and initialize the structures from the given file paths, and
3736
generate corresponding PDFGenerator objects.
3837
init_contribution(equation_string=None)
3938
Initialize the FitContribution object combining the PDF generators and
4039
the profile.
4140
init_recipe()
4241
Initialize the FitRecipe object for the fitting process.
43-
set_initial_variable_values(variable_name_to_value)
42+
set_initial_variable_values(variable_name_to_value : dict)
4443
Update parameter values from the provided dictionary.
45-
refine_variables(variable_names)
44+
refine_variables(variable_names: list[str])
4645
Refine the parameters specified in the list and in that order.
4746
get_variable_names()
4847
Get the names of all variables in the recipe.
49-
save_results(mode="str", filename=None)
48+
save_results(mode: str, filename: str=None)
5049
Save the fitting results.
51-
"""
50+
""" # noqa: E501
5251

5352
def __init__(self):
5453
pass
@@ -73,16 +72,21 @@ def init_profile(
7372
----------
7473
profile_path : str
7574
The path to the experimental PDF profile file.
76-
qmin : float, optional
77-
The minimum Q value for PDF calculation. Default is None.
78-
qmax : float, optional
79-
The maximum Q value for PDF calculation. Default is None.
80-
xmin : float, optional
81-
The minimum r value for PDF calculation. Default is None.
82-
xmax : float, optional
83-
The maximum r value for PDF calculation. Default is None.
84-
dx : float, optional
85-
The r step size for PDF calculation. Default is None.
75+
qmin : float
76+
The minimum Q value for PDF calculation. The default value is
77+
the one parsed from the profile file.
78+
qmax : float
79+
The maximum Q value for PDF calculation. The default value is the
80+
one parsed from the profile file.
81+
xmin : float
82+
The minimum r value for PDF calculation. The default value is the
83+
one parsed from the profile file.
84+
xmax : float
85+
The maximum r value for PDF calculation. The default value is the
86+
one parsed from the profile file.
87+
dx : float
88+
The r step size for PDF calculation. The default value is the
89+
one parsed from the profile file.
8690
"""
8791
profile = Profile()
8892
parser = PDFParser()
@@ -113,9 +117,9 @@ def init_structures(self, structure_paths: list[str], run_parallel=True):
113117
Notes
114118
-----
115119
Planned features:
116-
- Support cif file manipulation.
117-
- Add/Remove atoms.
118-
- symmetry operations?
120+
- Support cif file manipulation.
121+
- Add/Remove atoms.
122+
- symmetry operations?
119123
"""
120124
if isinstance(structure_paths, str):
121125
structure_paths = [structure_paths]
@@ -171,14 +175,19 @@ def init_contribution(self, equation_string=None):
171175
172176
Parameters
173177
----------
174-
equation_string : str, optional
175-
The equation string defining the contribution. If None, a default
178+
equation_string : str
179+
The equation string defining the contribution. The default
176180
equation will be generated based on the number of phases.
181+
e.g.
182+
for one phase: "s0*G1",
183+
for two phases: "s0*(s1*G1+(1-s1)*G2)",
184+
for three phases: "s0*(s1*G1+s2*G2+(1-(s1+s2))*G3)",
185+
...
177186
178187
Notes
179188
-----
180189
Planned features:
181-
- Support registerFunction for custom equations.
190+
- Support registerFunction for custom equations.
182191
"""
183192
contribution = FitContribution("pdfcontribution")
184193
contribution.setProfile(self.profile)
@@ -216,10 +225,10 @@ def init_recipe(
216225
Notes
217226
-----
218227
Planned features:
219-
- support instructions to
220-
- add variables
221-
- constrain variables of the scatters
222-
- change symmetry constraints
228+
- support instructions to
229+
- add variables
230+
- constrain variables of the scatters
231+
- change symmetry constraints
223232
"""
224233
recipe = FitRecipe()
225234
recipe.addContribution(self.contribution)
@@ -302,20 +311,25 @@ def get_variable_names(self) -> list[str]:
302311
return list(self.recipe._parameters.keys())
303312

304313
def save_results(
305-
self, mode: Literal["dict", "str"] = "str", filename=None
314+
self, mode: Literal["str", "dict"] = "str", filename=None
306315
):
307316
"""Save the fitting results. Must be called after
308317
refine_parameters.
309318
310319
Parameters
311320
----------
312-
filename : str | None
321+
mode : str
322+
The format to save the results. Options are:
323+
"str" - Save results as a formatted text string.
324+
"dict" - Save results as a JSON-compatible dictionary.
325+
filename : str
313326
The path to the output file. If None, results will not be saved to
314-
a file. The default is None.
315-
mode : {"dict", "str"}
316-
The format to save the results.
317-
"str" - Save results as a formatted text string.
318-
"dict" - Save results as a JSON-compatible dictionary.
327+
a file.
328+
329+
Returns
330+
-------
331+
str or dict
332+
The fitting results in the specified format.
319333
"""
320334
fit_results = FitResults(self.recipe)
321335
if mode == "str":

0 commit comments

Comments
 (0)