From 18a0fab98ffe4f11fbeb2c3db60bbd69b3b957e5 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Sat, 6 Oct 2018 14:02:23 -0700 Subject: TST: improve coverage of nd_grid --- numpy/lib/tests/test_index_tricks.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'numpy/lib/tests/test_index_tricks.py') diff --git a/numpy/lib/tests/test_index_tricks.py b/numpy/lib/tests/test_index_tricks.py index 7e9c026e4..33b98629d 100644 --- a/numpy/lib/tests/test_index_tricks.py +++ b/numpy/lib/tests/test_index_tricks.py @@ -1,5 +1,7 @@ from __future__ import division, absolute_import, print_function +import pytest + import numpy as np from numpy.testing import ( assert_, assert_equal, assert_array_equal, assert_almost_equal, @@ -164,6 +166,22 @@ class TestGrid(object): for f, b in zip(grid_full, grid_broadcast): assert_equal(f, b) + @pytest.mark.parametrize("start, stop, step, expected", [ + (None, 10, 10j, (200, 10)), + (-10, 20, None, (1800, 30)), + ]) + def test_mgrid_size_none_handling(self, start, stop, step, expected): + # regression test None value handling for + # start and step values used by mgrid; + # internally, this aims to cover previously + # unexplored code paths in nd_grid() + grid = mgrid[start:stop:step, start:stop:step] + # need a smaller grid to explore one of the + # untested code paths + grid_small = mgrid[start:stop:step] + assert_equal(grid.size, expected[0]) + assert_equal(grid_small.size, expected[1]) + class TestConcatenator(object): def test_1d(self): -- cgit v1.2.1