chemql-python 1.6.11__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.11/src/chemql_python.egg-info → chemql_python-1.7.0}/PKG-INFO +232 -10
  2. chemql_python-1.6.11/PKG-INFO → chemql_python-1.7.0/README.md +228 -24
  3. {chemql_python-1.6.11 → chemql_python-1.7.0}/pyproject.toml +5 -1
  4. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/__init__.py +447 -47
  5. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/codecql.py +4 -2
  6. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/codecql_gui_core.py +1 -0
  7. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/codecqlx.py +542 -46
  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.6.11/README.md → chemql_python-1.7.0/src/chemql_python.egg-info/PKG-INFO +246 -10
  24. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql_python.egg-info/SOURCES.txt +20 -0
  25. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql_python.egg-info/requires.txt +4 -0
  26. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_codecql.py +12 -0
  27. chemql_python-1.7.0/tests/test_codecqlx_theme.py +65 -0
  28. chemql_python-1.7.0/tests/test_data_analysis.py +105 -0
  29. chemql_python-1.7.0/tests/test_function_parameters.py +134 -0
  30. chemql_python-1.7.0/tests/test_images_and_binary.py +63 -0
  31. chemql_python-1.7.0/tests/test_repl_history.py +34 -0
  32. {chemql_python-1.6.11 → chemql_python-1.7.0}/LICENSE +0 -0
  33. {chemql_python-1.6.11 → chemql_python-1.7.0}/setup.cfg +0 -0
  34. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/__main__.py +0 -0
  35. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/build.py +0 -0
  36. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/colors.json +0 -0
  37. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/BondEnergies.json +0 -0
  38. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/MoleculeBonds.json +0 -0
  39. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/Molecules.json +0 -0
  40. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/PeriodicTableJSON.json +0 -0
  41. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/Reactions.json +0 -0
  42. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/THIRD_PARTY_LICENSES/PeriodicTableJSON.txt +0 -0
  43. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/data/THIRD_PARTY_LICENSES/RHEA.txt +0 -0
  44. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/highlighting.json +0 -0
  45. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/highlighting.py +0 -0
  46. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/html/periodic_table.html +0 -0
  47. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/logo64-macos.png +0 -0
  48. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/logo64.png +0 -0
  49. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/README.md +0 -0
  50. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/collections.cql +0 -0
  51. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/datetime.cql +0 -0
  52. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/decimal.cql +0 -0
  53. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/fractions.cql +0 -0
  54. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/json.cql +0 -0
  55. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/math/statistics.cql +0 -0
  56. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/math.cql +0 -0
  57. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/pathlib.cql +0 -0
  58. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/random.cql +0 -0
  59. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql/stdlib/text.cql +0 -0
  60. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql_python.egg-info/dependency_links.txt +0 -0
  61. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql_python.egg-info/entry_points.txt +0 -0
  62. {chemql_python-1.6.11 → chemql_python-1.7.0}/src/chemql_python.egg-info/top_level.txt +0 -0
  63. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_codecqlx_fonts.py +0 -0
  64. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_codecqlx_icon.py +0 -0
  65. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_external_molecule_lookup.py +0 -0
  66. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_public_api.py +0 -0
  67. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_reactions.py +0 -0
  68. {chemql_python-1.6.11 → chemql_python-1.7.0}/tests/test_stdlib.py +0 -0
  69. {chemql_python-1.6.11 → 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.11
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,7 +24,7 @@ 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.11` (per `chemql.__version__`)
27
+ - **Language version:** `1.7.0` (per `chemql.__version__`)
24
28
  - **Editor version:** `codecql 0.1.2`
25
29
  - **GUI Editor version:** `CodecQLX 1.1.1`
26
30
  - **Python import / CLI name:** `chemql`
@@ -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
 
@@ -870,13 +1086,16 @@ the `chemql` package cannot be imported.
870
1086
  - Syntax highlighting and context-aware autocomplete for `.cql` files
871
1087
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
872
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)
873
1092
  - Side-by-side editor panes for working with different files
874
1093
  - Query Console that executes ChemQL in-process and displays table or card results
875
1094
  - Interactive Periodic Table lookup
876
1095
  - Balance Equation panel
877
1096
  - Find and replace, bookmarks, zoom controls, and run-file/run-selection actions
878
- - Dark and light themes, font settings, autocomplete/minimap toggles, and
879
- 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
880
1099
 
881
1100
  When enabled, CodecQLX prefers an installed programming font with ligature
882
1101
  support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
@@ -906,6 +1125,9 @@ user profile (`%APPDATA%` on Windows).
906
1125
  | `Ctrl+F2` / `F2` / `Shift+F2` | Toggle / next / previous bookmark |
907
1126
  | `Ctrl+=` / `Ctrl+-` / `Ctrl+0` | Zoom in / out / reset |
908
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
+
909
1131
  ---
910
1132
 
911
1133
  ## Standard library
@@ -1,17 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: chemql-python
3
- Version: 1.6.11
4
- Summary: A chemistry-focused query language and REPL
5
- Author-email: Mohammad Rakibul Islam <rakibulofficial1017@gmail.com>
6
- Requires-Python: >=3.12
7
- Description-Content-Type: text/markdown
8
- License-File: LICENSE
9
- Requires-Dist: prompt_toolkit>=3.0
10
- Requires-Dist: rich>=13.7
11
- Provides-Extra: test
12
- Requires-Dist: pytest>=8.0; extra == "test"
13
- Dynamic: license-file
14
-
15
1
  # ChemQL & CodecQL
16
2
 
17
3
  > A Python-embedded query language and terminal toolchain for chemistry data — with a purpose-built editor, package manager, and standard library.
@@ -20,7 +6,7 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
20
6
 
21
7
  - **Distribution name:** `chemql-python`
22
8
  - **Import / CLI name:** `chemql`
23
- - **Language version:** `1.6.11` (per `chemql.__version__`)
9
+ - **Language version:** `1.7.0` (per `chemql.__version__`)
24
10
  - **Editor version:** `codecql 0.1.2`
25
11
  - **GUI Editor version:** `CodecQLX 1.1.1`
26
12
  - **Python import / CLI name:** `chemql`
@@ -38,6 +24,38 @@ ChemQL is a small language for querying, computing with, and simulating chemistr
38
24
  pip install chemql-python
39
25
  ```
40
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
+
41
59
  Verify:
42
60
 
43
61
  ```bash
@@ -90,6 +108,11 @@ Open a file in the bundled editor:
90
108
  chemql edit script.cql
91
109
  ```
92
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
+
93
116
  ---
94
117
 
95
118
  ## Core commands
@@ -210,6 +233,159 @@ Reference conditions are °C at 1 atm (mp/bp), g/cm³ at 25 °C (density), and `
210
233
 
211
234
  ---
212
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
+
213
389
  ## Type system
214
390
 
215
391
  ### Structs — mutable, methods, inheritance
@@ -332,17 +508,39 @@ isEven{4}
332
508
  ## Functions, arguments, macros
333
509
 
334
510
  ```chemql
335
- func square
336
- return \1 * \1
511
+ func greet{name, age=10}
512
+ let value = str{name}
513
+ return value, age, arguments
337
514
  endfunc
515
+
516
+ greet{"Jacob"} // ("Jacob", 10, ["Jacob", 10])
517
+ greet{age=30, name="Jacob"} // ("Jacob", 30, ["Jacob", 30])
338
518
  ```
339
519
 
340
- **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.
341
524
 
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**
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:
344
528
 
345
- > ⚠️ `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.
346
544
 
347
545
  ### Definitions (object-like)
348
546
 
@@ -870,13 +1068,16 @@ the `chemql` package cannot be imported.
870
1068
  - Syntax highlighting and context-aware autocomplete for `.cql` files
871
1069
  - Hoverable diagnostics, gutter markers, a Problems panel, and an overview ruler
872
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)
873
1074
  - Side-by-side editor panes for working with different files
874
1075
  - Query Console that executes ChemQL in-process and displays table or card results
875
1076
  - Interactive Periodic Table lookup
876
1077
  - Balance Equation panel
877
1078
  - Find and replace, bookmarks, zoom controls, and run-file/run-selection actions
878
- - Dark and light themes, font settings, autocomplete/minimap toggles, and
879
- 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
880
1081
 
881
1082
  When enabled, CodecQLX prefers an installed programming font with ligature
882
1083
  support (such as Fira Code, JetBrains Mono, or Cascadia Code) over its default
@@ -906,6 +1107,9 @@ user profile (`%APPDATA%` on Windows).
906
1107
  | `Ctrl+F2` / `F2` / `Shift+F2` | Toggle / next / previous bookmark |
907
1108
  | `Ctrl+=` / `Ctrl+-` / `Ctrl+0` | Zoom in / out / reset |
908
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
+
909
1113
  ---
910
1114
 
911
1115
  ## Standard library
@@ -972,4 +1176,4 @@ Source code: [rakibulofficial1017/ChemQL](https://github.com/rakibulofficial1017
972
1176
 
973
1177
  For the command reference that matches your installed build, type `help`
974
1178
  inside ChemQL. Use `list all` to inspect fields available in your
975
- bundled datasets.
1179
+ bundled datasets.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "chemql-python"
7
- version = "1.6.11"
7
+ version = "1.7.0"
8
8
  authors = [
9
9
  { name = "Mohammad Rakibul Islam", email = "rakibulofficial1017@gmail.com" }
10
10
  ]
@@ -14,6 +14,10 @@ requires-python = ">=3.12"
14
14
  dependencies = [
15
15
  "prompt_toolkit>=3.0",
16
16
  "rich>=13.7",
17
+ "pandas>=2.0",
18
+ "openpyxl>=3.1",
19
+ "xlrd>=2.0",
20
+ "pillow>=10.0",
17
21
  ]
18
22
 
19
23
  [project.optional-dependencies]