Skip to content

Commit 20caeb5

Browse files
authored
Maintenance updates (#2)
Refactor pyproject.toml Update github pipelines Update tests Run everything through black
1 parent d153b07 commit 20caeb5

File tree

11 files changed

+100
-47
lines changed

11 files changed

+100
-47
lines changed

.github/workflows/publish_release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ jobs:
99
name: Build wheel and zip for PyPI
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v4
1313
- name: Set up Python
14-
uses: actions/setup-python@v1
14+
uses: actions/setup-python@v5
1515
with:
16-
python-version: 3.8
16+
python-version: 3.12
1717

1818
- name: Build dist
1919
run: |
2020
python -m pip install twine build
2121
python -m build
2222
23-
- uses: actions/upload-artifact@v1
23+
- uses: actions/upload-artifact@v4.6.2
2424
with:
2525
name: wheelhouse
2626
path: dist

.github/workflows/test.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
- cron: '0 0 1 * *' # Runs at midnight on the first day of every month
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.9", "3.10", "3.11", "3.12"]
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install .[test]
30+
31+
- name: Run tests
32+
run: |
33+
python -m pytest
34+
35+
- name: Build dist
36+
run: |
37+
python -m pip install build
38+
python -m build

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*_pycache_*
2+
_version.py
23
dist
3-
*egg*
4+
*egg*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Available on pypi](https://img.shields.io/pypi/v/tcmarkers.svg)](https://pypi.python.org/pypi/tcmarkers/)
22
[![PyPI - Downloads](https://img.shields.io/pypi/dm/tcmarkers)](https://pypistats.org/packages/tcmarkers)
3-
3+
[![Tests](https://github.com/abrammer/tc_markers/actions/workflows/test.yml/badge.svg)](https://github.com/abrammer/tc_markers/actions/workflows/test.yml)
44

55
# TC Markers
66

backend/generate_paths.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,43 @@ def main():
1313

1414
parent_map = {c: p for p in tree.iter() for c in p}
1515
root = tree.getroot()
16-
path_elems = root.findall('.//{http://www.w3.org/2000/svg}path')
16+
path_elems = root.findall(".//{http://www.w3.org/2000/svg}path")
1717

1818
marks = {}
1919
for i, path_elem in enumerate(path_elems):
20-
_id = path_elem.attrib['id']
21-
p = parse_path(path_elem.attrib['d'])
20+
_id = path_elem.attrib["id"]
21+
p = parse_path(path_elem.attrib["d"])
2222

2323
verts = p.vertices
24-
offset = verts.max(
25-
axis=0) - (verts.max(axis=0) - verts.min(axis=0)) / 2
24+
offset = verts.max(axis=0) - (verts.max(axis=0) - verts.min(axis=0)) / 2
2625
for vert in p._vertices:
2726
vert[0] -= offset[0]
2827
vert[1] -= offset[1]
2928
vert[1] *= -1 # somewhere things get flipped, not sure why
30-
p._vertices = np.round(p.vertices,
31-
2) # arbitrary to clean up the file a little.
29+
p._vertices = np.round(
30+
p.vertices, 2
31+
) # arbitrary to clean up the file a little.
3232
marks[_id] = p.deepcopy()
3333

3434
outpath = pathlib.Path(__file__).parent.parent / "tcmarkers/markers.py"
35-
with open(outpath, 'wt') as outf:
36-
outf.write("""
35+
with open(outpath, "wt") as outf:
36+
outf.write(
37+
"""
3738
# Autogenerated Paths for each marker from SVG file.
3839
# Don't edit manually. Edit SVG and regenerate this file.
3940
4041
from matplotlib.path import Path
4142
from numpy import array, uint8
4243
4344
44-
""")
45+
"""
46+
)
4547
for key, path in marks.items():
4648
outf.write(
47-
f"{key}_path = {path}") # relying on the matplotlib.path.Path repr
49+
f"{key}_path = {path}"
50+
) # relying on the matplotlib.path.Path repr
4851
outf.write("\n\n")
4952

5053

5154
if __name__ == "__main__":
52-
main()
55+
main()

pyproject.toml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
11
[build-system]
2-
requires = ["setuptools", "wheel"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["setuptools>=77.0", "setuptools-scm[toml]>=8.0.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
6+
[project]
7+
name = "tcmarkers"
8+
dynamic = ["version"]
9+
description = "Tropical Storm and Hurricane Markers for Matplotlib"
10+
readme = "README.md"
11+
license-files = [ "LICENSE" ]
12+
requires-python = ">=3.6"
13+
classifiers = [ "Programming Language :: Python :: 3" ]
14+
dependencies = [
15+
"matplotlib",
16+
"numpy",
17+
]
18+
19+
# Only include the tcmarkers directory as a package
20+
[tool.setuptools.packages.find]
21+
where = ["tcmarkers"]
22+
23+
[project.optional-dependencies]
24+
test = ["pytest"]
25+
26+
[project.urls]
27+
Homepage = "https://github.com/abrammer/tc_markers"
28+
29+
[tool.setuptools_scm]
30+
write_to = "tcmarkers/_version.py"

setup.cfg

Lines changed: 0 additions & 17 deletions
This file was deleted.

tcmarkers/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.0.3"
1+
import bisect
22

33
import numpy as np
44
from matplotlib import transforms
@@ -12,7 +12,7 @@
1212

1313
class TCMarkerStyle(MarkerStyle):
1414
def _set_custom_marker(self, path):
15-
self._transform = Affine2D().scale(1. / _MARKERSCALE)
15+
self._transform = Affine2D().scale(1.0 / _MARKERSCALE)
1616
self._path = path
1717

1818

@@ -34,7 +34,7 @@ def _set_custom_marker(self, path):
3434

3535

3636
def tc_marker(vmx, lat=5):
37-
""" Returns marker for given intensity and latitude
37+
"""Returns marker for given intensity and latitude
3838
3939
Parameters
4040
----------
@@ -53,7 +53,7 @@ def tc_marker(vmx, lat=5):
5353
ValueError
5454
if vmx is too great (< 500 kts), raise error as something is wrong
5555
"""
56-
import bisect
56+
5757
limits = [34, 64, 500]
5858
if lat < 0:
5959
marks = [TD, SH_TS, SH_HU]

tests/expected.png

-6.74 KB
Loading

tests/requirements.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)