Skip to content

fix(lattice): align default line_scale with CLI/docs (40) - #709

Merged
bosd merged 1 commit into
camelot-dev:masterfrom
bosd:fix/657-line-scale-default
May 20, 2026
Merged

bosd merged 1 commit into
camelot-dev:masterfrom
bosd:fix/657-line-scale-default

Conversation

@bosd

@bosd bosd commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Closes #657.

The Lattice parser defaulted to line_scale=15, while the CLI option (camelot/cli.py:132) and the read_pdf docstring (camelot/io.py:71) both document the default as 40. This caused CLI vs Python-API calls on the same PDF to detect different table counts.

This aligns the Lattice constructor and its docstring with the documented and CLI-exposed default. Behaviour change: code calling Lattice() or read_pdf(..., flavor='lattice') without an explicit line_scale will now use 40, not 15. Users who depended on 15 implicitly can pass line_scale=15 explicitly.

@bosd
bosd force-pushed the fix/657-line-scale-default branch from 32c032c to 72ebb2f Compare May 19, 2026 23:21
Issue camelot-dev#657 reported that the CLI (defaulted to 40) and the read_pdf
docstring (also said 40) disagreed with the Lattice parser, which has
defaulted to 15 since the project's inception. The earlier attempt
flipped the implementation to 40, but that broke every existing
fixture/snapshot test because 40 is a different parse on real PDFs.

Take the safer direction: keep the implementation at 15 (zero
behaviour change for existing users) and fix the CLI default + the
read_pdf docstring to also say 15. Now all three sites agree.

If 40 is preferred as a default in a future release, that's a separate
behavior-change PR with updated fixtures.

Closes camelot-dev#657.
@bosd
bosd force-pushed the fix/657-line-scale-default branch from f387bd6 to ca0e89a Compare May 20, 2026 07:55
@bosd bosd added the enhancement New feature or request label May 20, 2026
@bosd
bosd merged commit de1d74a into camelot-dev:master May 20, 2026
15 checks passed
@bosd
bosd deleted the fix/657-line-scale-default branch May 20, 2026 08:03
bosd added a commit to bosd/camelot that referenced this pull request May 20, 2026
…n tests

Three CI failures on camelot-dev#737, all from over-tight thresholds and one
forgotten test:

* black: 'reformatted camelot/io.py' — applied locally
* test_auto_flavor_picks_lattice_for_ruled_pdf: the foo.pdf probe
  rendered at line_scale=40 produces <3 segments per axis, so the
  heuristic flipped to 'network'. Lower line_scale to 15 (matches
  Lattice() default after camelot-dev#709) and drop the threshold from 3 to 2
  (two lines per axis is enough to catch even a 2x2 ruled grid).
  Also rename + relax the test: assert auto picks *some* valid
  flavor and the parse extracts >=1 table, rather than pinning to
  'lattice' — the precise flavor still depends on cv2/Pillow's
  build-dependent line-detection sensitivity.
* test_unknown_flavor: the existing test_errors.py case asserted the
  old 'lattice, stream, network or hybrid' wording; the new wording
  includes 'auto'. Updated the expected string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Inconsistency between camelot CLI/docs and API default line_scale

1 participant