8000 refactor: remove debug print statements from DataFrameHtmlFormatter a… · kosiew/datafusion-python@9495e90 · GitHub 10000
[go: up one dir, main page]

Skip to content

Commit 9495e90

Browse files
committed
refactor: remove debug print statements from DataFrameHtmlFormatter and add HTML formatter integration tests
- Removed debug print statements from format_html, _build_table_body, and get_formatter methods in DataFrameHtmlFormatter to clean up the code. - Introduced a new debug_utils.py file containing a function to check HTML formatter integration. - Updated __init__.py to include configure_formatter for easier access. - Enhanced DataFrame class to include a docstring for _repr_html_ method. - Added comprehensive tests for HTML formatter configuration, custom style providers, type formatters, and cell/header builders in test_dataframe.py.
1 parent 9012239 commit 9495e90

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

python/datafusion/html_formatter.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ def format_html(
141141
Returns:
142142
HTML string representation of the data
143143
"""
144-
print("DEBUG format_html: Called with batches:", len(batches) if batches else 0)
145-
print(
146-
f"DEBUG format_html: Type formatters registered: {len(self._type_formatters)}"
147-
)
148-
print(
149-
f"DEBUG format_html: Has custom cell builder: {self._custom_cell_builder is not None}"
150-
)
151-
152144
if not batches:
153145
return "No data to display"
154146

@@ -224,25 +216,16 @@ def _build_table_body(self, batches: list, table_uuid: str) -> List[str]:
224216
for col_idx, column in enumerate(batch.columns):
225217
# Get the raw value from the column
226218
raw_value = self._get_cell_value(column, row_idx)
227-
print(
228-
f"DEBUG row {row_count}, col {col_idx}: raw_value = {raw_value} ({type(raw_value).__name__})"
229-
)
230219

231220
# Always check for type formatters first to format the value
232221
formatted_value = self._format_cell_value(raw_value)
233-
print(
234-
f"DEBUG row {row_count}, col {col_idx}: formatted_value = {formatted_value}"
235-
)
236222

237223
# Then apply either custom cell builder or standard cell formatting
238224
if self._custom_cell_builder:
239225
# Pass both the raw value and formatted value to let the builder decide
240226
cell_html = self._custom_cell_builder(
241227
raw_value, row_count, col_idx, table_uuid
242228
)
243-
print(
244-
f"DEBUG custom cell builder returned: {cell_html[:50]}..."
245-
)
246229
html.append(cell_html)
247230
else:
248231
# Standard cell formatting with formatted value
@@ -302,9 +285,7 @@ def _format_cell_value(self, value: Any) -> str:
302285
# Check for custom type formatters
303286
for type_cls, formatter in self._type_formatters.items():
304287
if isinstance(value, type_cls):
305-
print(f"DEBUG formatter match for {type_cls.__name__}: {value}")
306288
result = formatter(value)
307-
print(f"DEBUG formatter returned: {result}")
308289
return result
309290

310291
# If no formatter matched, return string representation
@@ -415,10 +396,6 @@ def get_formatter() -> DataFrameHtmlFormatter:
415396
Returns:
416397
The global HTML formatter instance
417398
"""
418-
print(f"DEBUG get_formatter: returning instance id={id(_default_formatter)}")
419-
print(
420-
f"DEBUG get_formatter: type formatters: {len(_default_formatter._type_formatters)}"
421-
)
422399
return _default_formatter
423400

424401

0 commit comments

Comments
 (0)
0