cellproof 0.2.2__tar.gz → 0.3.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 (114) hide show
  1. {cellproof-0.2.2 → cellproof-0.3.0}/AGENTS.md +2 -1
  2. cellproof-0.3.0/CHANGELOG.md +88 -0
  3. {cellproof-0.2.2 → cellproof-0.3.0}/PKG-INFO +38 -16
  4. {cellproof-0.2.2 → cellproof-0.3.0}/PROGRESS.md +20 -5
  5. {cellproof-0.2.2 → cellproof-0.3.0}/README.md +37 -15
  6. {cellproof-0.2.2 → cellproof-0.3.0}/pyproject.toml +1 -1
  7. cellproof-0.3.0/src/cellproof/__init__.py +1 -0
  8. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/cli.py +2 -1
  9. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/compiler.py +19 -5
  10. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/expr.py +9 -1
  11. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/__init__.py +1 -1
  12. cellproof-0.3.0/src/cellproof/fn/aggregate.py +473 -0
  13. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/dates.py +63 -2
  14. cellproof-0.3.0/src/cellproof/fn/finance.py +103 -0
  15. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/logic.py +47 -4
  16. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/lookup.py +141 -19
  17. cellproof-0.3.0/src/cellproof/fn/stats.py +116 -0
  18. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/functions.py +2 -13
  19. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/graph.py +2 -0
  20. cellproof-0.3.0/src/cellproof/impact.py +57 -0
  21. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/model.py +10 -1
  22. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/parser.py +2 -1
  23. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/reader.py +31 -5
  24. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/region.py +1 -1
  25. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/report.py +18 -2
  26. cellproof-0.3.0/src/cellproof/tables.py +162 -0
  27. cellproof-0.3.0/tests/test_arrays.py +166 -0
  28. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_corpus_findings.py +35 -0
  29. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_excel_findings.py +8 -6
  30. cellproof-0.3.0/tests/test_finance_stats.py +127 -0
  31. cellproof-0.3.0/tests/test_impact.py +115 -0
  32. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_implicit.py +6 -5
  33. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_logic.py +36 -0
  34. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_lookup.py +2 -2
  35. cellproof-0.3.0/tests/test_lookups.py +136 -0
  36. cellproof-0.3.0/tests/test_tables.py +75 -0
  37. {cellproof-0.2.2 → cellproof-0.3.0}/tests/xlsxkit.py +40 -8
  38. cellproof-0.2.2/CHANGELOG.md +0 -50
  39. cellproof-0.2.2/src/cellproof/__init__.py +0 -1
  40. cellproof-0.2.2/src/cellproof/fn/aggregate.py +0 -197
  41. cellproof-0.2.2/tests/test_arrays.py +0 -45
  42. cellproof-0.2.2/tests/test_lookups.py +0 -49
  43. {cellproof-0.2.2 → cellproof-0.3.0}/.github/workflows/ci.yml +0 -0
  44. {cellproof-0.2.2 → cellproof-0.3.0}/.github/workflows/publish.yml +0 -0
  45. {cellproof-0.2.2 → cellproof-0.3.0}/.gitignore +0 -0
  46. {cellproof-0.2.2 → cellproof-0.3.0}/DESIGN.md +0 -0
  47. {cellproof-0.2.2 → cellproof-0.3.0}/INFO.md +0 -0
  48. {cellproof-0.2.2 → cellproof-0.3.0}/LICENSE +0 -0
  49. {cellproof-0.2.2 → cellproof-0.3.0}/PLAN-2a.md +0 -0
  50. {cellproof-0.2.2 → cellproof-0.3.0}/PLAN-2b.md +0 -0
  51. {cellproof-0.2.2 → cellproof-0.3.0}/PLAN.md +0 -0
  52. {cellproof-0.2.2 → cellproof-0.3.0}/SECURITY.md +0 -0
  53. {cellproof-0.2.2 → cellproof-0.3.0}/docs/JOURNEY.md +0 -0
  54. {cellproof-0.2.2 → cellproof-0.3.0}/docs/superpowers/plans/2026-10-14-plan-2c-speed.md +0 -0
  55. {cellproof-0.2.2 → cellproof-0.3.0}/docs/superpowers/plans/2026-10-14-plan-2d-table-mode.md +0 -0
  56. {cellproof-0.2.2 → cellproof-0.3.0}/docs/superpowers/specs/2026-10-14-plan-2c-speed-design.md +0 -0
  57. {cellproof-0.2.2 → cellproof-0.3.0}/docs/superpowers/specs/2026-10-14-plan-2d-table-mode-design.md +0 -0
  58. {cellproof-0.2.2 → cellproof-0.3.0}/docs/superpowers/specs/2026-10-18-running-totals-design.md +0 -0
  59. {cellproof-0.2.2 → cellproof-0.3.0}/docs/superpowers/specs/2026-10-19-lookups-row-wise-design.md +0 -0
  60. {cellproof-0.2.2 → cellproof-0.3.0}/examples/commission.xlsx +0 -0
  61. {cellproof-0.2.2 → cellproof-0.3.0}/examples/errors.xlsx +0 -0
  62. {cellproof-0.2.2 → cellproof-0.3.0}/examples/functions.xlsx +0 -0
  63. {cellproof-0.2.2 → cellproof-0.3.0}/examples/functions_unsaved.xlsx +0 -0
  64. {cellproof-0.2.2 → cellproof-0.3.0}/examples/make_commission.py +0 -0
  65. {cellproof-0.2.2 → cellproof-0.3.0}/examples/make_errors.py +0 -0
  66. {cellproof-0.2.2 → cellproof-0.3.0}/examples/make_functions.py +0 -0
  67. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/__main__.py +0 -0
  68. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/compute.py +0 -0
  69. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/emitter.py +0 -0
  70. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fenwick.py +0 -0
  71. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/criteria.py +0 -0
  72. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/maths.py +0 -0
  73. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/fn/text.py +0 -0
  74. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/r1c1.py +0 -0
  75. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/rangeindex.py +0 -0
  76. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/refs.py +0 -0
  77. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/regions.py +0 -0
  78. {cellproof-0.2.2 → cellproof-0.3.0}/src/cellproof/verifier.py +0 -0
  79. {cellproof-0.2.2 → cellproof-0.3.0}/tests/bench_shapes.py +0 -0
  80. {cellproof-0.2.2 → cellproof-0.3.0}/tests/corpus.py +0 -0
  81. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_aggregate.py +0 -0
  82. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_batches.py +0 -0
  83. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_cli.py +0 -0
  84. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_compiler.py +0 -0
  85. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_compute.py +0 -0
  86. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_criteria.py +0 -0
  87. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_dates.py +0 -0
  88. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_emitter.py +0 -0
  89. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_errors.py +0 -0
  90. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_excel_saved.py +0 -0
  91. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_fenwick.py +0 -0
  92. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_functions.py +0 -0
  93. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_graph.py +0 -0
  94. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_index.py +0 -0
  95. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_lexed.py +0 -0
  96. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_limits.py +0 -0
  97. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_maths.py +0 -0
  98. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_parser.py +0 -0
  99. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_perf.py +0 -0
  100. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_r1c1.py +0 -0
  101. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_rangeindex.py +0 -0
  102. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_reader.py +0 -0
  103. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_refs.py +0 -0
  104. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_region.py +0 -0
  105. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_regions.py +0 -0
  106. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_regions_differential.py +0 -0
  107. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_regions_split.py +0 -0
  108. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_report.py +0 -0
  109. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_review_regressions.py +0 -0
  110. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_running.py +0 -0
  111. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_shapes.py +0 -0
  112. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_text.py +0 -0
  113. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_types.py +0 -0
  114. {cellproof-0.2.2 → cellproof-0.3.0}/tests/test_verifier.py +0 -0
@@ -28,7 +28,8 @@ CELLPROOF_PERF=1 python -m pytest tests/test_perf.py -s # 200k-formula benchmar
28
28
  | `expr.py` | `Expr` (SQL value + SQL error code), Excel coercions |
29
29
  | `compiler.py` | cell mode: formula -> SQL in batches |
30
30
  | `region.py` | a region -> one set-based statement (window functions for running totals) |
31
- | `functions.py`, `fn/` | the 96 Excel functions |
31
+ | `functions.py`, `fn/` | the 121 Excel functions (`fn/finance.py`, `fn/stats.py` new in 0.3.0; LET in `fn/logic.py`) |
32
+ | `tables.py` | structured references to Excel tables -> A1 text, applied by the reader |
32
33
  | `verifier.py` | runs everything on DuckDB and compares with Excel's saved values |
33
34
  | `emitter.py` | writes the dbt project; `--dbt` runs `dbt build` |
34
35
  | `report.py`, `cli.py`, `compute.py` | REPORT.md/report.json, the CLI, the optional `formulas` answer key |
@@ -0,0 +1,88 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 (2026-10-31)
4
+
5
+ - **Finance:** PMT, PV, FV, NPER, NPV. Microsoft's closed forms; NPV skips text, TRUE/FALSE and empty cells in a
6
+ reference without spending a period on them (checked against pycel's Excel-saved npv.xlsx).
7
+ - **Statistics:** LARGE, SMALL, RANK(.EQ), STDEV(.S/.P/P), VAR(.S/.P/P), PERCENTILE(.INC), QUARTILE(.INC). Real Excel
8
+ (formulas' test.xlsx) taught two rules: k's error comes before an error in the range, and QUARTILE checks quart
9
+ before truncating it (QUARTILE(x, -0.1) is #NUM!).
10
+ - **Working days:** NETWORKDAYS and WORKDAY, with a holidays range.
11
+ - **Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `#All`,
12
+ `#Data`, `#Headers`, `#Totals`, `Sales[[Rep]:[Amount]]`) are rewritten to A1 references by the reader; a
13
+ calculated table column compiles as a region.
14
+ - **LET**, nested LETs and a name bound to a range (`LET(r, A1:A9, SUM(r)/COUNT(r))`) included.
15
+ - **Not guessed:** edge cases of the new functions that were never checked in real Excel (zero periods, rate <= -100%,
16
+ payment type other than 0/1, a k that is not whole, ...) are UNRESOLVED with that reason.
17
+ - **Fixes found by the public corpus** (FAIL 92 -> 16, all 16 explained: 10 in LibreOffice files, 6 last-digit
18
+ cancellations around NPV): INDEX with a negative row or column is #VALUE!, not #REF!; SWITCH reads an empty cell as
19
+ 0 (it matches 0, not FALSE or ""); a range where one value is expected inside an array formula is UNRESOLVED
20
+ instead of implicitly intersected (Excel evaluates it per element there).
21
+ - **Array arithmetic in aggregates**, the first slices of array evaluation: `SUM(A1:A10*B1:B10)`,
22
+ `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`, `SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`,
23
+ `SUM(A1:A9^2)` and friends evaluate element by element like modern Excel - an empty element is 0, text converts
24
+ when it is a number and is #VALUE! otherwise, comparisons rank numbers < text < TRUE/FALSE case-insensitively,
25
+ concatenation writes numbers the Excel way, and the first error wins. SUM, SUMPRODUCT, MAX, MIN, AVERAGE, COUNT,
26
+ COUNTA and PRODUCT take arrays; IF, IFERROR and IFNA take them as their arguments. A single-cell array formula
27
+ (Ctrl+Shift+Enter) now compiles; one over several cells is UNRESOLVED. Plain-entered range arithmetic or IF as an
28
+ aggregate argument follows modern Excel (the element-wise answer), not the legacy first-row intersection - a
29
+ workbook an old Excel last saved can show FAILs there, with both values shown.
30
+ - **Approximate lookups on unsorted data** (MATCH type 1, VLOOKUP/HLOOKUP approximate, LOOKUP) over a plain numeric
31
+ input table: cellproof now compiles Excel's binary-search path itself - the answer is the last probe the search
32
+ moves right from, not the sorted bracket, and it matches Excel's own answers on files we checked (the 9.99E+307
33
+ last-number trick included). The SQL refuses table values that changed after translation (#STALE, UNRESOLVED)
34
+ instead of answering from a stale search. MATCH type -1, text, and tables with empty cells or formulas stay
35
+ UNRESOLVED: Excel's answer there is not derivable from the file.
36
+ - **Where to start:** the report groups the unresolved cells by the reason to fix first and ranks the reasons by
37
+ reach: a cell that reads an unresolved cell is attributed to the reason above it, so the top row of
38
+ "Where to start" names the fix that lets the most cells try again. report.json gains `unresolved_groups` and a
39
+ `blocked_by` root per unresolved cell.
40
+
41
+ ## 0.2.2 (2026-10-27)
42
+
43
+ - **LOOKUP** (vector and array form). Like the other approximate lookups, UNRESOLVED on data out of order.
44
+ - **YEARFRAC**, all five bases, the basis written in the formula or computed. The 1,992 YEARFRAC cells of pycel's
45
+ test workbook all PASS; a date before 1 March 1900 (Excel's 29 February 1900) is UNRESOLVED.
46
+ - **Array constants** (`{0,50,100}`, `{1,"a";2,"b"}`) wherever a range is taken: `LOOKUP(x,{0,50,100},{"F","C","A"})`,
47
+ `MATCH(x,{...},0)`, `SUM({...})`. Used as one value (`A1*{1,2}`) they stay UNRESOLVED.
48
+
49
+ ## 0.2.1 (2026-10-20)
50
+
51
+ Found by running all 85 public test workbooks of pycel, formulas and xlcalculator (`python tests/corpus.py DIR`):
52
+ FAIL 229 -> 10 (all 10 in files LibreOffice saved, which the report now says), no crashes.
53
+
54
+ - **Reading:** a defined name that is a formula of names (`=h+i`) no longer crashes the load; a date-formatted number
55
+ keeps its serial (Excel's 29 February 1900 and date-formatted negatives were lost); text escaped by the file format
56
+ (`_x000D_`, written for a carriage return) is decoded as Excel does.
57
+ - **AND/OR/XOR** skip text and empty cells in references, and typed text other than TRUE/FALSE, like Excel.
58
+ - **An empty or omitted result is 0:** `IF(c,,"x")`, `IFERROR(A1,"x")` with A1 empty.
59
+ - **EDATE/EOMONTH/MROUND/VALUE** refuse TRUE/FALSE (`#VALUE!`); `EOMONTH(0,0)` is 31.
60
+ - **SUMPRODUCT** of ranges of different sizes returns an error inside them before `#VALUE!`.
61
+ - **PROPER** accepts another cell's value (DuckDB refused the SQL) and capitalizes accented letters.
62
+ - **Locale-dependent text** (`"1,000"`, `"1/2/2020"`) is UNRESOLVED instead of a wrong `#VALUE!`.
63
+ - **Report:** warns when the file was not last saved by Excel; CHAR above 127 in a Mac-calculated file is UNRESOLVED.
64
+
65
+ From a user's practice workbook (3 PASS / 47 UNRESOLVED -> 48 PASS / 2 UNRESOLVED):
66
+
67
+ - **Implicit intersection:** a one-column or one-row range where one value is expected takes the formula's own row or
68
+ column (`=IF(E$3:E$41="F",B$3:B$41)`); outside it is `#VALUE!`. A range IF passes into another function is
69
+ UNRESOLVED (Excel gives that function the whole range).
70
+ - **`INDIRECT("Sales")`** of fixed text is the reference it names (dependencies included).
71
+ - **MODE / MODE.SNGL.**
72
+ - **A bare word is a name, never a column:** `=i` without a name `i` was read as column I.
73
+
74
+ ## 0.2.0 (2026-10-19)
75
+
76
+ - **Renamed** from `unexcel` to `cellproof` (the old name clashed with an R package): `pip install cellproof`, command
77
+ `cellproof convert`, import `cellproof`, `CELLPROOF_PERF` for the benchmark, dbt project and database `cellproof`.
78
+ - **Lookups row-wise:** VLOOKUP, HLOOKUP, MATCH, INDEX and XLOOKUP pasted down a column compile into one statement.
79
+ 1,000 VLOOKUPs: verify 5.7 s -> 0.1 s.
80
+ - **Criteria row-wise:** COUNTIFS (and SUMIF/AVERAGEIF(S) over a range holding an error) with a criterion from the row
81
+ no longer fall back to cell mode. 1,000 COUNTIFS: verify 29 s -> 0.1 s.
82
+ - **Faster compile:** a pasted-down formula is tokenized once per run. 200k-formula benchmark 31 s -> 26 s; 50k
83
+ VLOOKUPs 8.9 s -> 4.6 s.
84
+ - A lookup outside a region is about 20% slower than in 0.1.0 (one SQL form for both modes).
85
+
86
+ ## 0.1.0 (2026-10-18)
87
+
88
+ First release, as `unexcel`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: cellproof
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: Turn an Excel workbook into SQL (a dbt project on DuckDB) and prove every number matches.
5
5
  Project-URL: Homepage, https://github.com/Nikhil414/cellproof
6
6
  Project-URL: Issues, https://github.com/Nikhil414/cellproof/issues
@@ -83,7 +83,8 @@ The output folder holds:
83
83
 
84
84
  - **`REPORT.md` / `report.json`**: every verdict, failed cells with both values, unresolved cells with the reason,
85
85
  findings (for example a number stored as text, which Excel skips in SUM), and which blocks of rows became readable
86
- table models.
86
+ table models. The unresolved reasons are ranked by how many cells depend on them ("Where to start"), so a long list
87
+ of unresolved cells says what to fix first.
87
88
  - **A dbt project** (`dbt_project.yml`, `models/`, `seeds/input_cells.csv`) that recomputes the workbook on DuckDB.
88
89
  It runs exactly the SQL the verifier checked.
89
90
 
@@ -110,12 +111,18 @@ reader -> regions -> dependency graph -> compiler -> verifier -> dbt emitter ->
110
111
  code.
111
112
  6. **Emit** the dbt project and the report.
112
113
 
113
- 96 Excel functions are supported: ABS, AND, AVERAGE, AVERAGEIF(S), CEILING, CHAR, CHOOSE, CLEAN, CONCAT(ENATE),
114
- COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR,
115
- HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LEFT, LEN, LN, LOG,
116
- LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NOT, OR, PI, POWER, PRODUCT,
117
- PROPER, REPLACE, REPT, RIGHT, ROUND(UP/DOWN), SEARCH, SIGN, SQRT, SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
118
- SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UPPER, VALUE, VLOOKUP, WEEKDAY, XLOOKUP, XOR, YEAR, YEARFRAC.
114
+ 121 Excel functions are supported: ABS, AND, AVERAGE, AVERAGEIF(S), CEILING, CHAR, CHOOSE, CLEAN, CONCAT(ENATE),
115
+ COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR, FV,
116
+ HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LARGE, LEFT, LEN, LET,
117
+ LN, LOG, LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NETWORKDAYS,
118
+ NOT, NPER, NPV, OR, PERCENTILE(.INC), PI, PMT, POWER, PRODUCT, PROPER, PV, QUARTILE(.INC), RANK(.EQ), REPLACE, REPT,
119
+ RIGHT, ROUND(UP/DOWN), SEARCH, SIGN, SMALL, SQRT, STDEV(.S/.P/P), SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
120
+ SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UPPER, VALUE, VAR(.S/.P/P), VLOOKUP, WEEKDAY, WORKDAY, XLOOKUP, XOR,
121
+ YEAR, YEARFRAC.
122
+
123
+ **Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `Sales[#Totals]`,
124
+ `Sales[[Rep]:[Amount]]`) are rewritten to plain references when the file is read, so a calculated table column
125
+ compiles like any column pasted down.
119
126
 
120
127
  **Speed** (Windows 11 laptop, measured): a 200,000-formula workbook (four formula columns over 50,000 rows, one of them
121
128
  a running total) converts and verifies in 26 s, all PASS. 50,000 rows of VLOOKUP into a 1,000-row table: 4.6 s.
@@ -126,23 +133,38 @@ COUNTIFS/SUMIFS with a criterion from the row run at the same speed.
126
133
  cellproof prefers an honest UNRESOLVED or FAIL to a guess. Known limits, each reported with a reason:
127
134
 
128
135
  - **File formats:** `.xlsx` and `.xlsm` only (no `.xls`, `.xlsb`, `.ods`). Macros (VBA) are ignored.
129
- - **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...);
130
- where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
131
- - **Not supported:** array formulas and dynamic arrays, volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
136
+ - **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
137
+ and inside array arithmetic; where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
138
+ - **Array arithmetic in aggregates** (`SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`,
139
+ `SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`, `SUM(A1:A9^2)`) follows modern Excel: element by element, an
140
+ empty element is 0, text converts when it is a number ("3" -> 3) and is #VALUE! otherwise, comparisons rank
141
+ numbers < text < TRUE/FALSE case-insensitively, concatenation writes numbers the Excel way, and the first error
142
+ wins. A single-cell array formula (Ctrl+Shift+Enter) compiles; an array formula over several cells is UNRESOLVED
143
+ (spilling is not read yet). A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
144
+ not the legacy first-row intersection - a workbook an old Excel last saved can show FAILs there, with both values
145
+ shown.
146
+ - **Not supported:** multi-cell array formulas and dynamic arrays, volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
132
147
  `INDIRECT` of text built while the sheet runs; `INDIRECT("Sales")` is fine), functions outside the list above,
133
- external workbooks, structured table references (`Table1[@Col]`), INDEX used as a reference, the 1904 date system in
148
+ external workbooks, a structured reference naming several separate columns (`T[[A],[C]]`), INDEX used as a reference, the 1904 date system in
134
149
  TEXT date formats.
135
150
  - **Ranges where one value is expected** (`=IF(E$3:E$41="F",B$3:B$41)`) take the formula's own row or column, as
136
- Excel does (implicit intersection). A range that IF/IFERROR/CHOOSE hands to another function
137
- (`MAX(IF(c,A1:A9,0))`, where Excel uses the whole range) is UNRESOLVED.
138
- - **Approximate lookups on unsorted data** (LOOKUP, and MATCH/VLOOKUP/HLOOKUP with match type 1/-1): UNRESOLVED, because Excel's
139
- answer then depends on its binary search.
151
+ Excel does (implicit intersection). As an aggregate's argument the element-wise answer is compiled instead (see
152
+ array arithmetic above). IFERROR, IFS and CHOOSE over arrays are still UNRESOLVED.
153
+ - **Approximate lookups on unsorted data** (LOOKUP, MATCH/VLOOKUP/HLOOKUP with match type 1): compiled for plain
154
+ numeric tables written as inputs (up to about 1,000 values): the SQL carries Excel's binary-search path itself, and
155
+ refuses changed table values instead of answering from a stale search. MATCH with type -1, text tables, tables with
156
+ empty cells or formulas, and bigger tables stay UNRESOLVED, because Excel's answer there is not derivable from the
157
+ file (LibreOffice, the only open source that emulates the search, provably differs from Excel in places).
140
158
  - **Text to number:** only plain numbers convert (`"3"`, `" -1.5e3 "`). Text Excel reads with the computer's language
141
159
  settings (`"1,000"`, `"$5"`, `"50%"`, `"1/2/2020"`, `"2:00 PM"`, `"Jan 5"`) makes the cell UNRESOLVED, because the
142
160
  file does not record those settings.
143
161
  - **Who saved the file:** the report warns when it was last saved by another program (LibreOffice, a script): the
144
162
  saved values then follow that program's rules. In a file Excel for Mac calculated, `CHAR` above 127 is UNRESOLVED
145
163
  (the Mac character set differs).
164
+ - **Edge cases not checked in real Excel yet** are UNRESOLVED with that reason, never guessed: PMT/PV/FV/NPER with
165
+ zero periods, a rate of -100% or less or a payment type other than 0 or 1; NPV at a rate of -100%; LARGE/SMALL with
166
+ a k that is not whole; RANK over a range holding an error; NETWORKDAYS/WORKDAY with text or errors among the
167
+ holidays. NETWORKDAYS.INTL, WORKDAY.INTL, IRR, RATE and the other finance and statistics functions are not in yet.
146
168
  - **Some function options:** SUBTOTAL 101-111 (hidden rows), DATEDIF units MD/YM/YD, WEEKDAY types 11-17, TEXT formats
147
169
  outside the supported table, COUNT or MEDIAN of values typed into the formula, criteria taken from an empty cell.
148
170
  - **Floating point:** a running total becomes a fast window function only when Excel's saved values prove the different
@@ -1,6 +1,6 @@
1
1
  # cellproof: progress
2
2
 
3
- Last updated: 2026-10-20.
3
+ Last updated: 2026-10-31.
4
4
 
5
5
  ## State
6
6
 
@@ -18,12 +18,26 @@ Everything below is on `main`, built test-first, each piece reviewed by a fresh
18
18
  | Tokenize once | a formula pasted down a column is tokenized once; the next rows' text is predicted and only re-tokenized when it differs |
19
19
  | Implicit intersection | a one-column range where one value is expected takes the formula's row; `INDIRECT` of fixed text; MODE (found in a user's workbook) |
20
20
  | Criteria row-wise | the *IF(S) family with a criterion from the row (`=COUNTIFS($E:$E,">"&A2,...)`) compiles into the region's statement too |
21
+ | Impact-ranked unresolveds | the report groups UNRESOLVED cells by the reason to fix first ("Where to start"): the compiler records which unresolved cell stopped a compile (`Unsupported.dep`), each chained cell is attributed to the first blocker its chain reaches, reasons are ranked by reach; report.json gains `unresolved_groups` and per-cell `blocked_by` |
22
+ | Approximate lookups unsorted | MATCH type 1 / VLOOKUP / HLOOKUP / LOOKUP over a plain numeric input table out of order compiles Excel's binary-search path (a decision tree of probes, depths and x-intervals, one aggregate in SQL; verified differentially against the bisection and against real Excel answers). A changed table is #STALE -> UNRESOLVED, never a stale answer. Type -1 and text stay UNRESOLVED (Excel's rule there is not derivable; LibreOffice differs). examples/functions.xlsx: 4 UNRESOLVED -> 2 |
23
+ | Arrays slices 1+2 | element-wise arrays in the aggregates: `SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`. An array argument is one relation with the cells table's columns (a row per element position, blanks and all), which SUM/PRODUCT/MAX/MIN/AVERAGE/COUNT/COUNTA/SUMPRODUCT read like a range; IF picks one element per position (the untaken branch's error never shows). Text converts in arithmetic ("3"->3, else #VALUE!); comparisons rank numbers < text < TRUE/FALSE case-insensitively. SUM moved from functions.py onto the aggregate machinery. A single-cell CSE formula compiles (`Cell.ref` kept from the file); multi-cell stays UNRESOLVED. Plain-entered range arithmetic/IF as an aggregate argument now follows modern Excel, not the legacy intersection - a legacy-saved workbook can FAIL there (a real user workbook's MAX(IF(...))=99 artifact surfaces as a FAIL with both values shown). Next: IFERROR/IFS/CHOOSE over arrays, & and ^ on arrays, then legacy multi-cell array formulas and dynamic arrays |
24
+ | 0.3.0 functions | PMT, PV, FV, NPER, NPV; LARGE, SMALL, RANK(.EQ), STDEV/VAR (S/P), PERCENTILE(.INC), QUARTILE(.INC); NETWORKDAYS, WORKDAY. Edge cases not checked in real Excel are an UNCHECKED marker (UNRESOLVED), like LOCALE |
25
+ | Excel tables | structured references rewritten to A1 text by the reader (`tables.py`); [#This Row] becomes a same-row reference, so a calculated column is a region |
26
+ | LET | names (stored `_xlpm.x`) substituted by their value's tree, shadowing respected; the graph skips them as dependencies |
21
27
  | Open source | MIT license, README with limits, SECURITY.md, CI on Windows/macOS/Linux x Python 3.10-3.13 |
22
28
 
23
- Tests: about 437 (dbt build included), plus 3 workbooks saved by real Excel that all PASS (4 cells UNRESOLVED on
24
- purpose). Public on GitHub (one-commit history start). 0.1.0 was released as `unexcel`; 0.2.0 (2026-10-19) and 0.2.1 (2026-10-20) are on PyPI as `cellproof` (see CHANGELOG.md).
29
+ Tests: 492 (+10 skipped without dbt/Excel files), plus 3 workbooks saved by real Excel that all PASS (4 cells UNRESOLVED on
30
+ purpose). Public on GitHub (one-commit history start). 0.1.0 was released as `unexcel`; 0.2.0, 0.2.1, 0.2.2 and 0.3.0 (2026-10-31) are on PyPI as `cellproof` (see CHANGELOG.md).
25
31
  A user's practice workbook: 3 PASS / 47 UNRESOLVED -> 48 PASS / 0 FAIL / 2 UNRESOLVED.
26
32
 
33
+ ## Public test workbooks (2026-10-31)
34
+
35
+ After 0.3.0's functions, tables and LET: 7,528 PASS, 16 FAIL, 16,104 UNRESOLVED (was 7,108 / 92 / 16,448 on 0.2.2 +
36
+ arrays). The 16 FAIL: 10 in LibreOffice files, 6 in pycel's npv.xlsx where `=C7-A7` subtracts two numbers equal to
37
+ 1e-13 relative (NPV's last digits differ from Excel's own arithmetic; every NPV cell itself PASSes). The 82 new FAILs
38
+ the arrays work exposed were INDEX with a negative index, SWITCH with an empty cell and ranges inside single-cell
39
+ array formulas - all fixed.
40
+
27
41
  ## Public test workbooks (2026-10-19)
28
42
 
29
43
  `python tests/corpus.py DIR` runs the 85 .xlsx/.xlsm test files of pycel, formulas and xlcalculator (Excel-saved,
@@ -80,8 +94,9 @@ What Excel taught us (each has a test in `tests/test_excel_findings.py`):
80
94
 
81
95
  ## Next
82
96
 
83
- 1. Array formulas and array evaluation (`SUM(A1:A10*B1:B10)`, `MAX(IF(...))`, `A1*{1,2}`). LOOKUP, YEARFRAC and
84
- array constants where a range is taken are done (unreleased).
97
+ 1. Array evaluation, next slices: IFS/CHOOSE over arrays, then legacy multi-cell array formulas and dynamic
98
+ arrays. (Done: element-wise arithmetic, comparisons, IF, IFERROR/IFNA, & and ^ inside the aggregates - see
99
+ Arrays slices 1-3 above.)
85
100
  2. Test on more real analyst workbooks (one user workbook found 4 gaps the 85 public files did not).
86
101
  3. Read time (openpyxl loads the workbook twice) and the per-cell dependency loop.
87
102
  4. Plan 3: AI retry loop for failed cells (it sees formula structure only, never values).
@@ -49,7 +49,8 @@ The output folder holds:
49
49
 
50
50
  - **`REPORT.md` / `report.json`**: every verdict, failed cells with both values, unresolved cells with the reason,
51
51
  findings (for example a number stored as text, which Excel skips in SUM), and which blocks of rows became readable
52
- table models.
52
+ table models. The unresolved reasons are ranked by how many cells depend on them ("Where to start"), so a long list
53
+ of unresolved cells says what to fix first.
53
54
  - **A dbt project** (`dbt_project.yml`, `models/`, `seeds/input_cells.csv`) that recomputes the workbook on DuckDB.
54
55
  It runs exactly the SQL the verifier checked.
55
56
 
@@ -76,12 +77,18 @@ reader -> regions -> dependency graph -> compiler -> verifier -> dbt emitter ->
76
77
  code.
77
78
  6. **Emit** the dbt project and the report.
78
79
 
79
- 96 Excel functions are supported: ABS, AND, AVERAGE, AVERAGEIF(S), CEILING, CHAR, CHOOSE, CLEAN, CONCAT(ENATE),
80
- COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR,
81
- HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LEFT, LEN, LN, LOG,
82
- LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NOT, OR, PI, POWER, PRODUCT,
83
- PROPER, REPLACE, REPT, RIGHT, ROUND(UP/DOWN), SEARCH, SIGN, SQRT, SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
84
- SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UPPER, VALUE, VLOOKUP, WEEKDAY, XLOOKUP, XOR, YEAR, YEARFRAC.
80
+ 121 Excel functions are supported: ABS, AND, AVERAGE, AVERAGEIF(S), CEILING, CHAR, CHOOSE, CLEAN, CONCAT(ENATE),
81
+ COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR, FV,
82
+ HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LARGE, LEFT, LEN, LET,
83
+ LN, LOG, LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NETWORKDAYS,
84
+ NOT, NPER, NPV, OR, PERCENTILE(.INC), PI, PMT, POWER, PRODUCT, PROPER, PV, QUARTILE(.INC), RANK(.EQ), REPLACE, REPT,
85
+ RIGHT, ROUND(UP/DOWN), SEARCH, SIGN, SMALL, SQRT, STDEV(.S/.P/P), SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
86
+ SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UPPER, VALUE, VAR(.S/.P/P), VLOOKUP, WEEKDAY, WORKDAY, XLOOKUP, XOR,
87
+ YEAR, YEARFRAC.
88
+
89
+ **Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `Sales[#Totals]`,
90
+ `Sales[[Rep]:[Amount]]`) are rewritten to plain references when the file is read, so a calculated table column
91
+ compiles like any column pasted down.
85
92
 
86
93
  **Speed** (Windows 11 laptop, measured): a 200,000-formula workbook (four formula columns over 50,000 rows, one of them
87
94
  a running total) converts and verifies in 26 s, all PASS. 50,000 rows of VLOOKUP into a 1,000-row table: 4.6 s.
@@ -92,23 +99,38 @@ COUNTIFS/SUMIFS with a criterion from the row run at the same speed.
92
99
  cellproof prefers an honest UNRESOLVED or FAIL to a guess. Known limits, each reported with a reason:
93
100
 
94
101
  - **File formats:** `.xlsx` and `.xlsm` only (no `.xls`, `.xlsb`, `.ods`). Macros (VBA) are ignored.
95
- - **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...);
96
- where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
97
- - **Not supported:** array formulas and dynamic arrays, volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
102
+ - **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
103
+ and inside array arithmetic; where one value is expected (`A1*{1,2}`) they need array evaluation and are UNRESOLVED.
104
+ - **Array arithmetic in aggregates** (`SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`,
105
+ `SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`, `SUM(A1:A9^2)`) follows modern Excel: element by element, an
106
+ empty element is 0, text converts when it is a number ("3" -> 3) and is #VALUE! otherwise, comparisons rank
107
+ numbers < text < TRUE/FALSE case-insensitively, concatenation writes numbers the Excel way, and the first error
108
+ wins. A single-cell array formula (Ctrl+Shift+Enter) compiles; an array formula over several cells is UNRESOLVED
109
+ (spilling is not read yet). A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
110
+ not the legacy first-row intersection - a workbook an old Excel last saved can show FAILs there, with both values
111
+ shown.
112
+ - **Not supported:** multi-cell array formulas and dynamic arrays, volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
98
113
  `INDIRECT` of text built while the sheet runs; `INDIRECT("Sales")` is fine), functions outside the list above,
99
- external workbooks, structured table references (`Table1[@Col]`), INDEX used as a reference, the 1904 date system in
114
+ external workbooks, a structured reference naming several separate columns (`T[[A],[C]]`), INDEX used as a reference, the 1904 date system in
100
115
  TEXT date formats.
101
116
  - **Ranges where one value is expected** (`=IF(E$3:E$41="F",B$3:B$41)`) take the formula's own row or column, as
102
- Excel does (implicit intersection). A range that IF/IFERROR/CHOOSE hands to another function
103
- (`MAX(IF(c,A1:A9,0))`, where Excel uses the whole range) is UNRESOLVED.
104
- - **Approximate lookups on unsorted data** (LOOKUP, and MATCH/VLOOKUP/HLOOKUP with match type 1/-1): UNRESOLVED, because Excel's
105
- answer then depends on its binary search.
117
+ Excel does (implicit intersection). As an aggregate's argument the element-wise answer is compiled instead (see
118
+ array arithmetic above). IFERROR, IFS and CHOOSE over arrays are still UNRESOLVED.
119
+ - **Approximate lookups on unsorted data** (LOOKUP, MATCH/VLOOKUP/HLOOKUP with match type 1): compiled for plain
120
+ numeric tables written as inputs (up to about 1,000 values): the SQL carries Excel's binary-search path itself, and
121
+ refuses changed table values instead of answering from a stale search. MATCH with type -1, text tables, tables with
122
+ empty cells or formulas, and bigger tables stay UNRESOLVED, because Excel's answer there is not derivable from the
123
+ file (LibreOffice, the only open source that emulates the search, provably differs from Excel in places).
106
124
  - **Text to number:** only plain numbers convert (`"3"`, `" -1.5e3 "`). Text Excel reads with the computer's language
107
125
  settings (`"1,000"`, `"$5"`, `"50%"`, `"1/2/2020"`, `"2:00 PM"`, `"Jan 5"`) makes the cell UNRESOLVED, because the
108
126
  file does not record those settings.
109
127
  - **Who saved the file:** the report warns when it was last saved by another program (LibreOffice, a script): the
110
128
  saved values then follow that program's rules. In a file Excel for Mac calculated, `CHAR` above 127 is UNRESOLVED
111
129
  (the Mac character set differs).
130
+ - **Edge cases not checked in real Excel yet** are UNRESOLVED with that reason, never guessed: PMT/PV/FV/NPER with
131
+ zero periods, a rate of -100% or less or a payment type other than 0 or 1; NPV at a rate of -100%; LARGE/SMALL with
132
+ a k that is not whole; RANK over a range holding an error; NETWORKDAYS/WORKDAY with text or errors among the
133
+ holidays. NETWORKDAYS.INTL, WORKDAY.INTL, IRR, RATE and the other finance and statistics functions are not in yet.
112
134
  - **Some function options:** SUBTOTAL 101-111 (hidden rows), DATEDIF units MD/YM/YD, WEEKDAY types 11-17, TEXT formats
113
135
  outside the supported table, COUNT or MEDIAN of values typed into the formula, criteria taken from an empty cell.
114
136
  - **Floating point:** a running total becomes a fast window function only when Excel's saved values prove the different
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "cellproof"
7
- version = "0.2.2"
7
+ version = "0.3.0"
8
8
  description = "Turn an Excel workbook into SQL (a dbt project on DuckDB) and prove every number matches."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -0,0 +1 @@
1
+ __version__ = "0.3.0"
@@ -41,7 +41,8 @@ def main(argv: list[str] | None = None) -> int:
41
41
  return 3
42
42
  out = args.out or args.workbook.with_name(args.workbook.stem + "_dbt")
43
43
  write_project(book, compiled, out, args.workbook.stem)
44
- counts = write_report(verdicts, compiled.findings, out, args.workbook.name, computed, compiled.notes)
44
+ counts = write_report(verdicts, compiled.findings, out, args.workbook.name, computed, compiled.notes,
45
+ compiled.chains)
45
46
  if computed:
46
47
  print(f"{len(computed)} expected values computed by the formulas library (the file had none saved)")
47
48
  print(f"{counts['PASS']} pass, {counts['FAIL']} fail, {counts['UNRESOLVED']} unresolved -> {out / 'REPORT.md'}")
@@ -71,6 +71,7 @@ class Compiled:
71
71
  unresolved: dict[Key, str]
72
72
  findings: list[str]
73
73
  notes: list[str] = dc_field(default_factory=list)
74
+ chains: dict[Key, Key] = dc_field(default_factory=dict) # cell -> the unresolved cell that stopped its compile
74
75
 
75
76
  @property
76
77
  def steps(self) -> list[Step]:
@@ -112,10 +113,17 @@ class Compiler:
112
113
  self.rowrefs: dict[str, Expr] | None = None # same-row placeholders of a region (see regions)
113
114
  self.at: Key | None = None # the formula cell being compiled in cell mode (implicit intersection)
114
115
  self.ctx: list[str] = [] # what consumes the node being compiled: "op", "fn" or "pass" (PASS_THROUGH)
116
+ self.wid = 0 # unique aliases w1, w2... for the element sources of one array argument
117
+
118
+ def walias(self) -> str:
119
+ self.wid += 1
120
+ return f"w{self.wid}"
115
121
 
116
122
  def compile_cell(self, cell: Cell) -> Expr:
117
- if cell.array:
118
- raise Unsupported("array formula")
123
+ if cell.key in self.book.unread:
124
+ raise Unsupported(self.book.unread[cell.key])
125
+ if cell.array and cell.ref and ":" in cell.ref:
126
+ raise Unsupported("array formula over several cells") # spilling into the neighbours is not read yet
119
127
  self.at = cell.key
120
128
  try:
121
129
  return finalize(self.expr(parse(cell.formula), cell.sheet))
@@ -129,6 +137,9 @@ class Compiler:
129
137
  raise Unsupported("array constant used where one value is expected (needs array evaluation) not supported yet")
130
138
  if self.at is None or area.sheet != self.at[0] or (area.r1 != area.r2 and area.c1 != area.c2):
131
139
  raise Unsupported(f"range {text} used as a single value")
140
+ if self.book.cells[self.at].array: # real Excel: {=MONTH(A1:B1)} evaluates per element, shows the first
141
+ raise Unsupported(f"range {text} where one value is expected in an array formula (needs array "
142
+ "evaluation) not supported yet")
132
143
  # real Excel: in MAX(IF(c, A1:A9, 0)) IF hands MAX the whole range; only an operator, a function's own
133
144
  # argument or the cell itself takes one value of it
134
145
  for consumer in reversed(self.ctx):
@@ -238,7 +249,7 @@ class Compiler:
238
249
  elif key in self.done:
239
250
  typ, may_err = self.done[key]
240
251
  else:
241
- raise Unsupported(f"depends on unresolved cell {a1(key)}")
252
+ raise Unsupported(f"depends on unresolved cell {a1(key)}", key)
242
253
  where = f"FROM {CELLS} WHERE {where_cell(key)}"
243
254
  err = f"(SELECT CASE WHEN kind = 'e' THEN txt END {where})" if may_err else NO_ERR
244
255
  if typ == "num":
@@ -266,7 +277,7 @@ class Compiler:
266
277
  if key in self.open:
267
278
  raise NewBatch
268
279
  if key not in self.done:
269
- raise Unsupported(f"depends on unresolved cell {a1(key)}")
280
+ raise Unsupported(f"depends on unresolved cell {a1(key)}", key)
270
281
  raise AssertionError("range index is out of step with the compiler")
271
282
 
272
283
  def kind_of(self, key: Key) -> str:
@@ -324,6 +335,7 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
324
335
  scan = find_regions(book) if regions else RegionScan([], [])
325
336
  order, unresolved, kept = order_with_regions(book, scan.regions)
326
337
  comp = Compiler(book)
338
+ chains: dict[Key, Key] = {} # cell -> the unresolved cell that stopped its compile (see impact.py)
327
339
  if book.app and not (book.app.startswith("Microsoft") and "Compatible" not in book.app): # openpyxl: "Compatible"
328
340
  comp.findings.append(f"the file was last saved by {book.app}, not Microsoft Excel: its saved values follow that "
329
341
  "program's rules, so a FAIL can be a difference between that program and Excel")
@@ -369,6 +381,8 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
369
381
  e = comp.compile_cell(cell) # the open batch is empty now, so this can't raise NewBatch
370
382
  except Unsupported as err:
371
383
  unresolved[key] = str(err)
384
+ if err.dep is not None:
385
+ chains[key] = err.dep
372
386
  return
373
387
  except RecursionError: # Python's stack, not DuckDB's: DuckDB took 900 nesting levels in tests
374
388
  unresolved[key] = DEEP
@@ -402,7 +416,7 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
402
416
  for row in range(region.r1, region.r2 + 1):
403
417
  add((region.sheet, row, col))
404
418
  _close(comp, batches, current)
405
- return Compiled(batches, unresolved, comp.findings, notes)
419
+ return Compiled(batches, unresolved, comp.findings, notes, chains)
406
420
 
407
421
 
408
422
  def cell_row(typ: str, v: str, e: str, t: str, k: str) -> tuple[str, str, str]:
@@ -18,7 +18,15 @@ PLATFORM = "#PLATFORM" # not an Excel error either: Excel for Mac answers diffe
18
18
  PLATFORM_REASON = "CHAR above 127 gives a different character in Excel for Mac, which last calculated this file"
19
19
  EARLY1900 = "#1900" # nor this: a date before 1 March 1900, where Excel counts a 29 February that never existed
20
20
  EARLY1900_REASON = "YEARFRAC of a date before 1 March 1900, around Excel's 29 February 1900 that never existed"
21
- SETTINGS = {LOCALE: LOCALE_REASON, PLATFORM: PLATFORM_REASON, EARLY1900: EARLY1900_REASON} # reported as UNRESOLVED
21
+ STALE = "#STALE" # nor this: a compiled binary search whose table's values changed after translation
22
+ STALE_REASON = ("the lookup table's values changed after the workbook was translated, so its compiled search is "
23
+ "out of date: re-run cellproof")
24
+ UNCHECKED = "#UNCHECKED" # nor this: an edge case of a function whose Excel answer was never checked in real Excel
25
+ UNCHECKED_REASON = ("an edge case of this function (like zero periods, a rate of -100% or less, a payment type other "
26
+ "than 0 or 1, a k that is not a whole number, or an error in the range) whose Excel answer has not "
27
+ "been checked against real Excel yet")
28
+ SETTINGS = {LOCALE: LOCALE_REASON, PLATFORM: PLATFORM_REASON, EARLY1900: EARLY1900_REASON,
29
+ STALE: STALE_REASON, UNCHECKED: UNCHECKED_REASON} # reported as UNRESOLVED
22
30
  Type = Literal["num", "txt", "bool", "blank", "err", "any"]
23
31
 
24
32
 
@@ -1,2 +1,2 @@
1
1
  """The Excel function library. Importing this package registers every function in cellproof.functions.FUNCS."""
2
- from cellproof.fn import aggregate, criteria, dates, logic, lookup, maths, text # noqa: F401
2
+ from cellproof.fn import aggregate, criteria, dates, finance, logic, lookup, maths, stats, text # noqa: F401