Skip to content

Commit

Permalink
'Refactored by Sourcery'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sourcery AI committed Oct 17, 2023
1 parent e4013a4 commit ecdcc3c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion glotaran/optimization/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def from_global_data(
clp_axis = [
label
for gl in global_matrix.clp_axis
for label in [gl + "@" + ml for ml in matrix.clp_axis]
for label in [f"{gl}@{ml}" for ml in matrix.clp_axis]
]

array = (
Expand Down
8 changes: 3 additions & 5 deletions glotaran/optimization/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,16 @@ def from_least_squares_result(

result_args = {
"success": success,
# "glotaran_version": glotaran_version,
"free_parameter_labels": free_parameter_labels,
"parameter_history": parameter_history,
"termination_reason": termination_reason,
"optimization_history": optimization_history,
"number_of_function_evaluations": result.nfev # type:ignore[union-attr]
"number_of_function_evaluations": result.nfev
if success
else parameter_history.number_of_records,
"cost": 0.5 * np.dot(penalty, penalty),
}

result_args["cost"] = 0.5 * np.dot(penalty, penalty)
if success:
result_args["number_clp"] = number_clp
result_args["number_of_jacobian_evaluations"] = result.njev # type:ignore[union-attr]
Expand Down Expand Up @@ -168,5 +167,4 @@ def calculate_covariance_matrix_and_standard_errors(
_, jacobian_sv, jacobian_rsv = np.linalg.svd(jacobian, full_matrices=False)
jacobian_sv_square = jacobian_sv**2
mask = jacobian_sv_square > np.finfo(float).eps
covariance_matrix = (jacobian_rsv[mask].T / jacobian_sv_square[mask]) @ jacobian_rsv[mask]
return covariance_matrix
return (jacobian_rsv[mask].T / jacobian_sv_square[mask]) @ jacobian_rsv[mask]
3 changes: 1 addition & 2 deletions glotaran/plugin_system/project_io_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ def load_scheme(file_name: StrOrPath, format_name: str | None = None, **kwargs:
"""
io = get_project_io(format_name or infer_file_format(file_name))

scheme = io.load_scheme(Path(file_name).as_posix(), **kwargs)
return scheme
return io.load_scheme(Path(file_name).as_posix(), **kwargs)


@not_implemented_to_value_error
Expand Down

0 comments on commit ecdcc3c

Please sign in to comment.