def test_np2str_multi_element(): """Test the np2str function on a multi-element array.""" # multi-element array npstring = np.string_('hej') npstring = np.array([npstring, npstring]) with pytest.raises(ValueError): _ = np2str(npstring)
def test_np2str_pure_string(): """Test the np2str function inputting a pure string.""" # pure string pure_str = 'HEJ' assert np2str(pure_str) is pure_str
def test_np2str_scalar(): """Test the np2str function inputting a scalar value.""" # non-array-non-string with pytest.raises(ValueError): _ = np2str(5)
def test_np2str_single_element_scalar(): """Test the np2str function on a scalar.""" # scalar numpy array npstring = np.string_('hej') np_arr = np.array(npstring) assert np2str(np_arr) == 'hej'
def test_np2str_single_element_array(): """Test the np2str function.""" # single element numpy array npstring = np.string_('Hej') np_arr = np.array([npstring]) assert np2str(np_arr) == 'Hej'
def test_np2str_byte_object(): """Test the np2str function on a byte object.""" # byte object npstring = np.string_('hey') assert np2str(npstring) == 'hey'