Skip to content

Commit

Permalink
trying to make CodaFactor happy
Browse files Browse the repository at this point in the history
  • Loading branch information
andped10 committed Nov 21, 2024
1 parent 3dfeeb9 commit 497e978
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
35 changes: 12 additions & 23 deletions src/easyreflectometry/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,18 @@ def parameters(self) -> List[Parameter]:
parameters.append(vertice_obj)
return parameters

# @property
# def count_free_parameters(self) -> int:
# count = 0
# for parameter in self.parameters:
# if parameter.free:
# count = count + 1
# return count

# @property
# def count_fixed_parameters(self) -> int:
# count = 0
# for parameter in self.parameters:
# if not parameter.free:
# count = count + 1
# return count

# @property
# def count_parameter_user_constraints(self) -> int:
# count = 0
# parameters = self.parameters
# for parameter in parameters:
# count = count + len(parameter.user_constraints.keys())
# return count
def count_free_parameters(self) -> int:
return sum(1 for parameter in self.parameters if parameter.free)

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

def count_parameter_user_constraints(self) -> int:
count = 0
parameters = self.parameters
for parameter in parameters:
count = count + len(parameter.user_constraints.keys())
return count

@property
def q_min(self):
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.count_free_parameters()
num_fixed_params = self._project.count_fixed_parameters()
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.count_parameter_user_constraints()

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.count_free_parameters()

# 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.count_fixed_parameters()

# 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.count_parameter_user_constraints()

# Expect
assert count == 1

0 comments on commit 497e978

Please sign in to comment.