Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .circleci/config.yml

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Node
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "npm"

- name: Install Node dependencies
run: npm ci

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.9.0"
enable-cache: true
cache-dependency-glob: uv.lock

- name: Install Python dependencies
run: uv sync --all-extras --dev

- name: Run Node tests
run: npm test

- name: Run Python tests
run: uv run --frozen pytest
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ npm-debug.log
*.bak
*.egg-info
*.pyc
build/
venv/
build
venv
.venv
.pypirc

# IDE files
nbproject
.idea
.netbeans.xml
.vscode

# GH pages
.publish
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.defaultInterpreterPath": ".venv/bin/python"
}
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# chrys

[![CircleCI](https://circleci.com/gh/netbek/chrys.svg?style=svg)](https://circleci.com/gh/netbek/chrys)

A collection of color palettes for visualisation in JavaScript, Python and Sass.

## Demo
Expand All @@ -16,7 +14,7 @@ A collection of color palettes for visualisation in JavaScript, Python and Sass.
npm install chrys
```

### Python 3.6 and up
### Python 3.10 and up

```shell
pip install chrys
Expand All @@ -28,22 +26,35 @@ For instructions, refer to [the docs](https://netbek.github.io/chrys#usage).

## Development: Installation

1. Install Node 18.x:
1. Install Node 22.x:

```shell
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 18
nvm use 18
nvm install 22
nvm use 22
```

2. Install uv:

```shell
curl -LsSf https://astral.sh/uv/install.sh | sh
```

2. Create `.pypirc`:
3. Create `.pypirc`:

```shell
cp example.pypirc .pypirc
```

3. Enter a [PyPI API token](https://pypi.org/manage/account/#api-tokens) as the password in `.pypirc`.
4. Enter a [PyPI API token](https://pypi.org/manage/account/#api-tokens) as the password in `.pypirc`.

5. Install Node and Python dependencies:

```shell
npm ci
uv sync
```

## Development: Usage

Expand All @@ -64,8 +75,7 @@ npm run build-dist
Publish the JavaScript and Python distribution packages:

```shell
npm publish
npm run publish-py
npm run publish-dist
```

## Credit
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
],
"scripts": {
"build-data": "node scripts/bokeh-palettes.js && node scripts/vega-palettes.js",
"build-dist": "./scripts/npm/build-dist.sh",
"build-dist": "./scripts/build.sh",
"deploy": "node scripts/deploy.js",
"format-js": "prettier --parser babel --write \"src/**/*.js\"",
"livereload": "node scripts/livereload.js",
"postinstall": "patch-package",
"publish-py": "twine upload --config-file .pypirc --verbose dist/*",
"publish-dist": "./scripts/publish.sh",
"test": "vitest run"
},
"author": {
Expand Down
34 changes: 32 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
[project]
name = "chrys"
version = "4.2.0"
description = "A collection of color palettes for mapping and visualisation"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"matplotlib>=3.3.2",
"numpy>=2.1.0",
"wcag-contrast-ratio>=0.9",
]

[dependency-groups]
dev = [
"pytest>=8.4.2",
"twine>=6.2.0",
]

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.isort]
force_alphabetical_sort = true
line_length = 100
profile = "black"
py_version = 310

[tool.pytest.ini_options]
addopts = "--no-header -vv"
python_classes = ["Test*"]
python_files = ["test_*.py"]
python_functions = ["test_*"]
testpaths = ["tests"]

[tool.ruff]
line-length = 100
target-version = "py310"

[tool.ruff.format]
quote-style = "preserve"
[tool.ruff.lint]
ignore = ["D100", "D101", "D102", "D103", "D104", "D107", "D205"]
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

11 changes: 8 additions & 3 deletions scripts/npm/build-dist.sh → scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#! /bin/bash
#!/bin/bash
set -e

scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_dir="${scripts_dir}/.."

cd "${repo_dir}"

# Required by Webpack 4+ on Node 17+ https://github.com/webpack/webpack/issues/14532
# export NODE_OPTIONS=--openssl-legacy-provider

Expand All @@ -23,5 +28,5 @@ node scripts/build-demo.js
rm -fr build/*
rm -fr dist/*

python3.8 setup.py sdist bdist_wheel --universal
twine check dist/*
uv build
.venv/bin/twine check dist/*
17 changes: 17 additions & 0 deletions scripts/publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
set -e

scripts_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
repo_dir="${scripts_dir}/.."

if ([ "$1" == "--help" ] || [ -z "$1" ]); then
echo "Usage: publish.sh [version]"
echo ""
echo "Example: ./publish.sh 0.0.1"
exit 1
fi

cd "${repo_dir}"
npm publish
.venv/bin/twine upload --config-file .pypirc --verbose dist/*
gh release create $1
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.

29 changes: 0 additions & 29 deletions setup.py

This file was deleted.

File renamed without changes.
35 changes: 0 additions & 35 deletions tests/py/palettes_tests.py

This file was deleted.

9 changes: 0 additions & 9 deletions tests/py/utils_tests.py

This file was deleted.

55 changes: 55 additions & 0 deletions tests/test_palettes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
from chrys.palettes import discrete_palette, parse_palette_name, VEGA_ACCENT

import pytest
import unittest


class TestParsePaletteName(unittest.TestCase):
def test_valid_name(self):
self.assertEqual(parse_palette_name(VEGA_ACCENT), ("vega", "accent"))

def test_invalid_name(self):
with pytest.raises(ValueError):
parse_palette_name("lorem ipsum")


class TestDiscretePalette(unittest.TestCase):
def test_no_size(self):
self.assertEqual(
discrete_palette(VEGA_ACCENT),
["#7fc97f", "#beaed4", "#fdc086", "#ffff99", "#386cb0", "#f0027f"],
)

def test_valid_size(self):
self.assertEqual(
discrete_palette(VEGA_ACCENT, 8),
[
"#7fc97f",
"#beaed4",
"#fdc086",
"#ffff99",
"#386cb0",
"#f0027f",
"#bf5b17",
"#666666",
],
)

def test_invalid_size(self):
self.assertEqual(
discrete_palette(VEGA_ACCENT, 20),
[
"#7fc97f",
"#beaed4",
"#fdc086",
"#ffff99",
"#386cb0",
"#f0027f",
"#bf5b17",
"#666666",
],
)

def test_invalid_name(self):
with pytest.raises(ValueError):
discrete_palette("lorem ipsum")
Loading