Skip to content

Commit

Permalink
Merge pull request #258 from ajhynes7/use_poetry
Browse files Browse the repository at this point in the history
Use poetry and `pyproject.toml`
  • Loading branch information
ajhynes7 committed Mar 14, 2021
2 parents 1ac50e0 + e46c46d commit aad0fca
Show file tree
Hide file tree
Showing 25 changed files with 144 additions and 135 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: snok/install-poetry@v1.1.2

- name: Install tox
run: pip install -r requirements/tox.txt
run: pip install tox==3.23.0

- name: Run tox
run: tox
Expand All @@ -29,3 +32,9 @@ jobs:
fail_ci_if_error: true
verbose: true
gcov_prefix: ${{ env.GITHUB_WORKSPACE }}

- name: Build and publish to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: JRubics/poetry-publish@v1
with:
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ docs/source/api_reference/*/
docs/source/computations/*/
docs/source/gallery/
htmlcov/
poetry.lock

!.github/
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ repos:
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0
Expand All @@ -20,6 +19,11 @@ repos:
hooks:
- id: black
args: [-S, -l 120]
- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
hooks:
- id: add-trailing-comma
args: [--py36-plus]
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
Expand Down
11 changes: 0 additions & 11 deletions MANIFEST.in

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
'../../examples/intersection',
'../../examples/fitting',
'../../examples/triangle',
]
],
),
}

Expand Down
2 changes: 1 addition & 1 deletion examples/fitting/plot_line_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[6, 5],
[5, 6],
[7, 8],
]
],
)

line_fit = Line.best_fit(points)
Expand Down
2 changes: 1 addition & 1 deletion examples/fitting/plot_line_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[6, 5, 5],
[6, 6, 5],
[7, 6, 7],
]
],
)

line_fit = Line.best_fit(points)
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
mypy_path = stubs
65 changes: 65 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
[tool.poetry]

name = "scikit-spatial"
version = "5.2.0"
description = "Spatial objects and computations based on NumPy arrays."
license = "BSD"

authors = ["Andrew Hynes <andrewjhynes@gmail.com>"]

readme = "README.rst"

repository = "https://github.com/ajhynes7/scikit-spatial"
documentation = "https://scikit-spatial.readthedocs.io"

keywords = ["NumPy", "matplotlib", "visualization", "spatial", "linear algebra"]

classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering",
]

packages = [{ include = "skspatial", from = "src" }]


[tool.poetry.dependencies]
python = "^3.7"

numpy = "^1.20"
matplotlib = "^3"

# Pre-commit
pre-commit = { version = "2.11.1", optional = true }

# Types
mypy = { version = "0.812", optional = true }

# Testing
pytest = { version = "6.2.2", optional = true }
pytest-cov = { version = "2.11.1", optional = true }
hypothesis = { version = "6.8.1", optional = true }

# Docs
Sphinx = { version = "3.5.2", optional = true }
numpydoc = { version = "1.1.0", optional = true }
sphinx-bootstrap-theme = { version = "0.7.1", optional = true }
sphinx-gallery = { version = "0.8.2", optional = true }


[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"


[tool.poetry.extras]
pre_commit = ["pre-commit"]
types = ["mypy"]
base_test = ["pytest", "pytest-cov"]
property = ["hypothesis"]
docs = ["Sphinx", "numpydoc", "sphinx-bootstrap-theme", "sphinx-gallery"]
2 changes: 0 additions & 2 deletions requirements/base.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/base_test.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements/docs.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/pre-commit.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/property.txt

This file was deleted.

2 changes: 0 additions & 2 deletions requirements/tox.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/types.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements/unit.txt

This file was deleted.

32 changes: 0 additions & 32 deletions setup.cfg

This file was deleted.

42 changes: 0 additions & 42 deletions setup.py

This file was deleted.

5 changes: 4 additions & 1 deletion src/skspatial/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def area_triangle(point_a: array_like, point_b: array_like, point_c: array_like)


def volume_tetrahedron(
point_a: array_like, point_b: array_like, point_c: array_like, point_d: array_like
point_a: array_like,
point_b: array_like,
point_c: array_like,
point_d: array_like,
) -> np.float64:
"""
Return the volume of a tetrahedron defined by four points.
Expand Down
13 changes: 11 additions & 2 deletions src/skspatial/objects/plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,13 @@ def best_fit(cls, points: array_like, tol: float | None = None, **kwargs) -> Pla
ValueError
If the points are collinear or are not 3D.
References
----------
Using SVD for some fitting problems
Inge Söderkvist
Algorithm 3.1
https://www.ltu.se/cms_fs/1.51590!/svd-fitting.pdf
Examples
--------
>>> from skspatial.objects import Plane
Expand Down Expand Up @@ -627,12 +634,14 @@ def best_fit(cls, points: array_like, tol: float | None = None, **kwargs) -> Pla
points_centered, centroid = points.mean_center(return_centroid=True)

u, _, _ = np.linalg.svd(points_centered.T, **kwargs)
normal = Vector(u[:, -1])
normal = Vector(u[:, 2])

return cls(centroid, normal)

def to_mesh(
self, lims_x: array_like = (-1, 1), lims_y: array_like = (-1, 1)
self,
lims_x: array_like = (-1, 1),
lims_y: array_like = (-1, 1),
) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
"""
Return coordinate matrices for the 3D surface of the plane.
Expand Down
2 changes: 1 addition & 1 deletion src/skspatial/objects/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Sphere(_BaseSphere, _ToPointsMixin):
Attributes
----------
point : (3,) Point
Center of the circle.
Center of the sphere.
radius : {int, float}
Radius of the sphere.
dimension : int
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/objects/test_line_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

@pytest.mark.parametrize("class_spatial", [Line, Plane])
@pytest.mark.parametrize(
("point", "vector"), [([0, 0], [0, 0]), ([1, 1], [0, 0]), ([1, 1, 1], [0, 0, 0]), ([4, 5, 2, 3], [0, 0, 0, 0])]
("point", "vector"),
[([0, 0], [0, 0]), ([1, 1], [0, 0]), ([1, 1, 1], [0, 0, 0]), ([4, 5, 2, 3], [0, 0, 0, 0])],
)
def test_zero_vector_failure(class_spatial, point, vector):

Expand Down
20 changes: 15 additions & 5 deletions tests/unit/objects/test_plane.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,25 @@ def test_sum_squares_plane(plane, points, error_expected):
(
[
[0, 0, 0],
[0, 0, 1],
[0, 1, 0],
[0, 1, 1],
[1, 0, 0],
[1, 0, 1],
[2, 0, 0],
[0, 1, 0],
[1, 1, 0],
[2, 1, 0],
[0, 2, 0],
[1, 2, 0],
[2, 2, 0],
[0, 0, 1],
[1, 0, 1],
[2, 0, 1],
[0, 1, 1],
[1, 1, 1],
[2, 1, 1],
[0, 2, 1],
[1, 2, 1],
[2, 2, 1],
],
Plane([0.5, 0.5, 0.5], [0, 1, 0]),
Plane([1, 1, 0.5], [0, 0, 1]),
),
],
)
Expand Down

0 comments on commit aad0fca

Please sign in to comment.