Skip to content

Commit 83cad90

Browse files
committed
fix: replace int() with float() in typst template
1 parent 0a649dc commit 83cad90

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- `Plot.plot()` performance should now be equivalent to the one of a generator object
44
- New shortcut syntax `Plot.line(...).plot()` is now available (#18, thanks @harrylojames)
5+
- Bugfix: typst error with certain decimal padding values.
56

67
## pyobsplot 0.5.0
78

src/pyobsplot/static/template.typ

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
spacing: .2em,
4242
image.decode(
4343
encode-xml(elem.children.first()),
44-
width: 1in * int(elem.children.first().attrs.width) / dpi,
45-
height: 1in * int(elem.children.first().attrs.width) /dpi
44+
width: 1in * float(elem.children.first().attrs.width) / dpi,
45+
height: 1in * float(elem.children.first().attrs.width) /dpi
4646
),
4747
text(elem.children.last(), size: 1in * 10/dpi)
4848
)
@@ -68,11 +68,11 @@
6868
let legends = figuresvgs
6969
.filter(svg => "ramp" in svg.attrs.class)
7070
.map(svg => (..svg, attrs: (..svg.attrs,
71-
width: str(int(svg.attrs.width) + 2*legend-padding),
72-
viewbox: "-"+str(legend-padding)+" 0 "+str(int(svg.attrs.width)+legend-padding)+" "+str(int(svg.attrs.height)))
71+
width: str(float(svg.attrs.width) + 2*legend-padding),
72+
viewbox: "-"+str(legend-padding)+" 0 "+str(float(svg.attrs.width)+legend-padding)+" "+str(float(svg.attrs.height)))
7373
))
7474
let mainfigure = figuresvgs.find(svg => "ramp" not in svg.attrs.class)
75-
let figurewidth = calc.max(..figuresvgs.map(svg => int(svg.attrs.width)))
75+
let figurewidth = calc.max(..figuresvgs.map(svg => float(svg.attrs.width)))
7676

7777
set page(
7878
width: 1in*figurewidth/dpi + 2*margin,
@@ -96,8 +96,8 @@
9696
v(1in * 8/dpi)
9797
},
9898
..figure.children.filter(e => e.tag == "div").map(swatch),
99-
..legends.map(svg => image.decode(encode-xml(svg), height: 1in * int(svg.attrs.height) / dpi)),
100-
image.decode(encode-xml(mainfigure), height: 1in * int(mainfigure.attrs.height) / dpi),
99+
..legends.map(svg => image.decode(encode-xml(svg), height: 1in * float(svg.attrs.height) / dpi)),
100+
image.decode(encode-xml(mainfigure), height: 1in * float(mainfigure.attrs.height) / dpi),
101101
if (caption != none) {
102102
set text(size: 1in * 13/dpi, fill: rgb(caption_color), weight: 500)
103103
text(caption.children.first())

0 commit comments

Comments
 (0)