henrikingo commented on code in PR #96:
URL: https://github.com/apache/otava/pull/96#discussion_r2532213028


##########
otava/analysis.py:
##########
@@ -170,10 +126,42 @@ def compare(self, left: np.ndarray, right: np.ndarray) -> 
ComparativeStats:
             )
         else:
             p = 1.0
-        return ComparativeStats(mean_l, mean_r, std_l, std_r, p)
+        return TTestStats(mean_1=mean_l, mean_2=mean_r, std_1=std_l, 
std_2=std_r, pvalue=p)
+
+    def change_point(
+        self, candidate: CandidateChangePoint, series: 
Sequence[SupportsFloat], intervals: List[slice]
+    ) -> ChangePoint[TTestStats]:
+        """
+        Computes properties of the change point if the Candidate Change Point 
based on the provided intervals.
+
+        The method works for two cases:
+        1. Divisive algorithm.
+           if the candidate is a new potential change point, i.e., its index 
is inside any interval, then
+           we split the interval by the candidate's index to get left and 
right subseries.
+        2. Merge step in t-test algorithm.
+           if the candidate is an existing change point, i.e., it matches the 
end of two intervals, then
+           it's a potential weak change point, and we don't need to split the 
intervals anymore (just take
+           both intervals as left and right subseries).
+
+        """
+        for i, interval in enumerate(intervals):
+            if interval.stop == candidate.index:
+                left_interval = interval
+                right_interval = intervals[i + 1]
+                break
+            elif (interval.start is None or interval.start < candidate.index) 
and (interval.stop is None or candidate.index < interval.stop):

Review Comment:
   Ah, makes sense. Could you add a short comment somewhere in the class 
definition.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to