Skip to content

Commit

Permalink
DOC: update names of the documentation examples in Gallery
Browse files Browse the repository at this point in the history
- also rename the file doc_uvars_params.py to follow the usual naming
  conventions
  • Loading branch information
reneeotten committed Aug 17, 2024
1 parent 22b062a commit 4aba7ca
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
13 changes: 8 additions & 5 deletions doc/doc_examples_to_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- create a "documentation" directory within "examples"
- add a README.txt file
- copy the examples from the documentation, bu remove the "doc_" from the
- copy the examples from the documentation, removing the "doc_" from the
filename
- add the required docstring to the files for proper rendering
- copy the data files
Expand Down Expand Up @@ -46,12 +46,15 @@ def copy_data_files(src_dir, dest_dir):
)

for fn in files:
sname = fn.name[4:]
lmfit_class, *description = sname[:-3].split('_')
gallery_name = f"{lmfit_class.capitalize()} - {' '.join(description)}"

script_text = fn.read_text()

gallery_file = examples_documentation_dir / fn.name[4:]
msg = "" # add optional message f
gallery_file.write_text(f'"""\n{fn.name}\n{"=" * len(fn.name)}\n\n'
gallery_file = examples_documentation_dir / sname
msg = "" # add optional message
gallery_file.write_text(f'"""\n{gallery_name}\n{"=" * len(gallery_name)}\n\n'
f'{msg}\n"""\n{script_text}')

# make sure the saved Models and ModelResult are available
Expand All @@ -67,5 +70,5 @@ def copy_data_files(src_dir, dest_dir):

os.chdir(doc_dir)

# # data files for the other Gallery examples
# data files for the other Gallery examples
copy_data_files(examples_documentation_dir, doc_dir)
2 changes: 1 addition & 1 deletion doc/model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ that taking correlations between Parameters into account when performing
calculations can have a noticeable influence on the resulting uncertainties.


.. jupyter-execute:: ../examples/doc_uvars_params.py
.. jupyter-execute:: ../examples/doc_parameters_uvars.py


Note that the :meth:`Model.post_fit` does not need to be limited to this
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <examples/doc_uvars_params.py>
# <examples/doc_parameters_uvars.py>
import numpy as np

from lmfit.models import ExponentialModel, GaussianModel
Expand Down Expand Up @@ -67,4 +67,4 @@ def post_fit(result):

out = mod.fit(y, pars, x=x)
print(out.fit_report(min_correl=0.5))
# <end examples/doc_uvars_params.py>
# <end examples/doc_parameters_uvars.py>

0 comments on commit 4aba7ca

Please sign in to comment.