nc-gcode-interpreter 0.3.0__tar.gz → 0.3.1__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 (147) hide show
  1. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/CHANGELOG.md +13 -0
  2. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/Cargo.lock +1 -1
  3. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/Cargo.toml +1 -1
  4. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/PKG-INFO +1 -1
  5. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/nc_gcode_interpreter/__init__.py +11 -9
  6. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_g_group_enum.py +12 -11
  7. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/lib.rs +11 -18
  8. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/.github/workflows/benchmark.yml +0 -0
  9. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/.github/workflows/build-and-release.yml +0 -0
  10. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/.gitignore +0 -0
  11. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/CONTRIBUTING.md +0 -0
  12. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/Development.md +0 -0
  13. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/LICENSE +0 -0
  14. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/README.md +0 -0
  15. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/TODO.md +0 -0
  16. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/benches/extensions.rs +0 -0
  17. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/benches/fixtures.rs +0 -0
  18. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/benches/workloads.rs +0 -0
  19. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/build.rs +0 -0
  20. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/build_backend/nc_build_backend.py +0 -0
  21. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/docs/resumable-interpretation-design.md +0 -0
  22. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/docs/sinumerik-execution-model.md +0 -0
  23. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/actual_position.csv +0 -0
  24. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/actual_position.mpf +0 -0
  25. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/arc.csv +0 -0
  26. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/arc.mpf +0 -0
  27. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/arrays.csv +0 -0
  28. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/arrays.mpf +0 -0
  29. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/axis_index_assignment.csv +0 -0
  30. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/axis_index_assignment.mpf +0 -0
  31. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/basic_math.csv +0 -0
  32. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/basic_math.mpf +0 -0
  33. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/case.csv +0 -0
  34. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/case.mpf +0 -0
  35. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/case_insensitive_variables.csv +0 -0
  36. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/case_insensitive_variables.mpf +0 -0
  37. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/custom_vars.csv +0 -0
  38. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/custom_vars.mpf +0 -0
  39. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/def_string.csv +0 -0
  40. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/def_string.mpf +0 -0
  41. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/defaults.csv +0 -0
  42. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/defaults.def +0 -0
  43. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/defaults.mpf +0 -0
  44. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/defaults_start.json +0 -0
  45. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/edge_cases.csv +0 -0
  46. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/edge_cases.mpf +0 -0
  47. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/flattening/flatten_demo.mpf +0 -0
  48. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/flattening/flatten_demo_flattened.csv +0 -0
  49. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/flattening/flatten_demo_raw.csv +0 -0
  50. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/for_loop.csv +0 -0
  51. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/for_loop.mpf +0 -0
  52. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/function_calls.csv +0 -0
  53. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/function_calls.mpf +0 -0
  54. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/goto.csv +0 -0
  55. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/goto.mpf +0 -0
  56. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/if_statement.csv +0 -0
  57. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/if_statement.mpf +0 -0
  58. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/increment.csv +0 -0
  59. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/increment.mpf +0 -0
  60. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/logic_operators.csv +0 -0
  61. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/logic_operators.mpf +0 -0
  62. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/loop.csv +0 -0
  63. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/loop.mpf +0 -0
  64. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/multiple_m_codes.csv +0 -0
  65. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/multiple_m_codes.mpf +0 -0
  66. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/precedence.csv +0 -0
  67. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/precedence.mpf +0 -0
  68. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/r_param.csv +0 -0
  69. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/r_param.mpf +0 -0
  70. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/repeat.csv +0 -0
  71. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/repeat.mpf +0 -0
  72. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/rot.csv +0 -0
  73. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/rot.mpf +0 -0
  74. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/simple.csv +0 -0
  75. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/simple.mpf +0 -0
  76. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/spline.csv +0 -0
  77. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/spline.mpf +0 -0
  78. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/tool.csv +0 -0
  79. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/tool.mpf +0 -0
  80. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans.csv +0 -0
  81. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans.mpf +0 -0
  82. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans2.csv +0 -0
  83. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans2.mpf +0 -0
  84. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans_ic.csv +0 -0
  85. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans_ic.mpf +0 -0
  86. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans_reset.csv +0 -0
  87. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trans_reset.mpf +0 -0
  88. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trig.csv +0 -0
  89. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/trig.mpf +0 -0
  90. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/variables.csv +0 -0
  91. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/examples/variables.mpf +0 -0
  92. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/ggroups/generate_g_commands.py +0 -0
  93. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/pyproject.toml +0 -0
  94. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/example/minimal.py +0 -0
  95. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/example/streaming.py +0 -0
  96. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/nc_gcode_interpreter/_internal.pyi +0 -0
  97. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/nc_gcode_interpreter/cli.py +0 -0
  98. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/nc_gcode_interpreter/ggroups.json +0 -0
  99. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/nc_gcode_interpreter/py.typed +0 -0
  100. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/nc_gcode_interpreter/viz.py +0 -0
  101. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/nc_source.py +0 -0
  102. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_arithmetic_functions.py +0 -0
  103. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_batch_variables.py +0 -0
  104. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_batches.py +0 -0
  105. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_compare_benchmarks.py +0 -0
  106. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_diagnostics.py +0 -0
  107. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_expected_output.py +0 -0
  108. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_feed_check.py +0 -0
  109. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_feed_group.py +0 -0
  110. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_field_defects.py +0 -0
  111. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_flags.py +0 -0
  112. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_flatten.py +0 -0
  113. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_frames.py +0 -0
  114. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_g_groups.py +0 -0
  115. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_g_vocabulary.py +0 -0
  116. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_jumps.py +0 -0
  117. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_real_comparisons.py +0 -0
  118. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_stage1.py +0 -0
  119. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_start_inputs.py +0 -0
  120. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_streaming.py +0 -0
  121. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_string_operations.py +0 -0
  122. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_structured_errors.py +0 -0
  123. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_subprograms.py +0 -0
  124. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/python/tests/test_unsupported.py +0 -0
  125. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/rustfmt.toml +0 -0
  126. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/scripts/benchmark.py +0 -0
  127. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/scripts/compare_benchmarks.py +0 -0
  128. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/errors.rs +0 -0
  129. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/flatten.rs +0 -0
  130. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/frame.rs +0 -0
  131. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/grammar.pest +0 -0
  132. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/interpret_rules.rs +0 -0
  133. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/interpreter.rs +0 -0
  134. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/line_driver/experiments.rs +0 -0
  135. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/line_driver.rs +0 -0
  136. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/main.rs +0 -0
  137. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/modal_groups.rs +0 -0
  138. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/output.rs +0 -0
  139. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/start.rs +0 -0
  140. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/state.rs +0 -0
  141. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/structure_scan.rs +0 -0
  142. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/subprogram.rs +0 -0
  143. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/types.rs +0 -0
  144. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/src/vm.rs +0 -0
  145. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/tests/cli.rs +0 -0
  146. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/tests/performance_contract.rs +0 -0
  147. {nc_gcode_interpreter-0.3.0 → nc_gcode_interpreter-0.3.1}/uv.lock +0 -0
@@ -4,6 +4,19 @@ Notable changes to **nc-gcode-interpreter**. The format loosely follows
4
4
  [Keep a Changelog](https://keepachangelog.com/); versions are git tags,
5
5
  released to PyPI.
6
6
 
7
+ ## [v0.3.1] - 2026-11-11
8
+
9
+ ### Changed
10
+
11
+ - The G-group columns reach Python as one-byte codes and become `pl.Enum`
12
+ by a gather from each group's categories. Before, Rust sent an Arrow
13
+ dictionary tagged with an undocumented polars metadata key, and polars
14
+ looked up every row's string on import. On polars 1.40 a 7M-row program
15
+ with eleven G-group columns takes 15% less CPU (3.92 s to 3.32 s); on
16
+ polars 2.1 the time is unchanged. The output is identical, and the
17
+ interpreter no longer depends on that key. Polars 2 does not cast
18
+ integers to an Enum, so the gather works on both.
19
+
7
20
  ## [v0.3.0] - 2026-11-11
8
21
 
9
22
  This release changes the API and the output. To upgrade:
@@ -506,7 +506,7 @@ checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4"
506
506
 
507
507
  [[package]]
508
508
  name = "nc-gcode-interpreter"
509
- version = "0.3.0"
509
+ version = "0.3.1"
510
510
  dependencies = [
511
511
  "arrow-array",
512
512
  "arrow-data",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "nc-gcode-interpreter"
3
- version = "0.3.0"
3
+ version = "0.3.1"
4
4
  edition = "2021"
5
5
  readme = "README.md"
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nc-gcode-interpreter
3
- Version: 0.3.0
3
+ Version: 0.3.1
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: 3.12
@@ -346,20 +346,22 @@ G_GROUP_DTYPES: dict[str, pl.Enum] = {
346
346
  }
347
347
 
348
348
 
349
+ # Each group's categories as an Enum series; gathering by code builds the column.
350
+ _G_GROUP_CATEGORIES: dict[str, pl.Series] = {
351
+ name: pl.Series(name, dtype.categories, dtype=dtype) for name, dtype in G_GROUP_DTYPES.items()
352
+ }
353
+
354
+
349
355
  def _batch_frame(batch: Any) -> pl.DataFrame:
350
356
  """Wrap one Arrow batch from Rust, with every G-group column as its Enum.
351
357
 
352
- Rust tags the G-group dictionaries so polars imports them as Enum
353
- directly. The cast is a safety net should polars stop reading that tag;
354
- ``test_g_group_columns_arrive_as_enum_without_a_cast`` turns red if it does.
358
+ Rust sends each G-group column as UInt8 indices into the group's commands
359
+ in manual order. Gathering from the Enum's categories turns them into the
360
+ Enum, since polars 2 no longer casts integers to an Enum.
355
361
  """
356
362
  frame = pl.DataFrame(batch)
357
- casts = [
358
- pl.col(name).cast(G_GROUP_DTYPES[name])
359
- for name, dtype in frame.schema.items()
360
- if name in G_GROUP_DTYPES and dtype != G_GROUP_DTYPES[name]
361
- ]
362
- return frame.with_columns(casts) if casts else frame
363
+ columns = [_G_GROUP_CATEGORIES[name].gather(frame[name]) for name in frame.columns if name in _G_GROUP_CATEGORIES]
364
+ return frame.with_columns(columns) if columns else frame
363
365
 
364
366
 
365
367
  def sanitize_dataframe(
@@ -33,19 +33,20 @@ def test_dtypes_cover_every_group_in_manual_order():
33
33
  assert G_GROUP_DTYPES["gg01_motion"].categories.to_list()[:4] == ["G0", "G1", "G2", "G3"]
34
34
 
35
35
 
36
- def test_g_group_columns_arrive_as_enum_without_a_cast():
37
- # Bypasses _batch_frame: red here means polars no longer reads the Enum tag Rust writes.
36
+ def test_g_group_columns_arrive_as_manual_order_codes():
37
+ # Bypasses _batch_frame: Rust hands over UInt8 indices into each group's manual-order list.
38
38
  from nc_gcode_interpreter import _internal
39
39
 
40
- batches = _internal.nc_to_batches(PROGRAM, batch_size=3)
41
- seen = set()
42
- for batch in batches:
43
- frame = pl.DataFrame(batch)
44
- for name, dtype in frame.schema.items():
45
- if name in G_GROUP_DTYPES:
46
- assert dtype == G_GROUP_DTYPES[name], f"{name} arrived as {dtype}"
47
- seen.add(name)
48
- assert {"gg01_motion", "gg02_wait", "gg06_plane_select"} <= seen
40
+ frames = [pl.DataFrame(batch) for batch in _internal.nc_to_batches(PROGRAM, batch_size=3)]
41
+ raw = pl.concat(frames, how="diagonal")
42
+ expected, _ = nc_to_dataframe(PROGRAM)
43
+ seen = [name for name in raw.columns if name in G_GROUP_DTYPES]
44
+ assert {"gg01_motion", "gg02_wait", "gg06_plane_select"} <= set(seen)
45
+ for name in seen:
46
+ assert raw.schema[name] == pl.UInt8, name
47
+ categories = G_GROUP_DTYPES[name].categories.to_list()
48
+ decoded = [None if code is None else categories[code] for code in raw[name].to_list()]
49
+ assert decoded == expected[name].to_list(), name
49
50
 
50
51
 
51
52
  def test_batches_share_one_enum_dtype_and_concat_vertically():
@@ -319,7 +319,7 @@ mod python_bindings {
319
319
  let mut arrays: Vec<ArrayRef> = Vec::with_capacity(table.columns.len());
320
320
  for (name, column) in table.columns {
321
321
  if let Some(categories) = crate::modal_groups::g_group_values(&name) {
322
- let (field, array) = g_group_enum_array(&name, categories, column)?;
322
+ let (field, array) = g_group_code_array(&name, categories, column)?;
323
323
  fields.push(field);
324
324
  arrays.push(array);
325
325
  continue;
@@ -376,30 +376,23 @@ mod python_bindings {
376
376
  .map_err(|e| PyErr::new::<PyValueError, _>(format!("failed to build RecordBatch: {}", e)))
377
377
  }
378
378
 
379
- /// One G-group column as an Arrow dictionary whose values are the group's
380
- /// full command list in manual order and whose keys index that list, so
381
- /// every batch carries the same categories. The `_PL_ENUM_VALUES2` field
382
- /// metadata is what polars (>= 1.32) reads to import it as `pl.Enum`. A
383
- /// value outside the list is an error, never a null.
384
- fn g_group_enum_array(
379
+ /// One G-group column as UInt8 indices into the group's command list in
380
+ /// manual order, which the Python wrapper casts to that group's `pl.Enum`.
381
+ /// Plain codes, because polars imports an Arrow dictionary by looking up
382
+ /// every row's string, about 15 times slower than the integer cast. A value
383
+ /// outside the list is an error, never a null.
384
+ fn g_group_code_array(
385
385
  name: &str,
386
386
  categories: &'static [&'static str],
387
387
  column: Column,
388
388
  ) -> PyResult<(arrow_schema::Field, arrow_array::ArrayRef)> {
389
- use arrow_array::types::UInt8Type;
390
- use arrow_array::{Array, DictionaryArray, StringArray, UInt8Array};
391
- use arrow_schema::Field;
389
+ use arrow_array::UInt8Array;
390
+ use arrow_schema::{DataType, Field};
392
391
 
393
- let keys: UInt8Array = crate::output::g_group_codes(name, categories, &column)
392
+ let codes: UInt8Array = crate::output::g_group_codes(name, categories, &column)
394
393
  .map_err(PyErr::new::<PyValueError, _>)?
395
394
  .into();
396
- let values: StringArray = categories.iter().map(|c| Some(*c)).collect();
397
- let array = DictionaryArray::<UInt8Type>::try_new(keys, Arc::new(values))
398
- .map_err(|e| PyErr::new::<PyValueError, _>(format!("G-group column '{}': {}", name, e)))?;
399
- let encoded: String = categories.iter().map(|c| format!("{};{}", c.len(), c)).collect();
400
- let metadata = HashMap::from([("_PL_ENUM_VALUES2".to_string(), encoded)]);
401
- let field = Field::new(name, array.data_type().clone(), true).with_metadata(metadata);
402
- Ok((field, Arc::new(array)))
395
+ Ok((Field::new(name, DataType::UInt8, true), Arc::new(codes)))
403
396
  }
404
397
 
405
398
  /// [`table_to_record_batch`] as an [`ArrowBatch`] the Python side receives