From bf716bb94a0030a3fbd043531929b7a3e2aae68d Mon Sep 17 00:00:00 2001 From: patniharshit Date: Tue, 9 May 2017 12:12:38 +0530 Subject: [PATCH 1/8] Add test in LogFormatter for _num_to_string method used in __call__ --- lib/matplotlib/tests/test_ticker.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index d647c5b764ca..6fc25ef9a3f9 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -467,6 +467,10 @@ class TestLogFormatter(object): (100000, 1000000.0, '1e5'), ] + call_data = [ + 1, 5, 10, 50, 100, 10000 + ] + @pytest.mark.parametrize('value, domain, expected', pprint_data) def test_pprint(self, value, domain, expected): fmt = mticker.LogFormatter() @@ -521,6 +525,15 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) + @pytest.mark.parametrize('val', call_data) + def test_LogFormatter_call(self, val): + # test _num_to_string method used in __call__ + fig, ax = plt.subplots() + lf = matplotlib.ticker.LogFormatter() + ax.xaxis.set_major_formatter(lf) + + assert str(lf(val)) is not None + class TestFormatStrFormatter(object): def test_basic(self): From 42c38a7b2c203c268dc7facfdefec2788d30dfe2 Mon Sep 17 00:00:00 2001 From: patniharshit Date: Tue, 9 May 2017 19:17:46 +0530 Subject: [PATCH 2/8] Add a fake axis to log formatter test --- lib/matplotlib/tests/test_ticker.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 6fc25ef9a3f9..d79289ef59db 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -467,10 +467,6 @@ class TestLogFormatter(object): (100000, 1000000.0, '1e5'), ] - call_data = [ - 1, 5, 10, 50, 100, 10000 - ] - @pytest.mark.parametrize('value, domain, expected', pprint_data) def test_pprint(self, value, domain, expected): fmt = mticker.LogFormatter() @@ -525,14 +521,11 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) - @pytest.mark.parametrize('val', call_data) - def test_LogFormatter_call(self, val): + def test_LogFormatter_call(self): # test _num_to_string method used in __call__ - fig, ax = plt.subplots() - lf = matplotlib.ticker.LogFormatter() - ax.xaxis.set_major_formatter(lf) - - assert str(lf(val)) is not None + temp_lf = mticker.LogFormatter() + temp_lf.axis = FakeAxis() + assert str(temp_lf(10)) is not None class TestFormatStrFormatter(object): From 9ff607c22d6544d98042dcf21a3007c4cd61fbee Mon Sep 17 00:00:00 2001 From: patniharshit Date: Wed, 10 May 2017 00:58:29 +0530 Subject: [PATCH 3/8] Run test_LogFormatter_call test on multiple values --- lib/matplotlib/tests/test_ticker.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index d79289ef59db..7de980548194 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -467,6 +467,10 @@ class TestLogFormatter(object): (100000, 1000000.0, '1e5'), ] + call_data = [ + 1, 10, 100, 1000 + ] + @pytest.mark.parametrize('value, domain, expected', pprint_data) def test_pprint(self, value, domain, expected): fmt = mticker.LogFormatter() @@ -521,11 +525,12 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) - def test_LogFormatter_call(self): + @pytest.mark.parametrize('val', call_data) + def test_LogFormatter_call(self, val): # test _num_to_string method used in __call__ temp_lf = mticker.LogFormatter() temp_lf.axis = FakeAxis() - assert str(temp_lf(10)) is not None + assert str(temp_lf(val)) is not None class TestFormatStrFormatter(object): From 6252a0f334ed1e32cc8558f0aebb8f37832dfccb Mon Sep 17 00:00:00 2001 From: patniharshit Date: Wed, 10 May 2017 01:08:19 +0530 Subject: [PATCH 4/8] Update assertion in log formatter test --- lib/matplotlib/tests/test_ticker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 7de980548194..10e7b61e0079 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -530,7 +530,7 @@ def test_LogFormatter_call(self, val): # test _num_to_string method used in __call__ temp_lf = mticker.LogFormatter() temp_lf.axis = FakeAxis() - assert str(temp_lf(val)) is not None + assert temp_lf(val) == str(val) class TestFormatStrFormatter(object): From 1dbd538a6dcbb3f46a1da66505ab3c026a6ca267 Mon Sep 17 00:00:00 2001 From: patniharshit Date: Wed, 10 May 2017 18:11:02 +0530 Subject: [PATCH 5/8] Remove pytest.mark.parameterize from test_LogFormatter_call test --- lib/matplotlib/tests/test_ticker.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 10e7b61e0079..71c8d9e3148f 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -467,10 +467,6 @@ class TestLogFormatter(object): (100000, 1000000.0, '1e5'), ] - call_data = [ - 1, 10, 100, 1000 - ] - @pytest.mark.parametrize('value, domain, expected', pprint_data) def test_pprint(self, value, domain, expected): fmt = mticker.LogFormatter() @@ -525,12 +521,14 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) - @pytest.mark.parametrize('val', call_data) - def test_LogFormatter_call(self, val): + def test_LogFormatter_call(self): # test _num_to_string method used in __call__ + call_data = [ 1, 10, 100, 1000 ] temp_lf = mticker.LogFormatter() temp_lf.axis = FakeAxis() - assert temp_lf(val) == str(val) + + for val in call_data: + assert temp_lf(val) == str(val) class TestFormatStrFormatter(object): From 4f16b0c9d3ab6057db24832371e098ae100c232b Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Wed, 10 May 2017 08:31:31 -0700 Subject: [PATCH 6/8] PEP8 fix and parametrization --- lib/matplotlib/tests/test_ticker.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 71c8d9e3148f..e19570edf241 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -521,14 +521,12 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) - def test_LogFormatter_call(self): + @pytest.mark.parametrize(('val', [1, 10, 100, 1000]), + def test_LogFormatter_call(self, val): # test _num_to_string method used in __call__ - call_data = [ 1, 10, 100, 1000 ] temp_lf = mticker.LogFormatter() temp_lf.axis = FakeAxis() - - for val in call_data: - assert temp_lf(val) == str(val) + assert temp_lf(val) == str(val) class TestFormatStrFormatter(object): From 650f47636f22a895e93838696253528cb85f76d7 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Wed, 10 May 2017 08:32:28 -0700 Subject: [PATCH 7/8] Stupid paren typo --- lib/matplotlib/tests/test_ticker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index e19570edf241..0666723f3d57 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -521,7 +521,7 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) - @pytest.mark.parametrize(('val', [1, 10, 100, 1000]), + @pytest.mark.parametrize('val', [1, 10, 100, 1000]), def test_LogFormatter_call(self, val): # test _num_to_string method used in __call__ temp_lf = mticker.LogFormatter() From 0c6cdb29ad689ec50894f2009ce07842a64d6270 Mon Sep 17 00:00:00 2001 From: Paul Hobson Date: Wed, 10 May 2017 08:33:25 -0700 Subject: [PATCH 8/8] Stupid paren typo 2 --- lib/matplotlib/tests/test_ticker.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 0666723f3d57..865cc085c376 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -521,7 +521,7 @@ def test_sublabel(self): ax.set_xlim(0.5, 0.9) self._sub_labels(ax.xaxis, subs=np.arange(2, 10, dtype=int)) - @pytest.mark.parametrize('val', [1, 10, 100, 1000]), + @pytest.mark.parametrize('val', [1, 10, 100, 1000]) def test_LogFormatter_call(self, val): # test _num_to_string method used in __call__ temp_lf = mticker.LogFormatter() pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy