Skip to content

Commit 5c40694

Browse files
committed
fix: wrap with ibis.literal() when needed
1 parent 2885fd9 commit 5c40694

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mismo/types/_linked_table.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,19 @@ def chart(self) -> alt.Chart:
384384
else:
385385
subtitle = "eg 'there were 1000 records with 0 links, 500 with 1 link, 100 with 2 links, ...'" # noqa: E501
386386

387-
frac_records = self.n_records / total_records if total_records > 0 else 0
387+
frac_records: ir.StringValue = (
388+
(self.n_records / total_records * 100).cast(int).cast(str)
389+
if total_records > 0
390+
else ibis.literal("0")
391+
)
388392
t = self.mutate(
389393
frac_records=frac_records,
390394
explanation=(
391395
"Out of the "
392396
+ f"{total_records:_} records, "
393397
+ self.n_records.cast(str)
394398
+ " ("
395-
+ (frac_records * 100).cast(int).cast(str)
399+
+ frac_records
396400
+ "%) had "
397401
+ self.n_links.cast(str)
398402
+ " links."

0 commit comments

Comments
 (0)