Skip to content

Commit 02a5259

Browse files
committed
Add regression test for ndarray parameters
1 parent 6563bd9 commit 02a5259

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/test_issue.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import annotations
22

3+
import pytest
4+
35
try:
46
from tools.python_api.test.type_aliases import ConnDB
57
except ImportError:
@@ -129,6 +131,27 @@ def test_int8_type_sniffing(conn_db_readwrite: ConnDB) -> None:
129131
result.close()
130132

131133

134+
def test_issue_483_numpy_ndarray_parameter(conn_db_readwrite: ConnDB) -> None:
135+
np = pytest.importorskip("numpy")
136+
137+
conn, _ = conn_db_readwrite
138+
conn.execute("CREATE NODE TABLE T(id INT64, v FLOAT[3], PRIMARY KEY(id))")
139+
conn.execute("CREATE (:T {id: 1})")
140+
141+
arr = np.array([0.1, 0.2, 0.3], dtype=np.float32)
142+
result = conn.execute(
143+
"MATCH (n:T {id: 1}) SET n.v = $v RETURN n.v",
144+
{"v": arr},
145+
)
146+
147+
assert result.has_next()
148+
assert result.get_next() == [
149+
[pytest.approx(0.1), pytest.approx(0.2), pytest.approx(0.3)]
150+
]
151+
assert not result.has_next()
152+
result.close()
153+
154+
132155
# TODO(Maxwell): check if we should change getCastCost() for the following test
133156
# def test_issue_3248(conn_db_readwrite: ConnDB) -> None:
134157
# conn, _ = conn_db_readwrite

0 commit comments

Comments
 (0)