-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Two issues from the changes made in #128
Running ruff check:
F841 Local variable `cell_count` is assigned to but never used
--> tests/test_encoding_engine.py:210:9
|
208 | # Each data row should have 2 cells, not 3
209 | cell_pattern = r"\\cell"
210 | cell_count = result.count(cell_pattern)
| ^^^^^^^^^^
211 |
212 | # We have 4 data rows + headers, so we expect cells for 2 columns
|
help: Remove assignment to unused variable `cell_count`
Running mkdocs serve or sh scripts/check_rtf.sh:
advanced-group-by-group-newpage.rtf
WARNING - markdown_exec: Execution of python code block exited with errors
Code block is:
# Create treatment-separated document with group_by within each page
# Filter data to have multiple treatment groups
ae_with_treatments = (
ae_t1.filter(pl.col("TRTA").is_in(["Placebo", "Xanomeline High Dose"]))
.select(["TRTA", "USUBJID", "ASTDY", "AEDECD1", "AESEV"])
.head(40)
.sort(["TRTA", "USUBJID", "ASTDY"])
)
doc_treatment_separated = rtf.RTFDocument(
df=ae_with_treatments,
rtf_title=rtf.RTFTitle(
text=[
"Adverse Events Listing",
"Example 5: group_by + new_page (Treatment Separation)",
],
text_convert=False,
),
rtf_column_header=rtf.RTFColumnHeader(
text=["Treatment", "Subject ID", "Study Day", "Adverse Event",
"Severity"],
text_format="b",
text_justification=["l", "l", "c", "l", "c"],
),
rtf_body=rtf.RTFBody(
page_by=["TRTA"], # Separate pages by treatment
new_page=True, # Force new page for each treatment
group_by=[
"TRTA",
"USUBJID",
"ASTDY",
], # Suppress duplicates within each treatment page
col_rel_width=[2, 3, 1, 4, 2],
text_justification=["l", "l", "c", "l", "c"],
pageby_header=True, # Repeat headers on each treatment page
),
rtf_footnote=rtf.RTFFootnote(
text=[
"Example of group_by + new_page combination:",
"- Each treatment group gets its own page(s) (new_page=True)",
"- Within each treatment, USUBJID and ASTDY are suppressed when
duplicate (group_by)",
"- Headers are repeated on each treatment page
(pageby_header=True)",
],
text_convert=False,
),
)
# Generate the RTF file
doc_treatment_separated.write_rtf("advanced-group-by-group-newpage.rtf")
Output is:
Traceback (most recent call last):
File
"/Users/nanx/rtflite/.venv/lib/python3.14/site-packages/markdown_exec/_internal/formatters/python.py",
line 71, in _run_python
exec_python(code, code_block_id, exec_globals)
~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File
"/Users/nanx/rtflite/.venv/lib/python3.14/site-packages/markdown_exec/_internal/formatters/_exec_python.py",
line 8, in exec_python
exec(compiled, exec_globals) # noqa: S102
~~~~^^^^^^^^^^^^^^^^^^^^^^^^
File "<code block: session default; n9>", line 48, in <module>
doc_treatment_separated.write_rtf("advanced-group-by-group-newpage.rtf")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/nanx/rtflite/src/rtflite/encode.py", line 438, in write_rtf
rtf_code = self.rtf_encode()
File "/Users/nanx/rtflite/src/rtflite/encode.py", line 415, in rtf_encode
return engine.encode_document(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/Users/nanx/rtflite/src/rtflite/encoding/engine.py", line 36, in
encode_document
return strategy.encode(document)
~~~~~~~~~~~~~~~^^^^^^^^^^
File "/Users/nanx/rtflite/src/rtflite/encoding/strategies.py", line 790, in
encode
suppressed_df = grouping_service.enhance_group_by(full_df, group_by_param)
File "/Users/nanx/rtflite/src/rtflite/services/grouping_service.py", line
44, in enhance_group_by
raise ValueError(f"group_by columns not found in DataFrame:
{missing_cols}")
ValueError: group_by columns not found in DataFrame: ['TRTA']
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working