Skip to content

Commit 7c8f675

Browse files
badGarnetclaude
andauthored
fix: rename isolate_tables chunking option to isolate_table (#4355)
Renames the option added in 0.22.30 for naming consistency. Bumps version to 0.22.31 and adds a CHANGELOG entry noting the rename. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Renames the chunking option `isolate_tables` to `isolate_table` for naming consistency with no behavior change. Updates docs/tests/messages and bumps to 0.22.31. - **Migration** - Update calls to `chunk_elements(...)` and `chunk_by_title(...)` to pass `isolate_table=` instead of `isolate_tables=`. - Validation message now references `isolate_table` (e.g., "'skip_table_chunking=True' requires 'isolate_table=True'"). <sup>Written for commit ecdbed1. Summary will update on new commits. <a href="https://cubic.dev/pr/Unstructured-IO/unstructured/pull/4355?utm_source=github">Review in cubic</a></sup> <!-- End of auto-generated description by cubic. --> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 346cfff commit 7c8f675

10 files changed

Lines changed: 46 additions & 40 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.22.31
2+
3+
### Enhancements
4+
5+
- **Rename `isolate_tables` chunking option to `isolate_table`**: the option added in 0.22.30 has been renamed for naming consistency. Callers passing `isolate_tables=` must update to `isolate_table=`.
6+
17
## 0.22.30
28

39
### Enhancements

test_unstructured/chunking/test_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,14 @@ def it_knows_whether_to_skip_table_chunking(self, kwargs: dict[str, Any], expect
130130
@pytest.mark.parametrize(
131131
("kwargs", "expected_value"),
132132
[
133-
({"isolate_tables": True}, True),
134-
({"isolate_tables": False}, False),
135-
({"isolate_tables": None}, True),
133+
({"isolate_table": True}, True),
134+
({"isolate_table": False}, False),
135+
({"isolate_table": None}, True),
136136
({}, True),
137137
],
138138
)
139-
def it_knows_whether_to_isolate_tables(self, kwargs: dict[str, Any], expected_value: bool):
140-
assert ChunkingOptions(**kwargs).isolate_tables is expected_value
139+
def it_knows_whether_to_isolate_table(self, kwargs: dict[str, Any], expected_value: bool):
140+
assert ChunkingOptions(**kwargs).isolate_table is expected_value
141141

142142
@pytest.mark.parametrize(
143143
("skip", "isolate"),
@@ -151,9 +151,9 @@ def it_knows_whether_to_isolate_tables(self, kwargs: dict[str, Any], expected_va
151151
def it_rejects_skip_table_chunking_when_isolation_is_disabled(self, skip: Any, isolate: Any):
152152
with pytest.raises(
153153
ValueError,
154-
match="'skip_table_chunking=True' requires 'isolate_tables=True'",
154+
match="'skip_table_chunking=True' requires 'isolate_table=True'",
155155
):
156-
ChunkingOptions(skip_table_chunking=skip, isolate_tables=isolate)._validate()
156+
ChunkingOptions(skip_table_chunking=skip, isolate_table=isolate)._validate()
157157

158158
@pytest.mark.parametrize("n_chars", [-1, -42])
159159
def it_rejects_new_after_n_chars_for_n_less_than_zero(self, n_chars: int):

test_unstructured/chunking/test_basic.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,19 @@ def it_supports_the_skip_table_chunking_option(
287287
@pytest.mark.parametrize(
288288
("kwargs", "expected_value"),
289289
[
290-
({"isolate_tables": True}, True),
291-
({"isolate_tables": False}, False),
292-
({"isolate_tables": None}, True),
290+
({"isolate_table": True}, True),
291+
({"isolate_table": False}, False),
292+
({"isolate_table": None}, True),
293293
({}, True),
294294
],
295295
)
296-
def it_supports_the_isolate_tables_option(
296+
def it_supports_the_isolate_table_option(
297297
self, kwargs: dict[str, Any], expected_value: bool, _chunk_elements_: Mock
298298
):
299299
chunk_elements([], **kwargs)
300300

301301
_, opts = _chunk_elements_.call_args.args
302-
assert opts.isolate_tables is expected_value
302+
assert opts.isolate_table is expected_value
303303

304304
# -- fixtures --------------------------------------------------------------------------------
305305

test_unstructured/chunking/test_table_isolation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,25 +239,25 @@ def it_never_produces_a_composite_element_that_lists_a_table_in_orig_elements(
239239

240240

241241
class DescribeTableIsolationDisabled:
242-
"""When `isolate_tables=False`, the pre-#4307 behavior is restored."""
242+
"""When `isolate_table=False`, the pre-#4307 behavior is restored."""
243243

244244
def it_lets_a_table_share_a_pre_chunk_with_adjacent_text_when_disabled(self):
245-
opts = ChunkingOptions(max_characters=500, isolate_tables=False)
245+
opts = ChunkingOptions(max_characters=500, isolate_table=False)
246246
builder = PreChunkBuilder(opts=opts)
247247
builder.add_element(Text("Short preamble."))
248248

249249
assert builder.will_fit(Table("Heading\nCell text"))
250250

251251
def it_lets_text_follow_a_table_in_the_same_pre_chunk_when_disabled(self):
252-
opts = ChunkingOptions(max_characters=500, isolate_tables=False)
252+
opts = ChunkingOptions(max_characters=500, isolate_table=False)
253253
builder = PreChunkBuilder(opts=opts)
254254
builder.add_element(Table("Heading\nCell text"))
255255

256256
assert builder.will_fit(Text("Follow-up paragraph."))
257257

258258
def it_combines_a_table_pre_chunk_with_text_neighbors_when_disabled(self):
259259
opts = ChunkingOptions(
260-
max_characters=500, combine_text_under_n_chars=500, isolate_tables=False
260+
max_characters=500, combine_text_under_n_chars=500, isolate_table=False
261261
)
262262
stream = [
263263
PreChunk([Text("Hello world.")], overlap_prefix="", opts=opts),
@@ -284,7 +284,7 @@ def it_wraps_a_table_into_a_composite_element_with_neighbors_when_disabled(self)
284284
chunks = chunk_elements(
285285
elements,
286286
max_characters=500,
287-
isolate_tables=False,
287+
isolate_table=False,
288288
)
289289

290290
assert len(chunks) == 1

test_unstructured/chunking/test_title.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,19 @@ def it_supports_the_skip_table_chunking_option(
612612
@pytest.mark.parametrize(
613613
("kwargs", "expected_value"),
614614
[
615-
({"isolate_tables": True}, True),
616-
({"isolate_tables": False}, False),
617-
({"isolate_tables": None}, True),
615+
({"isolate_table": True}, True),
616+
({"isolate_table": False}, False),
617+
({"isolate_table": None}, True),
618618
({}, True),
619619
],
620620
)
621-
def it_supports_the_isolate_tables_option(
621+
def it_supports_the_isolate_table_option(
622622
self, kwargs: dict[str, Any], expected_value: bool, _chunk_by_title_: Mock
623623
):
624624
chunk_by_title([], **kwargs)
625625

626626
_, opts = _chunk_by_title_.call_args.args
627-
assert opts.isolate_tables is expected_value
627+
assert opts.isolate_table is expected_value
628628

629629
# -- fixtures --------------------------------------------------------------------------------
630630

unstructured/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.22.30" # pragma: no cover
1+
__version__ = "0.22.31" # pragma: no cover

unstructured/chunking/base.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ChunkingOptions:
125125
repeat_table_headers
126126
Default: `True`. When `True`, repeated table-header behavior is enabled for chunked table
127127
continuations. Specify `False` to opt out and preserve legacy table-chunk behavior.
128-
isolate_tables
128+
isolate_table
129129
Default: `True`. When `True`, `Table` and `TableChunk` elements are always staged in
130130
their own pre-chunk and never combined with adjacent non-table elements. Specify
131131
`False` to allow tables to share pre-chunks with adjacent elements (the pre-#4307
@@ -215,14 +215,14 @@ def skip_table_chunking(self) -> bool:
215215
return False if arg_value is None else bool(arg_value)
216216

217217
@cached_property
218-
def isolate_tables(self) -> bool:
218+
def isolate_table(self) -> bool:
219219
"""When True, `Table`/`TableChunk` elements are staged in their own pre-chunk.
220220
221221
Default value is `True`. When `False`, table-family elements are allowed to share a
222222
pre-chunk with adjacent non-table elements (and may be merged by `PreChunkCombiner`),
223223
restoring the pre-#4307 behavior.
224224
"""
225-
arg_value = self._kwargs.get("isolate_tables")
225+
arg_value = self._kwargs.get("isolate_table")
226226
return True if arg_value is None else bool(arg_value)
227227

228228
@cached_property
@@ -366,13 +366,13 @@ def _validate(self) -> None:
366366
if new_after_n_chars is not None and new_after_n_chars < 0:
367367
raise ValueError(f"'new_after_n_chars' argument must be >= 0, got {new_after_n_chars}")
368368

369-
# -- `skip_table_chunking` requires `isolate_tables` because the pass-through path only
369+
# -- `skip_table_chunking` requires `isolate_table` because the pass-through path only
370370
# -- fires when the pre-chunk contains a single `Table` element. With isolation disabled,
371371
# -- tables can fold into `CompositeElement` alongside neighbors and the skip would be
372372
# -- silently ignored, breaking the contract.
373-
if self.skip_table_chunking and not self.isolate_tables:
373+
if self.skip_table_chunking and not self.isolate_table:
374374
raise ValueError(
375-
"'skip_table_chunking=True' requires 'isolate_tables=True' (the default);"
375+
"'skip_table_chunking=True' requires 'isolate_table=True' (the default);"
376376
" tables cannot be passed through unchanged while also sharing a pre-chunk with"
377377
" adjacent elements"
378378
)
@@ -531,7 +531,7 @@ def add_element(self, element: Element) -> None:
531531
"""Add `element` to this section."""
532532
# -- do not prefix a table-only pre-chunk with narrative overlap from the prior chunk --
533533
if (
534-
self._opts.isolate_tables
534+
self._opts.isolate_table
535535
and len(self._elements) == 0
536536
and _element_is_table_family(element)
537537
):
@@ -564,7 +564,7 @@ def flush(self) -> Iterator[PreChunk]:
564564
overlap_for_next = pre_chunk.overlap_tail
565565
# -- table tails must not prefix the following narrative pre-chunk (overlap_all) --
566566
if (
567-
self._opts.isolate_tables
567+
self._opts.isolate_table
568568
and len(elements) == 1
569569
and _element_is_table_family(elements[0])
570570
):
@@ -584,7 +584,7 @@ def will_fit(self, element: Element) -> bool:
584584
- A text-element will not fit when together with the elements already present it would
585585
exceed the hard-max (aka. max_characters/max_tokens).
586586
"""
587-
if self._opts.isolate_tables:
587+
if self._opts.isolate_table:
588588
# -- a `Table` can only start a pre-chunk; it is never appended to a non-empty
589589
# -- pre-chunk --
590590
if _element_is_table_family(element):
@@ -675,7 +675,7 @@ def __eq__(self, other: Any) -> bool:
675675

676676
def can_combine(self, pre_chunk: PreChunk) -> bool:
677677
"""True when `pre_chunk` can be combined with this one without exceeding size limits."""
678-
if self._opts.isolate_tables and _table_isolation_forbids_side_by_side_merge(
678+
if self._opts.isolate_table and _table_isolation_forbids_side_by_side_merge(
679679
self._elements, pre_chunk._elements
680680
):
681681
return False

unstructured/chunking/basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def chunk_elements(
3434
tokenizer: Optional[str] = None,
3535
repeat_table_headers: Optional[bool] = None,
3636
skip_table_chunking: Optional[bool] = None,
37-
isolate_tables: Optional[bool] = None,
37+
isolate_table: Optional[bool] = None,
3838
) -> list[Element]:
3939
"""Combine sequential `elements` into chunks, respecting specified text-length limits.
4040
@@ -85,7 +85,7 @@ def chunk_elements(
8585
skip_table_chunking
8686
Default: `False`. When `True`, `Table` elements are passed through unchanged without
8787
being split into `TableChunk` elements, regardless of their size.
88-
isolate_tables
88+
isolate_table
8989
Default: `True`. When `True`, `Table` and `TableChunk` elements are always staged in
9090
their own pre-chunk and never combined with adjacent non-table elements. Specify
9191
`False` to allow tables to share pre-chunks with adjacent elements (the pre-#4307
@@ -103,7 +103,7 @@ def chunk_elements(
103103
tokenizer=tokenizer,
104104
repeat_table_headers=repeat_table_headers,
105105
skip_table_chunking=skip_table_chunking,
106-
isolate_tables=isolate_tables,
106+
isolate_table=isolate_table,
107107
)
108108

109109
return _chunk_elements(elements, opts)

unstructured/chunking/dispatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def add_chunking_strategy(func: Callable[_P, list[Element]]) -> Callable[_P, lis
7474
+ "\n\t\tskip_table_chunking"
7575
+ "\n\t\t\tDefault: False. When True, Table elements are passed through"
7676
+ "\n\t\t\tunchanged without being split into TableChunk elements."
77-
+ "\n\t\tisolate_tables"
77+
+ "\n\t\tisolate_table"
7878
+ "\n\t\t\tDefault: True. When True, Table/TableChunk elements are always"
7979
+ "\n\t\t\tstaged in their own pre-chunk. Set to False to allow tables to"
8080
+ "\n\t\t\tshare pre-chunks with adjacent non-table elements."

unstructured/chunking/title.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def chunk_by_title(
3535
tokenizer: Optional[str] = None,
3636
repeat_table_headers: Optional[bool] = None,
3737
skip_table_chunking: Optional[bool] = None,
38-
isolate_tables: Optional[bool] = None,
38+
isolate_table: Optional[bool] = None,
3939
) -> list[Element]:
4040
"""Uses title elements to identify sections within the document for chunking.
4141
@@ -92,7 +92,7 @@ def chunk_by_title(
9292
skip_table_chunking
9393
Default: `False`. When `True`, `Table` elements are passed through unchanged without
9494
being split into `TableChunk` elements, regardless of their size.
95-
isolate_tables
95+
isolate_table
9696
Default: `True`. When `True`, `Table` and `TableChunk` elements are always staged in
9797
their own pre-chunk and never combined with adjacent non-table elements. Specify
9898
`False` to allow tables to share pre-chunks with adjacent elements (the pre-#4307
@@ -111,7 +111,7 @@ def chunk_by_title(
111111
tokenizer=tokenizer,
112112
repeat_table_headers=repeat_table_headers,
113113
skip_table_chunking=skip_table_chunking,
114-
isolate_tables=isolate_tables,
114+
isolate_table=isolate_table,
115115
)
116116
return _chunk_by_title(elements, opts)
117117

0 commit comments

Comments
 (0)