Skip to content
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

🗑️ [TEST-PR] Wip/projects against d2b297 (Sourcery refactored) #830

Closed
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
4 changes: 1 addition & 3 deletions glotaran/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ def _add_dataset_type(self):
self._add_model_item("dataset", dataset_model_type)

def as_dict(self) -> dict:
model_dict = {}
model_dict["default-megacomplex"] = self.default_megacomplex

model_dict = {"default-megacomplex": self.default_megacomplex}
for name in self._model_items:
items = getattr(self, name)
if len(items) == 0:
Expand Down
16 changes: 8 additions & 8 deletions glotaran/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def __post_init__(self):
self.folder = self.file.parent
if isinstance(self.folder, str):
self.folder = Path(self.folder)
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Project.__post_init__ refactored with the following changes:


@classmethod
def create(cls, name: str | None = None, folder: str | Path | None = None) -> Project:
Expand All @@ -78,7 +77,7 @@ def create(cls, name: str | None = None, folder: str | Path | None = None) -> Pr
if folder is None:
folder = getcwd()
project_folder = Path(folder)
name = name if name else project_folder.name
name = name or project_folder.name
Comment on lines -81 to +80
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Project.create refactored with the following changes:

project_file = project_folder / PROJECT_FILE_NAME
with open(project_file, "w") as f:
f.write(TEMPLATE.format(gta_version=gta_version, name=name))
Expand Down Expand Up @@ -297,12 +296,13 @@ def generate_parameters(
groups = parameter.split(".")
label = groups.pop()
if len(groups) == 0:
if isinstance(parameters, dict) and len(parameters) != 0:
raise ModelError(
"The root parameter group cannot contain both groups and parameters."
)
elif isinstance(parameters, dict):
parameters = []
if isinstance(parameters, dict):
if len(parameters) != 0:
raise ModelError(
"The root parameter group cannot contain both groups and parameters."
)
else:
parameters = []
Comment on lines -300 to +305
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Project.generate_parameters refactored with the following changes:

parameters.append(
[
label,
Expand Down
3 changes: 1 addition & 2 deletions glotaran/project/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ def get_scheme(self) -> Scheme:
if "weight" in dataset:
data[label]["weight"] = dataset.weight

new_scheme = replace(self.scheme, parameters=self.optimized_parameters)
return new_scheme
return replace(self.scheme, parameters=self.optimized_parameters)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Function Result.get_scheme refactored with the following changes:


def markdown(self, with_model: bool = True, base_heading_level: int = 1) -> MarkdownStr:
"""Format the model as a markdown text.
Expand Down