예제 #1
0
def test_add_get_cpp_types():
    from kwiver.sprokit.adapters import adapter_data_set

    ads = adapter_data_set.AdapterDataSet.create()
    add_get_helper(
        ads,
        ads._add_double_vector,
        ads._get_port_data_double_vector,
        adapter_data_set.VectorDouble([3.14, 4.14]),
        "double_vector",
    )
    add_get_helper(
        ads,
        ads._add_string_vector,
        ads._get_port_data_string_vector,
        adapter_data_set.VectorString(["s00", "s01"]),
        "string_vector",
    )
    add_get_helper(
        ads,
        ads._add_uchar_vector,
        ads._get_port_data_uchar_vector,
        adapter_data_set.VectorUChar([100, 101]),
        "uchar_vector",
    )
예제 #2
0
def test_mix_add_and_get():
    from kwiver.sprokit.adapters import adapter_data_set
    from kwiver.vital import types as kvt

    ads = adapter_data_set.AdapterDataSet.create()

    # Try adding with generic adder first, retrieving with
    # type specific get function
    ads["string_port"] = "string_value"
    check_same_type(
        ads._get_port_data_string("string_port"), "string_value", "string_port"
    )

    ads["timestamp_port"] = kvt.Timestamp(1000000000, 10)
    check_same_type(
        ads._get_port_data_timestamp("timestamp_port"),
        kvt.Timestamp(1000000000, 10),
        "timestamp_port",
    )

    ads["vector_string_port"] = adapter_data_set.VectorString(["element1", "element2"])
    check_same_type(
        ads._get_port_data_string_vector("vector_string_port"),
        adapter_data_set.VectorString(["element1", "element2"]),
        "vector_string_port",
    )

    # Now try the opposite
    ads._add_string("string_port", "string_value")
    check_same_type(ads["string_port"], "string_value", "string_port")

    ads._add_timestamp("timestamp_port", kvt.Timestamp(1000000000, 10))
    check_same_type(
        ads["timestamp_port"], kvt.Timestamp(1000000000, 10), "timestamp_port"
    )

    ads._add_string_vector(
        "vector_string_port", adapter_data_set.VectorString(["element1", "element2"])
    )
    check_same_type(
        ads["vector_string_port"],
        adapter_data_set.VectorString(["element1", "element2"]),
        "vector_string_port",
    )
예제 #3
0
def _create_ads():
    from kwiver.vital import types as kvt
    from kwiver.sprokit.adapters import adapter_data_set

    ads = adapter_data_set.AdapterDataSet.create()

    # Construct a few elements
    ads["string_port"] = "string_value"
    ads["timestamp_port"] = kvt.Timestamp(1000000000, 10)
    ads["vector_string_port"] = adapter_data_set.VectorString(["element1", "element2"])

    return ads
예제 #4
0
def test_overwrite():
    from kwiver.vital import types as kvt
    from kwiver.sprokit.adapters import adapter_data_set

    OVERWRITE_PORT = "test_overwrite_port"
    ads = adapter_data_set.AdapterDataSet.create()

    # Overwriting with same datum
    ads.add_datum(OVERWRITE_PORT, datum.new("d2"))
    overwrite_helper(
        ads.add_datum,
        ads.get_port_data,
        datum.new("d3"),
        "datum_string",
        OVERWRITE_PORT,
    )

    # Overwriting with completely different types
    overwrite_helper(
        ads.add_datum, ads.get_port_data, datum.new(12), "datum_int", OVERWRITE_PORT
    )
    overwrite_helper(
        ads._add_string_vector,
        ads._get_port_data_string_vector,
        adapter_data_set.VectorString(["baz", "qux"]),
        "string_vector",
        OVERWRITE_PORT,
    )
    overwrite_helper(
        ads._add_timestamp,
        ads._get_port_data_timestamp,
        kvt.Timestamp(100, 10),
        "timestamp",
        OVERWRITE_PORT,
    )
    overwrite_helper(ads.add_value, ads.get_port_data, 15, "int", OVERWRITE_PORT)
    overwrite_helper(
        ads._add_double_vector,
        ads._get_port_data_double_vector,
        adapter_data_set.VectorDouble([4, 8]),
        "double_vector",
        OVERWRITE_PORT,
    )