Skip to content

Commit 3798b11

Browse files
committed
fix: address PR comments
1 parent 0441b9e commit 3798b11

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

tests/test_solution_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,19 @@ def assert_score_analysis_summary(score_analysis: ScoreAnalysis):
147147
assert "3: constraint (Maximize Value) has 3 matches:" in summary
148148
assert "1: justified with" in summary
149149

150+
summary_str = str(score_analysis)
151+
assert summary == summary_str
152+
150153
match = score_analysis.constraint_analyses[0]
151154
match_summary = match.summary
152155
assert "Explanation of score (3):" in match_summary
153156
assert "Constraint matches:" in match_summary
154157
assert "3: constraint (Maximize Value) has 3 matches:" in match_summary
155158
assert "1: justified with" in match_summary
156159

160+
match_summary_str = str(match)
161+
assert match_summary == match_summary_str
162+
157163

158164
def assert_solution_manager(solution_manager: SolutionManager[Solution]):
159165
problem: Solution = Solution([Entity('A', 1), Entity('B', 1), Entity('C', 1)], [1, 2, 3])
@@ -203,7 +209,6 @@ def test_score_manager_diff():
203209

204210
diff_operation = score_analysis - second_score_analysis
205211
assert diff_operation.score.score == -1
206-
print(diff, diff_operation)
207212

208213
constraint_analyses = score_analysis.constraint_analyses
209214
assert len(constraint_analyses) == 1

timefold-solver-python-core/src/main/python/score/_score_analysis.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ def __init__(self, delegate: '_JavaConstraintAnalysis[Score_]'):
479479
delegate.constraintRef()
480480

481481
def __str__(self):
482-
return self.summarize
482+
return self.summary
483483

484484
@property
485485
def constraint_ref(self) -> ConstraintRef:
@@ -611,16 +611,16 @@ def constraint_analysis(self, *args) -> ConstraintAnalysis:
611611
612612
Parameters
613613
----------
614-
constraint_package : str
615-
constraint_name : str
616-
constraint_ref : ConstraintRef
614+
*args: *tuple[str, str] | *tuple[ConstraintRef]
615+
Either two strings or a single ConstraintRef can be passed as positional arguments.
616+
If two strings are passed, they are taken to be the constraint package and constraint name, respectively.
617+
If a ConstraintRef is passed, it is used to perform the lookup.
617618
618619
Returns
619620
-------
620621
ConstraintAnalysis
621622
None if no constraint matches of such constraint are present
622623
"""
623-
print(args)
624624
if len(args) == 1:
625625
return ConstraintAnalysis(self._delegate.getConstraintAnalysis(args[0]._to_java()))
626626
else:

0 commit comments

Comments
 (0)