klongpy 0.6.9__py3-none-any.whl → 0.7.1__py3-none-any.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.
Files changed (70) hide show
  1. klongpy/__init__.py +17 -1
  2. klongpy/adverbs.py +84 -82
  3. klongpy/autograd.py +299 -0
  4. klongpy/backend.py +38 -103
  5. klongpy/backends/__init__.py +26 -0
  6. klongpy/backends/base.py +469 -0
  7. klongpy/backends/numpy_backend.py +123 -0
  8. klongpy/backends/registry.py +76 -0
  9. klongpy/backends/torch_backend.py +1047 -0
  10. klongpy-0.6.9.data/scripts/kgpy → klongpy/cli.py +110 -90
  11. klongpy/core.py +113 -974
  12. klongpy/db/sys_fn_db.py +7 -6
  13. klongpy/db/sys_fn_kvs.py +2 -4
  14. klongpy/dyads.py +332 -160
  15. klongpy/interpreter.py +60 -15
  16. klongpy/monads.py +121 -75
  17. klongpy/parser.py +328 -0
  18. klongpy/repl.py +23 -5
  19. klongpy/sys_fn.py +170 -21
  20. klongpy/sys_fn_autograd.py +290 -0
  21. klongpy/sys_fn_ipc.py +22 -15
  22. klongpy/sys_fn_timer.py +13 -3
  23. klongpy/types.py +503 -0
  24. klongpy/web/sys_fn_web.py +14 -4
  25. klongpy/writer.py +122 -0
  26. klongpy/ws/sys_fn_ws.py +5 -8
  27. klongpy-0.7.1.dist-info/METADATA +544 -0
  28. klongpy-0.7.1.dist-info/RECORD +52 -0
  29. {klongpy-0.6.9.dist-info → klongpy-0.7.1.dist-info}/WHEEL +1 -1
  30. klongpy-0.7.1.dist-info/entry_points.txt +2 -0
  31. {klongpy-0.6.9.dist-info → klongpy-0.7.1.dist-info}/top_level.txt +0 -1
  32. klongpy-0.6.9.dist-info/METADATA +0 -448
  33. klongpy-0.6.9.dist-info/RECORD +0 -77
  34. tests/__init__.py +0 -6
  35. tests/gen_join_over.py +0 -119
  36. tests/gen_py_suite.py +0 -77
  37. tests/gen_test_fn.py +0 -259
  38. tests/perf_async.py +0 -25
  39. tests/perf_avg.py +0 -18
  40. tests/perf_duckdb.py +0 -32
  41. tests/perf_gen.py +0 -38
  42. tests/perf_ipc_overhead.py +0 -34
  43. tests/perf_join.py +0 -53
  44. tests/perf_load.py +0 -17
  45. tests/perf_prog.py +0 -18
  46. tests/perf_serdes.py +0 -52
  47. tests/perf_sys_fn_db.py +0 -263
  48. tests/perf_vector.py +0 -40
  49. tests/test_accel.py +0 -227
  50. tests/test_df_cache.py +0 -85
  51. tests/test_eval_monad_list.py +0 -34
  52. tests/test_examples.py +0 -64
  53. tests/test_extra_suite.py +0 -382
  54. tests/test_file_cache.py +0 -185
  55. tests/test_interop.py +0 -180
  56. tests/test_kg_asarray.py +0 -94
  57. tests/test_kgtests.py +0 -65
  58. tests/test_known_bugs.py +0 -206
  59. tests/test_prog.py +0 -107
  60. tests/test_reshape_strings.py +0 -33
  61. tests/test_suite.py +0 -1480
  62. tests/test_suite_file.py +0 -153
  63. tests/test_sys_fn.py +0 -420
  64. tests/test_sys_fn_db.py +0 -88
  65. tests/test_sys_fn_ipc.py +0 -587
  66. tests/test_sys_fn_timer.py +0 -133
  67. tests/test_sys_fn_web.py +0 -50
  68. tests/test_util.py +0 -233
  69. tests/utils.py +0 -126
  70. {klongpy-0.6.9.dist-info → klongpy-0.7.1.dist-info}/licenses/LICENSE +0 -0
klongpy/db/sys_fn_db.py CHANGED
@@ -4,8 +4,9 @@ import duckdb
4
4
  import numpy as np
5
5
  import pandas as pd
6
6
 
7
- from klongpy.core import (KGCall, KGLambda, KlongException, reserved_fn_args,
8
- reserved_fn_symbol_map)
7
+ from klongpy.core import (KGCall, KGLambda, KlongException, KLONG_UNDEFINED,
8
+ reserved_fn_args, reserved_fn_symbol_map)
9
+ from klongpy.backend import np as backend_np
9
10
 
10
11
 
11
12
  class KlongDbException(KlongException):
@@ -41,7 +42,7 @@ class Table(dict):
41
42
 
42
43
  def get(self, x):
43
44
  v = self._df.get(x)
44
- return np.inf if v is None else v.values
45
+ return KLONG_UNDEFINED if v is None else v.values
45
46
 
46
47
  def set(self, x, y):
47
48
  self._df[x] = y
@@ -179,7 +180,7 @@ def eval_sys_fn_create_table(x):
179
180
  t,"c",,c
180
181
 
181
182
  """
182
- if np.isarray(x):
183
+ if backend_np.isarray(x):
183
184
  return Table({k:v for k,v in x}, columns=[k for k,_ in x])
184
185
  elif isinstance(x, pd.DataFrame):
185
186
  return Table(x)
@@ -202,7 +203,7 @@ def eval_sys_fn_index(x, y):
202
203
  raise KlongDbException(x, "An index may only be created on a table.")
203
204
  if x.has_index():
204
205
  raise KlongDbException(x, "Table already has an index.")
205
- if not np.isarray(y):
206
+ if not backend_np.isarray(y):
206
207
  raise KlongDbException(x, "An index must be a list of column names")
207
208
  for q in y:
208
209
  if q not in x.columns:
@@ -266,7 +267,7 @@ def eval_sys_fn_insert_table(x, y):
266
267
  """
267
268
  if not isinstance(x,Table):
268
269
  raise KlongDbException(x, "Inserts must be applied to a table")
269
- if not np.isarray(y):
270
+ if not backend_np.isarray(y):
270
271
  raise KlongDbException(x, "Values to insert must be a list")
271
272
  batch = len(y.shape) > 1
272
273
  y_cols = len(y[0]) if batch else len(y)
klongpy/db/sys_fn_kvs.py CHANGED
@@ -1,8 +1,6 @@
1
1
  import sys
2
2
 
3
- import numpy as np
4
-
5
- from klongpy.core import KlongException
3
+ from klongpy.core import KlongException, KLONG_UNDEFINED
6
4
 
7
5
  from .df_cache import PandasDataFrameCache
8
6
  from .file_cache import FileCache
@@ -33,7 +31,7 @@ class TableStorage(dict):
33
31
  if not isinstance(x,str):
34
32
  raise KlongKvsException(x, "key must be a str")
35
33
  df = self.cache.get_dataframe(key_to_file_path(x), default_empty=False)
36
- return np.inf if df is None else Table(df)
34
+ return KLONG_UNDEFINED if df is None else Table(df)
37
35
 
38
36
  def set(self, x, y):
39
37
  if not isinstance(x,str):