Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ jobs:
numpy: "numpy"
uncertainties: "uncertainties"
extras: "sparse xarray netCDF4 dask[complete]==2024.5.1 graphviz babel==2.8 mip>=1.13"
- python-version: "3.10"
numpy: "numpy==1.26.1"
uncertainties: null
extras: "babel==2.15 matplotlib==3.9.0"
runs-on: ubuntu-latest

env:
Expand Down
10 changes: 9 additions & 1 deletion pint/delegates/formatter/_compound_unit_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,19 @@ def localize_per(
locale = babel_parse(locale)

patterns = locale._data["compound_unit_patterns"].get("per", None)
if patterns is None:
return default or "{}/{}"

patterns = patterns.get(length, None)
if patterns is None:
return default or "{}/{}"

return patterns.get(length, default or "{}/{}")
# babel 2.8
if isinstance(patterns, str):
return patterns

# babe; 2.15
return patterns.get("compound", default or "{}/{}")


@functools.lru_cache
Expand Down