Skip to content

Commit

Permalink
prepare release of 0.16.0 (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ringsaturn authored Nov 1, 2024
1 parent 54624b0 commit 6fc344a
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
--token "${{ secrets.BENCHER_API_TOKEN }}" \
--adapter python_pytest \
--err \
"pytest --benchmark-json results.json tests/test_bench.py"
"pytest --benchmark-json results.json --benchmark-warmup=on --benchmark-warmup-iterations=100 tests/test_bench.py"
2 changes: 1 addition & 1 deletion .github/workflows/CodSpeed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
run: uv run pytest tests/ --codspeed
run: uv run pytest --benchmark-warmup=on --benchmark-warmup-iterations=100 --codspeed tests/test_bench.py

- name: Minimize uv cache
run: uv cache prune --ci
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
> borders.
> 2. Rust use lazy init, so first calling will be a little slow.
> 3. Use about 40MB memory.
> 4. It's tested under Python 3.9+ but support 3.8+(noqa).
> 4. It's tested under Python 3.9+.
> 5. Try it online: <https://ringsaturn.github.io/tzf-web/>
## Usage
Expand Down Expand Up @@ -48,25 +48,25 @@ conda install -c conda-forge tzfpy
## Performance

Benchmark runs under
[`v0.15.3`](https://github.com/ringsaturn/tzfpy/releases/tag/v0.15.3) on my
[`v0.16.0`](https://github.com/ringsaturn/tzfpy/releases/tag/v0.16.0) on my
MacBook Pro with Apple M3 Max.

```bash
pytest tests/test_bench.py
pytest --benchmark-warmup=on --benchmark-warmup-iterations=100 tests/test_bench.py
```

```
------------------------------------------------------------ benchmark: 1 tests ------------------------------------------------------------
Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
--------------------------------------------------------------------------------------------------------------------------------------------
test_tzfpy_random_cities 837.4918 11,183.2982 1,973.3456 833.9543 1,820.9103 1,066.7020 6422;511 506.7536 20000 10
--------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------- benchmark: 1 tests -----------------------------------------------------------
Name (time in ns) Min Max Mean StdDev Median IQR Outliers OPS (Kops/s) Rounds Iterations
------------------------------------------------------------------------------------------------------------------------------------------
test_tzfpy_random_cities 699.9937 7,175.0022 1,562.1433 646.9249 1,441.6990 833.3940 13716;984 640.1461 41026 10
------------------------------------------------------------------------------------------------------------------------------------------
Legend:
Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
OPS: Operations Per Second, computed as 1 / Mean
Results (1.95s):
4 passed
Results (1.81s):
1 passed
```

Or you can view more benchmark results on
Expand Down
12 changes: 6 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,8 @@ Documentation = "https://github.com/ringsaturn/tzfpy"
Issues = "https://github.com/ringsaturn/tzfpy/issues"
"Source Code" = "https://github.com/ringsaturn/tzfpy"

[tool.maturin]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
features = ["pyo3/extension-module"]

[tool.uv]
dev-dependencies = [
[dependency-groups]
dev = [
"ruff>=0.7.1",
"citiespy>=0.6.5",
"maturin>=1.7.4",
Expand All @@ -56,3 +52,7 @@ dev-dependencies = [
"tzdata>=2024.2",
"pytest-codspeed>=2.2.1",
]

[tool.maturin]
# "extension-module" tells pyo3 we want to build an extension module (skips linking against libpython.so)
features = ["pyo3/extension-module"]
18 changes: 18 additions & 0 deletions tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from pytest import mark
from tzfpy import get_tz


@mark.parametrize(
"lng, lat, tz",
[
(116.3883, 39.9289, "Asia/Shanghai"),
(120.347287, 22.598127, "Asia/Taipei"),
(2.3522, 48.8566, "Europe/Paris"),
(-0.1276, 51.5074, "Europe/London"),
(13.4049, 52.5200, "Europe/Berlin"),
(-74.0060, 40.7128, "America/New_York"),
(-118.2437, 34.0522, "America/Los_Angeles"),
],
)
def test_get_tz(lng, lat, tz):
assert get_tz(lng, lat) == tz
34 changes: 15 additions & 19 deletions tests/test_compatibility.py
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
from unittest import TestCase, main

from citiespy import all_cities
from tzfpy import data_version, get_tzs, timezonenames


class TestCompatibility(TestCase):
def test_with_pytz(self):
from pytz import timezone
def test_with_pytz():
from pytz import timezone

for tz in timezonenames():
timezone(tz)

for tz in timezonenames():
timezone(tz)

def test_with_tzdata(self):
from zoneinfo import ZoneInfo
def test_with_tzdata():
from zoneinfo import ZoneInfo

for tz in timezonenames():
ZoneInfo(tz)
for tz in timezonenames():
ZoneInfo(tz)

def test_no_empty(self):
for city in all_cities():
tznames = get_tzs(city.lng, city.lat)
self.assertTrue(len(tznames) != 0)

def test_version_support(self):
self.assertTrue(data_version() not in [None, ""])
def test_no_empty():
for city in all_cities():
tznames = get_tzs(city.lng, city.lat)
assert len(tznames) != 0


if __name__ == "__main___":
main()
def test_version_support():
assert data_version() not in [None, ""]
51 changes: 37 additions & 14 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6fc344a

Please sign in to comment.