Skip to content

Commit 64a93e3

Browse files
authored
Prepare for release 2.3.0 (#83)
1 parent fa096a0 commit 64a93e3

File tree

8 files changed

+110
-83
lines changed

8 files changed

+110
-83
lines changed

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Include data
2+
include LICENSE
23
recursive-include pyhelpers/data *
34

45
# Exclude tests
56
prune tests
7+
prune tutorials
8+
prune venv
9+
prune dist

docs/source/_templates/class.rst

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,40 @@
33
.. currentmodule:: {{ module }}.{{ objname }}
44

55
.. autoclass:: {{ module }}.{{ objname }}
6+
67
{% block attributes %}
7-
{% if attributes %}
8+
{% set ns = namespace(attrs=[]) %}
9+
{% for item in all_attributes %}
10+
{% if not item.startswith('_') %}
11+
{% set _ = ns.attrs.append(item) %}
12+
{% endif %}
13+
{% endfor %}
14+
{% if ns.attrs %}
815
.. rubric:: {{ _('Attributes') }}
916
.. autosummary::
1017
:template: base.rst
1118
:toctree:
12-
{% for item in all_attributes %}
13-
{%- if not item.startswith('_') %}
19+
{% for item in ns.attrs %}
1420
{{ item }}
15-
{%- endif -%}
16-
{%- endfor %}
21+
{% endfor %}
1722
{% endif %}
1823
{% endblock %}
24+
1925
{% block methods %}
20-
{% if methods %}
26+
{% set ns = namespace(methods=[]) %}
27+
{% for item in all_methods %}
28+
{% if not item.startswith('_') or item in ['__call__'] %}
29+
{% set _ = ns.methods.append(item) %}
30+
{% endif %}
31+
{% endfor %}
32+
{% if ns.methods %}
2133
.. rubric:: {{ _('Methods') }}
2234
.. autosummary::
2335
:template: base.rst
2436
:toctree:
25-
{% for item in all_methods %}
26-
{%- if not item.startswith('_') or item in ['__call__'] %}
37+
{% for item in ns.methods %}
2738
{{ item }}
28-
{%- endif -%}
29-
{%- endfor %}
39+
{% endfor %}
3040
{% endif %}
3141
{% endblock %}
3242

docs/source/requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
branca==0.8.1
21
furo==2024.8.6
3-
jinja2==3.1.6
4-
pandas==2.3.0
2+
pandas==2.3.1
53
psycopg2==2.9.10
64
pyproj==3.7.1
75
shapely==2.1.1

pyhelpers/data/.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"Author": "Qian Fu",
66
"Affiliation": "School of Engineering, University of Birmingham",
77
"Email": "q.fu@bham.ac.uk",
8-
"Version": "2.2.0",
9-
"License": "MIT License",
8+
"Version": "2.3.0rc1",
9+
"License": "MIT",
1010
"First release": "September 2019"
1111
}

pyhelpers/viz/colormap.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@
44

55
from .._cache import _check_dependencies
66

7-
branca, jinja2 = _check_dependencies('branca', 'jinja2')
87

9-
10-
class BindColormap(branca.element.MacroElement):
8+
class BindColormap:
119
"""
1210
Binds a colormap to a Folium layer with visibility synchronization.
1311
1412
This class creates a connection between a Folium map layer and a color scale,
1513
showing/hiding the colormap legend when the layer visibility changes.
1614
"""
1715

18-
def __init__(self, layer, colormap, display=True):
16+
def __new__(cls, layer, colormap, display=True):
1917
"""
2018
:param layer: Folium layer object (``FeatureGroup``, ``GeoJson``, etc.) to bind with.
2119
:type layer: folium.FeatureGroup | folium.GeoJson
@@ -55,26 +53,35 @@ def __init__(self, layer, colormap, display=True):
5553
<https://nbviewer.org/gist/BibMartin/f153aa957ddc5fadc64929abdee9ff2e>`_].
5654
"""
5755

58-
super().__init__()
59-
60-
self.layer = layer
61-
self.colormap = colormap
62-
63-
display_first = "'block'" if display else "'none'"
64-
65-
# noinspection SpellCheckingInspection
66-
template_str = u"""
67-
{% macro script(this, kwargs) %}
68-
{{this.colormap.get_name()}}.svg[0][0].style.display = {display_first};
69-
{{this._parent.get_name()}}.on('overlayadd', function(eventLayer) {
70-
if (eventLayer.layer == {{this.layer.get_name()}}) {
71-
{{this.colormap.get_name()}}.svg[0][0].style.display = 'block';
72-
}});
73-
{{this._parent.get_name()}}.on('overlayremove', function(eventLayer) {
74-
if (eventLayer.layer == {{this.layer.get_name()}}) {
75-
{{this.colormap.get_name()}}.svg[0][0].style.display = 'none';
76-
}});
77-
{% endmacro %}
78-
"""
79-
80-
self._template = jinja2.Template(template_str.replace('{display_first}', display_first))
56+
branca, jinja2 = _check_dependencies('branca', 'jinja2')
57+
58+
class _BindColormap(branca.element.MacroElement):
59+
60+
def __init__(self, _layer, _colormap, _display):
61+
super().__init__()
62+
63+
self.layer = _layer
64+
self.colormap = _colormap
65+
66+
display_first = "'block'" if _display else "'none'"
67+
68+
# noinspection SpellCheckingInspection
69+
template_str = u"""
70+
{% macro script(this, kwargs) %}
71+
{{this.colormap.get_name()}}.svg[0][0].style.display = {display_first};
72+
{{this._parent.get_name()}}.on('overlayadd', function(eventLayer) {
73+
if (eventLayer.layer == {{this.layer.get_name()}}) {
74+
{{this.colormap.get_name()}}.svg[0][0].style.display = 'block';
75+
}});
76+
{{this._parent.get_name()}}.on('overlayremove', function(eventLayer) {
77+
if (eventLayer.layer == {{this.layer.get_name()}}) {
78+
{{this.colormap.get_name()}}.svg[0][0].style.display = 'none';
79+
}});
80+
{% endmacro %}
81+
"""
82+
83+
self._template = jinja2.Template(
84+
template_str.replace('{display_first}', display_first))
85+
86+
# Instantiate the dynamic subclass and return it directly
87+
return _BindColormap(layer, colormap, display)

pyproject.toml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
11
[build-system]
2-
requires = ["setuptools>=70.0"]
2+
requires = ["setuptools>=70", "wheel", "build"]
33
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "pyhelpers"
7+
dynamic = [
8+
"version",
9+
"description",
10+
"urls",
11+
"authors",
12+
"license"
13+
]
14+
readme = { file = "README.md", content-type = "text/markdown" }
15+
keywords = [
16+
"Python",
17+
"Utilities",
18+
"Data preprocessing",
19+
"Data manipulation",
20+
"Python utilities",
21+
"Python utils",
22+
"Python utility"
23+
]
24+
requires-python = ">=3.10"
25+
dependencies = [
26+
"numpy",
27+
"pandas",
28+
"psycopg2",
29+
"pyproj",
30+
"requests",
31+
"shapely",
32+
"sqlalchemy"
33+
]
34+
classifiers = [
35+
"Intended Audience :: Developers",
36+
"Intended Audience :: Education",
37+
"Intended Audience :: Science/Research",
38+
"Topic :: Education",
39+
"Topic :: Scientific/Engineering",
40+
"Topic :: Software Development",
41+
"Topic :: Utilities",
42+
"Programming Language :: Python :: 3",
43+
"Operating System :: Microsoft :: Windows",
44+
"Operating System :: POSIX :: Linux"
45+
]
46+
47+
[tool.setuptools]
48+
packages = { find = {} }

requirements.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ notebook==7.4.4
1313
odfpy==1.4.1
1414
openpyxl==3.1.5
1515
orjson==3.10.18
16-
pandas==2.3.0
16+
pandas==2.3.1
1717
pdfkit==1.0.0
1818
pip-chill==1.0.3
19+
pkginfo==1.12.1.2
1920
polars==1.31.0
2021
psycopg2==2.9.10
2122
pyarrow==20.0.0
@@ -33,7 +34,7 @@ sphinx-toggleprompt==0.6.0
3334
sqlalchemy==2.0.41
3435
tinycss2==1.4.0
3536
tomli==2.0.1
36-
twine==6.0.1
37+
twine==6.1.0
3738
ujson==5.10.0
3839
uri-template==1.3.0
3940
webcolors==24.11.1

setup.cfg

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

0 commit comments

Comments
 (0)