add pretty formatting for units

Open
#297 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start with the Pint Unit formatting examples in the issue, including the ~P format and the proposed Pcf formatter. Determine the desired pretty-string behavior for units such as degrees_east and degrees, then document what output would count as done.

Written by the indexing model from the issue text.

Description

Continuing from https://github.com/xarray-contrib/cf-xarray/pull/284#issuecomment-1018130308 (cc @keewis)

I see pint has a "pretty" formatting mode. Is there a way we can define the "pretty" string?

u = units.Unit("degrees_east")
f"{u:~P}"
degrees_east

EDIT: I see even pint doesn't do the pretty ° for "degrees"

u = units.Unit("degrees")
f"{u:P}"
degree

EDIT2: Should we define a Pcf formatter for our own pretty strings?

Dominant language
Python
Stars
181
Forks
49
Avg merge
43m
Merged PRs (30d)
1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from xarray-contrib/cf-xarray

All issues in xarray-contrib/cf-xarray

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.