Skip to content

Commit

Permalink
Merge pull request #1661 from Anselmoo/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
Anselmoo authored Oct 24, 2024
2 parents 52a5d27 + ff87212 commit b4b97a8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ repos:
- id: ruff-format
files: spectrafit/
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
rev: v1.12.1
hooks:
- id: mypy
additional_dependencies:
Expand Down
23 changes: 15 additions & 8 deletions spectrafit/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ class FitReport:
def __init__(
self,
inpars: Union[Parameters, Callable[..., Any]],
sort_pars: bool = True,
sort_pars: Union[bool, Callable[[str], Any]] = True,
show_correl: bool = True,
min_correl: float = 0.0,
modelpars: Optional[Callable[..., Any]] = None,
Expand All @@ -540,7 +540,7 @@ def __init__(
Args:
inpars (Parameters or object): The input parameters or
object.
sort_pars (bool, optional): Whether to sort the parameters.
sort_pars (Union[bool, Callable[[str], Any]], optional): Whether to sort the parameters.
Defaults to True.
show_correl (bool, optional): Whether to show correlations.
Defaults to True.
Expand All @@ -557,15 +557,22 @@ def __init__(

if isinstance(self.inpars, Parameters):
self.result, self.params = None, self.inpars
if hasattr(self.inpars, "params"):
elif hasattr(self.inpars, "params"):
self.result = self.inpars
self.params = self.inpars.params

if self.sort_pars:
key = self.sort_pars if callable(self.sort_pars) else alphanumeric_sort
self.parnames = sorted(self.params, key=key)
else:
self.parnames = list(self.params.keys())
self.parnames = self._get_parnames()

def _get_parnames(self) -> List[str]:
"""Get parameter names, sorted if required.
Returns:
List[str]: List of parameter names.
"""
if not self.sort_pars:
return list(self.params.keys())
key = self.sort_pars if callable(self.sort_pars) else alphanumeric_sort
return sorted(self.params, key=key)

def generate_fit_statistics(self) -> Optional[pd.DataFrame]:
"""Generate fit statistics based on the result of the fitting process.
Expand Down

0 comments on commit b4b97a8

Please sign in to comment.