real-ladybug 0.0.1.dev1__cp312-cp312-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of real-ladybug might be problematic. Click here for more details.

Files changed (114) hide show
  1. real_ladybug/__init__.py +83 -0
  2. real_ladybug/_lbug.cp312-win_amd64.pyd +0 -0
  3. real_ladybug/_lbug.exp +0 -0
  4. real_ladybug/_lbug.lib +0 -0
  5. real_ladybug/async_connection.py +226 -0
  6. real_ladybug/connection.py +323 -0
  7. real_ladybug/constants.py +7 -0
  8. real_ladybug/database.py +307 -0
  9. real_ladybug/prepared_statement.py +51 -0
  10. real_ladybug/py.typed +0 -0
  11. real_ladybug/query_result.py +511 -0
  12. real_ladybug/torch_geometric_feature_store.py +185 -0
  13. real_ladybug/torch_geometric_graph_store.py +131 -0
  14. real_ladybug/torch_geometric_result_converter.py +282 -0
  15. real_ladybug/types.py +39 -0
  16. real_ladybug-0.0.1.dev1.dist-info/METADATA +88 -0
  17. real_ladybug-0.0.1.dev1.dist-info/RECORD +114 -0
  18. real_ladybug-0.0.1.dev1.dist-info/WHEEL +5 -0
  19. real_ladybug-0.0.1.dev1.dist-info/licenses/LICENSE +21 -0
  20. real_ladybug-0.0.1.dev1.dist-info/top_level.txt +3 -0
  21. real_ladybug-0.0.1.dev1.dist-info/zip-safe +1 -0
  22. real_ladybug-source/scripts/antlr4/hash.py +2 -0
  23. real_ladybug-source/scripts/antlr4/keywordhandler.py +47 -0
  24. real_ladybug-source/scripts/collect-extensions.py +68 -0
  25. real_ladybug-source/scripts/collect-single-file-header.py +126 -0
  26. real_ladybug-source/scripts/export-dbs.py +101 -0
  27. real_ladybug-source/scripts/export-import-test.py +345 -0
  28. real_ladybug-source/scripts/extension/purge-beta.py +34 -0
  29. real_ladybug-source/scripts/generate-cpp-docs/collect_files.py +122 -0
  30. real_ladybug-source/scripts/generate-tinysnb.py +34 -0
  31. real_ladybug-source/scripts/get-clangd-diagnostics.py +233 -0
  32. real_ladybug-source/scripts/migrate-lbug-db.py +308 -0
  33. real_ladybug-source/scripts/multiplatform-test-helper/collect-results.py +71 -0
  34. real_ladybug-source/scripts/multiplatform-test-helper/notify-discord.py +68 -0
  35. real_ladybug-source/scripts/pip-package/package_tar.py +90 -0
  36. real_ladybug-source/scripts/pip-package/setup.py +130 -0
  37. real_ladybug-source/scripts/run-clang-format.py +408 -0
  38. real_ladybug-source/scripts/setup-extension-repo.py +67 -0
  39. real_ladybug-source/scripts/test-simsimd-dispatch.py +45 -0
  40. real_ladybug-source/scripts/update-nightly-build-version.py +81 -0
  41. real_ladybug-source/third_party/brotli/scripts/dictionary/step-01-download-rfc.py +16 -0
  42. real_ladybug-source/third_party/brotli/scripts/dictionary/step-02-rfc-to-bin.py +34 -0
  43. real_ladybug-source/third_party/brotli/scripts/dictionary/step-03-validate-bin.py +35 -0
  44. real_ladybug-source/third_party/brotli/scripts/dictionary/step-04-generate-java-literals.py +85 -0
  45. real_ladybug-source/third_party/pybind11/tools/codespell_ignore_lines_from_errors.py +35 -0
  46. real_ladybug-source/third_party/pybind11/tools/libsize.py +36 -0
  47. real_ladybug-source/third_party/pybind11/tools/make_changelog.py +63 -0
  48. real_ladybug-source/tools/python_api/build/real_ladybug/__init__.py +83 -0
  49. real_ladybug-source/tools/python_api/build/real_ladybug/async_connection.py +226 -0
  50. real_ladybug-source/tools/python_api/build/real_ladybug/connection.py +323 -0
  51. real_ladybug-source/tools/python_api/build/real_ladybug/constants.py +7 -0
  52. real_ladybug-source/tools/python_api/build/real_ladybug/database.py +307 -0
  53. real_ladybug-source/tools/python_api/build/real_ladybug/prepared_statement.py +51 -0
  54. real_ladybug-source/tools/python_api/build/real_ladybug/py.typed +0 -0
  55. real_ladybug-source/tools/python_api/build/real_ladybug/query_result.py +511 -0
  56. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_feature_store.py +185 -0
  57. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_graph_store.py +131 -0
  58. real_ladybug-source/tools/python_api/build/real_ladybug/torch_geometric_result_converter.py +282 -0
  59. real_ladybug-source/tools/python_api/build/real_ladybug/types.py +39 -0
  60. real_ladybug-source/tools/python_api/src_py/__init__.py +83 -0
  61. real_ladybug-source/tools/python_api/src_py/async_connection.py +226 -0
  62. real_ladybug-source/tools/python_api/src_py/connection.py +323 -0
  63. real_ladybug-source/tools/python_api/src_py/constants.py +7 -0
  64. real_ladybug-source/tools/python_api/src_py/database.py +307 -0
  65. real_ladybug-source/tools/python_api/src_py/prepared_statement.py +51 -0
  66. real_ladybug-source/tools/python_api/src_py/py.typed +0 -0
  67. real_ladybug-source/tools/python_api/src_py/query_result.py +511 -0
  68. real_ladybug-source/tools/python_api/src_py/torch_geometric_feature_store.py +185 -0
  69. real_ladybug-source/tools/python_api/src_py/torch_geometric_graph_store.py +131 -0
  70. real_ladybug-source/tools/python_api/src_py/torch_geometric_result_converter.py +282 -0
  71. real_ladybug-source/tools/python_api/src_py/types.py +39 -0
  72. real_ladybug-source/tools/python_api/test/conftest.py +230 -0
  73. real_ladybug-source/tools/python_api/test/disabled_test_extension.py +73 -0
  74. real_ladybug-source/tools/python_api/test/ground_truth.py +430 -0
  75. real_ladybug-source/tools/python_api/test/test_arrow.py +694 -0
  76. real_ladybug-source/tools/python_api/test/test_async_connection.py +159 -0
  77. real_ladybug-source/tools/python_api/test/test_blob_parameter.py +145 -0
  78. real_ladybug-source/tools/python_api/test/test_connection.py +49 -0
  79. real_ladybug-source/tools/python_api/test/test_database.py +234 -0
  80. real_ladybug-source/tools/python_api/test/test_datatype.py +372 -0
  81. real_ladybug-source/tools/python_api/test/test_df.py +564 -0
  82. real_ladybug-source/tools/python_api/test/test_dict.py +112 -0
  83. real_ladybug-source/tools/python_api/test/test_exception.py +54 -0
  84. real_ladybug-source/tools/python_api/test/test_fsm.py +227 -0
  85. real_ladybug-source/tools/python_api/test/test_get_header.py +49 -0
  86. real_ladybug-source/tools/python_api/test/test_helper.py +8 -0
  87. real_ladybug-source/tools/python_api/test/test_issue.py +147 -0
  88. real_ladybug-source/tools/python_api/test/test_iteration.py +96 -0
  89. real_ladybug-source/tools/python_api/test/test_networkx.py +437 -0
  90. real_ladybug-source/tools/python_api/test/test_parameter.py +340 -0
  91. real_ladybug-source/tools/python_api/test/test_prepared_statement.py +117 -0
  92. real_ladybug-source/tools/python_api/test/test_query_result.py +54 -0
  93. real_ladybug-source/tools/python_api/test/test_query_result_close.py +44 -0
  94. real_ladybug-source/tools/python_api/test/test_scan_pandas.py +676 -0
  95. real_ladybug-source/tools/python_api/test/test_scan_pandas_pyarrow.py +714 -0
  96. real_ladybug-source/tools/python_api/test/test_scan_polars.py +165 -0
  97. real_ladybug-source/tools/python_api/test/test_scan_pyarrow.py +167 -0
  98. real_ladybug-source/tools/python_api/test/test_timeout.py +11 -0
  99. real_ladybug-source/tools/python_api/test/test_torch_geometric.py +640 -0
  100. real_ladybug-source/tools/python_api/test/test_torch_geometric_remote_backend.py +111 -0
  101. real_ladybug-source/tools/python_api/test/test_udf.py +207 -0
  102. real_ladybug-source/tools/python_api/test/test_version.py +6 -0
  103. real_ladybug-source/tools/python_api/test/test_wal.py +80 -0
  104. real_ladybug-source/tools/python_api/test/type_aliases.py +10 -0
  105. real_ladybug-source/tools/rust_api/update_version.py +47 -0
  106. real_ladybug-source/tools/shell/test/conftest.py +218 -0
  107. real_ladybug-source/tools/shell/test/test_helper.py +60 -0
  108. real_ladybug-source/tools/shell/test/test_shell_basics.py +325 -0
  109. real_ladybug-source/tools/shell/test/test_shell_commands.py +656 -0
  110. real_ladybug-source/tools/shell/test/test_shell_control_edit.py +438 -0
  111. real_ladybug-source/tools/shell/test/test_shell_control_search.py +468 -0
  112. real_ladybug-source/tools/shell/test/test_shell_esc_edit.py +232 -0
  113. real_ladybug-source/tools/shell/test/test_shell_esc_search.py +162 -0
  114. real_ladybug-source/tools/shell/test/test_shell_flags.py +645 -0
@@ -0,0 +1,640 @@
1
+ from __future__ import annotations
2
+
3
+ import warnings
4
+
5
+ import ground_truth
6
+ import torch
7
+ from type_aliases import ConnDB
8
+ from real_ladybug.constants import LABEL
9
+
10
+
11
+ def test_to_torch_geometric_nodes_only(conn_db_readonly: ConnDB) -> None:
12
+ conn, _ = conn_db_readonly
13
+ query = "MATCH (p:person) return p"
14
+
15
+ res = conn.execute(query)
16
+ with warnings.catch_warnings(record=True) as ws:
17
+ torch_geometric_data, pos_to_idx, unconverted_properties, _ = res.get_as_torch_geometric()
18
+ warnings_ground_truth = {
19
+ "Property person.courseScoresPerTerm cannot be converted to Tensor (likely due to nested list of variable length). The property is marked as unconverted.",
20
+ "Property person.height of type FLOAT is not supported by torch_geometric. The property is marked as unconverted.",
21
+ "Property person.u of type UUID is not supported by torch_geometric. The property is marked as unconverted.",
22
+ "Property person.lastJobDuration of type INTERVAL is not supported by torch_geometric. The property is marked as unconverted.",
23
+ "Property person.registerTime of type TIMESTAMP is not supported by torch_geometric. The property is marked as unconverted.",
24
+ "Property person.birthdate of type DATE is not supported by torch_geometric. The property is marked as unconverted.",
25
+ "Property person.fName of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
26
+ "Property person.workedHours has an inconsistent shape. The property is marked as unconverted.",
27
+ "Property person.usedNames of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
28
+ }
29
+ assert len(ws) == 9
30
+ for w in ws:
31
+ assert str(w.message) in warnings_ground_truth
32
+
33
+ assert torch_geometric_data.ID.shape == torch.Size([8])
34
+ assert torch_geometric_data.ID.dtype == torch.int64
35
+ for i in range(8):
36
+ assert ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["ID"] == torch_geometric_data.ID[i].item()
37
+
38
+ assert torch_geometric_data.gender.shape == torch.Size([8])
39
+ assert torch_geometric_data.gender.dtype == torch.int64
40
+ for i in range(8):
41
+ assert (
42
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["gender"]
43
+ == torch_geometric_data.gender[i].item()
44
+ )
45
+
46
+ assert torch_geometric_data.isStudent.shape == torch.Size([8])
47
+ assert torch_geometric_data.isStudent.dtype == torch.bool
48
+ for i in range(8):
49
+ assert (
50
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["isStudent"]
51
+ == torch_geometric_data.isStudent[i].item()
52
+ )
53
+
54
+ assert torch_geometric_data.isWorker.shape == torch.Size([8])
55
+ assert torch_geometric_data.isWorker.dtype == torch.bool
56
+ for i in range(8):
57
+ assert (
58
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["isWorker"]
59
+ == torch_geometric_data.isWorker[i].item()
60
+ )
61
+
62
+ assert torch_geometric_data.age.shape == torch.Size([8])
63
+ assert torch_geometric_data.age.dtype == torch.int64
64
+ for i in range(8):
65
+ assert ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["age"] == torch_geometric_data.age[i].item()
66
+
67
+ assert torch_geometric_data.eyeSight.shape == torch.Size([8])
68
+ assert torch_geometric_data.eyeSight.dtype == torch.float32
69
+ for i in range(8):
70
+ assert (
71
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["eyeSight"]
72
+ - torch_geometric_data.eyeSight[i].item()
73
+ < 1e-6
74
+ )
75
+
76
+ assert len(unconverted_properties) == 9
77
+ assert "courseScoresPerTerm" in unconverted_properties
78
+ for i in range(8):
79
+ assert (
80
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["courseScoresPerTerm"]
81
+ == unconverted_properties["courseScoresPerTerm"][i]
82
+ )
83
+ assert "lastJobDuration" in unconverted_properties
84
+ for i in range(8):
85
+ assert (
86
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["lastJobDuration"]
87
+ == unconverted_properties["lastJobDuration"][i]
88
+ )
89
+ assert "registerTime" in unconverted_properties
90
+ for i in range(8):
91
+ assert (
92
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["registerTime"]
93
+ == unconverted_properties["registerTime"][i]
94
+ )
95
+ assert "birthdate" in unconverted_properties
96
+ for i in range(8):
97
+ assert (
98
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["birthdate"]
99
+ == unconverted_properties["birthdate"][i]
100
+ )
101
+ assert "fName" in unconverted_properties
102
+ for i in range(8):
103
+ assert ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["fName"] == unconverted_properties["fName"][i]
104
+ assert "usedNames" in unconverted_properties
105
+ for i in range(8):
106
+ assert (
107
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["usedNames"]
108
+ == unconverted_properties["usedNames"][i]
109
+ )
110
+
111
+ assert "workedHours" in unconverted_properties
112
+ for i in range(8):
113
+ assert (
114
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["workedHours"]
115
+ == unconverted_properties["workedHours"][i]
116
+ )
117
+
118
+
119
+ def test_to_torch_geometric_homogeneous_graph(conn_db_readonly: ConnDB) -> None:
120
+ conn, _ = conn_db_readonly
121
+ query = "MATCH (p:person)-[r:knows]->(q:person) RETURN p, r, q"
122
+
123
+ res = conn.execute(query)
124
+ with warnings.catch_warnings(record=True) as ws:
125
+ torch_geometric_data, pos_to_idx, unconverted_properties, edge_properties = res.get_as_torch_geometric()
126
+ warnings_ground_truth = {
127
+ "Property person.courseScoresPerTerm cannot be converted to Tensor (likely due to nested list of variable length). The property is marked as unconverted.",
128
+ "Property person.height of type FLOAT is not supported by torch_geometric. The property is marked as unconverted.",
129
+ "Property person.u of type UUID is not supported by torch_geometric. The property is marked as unconverted.",
130
+ "Property person.lastJobDuration of type INTERVAL is not supported by torch_geometric. The property is marked as unconverted.",
131
+ "Property person.registerTime of type TIMESTAMP is not supported by torch_geometric. The property is marked as unconverted.",
132
+ "Property person.birthdate of type DATE is not supported by torch_geometric. The property is marked as unconverted.",
133
+ "Property person.fName of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
134
+ "Property person.workedHours has an inconsistent shape. The property is marked as unconverted.",
135
+ "Property person.usedNames of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
136
+ }
137
+ assert len(ws) == 9
138
+ for w in ws:
139
+ assert str(w.message) in warnings_ground_truth
140
+
141
+ assert torch_geometric_data.ID.shape == torch.Size([7])
142
+ assert torch_geometric_data.ID.dtype == torch.int64
143
+ for i in range(7):
144
+ assert ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["ID"] == torch_geometric_data.ID[i].item()
145
+
146
+ assert torch_geometric_data.gender.shape == torch.Size([7])
147
+ assert torch_geometric_data.gender.dtype == torch.int64
148
+ for i in range(7):
149
+ assert (
150
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["gender"]
151
+ == torch_geometric_data.gender[i].item()
152
+ )
153
+
154
+ assert torch_geometric_data.isStudent.shape == torch.Size([7])
155
+ assert torch_geometric_data.isStudent.dtype == torch.bool
156
+ for i in range(7):
157
+ assert (
158
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["isStudent"]
159
+ == torch_geometric_data.isStudent[i].item()
160
+ )
161
+
162
+ assert torch_geometric_data.isWorker.shape == torch.Size([7])
163
+ assert torch_geometric_data.isWorker.dtype == torch.bool
164
+ for i in range(7):
165
+ assert (
166
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["isWorker"]
167
+ == torch_geometric_data.isWorker[i].item()
168
+ )
169
+
170
+ assert torch_geometric_data.age.shape == torch.Size([7])
171
+ assert torch_geometric_data.age.dtype == torch.int64
172
+ for i in range(7):
173
+ assert ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["age"] == torch_geometric_data.age[i].item()
174
+
175
+ assert torch_geometric_data.eyeSight.shape == torch.Size([7])
176
+ assert torch_geometric_data.eyeSight.dtype == torch.float32
177
+ for i in range(7):
178
+ assert (
179
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["eyeSight"]
180
+ - torch_geometric_data.eyeSight[i].item()
181
+ < 1e-6
182
+ )
183
+
184
+ assert len(unconverted_properties) == 9
185
+ assert "courseScoresPerTerm" in unconverted_properties
186
+ for i in range(7):
187
+ assert (
188
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["courseScoresPerTerm"]
189
+ == unconverted_properties["courseScoresPerTerm"][i]
190
+ )
191
+ assert "lastJobDuration" in unconverted_properties
192
+ for i in range(7):
193
+ assert (
194
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["lastJobDuration"]
195
+ == unconverted_properties["lastJobDuration"][i]
196
+ )
197
+ assert "registerTime" in unconverted_properties
198
+ for i in range(7):
199
+ assert (
200
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["registerTime"]
201
+ == unconverted_properties["registerTime"][i]
202
+ )
203
+ assert "birthdate" in unconverted_properties
204
+ for i in range(7):
205
+ assert (
206
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["birthdate"]
207
+ == unconverted_properties["birthdate"][i]
208
+ )
209
+ assert "fName" in unconverted_properties
210
+ for i in range(7):
211
+ assert ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["fName"] == unconverted_properties["fName"][i]
212
+ assert "usedNames" in unconverted_properties
213
+ for i in range(7):
214
+ assert (
215
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["usedNames"]
216
+ == unconverted_properties["usedNames"][i]
217
+ )
218
+
219
+ assert "workedHours" in unconverted_properties
220
+ for i in range(7):
221
+ assert (
222
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx[i]]["workedHours"]
223
+ == unconverted_properties["workedHours"][i]
224
+ )
225
+
226
+ assert torch_geometric_data.edge_index.shape == torch.Size([2, 14])
227
+ for i in range(14):
228
+ src, dst = torch_geometric_data.edge_index[0][i].item(), torch_geometric_data.edge_index[1][i].item()
229
+ assert src in pos_to_idx
230
+ assert dst in pos_to_idx
231
+ assert src != dst
232
+ assert pos_to_idx[dst] in ground_truth.TINY_SNB_KNOWS_GROUND_TRUTH[pos_to_idx[src]]
233
+
234
+ assert len(edge_properties) == 8
235
+ assert "date" in edge_properties
236
+ assert "meetTime" in edge_properties
237
+ assert "validInterval" in edge_properties
238
+ assert "comments" in edge_properties
239
+ assert "summary" in edge_properties
240
+ assert "notes" in edge_properties
241
+
242
+ for i in range(14):
243
+ src, dst = torch_geometric_data.edge_index[0][i].item(), torch_geometric_data.edge_index[1][i].item()
244
+ orginal_src = pos_to_idx[src]
245
+ orginal_dst = pos_to_idx[dst]
246
+ assert (orginal_src, orginal_dst) in ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH
247
+ assert (
248
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["date"]
249
+ == edge_properties["date"][i]
250
+ )
251
+ assert (
252
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["meetTime"]
253
+ == edge_properties["meetTime"][i]
254
+ )
255
+ assert (
256
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["validInterval"]
257
+ == edge_properties["validInterval"][i]
258
+ )
259
+ assert (
260
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["comments"]
261
+ == edge_properties["comments"][i]
262
+ )
263
+ assert (
264
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["summary"]
265
+ == edge_properties["summary"][i]
266
+ )
267
+ assert (
268
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["notes"]
269
+ == edge_properties["notes"][i]
270
+ )
271
+ assert (
272
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[orginal_src, orginal_dst]["someMap"]
273
+ == edge_properties["someMap"][i]
274
+ )
275
+
276
+
277
+ def test_to_torch_geometric_heterogeneous_graph(conn_db_readonly: ConnDB) -> None:
278
+ conn, _ = conn_db_readonly
279
+ query = "MATCH (p:person)-[r1:knows]->(q:person)-[r2:workAt]->(o:organisation) RETURN p, q, o, r1, r2"
280
+
281
+ res = conn.execute(query)
282
+ with warnings.catch_warnings(record=True) as ws:
283
+ torch_geometric_data, pos_to_idx, unconverted_properties, edge_properties = res.get_as_torch_geometric()
284
+
285
+ assert len(ws) == 13
286
+ warnings_ground_truth = {
287
+ "Property organisation.name of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
288
+ "Property person.height of type FLOAT is not supported by torch_geometric. The property is marked as unconverted.",
289
+ "Property person.u of type UUID is not supported by torch_geometric. The property is marked as unconverted.",
290
+ "Property person.courseScoresPerTerm cannot be converted to Tensor (likely due to nested list of variable length). The property is marked as unconverted.",
291
+ "Property person.lastJobDuration of type INTERVAL is not supported by torch_geometric. The property is marked as unconverted.",
292
+ "Property person.registerTime of type TIMESTAMP is not supported by torch_geometric. The property is marked as unconverted.",
293
+ "Property person.birthdate of type DATE is not supported by torch_geometric. The property is marked as unconverted.",
294
+ "Property person.fName of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
295
+ "Property organisation.history of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
296
+ "Property person.usedNames of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
297
+ "Property organisation.licenseValidInterval of type INTERVAL is not supported by torch_geometric. The property is marked as unconverted.",
298
+ "Property organisation.state of type STRUCT(revenue INT16, location STRING is not supported by torch_geometric. The property is marked as unconverted.",
299
+ "Property organisation.info of type UNION(price FLOAT, movein DATE, note STRING) is not supported by torch_geometric. The property is marked as unconverted.",
300
+ }
301
+
302
+ for w in ws:
303
+ assert str(w.message) in warnings_ground_truth
304
+
305
+ assert torch_geometric_data["person"].ID.shape == torch.Size([4])
306
+ assert torch_geometric_data["person"].ID.dtype == torch.int64
307
+ for i in range(4):
308
+ assert (
309
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["ID"]
310
+ == torch_geometric_data["person"].ID[i].item()
311
+ )
312
+
313
+ assert torch_geometric_data["person"].gender.shape == torch.Size([4])
314
+ assert torch_geometric_data["person"].gender.dtype == torch.int64
315
+ for i in range(4):
316
+ assert (
317
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["gender"]
318
+ == torch_geometric_data["person"].gender[i].item()
319
+ )
320
+
321
+ assert torch_geometric_data["person"].isStudent.shape == torch.Size([4])
322
+ assert torch_geometric_data["person"].isStudent.dtype == torch.bool
323
+ for i in range(4):
324
+ assert (
325
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["isStudent"]
326
+ == torch_geometric_data["person"].isStudent[i].item()
327
+ )
328
+
329
+ assert torch_geometric_data["person"].isWorker.shape == torch.Size([4])
330
+ assert torch_geometric_data["person"].isWorker.dtype == torch.bool
331
+ for i in range(4):
332
+ assert (
333
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["isWorker"]
334
+ == torch_geometric_data["person"].isWorker[i].item()
335
+ )
336
+
337
+ assert torch_geometric_data["person"].age.shape == torch.Size([4])
338
+ assert torch_geometric_data["person"].age.dtype == torch.int64
339
+ for i in range(4):
340
+ assert (
341
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["age"]
342
+ == torch_geometric_data["person"].age[i].item()
343
+ )
344
+
345
+ assert torch_geometric_data["person"].eyeSight.shape == torch.Size([4])
346
+ assert torch_geometric_data["person"].eyeSight.dtype == torch.float32
347
+ for i in range(4):
348
+ assert (
349
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["eyeSight"]
350
+ - torch_geometric_data["person"].eyeSight[i].item()
351
+ < 1e-6
352
+ )
353
+
354
+ assert "person" in unconverted_properties
355
+ assert len(unconverted_properties["person"]) == 8
356
+ assert "courseScoresPerTerm" in unconverted_properties["person"]
357
+ for i in range(4):
358
+ assert (
359
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["courseScoresPerTerm"]
360
+ == unconverted_properties["person"]["courseScoresPerTerm"][i]
361
+ )
362
+ assert "lastJobDuration" in unconverted_properties["person"]
363
+ for i in range(4):
364
+ assert (
365
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["lastJobDuration"]
366
+ == unconverted_properties["person"]["lastJobDuration"][i]
367
+ )
368
+ assert "registerTime" in unconverted_properties["person"]
369
+ for i in range(4):
370
+ assert (
371
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["registerTime"]
372
+ == unconverted_properties["person"]["registerTime"][i]
373
+ )
374
+ assert "birthdate" in unconverted_properties["person"]
375
+ for i in range(4):
376
+ assert (
377
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["birthdate"]
378
+ == unconverted_properties["person"]["birthdate"][i]
379
+ )
380
+ assert "fName" in unconverted_properties["person"]
381
+ for i in range(4):
382
+ assert (
383
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["fName"]
384
+ == unconverted_properties["person"]["fName"][i]
385
+ )
386
+ assert "usedNames" in unconverted_properties["person"]
387
+ for i in range(4):
388
+ assert (
389
+ ground_truth.TINY_SNB_PERSONS_GROUND_TRUTH[pos_to_idx["person"][i]]["usedNames"]
390
+ == unconverted_properties["person"]["usedNames"][i]
391
+ )
392
+
393
+ assert torch_geometric_data["person", "person"].edge_index.shape == torch.Size([2, 6])
394
+ for i in range(3):
395
+ src, dst = (
396
+ torch_geometric_data["person", "person"].edge_index[0][i].item(),
397
+ torch_geometric_data["person", "person"].edge_index[1][i].item(),
398
+ )
399
+ assert src in pos_to_idx["person"]
400
+ assert dst in pos_to_idx["person"]
401
+ assert src != dst
402
+ assert pos_to_idx["person"][dst] in ground_truth.TINY_SNB_KNOWS_GROUND_TRUTH[pos_to_idx["person"][src]]
403
+
404
+ assert len(edge_properties["person", "person"]) == 8
405
+ assert "date" in edge_properties["person", "person"]
406
+ assert "meetTime" in edge_properties["person", "person"]
407
+ assert "validInterval" in edge_properties["person", "person"]
408
+ assert "comments" in edge_properties["person", "person"]
409
+ assert "summary" in edge_properties["person", "person"]
410
+ assert "notes" in edge_properties["person", "person"]
411
+ assert LABEL in edge_properties["person", "person"]
412
+ for i in range(3):
413
+ src, dst = (
414
+ torch_geometric_data["person", "person"].edge_index[0][i].item(),
415
+ torch_geometric_data["person", "person"].edge_index[1][i].item(),
416
+ )
417
+ original_src, original_dst = pos_to_idx["person"][src], pos_to_idx["person"][dst]
418
+ assert (original_src, original_dst) in ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH
419
+ assert (
420
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["date"]
421
+ == edge_properties["person", "person"]["date"][i]
422
+ )
423
+ assert (
424
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["meetTime"]
425
+ == edge_properties["person", "person"]["meetTime"][i]
426
+ )
427
+ assert (
428
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["validInterval"]
429
+ == edge_properties["person", "person"]["validInterval"][i]
430
+ )
431
+ assert (
432
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["comments"]
433
+ == edge_properties["person", "person"]["comments"][i]
434
+ )
435
+ assert (
436
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["summary"]
437
+ == edge_properties["person", "person"]["summary"][i]
438
+ )
439
+ assert (
440
+ ground_truth.TINY_SNB_KNOWS_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["notes"]
441
+ == edge_properties["person", "person"]["notes"][i]
442
+ )
443
+ assert edge_properties["person", "person"][LABEL][i] == "knows"
444
+
445
+ assert torch_geometric_data["organisation"].ID.shape == torch.Size([2])
446
+ assert torch_geometric_data["organisation"].ID.dtype == torch.int64
447
+ for i in range(2):
448
+ assert (
449
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["ID"]
450
+ == torch_geometric_data["organisation"].ID[i].item()
451
+ )
452
+
453
+ assert torch_geometric_data["organisation"].orgCode.shape == torch.Size([2])
454
+ assert torch_geometric_data["organisation"].orgCode.dtype == torch.int64
455
+ for i in range(2):
456
+ assert (
457
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["orgCode"]
458
+ == torch_geometric_data["organisation"].orgCode[i].item()
459
+ )
460
+
461
+ assert torch_geometric_data["organisation"].mark.shape == torch.Size([2])
462
+ assert torch_geometric_data["organisation"].mark.dtype == torch.float32
463
+ for i in range(2):
464
+ assert (
465
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["mark"]
466
+ - torch_geometric_data["organisation"].mark[i].item()
467
+ < 1e-6
468
+ )
469
+
470
+ assert torch_geometric_data["organisation"].score.shape == torch.Size([2])
471
+ assert torch_geometric_data["organisation"].score.dtype == torch.int64
472
+ for i in range(2):
473
+ assert (
474
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["score"]
475
+ - torch_geometric_data["organisation"].score[i].item()
476
+ < 1e-6
477
+ )
478
+
479
+ assert torch_geometric_data["organisation"].rating.shape == torch.Size([2])
480
+ assert torch_geometric_data["organisation"].rating.dtype == torch.float32
481
+ for i in range(2):
482
+ assert (
483
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["rating"]
484
+ - torch_geometric_data["organisation"].rating[i].item()
485
+ < 1e-6
486
+ )
487
+
488
+ assert "organisation" in unconverted_properties
489
+ assert len(unconverted_properties["organisation"]) == 5
490
+ assert "name" in unconverted_properties["organisation"]
491
+ for i in range(2):
492
+ assert (
493
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["name"]
494
+ == unconverted_properties["organisation"]["name"][i]
495
+ )
496
+
497
+ assert "history" in unconverted_properties["organisation"]
498
+ for i in range(2):
499
+ assert (
500
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["history"]
501
+ == unconverted_properties["organisation"]["history"][i]
502
+ )
503
+
504
+ assert "licenseValidInterval" in unconverted_properties["organisation"]
505
+ for i in range(2):
506
+ assert (
507
+ ground_truth.TINY_SNB_ORGANISATIONS_GROUND_TRUTH[pos_to_idx["organisation"][i]]["licenseValidInterval"]
508
+ == unconverted_properties["organisation"]["licenseValidInterval"][i]
509
+ )
510
+
511
+ assert torch_geometric_data["person", "organisation"].edge_index.shape == torch.Size([2, 2])
512
+ for i in range(2):
513
+ src, dst = (
514
+ torch_geometric_data["person", "organisation"].edge_index[0][i].item(),
515
+ torch_geometric_data["person", "organisation"].edge_index[1][i].item(),
516
+ )
517
+ assert src in pos_to_idx["person"]
518
+ assert dst in pos_to_idx["organisation"]
519
+ assert src != dst
520
+ assert (
521
+ pos_to_idx["organisation"][dst] in ground_truth.TINY_SNB_WORKS_AT_GROUND_TRUTH[pos_to_idx["person"][src]]
522
+ )
523
+ assert len(edge_properties["person", "organisation"]) == 4
524
+ assert "year" in edge_properties["person", "organisation"]
525
+ assert LABEL in edge_properties["person", "organisation"]
526
+ for i in range(2):
527
+ src, dst = (
528
+ torch_geometric_data["person", "organisation"].edge_index[0][i].item(),
529
+ torch_geometric_data["person", "organisation"].edge_index[1][i].item(),
530
+ )
531
+ original_src, original_dst = pos_to_idx["person"][src], pos_to_idx["organisation"][dst]
532
+ assert (
533
+ ground_truth.TINY_SNB_WORKS_AT_PROPERTIES_GROUND_TRUTH[original_src, original_dst]["year"]
534
+ == edge_properties["person", "organisation"]["year"][i]
535
+ )
536
+ assert edge_properties["person", "organisation"][LABEL][i] == "workAt"
537
+
538
+
539
+ def test_to_torch_geometric_multi_dimensional_lists(
540
+ conn_db_readonly: ConnDB,
541
+ ) -> None:
542
+ conn, _ = conn_db_readonly
543
+ query = "MATCH (t:tensor) RETURN t"
544
+
545
+ res = conn.execute(query)
546
+ with warnings.catch_warnings(record=True) as ws:
547
+ torch_geometric_data, pos_to_idx, unconverted_properties, _ = res.get_as_torch_geometric()
548
+ assert len(ws) == 1
549
+ assert (
550
+ str(ws[0].message)
551
+ == "Property tensor.oneDimInt has a null value. torch_geometric does not support null values. The property is marked as unconverted."
552
+ )
553
+
554
+ bool_list = []
555
+ float_list = []
556
+ int_list = []
557
+
558
+ for i in range(len(pos_to_idx)):
559
+ idx = pos_to_idx[i]
560
+ bool_list.append(ground_truth.TENSOR_LIST_GROUND_TRUTH[idx]["boolTensor"])
561
+ float_list.append(ground_truth.TENSOR_LIST_GROUND_TRUTH[idx]["doubleTensor"])
562
+ int_list.append(ground_truth.TENSOR_LIST_GROUND_TRUTH[idx]["intTensor"])
563
+
564
+ bool_tensor = torch.tensor(bool_list, dtype=torch.bool)
565
+ float_tensor = torch.tensor(float_list, dtype=torch.float32)
566
+ int_tensor = torch.tensor(int_list, dtype=torch.int64)
567
+
568
+ assert torch_geometric_data.ID.shape == torch.Size([len(pos_to_idx)])
569
+ assert torch_geometric_data.ID.dtype == torch.int64
570
+ for i in range(len(pos_to_idx)):
571
+ assert torch_geometric_data.ID[i].item() == pos_to_idx[i]
572
+
573
+ assert torch_geometric_data.boolTensor.shape == bool_tensor.shape
574
+ assert torch_geometric_data.boolTensor.dtype == bool_tensor.dtype
575
+ assert torch.all(torch_geometric_data.boolTensor == bool_tensor)
576
+
577
+ assert torch_geometric_data.doubleTensor.shape == float_tensor.shape
578
+ assert torch_geometric_data.doubleTensor.dtype == float_tensor.dtype
579
+ assert torch.all(torch_geometric_data.doubleTensor == float_tensor)
580
+
581
+ assert torch_geometric_data.intTensor.shape == int_tensor.shape
582
+ assert torch_geometric_data.intTensor.dtype == int_tensor.dtype
583
+ assert torch.all(torch_geometric_data.intTensor == int_tensor)
584
+
585
+ assert len(unconverted_properties) == 1
586
+ assert "oneDimInt" in unconverted_properties
587
+ assert len(unconverted_properties["oneDimInt"]) == 6
588
+ assert unconverted_properties["oneDimInt"] == [1, 2, None, None, 5, 6]
589
+
590
+
591
+ def test_to_torch_geometric_no_properties_converted(
592
+ conn_db_readonly: ConnDB,
593
+ ) -> None:
594
+ conn, _ = conn_db_readonly
595
+ query = "MATCH (p:personLongString)-[r:knowsLongString]->(q:personLongString) RETURN p, r, q"
596
+
597
+ res = conn.execute(query)
598
+ with warnings.catch_warnings(record=True) as ws:
599
+ torch_geometric_data, pos_to_idx, unconverted_properties, _ = res.get_as_torch_geometric()
600
+ assert len(ws) == 3
601
+ warnings_ground_truth = {
602
+ "Property personLongString.name of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
603
+ "Property personLongString.spouse of type STRING is not supported by torch_geometric. The property is marked as unconverted.",
604
+ "No nodes found or all node properties are not converted.",
605
+ }
606
+ for w in ws:
607
+ assert str(w.message) in warnings_ground_truth
608
+ assert torch_geometric_data["personLongString"] == {}
609
+ assert torch_geometric_data["personLongString", "personLongString"].edge_index.shape == torch.Size([2, 1])
610
+
611
+ for i in range(1):
612
+ src, dst = (
613
+ torch_geometric_data["personLongString", "personLongString"].edge_index[0][i].item(),
614
+ torch_geometric_data["personLongString", "personLongString"].edge_index[1][i].item(),
615
+ )
616
+ assert src in pos_to_idx["personLongString"]
617
+ assert dst in pos_to_idx["personLongString"]
618
+ assert src != dst
619
+ assert (
620
+ pos_to_idx["personLongString"][dst]
621
+ in ground_truth.PERSONLONGSTRING_KNOWS_GROUND_TRUTH[pos_to_idx["personLongString"][src]]
622
+ )
623
+
624
+ assert len(unconverted_properties) == 1
625
+ assert len(unconverted_properties["personLongString"]) == 2
626
+
627
+ assert "spouse" in unconverted_properties["personLongString"]
628
+ assert len(unconverted_properties["personLongString"]["spouse"]) == 2
629
+ for i in range(2):
630
+ assert (
631
+ ground_truth.PERSONLONGSTRING_GROUND_TRUTH[pos_to_idx["personLongString"][i]]["spouse"]
632
+ == unconverted_properties["personLongString"]["spouse"][i]
633
+ )
634
+
635
+ assert "name" in unconverted_properties["personLongString"]
636
+ for i in range(2):
637
+ assert (
638
+ ground_truth.PERSONLONGSTRING_GROUND_TRUTH[pos_to_idx["personLongString"][i]]["name"]
639
+ == unconverted_properties["personLongString"]["name"][i]
640
+ )