-
Notifications
You must be signed in to change notification settings - Fork 4
Init: Refactor NMM mixture, separate generators and mixtures, tests r… #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Немного не понял, в чём разница между разными estimator'ами, так как у них одинаковое поведение (отдать на откуп родительскому классу. Но если это пока заготовки, то ок
src/estimators/abstract_estimator.py
Outdated
def get_params(self) -> dict: | ||
return {"algorithm_name": self.algorithm_name, "params": self.params, "estimated_result": self.estimate_result} | ||
|
||
def set_params(self, algorithm_name: str, params: dict | None = None) -> Self: | ||
self.algorithm_name = algorithm_name | ||
if params is None: | ||
self.params = dict() | ||
else: | ||
self.params = params | ||
return self | ||
|
||
def get_available_algorithms(self) -> list[tuple[str, str]]: | ||
return [key for key in self._registry.register_of_names.keys() if key[1] == self._purpose] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот тут много возьни со строками и словарями. В будущем рекомендую задуматься о рефакторинге, так как поддерживать может быть больно
class AbstractGenerator: | ||
@staticmethod | ||
@abstractmethod | ||
def canonical_generate(mixture: AbstractMixtures, size: int) -> tpg.NDArray: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Докстриги лучше здесь всё же написать
src/mixtures/nm_mixture.py
Outdated
alpha, beta, gamma = params | ||
return alpha, beta, gamma | ||
|
||
if len(params) != 4: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вот как раз такие проверки тяжело будет поддерживать. Гораздо удобнее будет создать класс под хранение параметров, который нельзя будет создать без всех необходимых параметров.
src/mixtures/nmv_mixture.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У разных классов mixture больно много подозрительно похожего кода, м.б. что-то вытащить в родителя?
src/register/register.py
Outdated
@@ -32,25 +34,36 @@ def register(self, name: str) -> Callable: | |||
def decorator(cls: Type[T]) -> Type[T]: | |||
if name in self.register_of_names: | |||
raise ValueError("This name is already registered") | |||
self.register_of_names[name] = cls | |||
if purpose not in [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А может для этого Enum
лучше использовать?
…efactor