def test_dataarray_from_array(): with clear_and_catch_warnings() as w: warnings.filterwarnings('always', category=DeprecationWarning) da = GiftiDataArray.from_array(np.ones((3, 4))) assert_equal(len(w), 1) for dt_code in data_type_codes.value_set(): data_type = data_type_codes.type[dt_code] if data_type is np.void: # not supported continue arr = np.zeros((10, 3), dtype=data_type) da = GiftiDataArray.from_array(arr, 'triangle') assert_equal(da.datatype, data_type_codes[arr.dtype]) bs_arr = arr.byteswap().newbyteorder() da = GiftiDataArray.from_array(bs_arr, 'triangle') assert_equal(da.datatype, data_type_codes[arr.dtype])
def test_dataarray(): for dt_code in data_type_codes.value_set(): data_type = data_type_codes.type[dt_code] if data_type is np.void: # not supported continue arr = np.zeros((10, 3), dtype=data_type) da = GiftiDataArray.from_array(arr, 'triangle') assert_equal(da.datatype, data_type_codes[arr.dtype]) bs_arr = arr.byteswap().newbyteorder() da = GiftiDataArray.from_array(bs_arr, 'triangle') assert_equal(da.datatype, data_type_codes[arr.dtype]) # Smoke test on deprecated functions da = GiftiDataArray.from_array(np.ones((1, )), 'triangle') with clear_and_catch_warnings() as w: warnings.filterwarnings('always', category=DeprecationWarning) assert_true(isinstance(da.to_xml_open(), string_types)) assert_equal(len(w), 1) with clear_and_catch_warnings() as w: warnings.filterwarnings('once', category=DeprecationWarning) assert_true(isinstance(da.to_xml_close(), string_types)) assert_equal(len(w), 1)
def test_dataarray(): for dt_code in data_type_codes.value_set(): data_type = data_type_codes.type[dt_code] if data_type is np.void: # not supported continue arr = np.zeros((10, 3), dtype=data_type) da = GiftiDataArray.from_array(arr, 'triangle') assert_equal(da.datatype, data_type_codes[arr.dtype]) bs_arr = arr.byteswap().newbyteorder() da = GiftiDataArray.from_array(bs_arr, 'triangle') assert_equal(da.datatype, data_type_codes[arr.dtype]) # Smoke test on deprecated functions da = GiftiDataArray.from_array(np.ones((1,)), 'triangle') with clear_and_catch_warnings() as w: warnings.filterwarnings('always', category=DeprecationWarning) assert_true(isinstance(da.to_xml_open(), string_types)) assert_equal(len(w), 1) with clear_and_catch_warnings() as w: warnings.filterwarnings('once', category=DeprecationWarning) assert_true(isinstance(da.to_xml_close(), string_types)) assert_equal(len(w), 1)