Skip to content

Commit 6cdab46

Browse files
authored
extend the readme (#81)
* add more to the readme * fix a link * move the code style after the link to the docs * move the code style between pypi and conda-forge badge * use the readme as long description (to be used on PyPI) * require at least python 3.7 * don't duplicate the long description * see if upgrading works [skip-ci]
1 parent fe61406 commit 6cdab46

File tree

3 files changed

+67
-5
lines changed

3 files changed

+67
-5
lines changed

.github/workflows/ci-additional.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
${{ runner.os }}-pip-py3.8-
3030
- name: upgrade pip
3131
run: |
32-
python -m pip install --upgrade pip
32+
python -m pip install --upgrade pip setuptools wheel
3333
- name: install dependencies
3434
run: |
3535
python -m pip install -r ci/requirements.txt

README.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,65 @@
1+
[![CI](https://github.com/xarray-contrib/pint-xarray/workflows/CI/badge.svg?branch=master)](https://github.com/xarray-contrib/pint-xarray/actions?query=branch%3Amaster)
2+
[![code coverage](https://codecov.io/gh/xarray-contrib/pint-xarray/branch/master/graph/badge.svg)](https://codecov.io/gh/xarray-contrib/pint-xarray)
3+
[![docs](https://readthedocs.org/projects/pint-xarray/badge/?version=latest)](https://pint-xarray.readthedocs.io)
4+
[![PyPI version](https://img.shields.io/pypi/v/pint-xarray.svg)](https://pypi.org/project/pint-xarray)
5+
[![codestyle](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
6+
[![conda-forge](https://img.shields.io/conda/vn/conda-forge/pint-xarray)](https://github.com/conda-forge/pint-xarray-feedstock)
7+
18
# pint-xarray
2-
Interface for using pint in xarray, providing convenience accessors, as [envisioned here](https://github.com/hgrecco/pint/issues/849).
9+
10+
A convenience wrapper for using [pint](https://pint.readthedocs.io) with
11+
[xarray](https://xarray.pydata.org).
12+
13+
## Usage
14+
15+
To convert the variables of a `Dataset` to quantities:
16+
```python
17+
In [1]: import pint_xarray
18+
...: import xarray as xr
19+
20+
In [2]: ds = xr.Dataset({"a": ("x", [0, 1, 2]), "b": ("y", [-3, 5, 1], {"units": "m"})})
21+
...: ds
22+
Out[2]:
23+
<xarray.Dataset>
24+
Dimensions: (x: 3, y: 3)
25+
Dimensions without coordinates: x, y
26+
Data variables:
27+
a (x) int64 0 1 2
28+
b (y) int64 -3 5 1
29+
30+
In [3]: q = ds.pint.quantify(a="s")
31+
...: q
32+
Out[3]:
33+
<xarray.Dataset>
34+
Dimensions: (x: 3, y: 3)
35+
Dimensions without coordinates: x, y
36+
Data variables:
37+
a (x) int64 [s] 0 1 2
38+
b (y) int64 [m] -3 5 1
39+
```
40+
to convert to different units:
41+
```python
42+
In [4]: c = q.pint.to({"a": "ms", "b": "km"})
43+
...: c
44+
Out[4]:
45+
<xarray.Dataset>
46+
Dimensions: (x: 3, y: 3)
47+
Dimensions without coordinates: x, y
48+
Data variables:
49+
a (x) float64 [ms] 0.0 1e+03 2e+03
50+
b (y) float64 [km] -0.003 0.005 0.001
51+
```
52+
to convert back to non-quantities:
53+
```python
54+
In [5]: d = c.pint.dequantify()
55+
...: d
56+
Out[5]:
57+
<xarray.Dataset>
58+
Dimensions: (x: 3, y: 3)
59+
Dimensions without coordinates: x, y
60+
Data variables:
61+
a (x) float64 0.0 1e+03 2e+03
62+
b (y) float64 -0.003 0.005 0.001
63+
```
64+
65+
For more, see the [documentation](https://pint-xarray.readthedocs.io)

setup.cfg

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,23 @@ description = Physical units interface to xarray using Pint
66
url = https://github.com/xarray-contrib/pint-xarray
77
project_urls =
88
Documentation=https://pint-xarray.readthedocs.io/en/stable
9-
long_description_content_type = text/markdown
109
long_description = file: README.md
10+
long_description_content_type = text/markdown
1111
classifiers =
1212
Development Status :: 3 - Alpha
1313
Environment :: Console
1414
Intended Audience :: Science/Research
1515
License :: OSI Approved :: Apache Software License
1616
Operating System :: OS Independent
1717
Programming Language :: Python
18-
Programming Language :: Python :: 3.6
1918
Programming Language :: Python :: 3.7
2019
Programming Language :: Python :: 3.8
2120
Programming Language :: Python :: 3.9
2221
Topic :: Scientific/Engineering
2322

2423
[options]
2524
packages = find:
26-
python_requires = >=3.6
25+
python_requires = >=3.7
2726
install_requires =
2827
numpy >= 1.17
2928
xarray >= 0.16.1

0 commit comments

Comments
 (0)