You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_dataset.py 18 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. import os
  2. import pytest
  3. import numpy as np
  4. from fastNLP.core.dataset import DataSet, FieldArray, Instance, ApplyResultException
  5. class TestDataSetInit:
  6. """初始化DataSet的办法有以下几种:
  7. 1) 用dict:
  8. 1.1) 二维list DataSet({"x": [[1, 2], [3, 4]]})
  9. 1.2) 二维array DataSet({"x": np.array([[1, 2], [3, 4]])})
  10. 1.3) 三维list DataSet({"x": [[[1, 2], [3, 4]], [[1, 2], [3, 4]]]})
  11. 2) 用list of Instance:
  12. 2.1) 一维list DataSet([Instance(x=[1, 2, 3, 4])])
  13. 2.2) 一维array DataSet([Instance(x=np.array([1, 2, 3, 4]))])
  14. 2.3) 二维list DataSet([Instance(x=[[1, 2], [3, 4]])])
  15. 2.4) 二维array DataSet([Instance(x=np.array([[1, 2], [3, 4]]))])
  16. 只接受纯list或者最外层ndarray
  17. """
  18. def test_init_v1(self):
  19. # 一维list
  20. ds = DataSet([Instance(x=[1, 2, 3, 4], y=[5, 6])] * 40)
  21. assert ("x" in ds.field_arrays and "y" in ds.field_arrays) == True
  22. assert ds.field_arrays["x"].content == [[1, 2, 3, 4], ] * 40
  23. assert ds.field_arrays["y"].content == [[5, 6], ] * 40
  24. def test_init_v2(self):
  25. # 用dict
  26. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  27. assert ("x" in ds.field_arrays and "y" in ds.field_arrays) == True
  28. assert ds.field_arrays["x"].content == [[1, 2, 3, 4], ] * 40
  29. assert ds.field_arrays["y"].content == [[5, 6], ] * 40
  30. def test_init_assert(self):
  31. with pytest.raises(AssertionError):
  32. _ = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 100})
  33. with pytest.raises(AssertionError):
  34. _ = DataSet([[1, 2, 3, 4]] * 10)
  35. with pytest.raises(ValueError):
  36. _ = DataSet(0.00001)
  37. class TestDataSetMethods:
  38. def test_append(self):
  39. dd = DataSet()
  40. for _ in range(3):
  41. dd.append(Instance(x=[1, 2, 3, 4], y=[5, 6]))
  42. assert len(dd) == 3
  43. assert dd.field_arrays["x"].content == [[1, 2, 3, 4]] * 3
  44. assert dd.field_arrays["y"].content == [[5, 6]] * 3
  45. def test_add_field(self):
  46. dd = DataSet()
  47. dd.add_field("x", [[1, 2, 3]] * 10)
  48. dd.add_field("y", [[1, 2, 3, 4]] * 10)
  49. dd.add_field("z", [[5, 6]] * 10)
  50. assert len(dd) == 10
  51. assert dd.field_arrays["x"].content == [[1, 2, 3]] * 10
  52. assert dd.field_arrays["y"].content == [[1, 2, 3, 4]] * 10
  53. assert dd.field_arrays["z"].content == [[5, 6]] * 10
  54. with pytest.raises(RuntimeError):
  55. dd.add_field("??", [[1, 2]] * 40)
  56. def test_delete_field(self):
  57. dd = DataSet()
  58. dd.add_field("x", [[1, 2, 3]] * 10)
  59. dd.add_field("y", [[1, 2, 3, 4]] * 10)
  60. dd.delete_field("x")
  61. assert ("x" in dd.field_arrays) == False
  62. assert "y" in dd.field_arrays
  63. def test_delete_instance(self):
  64. dd = DataSet()
  65. old_length = 2
  66. dd.add_field("x", [[1, 2, 3]] * old_length)
  67. dd.add_field("y", [[1, 2, 3, 4]] * old_length)
  68. dd.delete_instance(0)
  69. assert len(dd) == old_length - 1
  70. dd.delete_instance(0)
  71. assert len(dd) == old_length - 2
  72. def test_getitem(self):
  73. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  74. ins_1, ins_0 = ds[0], ds[1]
  75. assert isinstance(ins_1, Instance) and isinstance(ins_0, Instance) == True
  76. assert ins_1["x"] == [1, 2, 3, 4]
  77. assert ins_1["y"] == [5, 6]
  78. assert ins_0["x"] == [1, 2, 3, 4]
  79. assert ins_0["y"] == [5, 6]
  80. sub_ds = ds[:10]
  81. assert isinstance(sub_ds, DataSet) == True
  82. assert len(sub_ds) == 10
  83. sub_ds_1 = ds[[10, 0, 2, 3]]
  84. assert isinstance(sub_ds_1, DataSet) == True
  85. assert len(sub_ds_1) == 4
  86. field_array = ds['x']
  87. assert isinstance(field_array, FieldArray) == True
  88. assert len(field_array) == 40
  89. def test_setitem(self):
  90. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  91. ds.add_field('i', list(range(len(ds))))
  92. assert ds.get_field('i').content == list(range(len(ds)))
  93. import random
  94. random.shuffle(ds)
  95. import numpy as np
  96. np.random.shuffle(ds)
  97. assert ds.get_field('i').content != list(range(len(ds)))
  98. ins1 = ds[1]
  99. ds[2] = ds[1]
  100. assert ds[2]['x'] == ins1['x'] and ds[2]['y'] == ins1['y']
  101. def test_get_item_error(self):
  102. with pytest.raises(RuntimeError):
  103. ds = DataSet({"x": [[1, 2, 3, 4]] * 10, "y": [[5, 6]] * 10})
  104. _ = ds[40:]
  105. with pytest.raises(KeyError):
  106. ds = DataSet({"x": [[1, 2, 3, 4]] * 10, "y": [[5, 6]] * 10})
  107. _ = ds["kom"]
  108. def test_len_(self):
  109. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  110. assert len(ds) == 40
  111. ds = DataSet()
  112. assert len(ds) == 0
  113. def test_add_fieldarray(self):
  114. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  115. ds.add_fieldarray('z', FieldArray('z', [[7, 8]] * 40))
  116. assert ds['z'].content == [[7, 8]] * 40
  117. with pytest.raises(RuntimeError):
  118. ds.add_fieldarray('z', FieldArray('z', [[7, 8]] * 10))
  119. with pytest.raises(TypeError):
  120. ds.add_fieldarray('z', [1, 2, 4])
  121. def test_copy_field(self):
  122. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  123. ds.copy_field('x', 'z')
  124. assert ds['x'].content == ds['z'].content
  125. def test_has_field(self):
  126. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  127. assert ds.has_field('x') == True
  128. assert ds.has_field('z') == False
  129. def test_get_field(self):
  130. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  131. with pytest.raises(KeyError):
  132. ds.get_field('z')
  133. x_array = ds.get_field('x')
  134. assert x_array.content == [[1, 2, 3, 4]] * 40
  135. def test_get_all_fields(self):
  136. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  137. field_arrays = ds.get_all_fields()
  138. assert field_arrays["x"].content == [[1, 2, 3, 4]] * 40
  139. assert field_arrays['y'].content == [[5, 6]] * 40
  140. def test_get_field_names(self):
  141. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  142. field_names = ds.get_field_names()
  143. assert 'x' in field_names
  144. assert 'y' in field_names
  145. def test_apply(self):
  146. ds = DataSet({"x": [[1, 2, 3, 4]] * 4000, "y": [[5, 6]] * 4000})
  147. ds.apply(lambda ins: ins["x"][::-1], new_field_name="rx", progress_desc='rx')
  148. assert ("rx" in ds.field_arrays) == True
  149. assert ds.field_arrays["rx"].content[0] == [4, 3, 2, 1]
  150. ds.apply(lambda ins: len(ins["y"]), new_field_name="y", show_progress_bar=False)
  151. assert ds.field_arrays["y"].content[0] == 2
  152. res = ds.apply(lambda ins: len(ins["x"]), num_proc=0, progress_desc="len")
  153. assert (isinstance(res, list) and len(res) > 0) == True
  154. assert res[0] == 4
  155. ds.apply(lambda ins: (len(ins["x"]), "hahaha"), new_field_name="k")
  156. # expect no exception raised
  157. def test_apply_progress_bar(self):
  158. import time
  159. ds = DataSet({"x": [[1, 2, 3, 4]] * 400, "y": [[5, 6]] * 400})
  160. def do_nothing(ins):
  161. time.sleep(0.01)
  162. ds.apply(do_nothing, show_progress_bar=True, num_proc=0)
  163. ds.apply_field(do_nothing, field_name='x', show_progress_bar=True)
  164. def test_apply_cannot_modify_instance(self):
  165. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  166. def modify_inplace(instance):
  167. instance['words'] = 1
  168. ds.apply(modify_inplace)
  169. # with self.assertRaises(TypeError):
  170. # ds.apply(modify_inplace)
  171. def test_apply_more(self):
  172. T = DataSet({"a": [1, 2, 3], "b": [2, 4, 5]})
  173. func_1 = lambda x: {"c": x["a"] * 2, "d": x["a"] ** 2}
  174. func_2 = lambda x: {"c": x * 3, "d": x ** 3}
  175. def func_err_1(x):
  176. if x["a"] == 1:
  177. return {"e": x["a"] * 2, "f": x["a"] ** 2}
  178. else:
  179. return {"e": x["a"] * 2}
  180. def func_err_2(x):
  181. if x == 1:
  182. return {"e": x * 2, "f": x ** 2}
  183. else:
  184. return {"e": x * 2}
  185. T.apply_more(func_1)
  186. # print(T['c'][0, 1, 2])
  187. assert list(T["c"].content) == [2, 4, 6]
  188. assert list(T["d"].content) == [1, 4, 9]
  189. res = T.apply_field_more(func_2, "a", modify_fields=False)
  190. assert list(T["c"].content) == [2, 4, 6]
  191. assert list(T["d"].content) == [1, 4, 9]
  192. assert list(res["c"]) == [3, 6, 9]
  193. assert list(res["d"]) == [1, 8, 27]
  194. with pytest.raises(ApplyResultException) as e:
  195. T.apply_more(func_err_1)
  196. print(e)
  197. with pytest.raises(ApplyResultException) as e:
  198. T.apply_field_more(func_err_2, "a")
  199. print(e)
  200. def test_drop(self):
  201. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6], [7, 8, 9, 0]] * 20})
  202. ds.drop(lambda ins: len(ins["y"]) < 3, inplace=True)
  203. assert len(ds) == 20
  204. def test_contains(self):
  205. ds = DataSet({"x": [[1, 2, 3, 4]] * 40, "y": [[5, 6]] * 40})
  206. assert ("x" in ds) == True
  207. assert ("y" in ds) == True
  208. assert ("z" in ds) == False
  209. def test_rename_field(self):
  210. ds = DataSet({"x": [[1, 2, 3, 4]] * 10, "y": [[5, 6]] * 10})
  211. ds.rename_field("x", "xx")
  212. assert ("xx" in ds) == True
  213. assert ("x" in ds) == False
  214. with pytest.raises(KeyError):
  215. ds.rename_field("yyy", "oo")
  216. def test_split(self):
  217. ds = DataSet({"x": [[1, 2, 3, 4]] * 10, "y": [[5, 6]] * 10})
  218. d1, d2 = ds.split(0.1)
  219. assert len(d2) == (len(ds) * 0.9)
  220. assert len(d1) == (len(ds) * 0.1)
  221. def test_add_field_v2(self):
  222. ds = DataSet({"x": [3, 4]})
  223. ds.add_field('y', [['hello', 'world'], ['this', 'is', 'a', 'test']])
  224. # ds.apply(lambda x:[x['x']]*3, new_field_name='y')
  225. print(ds)
  226. def test_save_load(self):
  227. ds = DataSet({"x": [[1, 2, 3, 4]] * 10, "y": [[5, 6]] * 10})
  228. ds.save("./my_ds.pkl")
  229. assert os.path.exists("./my_ds.pkl") == True
  230. ds_1 = DataSet.load("./my_ds.pkl")
  231. os.remove("my_ds.pkl")
  232. def test_add_null(self):
  233. ds = DataSet()
  234. with pytest.raises(RuntimeError) as RE:
  235. ds.add_field('test', [])
  236. def test_concat(self):
  237. """
  238. 测试两个dataset能否正确concat
  239. """
  240. ds1 = DataSet({"x": [[1, 2, 3, 4] for _ in range(10)], "y": [[5, 6] for _ in range(10)]})
  241. ds2 = DataSet({"x": [[4, 3, 2, 1] for _ in range(10)], "y": [[6, 5] for _ in range(10)]})
  242. ds3 = ds1.concat(ds2)
  243. assert len(ds3) == 20
  244. assert ds1[9]['x'] == [1, 2, 3, 4]
  245. assert ds1[10]['x'] == [4, 3, 2, 1]
  246. ds2[0]['x'][0] = 100
  247. assert ds3[10]['x'][0] == 4 # 不改变copy后的field了
  248. ds3[10]['x'][0] = -100
  249. assert ds2[0]['x'][0] == 100 # 不改变copy前的field了
  250. # 测试inplace
  251. ds1 = DataSet({"x": [[1, 2, 3, 4] for i in range(10)], "y": [[5, 6] for i in range(10)]})
  252. ds2 = DataSet({"x": [[4, 3, 2, 1] for i in range(10)], "y": [[6, 5] for i in range(10)]})
  253. ds3 = ds1.concat(ds2, inplace=True)
  254. ds2[0]['x'][0] = 100
  255. assert ds3[10]['x'][0] == 4 # 不改变copy后的field了
  256. ds3[10]['x'][0] = -100
  257. assert ds2[0]['x'][0] == 100 # 不改变copy前的field了
  258. ds3[0]['x'][0] = 100
  259. assert ds1[0]['x'][0] == 100 # 改变copy前的field了
  260. # 测试mapping
  261. ds1 = DataSet({"x": [[1, 2, 3, 4] for i in range(10)], "y": [[5, 6] for i in range(10)]})
  262. ds2 = DataSet({"X": [[4, 3, 2, 1] for i in range(10)], "Y": [[6, 5] for i in range(10)]})
  263. ds3 = ds1.concat(ds2, field_mapping={'X': 'x', 'Y': 'y'})
  264. assert len(ds3) == 20
  265. # 测试忽略掉多余的
  266. ds1 = DataSet({"x": [[1, 2, 3, 4] for i in range(10)], "y": [[5, 6] for i in range(10)]})
  267. ds2 = DataSet({"X": [[4, 3, 2, 1] for i in range(10)], "Y": [[6, 5] for i in range(10)], 'Z': [0] * 10})
  268. ds3 = ds1.concat(ds2, field_mapping={'X': 'x', 'Y': 'y'})
  269. # 测试报错
  270. ds1 = DataSet({"x": [[1, 2, 3, 4] for i in range(10)], "y": [[5, 6] for i in range(10)]})
  271. ds2 = DataSet({"X": [[4, 3, 2, 1] for i in range(10)]})
  272. with pytest.raises(RuntimeError):
  273. ds3 = ds1.concat(ds2, field_mapping={'X': 'x'})
  274. def test_instance_field_disappear_bug(self):
  275. data = DataSet({'raw_chars': [[0, 1], [2]], 'target': [0, 1]})
  276. data.copy_field(field_name='raw_chars', new_field_name='chars')
  277. _data = data[:1]
  278. for field_name in ['raw_chars', 'target', 'chars']:
  279. assert _data.has_field(field_name) == True
  280. def test_from_pandas(self):
  281. import pandas as pd
  282. df = pd.DataFrame({'x': [1, 2, 3], 'y': [4, 5, 6]})
  283. ds = DataSet.from_pandas(df)
  284. print(ds)
  285. assert ds['x'].content == [1, 2, 3]
  286. assert ds['y'].content == [4, 5, 6]
  287. def test_to_pandas(self):
  288. ds = DataSet({'x': [1, 2, 3], 'y': [4, 5, 6]})
  289. df = ds.to_pandas()
  290. def test_to_csv(self):
  291. ds = DataSet({'x': [1, 2, 3], 'y': [4, 5, 6]})
  292. ds.to_csv("1.csv")
  293. assert os.path.exists("1.csv") == True
  294. os.remove("1.csv")
  295. def test_add_seq_len(self):
  296. ds = DataSet({'x': [[1, 2], [2, 3, 4], [3]], 'y': [4, 5, 6]})
  297. ds.add_seq_len('x')
  298. print(ds)
  299. class TestFieldArrayInit:
  300. """
  301. 1) 如果DataSet使用dict初始化,那么在add_field中会构造FieldArray:
  302. 1.1) 二维list DataSet({"x": [[1, 2], [3, 4]]})
  303. 1.2) 二维array DataSet({"x": np.array([[1, 2], [3, 4]])})
  304. 1.3) 三维list DataSet({"x": [[[1, 2], [3, 4]], [[1, 2], [3, 4]]]})
  305. 2) 如果DataSet使用list of Instance 初始化,那么在append中会先对第一个样本初始化FieldArray;
  306. 然后后面的样本使用FieldArray.append进行添加。
  307. 2.1) 一维list DataSet([Instance(x=[1, 2, 3, 4])])
  308. 2.2) 一维array DataSet([Instance(x=np.array([1, 2, 3, 4]))])
  309. 2.3) 二维list DataSet([Instance(x=[[1, 2], [3, 4]])])
  310. 2.4) 二维array DataSet([Instance(x=np.array([[1, 2], [3, 4]]))])
  311. """
  312. def test_init_v1(self):
  313. # 二维list
  314. fa = FieldArray("x", [[1, 2], [3, 4]] * 5)
  315. def test_init_v2(self):
  316. # 二维array
  317. fa = FieldArray("x", np.array([[1, 2], [3, 4]] * 5))
  318. def test_init_v3(self):
  319. # 三维list
  320. fa = FieldArray("x", [[[1, 2], [3, 4]], [[1, 2], [3, 4]]])
  321. def test_init_v4(self):
  322. # 一维list
  323. val = [1, 2, 3, 4]
  324. fa = FieldArray("x", [val])
  325. fa.append(val)
  326. def test_init_v5(self):
  327. # 一维array
  328. val = np.array([1, 2, 3, 4])
  329. fa = FieldArray("x", [val])
  330. fa.append(val)
  331. def test_init_v6(self):
  332. # 二维array
  333. val = [[1, 2], [3, 4]]
  334. fa = FieldArray("x", [val])
  335. fa.append(val)
  336. def test_init_v7(self):
  337. # list of array
  338. fa = FieldArray("x", [np.array([[1, 2], [3, 4]]), np.array([[1, 2], [3, 4]])])
  339. def test_init_v8(self):
  340. # 二维list
  341. val = np.array([[1, 2], [3, 4]])
  342. fa = FieldArray("x", [val])
  343. fa.append(val)
  344. class TestFieldArray:
  345. def test_main(self):
  346. fa = FieldArray("x", [1, 2, 3, 4, 5])
  347. assert len(fa) == 5
  348. fa.append(6)
  349. assert len(fa) == 6
  350. assert fa[-1] == 6
  351. assert fa[0] == 1
  352. fa[-1] = 60
  353. assert fa[-1] == 60
  354. assert fa.get(0) == 1
  355. assert isinstance(fa.get([0, 1, 2]), np.ndarray) == True
  356. assert list(fa.get([0, 1, 2])) == [1, 2, 3]
  357. def test_getitem_v1(self):
  358. fa = FieldArray("y", [[1.1, 2.2, 3.3, 4.4, 5.5], [1.0, 2.0, 3.0, 4.0, 5.0]])
  359. assert fa[0] == [1.1, 2.2, 3.3, 4.4, 5.5]
  360. ans = fa[[0, 1]]
  361. assert isinstance(ans, np.ndarray) == True
  362. assert isinstance(ans[0], np.ndarray) == True
  363. assert ans[0].tolist() == [1.1, 2.2, 3.3, 4.4, 5.5]
  364. assert ans[1].tolist() == [1, 2, 3, 4, 5]
  365. assert ans.dtype == np.float64
  366. def test_getitem_v2(self):
  367. x = np.random.rand(10, 5)
  368. fa = FieldArray("my_field", x)
  369. indices = [0, 1, 3, 4, 6]
  370. for a, b in zip(fa[indices], x[indices]):
  371. assert a.tolist() == b.tolist()
  372. def test_append(self):
  373. fa = FieldArray("y", [[1.1, 2.2, 3.3, 4.4, 5.5], [1.0, 2.0, 3.0, 4.0, 5.0]])
  374. fa.append([1.2, 2.3, 3.4, 4.5, 5.6])
  375. assert len(fa) == 3
  376. assert fa[2] == [1.2, 2.3, 3.4, 4.5, 5.6]
  377. def test_pop(self):
  378. fa = FieldArray("y", [[1.1, 2.2, 3.3, 4.4, 5.5], [1.0, 2.0, 3.0, 4.0, 5.0]])
  379. fa.pop(0)
  380. assert len(fa) == 1
  381. assert fa[0] == [1.0, 2.0, 3.0, 4.0, 5.0]
  382. fa[0] = [1.1, 2.2, 3.3, 4.4, 5.5]
  383. assert fa[0] == [1.1, 2.2, 3.3, 4.4, 5.5]
  384. class TestCase:
  385. def test_init(self):
  386. fields = {"x": [1, 2, 3], "y": [4, 5, 6]}
  387. ins = Instance(x=[1, 2, 3], y=[4, 5, 6])
  388. assert isinstance(ins.fields, dict) == True
  389. assert ins.fields == fields
  390. ins = Instance(**fields)
  391. assert ins.fields == fields
  392. def test_add_field(self):
  393. fields = {"x": [1, 2, 3], "y": [4, 5, 6]}
  394. ins = Instance(**fields)
  395. ins.add_field("z", [1, 1, 1])
  396. fields.update({"z": [1, 1, 1]})
  397. assert ins.fields == fields
  398. def test_get_item(self):
  399. fields = {"x": [1, 2, 3], "y": [4, 5, 6], "z": [1, 1, 1]}
  400. ins = Instance(**fields)
  401. assert ins["x"] == [1, 2, 3]
  402. assert ins["y"] == [4, 5, 6]
  403. assert ins["z"] == [1, 1, 1]
  404. def test_repr(self):
  405. fields = {"x": [1, 2, 3], "y": [4, 5, 6], "z": [1, 1, 1]}
  406. ins = Instance(**fields)
  407. # simple print, that is enough.
  408. print(ins)