chemql-python 1.6.10__tar.gz → 1.7.0__tar.gz

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 (69) hide show
  1. {chemql_python-1.6.10 → chemql_python-1.7.0}/PKG-INFO +246 -15
  2. {chemql_python-1.6.10 → chemql_python-1.7.0}/README.md +241 -14
  3. {chemql_python-1.6.10 → chemql_python-1.7.0}/pyproject.toml +6 -1
  4. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/__init__.py +467 -47
  5. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/codecql.py +42 -15
  6. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/codecql_gui_core.py +1 -4
  7. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/codecqlx.py +575 -65
  8. chemql_python-1.7.0/src/chemql/data_analysis/__init__.py +13 -0
  9. chemql_python-1.7.0/src/chemql/data_analysis/images.py +79 -0
  10. chemql_python-1.7.0/src/chemql/data_analysis/spreadsheet.py +475 -0
  11. chemql_python-1.7.0/src/chemql/data_analysis/visualization/__init__.py +63 -0
  12. chemql_python-1.7.0/src/chemql/data_analysis/visualization/area.py +91 -0
  13. chemql_python-1.7.0/src/chemql/data_analysis/visualization/bar.py +726 -0
  14. chemql_python-1.7.0/src/chemql/data_analysis/visualization/boxplot.py +324 -0
  15. chemql_python-1.7.0/src/chemql/data_analysis/visualization/candlestick.py +260 -0
  16. chemql_python-1.7.0/src/chemql/data_analysis/visualization/common.py +1104 -0
  17. chemql_python-1.7.0/src/chemql/data_analysis/visualization/heatmap.py +301 -0
  18. chemql_python-1.7.0/src/chemql/data_analysis/visualization/histogram.py +261 -0
  19. chemql_python-1.7.0/src/chemql/data_analysis/visualization/line.py +334 -0
  20. chemql_python-1.7.0/src/chemql/data_analysis/visualization/main.py +443 -0
  21. chemql_python-1.7.0/src/chemql/data_analysis/visualization/pie.py +240 -0
  22. chemql_python-1.7.0/src/chemql/data_analysis/visualization/scatter.py +327 -0
  23. chemql_python-1.7.0/src/chemql/logo64-macos.png +0 -0
  24. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql_python.egg-info/PKG-INFO +246 -15
  25. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql_python.egg-info/SOURCES.txt +23 -0
  26. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql_python.egg-info/requires.txt +4 -0
  27. {chemql_python-1.6.10 → chemql_python-1.7.0}/tests/test_codecql.py +42 -7
  28. chemql_python-1.7.0/tests/test_codecqlx_fonts.py +27 -0
  29. chemql_python-1.7.0/tests/test_codecqlx_icon.py +15 -0
  30. chemql_python-1.7.0/tests/test_codecqlx_theme.py +65 -0
  31. chemql_python-1.7.0/tests/test_data_analysis.py +105 -0
  32. chemql_python-1.7.0/tests/test_function_parameters.py +134 -0
  33. chemql_python-1.7.0/tests/test_images_and_binary.py +63 -0
  34. {chemql_python-1.6.10 → chemql_python-1.7.0}/tests/test_public_api.py +6 -0
  35. chemql_python-1.7.0/tests/test_repl_history.py +34 -0
  36. {chemql_python-1.6.10 → chemql_python-1.7.0}/LICENSE +0 -0
  37. {chemql_python-1.6.10 → chemql_python-1.7.0}/setup.cfg +0 -0
  38. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/__main__.py +0 -0
  39. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/build.py +0 -0
  40. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/colors.json +0 -0
  41. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/BondEnergies.json +0 -0
  42. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/MoleculeBonds.json +0 -0
  43. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/Molecules.json +0 -0
  44. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/PeriodicTableJSON.json +0 -0
  45. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/Reactions.json +0 -0
  46. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  47. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  48. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/highlighting.json +0 -0
  49. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/highlighting.py +0 -0
  50. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/html/periodic_table.html +0 -0
  51. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/logo64.png +0 -0
  52. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/README.md +0 -0
  53. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/collections.cql +0 -0
  54. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/datetime.cql +0 -0
  55. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/decimal.cql +0 -0
  56. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/fractions.cql +0 -0
  57. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/json.cql +0 -0
  58. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/math/statistics.cql +0 -0
  59. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/math.cql +0 -0
  60. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/pathlib.cql +0 -0
  61. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/random.cql +0 -0
  62. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql/stdlib/text.cql +0 -0
  63. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  64. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql_python.egg-info/entry_points.txt +0 -0
  65. {chemql_python-1.6.10 → chemql_python-1.7.0}/src/chemql_python.egg-info/top_level.txt +0 -0
  66. {chemql_python-1.6.10 → chemql_python-1.7.0}/tests/test_external_molecule_lookup.py +0 -0
  67. {chemql_python-1.6.10 → chemql_python-1.7.0}/tests/test_reactions.py +0 -0
  68. {chemql_python-1.6.10 → chemql_python-1.7.0}/tests/test_stdlib.py +0 -0
  69. {chemql_python-1.6.10 → chemql_python-1.7.0}/tests/test_structured_types.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: chemql-python
3
- Version: 1.6.10
3
+ Version: 1.7.0
4
4
  Summary: A chemistry-focused query language and REPL
5
5
  Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
6
6
  Requires-Python: >=3.12
@@ -8,6 +8,10 @@ Description-Content-Type: text/markdown
8
8
  License-File: LICENSE
9
9
  Requires-Dist: prompt_toolkit>=3.0
10
10
  Requires-Dist: rich>=13.7
11
+ Requires-Dist: pandas>=2.0
12
+ Requires-Dist: openpyxl>=3.1
13
+ Requires-Dist: xlrd>=2.0
14
+ Requires-Dist: pillow>=10.0
11
15
  Provides-Extra: test
12
16
  Requires-Dist: pytest>=8.0; extra == "test"
13
17
  Dynamic: license-file
@@ -20,9 +24,9 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
20
24
 
21
25
  - **Distribution name:** `chemql-python`
22
26
  - **Import / CLI name:** `chemql`
23
- - **Language version:** `1.6.10` (per `chemql.__version__`)
24
- - **Editor version:** `codecql 0.1.1`
25
- - **GUI Editor version:** `CodecQLX 1.1.0`
27
+ - **Language version:** `1.7.0` (per `chemql.__version__`)
28
+ - **Editor version:** `codecql 0.1.2`
29
+ - **GUI Editor version:** `CodecQLX 1.1.1`
26
30
  - **Python import / CLI name:** `chemql`
27
31
  - **Author:** Mohammad Rakibul Islam
28
32
  - **Minimum Python:** **3.12+** (verified with `vermin`)
@@ -38,6 +42,38 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
38
42
  pip install chemql-python
39
43
  ```
40
44
 
45
+ The data-analysis tools are installed with ChemQL and available in the
46
+ `chemql.data_analysis` package. In the REPL, chart helpers render directly:
47
+
48
+ ```text
49
+ >>> draw_bar_chart{[3, 5, 2], ["A", "B", "C"]}
50
+ >>> help{data_analysis}
51
+ ```
52
+
53
+ ChemQL code can call the same helpers or construct a chart directly:
54
+
55
+ ```chemql
56
+ [[[
57
+ print(draw_bar_chart([3, 5, 2], ["A", "B", "C"]))
58
+
59
+ chart = BarChart([12, 18, 15], ["Q1", "Q2", "Q3"])
60
+ print(chart)
61
+
62
+ sheet = Spreadsheet(3, 2)
63
+ sheet["A"] = ["Quarter", "Q1", "Q2"]
64
+ sheet["B"] = ["Sales", 12, 18]
65
+ run_spreadsheet_gui(sheet)
66
+ ]]]
67
+ ```
68
+
69
+ The same APIs are also importable from ordinary Python:
70
+
71
+ ```python
72
+ from chemql import BarChart, Spreadsheet, draw_bar_chart, run_spreadsheet_gui
73
+
74
+ print(draw_bar_chart([3, 5, 2], ["A", "B", "C"]))
75
+ ```
76
+
41
77
  Verify:
42
78
 
43
79
  ```bash
@@ -90,6 +126,11 @@ Open a file in the bundled editor:
90
126
  chemql edit script.cql
91
127
  ```
92
128
 
129
+ Interactive REPL commands are saved between sessions in
130
+ `~/.chemql/.repl_history`; press **Up** in a new session to recall previous
131
+ commands. The history file is plain text, so avoid entering secrets at the
132
+ prompt.
133
+
93
134
  ---
94
135
 
95
136
  ## Core commands
@@ -210,6 +251,159 @@ Reference conditions are °C at 1 atm (mp/bp), g/cm³ at 25 °C (density), and `
210
251
 
211
252
  ---
212
253
 
254
+ ## Data analysis and visualization
255
+
256
+ ChemQL includes spreadsheet tools and a complete charting toolkit. The
257
+ dependencies for data analysis (pandas, Excel readers, and Pillow for PNG
258
+ export) are installed with `pip install chemql-python`; there is no separate
259
+ extra to enable. Terminal charts work in the REPL, scripts, and redirected
260
+ output. Interactive charts use Tkinter, which may need to be installed
261
+ separately on Linux.
262
+
263
+ ### Chart types
264
+
265
+ | Chart | Input | Useful options |
266
+ |---|---|---|
267
+ | Bar | A list of values or a dictionary of named series | Grouped/stacked, horizontal, sort, value labels |
268
+ | Line | Values or named series, with optional category labels | Multiple series, axis ranges, smoothing in the GUI |
269
+ | Area | Values or named series | Filled or stacked areas |
270
+ | Pie / donut | Non-negative values and optional labels | Donut hole, sorting, percentage labels |
271
+ | Scatter | `(x, y)` pairs or named point series | Point labels, axis ranges |
272
+ | Histogram | Values or named series | Explicit bin count/edges, density |
273
+ | Box plot | One list, lists of groups, or a dictionary of groups | Quartiles, whiskers, outliers |
274
+ | Heat map | A rectangular matrix | Row/column labels, value scale |
275
+ | Candlestick | `(open, high, low, close)` records | Category labels and OHLC validation |
276
+
277
+ Chart classes accept more presentation and scale options than the short
278
+ ChemQL helpers. They are available in embedded Python along with `Spreadsheet`
279
+ and `Vector`.
280
+
281
+ ### Print images in the terminal
282
+
283
+ Pillow can turn an image file into terminal-sized half-block output. Color is
284
+ selected automatically when standard output is a color terminal; pass a width
285
+ to control its size, or `False` for monochrome shading:
286
+
287
+ ```chemql
288
+ print_image{"molecule.png"}
289
+ print_image{"molecule.png", 60}
290
+ print_image{"molecule.png", 40, False}
291
+ ```
292
+
293
+ In Python, `image_to_terminal(path, width=48, colors=None)` returns the
294
+ rendered string, while `print_image(...)` writes it directly to standard
295
+ output. It also accepts a Pillow `Image` object.
296
+
297
+ ### Plot from the REPL or a ChemQL script
298
+
299
+ Use the `draw_*` helpers for immediate terminal output. Inputs can be ChemQL
300
+ variables, Python-style lists/dictionaries, or values returned by other
301
+ ChemQL expressions:
302
+
303
+ ```chemql
304
+ let months = ["Jan", "Feb", "Mar", "Apr"]
305
+ let sales = [18, 22, 16, 29]
306
+ draw_bar_chart{sales, months}
307
+ draw_line_chart{sales, months}
308
+ draw_area_chart{sales, months}
309
+ draw_pie_chart{sales, months}
310
+ draw_histogram{sales}
311
+ draw_box_plot{sales}
312
+
313
+ let temperatures = [[12, 14, 17, 15], [8, 10, 13, 11]]
314
+ draw_heat_map{temperatures, ["North", "South"], months}
315
+
316
+ draw_scatter_plot{[(1, 2), (2, 4), (3, 3)]}
317
+ draw_candlestick_chart{[(10, 13, 9, 12), (12, 14, 10, 11)], ["Mon", "Tue"]}
318
+ ```
319
+
320
+ `help{data_analysis}` lists the helpers, and `help{draw_bar_chart}` gives a
321
+ specific signature and example. The helpers return the rendered chart text, so
322
+ they also work inside ChemQL expressions and Python blocks:
323
+
324
+ ```chemql
325
+ [[[
326
+ print(draw_bar_chart([18, 22, 16, 29], ["Jan", "Feb", "Mar", "Apr"]))
327
+ chart = BarChart([18, 22, 16, 29], ["Jan", "Feb", "Mar", "Apr"], title="Sales")
328
+ print(chart)
329
+ ]]]
330
+ ```
331
+
332
+ ### Interactive GUI charts from ChemQL
333
+
334
+ Use a corresponding `show_*` helper to open an interactive window. It accepts
335
+ the same data shape as its `draw_*` counterpart; an optional final `"dark"`
336
+ or `"light"` argument selects the initial theme:
337
+
338
+ ```chemql
339
+ show_bar_chart{sales, months}
340
+ show_line_chart{sales, months, "dark"}
341
+ show_area_chart{sales, months}
342
+ show_pie_chart{sales, months}
343
+ show_histogram{sales}
344
+ show_box_plot{sales}
345
+ show_heat_map{temperatures, ["North", "South"], months}
346
+ show_scatter_plot{[(1, 2), (2, 4), (3, 3)]}
347
+ show_candlestick_chart{[(10, 13, 9, 12), (12, 14, 10, 11)], ["Mon", "Tue"]}
348
+ ```
349
+
350
+ The call opens the window and returns to the REPL after it closes. In the
351
+ window, hover for data tooltips, click legend items to hide/show series,
352
+ double-click a legend item to isolate it, press `t` to toggle light/dark mode,
353
+ and press `r` to restore all series. Right-click for the context menu to export
354
+ the current chart as PNG or print its text version in the terminal.
355
+
356
+ For chart-specific options, use the GUI classes directly in an embedded Python
357
+ block, then call `.run()`:
358
+
359
+ ```chemql
360
+ [[[
361
+ gui = BarChartGUI(
362
+ {"Online": [12, 18, 21], "Retail": [9, 14, 17]},
363
+ ["Q1", "Q2", "Q3"],
364
+ mode="stacked",
365
+ theme="dark",
366
+ chart_title="Quarterly sales",
367
+ )
368
+ gui.run()
369
+ ]]]
370
+ ```
371
+
372
+ ### Spreadsheet dashboard
373
+
374
+ `Spreadsheet` stores labeled columns, supports cell/range access and formulas,
375
+ and can be passed directly to the GUI dashboard. The dashboard can also open
376
+ CSV, XLSX, and XLS files, infer numeric columns, and chart selected data as a
377
+ bar, line, area, pie, scatter, histogram, box plot, heat map, or candlestick:
378
+
379
+ ```chemql
380
+ let sheet = Spreadsheet{4, 2}
381
+ [[[
382
+ sheet["A"] = ["Quarter", "Q1", "Q2", "Q3"]
383
+ sheet["B"] = ["Sales", 12, 18, 15]
384
+ ]]]
385
+ run_spreadsheet_gui{sheet}
386
+ ```
387
+
388
+ Call `run_spreadsheet_gui{}` with no argument to open the file picker. From a
389
+ terminal, the bundled chart demo can open a spreadsheet directly:
390
+
391
+ ```bash
392
+ python -m chemql.data_analysis.visualization.main --spreadsheet sales.xlsx --theme dark
393
+ ```
394
+
395
+ The same API is available to normal Python programs:
396
+
397
+ ```python
398
+ from chemql import BarChart, BarChartGUI, Spreadsheet
399
+ from chemql.data_analysis.visualization import run_spreadsheet_gui
400
+
401
+ print(BarChart([12, 18, 15], ["Q1", "Q2", "Q3"], title="Sales"))
402
+ BarChartGUI([12, 18, 15], ["Q1", "Q2", "Q3"], theme="dark").run()
403
+ ```
404
+
405
+ ---
406
+
213
407
  ## Type system
214
408
 
215
409
  ### Structs — mutable, methods, inheritance
@@ -332,17 +526,39 @@ isEven{4}
332
526
  ## Functions, arguments, macros
333
527
 
334
528
  ```chemql
335
- func square
336
- return \1 * \1
529
+ func greet{name, age=10}
530
+ let value = str{name}
531
+ return value, age, arguments
337
532
  endfunc
533
+
534
+ greet{"Jacob"} // ("Jacob", 10, ["Jacob", 10])
535
+ greet{age=30, name="Jacob"} // ("Jacob", 30, ["Jacob", 30])
338
536
  ```
339
537
 
340
- **Two access forms:**
538
+ Declare parameters inside `{}` after the function name. Parameters can be
539
+ required, have a default (`age=10`), or be optional (`age?`, equivalent to
540
+ `age=None`). Calls may pass values positionally or by name; required
541
+ parameters still need a value.
341
542
 
342
- - `\1`, `\2`, … — 1-indexed positional placeholders, **substituted textually** (works inside strings; `\10` = tenth argument, greedy `\d+`)
343
- - `arguments` — a per-call `list` of positional arguments, `arguments[0]` indexed from 0, **function scope only**
543
+ `arguments` is a per-call list in declared parameter order, including defaults
544
+ and optional `None` values. `kwarguments` contains explicitly supplied
545
+ keyword arguments and supports both mapping and attribute access:
344
546
 
345
- > ⚠️ `arguments` is not available in macro bodies — macros get `\N` only.
547
+ ```chemql
548
+ func describe{name, age?}
549
+ if age is None
550
+ return "I am " + str{name}
551
+ endif
552
+ return "I am " + str{name} + " and I am " + str{age}
553
+ endfunc
554
+
555
+ describe{name="Jacob"} // "I am Jacob"
556
+ ```
557
+
558
+ Legacy functions may omit the parameter list and continue to use `\1`, `\2`,
559
+ and so on. These 1-indexed placeholders also remain available in parameterized
560
+ functions. `arguments` and `kwarguments` are function-scope values; macros
561
+ still use `\N` placeholders and do not receive either value.
346
562
 
347
563
  ### Definitions (object-like)
348
564
 
@@ -476,7 +692,7 @@ ls
476
692
 
477
693
  | | |
478
694
  |---|---|
479
- | Version | 0.1.1 |
695
+ | Version | 0.1.2 |
480
696
  | Ships with | `chemql-python` |
481
697
  | Files | `.cql` (ChemQL), `.py`, `cqlpackage.json` / `cqlpackage.toml`, and any plain-text file |
482
698
 
@@ -516,12 +732,16 @@ Opening a path that does not exist starts an empty buffer; it is created on the
516
732
  | `Ctrl` + `↑` `↓` | Scroll the view without moving the text |
517
733
  | `Backspace`, `Delete` | Delete a character, or the selection |
518
734
  | `Ctrl+Backspace` / `Alt+Backspace` | Delete the word to the left |
735
+ | `Command+Backspace` (macOS, when sent as CSI-u) | Delete to the start of the line |
519
736
  | `Ctrl+Delete` / `Alt+Delete` | Delete the word to the right |
520
737
  | `Ctrl+C` / `Ctrl+Insert` | Copy the selection (editor + system clipboard when available). It does **not** quit |
521
738
  | `Ctrl+X` | Cut the selection |
522
739
  | `Ctrl+V` / `Shift+Insert` | Paste the editor's clipboard |
523
740
 
524
- Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so multi-line pastes arrive as a single insertion.
741
+ Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so
742
+ multi-line pastes arrive as a single insertion. The terminal must forward macOS Command-key
743
+ combinations using the CSI-u keyboard protocol; otherwise it may consume or remap them before
744
+ CodecQL receives them.
525
745
 
526
746
  **Auto-indent.** After a line that opens a block (`func`, `define NAME{}`, `struct`, `record`, `enum`, `namespace`, `if`, `elif`, `else`, `for`, `while`) or ends in a `\` continuation, the next line is indented with a tab. Pressing Enter after `endnamespace` removes one level of indentation. Other `end...` keywords do not dedent automatically.
527
747
 
@@ -829,7 +1049,6 @@ Each entry needs an `ansi256` number from 0 to 255, and an optional `channel` of
829
1049
  - Auto-dedent applies only after `endnamespace`.
830
1050
  - One file per session: there are no tabs or split editors.
831
1051
  - Tabs are drawn four columns wide.
832
- - CodecQL's Windows Backspace / Ctrl+Backspace are intentionally inverted relative to POSIX.
833
1052
 
834
1053
  ## CodecQLX — the desktop editor
835
1054
 
@@ -867,13 +1086,22 @@ the `chemql` package cannot be imported.
867
1086
  - Syntax highlighting and context-aware autocomplete for `.cql` files
868
1087
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
869
1088
  - File tree sidebar, recent files, and multiple editor tabs
1089
+ - Pillow-backed, scrollable previews for image files
1090
+ - Automatic hex-editor view for binary files; edit byte values and save with
1091
+ `Ctrl+S` (file length is kept fixed; offsets and ASCII are reference columns)
870
1092
  - Side-by-side editor panes for working with different files
871
1093
  - Query Console that executes ChemQL in-process and displays table or card results
872
1094
  - Interactive Periodic Table lookup
873
1095
  - Balance Equation panel
874
1096
  - Find and replace, bookmarks, zoom controls, and run-file/run-selection actions
875
- - Dark and light themes, font settings, autocomplete/minimap toggles, and
876
- per-token color preferences
1097
+ - Dark and light themes across the editor, file tree, menus, and panels, plus
1098
+ font settings, autocomplete/minimap toggles, and per-token color preferences
1099
+
1100
+ When enabled, CodecQLX prefers an installed programming font with ligature
1101
+ support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
1102
+ monospace font. Install a ligature font on your system; the native Tk text
1103
+ renderer and font must support shaping for ligature glyphs to appear. A custom
1104
+ font family selected in **Preferences > General** is kept as-is.
877
1105
 
878
1106
  Use **View** to toggle the file tree, Chemistry panel, and bottom panels.
879
1107
  Enable **View > Split Editor**, then choose **File > Open File in Other Pane**
@@ -897,6 +1125,9 @@ user profile (`%APPDATA%` on Windows).
897
1125
  | `Ctrl+F2` / `F2` / `Shift+F2` | Toggle / next / previous bookmark |
898
1126
  | `Ctrl+=` / `Ctrl+-` / `Ctrl+0` | Zoom in / out / reset |
899
1127
 
1128
+ Click the `×` at the right side of any editor tab to close that tab. Unsaved
1129
+ changes still prompt before the tab is closed.
1130
+
900
1131
  ---
901
1132
 
902
1133
  ## Standard library
@@ -6,9 +6,9 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
6
6
 
7
7
  - **Distribution name:** `chemql-python`
8
8
  - **Import / CLI name:** `chemql`
9
- - **Language version:** `1.6.10` (per `chemql.__version__`)
10
- - **Editor version:** `codecql 0.1.1`
11
- - **GUI Editor version:** `CodecQLX 1.1.0`
9
+ - **Language version:** `1.7.0` (per `chemql.__version__`)
10
+ - **Editor version:** `codecql 0.1.2`
11
+ - **GUI Editor version:** `CodecQLX 1.1.1`
12
12
  - **Python import / CLI name:** `chemql`
13
13
  - **Author:** Mohammad Rakibul Islam
14
14
  - **Minimum Python:** **3.12+** (verified with `vermin`)
@@ -24,6 +24,38 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
24
24
  pip install chemql-python
25
25
  ```
26
26
 
27
+ The data-analysis tools are installed with ChemQL and available in the
28
+ `chemql.data_analysis` package. In the REPL, chart helpers render directly:
29
+
30
+ ```text
31
+ >>> draw_bar_chart{[3, 5, 2], ["A", "B", "C"]}
32
+ >>> help{data_analysis}
33
+ ```
34
+
35
+ ChemQL code can call the same helpers or construct a chart directly:
36
+
37
+ ```chemql
38
+ [[[
39
+ print(draw_bar_chart([3, 5, 2], ["A", "B", "C"]))
40
+
41
+ chart = BarChart([12, 18, 15], ["Q1", "Q2", "Q3"])
42
+ print(chart)
43
+
44
+ sheet = Spreadsheet(3, 2)
45
+ sheet["A"] = ["Quarter", "Q1", "Q2"]
46
+ sheet["B"] = ["Sales", 12, 18]
47
+ run_spreadsheet_gui(sheet)
48
+ ]]]
49
+ ```
50
+
51
+ The same APIs are also importable from ordinary Python:
52
+
53
+ ```python
54
+ from chemql import BarChart, Spreadsheet, draw_bar_chart, run_spreadsheet_gui
55
+
56
+ print(draw_bar_chart([3, 5, 2], ["A", "B", "C"]))
57
+ ```
58
+
27
59
  Verify:
28
60
 
29
61
  ```bash
@@ -76,6 +108,11 @@ Open a file in the bundled editor:
76
108
  chemql edit script.cql
77
109
  ```
78
110
 
111
+ Interactive REPL commands are saved between sessions in
112
+ `~/.chemql/.repl_history`; press **Up** in a new session to recall previous
113
+ commands. The history file is plain text, so avoid entering secrets at the
114
+ prompt.
115
+
79
116
  ---
80
117
 
81
118
  ## Core commands
@@ -196,6 +233,159 @@ Reference conditions are °C at 1 atm (mp/bp), g/cm³ at 25 °C (density), and `
196
233
 
197
234
  ---
198
235
 
236
+ ## Data analysis and visualization
237
+
238
+ ChemQL includes spreadsheet tools and a complete charting toolkit. The
239
+ dependencies for data analysis (pandas, Excel readers, and Pillow for PNG
240
+ export) are installed with `pip install chemql-python`; there is no separate
241
+ extra to enable. Terminal charts work in the REPL, scripts, and redirected
242
+ output. Interactive charts use Tkinter, which may need to be installed
243
+ separately on Linux.
244
+
245
+ ### Chart types
246
+
247
+ | Chart | Input | Useful options |
248
+ |---|---|---|
249
+ | Bar | A list of values or a dictionary of named series | Grouped/stacked, horizontal, sort, value labels |
250
+ | Line | Values or named series, with optional category labels | Multiple series, axis ranges, smoothing in the GUI |
251
+ | Area | Values or named series | Filled or stacked areas |
252
+ | Pie / donut | Non-negative values and optional labels | Donut hole, sorting, percentage labels |
253
+ | Scatter | `(x, y)` pairs or named point series | Point labels, axis ranges |
254
+ | Histogram | Values or named series | Explicit bin count/edges, density |
255
+ | Box plot | One list, lists of groups, or a dictionary of groups | Quartiles, whiskers, outliers |
256
+ | Heat map | A rectangular matrix | Row/column labels, value scale |
257
+ | Candlestick | `(open, high, low, close)` records | Category labels and OHLC validation |
258
+
259
+ Chart classes accept more presentation and scale options than the short
260
+ ChemQL helpers. They are available in embedded Python along with `Spreadsheet`
261
+ and `Vector`.
262
+
263
+ ### Print images in the terminal
264
+
265
+ Pillow can turn an image file into terminal-sized half-block output. Color is
266
+ selected automatically when standard output is a color terminal; pass a width
267
+ to control its size, or `False` for monochrome shading:
268
+
269
+ ```chemql
270
+ print_image{"molecule.png"}
271
+ print_image{"molecule.png", 60}
272
+ print_image{"molecule.png", 40, False}
273
+ ```
274
+
275
+ In Python, `image_to_terminal(path, width=48, colors=None)` returns the
276
+ rendered string, while `print_image(...)` writes it directly to standard
277
+ output. It also accepts a Pillow `Image` object.
278
+
279
+ ### Plot from the REPL or a ChemQL script
280
+
281
+ Use the `draw_*` helpers for immediate terminal output. Inputs can be ChemQL
282
+ variables, Python-style lists/dictionaries, or values returned by other
283
+ ChemQL expressions:
284
+
285
+ ```chemql
286
+ let months = ["Jan", "Feb", "Mar", "Apr"]
287
+ let sales = [18, 22, 16, 29]
288
+ draw_bar_chart{sales, months}
289
+ draw_line_chart{sales, months}
290
+ draw_area_chart{sales, months}
291
+ draw_pie_chart{sales, months}
292
+ draw_histogram{sales}
293
+ draw_box_plot{sales}
294
+
295
+ let temperatures = [[12, 14, 17, 15], [8, 10, 13, 11]]
296
+ draw_heat_map{temperatures, ["North", "South"], months}
297
+
298
+ draw_scatter_plot{[(1, 2), (2, 4), (3, 3)]}
299
+ draw_candlestick_chart{[(10, 13, 9, 12), (12, 14, 10, 11)], ["Mon", "Tue"]}
300
+ ```
301
+
302
+ `help{data_analysis}` lists the helpers, and `help{draw_bar_chart}` gives a
303
+ specific signature and example. The helpers return the rendered chart text, so
304
+ they also work inside ChemQL expressions and Python blocks:
305
+
306
+ ```chemql
307
+ [[[
308
+ print(draw_bar_chart([18, 22, 16, 29], ["Jan", "Feb", "Mar", "Apr"]))
309
+ chart = BarChart([18, 22, 16, 29], ["Jan", "Feb", "Mar", "Apr"], title="Sales")
310
+ print(chart)
311
+ ]]]
312
+ ```
313
+
314
+ ### Interactive GUI charts from ChemQL
315
+
316
+ Use a corresponding `show_*` helper to open an interactive window. It accepts
317
+ the same data shape as its `draw_*` counterpart; an optional final `"dark"`
318
+ or `"light"` argument selects the initial theme:
319
+
320
+ ```chemql
321
+ show_bar_chart{sales, months}
322
+ show_line_chart{sales, months, "dark"}
323
+ show_area_chart{sales, months}
324
+ show_pie_chart{sales, months}
325
+ show_histogram{sales}
326
+ show_box_plot{sales}
327
+ show_heat_map{temperatures, ["North", "South"], months}
328
+ show_scatter_plot{[(1, 2), (2, 4), (3, 3)]}
329
+ show_candlestick_chart{[(10, 13, 9, 12), (12, 14, 10, 11)], ["Mon", "Tue"]}
330
+ ```
331
+
332
+ The call opens the window and returns to the REPL after it closes. In the
333
+ window, hover for data tooltips, click legend items to hide/show series,
334
+ double-click a legend item to isolate it, press `t` to toggle light/dark mode,
335
+ and press `r` to restore all series. Right-click for the context menu to export
336
+ the current chart as PNG or print its text version in the terminal.
337
+
338
+ For chart-specific options, use the GUI classes directly in an embedded Python
339
+ block, then call `.run()`:
340
+
341
+ ```chemql
342
+ [[[
343
+ gui = BarChartGUI(
344
+ {"Online": [12, 18, 21], "Retail": [9, 14, 17]},
345
+ ["Q1", "Q2", "Q3"],
346
+ mode="stacked",
347
+ theme="dark",
348
+ chart_title="Quarterly sales",
349
+ )
350
+ gui.run()
351
+ ]]]
352
+ ```
353
+
354
+ ### Spreadsheet dashboard
355
+
356
+ `Spreadsheet` stores labeled columns, supports cell/range access and formulas,
357
+ and can be passed directly to the GUI dashboard. The dashboard can also open
358
+ CSV, XLSX, and XLS files, infer numeric columns, and chart selected data as a
359
+ bar, line, area, pie, scatter, histogram, box plot, heat map, or candlestick:
360
+
361
+ ```chemql
362
+ let sheet = Spreadsheet{4, 2}
363
+ [[[
364
+ sheet["A"] = ["Quarter", "Q1", "Q2", "Q3"]
365
+ sheet["B"] = ["Sales", 12, 18, 15]
366
+ ]]]
367
+ run_spreadsheet_gui{sheet}
368
+ ```
369
+
370
+ Call `run_spreadsheet_gui{}` with no argument to open the file picker. From a
371
+ terminal, the bundled chart demo can open a spreadsheet directly:
372
+
373
+ ```bash
374
+ python -m chemql.data_analysis.visualization.main --spreadsheet sales.xlsx --theme dark
375
+ ```
376
+
377
+ The same API is available to normal Python programs:
378
+
379
+ ```python
380
+ from chemql import BarChart, BarChartGUI, Spreadsheet
381
+ from chemql.data_analysis.visualization import run_spreadsheet_gui
382
+
383
+ print(BarChart([12, 18, 15], ["Q1", "Q2", "Q3"], title="Sales"))
384
+ BarChartGUI([12, 18, 15], ["Q1", "Q2", "Q3"], theme="dark").run()
385
+ ```
386
+
387
+ ---
388
+
199
389
  ## Type system
200
390
 
201
391
  ### Structs — mutable, methods, inheritance
@@ -318,17 +508,39 @@ isEven{4}
318
508
  ## Functions, arguments, macros
319
509
 
320
510
  ```chemql
321
- func square
322
- return \1 * \1
511
+ func greet{name, age=10}
512
+ let value = str{name}
513
+ return value, age, arguments
323
514
  endfunc
515
+
516
+ greet{"Jacob"} // ("Jacob", 10, ["Jacob", 10])
517
+ greet{age=30, name="Jacob"} // ("Jacob", 30, ["Jacob", 30])
324
518
  ```
325
519
 
326
- **Two access forms:**
520
+ Declare parameters inside `{}` after the function name. Parameters can be
521
+ required, have a default (`age=10`), or be optional (`age?`, equivalent to
522
+ `age=None`). Calls may pass values positionally or by name; required
523
+ parameters still need a value.
327
524
 
328
- - `\1`, `\2`, … — 1-indexed positional placeholders, **substituted textually** (works inside strings; `\10` = tenth argument, greedy `\d+`)
329
- - `arguments` — a per-call `list` of positional arguments, `arguments[0]` indexed from 0, **function scope only**
525
+ `arguments` is a per-call list in declared parameter order, including defaults
526
+ and optional `None` values. `kwarguments` contains explicitly supplied
527
+ keyword arguments and supports both mapping and attribute access:
330
528
 
331
- > ⚠️ `arguments` is not available in macro bodies — macros get `\N` only.
529
+ ```chemql
530
+ func describe{name, age?}
531
+ if age is None
532
+ return "I am " + str{name}
533
+ endif
534
+ return "I am " + str{name} + " and I am " + str{age}
535
+ endfunc
536
+
537
+ describe{name="Jacob"} // "I am Jacob"
538
+ ```
539
+
540
+ Legacy functions may omit the parameter list and continue to use `\1`, `\2`,
541
+ and so on. These 1-indexed placeholders also remain available in parameterized
542
+ functions. `arguments` and `kwarguments` are function-scope values; macros
543
+ still use `\N` placeholders and do not receive either value.
332
544
 
333
545
  ### Definitions (object-like)
334
546
 
@@ -462,7 +674,7 @@ ls
462
674
 
463
675
  | | |
464
676
  |---|---|
465
- | Version | 0.1.1 |
677
+ | Version | 0.1.2 |
466
678
  | Ships with | `chemql-python` |
467
679
  | Files | `.cql` (ChemQL), `.py`, `cqlpackage.json` / `cqlpackage.toml`, and any plain-text file |
468
680
 
@@ -502,12 +714,16 @@ Opening a path that does not exist starts an empty buffer; it is created on the
502
714
  | `Ctrl` + `↑` `↓` | Scroll the view without moving the text |
503
715
  | `Backspace`, `Delete` | Delete a character, or the selection |
504
716
  | `Ctrl+Backspace` / `Alt+Backspace` | Delete the word to the left |
717
+ | `Command+Backspace` (macOS, when sent as CSI-u) | Delete to the start of the line |
505
718
  | `Ctrl+Delete` / `Alt+Delete` | Delete the word to the right |
506
719
  | `Ctrl+C` / `Ctrl+Insert` | Copy the selection (editor + system clipboard when available). It does **not** quit |
507
720
  | `Ctrl+X` | Cut the selection |
508
721
  | `Ctrl+V` / `Shift+Insert` | Paste the editor's clipboard |
509
722
 
510
- Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so multi-line pastes arrive as a single insertion.
723
+ Pasting from your terminal or OS clipboard also works: CodecQL enables bracketed paste, so
724
+ multi-line pastes arrive as a single insertion. The terminal must forward macOS Command-key
725
+ combinations using the CSI-u keyboard protocol; otherwise it may consume or remap them before
726
+ CodecQL receives them.
511
727
 
512
728
  **Auto-indent.** After a line that opens a block (`func`, `define NAME{}`, `struct`, `record`, `enum`, `namespace`, `if`, `elif`, `else`, `for`, `while`) or ends in a `\` continuation, the next line is indented with a tab. Pressing Enter after `endnamespace` removes one level of indentation. Other `end...` keywords do not dedent automatically.
513
729
 
@@ -815,7 +1031,6 @@ Each entry needs an `ansi256` number from 0 to 255, and an optional `channel` of
815
1031
  - Auto-dedent applies only after `endnamespace`.
816
1032
  - One file per session: there are no tabs or split editors.
817
1033
  - Tabs are drawn four columns wide.
818
- - CodecQL's Windows Backspace / Ctrl+Backspace are intentionally inverted relative to POSIX.
819
1034
 
820
1035
  ## CodecQLX — the desktop editor
821
1036
 
@@ -853,13 +1068,22 @@ the `chemql` package cannot be imported.
853
1068
  - Syntax highlighting and context-aware autocomplete for `.cql` files
854
1069
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
855
1070
  - File tree sidebar, recent files, and multiple editor tabs
1071
+ - Pillow-backed, scrollable previews for image files
1072
+ - Automatic hex-editor view for binary files; edit byte values and save with
1073
+ `Ctrl+S` (file length is kept fixed; offsets and ASCII are reference columns)
856
1074
  - Side-by-side editor panes for working with different files
857
1075
  - Query Console that executes ChemQL in-process and displays table or card results
858
1076
  - Interactive Periodic Table lookup
859
1077
  - Balance Equation panel
860
1078
  - Find and replace, bookmarks, zoom controls, and run-file/run-selection actions
861
- - Dark and light themes, font settings, autocomplete/minimap toggles, and
862
- per-token color preferences
1079
+ - Dark and light themes across the editor, file tree, menus, and panels, plus
1080
+ font settings, autocomplete/minimap toggles, and per-token color preferences
1081
+
1082
+ When enabled, CodecQLX prefers an installed programming font with ligature
1083
+ support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
1084
+ monospace font. Install a ligature font on your system; the native Tk text
1085
+ renderer and font must support shaping for ligature glyphs to appear. A custom
1086
+ font family selected in **Preferences > General** is kept as-is.
863
1087
 
864
1088
  Use **View** to toggle the file tree, Chemistry panel, and bottom panels.
865
1089
  Enable **View > Split Editor**, then choose **File > Open File in Other Pane**
@@ -883,6 +1107,9 @@ user profile (`%APPDATA%` on Windows).
883
1107
  | `Ctrl+F2` / `F2` / `Shift+F2` | Toggle / next / previous bookmark |
884
1108
  | `Ctrl+=` / `Ctrl+-` / `Ctrl+0` | Zoom in / out / reset |
885
1109
 
1110
+ Click the `×` at the right side of any editor tab to close that tab. Unsaved
1111
+ changes still prompt before the tab is closed.
1112
+
886
1113
  ---
887
1114
 
888
1115
  ## Standard library