How to use the vortexasdk.endpoints.vessels.Vessels function in vortexasdk

To help you get started, we’ve selected a few vortexasdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github V0RT3X4 / python-sdk / tests / endpoints / test_vessels_real.py View on Github external
def test_find_crude_vessels(self):
        df = Vessels().search(vessel_product_types="crude").to_df()
        assert len(df) > 1000
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels_real.py View on Github external
def test_search_ids(self):
        ids = [
            "6d8a8f0863ca087204dd68e5fc3b6469a879829e6262856e34856aea3ca20509",
            "bf2b55bd31c709aa4cba91a3cc4111191c88c83753cbd285674c22150e42003e",
        ]

        vessels = Vessels().search(ids=ids).to_list()
        assert len(vessels) == 2

        print([x.name for x in vessels])
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels_real.py View on Github external
def test_search_load_all_vessels(self):
        with Timer("Search"):
            result = Vessels().search()

        with Timer("Serialize"):
            result.to_list()

        with Timer("Dataframe"):
            df = result.to_df()
            print(df.head())

        assert len(result) >= 1_000
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels.py View on Github external
def test_convert_to_df(self):
        df = Vessels().search().to_df()
        assert len(df) > 0
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels_real.py View on Github external
def test_search_ids_dataframe(self):
        ids = [
            "6d8a8f0863ca087204dd68e5fc3b6469a879829e6262856e34856aea3ca20509",
            "bf2b55bd31c709aa4cba91a3cc4111191c88c83753cbd285674c22150e42003e",
        ]

        df = Vessels().search(ids=ids).to_df()
        assert list(df.columns) == ["id", "name", "imo", "vessel_class"]
        assert len(df) == 2
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels_real.py View on Github external
def test_search_terms_are_combined_with_AND(self):
        aframax = set(
            v.id for v in Vessels().search(vessel_classes="aframax").to_list()
        )
        aframax_called_zhen = set(
            v.id
            for v in Vessels()
            .search(vessel_classes="aframax", term="zhen")
            .to_list()
        )

        assert aframax_called_zhen.issubset(aframax)
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels_real.py View on Github external
def test_search_filters_vessel_class(self):
        vessel_classes = ["vlcc_plus", "aframax"]

        vessels = Vessels().search(vessel_classes=vessel_classes).to_list()

        actual = {x.vessel_class for x in vessels}

        assert actual == set(vessel_classes)
github V0RT3X4 / python-sdk / tests / conversions / test_convert_vessels.py View on Github external
def test_convert_class_to_vessel_ids(self):
        set_client(create_client())

        result = convert_to_vessel_ids(["panamax"])

        assert result == [
            v.id for v in Vessels().search(vessel_classes="panamax").to_list()
        ]
github V0RT3X4 / python-sdk / tests / endpoints / test_vessels.py View on Github external
def test_search_ids_retreives_names(self):
        vessels = Vessels().search().to_list()

        names = [x.name for x in vessels]

        assert names == ["0", "058"]
github V0RT3X4 / python-sdk / vortexasdk / conversions / vessels.py View on Github external
```
    """

    vessel_attributes_list = convert_to_list(vessel_attributes)
    ids, others = split_ids_other(vessel_attributes_list)

    vessel_classes = []
    names_imos_mmsis = []
    for e in others:
        if _is_vessel_class(e):
            vessel_classes.append(e)
        else:
            names_imos_mmsis.append(e)

    vessels_matched_on_vessel_class = (
        _search_ids(Vessels(), vessel_classes=vessel_classes)
        if len(vessel_classes) > 0
        else []
    )

    vessels_matched_on_name_imo_mmsi = (
        _search_ids(Vessels(), term=names_imos_mmsis)
        if len(names_imos_mmsis) > 0
        else []
    )

    return (
        ids
        + vessels_matched_on_vessel_class
        + vessels_matched_on_name_imo_mmsi
    )