Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
252 changes: 126 additions & 126 deletions pixi.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ select = [
'DTZ', # https://docs.astral.sh/ruff/rules/#flake8-datetimez-dtz
'EM', # https://docs.astral.sh/ruff/rules/#flake8-errmsg-em
'FA', # https://docs.astral.sh/ruff/rules/#flake8-future-annotations-fa
#'FBT', # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
'FBT', # https://docs.astral.sh/ruff/rules/#flake8-boolean-trap-fbt
#'FIX', # https://docs.astral.sh/ruff/rules/#flake8-fixme-fix
'G', # https://docs.astral.sh/ruff/rules/#flake8-logging-format-g
'ICN', # https://docs.astral.sh/ruff/rules/#flake8-import-conventions-icn
Expand All @@ -268,7 +268,7 @@ select = [
'PT', # https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt
'PTH', # https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
'PYI', # https://docs.astral.sh/ruff/rules/#flake8-pyi-pyi
#'RET', # https://docs.astral.sh/ruff/rules/#flake8-return-ret
'RET', # https://docs.astral.sh/ruff/rules/#flake8-return-ret
'RSE', # https://docs.astral.sh/ruff/rules/#flake8-raise-rse
'S', # https://docs.astral.sh/ruff/rules/#flake8-bandit-s
'SIM', # https://docs.astral.sh/ruff/rules/#flake8-simplify-sim
Expand Down
16 changes: 8 additions & 8 deletions src/easydiffraction/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
@app.callback(invoke_without_command=True)
def main(
ctx: typer.Context,
version: bool = typer.Option(
False,
version: bool = typer.Option( # noqa: FBT001
False, # noqa: FBT003
'--version',
'-V',
help='Show easydiffraction version and exit.',
Expand Down Expand Up @@ -52,8 +52,8 @@ def download_tutorial(
'-d',
help='Directory to save the tutorial into.',
),
overwrite: bool = typer.Option(
False,
overwrite: bool = typer.Option( # noqa: FBT001
False, # noqa: FBT003
'--overwrite',
'-o',
help='Overwrite existing file if present.',
Expand All @@ -71,8 +71,8 @@ def download_all_tutorials(
'-d',
help='Directory to save the tutorials into.',
),
overwrite: bool = typer.Option(
False,
overwrite: bool = typer.Option( # noqa: FBT001
False, # noqa: FBT003
'--overwrite',
'-o',
help='Overwrite existing files if present.',
Expand All @@ -88,8 +88,8 @@ def fit(
...,
help='Path to the project directory (must contain project.cif).',
),
dry: bool = typer.Option(
False,
dry: bool = typer.Option( # noqa: FBT001
False, # noqa: FBT003
'--dry',
help='Run fitting without saving results back to the project directory.',
),
Expand Down
7 changes: 6 additions & 1 deletion src/easydiffraction/analysis/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ def fit_sequential(
file_pattern: str = '*',
extract_diffrn: object = None,
verbosity: str | None = None,
*,
reverse: bool = False,
) -> None:
"""
Expand Down Expand Up @@ -966,7 +967,11 @@ def fit_sequential(
if original_verbosity is not None:
self.project.verbosity = original_verbosity

def _update_categories(self, called_by_minimizer: bool = False) -> None:
def _update_categories(
self,
*,
called_by_minimizer: bool = False,
) -> None:
"""
Update all categories owned by Analysis.

Expand Down
2 changes: 2 additions & 0 deletions src/easydiffraction/analysis/calculators/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def calculate_structure_factors(
self,
structure: Structure,
experiment: ExperimentBase,
*,
called_by_minimizer: bool,
) -> None:
"""Calculate structure factors for one experiment."""
Expand All @@ -38,6 +39,7 @@ def calculate_pattern(
self,
structure: Structures, # TODO: Structure?
experiment: ExperimentBase,
*,
called_by_minimizer: bool,
) -> np.ndarray:
"""
Expand Down
5 changes: 2 additions & 3 deletions src/easydiffraction/analysis/calculators/crysfml.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def calculate_pattern(
self,
structure: Structures,
experiment: ExperimentBase,
*,
called_by_minimizer: bool = False,
) -> np.ndarray | list[float]:
"""
Expand Down Expand Up @@ -231,7 +232,7 @@ def _convert_experiment_to_dict( # noqa: PLR6301

# TODO: Process default values on the experiment creation
# instead of here
exp_dict = {
return {
'NPD': {
'_diffrn_radiation_probe': expt_type.radiation_probe.value
if expt_type
Expand All @@ -258,5 +259,3 @@ def _convert_experiment_to_dict( # noqa: PLR6301
/ (len(x_data) - 1 + 1e-9),
}
}

return exp_dict
2 changes: 2 additions & 0 deletions src/easydiffraction/analysis/calculators/cryspy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def calculate_structure_factors(
self,
structure: Structure,
experiment: ExperimentBase,
*,
called_by_minimizer: bool = False,
) -> None:
"""
Expand Down Expand Up @@ -117,6 +118,7 @@ def calculate_pattern(
self,
structure: Structure,
experiment: ExperimentBase,
*,
called_by_minimizer: bool = False,
) -> np.ndarray | list[float]:
"""
Expand Down
5 changes: 2 additions & 3 deletions src/easydiffraction/analysis/calculators/pdffit.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def calculate_pattern( # noqa: PLR6301
self,
structure: Structure,
experiment: ExperimentBase,
*,
called_by_minimizer: bool = False,
) -> None:
"""
Expand Down Expand Up @@ -165,6 +166,4 @@ def calculate_pattern( # noqa: PLR6301

# Get the calculated PDF pattern
pattern = calculator.getpdf_fit()
pattern = np.array(pattern)

return pattern
return np.array(pattern)
1 change: 1 addition & 0 deletions src/easydiffraction/analysis/categories/fit_mode/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ def description(self) -> str:
return 'Independent fitting of each experiment; no shared parameters'
if self is FitModeEnum.JOINT:
return 'Simultaneous fitting of all experiments; some parameters are shared'
return None
1 change: 1 addition & 0 deletions src/easydiffraction/analysis/fit_helpers/reporting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class FitResults:

def __init__(
self,
*,
success: bool = False,
parameters: list[object] | None = None,
reduced_chi_square: float | None = None,
Expand Down
4 changes: 1 addition & 3 deletions src/easydiffraction/analysis/minimizers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def fit(

self._stop_tracking()

result = self._finalize_fit(parameters, raw_result)

return result
return self._finalize_fit(parameters, raw_result)

def _objective_function(
self,
Expand Down
1 change: 1 addition & 0 deletions src/easydiffraction/analysis/sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ def fit_sequential(
chunk_size: int | None = None,
file_pattern: str = '*',
extract_diffrn: Callable | None = None,
*,
reverse: bool = False,
) -> None:
"""
Expand Down
12 changes: 10 additions & 2 deletions src/easydiffraction/core/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ def __str__(self) -> str:
return f'<{name} ({params})>'

# TODO: Common for all categories
def _update(self, called_by_minimizer: bool = False) -> None: # noqa: PLR6301
def _update( # noqa: PLR6301
self,
*,
called_by_minimizer: bool = False,
) -> None:
del called_by_minimizer

@property
Expand Down Expand Up @@ -193,7 +197,11 @@ def __str__(self) -> str:
return f'<{name} collection ({size} items)>'

# TODO: Common for all categories
def _update(self, called_by_minimizer: bool = False) -> None: # noqa: PLR6301
def _update( # noqa: PLR6301
self,
*,
called_by_minimizer: bool = False,
) -> None:
del called_by_minimizer

@property
Expand Down
1 change: 1 addition & 0 deletions src/easydiffraction/core/datablock.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __repr__(self) -> str:

def _update_categories(
self,
*,
called_by_minimizer: bool = False,
) -> None:
# TODO: Make abstract method and implement in subclasses.
Expand Down
6 changes: 5 additions & 1 deletion src/easydiffraction/core/guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def _public_writable_attrs(cls) -> set[str]:
"""Public properties with a setter."""
return {key for key, prop in cls._iter_properties() if prop.fset is not None}

def _allowed_attrs(self, writable_only: bool = False) -> set[str]:
def _allowed_attrs(
self,
*,
writable_only: bool = False,
) -> set[str]:
cls = type(self)
if writable_only:
return cls._public_writable_attrs()
Expand Down
1 change: 1 addition & 0 deletions src/easydiffraction/core/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ def validated(
name: str,
default: object = None,
current: object = None,
*,
allow_none: bool = False,
) -> object:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ class ChebyshevPolynomialBackground(BackgroundBase):
def __init__(self) -> None:
super().__init__(item_type=PolynomialTerm)

def _update(self, called_by_minimizer: bool = False) -> None:
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
"""Evaluate polynomial background over x data."""
del called_by_minimizer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ def description(self) -> str:
return 'Linear interpolation between points'
if self is BackgroundTypeEnum.CHEBYSHEV:
return 'Chebyshev polynomial background'
return None
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ class LineSegmentBackground(BackgroundBase):
def __init__(self) -> None:
super().__init__(item_type=LineSegment)

def _update(self, called_by_minimizer: bool = False) -> None:
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
"""Interpolate background points over x data."""
del called_by_minimizer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,11 @@ def _calc_items(self) -> list:

# Misc

def _update(self, called_by_minimizer: bool = False) -> None:
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
experiment = self._parent
experiments = experiment._parent
project = experiments._parent
Expand Down Expand Up @@ -452,8 +456,7 @@ def intensity_meas_su(self) -> np.ndarray:
dtype=float, # TODO: needed? DataTypes.NUMERIC?
)
# Replace values smaller than _MIN_UNCERTAINTY with 1.0
modified = np.where(original < _MIN_UNCERTAINTY, 1.0, original)
return modified
return np.where(original < _MIN_UNCERTAINTY, 1.0, original)

@property
def intensity_calc(self) -> np.ndarray:
Expand Down Expand Up @@ -514,8 +517,12 @@ def _create_items_set_xcoord_and_id(self, values: object) -> None:

# Misc

def _update(self, called_by_minimizer: bool = False) -> None:
super()._update(called_by_minimizer)
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
super()._update(called_by_minimizer=called_by_minimizer)

experiment = self._parent
d_spacing = twotheta_to_d(
Expand Down Expand Up @@ -589,8 +596,12 @@ def _create_items_set_xcoord_and_id(self, values: object) -> None:

# Misc

def _update(self, called_by_minimizer: bool = False) -> None:
super()._update(called_by_minimizer)
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
super()._update(called_by_minimizer=called_by_minimizer)

experiment = self._parent
d_spacing = tof_to_d(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,11 @@ def _set_intensity_calc(self, values: object) -> None:

# Misc

def _update(self, called_by_minimizer: bool = False) -> None:
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
experiment = self._parent
experiments = experiment._parent
project = experiments._parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ def _calc_items(self) -> list:

# Misc

def _update(self, called_by_minimizer: bool = False) -> None:
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
experiment = self._parent
experiments = experiment._parent
project = experiments._parent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ class ExcludedRegions(CategoryCollection):
def __init__(self) -> None:
super().__init__(item_type=ExcludedRegion)

def _update(self, called_by_minimizer: bool = False) -> None:
def _update(
self,
*,
called_by_minimizer: bool = False,
) -> None:
del called_by_minimizer

data = self._parent.data
Expand Down
Loading
Loading