@@ -101,7 +101,7 @@ def batch_multi_index(self) -> Optional["pd.MultiIndex"]:
101101 return None
102102
103103 for tensor in self .members .values ():
104- idx = tensor .data .indexes .get (AxisId ("batch" ))
104+ idx = tensor .data .indexes .get (AxisId ("batch" )) # pyright: ignore[reportUnknownVariableType]
105105 if isinstance (idx , pd .MultiIndex ):
106106 return idx
107107
@@ -316,7 +316,7 @@ def transpose(
316316 (
317317 batch_lengths := {
318318 t .sizes [AxisId ("batch" )]
319- for m , t in members .items ()
319+ for t in members .values ()
320320 if AxisId ("batch" ) in t .dims
321321 }
322322 )
@@ -335,7 +335,7 @@ def assign_batch_multi_index(self, multi_index: "pd.MultiIndex") -> Self:
335335 Raises:
336336 ValueError: If not all sample members have a batch dimension.
337337 """
338- if (
338+ if len (
339339 no_batch := [
340340 m for m , t in self .members .items () if AxisId ("batch" ) not in t .dims
341341 ]
@@ -365,10 +365,14 @@ def unstack_batch_multi_index(
365365 A new `Sample` with unstacked batch multi-index for all members.
366366 """
367367 if (
368- no_batch := [
369- m for m , t in self .members .items () if AxisId ("batch" ) not in t .dims
370- ]
371- ) == len (self .members ) and errors == "raise" :
368+ len (
369+ no_batch := [
370+ m for m , t in self .members .items () if AxisId ("batch" ) not in t .dims
371+ ]
372+ )
373+ == len (self .members )
374+ and errors == "raise"
375+ ):
372376 raise ValueError (f"No member has a batch dimension: { no_batch } " )
373377
374378 members = {
@@ -381,7 +385,7 @@ def unstack_batch_multi_index(
381385 len (
382386 batch_lengths := {
383387 t .sizes .get (AxisId ("batch" ))
384- for m , t in members .items ()
388+ for t in members .values ()
385389 if AxisId ("batch" ) in t .dims
386390 }
387391 )
@@ -391,10 +395,10 @@ def unstack_batch_multi_index(
391395 f"Different batch lengths after unstacking: { batch_lengths } "
392396 )
393397
394- stat = {
398+ stat : Stat = {
395399 k : v .unstack_batch_multi_index (errors = "ignore" )
396400 if isinstance (v , Tensor )
397- else v
401+ else float ( v )
398402 for k , v in self .stat .items ()
399403 }
400404 return self .__class__ (
0 commit comments