Skip to content

Commit 8497291

Browse files
committed
Update the _transform_test_units() util fn
1 parent 4e430b3 commit 8497291

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pointblank/validate.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13850,19 +13850,30 @@ def _format_single_number_with_gt(
1385013850

1385113851

1385213852
def _transform_test_units(
13853-
test_units: list[int], interrogation_performed: bool, active: list[bool], locale: str
13853+
test_units: list[int],
13854+
interrogation_performed: bool,
13855+
active: list[bool],
13856+
locale: str,
13857+
df_lib=None,
1385413858
) -> list[str]:
1385513859
# If no interrogation was performed, return a list of empty strings
1385613860
if not interrogation_performed:
1385713861
return ["" for _ in range(len(test_units))]
1385813862

13863+
# Define the helper function that'll format numbers safely with Great Tables
13864+
def _format_number_safe(value: int) -> str:
13865+
if df_lib is not None:
13866+
# Use GT-based formatting to avoid Pandas dependency completely
13867+
return _format_single_number_with_gt(
13868+
value, n_sigfig=3, compact=True, locale=locale, df_lib=df_lib
13869+
)
13870+
else:
13871+
# Fallback to the original behavior
13872+
return str(vals.fmt_number(value, n_sigfig=3, compact=True, locale=locale)[0])
13873+
1385913874
return [
1386013875
(
13861-
(
13862-
str(test_units[i])
13863-
if test_units[i] < 10000
13864-
else str(vals.fmt_number(test_units[i], n_sigfig=3, compact=True, locale=locale)[0])
13865-
)
13876+
(str(test_units[i]) if test_units[i] < 10000 else _format_number_safe(test_units[i]))
1386613877
if active[i]
1386713878
else "&mdash;"
1386813879
)

0 commit comments

Comments
 (0)