Example #1
0
def test_bytes_to_char():
    array = np.array([[b"ab", b"cd"], [b"ef", b"gh"]])
    expected = np.array([[[b"a", b"b"], [b"c", b"d"]], [[b"e", b"f"], [b"g", b"h"]]])
    actual = strings.bytes_to_char(array)
    assert_array_equal(actual, expected)

    expected = np.array([[[b"a", b"b"], [b"e", b"f"]], [[b"c", b"d"], [b"g", b"h"]]])
    actual = strings.bytes_to_char(array.T)  # non-contiguous
    assert_array_equal(actual, expected)
def test_bytes_to_char():
    array = np.array([[b'ab', b'cd'], [b'ef', b'gh']])
    expected = np.array([[[b'a', b'b'], [b'c', b'd']],
                         [[b'e', b'f'], [b'g', b'h']]])
    actual = strings.bytes_to_char(array)
    assert_array_equal(actual, expected)

    expected = np.array([[[b'a', b'b'], [b'e', b'f']],
                         [[b'c', b'd'], [b'g', b'h']]])
    actual = strings.bytes_to_char(array.T)  # non-contiguous
    assert_array_equal(actual, expected)
Example #3
0
def test_bytes_to_char():
    array = np.array([[b'ab', b'cd'], [b'ef', b'gh']])
    expected = np.array([[[b'a', b'b'], [b'c', b'd']],
                         [[b'e', b'f'], [b'g', b'h']]])
    actual = strings.bytes_to_char(array)
    assert_array_equal(actual, expected)

    expected = np.array([[[b'a', b'b'], [b'e', b'f']],
                         [[b'c', b'd'], [b'g', b'h']]])
    actual = strings.bytes_to_char(array.T)  # non-contiguous
    assert_array_equal(actual, expected)
def test_bytes_to_char_dask():
    numpy_array = np.array([b'ab', b'cd'])
    array = da.from_array(numpy_array, ((1, 1), ))
    expected = np.array([[b'a', b'b'], [b'c', b'd']])
    actual = strings.bytes_to_char(array)
    assert isinstance(actual, da.Array)
    assert actual.chunks == ((1, 1), ((2, )))
    assert actual.dtype == 'S1'
    assert_array_equal(np.array(actual), expected)
Example #5
0
def test_bytes_to_char_dask():
    numpy_array = np.array([b'ab', b'cd'])
    array = da.from_array(numpy_array, ((1, 1),))
    expected = np.array([[b'a', b'b'], [b'c', b'd']])
    actual = strings.bytes_to_char(array)
    assert isinstance(actual, da.Array)
    assert actual.chunks == ((1, 1), ((2,)))
    assert actual.dtype == 'S1'
    assert_array_equal(np.array(actual), expected)
Example #6
0
def test_bytes_to_char_dask():
    numpy_array = np.array([b"ab", b"cd"])
    array = da.from_array(numpy_array, ((1, 1), ))
    expected = np.array([[b"a", b"b"], [b"c", b"d"]])
    actual = strings.bytes_to_char(array)
    assert isinstance(actual, da.Array)
    assert actual.chunks == ((1, 1), ((2, )))
    assert actual.dtype == "S1"
    assert_array_equal(np.array(actual), expected)