Skip to content

Commit

Permalink
Fixed bug in aastex.Figure() where the label was being placed befor…
Browse files Browse the repository at this point in the history
…e the caption.
  • Loading branch information
byrdie committed Jun 5, 2024
1 parent d39dd6f commit be305db
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions aastex/_aastex.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,18 @@ def __init__(
position=position,
**kwargs,
)
if isinstance(label, Label):
self._label = label
else:
self.label = label

@property
def _label(self) -> Label:
label = self.label
if not isinstance(label, Label):
if ":" in label:
label = label.split(":", 1)
self._label = Label(Marker(label[1], label[0]))
label = Label(Marker(label[1], label[0]))
else:
self._label = Label(Marker(label, self.marker_prefix))

self.append(self._label)
label = Label(Marker(label, self.marker_prefix))
return label

def __format__(self, format_spec):
return Ref(self._label.marker).dumps()
Expand Down Expand Up @@ -346,6 +348,10 @@ def add_fig(

self.add_image(filename, **add_image_kwargs)

def add_caption(self, caption) -> None:
super().add_caption(caption)
self.append(self._label)

Check warning on line 353 in aastex/_aastex.py

View check run for this annotation

Codecov / codecov/patch

aastex/_aastex.py#L352-L353

Added lines #L352 - L353 were not covered by tests


class FigureStar(
Figure,
Expand Down

0 comments on commit be305db

Please sign in to comment.