3
3
from .._timefold_java_interop import _java_score_mapping_dict
4
4
from _jpyinterpreter import unwrap_python_like_object , add_java_interface
5
5
from dataclasses import dataclass
6
- from multipledispatch import dispatch
7
6
8
- from typing import TypeVar , Generic , Union , TYPE_CHECKING , Any , cast , Optional , Type
7
+ from typing import overload , TypeVar , Generic , Union , TYPE_CHECKING , Any , cast , Optional , Type
9
8
10
9
if TYPE_CHECKING :
11
10
# These imports require a JVM to be running, so only import if type checking
@@ -120,7 +119,7 @@ def identification_string(self) -> str:
120
119
return self .constraint_ref .constraint_id
121
120
122
121
@property
123
- def get_indicted_object_list (self ):
122
+ def indicted_object_list (self ):
124
123
return self .indicted_objects
125
124
126
125
def __hash__ (self ) -> int :
@@ -467,7 +466,7 @@ class ConstraintAnalysis(Generic[Score_]):
467
466
but still non-zero constraint weight; non-empty if constraint has matches.
468
467
This is a list to simplify access to individual elements,
469
468
but it contains no duplicates just like `set` wouldn't.
470
- summarize : str
469
+ summary : str
471
470
Returns a diagnostic text
472
471
that explains part of the score quality through the ConstraintAnalysis API.
473
472
match_count : int
@@ -513,7 +512,7 @@ def score(self) -> Score_:
513
512
return to_python_score (self ._delegate .score ())
514
513
515
514
@property
516
- def summarize (self ) -> str :
515
+ def summary (self ) -> str :
517
516
return self ._delegate .summarize ()
518
517
519
518
@@ -547,7 +546,7 @@ class ScoreAnalysis:
547
546
constraint_analyses : list[ConstraintAnalysis]
548
547
Individual ConstraintAnalysis instances that make up this ScoreAnalysis.
549
548
550
- summarize : str
549
+ summary : str
551
550
Returns a diagnostic text that explains the solution through the `ConstraintAnalysis` API to identify which
552
551
Constraints cause that score quality.
553
552
The string is built fresh every time the method is called.
@@ -572,7 +571,10 @@ def __init__(self, delegate: '_JavaScoreAnalysis'):
572
571
self ._delegate = delegate
573
572
574
573
def __str__ (self ):
575
- return self .summarize
574
+ return self .summary
575
+
576
+ def __sub__ (self , other ):
577
+ return self .diff (other )
576
578
577
579
@property
578
580
def score (self ) -> 'Score' :
@@ -595,41 +597,37 @@ def constraint_analyses(self) -> list[ConstraintAnalysis]:
595
597
list ['_JavaConstraintAnalysis[Score]' ], self ._delegate .constraintAnalyses ())
596
598
]
597
599
598
- @dispatch ( str , str )
600
+ @overload
599
601
def constraint_analysis (self , constraint_package : str , constraint_name : str ) -> ConstraintAnalysis :
600
- """
601
- Performs a lookup on `constraint_map`.
602
-
603
- Parameters
604
- ----------
605
- constraint_package : str
606
- constraint_name : str
602
+ ...
607
603
608
- Returns
609
- -------
610
- ConstraintAnalysis
611
- None if no constraint matches of such constraint are present
612
- """
613
- return ConstraintAnalysis (self ._delegate .getConstraintAnalysis (constraint_package , constraint_name ))
614
-
615
- @dispatch (ConstraintRef )
604
+ @overload
616
605
def constraint_analysis (self , constraint_ref : 'ConstraintRef' ) -> ConstraintAnalysis :
606
+ ...
607
+
608
+ def constraint_analysis (self , * args ) -> ConstraintAnalysis :
617
609
"""
618
610
Performs a lookup on `constraint_map`.
619
611
620
612
Parameters
621
613
----------
614
+ constraint_package : str
615
+ constraint_name : str
622
616
constraint_ref : ConstraintRef
623
617
624
618
Returns
625
619
-------
626
620
ConstraintAnalysis
627
621
None if no constraint matches of such constraint are present
628
622
"""
629
- return ConstraintAnalysis (self ._delegate .getConstraintAnalysis (constraint_ref ._to_java ()))
623
+ print (args )
624
+ if len (args ) == 1 :
625
+ return ConstraintAnalysis (self ._delegate .getConstraintAnalysis (args [0 ]._to_java ()))
626
+ else :
627
+ return ConstraintAnalysis (self ._delegate .getConstraintAnalysis (args [0 ], args [1 ]))
630
628
631
629
@property
632
- def summarize (self ) -> str :
630
+ def summary (self ) -> str :
633
631
return self ._delegate .summarize ()
634
632
635
633
@property
0 commit comments