Skip to content

Commit 54c1131

Browse files
Merge pull request #74 from easyscience/patch
Updates documentation tutorials and adds excluded regions section
2 parents 77da6a6 + cb938af commit 54c1131

20 files changed

+385
-179
lines changed

.github/workflows/draft-release-notes.yml

Lines changed: 22 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,45 +10,38 @@ on:
1010
- main
1111
- master
1212

13-
# Runs on PRs targeting the default branch (dry-run testing; does NOT update the real draft)
14-
pull_request:
15-
branches:
16-
- main
17-
- master
18-
1913
jobs:
2014
draft-release-notes:
21-
if: ${{ github.event_name == 'push' }}
22-
2315
permissions:
2416
# write permission is required to create a github release
2517
contents: write
2618

2719
runs-on: ubuntu-latest
2820

2921
steps:
30-
- name: Drafts the next Release notes
31-
uses: release-drafter/release-drafter@v6
32-
with:
33-
disable-autolabeler: true
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
- name: Drafts the next release notes
23+
uses: enhantica/drafterino@v1
3624

37-
# Test the Release Drafter config on PRs without modifying the real draft release
38-
draft-release-notes-dry-run:
39-
if: ${{ github.event_name == 'pull_request' }}
40-
41-
permissions:
42-
contents: read
43-
pull-requests: read
44-
45-
runs-on: ubuntu-latest
46-
47-
steps:
48-
- name: Drafts the next Release notes (dry-run)
49-
uses: release-drafter/release-drafter@v6
5025
with:
51-
disable-autolabeler: true
52-
disable-releaser: true # prevents creating/updating the draft
26+
config: |
27+
title: 'easydiffraction $COMPUTED_VERSION'
28+
tag: 'v$COMPUTED_VERSION'
29+
note-template: '- $PR_TITLE (#$PR_NUMBER)'
30+
31+
default-bump: post
32+
33+
major-bump-labels: ['[scope] significant']
34+
minor-bump-labels: ['[scope] enhancement']
35+
patch-bump-labels: ['[scope] bug', '[scope] maintenance']
36+
post-bump-labels: ['[scope] documentation']
37+
38+
release-notes:
39+
- title: 'Added'
40+
labels: ['[scope] significant', '[scope] enhancement']
41+
- title: 'Fixed'
42+
labels: ['[scope] bug']
43+
- title: 'Changed'
44+
labels: ['[scope] maintenance', '[scope] documentation']
45+
5346
env:
5447
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test-code.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,19 @@ jobs:
197197
export PYTHONPATH="$(pwd)/src${PYTHONPATH:+:$PYTHONPATH}"
198198
python -m pytest tests/functional_tests/ --color=yes -n auto
199199
200+
# Ensures a consistent high version like 999.0.0 when not on a tagged commit
201+
# This is needed for testing the package in the next job, as its version
202+
# must be higher than the PyPI version for pip to prefer the local version.
203+
- name: Inject fallback version tag if not on a real tag
204+
shell: bash
205+
run: |
206+
if ! git describe --tags --match "v*" --exact-match > /dev/null 2>&1; then
207+
echo "Not on release tag — applying fallback 'v999.0.0'"
208+
git tag v999.0.0
209+
else
210+
echo "On a valid tag"
211+
fi
212+
200213
- name: Create Python package for the next job
201214
shell: bash
202215
run: python -m build --wheel --outdir dist

docs/user-guide/analysis-workflow/experiment.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,23 @@ which makes it easier to manage the experiment:
132132
depends on the experiment type, but generally includes columns for 2θ angle
133133
or TOF and intensity.
134134

135-
### 1. Instrument Category
135+
### 1. Instrument Category { #instrument-category }
136136

137137
```python
138138
# Modify the default instrument parameters
139139
project.experiments['hrpt'].instrument.setup_wavelength = 1.494
140140
project.experiments['hrpt'].instrument.calib_twotheta_offset = 0.6
141141
```
142142

143-
### 2. Peak Category
143+
### 2. Excluded Regions Category { #excluded-regions-category }
144+
145+
```python
146+
# Add excluded regions to the experiment
147+
project.experiments['hrpt'].excluded_regions.add(start=0, end=10)
148+
project.experiments['hrpt'].excluded_regions.add(start=160, end=180)
149+
```
150+
151+
### 3. Peak Category { #peak-category }
144152

145153
```python
146154
# Select the desired peak profile type
@@ -154,7 +162,7 @@ project.experiments['hrpt'].peak.broad_lorentz_x = 0
154162
project.experiments['hrpt'].peak.broad_lorentz_y = 0.1
155163
```
156164

157-
### 3. Background Category
165+
### 4. Background Category { #background-category }
158166

159167
```python
160168
# Select the desired background type
@@ -168,14 +176,14 @@ project.experiments['hrpt'].background.add(x=110, y=170)
168176
project.experiments['hrpt'].background.add(x=165, y=170)
169177
```
170178

171-
### 4. Linked Phases Category
179+
### 5. Linked Phases Category { #linked-phases-category }
172180

173181
```python
174182
# Link the sample model defined in the previous step to the experiment
175183
project.experiments['hrpt'].linked_phases.add(id='lbco', scale=10.0)
176184
```
177185

178-
### 5. Measured Data Category
186+
### 6. Measured Data Category { #measured-data-category }
179187

180188
If you do not have a CIF file for your experiment, you can load measured data
181189
from a file in a supported format. The measured data will be automatically

docs/user-guide/analysis-workflow/model.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,21 @@ to manage the model:
7979
3. **Atom Sites Category**: Describes the positions and properties of atoms
8080
within the unit cell.
8181

82-
### 1. Space Group Category
82+
### 1. Space Group Category { #space-group-category }
8383

8484
```python
8585
# Set space group
8686
project.sample_models['nacl'].space_group.name_h_m = 'F m -3 m'
8787
```
8888

89-
### 2. Cell Category
89+
### 2. Cell Category { #cell-category }
9090

9191
```python
9292
# Define unit cell parameters
9393
project.sample_models['nacl'].cell.length_a = 5.691694
9494
```
9595

96-
### 3. Atom Sites Category
96+
### 3. Atom Sites Category { #atom-sites-category }
9797

9898
```python
9999
# Add atomic sites

docs/user-guide/first-steps.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ example datasets without having to manually download them.
8787

8888
EasyDiffraction provides several helper methods to display supported engines for
8989
calculation, minimization, and plotting. These methods can be called on the
90-
`Project` instance to display the available options for each category. For
91-
example, you can use the `show_supported_calculators()` method to see which
90+
`Project` instance to display the available options for different categories.
91+
92+
### Supported calculators
93+
94+
For example, you can use the `show_supported_calculators()` method to see which
9295
calculation engines are available for use in your project:
9396

9497
```python
@@ -105,8 +108,19 @@ An example of the output for the `show_supported_calculators()` method is:
105108
| cryspy | CrysPy library for crystallographic calculations |
106109
| pdffit | PDFfit2 library for pair distribution function calculations |
107110

108-
Other helper methods include those for showing the available parameters grouped
109-
in different categories. For example, you can use:
111+
### Supported minimizers
112+
113+
You can also check the available minimizers using the
114+
`show_available_minimizers()` method:
115+
116+
```python
117+
project.show_available_minimizers()
118+
```
119+
120+
### Available parameters
121+
122+
EasyDiffraction provides several methods for showing the available parameters
123+
grouped in different categories. For example, you can use:
110124

111125
- `project.analysis.show_all_params()` – to display all available parameters for
112126
the analysis step.
@@ -135,6 +149,22 @@ method is:
135149
| 60 | project.experiments['hrpt'].peak.broad_gauss_v | hrpt.peak.broad_gauss_v |
136150
| 61 | project.experiments['hrpt'].peak.broad_gauss_w | hrpt.peak.broad_gauss_w |
137151

152+
### Supported plotters
153+
154+
To see the available plotters, you can use the `show_available_plotters()`
155+
method on the `plotter` attribute of the `Project` instance:
156+
157+
```python
158+
project.plotter.show_supported_engines()
159+
```
160+
161+
An example of the output is:
162+
163+
| Engine | Description |
164+
| ------------ | ------------------------------------------ |
165+
| asciichartpy | Console ASCII line charts |
166+
| plotly | Interactive browser-based graphing library |
167+
138168
## Data analysis workflow
139169

140170
Once the EasyDiffraction package is imported, you can proceed with the **data

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ classifiers = [
1616
'Operating System :: OS Independent',
1717
'Programming Language :: Python :: 3 :: Only',
1818
'Programming Language :: Python :: 3',
19-
"Programming Language :: Python :: 3.11",
20-
"Programming Language :: Python :: 3.12",
21-
"Programming Language :: Python :: 3.13",
19+
'Programming Language :: Python :: 3.11',
20+
'Programming Language :: Python :: 3.12',
21+
'Programming Language :: Python :: 3.13',
2222
]
2323
requires-python = '>=3.11,<3.14'
2424
dependencies = [
@@ -117,6 +117,9 @@ distance = '{base_version}.post{distance}' # example: 1.2.3.post42
117117
dirty = '{base_version}' # example: 1.2.3
118118
distance-dirty = '{base_version}.post{distance}' # example: 1.2.3.post42
119119

120+
# Configure how versioningit detects versions from Git
121+
# - 'match' ensures it only considers tags starting with 'v'
122+
# - 'default-tag' is used as a fallback when no matching tag is found
120123
[tool.versioningit.vcs]
121124
method = 'git'
122125
match = ['v*']

src/easydiffraction/analysis/calculators/calculator_crysfml.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020

2121
print("✅ 'pycrysfml' calculation engine is successfully imported.")
2222
except ImportError:
23-
print("⚠️ 'pycrysfml' module not found. This calculation engine will not be available.")
23+
# TODO: Add the following print to debug mode
24+
# print("⚠️ 'pycrysfml' module not found. This calculation engine will not be available.")
2425
cfml_py_utilities = None
2526

2627

src/easydiffraction/analysis/calculators/calculator_cryspy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
print("✅ 'cryspy' calculation engine is successfully imported.")
2525
except ImportError:
26-
print("⚠️ 'cryspy' module not found. This calculation engine will not be available.")
26+
# TODO: Add the following print to debug mode
27+
# print("⚠️ 'cryspy' module not found. This calculation engine will not be available.")
2728
cryspy = None
2829

2930

src/easydiffraction/analysis/calculators/calculator_pdffit.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
redirect_stdout(open(os.path.devnull, 'w')) # silence the C++ engine output
2020
print("✅ 'pdffit' calculation engine is successfully imported.")
2121
except ImportError:
22-
print("⚠️ 'pdffit' module not found. This calculation engine will not be available.")
22+
# TODO: Add the following print to debug mode
23+
# print("⚠️ 'pdffit' module not found. This calculation engine will not be available.")
2324
pdffit = None
2425

2526

src/easydiffraction/analysis/minimizers/minimizer_factory.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ def list_available_minimizers(cls) -> List[str]:
5555

5656
@classmethod
5757
def show_available_minimizers(cls) -> None:
58+
# TODO: Rename this method to `show_supported_minimizers` for
59+
# consistency with other methods in the library. E.g.
60+
# `show_supported_calculators`, etc.
5861
"""
5962
Display a table of available minimizers and their descriptions.
6063
"""

0 commit comments

Comments
 (0)