klongpy 0.6.8__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 (61) 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.8.data/scripts/kgpy → klongpy/cli.py +65 -88
  10. klongpy/core.py +228 -106
  11. klongpy/db/sys_fn_db.py +4 -3
  12. klongpy/dyads.py +173 -32
  13. klongpy/interpreter.py +31 -3
  14. klongpy/lib/help.kg +2 -2
  15. klongpy/monads.py +49 -12
  16. klongpy/repl.py +91 -0
  17. klongpy/sys_fn.py +129 -18
  18. klongpy/sys_fn_autograd.py +290 -0
  19. klongpy/sys_fn_ipc.py +18 -7
  20. klongpy/sys_fn_timer.py +13 -3
  21. klongpy/web/sys_fn_web.py +28 -6
  22. klongpy-0.7.0.dist-info/METADATA +493 -0
  23. klongpy-0.7.0.dist-info/RECORD +48 -0
  24. {klongpy-0.6.8.dist-info → klongpy-0.7.0.dist-info}/WHEEL +1 -1
  25. klongpy-0.7.0.dist-info/entry_points.txt +2 -0
  26. {klongpy-0.6.8.dist-info → klongpy-0.7.0.dist-info}/top_level.txt +0 -1
  27. klongpy-0.6.8.dist-info/METADATA +0 -412
  28. klongpy-0.6.8.dist-info/RECORD +0 -72
  29. tests/__init__.py +0 -6
  30. tests/gen_join_over.py +0 -119
  31. tests/gen_py_suite.py +0 -77
  32. tests/gen_test_fn.py +0 -259
  33. tests/perf_async.py +0 -25
  34. tests/perf_avg.py +0 -18
  35. tests/perf_duckdb.py +0 -32
  36. tests/perf_gen.py +0 -38
  37. tests/perf_ipc_overhead.py +0 -34
  38. tests/perf_join.py +0 -53
  39. tests/perf_load.py +0 -17
  40. tests/perf_prog.py +0 -18
  41. tests/perf_serdes.py +0 -52
  42. tests/perf_sys_fn_db.py +0 -263
  43. tests/perf_vector.py +0 -40
  44. tests/test_accel.py +0 -227
  45. tests/test_df_cache.py +0 -85
  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 -181
  50. tests/test_kgtests.py +0 -65
  51. tests/test_known_bugs.py +0 -206
  52. tests/test_prog.py +0 -107
  53. tests/test_suite.py +0 -1479
  54. tests/test_suite_file.py +0 -153
  55. tests/test_sys_fn.py +0 -420
  56. tests/test_sys_fn_db.py +0 -88
  57. tests/test_sys_fn_ipc.py +0 -587
  58. tests/test_sys_fn_timer.py +0 -133
  59. tests/test_util.py +0 -233
  60. tests/utils.py +0 -126
  61. {klongpy-0.6.8.dist-info → klongpy-0.7.0.dist-info/licenses}/LICENSE +0 -0
@@ -1,412 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: klongpy
3
- Version: 0.6.8
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: cuda102
14
- Requires-Dist: cupy-cuda102; extra == "cuda102"
15
- Provides-Extra: cuda110
16
- Requires-Dist: cupy-cuda110; extra == "cuda110"
17
- Provides-Extra: cuda111
18
- Requires-Dist: cupy-cuda111; extra == "cuda111"
19
- Provides-Extra: cuda11x
20
- Requires-Dist: cupy-cuda11x; extra == "cuda11x"
21
- Provides-Extra: cuda12x
22
- Requires-Dist: cupy-cuda12x; extra == "cuda12x"
23
- Provides-Extra: cupy
24
- Requires-Dist: cupy; extra == "cupy"
25
- Provides-Extra: db
26
- Requires-Dist: pandas==2.2.2; extra == "db"
27
- Requires-Dist: duckdb==1.0.0; extra == "db"
28
- Provides-Extra: full
29
- Requires-Dist: colorama==0.4.6; extra == "full"
30
- Requires-Dist: aiohttp==3.9.4; extra == "full"
31
- Requires-Dist: pandas==2.2.2; extra == "full"
32
- Requires-Dist: duckdb==1.0.0; extra == "full"
33
- Requires-Dist: websockets==12.0; extra == "full"
34
- Provides-Extra: repl
35
- Requires-Dist: colorama==0.4.6; extra == "repl"
36
- Provides-Extra: rocm-4-3
37
- Requires-Dist: cupy-rocm-4-3; extra == "rocm-4-3"
38
- Provides-Extra: rocm-5-0
39
- Requires-Dist: cupy-rocm-5-0; extra == "rocm-5-0"
40
- Provides-Extra: web
41
- Requires-Dist: aiohttp==3.9.4; extra == "web"
42
- Provides-Extra: ws
43
- Requires-Dist: websockets==12.0; extra == "ws"
44
-
45
-
46
- ![Unit Tests](https://github.com/briangu/klongpy/workflows/Unit%20Tests/badge.svg)
47
- [![Last Commit](https://img.shields.io/github/last-commit/briangu/klongpy)](https://img.shields.io/github/last-commit/briangu/klongpy)
48
- [![Dependency Status](https://img.shields.io/librariesio/github/briangu/klongpy)](https://libraries.io/github/briangu/klongpy)
49
- [![Open Issues](https://img.shields.io/github/issues-raw/briangu/klongpy)](https://github.com/briangu/klongpy/issues)
50
- [![Repo Size](https://img.shields.io/github/repo-size/briangu/klongpy)](https://img.shields.io/github/repo-size/briangu/klongpy)
51
- [![GitHub star chart](https://img.shields.io/github/stars/briangu/klongpy?style=social)](https://star-history.com/#briangu/klongpy)
52
-
53
- [![Release Notes](https://img.shields.io/github/release/briangu/klongpy)](https://github.com/briangu/klongpy/releases)
54
- [![Downloads](https://static.pepy.tech/badge/klongpy/month)](https://pepy.tech/project/klongpy)
55
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
56
-
57
- # KlongPy: High-Performance Array Programming in Python
58
-
59
- 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.
60
-
61
- ## Core Features
62
-
63
- - **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.
64
- - **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.
65
- - **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.
66
-
67
- ## KlongPy's Foundation and Applications
68
-
69
- - **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).
70
- - **Ideal for Diverse Fields:** Data scientists, quantitative analysts, researchers, and programming language enthusiasts will find KlongPy especially beneficial for its versatility and performance.
71
-
72
- 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.
73
-
74
- # Quick install
75
-
76
- ```bash
77
- pip3 install "klongpy[full]"
78
- ```
79
-
80
- # Feature Overview
81
-
82
- 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:
83
-
84
- * [__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.
85
- * [__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.
86
- * [__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.
87
- * [__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.
88
- * [__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.
89
- * [__Python Integration__](docs/python_integration.md): Seamlessly compatible with Python and modules, allowing you to leverage existing Python libraries and frameworks.
90
- * [__Web server__](docs/web_server.md): Includes a web server, making it easy to build sites backed by KlongPy capabilities.
91
- * [__Timers__](docs/timer.md): Includes periodic timer facility to periodically perform tasks.
92
-
93
- # KlongPy Examples
94
-
95
- Explore KlongPy with these examples. Each snippet highlights a unique aspect of Klong, demonstrating its versatility in various programming scenarios.
96
-
97
- Before we get started, you may be wondering: *Why is the syntax so terse?*
98
-
99
- 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.
100
-
101
- 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.
102
-
103
- Less code to write and faster execution.
104
-
105
- ---
106
-
107
- 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.
108
-
109
- A function with
110
-
111
- * no parameters is called a nilad
112
- * one parameter is called a monad (x)
113
- * two parameters: dyad (x and y)
114
- * three parameters: a triad (x, y and z)
115
-
116
- The reason that Klong functions only take up to 3 parameters AND name them for you is both convience and compactness.
117
-
118
- ---
119
-
120
- ## 0. Start the REPL
121
-
122
- ```Bash
123
- $ rlwrap kgpy
124
-
125
- Welcome to KlongPy REPL v0.6.0
126
- Author: Brian Guarraci
127
- Web: http://klongpy.org
128
- ]h for help; crtl-d or ]q to quit
129
-
130
- ?>
131
- ```
132
-
133
- ## 1. Basic Arithmetic
134
-
135
- 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
136
-
137
- ```kgpy
138
- ?> 5+3*2
139
- 11
140
- ```
141
-
142
- KlongPy is more about arrays of things, so let's define sum and count functions over an array:
143
-
144
- ```kgpy
145
- ?> sum::{+/x} :" sum + over / the array x
146
- :monad
147
- ?> sum([1 2 3])
148
- 6
149
- ?> count::{#x}
150
- :monad
151
- ?> count([1 2 3])
152
- 3
153
- ```
154
-
155
- Now that we know the sum and number of elements we can compute the average:
156
-
157
- ```kgpy
158
- ?> avg::{sum(x)%count(x)} :" average is the sum divided by the number of elements
159
- :monad
160
- ?> avg([1 2 3])
161
- 2
162
- ```
163
-
164
- ## 2. Math on arrays
165
-
166
- 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.
167
-
168
- For the simple case of squaring numbers in a list, let's try a couple solutions:
169
-
170
- ```kgpy
171
- ?> {x*x}'[1 2 3 4 5] :" square each element as we iterate over the array
172
- [1 4 9 16 25]
173
- ```
174
-
175
- The vectorized approach will do an element-wise multiplication in bulk:
176
-
177
- ```kgpy
178
- ?> a::[1 2 3 4 5];a*a :" a*a multiplies the arrays
179
- [1 4 9 16 25]
180
- ```
181
-
182
- The vectorized approach is going to be MUCH faster. Let's crank up the size of the array and time it:
183
-
184
- ```kgpy
185
- $> .l("time")
186
- :monad
187
- $> a::!1000;#a
188
- 1
189
- $> fast::{{a*a}'!1000}
190
- :nilad
191
- $> slow::{{{x*x}'a}'!1000}
192
- :nilad
193
- $> time(fast)
194
- 0.015867948532104492
195
- $> time(slow)
196
- 2.8987138271331787
197
- ```
198
-
199
- 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.
200
-
201
- KlongPy aims to give you tools that let you conveniently exploit this vectorization property - and go FAST!
202
-
203
- Less code to write AND faster to compute.
204
-
205
- ## 3. Data Analysis with Python Integration
206
-
207
- 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.
208
-
209
- 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:
210
-
211
- ```python
212
- from klongpy import KlongInterpreter
213
- import numpy as np
214
-
215
- data = np.array([1, 2, 3, 4, 5])
216
- klong = KlongInterpreter()
217
- # make the data NumPy array available to KlongPy code by passing it into the interpreter
218
- # we are creating a symbol in KlongPy called 'data' and assigning the external NumPy array value
219
- klong['data'] = data
220
- # define the average function in KlongPY
221
- klong('avg::{(+/x)%#x}')
222
- # call the average function with the external data and return the result.
223
- r = klong('avg(data)')
224
- print(r) # expected value: 3
225
- ```
226
-
227
- 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).
228
-
229
- How about we use the NumPy FFT?
230
-
231
- ```kgpy
232
- ?> .pyf("numpy";"fft");fft::.pya(fft;"fft")
233
- :monad
234
- ?> signal::[0.0 1.0 0.0 -1.0] :" Example simple signal
235
- [0.0 1.0 0.0 -1.0]
236
- ?> result::fft(signal)
237
- [0j -2j 0j 2j]
238
- ```
239
-
240
- Now you can use NumPy or other libraries to provide complex functions while KlongPy lets you quickly prepare and process the vectors.
241
-
242
- There's a lot more we can do with interop but let's move on for now!
243
-
244
- ## 4. Database Functionality
245
-
246
- 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.
247
-
248
- It's easy to create a table and a db to query:
249
-
250
- ```kgpy
251
- ?> .py("klongpy.db")
252
- ?> t::.table([["name" ["Alice" "Bob"]] ["age" [25 30]]])
253
- name age
254
- Alice 25
255
- Bob 30
256
- ?> db::.db(:{},"T",t)
257
- ?> db("select * from T where age > 27")
258
- name age
259
- Bob 30
260
- ```
261
-
262
- ## 5. IPC, Remote Function Calls and Asynchronous operations
263
-
264
- Inter Process Communication (IPC) lets you build distributed and interconnected KlongPy programs and services.
265
-
266
- 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.
267
-
268
- 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.
269
-
270
- Start a server in one terminal:
271
-
272
- ```kgpy
273
- ?> avg::{(+/x)%#x}
274
- :monad
275
- ?> .srv(8888)
276
- 1
277
- ```
278
-
279
- 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)
280
-
281
- ```kgpy
282
- ?> f::.cli(8888) :" connect to the server
283
- remote[localhost:8888]:fn
284
- ?> f(:avg,,!100) : call the remote function "avg" directly with the paramter !100
285
- 49.5
286
- ```
287
-
288
- Let's get fancy and make a local proxy to the remote function:
289
-
290
- ```kgpy
291
- ?> myavg::f(:avg) :" reference the remote function by it's symbol :avg and assign to a local variable called myavg
292
- remote[localhost:8888]:fn:avg:monad
293
- ?> myavg(!100) :" this runs on the server with !100 array passed to it as a parameter
294
- 49.5
295
- ```
296
-
297
- Since remote functions may take a while we can wrap them with an async wrapper and have it call our callback when completed:
298
-
299
- ```kgpy
300
- ?> afn::.async(myavg;{.d("Avg calculated: ");.p(x)})
301
- async::monad
302
- ?> afn(!100)
303
- Avg calculated: 49.5
304
- 1
305
- ```
306
-
307
- ## 6. Web Server Implementation
308
-
309
- 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.
310
-
311
- Let's create a file called web.kg with the following code that adds one index handler:
312
-
313
- ```text
314
- .py("klongpy.web")
315
- data::!10
316
- index::{x; "Hello, Klong World! ",data}
317
- .web(8888;:{},"/",index;:{})
318
- .p("ready at http://localhost:8888")
319
- ```
320
-
321
- We can run this web server as follows:
322
-
323
- ```bash
324
- $ kgpy web.kg
325
- ready at http://localhost:8888
326
- ```
327
-
328
- In another terminal:
329
-
330
- ```bash
331
- $ curl http://localhost:8888
332
- ['Hello, Klong World! ' 0 1 2 3 4 5 6 7 8 9]
333
- ```
334
-
335
- ## Conclusion
336
-
337
- 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.
338
-
339
- [Check out the examples folder for more](https://github.com/briangu/klongpy/tree/main/examples).
340
-
341
- # Installation
342
-
343
- ### CPU
344
-
345
- ```bash
346
- pip3 install klongpy
347
- ```
348
-
349
- ### GPU support
350
-
351
- Choose your CuPy prebuilt binary or from source. Note, the [ROCM](docs/ROCM.md) support for CuPy is experimental and likely will have issues.
352
-
353
- 'cupy' => build from source
354
- 'cuda12x' => "cupy-cuda12x"
355
- 'cuda11x' => "cupy-cuda11x"
356
- 'cuda111' => "cupy-cuda111"
357
- 'cuda110' => "cupy-cuda110"
358
- 'cuda102' => "cupy-cuda102"
359
- 'rocm-5-0' => "cupy-rocm-5-0"
360
- 'rocm-4-3' => "cupy-rocm-4-3"
361
-
362
- ```bash
363
- pip3 install "klongpy[cupy]"
364
- ```
365
-
366
- ### All application tools (db, web, REPL, etc.)
367
-
368
- ```bash
369
- pip3 install "klongpy[full]"
370
- ```
371
-
372
- # Status
373
-
374
- 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.
375
-
376
- 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.
377
-
378
- Primary ongoing work includes:
379
-
380
- * Additional tools to make KlongPy applications more capable.
381
- * Additional syntax error help
382
- * Actively switch between CuPy and NumPy when incompatibilities are present
383
-
384
- # Differences from Klong
385
-
386
- KlongPy is effectively a superset of the Klong language, but has some key differences:
387
-
388
- * Infinite precision: The main difference in this implementation of Klong is the lack of infinite precision. By using NumPy we are restricted to doubles.
389
- * Python integration: Most notably, the ".py" command allows direct import of Python modules into the current Klong context.
390
- * KlongPy aims to be more "batteries included" approach to modules and contains additional features such as IPC, Web service, Websockets, etc.
391
-
392
- # Related
393
-
394
- * [Klupyter - KlongPy in Jupyter Notebooks](https://github.com/briangu/klupyter)
395
- * [Visual Studio Code Syntax Highlighting](https://github.com/briangu/klongpy-vscode)
396
- * [Advent Of Code in KlongPy](https://github.com/briangu/aoc)
397
-
398
- ## Develop
399
-
400
- git clone https://github.com/briangu/klongpy.git
401
- cd klongpy
402
- python3 setup.py develop
403
-
404
- ### Running tests
405
-
406
- ```bash
407
- python3 -m unittest
408
- ```
409
-
410
- # Acknowledgement
411
-
412
- HUGE thanks to Nils M Holm for his work on Klong and providing the foundations for this interesting project.
@@ -1,72 +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=CRXiq9epjjUGGFEJW46KhrakuU-hvQ6zlMyVLmAubmA,27396
5
- klongpy/dyads.py,sha256=Fhr2u2PgLKKyBOaiB8ofyDl3-TDceoSmgfrLBj5WyFI,31247
6
- klongpy/interpreter.py,sha256=AH4LEv3jhgmupgJrvwqMbW_F2EwpmZFKtOMdKc_SJzM,23981
7
- klongpy/monads.py,sha256=6PoLROije2u-ojQZPu2f5FYnRav02Bx8eovrm2C29NY,14158
8
- klongpy/sys_fn.py,sha256=MnnP0tHHnbs2krfiYN88jWbZLsZ2jqPQmZlOrbMVuxk,23725
9
- klongpy/sys_fn_ipc.py,sha256=O_QAEvJtkmcom-CdPOqpqhED7O8euqIn6Gc2NGT45ZA,35687
10
- klongpy/sys_fn_timer.py,sha256=wY9Xx_zA3LOHnAm9ltFvr9OAOXNcnoWQVNYIniDQlSQ,2945
11
- klongpy/sys_var.py,sha256=x4Jq5JwnQrwdU54vxh03JuunKBb6nQoAGOoxvQAk1w4,4322
12
- klongpy/utils.py,sha256=nuevztUECi73_H0rrUX8Og19GUEdgkULp5tb2pirhVU,749
13
- klongpy/db/__init__.py,sha256=KUEKYPphDAYLdRfzcRuvj3Mv9ti6x_y9hjIzNh0ufRI,282
14
- klongpy/db/df_cache.py,sha256=_2tI3Gv5nzASlQfnFiwnXrkPnZ-mzJzyM0tt_gi3c5o,3325
15
- klongpy/db/file_cache.py,sha256=MnSTRB0B8yi8yAHFXGqduqaBqGhllLKxo1rrqMJ6-ik,9294
16
- klongpy/db/helpers.py,sha256=vdxSY2W-N13cBF3PUi86WlecGSz0ZkJN0OR7Jb6E9iM,1457
17
- klongpy/db/sys_fn_db.py,sha256=R5yfEa8LvCbCdSCV2BrZXfGrh7IbwSK9zuZ7OVRd8UI,9234
18
- klongpy/db/sys_fn_kvs.py,sha256=--FTMQyKdn8vBx0qG4mOBzdd2rtBfm0rW4c0AnB0G94,4114
19
- klongpy/lib/csv.kg,sha256=w6FvenQmkl0EF2kieQxxloNOFgZbt3M9IMSYSdImJcA,1498
20
- klongpy/lib/edt.kg,sha256=aJsjCxAkbfzwxWg8mF9nRDbCCt2fqtCWv0CPsq4SIHw,707
21
- klongpy/lib/eigenv.kg,sha256=_9iypo9qozqx5HfQR2h8aOx8kYlHGjuZ6NJ4vrfesd4,2118
22
- klongpy/lib/help.kg,sha256=xlnDZOZNS3vYKdgcr0oBSvUSYBlcuq6nDhFCnQ9KbsU,4260
23
- klongpy/lib/huffman.kg,sha256=u4vmvzhZ6_-rLgjUH_6HAFMuvqDxhrH1ZWqyNywStOk,637
24
- klongpy/lib/math.kg,sha256=pIFXlEV_-NzyYobqk3ofvW4Mte-4EqYmSWkwkA8AyLw,10118
25
- klongpy/lib/nstat.kg,sha256=1besBcCWp067aOv86jHPVmPQMtEWpC41uU1W_pET4yI,18920
26
- klongpy/lib/print.kg,sha256=v29mWgKpGYbAZGmif3F7rtrhdbmX4TZu-ezMgpB9oVk,78
27
- klongpy/lib/set.kg,sha256=KGkBqOeJjEZYKd8LS-lu1RPx5KcqjIxl7-7XpUaH8VI,887
28
- klongpy/lib/spline.kg,sha256=8kVvX9gsieR5f2hZDx0M_oKmJl7CP6Nn0hJssdcXkwk,1454
29
- klongpy/lib/time.kg,sha256=tJPknPGXHa_239PBMscg2VSaJ3ZV6SVRbADtTtE1a_4,359
30
- klongpy/lib/util.kg,sha256=LXwPtmcYZUv3Vs5eFt-1RqTvr7cn-_RKLKaSnLLN5gc,440
31
- klongpy/web/__init__.py,sha256=lM_40n_qzwYSx_OFi4RqFwsxQe8GGBtJm3_GLLxn9-8,101
32
- klongpy/web/sys_fn_web.py,sha256=En9_8Xh1uIaGz8CRyWsYuwpt0rbpNWvDCKFJ6KZpU5o,4710
33
- klongpy/ws/__init__.py,sha256=GKl5804W3XNkDER0mkdFf-4cIVjgeP9M3tfNg_tCv3c,114
34
- klongpy/ws/sys_fn_ws.py,sha256=Ba6MmmTS6cWHlruGgNznNXXPQX2zaBQmAEwkz9ge7sk,18300
35
- klongpy-0.6.8.data/scripts/kgpy,sha256=nDF66LclUBK6qILB2dgJ9VKAlGlPKMQfoJ4CvH5d_UQ,12119
36
- tests/__init__.py,sha256=xdETQVm8SNlASCru27aks1KZwSs2Oh-0NR5zrccSqb0,221
37
- tests/gen_join_over.py,sha256=ZiliJS6Lz0rqaZAfAeJFbPOU109PRF0QFE6262a4TPU,3684
38
- tests/gen_py_suite.py,sha256=ihXihalZkjN9Poy3m-1FVGdZy_YYWS0CEkY68pDgGso,2495
39
- tests/gen_test_fn.py,sha256=thoxQcqwY3ANClYn2PGtpRsm8XPPZWLActPPEqbwtgg,9894
40
- tests/perf_async.py,sha256=p9hMNal65LUu3Z8Of7878ZHiSKQtwEJAqbWZzNLt5tQ,736
41
- tests/perf_avg.py,sha256=Vriws6Xco-1BXoZKxzyOz904PeDF_B8TmOzStjCtTp4,483
42
- tests/perf_duckdb.py,sha256=QPa1AO1iuAFv7zenrtjUmKVpyE6Ep3d-_E84noFSEk0,737
43
- tests/perf_gen.py,sha256=zxtZC1hspUURr5dp8U5jsaSVo5yNbQDuq1I6-KcxYM8,1123
44
- tests/perf_ipc_overhead.py,sha256=u3w-3bKNn88Ul9Zd1dFGjkMoUAv9P_veRQg_dRXiQOs,1172
45
- tests/perf_join.py,sha256=LPRgbOvWd0qttC2rE210l9RjlIRKCq4EFW3N3ifqwRQ,1143
46
- tests/perf_load.py,sha256=EOs5Zf8SvqNaW7rftWyGwM6jWYUQPGBZO4jhFzJzZoM,310
47
- tests/perf_prog.py,sha256=Vm6V48McBgNGaH5X26JydajPsD8m46SYpxvc_Qs-o0Y,566
48
- tests/perf_serdes.py,sha256=1tw3fK8hUcorxQ123zDNOr8X0-Exirv-o_ufifYVBwE,1829
49
- tests/perf_sys_fn_db.py,sha256=mjoskDzjRJQL4xZULtOm4_y0r2GT8WhgGR1RdhNLjqw,5015
50
- tests/perf_vector.py,sha256=p76TVCS5szG0BX7rzquvKb7xikxUQOUmQttvTS0EH44,976
51
- tests/test_accel.py,sha256=apKi0PN9l9ztDLTwtdo6esWCl7_Yo97xljfNY0q9hug,6305
52
- tests/test_df_cache.py,sha256=vK36B0ENNwTYgv_JvRZimum9EEoPw-qgi4BWQWHRqQQ,3302
53
- tests/test_examples.py,sha256=hfpCQlcLR4pjUeSk9uAhtgnsjLEHLc_sfvRRWq8W1iY,2131
54
- tests/test_extra_suite.py,sha256=WPIA_UcP5BVvZIlkiDMUx_877ts3rYoVLo0grQh4JW8,12967
55
- tests/test_file_cache.py,sha256=lkE4bXPR9qp6wRdNHcG0f0Fb_BBB-2oocRttmCbXT7A,7733
56
- tests/test_interop.py,sha256=efUVa-IB43TecUhOm1rfTlK9G6kcf0U4q6EEVf06gaE,5837
57
- tests/test_kgtests.py,sha256=7lUgKYt9TQiYxAXWqE4VuaZo7frhbzSd9ofa6_pWBLE,2190
58
- tests/test_known_bugs.py,sha256=shBMW2rwQV0CLtrPZZ54TDFII7W5fxi7AOpZyvbydM8,6481
59
- tests/test_prog.py,sha256=8P019M-hiW9jxe9FgQS3Q7wqxoTrkhclMTk6xO4HBWU,3311
60
- tests/test_suite.py,sha256=cKTH9ICQUFPyM2xcmQNuS_jueDHLD2ukVMeM_KstTbQ,73051
61
- tests/test_suite_file.py,sha256=zZLXK1xEQgUH0OO9J53jkF4j0rjbgIXsWlsNo5puriA,4027
62
- tests/test_sys_fn.py,sha256=iGoalDXEw2LEIRGYgYIhc1rc-rU5wCNbRyvcr6nYoPw,15695
63
- tests/test_sys_fn_db.py,sha256=iX5sSJGzVMaN_GnhNQE_b6mWCIUYrDmE25KdubXNQL8,2471
64
- tests/test_sys_fn_ipc.py,sha256=tV7uCGxXQCHZQ2CkffD4j5h01TYBe1ozC_wImiANyHA,21605
65
- tests/test_sys_fn_timer.py,sha256=VUfi1AK9SCzA9g5IgbfpdEMW2AP4-9dgVOpJXhMMQhA,4447
66
- tests/test_util.py,sha256=k4UCR0avjWNxo_jO710x32AAMOAePOx79EOt58wL584,7942
67
- tests/utils.py,sha256=QrLAR4-WXVSDrC60qhl78_NE-3idp0mgLJmSZ5seyWw,3721
68
- klongpy-0.6.8.dist-info/LICENSE,sha256=Nk1iW-tI7n0z8R2jMqVm9SuFIoa8iukXsFcJoPqQgns,1071
69
- klongpy-0.6.8.dist-info/METADATA,sha256=3znv7SQ4tsMpZLeR5g6OhfQ2kj8eK_CKHM21I7XYmSQ,16421
70
- klongpy-0.6.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
71
- klongpy-0.6.8.dist-info/top_level.txt,sha256=1dsI3MhtibeAZuB7WPW58dpNgyGvXLX5EEHqm46NQYo,14
72
- klongpy-0.6.8.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
-