marcoabreu commented on a change in pull request #16477: added more tests to verify support for large vector URL: https://github.com/apache/incubator-mxnet/pull/16477#discussion_r342182341
########## File path: tests/nightly/test_large_vector.py ########## @@ -708,6 +708,174 @@ def test_full(): assert a[-1] == 3 +def test_astype(): + x = create_vector(size=LARGE_X//4) + x = nd.tile(x, 4) + y = x.astype('int32') + assert y.dtype == np.int32 + assert y[-1] == LARGE_X//4-1 + + +def test_cast(): + x = create_vector(size=LARGE_X//4) + x = nd.tile(x, 4) + y = nd.cast(x, np.int32) + assert y.dtype == np.int32 + assert y[-1] == LARGE_X//4-1 + + +def test_repeat(): + x = create_vector(size=LARGE_X//2) + y = nd.repeat(x, repeats=2, axis = 0) + assert y.shape[0] == LARGE_X + assert y[1] == 0 + assert y[LARGE_X-1] == LARGE_X//2-1 + + +def create_input_for_rounding_ops(): + # Creates an vector with values (-LARGE/2 .... -2, -1, 0, 1, 2, .... , LARGE/2-1) + # then divides each element by 2 i.e (-LARGE/4 .... -1, -0.5, 0, 0.5, 1, .... , LARGE/4-1) + inp = nd.arange(-LARGE_X//2, LARGE_X//2, dtype=np.float64) + inp = inp/2 + return inp + + +def assert_correctness_of_rounding_ops(output, mid, expected_vals): + # checks verifies 5 values at the middle positions of the input vector + # i.e mid-2, mid-1, mid, mid+1, mid+2 + output_idx_to_inspect = [mid-2, mid-1, mid, mid+1, mid+2] + for i in range(len(output_idx_to_inspect)): + assert output[output_idx_to_inspect[i]] == expected_vals[i] + + +def test_rounding_ops(): + x = create_input_for_rounding_ops() + + def test_ceil(): + y = nd.ceil(x) + # expected ouput for middle 5 values after applying ceil() + expected_output = [-1, 0, 0, 1, 1] + assert_correctness_of_rounding_ops(y, LARGE_X//2, expected_output) + + def test_fix(): + y = nd.fix(x) + # expected ouput for middle 5 values after applying fix() + expected_output = [-1, 0, 0, 0, 1] + assert_correctness_of_rounding_ops(y, LARGE_X//2, expected_output) + + def test_floor(): + y = nd.floor(x) + # expected ouput for middle 5 values after applying floor() + expected_output = [-1, -1, 0, 0, 1] + assert_correctness_of_rounding_ops(y, LARGE_X//2, expected_output) + + def test_rint(): Review comment: nosetests generally looks for functions starting with "test_", thus this function could be mistaken for being a standalone test ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services