def test_persist_and_load(self, node_embeddings: List[TextNode]) -> None:
        """Test persisting and loading from faiss map vector store."""
        vector_store = FaissMapVectorStore(faiss_index=get_map_index())

        # Add nodes to the faiss map vector
        vector_store.add(node_embeddings)

        query = VectorStoreQuery(
            query_embedding=text_to_embedding("baz"),
            similarity_top_k=1,
        )
        result = vector_store.query(query)
        assert result.similarities[0] == 0.0
        assert result.ids[0] == "469e9537-7bc5-4669-9ff6-baa0ed086236"

        # Persist the vector store
        vector_store.persist()

        # Load the vector store
        loaded_vector_store = FaissMapVectorStore.from_persist_dir()

        assert (
            loaded_vector_store._node_id_to_faiss_id_map
            == vector_store._node_id_to_faiss_id_map
        )
        assert (
            loaded_vector_store._faiss_id_to_node_id_map
            == vector_store._faiss_id_to_node_id_map
        )

        # query from loaded vector store
        query = VectorStoreQuery(
            query_embedding=text_to_embedding("baz"),
            similarity_top_k=1,
        )
        result = loaded_vector_store.query(query)
        assert result.similarities[0] == 0.0
        assert result.ids[0] == "469e9537-7bc5-4669-9ff6-baa0ed086236"

        # delete from original vector store
        vector_store.delete(
            ref_doc_id="469e9537-7bc5-4669-9ff6-baa0ed086236",
        )

        assert (
            loaded_vector_store._node_id_to_faiss_id_map
            != vector_store._node_id_to_faiss_id_map
        )
        assert (
            loaded_vector_store._faiss_id_to_node_id_map
            != vector_store._faiss_id_to_node_id_map
        )

        # query from loaded vector store without delete
        result = loaded_vector_store.query(query)
        assert result.similarities[0] == 0.0
        assert result.ids[0] == "469e9537-7bc5-4669-9ff6-baa0ed086236"
Test persisting and loading from faiss map vector store.
llama-index-integrations/vector_stores/llama-index-vector-stores-faiss/tests/test_vector_stores_faiss.py