From 2a76cbb402b5f65bc28305eaf053abfe830064c0 Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Sun, 24 Jul 2016 13:42:50 +0200 Subject: [PATCH] add .coverage to git ignore --- .gitignore | 1 + tests/Phpml/Preprocessing/NormalizerTest.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) 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); + } }