Skip to content

Conversation

andped10
Copy link
Contributor

@andped10 andped10 commented Aug 6, 2024

Moved duplicated functionality to base class.

Tests are moved to module for base class.

minimizer_lmfit moved public methods to the top of the file.

@andped10 andped10 added the chore PR label label Aug 6, 2024
parameters[parameter_name] = item.raw_value
return parameters

def _generate_fit_function(self) -> Callable:
Copy link
Contributor Author

@andped10 andped10 Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetched from bumps / dfo

return _fit_function

@staticmethod
def _create_signature(parameters: Dict[int, Parameter]) -> Signature:
Copy link
Contributor Author

@andped10 andped10 Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetched from bumps / lmfit


lm_fit_function.__signature__ = self._wrap_to_lm_signature(self._cached_pars)
return lm_fit_function
def available_methods(self) -> List[str]:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public method moved to top

"""
super().__init__(obj=obj, fit_function=fit_function, method=method)

def _make_model(self, pars: Optional[LMParameters] = None) -> LMModel:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private method moved down

assert str(domain_fit_results.minimizer_engine) == "<class 'easyscience.fitting.minimizers.minimizer_lmfit.LMFit'>"
assert domain_fit_results.fit_args is None

def test_wrap_to_lm_signature(self, minimizer: LMFit) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now tested in minimizer_base

]

@staticmethod
def _wrap_to_lm_signature(parameters: Dict[int, Parameter]) -> Signature:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now in minimizer_base

assert mock_lm_model.set_param_hint.call_count == 2
assert model == mock_lm_model

def test_generate_fit_function_signatur(self, minimizer: LMFit) -> None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now tested in minimizer_base

Copy link
Member

@rozyczko rozyczko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clearly done refactoring, one minor question raised.
Ready to merge.

@andped10 andped10 merged commit 173e135 into develop Aug 7, 2024
@andped10 andped10 deleted the 42-consolidate-minimizer-codes branch August 7, 2024 09:40
rozyczko added a commit to rozyczko/EasyScience that referenced this pull request Aug 15, 2024
PR related fixes

ruff, be quiet.

renamed Job->job directory name

38 add tests for minimizer bumps (easyscience#41)

* tests and adjustments

* handling circular dependency

* Updated minimizer names

* Made ruff happy

* pr response

* more consistent usage of enum

---------

Co-authored-by: henrikjacobsenfys <henrik.jacobsen.fys@gmail.com>

removed unnecessary empty line

minimizer consolidation (easyscience#45)

* minimizer consolidation

* pr response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore PR label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants