klongpy 0.6.9__py3-none-any.whl → 0.7.0__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 (64) hide show
  1. klongpy/__init__.py +19 -1
  2. klongpy/adverbs.py +5 -5
  3. klongpy/autograd.py +308 -0
  4. klongpy/backend.py +167 -99
  5. klongpy/backends/__init__.py +94 -0
  6. klongpy/backends/base.py +320 -0
  7. klongpy/backends/numpy_backend.py +122 -0
  8. klongpy/backends/torch_backend.py +995 -0
  9. klongpy-0.6.9.data/scripts/kgpy → klongpy/cli.py +65 -88
  10. klongpy/core.py +228 -108
  11. klongpy/db/sys_fn_db.py +4 -3
  12. klongpy/dyads.py +159 -28
  13. klongpy/interpreter.py +31 -3
  14. klongpy/monads.py +39 -3
  15. klongpy/repl.py +21 -3
  16. klongpy/sys_fn.py +128 -17
  17. klongpy/sys_fn_autograd.py +290 -0
  18. klongpy/sys_fn_ipc.py +18 -6
  19. klongpy/sys_fn_timer.py +13 -3
  20. klongpy/web/sys_fn_web.py +14 -4
  21. klongpy-0.7.0.dist-info/METADATA +493 -0
  22. klongpy-0.7.0.dist-info/RECORD +48 -0
  23. {klongpy-0.6.9.dist-info → klongpy-0.7.0.dist-info}/WHEEL +1 -1
  24. klongpy-0.7.0.dist-info/entry_points.txt +2 -0
  25. {klongpy-0.6.9.dist-info → klongpy-0.7.0.dist-info}/top_level.txt +0 -1
  26. klongpy-0.6.9.dist-info/METADATA +0 -448
  27. klongpy-0.6.9.dist-info/RECORD +0 -77
  28. tests/__init__.py +0 -6
  29. tests/gen_join_over.py +0 -119
  30. tests/gen_py_suite.py +0 -77
  31. tests/gen_test_fn.py +0 -259
  32. tests/perf_async.py +0 -25
  33. tests/perf_avg.py +0 -18
  34. tests/perf_duckdb.py +0 -32
  35. tests/perf_gen.py +0 -38
  36. tests/perf_ipc_overhead.py +0 -34
  37. tests/perf_join.py +0 -53
  38. tests/perf_load.py +0 -17
  39. tests/perf_prog.py +0 -18
  40. tests/perf_serdes.py +0 -52
  41. tests/perf_sys_fn_db.py +0 -263
  42. tests/perf_vector.py +0 -40
  43. tests/test_accel.py +0 -227
  44. tests/test_df_cache.py +0 -85
  45. tests/test_eval_monad_list.py +0 -34
  46. tests/test_examples.py +0 -64
  47. tests/test_extra_suite.py +0 -382
  48. tests/test_file_cache.py +0 -185
  49. tests/test_interop.py +0 -180
  50. tests/test_kg_asarray.py +0 -94
  51. tests/test_kgtests.py +0 -65
  52. tests/test_known_bugs.py +0 -206
  53. tests/test_prog.py +0 -107
  54. tests/test_reshape_strings.py +0 -33
  55. tests/test_suite.py +0 -1480
  56. tests/test_suite_file.py +0 -153
  57. tests/test_sys_fn.py +0 -420
  58. tests/test_sys_fn_db.py +0 -88
  59. tests/test_sys_fn_ipc.py +0 -587
  60. tests/test_sys_fn_timer.py +0 -133
  61. tests/test_sys_fn_web.py +0 -50
  62. tests/test_util.py +0 -233
  63. tests/utils.py +0 -126
  64. {klongpy-0.6.9.dist-info → klongpy-0.7.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,448 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: klongpy
3
- Version: 0.6.9
4
- Summary: High-Performance Klong array language with rich Python integration.
5
- Author: Brian Guarraci
6
- License: MIT
7
- Classifier: Programming Language :: Python :: 3
8
- Classifier: License :: OSI Approved :: MIT License
9
- Requires-Python: <3.13,>=3.9
10
- Description-Content-Type: text/markdown
11
- License-File: LICENSE
12
- Requires-Dist: numpy~=1.26.4
13
- Provides-Extra: cupy
14
- Requires-Dist: cupy; extra == "cupy"
15
- Provides-Extra: cuda12x
16
- Requires-Dist: cupy-cuda12x; extra == "cuda12x"
17
- Provides-Extra: cuda11x
18
- Requires-Dist: cupy-cuda11x; extra == "cuda11x"
19
- Provides-Extra: cuda111
20
- Requires-Dist: cupy-cuda111; extra == "cuda111"
21
- Provides-Extra: cuda110
22
- Requires-Dist: cupy-cuda110; extra == "cuda110"
23
- Provides-Extra: cuda102
24
- Requires-Dist: cupy-cuda102; extra == "cuda102"
25
- Provides-Extra: rocm-5-0
26
- Requires-Dist: cupy-rocm-5-0; extra == "rocm-5-0"
27
- Provides-Extra: rocm-4-3
28
- Requires-Dist: cupy-rocm-4-3; extra == "rocm-4-3"
29
- Provides-Extra: repl
30
- Requires-Dist: colorama==0.4.6; extra == "repl"
31
- Provides-Extra: web
32
- Requires-Dist: aiohttp==3.9.4; extra == "web"
33
- Provides-Extra: db
34
- Requires-Dist: pandas==2.2.2; extra == "db"
35
- Requires-Dist: duckdb==1.3.0; extra == "db"
36
- Provides-Extra: ws
37
- Requires-Dist: websockets==12.0; extra == "ws"
38
- Provides-Extra: full
39
- Requires-Dist: colorama==0.4.6; extra == "full"
40
- Requires-Dist: aiohttp==3.9.4; extra == "full"
41
- Requires-Dist: pandas==2.2.2; extra == "full"
42
- Requires-Dist: duckdb==1.3.0; extra == "full"
43
- Requires-Dist: websockets==12.0; extra == "full"
44
- Dynamic: author
45
- Dynamic: classifier
46
- Dynamic: description
47
- Dynamic: description-content-type
48
- Dynamic: license
49
- Dynamic: license-file
50
- Dynamic: provides-extra
51
- Dynamic: requires-dist
52
- Dynamic: requires-python
53
- Dynamic: summary
54
-
55
-
56
- ![Unit Tests](https://github.com/briangu/klongpy/workflows/Unit%20Tests/badge.svg)
57
- [![Last Commit](https://img.shields.io/github/last-commit/briangu/klongpy)](https://img.shields.io/github/last-commit/briangu/klongpy)
58
- [![Dependency Status](https://img.shields.io/librariesio/github/briangu/klongpy)](https://libraries.io/github/briangu/klongpy)
59
- [![Open Issues](https://img.shields.io/github/issues-raw/briangu/klongpy)](https://github.com/briangu/klongpy/issues)
60
- [![Repo Size](https://img.shields.io/github/repo-size/briangu/klongpy)](https://img.shields.io/github/repo-size/briangu/klongpy)
61
- [![GitHub star chart](https://img.shields.io/github/stars/briangu/klongpy?style=social)](https://star-history.com/#briangu/klongpy)
62
-
63
- [![Release Notes](https://img.shields.io/github/release/briangu/klongpy)](https://github.com/briangu/klongpy/releases)
64
- [![Downloads](https://static.pepy.tech/badge/klongpy/month)](https://pepy.tech/project/klongpy)
65
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
66
-
67
- # KlongPy: High-Performance Array Programming in Python
68
-
69
- KlongPy is a Python adaptation of the [Klong](https://t3x.org/klong) [array language](https://en.wikipedia.org/wiki/Array_programming), known for its high-performance vectorized operations that leverage the power of NumPy. Embracing a "batteries included" philosophy, KlongPy combines built-in modules with Python's expansive ecosystem, facilitating rapid application development with Klong's succinct syntax.
70
-
71
- ## Core Features
72
-
73
- - **Vectorized Operations with NumPy:** At its core, KlongPy uses [NumPy](https://numpy.org/), an [Iverson Ghost](https://analyzethedatanotthedrivel.org/2018/03/31/NumPy-another-iverson-ghost/) descendant from APL, for high-efficiency array manipulations.
74
- - **CPU and GPU Backend Support:** Incorporating [CuPy](https://github.com/cupy/cupy), KlongPy extends its capabilities to operate on both CPU and GPU backends, ensuring versatile and powerful computing options.
75
- - **Seamless Integration with Python Ecosystem:** The combination of KlongPy's built-in features with Python's wide-ranging libraries enables developers to build complex applications effortlessly.
76
-
77
- ## KlongPy's Foundation and Applications
78
-
79
- - **Inspired by Nils M Holm:** KlongPy is grounded in the work of [Nils M Holm](https://t3x.org), the original creator of Klong, and is further enriched by his [Klong Book](https://t3x.org/klong/book.html).
80
- - **Ideal for Diverse Fields:** Data scientists, quantitative analysts, researchers, and programming language enthusiasts will find KlongPy especially beneficial for its versatility and performance.
81
-
82
- KlongPy thus stands as a robust tool, blending the simplicity of Klong with the extensive capabilities of Python, suitable for a wide range of computational tasks.
83
-
84
- # Quick install
85
-
86
- ```bash
87
- pip3 install "klongpy[full]"
88
- ```
89
-
90
- # Feature Overview
91
-
92
- KlongPy is both an Array Language runtime and a set of powerful tools for building high performance data analysis and distributed computing applications. Some of the features include:
93
-
94
- * [__Array Programming__](https://en.wikipedia.org/wiki/Array_programming): Based on [Klong](https://t3x.org/klong), a concise, expressive, and easy-to-understand array programming language. Its simple syntax and rich feature set make it an excellent tool for data scientists and engineers.
95
- * [__Speed__](docs/performance.md): Designed for high-speed vectorized computing, enabling you to process large data sets quickly and efficiently on either CPU or GPU.
96
- * [__Fast Columnar Database__](docs/fast_columnar_database.md): Includes integration with [DuckDb](http://duckdb.org), a super fast in-process columnar store that can operate directly on NumPy arrays with zero-copy.
97
- * [__Inter-Process Communication (IPC)__](docs/ipc_capabilities.md): Includes built-in support for IPC, enabling easy communication between different processes and systems. Ticker plants and similar pipelines are easy to build.
98
- * [__Table and Key-Value Store__](docs/table_and_key_value_stores.md): Includes a simple file-backed key value store that can be used to store database tables or raw key/value pairs.
99
- * [__Python Integration__](docs/python_integration.md): Seamlessly compatible with Python and modules, allowing you to leverage existing Python libraries and frameworks.
100
- * [__Web server__](docs/web_server.md): Includes a web server, making it easy to build sites backed by KlongPy capabilities.
101
- * [__Timers__](docs/timer.md): Includes periodic timer facility to periodically perform tasks.
102
-
103
- # KlongPy Examples
104
-
105
- Explore KlongPy with these examples. Each snippet highlights a unique aspect of Klong, demonstrating its versatility in various programming scenarios.
106
-
107
- Before we get started, you may be wondering: *Why is the syntax so terse?*
108
-
109
- The answer is that it's based on the APL style array language programming and there's a good reason why its compact nature is actually helpful.
110
-
111
- Array language style lets you describe WHAT you want the computer to do and it lets the computer figure out HOW to do it. This frees you up from the details while letting the computer figure out how to go as fast as possible.
112
-
113
- Less code to write and faster execution.
114
-
115
- ---
116
-
117
- Just so the following examples make more sense when you see the REPL outputs, there are a few quick rules about Klong functions. Functions only take up to 3 parameters and they are ALWAYS called x,y and z.
118
-
119
- A function with
120
-
121
- * no parameters is called a nilad
122
- * one parameter is called a monad (x)
123
- * two parameters: dyad (x and y)
124
- * three parameters: a triad (x, y and z)
125
-
126
- The reason that Klong functions only take up to 3 parameters AND name them for you is both convience and compactness.
127
-
128
- ---
129
-
130
- ## 0. Start the REPL
131
-
132
- ```Bash
133
- $ rlwrap kgpy
134
-
135
- Welcome to KlongPy REPL v0.6.0
136
- Author: Brian Guarraci
137
- Web: http://klongpy.org
138
- ]h for help; crtl-d or ]q to quit
139
-
140
- ?>
141
- ```
142
-
143
- ## 1. Basic Arithmetic
144
-
145
- Let's get started with the basics and build up to some more interesting math. Expressions are evaluated from right to left: 3*2 and then + 5
146
-
147
- ```kgpy
148
- ?> 5+3*2
149
- 11
150
- ```
151
-
152
- KlongPy is more about arrays of things, so let's define sum and count functions over an array:
153
-
154
- ```kgpy
155
- ?> sum::{+/x} :" sum + over / the array x
156
- :monad
157
- ?> sum([1 2 3])
158
- 6
159
- ?> count::{#x}
160
- :monad
161
- ?> count([1 2 3])
162
- 3
163
- ```
164
-
165
- Now that we know the sum and number of elements we can compute the average:
166
-
167
- ```kgpy
168
- ?> avg::{sum(x)%count(x)} :" average is the sum divided by the number of elements
169
- :monad
170
- ?> avg([1 2 3])
171
- 2
172
- ```
173
-
174
- ## 2. Math on arrays
175
-
176
- Let's dig into more interesting operations over array elements. There's really big performance differences in how you approach the problem and it's important to see the difference.
177
-
178
- For the simple case of squaring numbers in a list, let's try a couple solutions:
179
-
180
- ```kgpy
181
- ?> {x*x}'[1 2 3 4 5] :" square each element as we iterate over the array
182
- [1 4 9 16 25]
183
- ```
184
-
185
- The vectorized approach will do an element-wise multiplication in bulk:
186
-
187
- ```kgpy
188
- ?> a::[1 2 3 4 5];a*a :" a*a multiplies the arrays
189
- [1 4 9 16 25]
190
- ```
191
-
192
- The vectorized approach is going to be MUCH faster. Let's crank up the size of the array and time it:
193
-
194
- ```kgpy
195
- $> .l("time")
196
- :monad
197
- $> a::!1000;#a
198
- 1
199
- $> fast::{{a*a}'!1000}
200
- :nilad
201
- $> slow::{{{x*x}'a}'!1000}
202
- :nilad
203
- $> time(fast)
204
- 0.015867948532104492
205
- $> time(slow)
206
- 2.8987138271331787
207
- ```
208
-
209
- Vectors win by 182x! Why? Because when you perform a bulk vector operation the CPU can perform the math with much less overhead and do many more operations at a time because it has the entire computation presented to it at once.
210
-
211
- KlongPy aims to give you tools that let you conveniently exploit this vectorization property - and go FAST!
212
-
213
- Less code to write AND faster to compute.
214
-
215
- ## 3. Data Analysis with Python Integration
216
-
217
- KlongPy integrates seamlessly with Python so that the strenghts of both can be combined. It's easy to use KlongPy from Python and vice versa.
218
-
219
- For example, let's say we have some data in Python that we want to operate on in KlongPy. We can just directly use the interpreter in Python and run functions on data we put into the KlongPy context:
220
-
221
- ```python
222
- from klongpy import KlongInterpreter
223
- import numpy as np
224
-
225
- data = np.array([1, 2, 3, 4, 5])
226
- klong = KlongInterpreter()
227
- # make the data NumPy array available to KlongPy code by passing it into the interpreter
228
- # we are creating a symbol in KlongPy called 'data' and assigning the external NumPy array value
229
- klong['data'] = data
230
- # define the average function in KlongPY
231
- klong('avg::{(+/x)%#x}')
232
- # call the average function with the external data and return the result.
233
- r = klong('avg(data)')
234
- print(r) # expected value: 3
235
- ```
236
-
237
- It doesn't make sense to write code in Klong that already exists in other libraries. We can directly access them via the python inport functions (.py and .pyf).
238
-
239
- How about we use the NumPy FFT?
240
-
241
- ```kgpy
242
- ?> .pyf("numpy";"fft");fft::.pya(fft;"fft")
243
- :monad
244
- ?> signal::[0.0 1.0 0.0 -1.0] :" Example simple signal
245
- [0.0 1.0 0.0 -1.0]
246
- ?> result::fft(signal)
247
- [0j -2j 0j 2j]
248
- ```
249
-
250
- Now you can use NumPy or other libraries to provide complex functions while KlongPy lets you quickly prepare and process the vectors.
251
-
252
- There's a lot more we can do with interop but let's move on for now!
253
-
254
- ## 4. Database Functionality
255
-
256
- KlongPy leverages a high-performance columnar store called DuckDb that uses zero-copy NumPy array operations behind the scenes. This database allows fast interop between KlongPy and DuckDb (the arrays are not copied) so that applications can manage arrays in KlongPy and then instantly perform SQL on the data for deeper insights.
257
-
258
- It's easy to create a table and a db to query:
259
-
260
- ```kgpy
261
- ?> .py("klongpy.db")
262
- ?> t::.table([["name" ["Alice" "Bob"]] ["age" [25 30]]])
263
- name age
264
- Alice 25
265
- Bob 30
266
- ?> db::.db(:{},"T",t)
267
- ?> db("select * from T where age > 27")
268
- name age
269
- Bob 30
270
- ```
271
-
272
- ## 5. IPC, Remote Function Calls and Asynchronous operations
273
-
274
- Inter Process Communication (IPC) lets you build distributed and interconnected KlongPy programs and services.
275
-
276
- KlongPy treats IPC connections to servers as functions. These functions let you call the server and ask for things it has in it's memory - they can be other functions or values, etc. For example you can ask for a reference to a remote function and you will get a local function that when you call it runs on teh server with your arguemnts. This general "remote proxy" approach allows you to write your client code in the same way as if all the code were running locally.
277
-
278
- To see this in action, let's setup a simple scenario where the server has an "avg" function and the client wants to call it.
279
-
280
- Start a server in one terminal:
281
-
282
- ```kgpy
283
- ?> avg::{(+/x)%#x}
284
- :monad
285
- ?> .srv(8888)
286
- 1
287
- ```
288
-
289
- Start the client and make the connection to the server as 'f'. In order to pass parameters to a remote function we form an array of the function symbol followed by the parameters (e.g. :avg,,!100)
290
-
291
- ```kgpy
292
- ?> f::.cli(8888) :" connect to the server
293
- remote[localhost:8888]:fn
294
- ?> f(:avg,,!100) : call the remote function "avg" directly with the paramter !100
295
- 49.5
296
- ```
297
-
298
- Let's get fancy and make a local proxy to the remote function:
299
-
300
- ```kgpy
301
- ?> myavg::f(:avg) :" reference the remote function by it's symbol :avg and assign to a local variable called myavg
302
- remote[localhost:8888]:fn:avg:monad
303
- ?> myavg(!100) :" this runs on the server with !100 array passed to it as a parameter
304
- 49.5
305
- ```
306
-
307
- Since remote functions may take a while we can wrap them with an async wrapper and have it call our callback when completed:
308
-
309
- ```kgpy
310
- ?> afn::.async(myavg;{.d("Avg calculated: ");.p(x)})
311
- async::monad
312
- ?> afn(!100)
313
- Avg calculated: 49.5
314
- 1
315
- ```
316
-
317
- ## 6. Web Server Implementation
318
-
319
- In addition to IPC we can also expose data via a standard web server. This capability lets you have other ways of serving content that can be either exposing interesting details about some computation or just a simple web server for other reasons.
320
-
321
- Let's create a file called web.kg with the following code that adds one index handler:
322
-
323
- ```text
324
- .py("klongpy.web")
325
- data::!10
326
- index::{x; "Hello, Klong World! ",data}
327
- .web(8888;:{},"/",index;:{})
328
- .p("ready at http://localhost:8888")
329
- ```
330
-
331
- We can run this web server as follows:
332
-
333
- ```bash
334
- $ kgpy web.kg
335
- ready at http://localhost:8888
336
- ```
337
-
338
- In another terminal:
339
-
340
- ```bash
341
- $ curl http://localhost:8888
342
- ['Hello, Klong World! ' 0 1 2 3 4 5 6 7 8 9]
343
- ```
344
-
345
- You can also spin up this server directly inside the REPL:
346
-
347
- ```kgpy
348
- ?> .py("klongpy.web")
349
- ?> data::!10
350
- ?> index::{x; "Hello, Klong World! ", data}
351
- ?> get:::{}; get,"/",index
352
- ?> post:::{}
353
- ?> h::.web(8888;get;post)
354
- ```
355
-
356
- And from another terminal:
357
-
358
- ```bash
359
- $ curl http://localhost:8888
360
- ['Hello, Klong World! ' 0 1 2 3 4 5 6 7 8 9]
361
- ```
362
-
363
- Stop the server with:
364
-
365
- ```kgpy
366
- ?> .webc(h)
367
- 1
368
- ```
369
-
370
- ## Conclusion
371
-
372
- These examples are designed to illustrate the "batteries included" approach, ease of use and diverse applications of KlongPy, making it a versatile choice for various programming needs.
373
-
374
- [Check out the examples folder for more](https://github.com/briangu/klongpy/tree/main/examples).
375
-
376
- # Installation
377
-
378
- ### CPU
379
-
380
- ```bash
381
- pip3 install klongpy
382
- ```
383
-
384
- ### GPU support
385
-
386
- Choose your CuPy prebuilt binary or from source. Note, the [ROCM](docs/ROCM.md) support for CuPy is experimental and likely will have issues.
387
-
388
- 'cupy' => build from source
389
- 'cuda12x' => "cupy-cuda12x"
390
- 'cuda11x' => "cupy-cuda11x"
391
- 'cuda111' => "cupy-cuda111"
392
- 'cuda110' => "cupy-cuda110"
393
- 'cuda102' => "cupy-cuda102"
394
- 'rocm-5-0' => "cupy-rocm-5-0"
395
- 'rocm-4-3' => "cupy-rocm-4-3"
396
-
397
- ```bash
398
- pip3 install "klongpy[cupy]"
399
- ```
400
-
401
- ### All application tools (db, web, REPL, etc.)
402
-
403
- ```bash
404
- pip3 install "klongpy[full]"
405
- ```
406
-
407
- # Status
408
-
409
- KlongPy is a superset of the Klong array language. It currently passes all of the integration tests provided by klong as well as additional suites.
410
-
411
- Since CuPy is [not 100% compatible with NumPy](https://docs.cupy.dev/en/stable/user_guide/difference.html), there are currently some gaps in KlongPy between the two backends. Notably, strings are supported in CuPy arrays so KlongPy GPU support currently is limited to math.
412
-
413
- Primary ongoing work includes:
414
-
415
- * Additional tools to make KlongPy applications more capable.
416
- * Additional syntax error help
417
- * Actively switch between CuPy and NumPy when incompatibilities are present
418
-
419
- # Differences from Klong
420
-
421
- KlongPy is effectively a superset of the Klong language, but has some key differences:
422
-
423
- * Infinite precision: The main difference in this implementation of Klong is the lack of infinite precision. By using NumPy we are restricted to doubles.
424
- * Python integration: Most notably, the ".py" command allows direct import of Python modules into the current Klong context.
425
- * KlongPy aims to be more "batteries included" approach to modules and contains additional features such as IPC, Web service, Websockets, etc.
426
- * For array operations, KlongPy matches the shape of array arguments differently. Compare the results of an expression like `[1 2]+[[3 4][5 6]]` which in Klong produces `[[4 5] [7 8]]` but in KlongPy produces `[[4 6] [6 8]]`.
427
-
428
- # Related
429
-
430
- * [Klupyter - KlongPy in Jupyter Notebooks](https://github.com/briangu/klupyter)
431
- * [Visual Studio Code Syntax Highlighting](https://github.com/briangu/klongpy-vscode)
432
- * [Advent Of Code in KlongPy](https://github.com/briangu/aoc)
433
-
434
- ## Develop
435
-
436
- git clone https://github.com/briangu/klongpy.git
437
- cd klongpy
438
- python3 setup.py develop
439
-
440
- ### Running tests
441
-
442
- ```bash
443
- python3 -m unittest
444
- ```
445
-
446
- # Acknowledgement
447
-
448
- HUGE thanks to Nils M Holm for his work on Klong and providing the foundations for this interesting project.
@@ -1,77 +0,0 @@
1
- klongpy/__init__.py,sha256=8K0RIIZh2QLdOBA68oym_MeEwO33ffcDOZAU3etJ7kA,107
2
- klongpy/adverbs.py,sha256=W6HAL4rxWV6djrILnahRqw8o6-Yq9pUWIUznSJG8-f0,12566
3
- klongpy/backend.py,sha256=qA2DulWLVtlOYs3opwJIod0XZVTLCMvqjuttK2_-CHo,2897
4
- klongpy/core.py,sha256=bie-UnhYufNmB7hSKhKmR_dT4X4K8EdrUTiBzk9A3ck,27460
5
- klongpy/dyads.py,sha256=KkVfKaFnxU6_1-wJNIuwagN_NVwySt9XVP6Sqg0dack,31636
6
- klongpy/interpreter.py,sha256=AH4LEv3jhgmupgJrvwqMbW_F2EwpmZFKtOMdKc_SJzM,23981
7
- klongpy/monads.py,sha256=HTpBQKNVbZ7KBnS1xxOsNAwKWUG8xAOXLQIOQR4022g,14076
8
- klongpy/repl.py,sha256=zwWrxU_KbNfbXAdAJS_wN56bi12w3Jm7HGH6m6Tv0yY,2542
9
- klongpy/sys_fn.py,sha256=jVhBcUBmKWAgCnZpueyRebYxaWn7fvyDoI_fNx3nw3Y,23729
10
- klongpy/sys_fn_ipc.py,sha256=okKzZm-FKCyWlDqpL7bnUDZjLqkQVSQK9h20ERItma0,35660
11
- klongpy/sys_fn_timer.py,sha256=wY9Xx_zA3LOHnAm9ltFvr9OAOXNcnoWQVNYIniDQlSQ,2945
12
- klongpy/sys_var.py,sha256=x4Jq5JwnQrwdU54vxh03JuunKBb6nQoAGOoxvQAk1w4,4322
13
- klongpy/utils.py,sha256=nuevztUECi73_H0rrUX8Og19GUEdgkULp5tb2pirhVU,749
14
- klongpy/db/__init__.py,sha256=KUEKYPphDAYLdRfzcRuvj3Mv9ti6x_y9hjIzNh0ufRI,282
15
- klongpy/db/df_cache.py,sha256=_2tI3Gv5nzASlQfnFiwnXrkPnZ-mzJzyM0tt_gi3c5o,3325
16
- klongpy/db/file_cache.py,sha256=MnSTRB0B8yi8yAHFXGqduqaBqGhllLKxo1rrqMJ6-ik,9294
17
- klongpy/db/helpers.py,sha256=vdxSY2W-N13cBF3PUi86WlecGSz0ZkJN0OR7Jb6E9iM,1457
18
- klongpy/db/sys_fn_db.py,sha256=R5yfEa8LvCbCdSCV2BrZXfGrh7IbwSK9zuZ7OVRd8UI,9234
19
- klongpy/db/sys_fn_kvs.py,sha256=--FTMQyKdn8vBx0qG4mOBzdd2rtBfm0rW4c0AnB0G94,4114
20
- klongpy/lib/csv.kg,sha256=w6FvenQmkl0EF2kieQxxloNOFgZbt3M9IMSYSdImJcA,1498
21
- klongpy/lib/edt.kg,sha256=aJsjCxAkbfzwxWg8mF9nRDbCCt2fqtCWv0CPsq4SIHw,707
22
- klongpy/lib/eigenv.kg,sha256=_9iypo9qozqx5HfQR2h8aOx8kYlHGjuZ6NJ4vrfesd4,2118
23
- klongpy/lib/help.kg,sha256=p2OobNtxpXMz5xR0DCJwnBonR8Ot86q62r41F2cy4qQ,4309
24
- klongpy/lib/huffman.kg,sha256=u4vmvzhZ6_-rLgjUH_6HAFMuvqDxhrH1ZWqyNywStOk,637
25
- klongpy/lib/math.kg,sha256=pIFXlEV_-NzyYobqk3ofvW4Mte-4EqYmSWkwkA8AyLw,10118
26
- klongpy/lib/nstat.kg,sha256=1besBcCWp067aOv86jHPVmPQMtEWpC41uU1W_pET4yI,18920
27
- klongpy/lib/print.kg,sha256=v29mWgKpGYbAZGmif3F7rtrhdbmX4TZu-ezMgpB9oVk,78
28
- klongpy/lib/set.kg,sha256=KGkBqOeJjEZYKd8LS-lu1RPx5KcqjIxl7-7XpUaH8VI,887
29
- klongpy/lib/spline.kg,sha256=8kVvX9gsieR5f2hZDx0M_oKmJl7CP6Nn0hJssdcXkwk,1454
30
- klongpy/lib/time.kg,sha256=tJPknPGXHa_239PBMscg2VSaJ3ZV6SVRbADtTtE1a_4,359
31
- klongpy/lib/util.kg,sha256=LXwPtmcYZUv3Vs5eFt-1RqTvr7cn-_RKLKaSnLLN5gc,440
32
- klongpy/web/__init__.py,sha256=lM_40n_qzwYSx_OFi4RqFwsxQe8GGBtJm3_GLLxn9-8,101
33
- klongpy/web/sys_fn_web.py,sha256=usfcEWAQyTK0cppPZPefzr_raYoMzZUeh8WZDuvaAMU,5064
34
- klongpy/ws/__init__.py,sha256=GKl5804W3XNkDER0mkdFf-4cIVjgeP9M3tfNg_tCv3c,114
35
- klongpy/ws/sys_fn_ws.py,sha256=Ba6MmmTS6cWHlruGgNznNXXPQX2zaBQmAEwkz9ge7sk,18300
36
- klongpy-0.6.9.data/scripts/kgpy,sha256=nDF66LclUBK6qILB2dgJ9VKAlGlPKMQfoJ4CvH5d_UQ,12119
37
- klongpy-0.6.9.dist-info/licenses/LICENSE,sha256=Nk1iW-tI7n0z8R2jMqVm9SuFIoa8iukXsFcJoPqQgns,1071
38
- tests/__init__.py,sha256=xdETQVm8SNlASCru27aks1KZwSs2Oh-0NR5zrccSqb0,221
39
- tests/gen_join_over.py,sha256=ZiliJS6Lz0rqaZAfAeJFbPOU109PRF0QFE6262a4TPU,3684
40
- tests/gen_py_suite.py,sha256=ihXihalZkjN9Poy3m-1FVGdZy_YYWS0CEkY68pDgGso,2495
41
- tests/gen_test_fn.py,sha256=thoxQcqwY3ANClYn2PGtpRsm8XPPZWLActPPEqbwtgg,9894
42
- tests/perf_async.py,sha256=p9hMNal65LUu3Z8Of7878ZHiSKQtwEJAqbWZzNLt5tQ,736
43
- tests/perf_avg.py,sha256=Vriws6Xco-1BXoZKxzyOz904PeDF_B8TmOzStjCtTp4,483
44
- tests/perf_duckdb.py,sha256=QPa1AO1iuAFv7zenrtjUmKVpyE6Ep3d-_E84noFSEk0,737
45
- tests/perf_gen.py,sha256=zxtZC1hspUURr5dp8U5jsaSVo5yNbQDuq1I6-KcxYM8,1123
46
- tests/perf_ipc_overhead.py,sha256=u3w-3bKNn88Ul9Zd1dFGjkMoUAv9P_veRQg_dRXiQOs,1172
47
- tests/perf_join.py,sha256=LPRgbOvWd0qttC2rE210l9RjlIRKCq4EFW3N3ifqwRQ,1143
48
- tests/perf_load.py,sha256=EOs5Zf8SvqNaW7rftWyGwM6jWYUQPGBZO4jhFzJzZoM,310
49
- tests/perf_prog.py,sha256=Vm6V48McBgNGaH5X26JydajPsD8m46SYpxvc_Qs-o0Y,566
50
- tests/perf_serdes.py,sha256=1tw3fK8hUcorxQ123zDNOr8X0-Exirv-o_ufifYVBwE,1829
51
- tests/perf_sys_fn_db.py,sha256=mjoskDzjRJQL4xZULtOm4_y0r2GT8WhgGR1RdhNLjqw,5015
52
- tests/perf_vector.py,sha256=p76TVCS5szG0BX7rzquvKb7xikxUQOUmQttvTS0EH44,976
53
- tests/test_accel.py,sha256=apKi0PN9l9ztDLTwtdo6esWCl7_Yo97xljfNY0q9hug,6305
54
- tests/test_df_cache.py,sha256=vK36B0ENNwTYgv_JvRZimum9EEoPw-qgi4BWQWHRqQQ,3302
55
- tests/test_eval_monad_list.py,sha256=pP7hDxpWIJSg6MD8tya5ctS9d5Z6I2xHnrFbDutkMQY,846
56
- tests/test_examples.py,sha256=hfpCQlcLR4pjUeSk9uAhtgnsjLEHLc_sfvRRWq8W1iY,2131
57
- tests/test_extra_suite.py,sha256=WPIA_UcP5BVvZIlkiDMUx_877ts3rYoVLo0grQh4JW8,12967
58
- tests/test_file_cache.py,sha256=lkE4bXPR9qp6wRdNHcG0f0Fb_BBB-2oocRttmCbXT7A,7733
59
- tests/test_interop.py,sha256=1ja39E4p_aHpc1hdWbldAid2MIWCv2raNamYxMrSfwk,5805
60
- tests/test_kg_asarray.py,sha256=7k2BjUWz7ojRKou2wpEniLNtV9JLTQPkDLmXKh3gph4,2854
61
- tests/test_kgtests.py,sha256=7lUgKYt9TQiYxAXWqE4VuaZo7frhbzSd9ofa6_pWBLE,2190
62
- tests/test_known_bugs.py,sha256=shBMW2rwQV0CLtrPZZ54TDFII7W5fxi7AOpZyvbydM8,6481
63
- tests/test_prog.py,sha256=8P019M-hiW9jxe9FgQS3Q7wqxoTrkhclMTk6xO4HBWU,3311
64
- tests/test_reshape_strings.py,sha256=sZlzKnBuv9ZvUm3sU_PXLr2SXA8gL92n8F0h4gjV528,1063
65
- tests/test_suite.py,sha256=iBLRwnzEPZWh86lJ9rXUrUMqRUCh-kDl11TsrfPSrWM,73100
66
- tests/test_suite_file.py,sha256=zZLXK1xEQgUH0OO9J53jkF4j0rjbgIXsWlsNo5puriA,4027
67
- tests/test_sys_fn.py,sha256=iGoalDXEw2LEIRGYgYIhc1rc-rU5wCNbRyvcr6nYoPw,15695
68
- tests/test_sys_fn_db.py,sha256=iX5sSJGzVMaN_GnhNQE_b6mWCIUYrDmE25KdubXNQL8,2471
69
- tests/test_sys_fn_ipc.py,sha256=tV7uCGxXQCHZQ2CkffD4j5h01TYBe1ozC_wImiANyHA,21605
70
- tests/test_sys_fn_timer.py,sha256=VUfi1AK9SCzA9g5IgbfpdEMW2AP4-9dgVOpJXhMMQhA,4447
71
- tests/test_sys_fn_web.py,sha256=TQX2R_4DCR2YOnhITFpTibL6_4UNbAphiix0fOuFv0Q,1552
72
- tests/test_util.py,sha256=k4UCR0avjWNxo_jO710x32AAMOAePOx79EOt58wL584,7942
73
- tests/utils.py,sha256=QrLAR4-WXVSDrC60qhl78_NE-3idp0mgLJmSZ5seyWw,3721
74
- klongpy-0.6.9.dist-info/METADATA,sha256=49HaLNk5_XaBlB3Uq6U_hFN8w04_rYHBd7-ipbU-Cbc,17249
75
- klongpy-0.6.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
76
- klongpy-0.6.9.dist-info/top_level.txt,sha256=1dsI3MhtibeAZuB7WPW58dpNgyGvXLX5EEHqm46NQYo,14
77
- klongpy-0.6.9.dist-info/RECORD,,
tests/__init__.py DELETED
@@ -1,6 +0,0 @@
1
- import os
2
- import sys
3
- PROJECT_PATH = os.getcwd()
4
- # fix paths so it works both from "python3 -m unittest" and vscode
5
- sys.path.append(os.path.join(PROJECT_PATH,"tests"))
6
- sys.path.append(os.path.join(PROJECT_PATH,"klongpy"))
tests/gen_join_over.py DELETED
@@ -1,119 +0,0 @@
1
- import numpy as np
2
- import subprocess
3
- import os
4
- import itertools
5
- import numpy as np
6
-
7
-
8
- # def _generate_arrays(depth, max_size, max_scalar):
9
- # arr = []
10
- # if depth == 0:
11
- # # Generate both scalars and arrays at leaf level
12
- # if max_size > 0:
13
- # arr.append(list(range(max_size)))
14
- # if max_scalar > 0:
15
- # arr.extend(list(range(max_scalar)))
16
- # else:
17
- # # Generate both scalars and arrays at each level
18
- # for sizes in itertools.product(range(max_size), repeat=max_size):
19
- # for sub_arrays in itertools.product(*[generate_arrays(depth - 1, size, max_scalar) for size in sizes]):
20
- # arr.append(list(sub_arrays)) # array
21
- # if max_scalar > 0:
22
- # arr.extend(list(range(max_scalar)))
23
- # for p in itertools.permutations(arr):
24
- # yield list(p)
25
-
26
-
27
- def generate_random_arrays(depth, max_size, max_scalar, scalar_types=['%d','%s']):
28
- # Base case: depth 0, return a random scalar
29
- if depth == 0:
30
- size = np.random.randint(max_scalar+1)
31
- arr = np.random.choice(scalar_types) if size == 0 else ['%d'] * size
32
- else:
33
- # Decide randomly whether to generate a deeper array or stop at a scalar
34
- if np.random.choice([True, False]):
35
- # Generate a deeper array
36
- size = np.random.randint(max_size + 1) # Random size, including 0
37
- arr = [generate_random_arrays(depth-1, max_size, max_scalar) for _ in range(size)]
38
- else:
39
- # Stop at a scalar
40
- size = np.random.randint(max_scalar+1)
41
- arr = np.random.choice(scalar_types) if size == 0 else ['%d'] * size
42
- return arr
43
-
44
-
45
- def run_test(test_case):
46
- # Prepare the command and the input
47
- cmd = [os.environ['KG_PATH'], "-e", test_case]
48
-
49
- # Run the command with the input and capture the output
50
- result = subprocess.run(cmd, text=True, capture_output=True)
51
-
52
- # Return the result
53
- return result.stdout
54
-
55
-
56
- def fill_template(s):
57
- params = []
58
- i = 0
59
- d = 0
60
- while(i < len(s)):
61
- if s[i] == '%':
62
- i += 1
63
- if s[i] == 'd':
64
- params.append(d)
65
- elif s[i] == 's':
66
- params.append('"'+chr(ord('a')+(d % 26))+'"')
67
- d += 1
68
- i += 1
69
- s = s % tuple(params)
70
- return s
71
-
72
-
73
- def gen_tests(max_test_cases=10000, max_depth=3, max_size=3, max_scalar=3):
74
- # Prepare all possible test cases
75
- seen = set()
76
- while len(seen) < max_test_cases:
77
- array = generate_random_arrays(np.random.randint(max_depth), max_size, max_scalar)
78
- # Convert numpy array to Klong array string representation
79
- array_str = (array if isinstance(array, str) else str(array)).replace(",","").replace("'",'"').replace('"%d"', '%d').replace('"%s"','%s')
80
- test_case = ",/" + array_str
81
- if test_case in seen:
82
- continue
83
- seen.add(test_case)
84
-
85
- seen = list(seen)
86
- seen.sort(key=lambda x: (len(x),x))
87
-
88
- test_cases = set()
89
- for test_case in seen:
90
- test_case = fill_template(test_case)
91
- pretty_case = test_case.replace('"','""')
92
- output = run_test(test_case).strip()
93
- s = f"""t("{pretty_case}"; {test_case}; {output})"""
94
- test_cases.add(s)
95
-
96
- # Print the test strings
97
- test_cases = list(test_cases)
98
- test_cases.sort(key=lambda x: (len(x),x))
99
- for o in test_cases:
100
- print(o)
101
-
102
-
103
-
104
- if __name__ == '__main__':
105
- print("""
106
- :"DO NOT MODIFY: GENERATED BY gen_join_over.py"
107
-
108
- err::0
109
- wl::{.w(x);.p("")}
110
- fail::{err::1;.d("failed: ");.p(x);.d("expected: ");wl(z);.d("got: ");wl(y);[]}
111
- t::{:[~y~z;fail(x;y;z);[]]}
112
-
113
- """)
114
- gen_tests()
115
-
116
- print("""
117
- :[err;[];.p("ok!")]
118
- """)
119
-