File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed 
src/frequenz/sdk/timeseries Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -315,6 +315,15 @@ def count_valid(self) -> int:
315315        """ 
316316        return  self ._buffer .count_valid ()
317317
318+     def  count_covered (self ) ->  int :
319+         """Count the number of samples that are covered by the oldest and newest valid samples. 
320+ 
321+         Returns: 
322+             The count of samples between the oldest and newest (inclusive) valid samples 
323+                 or 0 if there are is no time range covered. 
324+         """ 
325+         return  self ._buffer .count_covered ()
326+ 
318327    @overload  
319328    def  __getitem__ (self , key : SupportsIndex ) ->  float :
320329        """See the main __getitem__ method. 
Original file line number Diff line number Diff line change @@ -144,12 +144,15 @@ async def test_window_size() -> None:
144144    async  with  window :
145145        assert  window .capacity  ==  5 , "Wrong window capacity" 
146146        assert  window .count_valid () ==  0 , "Window should be empty" 
147+         assert  window .count_covered () ==  0 , "Window should be empty" 
147148        await  push_logical_meter_data (sender , range (0 , 2 ))
148149        assert  window .capacity  ==  5 , "Wrong window capacity" 
149150        assert  window .count_valid () ==  2 , "Window should be partially full" 
151+         assert  window .count_covered () ==  2 , "Window should be partially full" 
150152        await  push_logical_meter_data (sender , range (2 , 20 ))
151153        assert  window .capacity  ==  5 , "Wrong window capacity" 
152154        assert  window .count_valid () ==  5 , "Window should be full" 
155+         assert  window .count_covered () ==  5 , "Window should be full" 
153156
154157
155158# pylint: disable=redefined-outer-name 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments