diff --git a/.gitignore b/.gitignore index 73854f2..8a409f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /vendor/ humbuglog.* /bin/phpunit +.coverage diff --git a/tests/Phpml/Preprocessing/NormalizerTest.php b/tests/Phpml/Preprocessing/NormalizerTest.php index f0e21c9..d33881f 100644 --- a/tests/Phpml/Preprocessing/NormalizerTest.php +++ b/tests/Phpml/Preprocessing/NormalizerTest.php @@ -79,4 +79,24 @@ class NormalizerTest extends \PHPUnit_Framework_TestCase $this->assertEquals($normalized, $samples, '', $delta = 0.01); } + + public function testL1NormWithZeroSumCondition() + { + $samples = [ + [0, 0, 0], + [2, 0, 0], + [0, 1, -1], + ]; + + $normalized = [ + [0.33, 0.33, 0.33], + [1.0, 0.0, 0.0], + [0.0, 0.5, -0.5], + ]; + + $normalizer = new Normalizer(Normalizer::NORM_L1); + $normalizer->transform($samples); + + $this->assertEquals($normalized, $samples, '', $delta = 0.01); + } }