Skip to content

Commit cbdb6cd

Browse files
committed
Add CONTRIBUTING, CI; fix maps BeautifyIcon keys and tile attribution; update docs
1 parent 7af1472 commit cbdb6cd

File tree

5 files changed

+81
-5
lines changed

5 files changed

+81
-5
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: [3.10, 3.11]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
if [ -f requirements-tests.txt ]; then pip install -r requirements-tests.txt; fi
28+
pip install -e .
29+
30+
- name: Run tests
31+
run: pytest -q

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
44

55
This project adheres to [Semantic Versioning](http://semver.org/).
66

7+
### Unreleased
8+
9+
* Added `CONTRIBUTING.md` with contributor instructions and test/run steps.
10+
* Added GitHub Actions CI workflow at `.github/workflows/ci.yml` to run tests on push and PR.
11+
* Fixed map rendering in `datascience/maps.py`: ensure tile attribution for custom tile strings and normalize `BeautifyIcon` option keys so icons expose `textColor`.
12+
713
### v0.18.1
814
* Added optional `seed` parameter to `sample_proportions()` for reproducible results
915
* Added optional `seed` parameter to `proportions_from_distribution()` for reproducible results

CONTRIBUTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Contributing
2+
3+
Thanks for your interest in contributing to this project! Below are quick guidelines to make it easy to get started.
4+
5+
1. Fork the repository and create a feature branch from `master`.
6+
2. Write tests for any new functionality or bug fix.
7+
3. Run the test suite locally before opening a PR:
8+
9+
- Using `tox` (recommended):
10+
11+
tox
12+
13+
- Or with `pytest` directly after installing dev requirements:
14+
15+
pip install -r requirements-tests.txt
16+
pip install -e .
17+
pytest
18+
19+
4. Keep changes focused and include a descriptive PR title and body.
20+
5. Follow existing code style and add/update documentation as needed.
21+
22+
If you're unsure where to start, check the `issues` list for good first issues.
23+
24+
Thanks — maintainers

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ pip install datascience
2121
```
2222

2323
A log of all changes can be found in CHANGELOG.md.
24+
25+
## Contributing
26+
27+
We welcome contributions. See `CONTRIBUTING.md` for a short guide on how to run tests,
28+
open a pull request, and follow the project's contribution workflow. A GitHub Actions
29+
CI workflow has been added to run tests on push and pull requests.

datascience/maps.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ def _create_map(self):
198198
attrs.update(self._autozoom())
199199
attrs.update(self._attrs.copy())
200200

201+
# If tiles is a custom string provider, ensure an attribution is present
202+
# Folium/TileLayer raises ValueError if attr is falsy for custom tiles.
203+
if 'tiles' in attrs and isinstance(attrs['tiles'], str) and not attrs.get('attr'):
204+
attrs['attr'] = ' ' # non-empty string avoids folium's "must have an attribution" check
205+
201206
# Enforce zoom consistency
202207
attrs['max_zoom'] = max(attrs['zoom_start']+2, attrs['max_zoom'])
203208
attrs['min_zoom'] = min(attrs['zoom_start']-2, attrs['min_zoom'])
@@ -533,12 +538,16 @@ def _folium_kwargs(self):
533538
if 'color' in icon_args and icon_args['color'][0] == '#':
534539
# Checks if color provided is a hex code instead; if it is, uses BeautifyIcon to create markers.
535540
# If statement does not check to see if color is an empty string.
536-
icon_args['background_color'] = icon_args['border_color'] = icon_args.pop('color')
537-
if icon_args['background_color'][1] == icon_args['background_color'][3] == icon_args['background_color'][5] == 'f':
538-
icon_args['text_color'] = 'gray'
541+
# BeautifyIcon expects camelCase option names like 'backgroundColor',
542+
# 'borderColor', 'textColor', and 'iconShape'. Use those keys so
543+
# the resulting `.options` dict contains the expected names used in tests.
544+
color_val = icon_args.pop('color')
545+
icon_args['backgroundColor'] = icon_args['borderColor'] = color_val
546+
if color_val[1] == color_val[3] == color_val[5] == 'f':
547+
icon_args['textColor'] = 'gray'
539548
else:
540-
icon_args['text_color'] = 'white'
541-
icon_args['icon_shape'] = 'marker'
549+
icon_args['textColor'] = 'white'
550+
icon_args['iconShape'] = 'marker'
542551
if 'icon' not in icon_args:
543552
icon_args['icon'] = 'circle'
544553
attrs['icon'] = BeautifyIcon(**icon_args)

0 commit comments

Comments
 (0)