Skip to content

Commit aad2323

Browse files
committed
Initial project setup
1 parent 480f1d4 commit aad2323

11 files changed

+529
-0
lines changed
+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Lint and Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
pull_request:
9+
branches:
10+
- main
11+
- release/*
12+
13+
jobs:
14+
15+
###########
16+
# LINTING #
17+
###########
18+
linting:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: 3.9
26+
# Cache pip
27+
- uses: actions/cache@v2
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip
31+
restore-keys: ${{ runner.os }}-pip
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install .
36+
python -m pip install mypy black isort
37+
- name: Python Code Quality and Lint
38+
uses: abey79/python-lint@master
39+
with:
40+
python-root-list: "pnoise tests"
41+
use-pylint: false
42+
use-pycodestyle: false
43+
use-flake8: false
44+
use-black: true
45+
extra-black-options: --diff
46+
use-mypy: true
47+
use-isort: true
48+
49+
#########
50+
# TESTS #
51+
#########
52+
tests:
53+
needs: linting
54+
strategy:
55+
fail-fast: true
56+
matrix:
57+
python-version: [3.7, 3.8, 3.9]
58+
os: [ubuntu-latest, macos-latest, windows-latest]
59+
defaults:
60+
run:
61+
shell: bash
62+
runs-on: ${{ matrix.os }}
63+
64+
steps:
65+
- uses: actions/checkout@v2
66+
- name: Set up Python ${{ matrix.python-version }}
67+
uses: actions/setup-python@v2
68+
with:
69+
python-version: ${{ matrix.python-version }}
70+
- name: Install dependencies
71+
run: |
72+
pip install .
73+
pip install -r dev-requirements.txt
74+
- name: Pytest
75+
run: |
76+
pytest

.github/workflows/release.yml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
2+
name: Release
3+
4+
on:
5+
push:
6+
tags:
7+
- '*.*.*'
8+
9+
jobs:
10+
11+
########################
12+
# RELEASE CREATION JOB #
13+
########################
14+
job_release:
15+
name: Create Release
16+
runs-on: ubuntu-latest
17+
outputs:
18+
upload_url: ${{ steps.create_release.outputs.upload_url }}
19+
tag: ${{ steps.tag.outputs.tag }}
20+
steps:
21+
- name: Get tag
22+
id: tag
23+
run: |
24+
echo ::set-output name=tag::${GITHUB_REF#refs/tags/}
25+
- uses: actions/checkout@v2
26+
- name: Create Release
27+
id: create_release
28+
uses: actions/create-release@v1
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
with:
32+
tag_name: ${{ steps.tag.outputs.tag }}
33+
release_name: pnoise ${{ steps.tag.outputs.tag }}
34+
draft: true
35+
prerelease: false
36+
37+
38+
##################
39+
# UPLOAD TO PYPI #
40+
##################
41+
job_pypi:
42+
name: Upload to PyPI
43+
runs-on: ubuntu-latest
44+
needs: job_release
45+
steps:
46+
- uses: actions/checkout@v2
47+
- name: Set up Python 3.9
48+
uses: actions/setup-python@v2
49+
with:
50+
python-version: 3.9
51+
- name: Build
52+
id: build
53+
run: |
54+
pip install -r dev-requirements.txt
55+
pip install .
56+
python setup.py sdist bdist_wheel
57+
echo ::set-output name=version::`python -c "import pnoise;print(pnoise.__version__)"`
58+
- name: Upload File Assets
59+
uses: actions/[email protected]
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
with:
63+
upload_url: ${{ needs.job_release.outputs.upload_url }}
64+
asset_path: dist/pnoise-${{ steps.build.outputs.version }}.tar.gz
65+
asset_name: pnoise-${{ steps.build.outputs.version }}.tar.gz
66+
asset_content_type: application/gzip
67+
- name: pypi-publish
68+
uses: pypa/[email protected]
69+
with:
70+
# repository_url: https://test.pypi.org/legacy/
71+
password: ${{ secrets.PYPI_TOKEN }}
72+
# skip_existing: true
73+
verbose: true

.gitignore

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# *pnoise*
2+
3+
*pnoise* is a pure-Python, Numpy-based, vectorized port of Processing's `noise()` function.
4+
5+
## Why?
6+
7+
I wrote this port before switching to [vnoise](https://github.com/plottertools/vnoise) and although I'm no longer using it I figured I would keep it around.
8+
9+
## How does it compare to *vnoise*?
10+
11+
| | *pnoise* | *vnoise* |
12+
| --- | --- | --- |
13+
| Algorithm | "classic Perlin noise of 1983" | "Perlin improved
14+
noise" |
15+
| Scalar API |||
16+
| Vectorized API |||
17+
| 3D function |||
18+
| 2D function | ❌ (can be derived from 3D but slower) ||
19+
| 1D function | ❌ (can be derived from 3D but slower) ||
20+
| Scalar performance 3D (1 octave) | - | ~2x faster |
21+
| Scalar performance 3D (4 octave) | ~2x faster | - |
22+
| Vectorized performance 3D (1 octave) | - | ~2.5x faster |
23+
| Vectorized performance 3D (4 octave) | ~2x faster | - |
24+
| Vectorized performance 2D (1 octave) | - | ~5.5x faster |
25+
| Vectorized performance 2D (4 octave) | - | ~30% faster |
26+
| Vectorized performance 1D (1 octave) | - | ~8x faster |
27+
| Vectorized performance 1D (4 octave) | similar | similar |
28+
29+
30+
## Installation
31+
32+
```
33+
pip install git+https://github.com/plottertools/pnoise#egg=pnoise
34+
```
35+
36+
## License
37+
38+
LGPL 2.1, see [LICENSE](LICENSE) file.

dev-requirements.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
black
2+
isort
3+
mypy
4+
pytest
5+
setuptools
6+
wheel

mypy.ini

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[mypy]
2+
ignore_missing_imports = True
3+
allow_redefinition = True
4+
disallow_incomplete_defs = True
5+
files = pnoise,tests
6+

pnoise/__init__.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from .pnoise import Noise
2+
3+
4+
def _get_version() -> str:
5+
import pkg_resources
6+
7+
return pkg_resources.get_distribution("pnoise").version
8+
9+
10+
__version__ = _get_version()

0 commit comments

Comments
 (0)