Skip to content

Commit

Permalink
CodeFactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andped10 committed Nov 21, 2024
1 parent 10d3927 commit c49469e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/easyreflectometry/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ def parameters(self) -> List[Parameter]:
parameters.append(vertice_obj)
return parameters

def count_free_parameters(self) -> int:
def free_parameters_count(self) -> int:
return sum(1 for parameter in self.parameters if parameter.free)

def count_fixed_parameters(self) -> int:
def fixed_parameters_count(self) -> int:
return sum(1 for parameter in self.parameters if not parameter.free)

def count_parameter_user_constraints(self) -> int:
def parameter_user_constraints_count(self) -> int:
return sum(len(parameter.user_constraints.keys()) for parameter in self.parameters if not parameter.free)

@property
Expand Down
6 changes: 3 additions & 3 deletions src/easyreflectometry/summary/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ def _experiments_section(self) -> str:

def _refinement_section(self) -> str:
html_refinement = HTML_REFINEMENT_TEMPLATE
num_free_params = self._project.count_free_parameters()
num_fixed_params = self._project.count_fixed_parameters()
num_free_params = self._project.free_parameters_count()
num_fixed_params = self._project.fixed_parameters_count()
num_params = num_free_params + num_fixed_params
# goodness_of_fit = self._project.status.goodnessOfFit
# goodness_of_fit = goodness_of_fit.split(' → ')[-1]
num_constraints = self._project.count_parameter_user_constraints()
num_constraints = self._project.parameter_user_constraints_count()

html_refinement = html_refinement.replace('calculation_engine', f'{self._project._calculator.current_interface_name}')
html_refinement = html_refinement.replace('minimization_engine', f'{self._project.minimizer.name}')
Expand Down
6 changes: 3 additions & 3 deletions tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def test_count_free_parameters(self):
project.parameters[0].free = True

# Then
count = project.count_free_parameters()
count = project.free_parameters_count()

# Expect
assert count == 1
Expand All @@ -654,7 +654,7 @@ def test_count_fixed_parameters(self):
project.parameters[0].free = True

# Then
count = project.count_fixed_parameters()
count = project.fixed_parameters_count()

# Expect
assert count == 13
Expand All @@ -666,7 +666,7 @@ def test_count_parameter_user_constraints(self):
project.parameters[0].user_constraints['name_other_parameter'] = 'constraint'

# Then
count = project.count_parameter_user_constraints()
count = project.parameter_user_constraints_count()

# Expect
assert count == 1

0 comments on commit c49469e

Please sign in to comment.