Skip to content

Commit

Permalink
fix to_pyvis and tests (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
shivamka1 authored Apr 16, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 633c7c2 commit 04a8e0f
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion python/tests/test_graphdb.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,8 @@
from pytest import fixture
import os
import shutil

import numpy as np

base_dir = Path(__file__).parent
edges = [(1, 1, 2), (2, 1, 3), (-1, 2, 1), (0, 1, 1), (7, 3, 2), (1, 1, 1)]
utc = timezone.utc
@@ -2049,6 +2050,21 @@ def test_is_self_loop():
ee = g.add_edge(0, "A", "B", None, None)
assert not ee.is_self_loop()

def test_NaN_NaT_as_properties():
now = datetime.now()
data = {
'floats': [np.NaN, None, 2.4, None, None, None],
'time': [10, 20, 30, 40, 50, 60],
'id': [101, 102, 103, 104, 105, 106],
'datetime': [now, now, np.datetime64('NaT'), now, now, now] # Hardcoded datetime
}

df = pd.DataFrame(data)
g = Graph()
g.load_nodes_from_pandas(time='time', id = 'id', df=df, properties=['floats'])
assert g.node(103).properties.temporal.get('floats').items() == [(30, 2.4)]
assert g.node(101).properties.temporal.get('floats') == None


def test_fuzzy_search():
g = Graph()
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@ impl PyGraphView {
///
/// Returns:
/// A pyvis network
#[pyo3(signature = (explode_edges=false, edge_color="#000000", shape=None, node_image=None, edge_weight=None, edge_label=None, colour_nodes_by_type=false, notebook=true, **kwargs))]
#[pyo3(signature = (explode_edges=false, edge_color="#000000", shape=None, node_image=None, edge_weight=None, edge_label=None, colour_nodes_by_type=false, notebook=false, **kwargs))]
pub fn to_pyvis(
&self,
explode_edges: Option<bool>,

0 comments on commit 04a8e0f

Please sign in to comment.