Skip to content

Commit

Permalink
Implement the configuration for AISTATS 2025 and capture errors in bu…
Browse files Browse the repository at this point in the history
…ndles.* (#153)

* Autoupdate the pre-commit hook

* Implement the AISTATS 2025 style

* Implememt a test to catch unexpected 'column' arguments

* Apply the new column-arg-test to the remaining multicol templates

* Implement the multicol test-case via tags to enable reusing them for tex-or-not tests

* Apply the usetex-test to all other tex-or-not bundles
  • Loading branch information
pnkraemer authored Sep 24, 2024
1 parent b9df9e0 commit 2ca9ced
Show file tree
Hide file tree
Showing 10 changed files with 209 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
# exclude autogenerated files
exclude: /README\.rst$|\.pot?$
- repo: https://github.com/psf/black
rev: 24.4.0
rev: 24.8.0
hooks:
- id: black
language_version: python3
Expand All @@ -39,7 +39,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.8.5
rev: 1.8.7
hooks:
- id: nbqa-black
additional_dependencies: [black==22.8.0]
Expand Down
96 changes: 96 additions & 0 deletions tests/test_bundles_error_handling.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
"""Test that the functions in tueplots.bundles raise good errors when misused."""

import pytest
import pytest_cases

from tueplots import bundles


@pytest_cases.case(tags=["multicol", "tex_or_not"])
def case_bundle_cvpr2024():
return bundles.cvpr2024


@pytest_cases.case(tags=["multicol", "tex_or_not"])
def case_bundle_icml2022():
return bundles.icml2022


@pytest_cases.case(tags=["multicol", "tex_or_not"])
def case_bundle_icml2024():
return bundles.icml2024


@pytest_cases.case(tags=["multicol"])
def case_bundle_aistats2022():
return bundles.aistats2022


@pytest_cases.case(tags=["multicol"])
def case_bundle_aistats2023():
return bundles.aistats2023


@pytest_cases.case(tags=["multicol"])
def case_bundle_aistats2025():
return bundles.aistats2025


@pytest_cases.case(tags=["multicol"])
def case_bundle_aaai2024():
return bundles.aaai2024


@pytest_cases.case(tags=["multicol"])
def case_bundle_uai2024():
return bundles.uai2023


@pytest_cases.case(tags=["tex_or_not"])
def case_bundle_neurips2021():
return bundles.neurips2021


@pytest_cases.case(tags=["tex_or_not"])
def case_bundle_neurips2022():
return bundles.neurips2022


@pytest_cases.case(tags=["tex_or_not"])
def case_bundle_neurips2023():
return bundles.neurips2023


@pytest_cases.case(tags=["tex_or_not"])
def case_bundle_neurips2024():
return bundles.neurips2024


@pytest_cases.case(tags=["tex_or_not"])
def case_bundle_iclr2023():
return bundles.iclr2023


@pytest_cases.case(tags=["tex_or_not"])
def case_bundle_iclr2024():
return bundles.iclr2024


@pytest_cases.parametrize_with_cases("bundle_fun", cases=".", has_tag=["multicol"])
def test_column_neither_half_nor_full_raises_value_error(bundle_fun):
# Sanity checks
_ = bundle_fun(column="half")
_ = bundle_fun(column="full")

with pytest.raises(ValueError, match="expected"):
_ = bundle_fun(column="anything-but-half")


@pytest_cases.parametrize_with_cases("bundle_fun", cases=".", has_tag=["tex_or_not"])
def test_usetex_must_be_bool_otherwise_type_error(bundle_fun):
# Sanity checks
_ = bundle_fun(usetex=True)
_ = bundle_fun(usetex=False)

with pytest.raises(ValueError, match="expected"):
_ = bundle_fun(usetex=2)
5 changes: 5 additions & 0 deletions tests/test_rc_params_cases/case_bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ def case_bundles_aistats2023(column):
return bundles.aistats2023(column=column, nrows=2, ncols=2, family="serif")


@pytest_cases.parametrize(column=["full", "half"])
def case_bundles_aistats2025(column):
return bundles.aistats2025(column=column, nrows=2, ncols=2, family="serif")


@pytest_cases.parametrize(usetex=[True, False])
def case_bundles_neurips2021(usetex):
return bundles.neurips2021(usetex=usetex, nrows=2, ncols=2, family="serif")
Expand Down
8 changes: 8 additions & 0 deletions tests/test_rc_params_cases/case_figsizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def case_figsizes_aistats2023_half():
return figsizes.aistats2023_half(nrows=2, ncols=3, height_to_width_ratio=1.0)


def case_figsizes_aistats2025_full():
return figsizes.aistats2025_full(nrows=2, ncols=3, height_to_width_ratio=1.0)


def case_figsizes_aistats2025_half():
return figsizes.aistats2025_half(nrows=2, ncols=3, height_to_width_ratio=1.0)


def case_figsizes_cvpr2022_half():
return figsizes.cvpr2022_half(nrows=2, ncols=3, height_to_width_ratio=1.0)

Expand Down
8 changes: 8 additions & 0 deletions tests/test_rc_params_cases/case_fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def case_fonts_aistats2023_tex_default():
return fonts.aistats2023_tex()


def case_fonts_aistats2025_tex_default():
return fonts.aistats2025_tex()


def case_fonts_aistats2022_tex_custom():
return fonts.aistats2022_tex(family="serif")

Expand All @@ -171,6 +175,10 @@ def case_fonts_aistats2023_tex_custom():
return fonts.aistats2023_tex(family="serif")


def case_fonts_aistats2025_tex_custom():
return fonts.aistats2025_tex(family="serif")


def case_fonts_cvpr2024_default():
return fonts.cvpr2024()

Expand Down
4 changes: 4 additions & 0 deletions tests/test_rc_params_cases/case_fontsizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def case_fontsizes_aistats2023():
return fontsizes.aistats2023()


def case_fontsizes_aistats2025():
return fontsizes.aistats2025()


def case_fontsizes_aaai2024():
return fontsizes.aaai2024()

Expand Down
65 changes: 65 additions & 0 deletions tueplots/bundles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ def cvpr2024(*, column="half", nrows=1, ncols=1, usetex=True, family="serif"):
size = figsizes.cvpr2024_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.cvpr2024_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
if usetex is True:
font_config = fonts.cvpr2024_tex(family=family)
elif usetex is False:
font_config = fonts.cvpr2024(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
fontsize_config = fontsizes.cvpr2024()
return {**font_config, **size, **fontsize_config}

Expand All @@ -24,10 +29,15 @@ def icml2022(*, column="half", nrows=1, ncols=1, usetex=True, family="serif"):
size = figsizes.icml2022_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.icml2022_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
if usetex is True:
font_config = fonts.icml2022_tex(family=family)
elif usetex is False:
font_config = fonts.icml2022(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
fontsize_config = fontsizes.icml2022()
return {**font_config, **size, **fontsize_config}

Expand All @@ -38,10 +48,15 @@ def icml2024(*, column="half", nrows=1, ncols=1, usetex=True, family="serif"):
size = figsizes.icml2024_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.icml2024_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
if usetex is True:
font_config = fonts.icml2024_tex(family=family)
elif usetex is False:
font_config = fonts.icml2024(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
fontsize_config = fontsizes.icml2024()
return {**font_config, **size, **fontsize_config}

Expand All @@ -52,6 +67,9 @@ def aistats2022(*, column="half", nrows=1, ncols=1, family="serif"):
size = figsizes.aistats2022_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.aistats2022_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
font_config = fonts.aistats2022_tex(family=family)
fontsize_config = fontsizes.aistats2022()
return {**font_config, **size, **fontsize_config}
Expand All @@ -63,11 +81,28 @@ def aistats2023(*, column="half", nrows=1, ncols=1, family="serif"):
size = figsizes.aistats2023_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.aistats2023_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
font_config = fonts.aistats2023_tex(family=family)
fontsize_config = fontsizes.aistats2023()
return {**font_config, **size, **fontsize_config}


def aistats2025(*, column="half", nrows=1, ncols=1, family="serif"):
"""AISTATS 2025 bundle."""
if column == "half":
size = figsizes.aistats2025_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.aistats2025_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
font_config = fonts.aistats2025_tex(family=family)
fontsize_config = fontsizes.aistats2025()
return {**font_config, **size, **fontsize_config}


def aaai2024(*, column="half", nrows=1, ncols=1, family="serif", rel_width=1.0):
"""AAAI 2024 bundle.
Expand All @@ -77,6 +112,9 @@ def aaai2024(*, column="half", nrows=1, ncols=1, family="serif", rel_width=1.0):
size = figsizes.aaai2024_half(nrows=nrows, ncols=ncols, rel_width=rel_width)
elif column == "full":
size = figsizes.aaai2024_full(nrows=nrows, ncols=ncols, rel_width=rel_width)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
font_config = fonts.aaai2024_tex(family=family)
fontsize_config = fontsizes.aaai2024()
return {**font_config, **size, **fontsize_config}
Expand All @@ -88,6 +126,9 @@ def uai2023(*, column="half", nrows=1, ncols=1, family="serif"):
size = figsizes.uai2023_half(nrows=nrows, ncols=ncols)
elif column == "full":
size = figsizes.uai2023_full(nrows=nrows, ncols=ncols)
else:
msg = _msg_error_wrong_arg_column(column)
raise ValueError(msg)
font_config = fonts.uai2023_tex(family=family)
fontsize_config = fontsizes.uai2023()
return {**font_config, **size, **fontsize_config}
Expand Down Expand Up @@ -123,6 +164,8 @@ def neurips2021(*, usetex=True, rel_width=1.0, nrows=1, ncols=1, family="serif")
font_config = fonts.neurips2021_tex(family=family)
elif usetex is False:
font_config = fonts.neurips2021(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
size = figsizes.neurips2021(rel_width=rel_width, nrows=nrows, ncols=ncols)
fontsize_config = fontsizes.neurips2021()
return {**font_config, **size, **fontsize_config}
Expand All @@ -134,6 +177,8 @@ def neurips2022(*, usetex=True, rel_width=1.0, nrows=1, ncols=1, family="serif")
font_config = fonts.neurips2022_tex(family=family)
elif usetex is False:
font_config = fonts.neurips2022(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
size = figsizes.neurips2022(rel_width=rel_width, nrows=nrows, ncols=ncols)
fontsize_config = fontsizes.neurips2022()
return {**font_config, **size, **fontsize_config}
Expand All @@ -145,6 +190,8 @@ def neurips2023(*, usetex=True, rel_width=1.0, nrows=1, ncols=1, family="serif")
font_config = fonts.neurips2023_tex(family=family)
elif usetex is False:
font_config = fonts.neurips2023(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
size = figsizes.neurips2023(rel_width=rel_width, nrows=nrows, ncols=ncols)
fontsize_config = fontsizes.neurips2023()
return {**font_config, **size, **fontsize_config}
Expand All @@ -156,6 +203,8 @@ def neurips2024(*, usetex=True, rel_width=1.0, nrows=1, ncols=1, family="serif")
font_config = fonts.neurips2024_tex(family=family)
elif usetex is False:
font_config = fonts.neurips2024(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
size = figsizes.neurips2024(rel_width=rel_width, nrows=nrows, ncols=ncols)
fontsize_config = fontsizes.neurips2024()
return {**font_config, **size, **fontsize_config}
Expand All @@ -167,6 +216,8 @@ def iclr2023(*, usetex=True, rel_width=1.0, nrows=1, ncols=1, family="serif"):
font_config = fonts.iclr2023_tex(family=family)
elif usetex is False:
font_config = fonts.iclr2023(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
size = figsizes.iclr2023(rel_width=rel_width, nrows=nrows, ncols=ncols)
fontsize_config = fontsizes.iclr2023()
return {**font_config, **size, **fontsize_config}
Expand All @@ -178,11 +229,25 @@ def iclr2024(*, usetex=True, rel_width=1.0, nrows=1, ncols=1, family="serif"):
font_config = fonts.iclr2024_tex(family=family)
elif usetex is False:
font_config = fonts.iclr2024(family=family)
else:
raise ValueError(_msg_error_wrong_arg_usetex(usetex))
size = figsizes.iclr2024(rel_width=rel_width, nrows=nrows, ncols=ncols)
fontsize_config = fontsizes.iclr2024()
return {**font_config, **size, **fontsize_config}


def _msg_error_wrong_arg_usetex(usetex):
msg = f"Argument usetex={usetex} unknown."
msg += "Either usetex=True or usetex=False expected."
return msg


def _msg_error_wrong_arg_column(column):
msg = f"Argument column={column} unknown."
msg += "Either column='half' or column='full' expected."
return msg


def beamer_moml(
*,
rel_width=1.0,
Expand Down
10 changes: 10 additions & 0 deletions tueplots/figsizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ def aistats2023_full(**kwargs):
return _icml_and_aistats_common_full(**kwargs)


def aistats2025_half(**kwargs):
"""Double-column (half-width) figures for AISTATS 2025."""
return _icml_and_aistats_common_half(**kwargs)


def aistats2025_full(**kwargs):
"""Single-column (full-width) figures for AISTATS 2025."""
return _icml_and_aistats_common_full(**kwargs)


def _icml_and_aistats_common_half(
*,
nrows=1,
Expand Down
7 changes: 6 additions & 1 deletion tueplots/fonts.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ def aistats2022_tex(*, family="serif"):

def aistats2023_tex(*, family="serif"):
"""Fonts for AISTATS 2023. LaTeX version."""
return _times_tex_via_pkg_times(family=family)
return _computer_modern_tex(family=family)


def aistats2025_tex(*, family="serif"):
"""Fonts for AISTATS 2025. LaTeX version."""
return _computer_modern_tex(family=family)


def uai2023_tex(*, family="serif"):
Expand Down
5 changes: 5 additions & 0 deletions tueplots/fontsizes.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def aistats2023(*, default_smaller=1):
return _from_base(base=10 - default_smaller)


def aistats2025(*, default_smaller=1):
"""Font size for AISTATS 2025."""
return _from_base(base=10 - default_smaller)


def aaai2024(*, default_smaller=1):
"""Font size for AAAI 2024."""
return _from_base(base=10 - default_smaller)
Expand Down

0 comments on commit 2ca9ced

Please sign in to comment.