Skip to content

Commit

Permalink
fix babel tests issue (#2020)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage committed Jun 21, 2024
1 parent 5f75bdc commit 88e2e80
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 88e2e80

Please sign in to comment.