File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -677,7 +677,7 @@ private static function ranks(array $data): array
677677 $ indexed [] = [$ data [$ i ], $ i ];
678678 }
679679
680- usort ($ indexed , fn ( $ a , $ b ) => $ a [0 ] <=> $ b [0 ]);
680+ usort ($ indexed , fn ( array $ a , array $ b ): int => $ a [0 ] <=> $ b [0 ]);
681681
682682 $ ranks = array_fill (0 , $ n , 0.0 );
683683 $ i = 0 ;
Original file line number Diff line number Diff line change @@ -403,13 +403,15 @@ public function test_calculates_spearman_correlation_planets(): void
403403
404404 // Linear (Pearson) correlation is imperfect
405405 $ correlation = Stat::correlation ($ orbitalPeriod , $ distFromSun );
406+ $ this ->assertIsFloat ($ correlation );
406407 $ this ->assertEquals (0.9882 , round ($ correlation , 4 ));
407408
408409 // Kepler's third law: linear correlation between
409410 // the square of the period and the cube of the distance
410- $ periodSquared = array_map (fn ( $ p ) => $ p * $ p , $ orbitalPeriod );
411- $ distCubed = array_map (fn ( $ d ) => $ d * $ d * $ d , $ distFromSun );
411+ $ periodSquared = array_map (fn ( int $ p ): int => $ p * $ p , $ orbitalPeriod );
412+ $ distCubed = array_map (fn ( int $ d ): int => $ d * $ d * $ d , $ distFromSun );
412413 $ correlation = Stat::correlation ($ periodSquared , $ distCubed );
414+ $ this ->assertIsFloat ($ correlation );
413415 $ this ->assertEquals (1.0 , round ($ correlation , 4 ));
414416 }
415417
You can’t perform that action at this time.
0 commit comments