Example #1
0
def int_to_ip(values):
    """
    Convert integer column to IP addresses.
    **Addresses must be IPv4. IPv6 not yet supported.**

    :param values: Integers to be converted
    :type values: cudf.Series
    :return: IP addresses
    :rtype: cudf.Series

    Examples
    --------
    >>> import clx.ip
    >>> import cudf
    >>> clx.ip.int_to_ip(cudf.Series([3232235521, 167772161]))
    0     5.79.97.178
    1    94.130.74.45
    dtype: object
    """
    return cudf.Series(
        nvstrings.int2ip(
            values.astype("int32")._column.data_array_view,
            count=len(values),
            bdevmem=True,
        ))
Example #2
0
def test_int2ip():
    ints = [3232235521, 167772161, None, 0, 0, 700055553, 700776449]
    got = nvstrings.int2ip(ints)
    expected = [
        '192.168.0.1', '10.0.0.1', '0.0.0.0', '0.0.0.0', '0.0.0.0',
        '41.186.0.1', '41.197.0.1'
    ]
    assert_eq(got, expected)
Example #3
0
def int_to_ip(values):
    """Convert integer column to IP addresses.
    *** Addresses must be IPv4. IPv6 not yet supported. ***

        Example
        -------
        >>> int_to_ip(cudf.Series([3232235521, 167772161])
        0     5.79.97.178
        1    94.130.74.45
        dtype: object
    """
    return cudf.Series(
        nvstrings.int2ip(
            values.astype("int32").data.mem, count=len(values), bdevmem=True
        )
    )
Example #4
0
print(".isdecimal(devptr):",d_arr.copy_to_host())

#
print(".isspace():",s.isspace())
s.isspace(d_arr.device_ctypes_pointer.value)
print(".isspace(devptr):",d_arr.copy_to_host())

#
print(".isnumeric():",s.isnumeric())
s.isnumeric(d_arr.device_ctypes_pointer.value)
print(".isnumeric(devptr):",d_arr.copy_to_host())

s = nvstrings.to_device(["1234","ABCDEF","1A2","cafe"])
print(s)
print(".htoi()",s.htoi())
arr = np.arange(s.size(),dtype=np.uint32)
d_arr = rmm.to_device(arr)
s.htoi(d_arr.device_ctypes_pointer.value)
print(".htoi(devptr)",d_arr.copy_to_host())
print("itos():",nvstrings.itos(d_arr))
nulls = np.empty(int(s.size()/8)+1, dtype=np.int8)
nulls[0] = 11
arr = d_arr.copy_to_host()
print("itos(nulls=\\b1011):",nvstrings.itos(arr,nulls=nulls))

s = nvstrings.to_device(["192.168.0.1","10.0.0.1",None,"","hello"])
print(s)
print(".ip2int()",s.ip2int())
print(nvstrings.int2ip(s.ip2int()))

s = None
Example #5
0
def test_int2ip():
    ints = [3232235521, 167772161, None, 0, 0]
    got = nvstrings.int2ip(ints)
    expected = ['192.168.0.1', '10.0.0.1', '0.0.0.0', '0.0.0.0', '0.0.0.0']
    assert_eq(got, expected)