cellproof 0.3.1__tar.gz → 0.5.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.
- {cellproof-0.3.1 → cellproof-0.5.0}/CHANGELOG.md +38 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/PKG-INFO +21 -11
- {cellproof-0.3.1 → cellproof-0.5.0}/PROGRESS.md +5 -4
- {cellproof-0.3.1 → cellproof-0.5.0}/README.md +20 -10
- {cellproof-0.3.1 → cellproof-0.5.0}/pyproject.toml +1 -1
- cellproof-0.5.0/src/cellproof/__init__.py +1 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/compiler.py +88 -7
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/emitter.py +4 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/expr.py +2 -2
- cellproof-0.5.0/src/cellproof/fn/__init__.py +2 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/aggregate.py +7 -1
- cellproof-0.5.0/src/cellproof/fn/dynamic.py +351 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/logic.py +36 -2
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/lookup.py +50 -3
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/text.py +11 -6
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/model.py +1 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/parser.py +1 -1
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/reader.py +108 -2
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_arrays.py +4 -3
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_corpus_findings.py +6 -5
- cellproof-0.5.0/tests/test_dynamic.py +133 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_emitter.py +27 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_lookups.py +19 -0
- cellproof-0.5.0/tests/test_spill.py +100 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_text.py +12 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/xlsxkit.py +4 -2
- cellproof-0.3.1/src/cellproof/__init__.py +0 -1
- cellproof-0.3.1/src/cellproof/fn/__init__.py +0 -2
- {cellproof-0.3.1 → cellproof-0.5.0}/.github/workflows/ci.yml +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/.github/workflows/publish.yml +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/.gitignore +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/AGENTS.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/DESIGN.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/INFO.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/LICENSE +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/PLAN-2a.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/PLAN-2b.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/PLAN.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/SECURITY.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/JOURNEY.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/superpowers/plans/2026-10-14-plan-2c-speed.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/superpowers/plans/2026-10-14-plan-2d-table-mode.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/superpowers/specs/2026-10-14-plan-2c-speed-design.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/superpowers/specs/2026-10-14-plan-2d-table-mode-design.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/superpowers/specs/2026-10-18-running-totals-design.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/docs/superpowers/specs/2026-10-19-lookups-row-wise-design.md +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/commission.xlsx +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/errors.xlsx +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/functions.xlsx +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/functions_unsaved.xlsx +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/make_commission.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/make_errors.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/examples/make_functions.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/__main__.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/cli.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/compute.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fenwick.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/criteria.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/dates.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/finance.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/maths.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/fn/stats.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/functions.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/graph.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/impact.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/r1c1.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/rangeindex.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/refs.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/region.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/regions.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/report.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/tables.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/src/cellproof/verifier.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/bench_shapes.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/corpus.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_aggregate.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_batches.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_cli.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_compiler.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_compute.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_criteria.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_dates.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_errors.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_excel_findings.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_excel_saved.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_fenwick.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_finance_stats.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_functions.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_graph.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_impact.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_implicit.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_index.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_lexed.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_limits.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_logic.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_lookup.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_maths.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_parser.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_perf.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_r1c1.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_rangeindex.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_reader.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_refs.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_region.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_regions.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_regions_differential.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_regions_split.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_report.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_review_regressions.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_running.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_shapes.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_tables.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_types.py +0 -0
- {cellproof-0.3.1 → cellproof-0.5.0}/tests/test_verifier.py +0 -0
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0 (2026-10-31)
|
|
4
|
+
|
|
5
|
+
- **FILTER, SORT, UNIQUE inside other calculations:** `SUM(FILTER(...))`, `COUNTA(UNIQUE(...))`, AVERAGE, MIN, MAX,
|
|
6
|
+
PRODUCT, STDEV, VAR of them; **ROWS** and **COLUMNS** (of a range or of these). An empty element reaching an
|
|
7
|
+
aggregate is UNRESOLVED (whether Excel skips it or takes 0 was not checked), even through COUNT.
|
|
8
|
+
- **XMATCH** (exact, next smaller/larger, wildcards; first-to-last or last-to-first), **SORTBY** (several keys; by
|
|
9
|
+
rows, or by columns when the keys are one row: real Excel), **SEQUENCE** (more than a million elements is
|
|
10
|
+
UNRESOLVED and builds nothing). FILTER's if_empty can be a range, which spills whole.
|
|
11
|
+
- **Spills are one statement:** a spilled block is one batch computing its relation once (verify 1,334 cells
|
|
12
|
+
31.0 s -> 0.03 s; 33,334 cells in 0.7 s), and one dbt model.
|
|
13
|
+
- **Not guessed:** XLOOKUP/XMATCH next smaller/larger across types or over text with punctuation (Excel ranks numbers
|
|
14
|
+
< text < TRUE/FALSE and orders text by its own collation), and exact text matches with a German sharp s (Excel
|
|
15
|
+
matched "ss" to it). Some of these used to PASS by luck; they are UNRESOLVED now.
|
|
16
|
+
|
|
17
|
+
## 0.4.0 (2026-10-31)
|
|
18
|
+
|
|
19
|
+
- **Array formulas over a block** (legacy Ctrl+Shift+Enter blocks and dynamic-array spills) compile cell by cell:
|
|
20
|
+
a range where one value is expected takes this cell's element, a range one row (column) high repeats down
|
|
21
|
+
(across). Rules learned from formulas' Excel-saved test.xlsx: a block cell past the array is #N/A whatever the
|
|
22
|
+
formula does with errors (`{=IFERROR(G9:Q9,R9)}`), but an IS function's own range is padded with #N/A elements
|
|
23
|
+
(`{=ISERROR(C8:Q8)}` past Q8 is TRUE); EDATE, EOMONTH, MROUND and YEARFRAC do not take a range there (#VALUE!).
|
|
24
|
+
A single-cell array formula is its first element (`{=MONTH(I6:J6)}`).
|
|
25
|
+
- **FILTER, SORT, UNIQUE** spill their results and nest in each other (`SORT(UNIQUE(FILTER(...)))`): FILTER by rows
|
|
26
|
+
or columns with if_empty, SORT by one key (ascending or descending, equal keys keep their order), UNIQUE with
|
|
27
|
+
exactly_once, text compared ignoring case. A dynamic spill (Excel's cm mark on the cell, now read) whose result
|
|
28
|
+
is not exactly as big as the block Excel saved shows #SPILL! in its first cell, a FAIL. Not guessed (UNRESOLVED):
|
|
29
|
+
an empty FILTER without if_empty (#CALC! in Microsoft's docs, #VALUE! in an Excel-saved file), SORT keys that
|
|
30
|
+
are empty, errors or text with punctuation, UNIQUE over empty cells or errors.
|
|
31
|
+
- **Excel 365 error codes** (#CALC!, #SPILL!, #FIELD!, ...) are read as errors; functions stored `_xlfn._xlws.` are
|
|
32
|
+
recognised.
|
|
33
|
+
- **Security:** an array block in a crafted file can no longer overwrite another cell's formula or create cells the
|
|
34
|
+
file does not hold.
|
|
35
|
+
- **`A1#`** (ANCHORARRAY) is the block Excel spilled A1 into; **`@`** (SINGLE) is implicit intersection.
|
|
36
|
+
- **INDEX with a row or column of 0** is the whole column or row: element by element in an array formula,
|
|
37
|
+
UNRESOLVED elsewhere (was a wrong #REF!).
|
|
38
|
+
- **Fixes:** SUBSTITUTE with an instance number and cell arguments stopped the run on DuckDB 2.0 (exit 3), and
|
|
39
|
+
refuses TRUE as the instance like Excel; ISBLANK of a range read its first cell only.
|
|
40
|
+
|
|
3
41
|
## 0.3.1 (2026-10-31)
|
|
4
42
|
|
|
5
43
|
- **WORKDAY with a huge holidays range** (`WORKDAY(A1,5,I1:XFD1048576)`): the days it searched were sized by the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: cellproof
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.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
|
|
@@ -111,13 +111,13 @@ reader -> regions -> dependency graph -> compiler -> verifier -> dbt emitter ->
|
|
|
111
111
|
code.
|
|
112
112
|
6. **Emit** the dbt project and the report.
|
|
113
113
|
|
|
114
|
-
|
|
115
|
-
COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR, FV,
|
|
114
|
+
130 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, COLUMNS, EXACT, EXP, FILTER, FIND, FLOOR, FV,
|
|
116
116
|
HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LARGE, LEFT, LEN, LET,
|
|
117
117
|
LN, LOG, LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NETWORKDAYS,
|
|
118
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,
|
|
119
|
+
RIGHT, ROUND(UP/DOWN), ROWS, SEQUENCE, SEARCH, SIGN, SMALL, SQRT, STDEV(.S/.P/P), SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
|
|
120
|
+
SORT, SORTBY, SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UNIQUE, UPPER, VALUE, VAR(.S/.P/P), VLOOKUP, WEEKDAY, WORKDAY, XLOOKUP, XMATCH, XOR,
|
|
121
121
|
YEAR, YEARFRAC.
|
|
122
122
|
|
|
123
123
|
**Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `Sales[#Totals]`,
|
|
@@ -133,23 +133,33 @@ COUNTIFS/SUMIFS with a criterion from the row run at the same speed.
|
|
|
133
133
|
cellproof prefers an honest UNRESOLVED or FAIL to a guess. Known limits, each reported with a reason:
|
|
134
134
|
|
|
135
135
|
- **File formats:** `.xlsx` and `.xlsm` only (no `.xls`, `.xlsb`, `.ods`). Macros (VBA) are ignored.
|
|
136
|
-
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
|
|
137
|
-
and
|
|
136
|
+
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...),
|
|
137
|
+
inside array arithmetic and in array formulas; where one value is expected in a plain formula (`A1*{1,2}`) they are
|
|
138
|
+
UNRESOLVED.
|
|
139
|
+
- **Array formulas over a block and dynamic arrays** (legacy Ctrl+Shift+Enter blocks, Excel 365 spills): every cell of
|
|
140
|
+
the block is verified. A range where one value is expected takes the cell's element (one row or column repeats);
|
|
141
|
+
past the array a cell is #N/A, while an IS function's own range is padded per element, as real Excel does. `A1#`
|
|
142
|
+
and `@` are read. **FILTER, SORT and UNIQUE** spill their results and nest in each other; a dynamic spill whose
|
|
143
|
+
result is not exactly as big as the block Excel saved shows #SPILL! in its first cell (a FAIL). The generated SQL
|
|
144
|
+
computes the block Excel saved: if the data later changes the size of a FILTER's result, re-run cellproof.
|
|
145
|
+
SORTBY, SEQUENCE and XMATCH too, and all of them inside aggregates (`SUM(FILTER(...))`, `ROWS(UNIQUE(...))`).
|
|
146
|
+
Not yet: TAKE/DROP/CHOOSECOLS and the other array functions, these functions inside other non-aggregate
|
|
147
|
+
calculations, SORT by several keys or by columns (SORTBY does both), SORT/SORTBY keys that are empty, errors or text
|
|
148
|
+
with punctuation (Excel's own text order), UNIQUE over empty cells or errors - all UNRESOLVED.
|
|
138
149
|
- **Array arithmetic in aggregates** (`SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`,
|
|
139
150
|
`SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`, `SUM(A1:A9^2)`) follows modern Excel: element by element, an
|
|
140
151
|
empty element is 0, text converts when it is a number ("3" -> 3) and is #VALUE! otherwise, comparisons rank
|
|
141
152
|
numbers < text < TRUE/FALSE case-insensitively, concatenation writes numbers the Excel way, and the first error
|
|
142
|
-
wins. A
|
|
143
|
-
(spilling is not read yet). A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
|
|
153
|
+
wins. A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
|
|
144
154
|
not the legacy first-row intersection - a workbook an old Excel last saved can show FAILs there, with both values
|
|
145
155
|
shown.
|
|
146
|
-
- **Not supported:**
|
|
156
|
+
- **Not supported:** volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
|
|
147
157
|
`INDIRECT` of text built while the sheet runs; `INDIRECT("Sales")` is fine), functions outside the list above,
|
|
148
158
|
external workbooks, a structured reference naming several separate columns (`T[[A],[C]]`), INDEX used as a reference, the 1904 date system in
|
|
149
159
|
TEXT date formats.
|
|
150
160
|
- **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
|
|
151
161
|
Excel does (implicit intersection). As an aggregate's argument the element-wise answer is compiled instead (see
|
|
152
|
-
array arithmetic above)
|
|
162
|
+
array arithmetic above); in an array formula, element by element (see array formulas above).
|
|
153
163
|
- **Approximate lookups on unsorted data** (LOOKUP, MATCH/VLOOKUP/HLOOKUP with match type 1): compiled for plain
|
|
154
164
|
numeric tables written as inputs (up to about 1,000 values): the SQL carries Excel's binary-search path itself, and
|
|
155
165
|
refuses changed table values instead of answering from a stale search. MATCH with type -1, text tables, tables with
|
|
@@ -24,10 +24,12 @@ Everything below is on `main`, built test-first, each piece reviewed by a fresh
|
|
|
24
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
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
26
|
| LET | names (stored `_xlpm.x`) substituted by their value's tree, shadowing respected; the graph skips them as dependencies |
|
|
27
|
+
| Array blocks (0.4.0) | each cell of a CSE block or dynamic spill is a formula cell computing its element (`Compiler.spill`, `_element`); per-cell #N/A past the array, IS functions padded per element; ANCHORARRAY, SINGLE; blocks never overwrite other formulas |
|
|
28
|
+
| FILTER/SORT/UNIQUE (0.4.0) | `fn/dynamic.py`: arrays as relations (i, j, value), nested via MATERIALIZED CTEs; dynamic anchors check the result size against the saved block (`Cell.dynamic` from the file's cm mark) |
|
|
27
29
|
| Open source | MIT license, README with limits, SECURITY.md, CI on Windows/macOS/Linux x Python 3.10-3.13 |
|
|
28
30
|
|
|
29
31
|
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.
|
|
32
|
+
purpose). Public on GitHub (one-commit history start). 0.1.0 was released as `unexcel`; 0.2.x, 0.3.0, 0.3.1, 0.4.0 and 0.5.0 (2026-10-31) are on PyPI as `cellproof` (see CHANGELOG.md).
|
|
31
33
|
A user's practice workbook: 3 PASS / 47 UNRESOLVED -> 48 PASS / 0 FAIL / 2 UNRESOLVED.
|
|
32
34
|
|
|
33
35
|
## Public test workbooks (2026-10-31)
|
|
@@ -94,9 +96,8 @@ What Excel taught us (each has a test in `tests/test_excel_findings.py`):
|
|
|
94
96
|
|
|
95
97
|
## Next
|
|
96
98
|
|
|
97
|
-
1.
|
|
98
|
-
|
|
99
|
-
Arrays slices 1-3 above.)
|
|
99
|
+
1. Arrays, next: FILTER/SORT/UNIQUE inside other calculations (`ROWS(UNIQUE())`, `SUM(FILTER())`), SORTBY,
|
|
100
|
+
SEQUENCE, XMATCH (384 corpus cells), TAKE/DROP/CHOOSECOLS/TOCOL; one evaluation per spill instead of per cell.
|
|
100
101
|
2. Test on more real analyst workbooks (one user workbook found 4 gaps the 85 public files did not).
|
|
101
102
|
3. Read time (openpyxl loads the workbook twice) and the per-cell dependency loop.
|
|
102
103
|
4. Plan 3: AI retry loop for failed cells (it sees formula structure only, never values).
|
|
@@ -77,13 +77,13 @@ reader -> regions -> dependency graph -> compiler -> verifier -> dbt emitter ->
|
|
|
77
77
|
code.
|
|
78
78
|
6. **Emit** the dbt project and the report.
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
COUNT, COUNTA, COUNTBLANK, COUNTIF(S), DATE, DATEDIF, DAY, DAYS, DAYS360, EDATE, EOMONTH, EXACT, EXP, FIND, FLOOR, FV,
|
|
80
|
+
130 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, COLUMNS, EXACT, EXP, FILTER, FIND, FLOOR, FV,
|
|
82
82
|
HLOOKUP, IF, IFERROR, IFNA, IFS, INDEX, INT, IS* (BLANK, ERR, ERROR, LOGICAL, NA, NUMBER, TEXT), LARGE, LEFT, LEN, LET,
|
|
83
83
|
LN, LOG, LOG10, LOOKUP, LOWER, MATCH, MAX, MAXIFS, MEDIAN, MID, MIN, MINIFS, MOD, MODE, MONTH, MROUND, NA, NETWORKDAYS,
|
|
84
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,
|
|
85
|
+
RIGHT, ROUND(UP/DOWN), ROWS, SEQUENCE, SEARCH, SIGN, SMALL, SQRT, STDEV(.S/.P/P), SUBSTITUTE, SUBTOTAL, SUM, SUMIF(S), SUMPRODUCT,
|
|
86
|
+
SORT, SORTBY, SWITCH, TEXT, TEXTJOIN, TRIM, TRUE/FALSE, TRUNC, UNIQUE, UPPER, VALUE, VAR(.S/.P/P), VLOOKUP, WEEKDAY, WORKDAY, XLOOKUP, XMATCH, XOR,
|
|
87
87
|
YEAR, YEARFRAC.
|
|
88
88
|
|
|
89
89
|
**Excel tables:** structured references (`Sales[Amount]`, `Sales[@Qty]`, `Sales[[#This Row],[Qty]]`, `Sales[#Totals]`,
|
|
@@ -99,23 +99,33 @@ COUNTIFS/SUMIFS with a criterion from the row run at the same speed.
|
|
|
99
99
|
cellproof prefers an honest UNRESOLVED or FAIL to a guess. Known limits, each reported with a reason:
|
|
100
100
|
|
|
101
101
|
- **File formats:** `.xlsx` and `.xlsm` only (no `.xls`, `.xlsb`, `.ods`). Macros (VBA) are ignored.
|
|
102
|
-
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...)
|
|
103
|
-
and
|
|
102
|
+
- **Array constants** (`{0,50,100}`) work wherever a range is taken (`SUM`, `MATCH`, `LOOKUP`, `VLOOKUP`, `INDEX`...),
|
|
103
|
+
inside array arithmetic and in array formulas; where one value is expected in a plain formula (`A1*{1,2}`) they are
|
|
104
|
+
UNRESOLVED.
|
|
105
|
+
- **Array formulas over a block and dynamic arrays** (legacy Ctrl+Shift+Enter blocks, Excel 365 spills): every cell of
|
|
106
|
+
the block is verified. A range where one value is expected takes the cell's element (one row or column repeats);
|
|
107
|
+
past the array a cell is #N/A, while an IS function's own range is padded per element, as real Excel does. `A1#`
|
|
108
|
+
and `@` are read. **FILTER, SORT and UNIQUE** spill their results and nest in each other; a dynamic spill whose
|
|
109
|
+
result is not exactly as big as the block Excel saved shows #SPILL! in its first cell (a FAIL). The generated SQL
|
|
110
|
+
computes the block Excel saved: if the data later changes the size of a FILTER's result, re-run cellproof.
|
|
111
|
+
SORTBY, SEQUENCE and XMATCH too, and all of them inside aggregates (`SUM(FILTER(...))`, `ROWS(UNIQUE(...))`).
|
|
112
|
+
Not yet: TAKE/DROP/CHOOSECOLS and the other array functions, these functions inside other non-aggregate
|
|
113
|
+
calculations, SORT by several keys or by columns (SORTBY does both), SORT/SORTBY keys that are empty, errors or text
|
|
114
|
+
with punctuation (Excel's own text order), UNIQUE over empty cells or errors - all UNRESOLVED.
|
|
104
115
|
- **Array arithmetic in aggregates** (`SUM(A1:A10*B1:B10)`, `SUMPRODUCT((A1:A9>5)*C1:C9)`, `MAX(IF(A1:A9="x",B1:B9))`,
|
|
105
116
|
`SUM(IFERROR(A1:A9/B1:B9,0))`, `COUNTA(A1:A9&B1:B9)`, `SUM(A1:A9^2)`) follows modern Excel: element by element, an
|
|
106
117
|
empty element is 0, text converts when it is a number ("3" -> 3) and is #VALUE! otherwise, comparisons rank
|
|
107
118
|
numbers < text < TRUE/FALSE case-insensitively, concatenation writes numbers the Excel way, and the first error
|
|
108
|
-
wins. A
|
|
109
|
-
(spilling is not read yet). A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
|
|
119
|
+
wins. A plain-entered range arithmetic or IF as an aggregate argument follows modern Excel,
|
|
110
120
|
not the legacy first-row intersection - a workbook an old Excel last saved can show FAILs there, with both values
|
|
111
121
|
shown.
|
|
112
|
-
- **Not supported:**
|
|
122
|
+
- **Not supported:** volatile functions (`NOW`, `TODAY`, `RAND`, `OFFSET`, and
|
|
113
123
|
`INDIRECT` of text built while the sheet runs; `INDIRECT("Sales")` is fine), functions outside the list above,
|
|
114
124
|
external workbooks, a structured reference naming several separate columns (`T[[A],[C]]`), INDEX used as a reference, the 1904 date system in
|
|
115
125
|
TEXT date formats.
|
|
116
126
|
- **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
|
|
117
127
|
Excel does (implicit intersection). As an aggregate's argument the element-wise answer is compiled instead (see
|
|
118
|
-
array arithmetic above)
|
|
128
|
+
array arithmetic above); in an array formula, element by element (see array formulas above).
|
|
119
129
|
- **Approximate lookups on unsorted data** (LOOKUP, MATCH/VLOOKUP/HLOOKUP with match type 1): compiled for plain
|
|
120
130
|
numeric tables written as inputs (up to about 1,000 values): the SQL carries Excel's binary-search path itself, and
|
|
121
131
|
refuses changed table values instead of answering from a stale search. MATCH with type -1, text tables, tables with
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.0"
|
|
@@ -15,8 +15,11 @@ from dataclasses import field as dc_field
|
|
|
15
15
|
from pathlib import Path
|
|
16
16
|
|
|
17
17
|
import cellproof.fn # noqa: F401 (registers the function library)
|
|
18
|
+
from openpyxl.utils import range_boundaries
|
|
19
|
+
|
|
18
20
|
from cellproof.expr import (BLANK, CELLS, NO_ERR, Expr, any_of, compare, error, errs, finalize, lit_num, lit_str, num,
|
|
19
21
|
txt, where_cell)
|
|
22
|
+
from cellproof.fn.dynamic import DYNAMIC, spill_batch
|
|
20
23
|
from cellproof.functions import FUNCS
|
|
21
24
|
from cellproof.graph import formula_order
|
|
22
25
|
from cellproof.model import Book, Cell, Key, Unsupported, a1
|
|
@@ -102,6 +105,11 @@ class Keys:
|
|
|
102
105
|
return self._comp.index.text_cells(a.sheet, a.r1, a.c1, a.r2, a.c2)
|
|
103
106
|
|
|
104
107
|
|
|
108
|
+
# Analysis ToolPak functions do not take an array where one value is expected: {arguments that are one value}
|
|
109
|
+
NO_LIFT = {"EDATE": 2, "EOMONTH": 2, "MROUND": 2, "YEARFRAC": 3, "NETWORKDAYS": 2, "WORKDAY": 2}
|
|
110
|
+
NO_LIFT_CHECKED = {"EDATE", "EOMONTH", "MROUND", "YEARFRAC"} # #VALUE! there, in formulas' Excel-saved test.xlsx
|
|
111
|
+
|
|
112
|
+
|
|
105
113
|
class Compiler:
|
|
106
114
|
def __init__(self, book: Book):
|
|
107
115
|
add_arrays(book)
|
|
@@ -114,6 +122,8 @@ class Compiler:
|
|
|
114
122
|
self.at: Key | None = None # the formula cell being compiled in cell mode (implicit intersection)
|
|
115
123
|
self.ctx: list[str] = [] # what consumes the node being compiled: "op", "fn" or "pass" (PASS_THROUGH)
|
|
116
124
|
self.wid = 0 # unique aliases w1, w2... for the element sources of one array argument
|
|
125
|
+
self.spill: tuple[int, int] | None = None # array formula: this cell's (row, col) offset in its block
|
|
126
|
+
self.spill_dims: list[tuple[int, int]] = [] # sizes of the ranges taken element by element (see _element)
|
|
117
127
|
|
|
118
128
|
def walias(self) -> str:
|
|
119
129
|
self.wid += 1
|
|
@@ -122,24 +132,35 @@ class Compiler:
|
|
|
122
132
|
def compile_cell(self, cell: Cell) -> Expr:
|
|
123
133
|
if cell.key in self.book.unread:
|
|
124
134
|
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
|
|
127
135
|
self.at = cell.key
|
|
136
|
+
self.spill, self.spill_dims = None, []
|
|
137
|
+
if cell.array:
|
|
138
|
+
c1, r1, _, _ = range_boundaries(cell.ref or a1(cell.key).split("!")[-1])
|
|
139
|
+
self.spill = (cell.row - r1, cell.col - c1)
|
|
128
140
|
try:
|
|
129
|
-
|
|
141
|
+
e = finalize(self.expr(parse(cell.formula), cell.sheet))
|
|
142
|
+
if self.spill is not None and self.spill_dims:
|
|
143
|
+
# real Excel (formulas' test.xlsx): the array is as big as its biggest range, one row (column)
|
|
144
|
+
# repeating; a block cell beyond it is #N/A whatever the formula does with errors -
|
|
145
|
+
# {=IFERROR(G9:Q9,R9)} one cell past Q9 is #N/A, not R9
|
|
146
|
+
rows = max(d[0] for d in self.spill_dims)
|
|
147
|
+
cols = max(d[1] for d in self.spill_dims)
|
|
148
|
+
i, j = self.spill
|
|
149
|
+
if (rows > 1 and i >= rows) or (cols > 1 and j >= cols):
|
|
150
|
+
return error("#N/A")
|
|
151
|
+
return e
|
|
130
152
|
finally:
|
|
131
|
-
self.at = None
|
|
153
|
+
self.at, self.spill = None, None
|
|
132
154
|
|
|
133
155
|
def _intersect(self, area, text: str) -> Expr:
|
|
134
156
|
"""A range where one value is expected: Excel's implicit intersection takes the cell in the formula's own row
|
|
135
157
|
(a one-column range) or column (a one-row range), and is #VALUE! when there is none."""
|
|
158
|
+
if self.spill is not None:
|
|
159
|
+
return self._element(area)
|
|
136
160
|
if area.sheet in self.book.arrays:
|
|
137
161
|
raise Unsupported("array constant used where one value is expected (needs array evaluation) not supported yet")
|
|
138
162
|
if self.at is None or area.sheet != self.at[0] or (area.r1 != area.r2 and area.c1 != area.c2):
|
|
139
163
|
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")
|
|
143
164
|
# real Excel: in MAX(IF(c, A1:A9, 0)) IF hands MAX the whole range; only an operator, a function's own
|
|
144
165
|
# argument or the cell itself takes one value of it
|
|
145
166
|
for consumer in reversed(self.ctx):
|
|
@@ -157,6 +178,23 @@ class Compiler:
|
|
|
157
178
|
return self.cell_value((area.sheet, area.r1, col))
|
|
158
179
|
return error("#VALUE!")
|
|
159
180
|
|
|
181
|
+
def element_key(self, area) -> Key | None:
|
|
182
|
+
"""In an array formula a range where one value is expected is taken element by element: this cell's element,
|
|
183
|
+
the only row (column) of a range one row (column) high for every row (column); None beyond its size, where
|
|
184
|
+
Excel pads the range with #N/A (so ISERROR there is TRUE: real Excel, formulas' test.xlsx)."""
|
|
185
|
+
rows, cols = area.r2 - area.r1 + 1, area.c2 - area.c1 + 1
|
|
186
|
+
i, j = self.spill
|
|
187
|
+
i, j = (0 if rows == 1 else i), (0 if cols == 1 else j)
|
|
188
|
+
return None if i >= rows or j >= cols else (area.sheet, area.r1 + i, area.c1 + j)
|
|
189
|
+
|
|
190
|
+
def _element(self, area, sized: bool = True) -> Expr:
|
|
191
|
+
"""sized=False: an IS function's own argument, which real Excel pads with #N/A without sizing the array
|
|
192
|
+
({=ISERROR(C8:Q8)} past Q8 is TRUE)."""
|
|
193
|
+
if sized:
|
|
194
|
+
self.spill_dims.append((area.r2 - area.r1 + 1, area.c2 - area.c1 + 1))
|
|
195
|
+
key = self.element_key(area)
|
|
196
|
+
return error("#N/A") if key is None else self.cell_value(key)
|
|
197
|
+
|
|
160
198
|
def expr(self, node, sheet: str) -> Expr:
|
|
161
199
|
e = self._expr(node, sheet)
|
|
162
200
|
if sum(len(part) for part in (e.sql, e.err, e.txt, e.kind)) > MAX_SQL:
|
|
@@ -204,6 +242,13 @@ class Compiler:
|
|
|
204
242
|
fn = FUNCS.get(node.name)
|
|
205
243
|
if fn is None:
|
|
206
244
|
raise Unsupported(f"function {node.name} not supported yet")
|
|
245
|
+
if self.spill is not None and node.name in NO_LIFT:
|
|
246
|
+
ranged = [i for i, a in enumerate(node.args) if i < NO_LIFT[node.name] and isinstance(a, RefNode)
|
|
247
|
+
and not resolve(a.text, sheet, self.book).is_single]
|
|
248
|
+
if ranged and node.name in NO_LIFT_CHECKED:
|
|
249
|
+
return error("#VALUE!") # real Excel: {=EDATE(E9:I9,C9:G9)} is #VALUE! in every cell
|
|
250
|
+
if ranged:
|
|
251
|
+
raise Unsupported(f"{node.name} of a range in an array formula not supported yet")
|
|
207
252
|
return fn(self, node.args, sheet)
|
|
208
253
|
raise Unsupported(f"cannot translate {node!r}")
|
|
209
254
|
|
|
@@ -362,10 +407,46 @@ def compile_book(book: Book, regions: bool = True) -> Compiled:
|
|
|
362
407
|
notes.append(f"{r.sheet} rows {r.r1}-{r.r2}, columns {letters(r.cols)} stay in cell mode: they could not "
|
|
363
408
|
f"be ordered as one block ({why})")
|
|
364
409
|
used_models: set[str] = set()
|
|
410
|
+
spilled: set[Key] = set()
|
|
411
|
+
|
|
412
|
+
def add_spill(cell) -> bool:
|
|
413
|
+
"""FILTER/SORT/UNIQUE/... spilled into a block: one batch for the whole block (fn/dynamic.spill_batch)."""
|
|
414
|
+
nonlocal weight
|
|
415
|
+
if not cell.array:
|
|
416
|
+
return False
|
|
417
|
+
try:
|
|
418
|
+
tree = parse(cell.formula)
|
|
419
|
+
except Unsupported:
|
|
420
|
+
return False
|
|
421
|
+
if not (isinstance(tree, Call) and tree.name in DYNAMIC):
|
|
422
|
+
return False
|
|
423
|
+
c1, r1, c2, r2 = range_boundaries(cell.ref or a1(cell.key).split("!")[-1])
|
|
424
|
+
block = [k for k in ((cell.sheet, r, c) for r in range(r1, r2 + 1) for c in range(c1, c2 + 1))
|
|
425
|
+
if k in book.cells and book.cells[k].array and book.cells[k].ref == cell.ref
|
|
426
|
+
and book.cells[k].formula == cell.formula]
|
|
427
|
+
spilled.update(block)
|
|
428
|
+
_close(comp, batches, current)
|
|
429
|
+
weight = 0
|
|
430
|
+
comp.at = (cell.sheet, r1, c1)
|
|
431
|
+
try:
|
|
432
|
+
_finish(comp, batches, spill_batch(comp, tree, cell.sheet, block, (r1, c1, r2, c2), cell.dynamic))
|
|
433
|
+
except Unsupported as err:
|
|
434
|
+
for k in block:
|
|
435
|
+
unresolved[k] = str(err)
|
|
436
|
+
if err.dep is not None:
|
|
437
|
+
chains[k] = err.dep
|
|
438
|
+
except RecursionError:
|
|
439
|
+
for k in block:
|
|
440
|
+
unresolved[k] = DEEP
|
|
441
|
+
finally:
|
|
442
|
+
comp.at = None
|
|
443
|
+
return True
|
|
365
444
|
|
|
366
445
|
def add(key) -> None:
|
|
367
446
|
nonlocal weight
|
|
368
447
|
cell = book.cells[key]
|
|
448
|
+
if key in spilled or add_spill(cell):
|
|
449
|
+
return
|
|
369
450
|
if cell.kind == "blank":
|
|
370
451
|
unresolved[key] = NO_VALUE
|
|
371
452
|
return
|
|
@@ -140,6 +140,10 @@ def write_project(book: Book, compiled: Compiled, out: Path, stem: str) -> None:
|
|
|
140
140
|
(batches_dir / f"{model_name(k)}.sql").write_text(dbt_region_cells(batch) + "\n", encoding="utf-8")
|
|
141
141
|
schema += (f' - name: {batch.model}\n description: "Region: rows of one sheet that repeat one formula down their rows, '
|
|
142
142
|
f'computed in one statement. Wide and readable; its {model_name(k)} twin holds the same values as long rows."\n')
|
|
143
|
+
elif hasattr(batch, "render_rows"): # a spill: its one statement, reading earlier cells as all_cells
|
|
144
|
+
body = _escape(batch.render_rows("all_cells"))
|
|
145
|
+
body = body.replace("WITH\n", f"WITH\nall_cells AS (\n{_union(sources_for(k))}\n),\n", 1)
|
|
146
|
+
(batches_dir / f"{model_name(k)}.sql").write_text(body + "\n", encoding="utf-8")
|
|
143
147
|
else:
|
|
144
148
|
(batches_dir / f"{model_name(k)}.sql").write_text(dbt_sql(batch, sources_for(k)) + "\n", encoding="utf-8")
|
|
145
149
|
if k % CHECKPOINT == 0 or k == n:
|
|
@@ -23,8 +23,8 @@ STALE_REASON = ("the lookup table's values changed after the workbook was transl
|
|
|
23
23
|
"out of date: re-run cellproof")
|
|
24
24
|
UNCHECKED = "#UNCHECKED" # nor this: an edge case of a function whose Excel answer was never checked in real Excel
|
|
25
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,
|
|
27
|
-
"been checked against real Excel yet")
|
|
26
|
+
"than 0 or 1, a k that is not a whole number, an error in the range, or INDEX of a whole row or column "
|
|
27
|
+
"outside an array formula) whose Excel answer has not been checked against real Excel yet")
|
|
28
28
|
SETTINGS = {LOCALE: LOCALE_REASON, PLATFORM: PLATFORM_REASON, EARLY1900: EARLY1900_REASON,
|
|
29
29
|
STALE: STALE_REASON, UNCHECKED: UNCHECKED_REASON} # reported as UNRESOLVED
|
|
30
30
|
Type = Literal["num", "txt", "bool", "blank", "err", "any"]
|
|
@@ -286,9 +286,12 @@ def _rng(c, node, sheet: str, skip_subtotals: bool = False) -> Rng:
|
|
|
286
286
|
def _split(c, args, sheet: str, fname: str, skip_subtotals: bool = False) -> tuple[list, list, list]:
|
|
287
287
|
"""The arguments as (ranges, arrays, values). A range arithmetic or an IF over ranges is an array; a
|
|
288
288
|
calculation over plain values stays a value, evaluated before the cells are read (MAX(H3, 1/0) is #DIV/0!)."""
|
|
289
|
+
from cellproof.fn.dynamic import DYNAMIC, as_array
|
|
289
290
|
ranges, arrays, values = [], [], []
|
|
290
291
|
for a in args:
|
|
291
|
-
if isinstance(a,
|
|
292
|
+
if isinstance(a, Call) and a.name in DYNAMIC: # SUM(FILTER(...)): the relation, read like an array
|
|
293
|
+
arrays.append(as_array(c, a, sheet))
|
|
294
|
+
elif isinstance(a, RefNode):
|
|
292
295
|
ranges.append(_rng(c, a, sheet, skip_subtotals))
|
|
293
296
|
elif isinstance(a, Binary) or (isinstance(a, Unary) and a.op == "-") or (
|
|
294
297
|
isinstance(a, Call) and a.name in ("IF", "IFERROR", "IFNA")):
|
|
@@ -363,6 +366,9 @@ def _plain(name, how):
|
|
|
363
366
|
result = how(c, ranges, arrays, values)
|
|
364
367
|
if name not in ("COUNT", "COUNTA", "SUM"): # SUM's error order is already the rule inside _sum
|
|
365
368
|
result = replace(result, err=errs(_errs(c, ranges, arrays, values), result.err))
|
|
369
|
+
markers = [a.unchecked() for a in arrays if hasattr(a, "unchecked")] # FILTER/SORT/UNIQUE: never hidden
|
|
370
|
+
if markers:
|
|
371
|
+
result = replace(result, err=errs(*markers, result.err))
|
|
366
372
|
return result
|
|
367
373
|
register(name)(fn)
|
|
368
374
|
|