Skip to content

Commit

Permalink
Merge 68e92af into 57a401d
Browse files Browse the repository at this point in the history
  • Loading branch information
fitodic committed Aug 22, 2018
2 parents 57a401d + 68e92af commit e0b47b8
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 128 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Moved the `coverage` configuration to setup.cfg
- Moved the `coverage` configuration to `setup.cfg`
- Moved the package's metadata to `setup.cfg`

### Fixed

- Error when `MultiLineString` degenerates into `LineString` ([#14](https://github.com/fitodic/centerline/issues/14)). Thanks [mxwell](https://github.com/mxwell)!

### Removed

- MANIFEST.in
- `Centerline` from the `centerline` namespace. To import the `Centerline`
class, use `from centerline.main import Centerline`

## 0.4.1 - 2018-01-07

Expand Down
11 changes: 8 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# How to contribute

Pull requests are always welcome, but before you contribute to this project, please be mindful of the following guidelines:
Pull requests are always welcome, but before you contribute to this project,
please bear in mind that the following tools are used:

- This project adheres to [PEP8](https://www.python.org/dev/peps/pep-0008/) and most of [PEP257](https://www.python.org/dev/peps/pep-0257/) conventions. The [`pylama`](https://github.com/klen/pylama) linter is used for checking the code. The full configuration can be found in the `setup.cfg` file. Please read these conventions and the project's configuration.
- [`pylama`](https://github.com/klen/pylama) linter;
- [`isort`](https://pypi.python.org/pypi/isort) package is for sorting imports;
- [yapf](https://github.com/google/yapf) formatter;
- [pytest](https://docs.pytest.org/en/latest/) as a test runner.

- The [`isort`](https://pypi.python.org/pypi/isort) package is used for sorting imports. The full configuration can be found in `setup.cfg`. Please review them.
The configuration of these tools is located in `setup.cfg`. Please review it
and set up your editor accordingly.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Filip Todic
Copyright (c) 2014-present Filip Todic

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 0 additions & 13 deletions MANIFEST.in

This file was deleted.

10 changes: 7 additions & 3 deletions centerline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

from __future__ import unicode_literals

from . import io, utils
from .main import Centerline
__title__ = 'centerline'
__version__ = '0.4.1'
__author__ = 'Filip Todic'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2014-present Filip Todic'

__all__ = ('Centerline', 'io', 'utils')
# Version synonym
VERSION = __version__
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ If you want to contribute to this library, apart from installing GDAL, you have

2. install the library into its own virtual environment::

$ pip install -e .[dev,test,docs]
$ pip install -e .[dev,lint,test,docs]

3. run the test suite to make sure everything is in order::

Expand Down
2 changes: 1 addition & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ Python

If you need to customize the creation of centerlines in any way, simply import the `Centerline` class and use it or extend it::

from centerline import Centerline
from centerline.main import Centerline
62 changes: 59 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
[metadata]
name = centerline
version = attr: centerline.VERSION
description = Calculate the centerline of a polygon
long_description = file: README.rst, CHANGELOG.md
keywords = polygon, centerline, Voronoi
license = file: LICENSE
url=https://github.com/fitodic/centerline
author=Filip Todic
author_email=todic.filip@gmail.com
classifiers =
Development Status :: 4 - Beta
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Intended Audience :: Science/Research
Intended Audience :: Developers
Topic :: Scientific/Engineering :: GIS
Topic :: Software Development :: Libraries :: Python Modules

[options]
zip_safe = False
packages = centerline
scripts =
bin/create_centerlines
install_requires =
GDAL>=2.0.1
Fiona>=1.7.0
Shapely>=1.5.13
numpy>=1.10.4
scipy>=0.16.1

[options.extras_require]
dev = ipdb
lint =
pylama
isort
yapf
test =
coverage
pytest>=3.0.0
pytest-cov
pytest-sugar
docs =
sphinx
sphinx_rtd_theme

[bdist_wheel]
universal = 1

[isort]
# Reference: https://github.com/timothycrosley/isort/wiki/isort-Settings
skip=.git,__pycache__,docs,build,dist,*.egg*
Expand Down Expand Up @@ -40,11 +93,14 @@ addopts =
-s
testpaths = tests

[bdist_wheel]
universal = 1

[coverage:run]
branch=True

[coverage:report]
show_missing = True

[yapf]
based_on_style = google

# The column limit.
column_limit=79
67 changes: 1 addition & 66 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
from codecs import open
from os import path

from setuptools import setup

here = path.abspath(path.dirname(__file__))

# Get the long description from the relevant file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()

setup(
name='centerline',
version='0.4.1',
description='Calculate the centerline of a polygon',
long_description=long_description,
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Topic :: Scientific/Engineering :: GIS',
'Topic :: Software Development :: Libraries :: Python Modules'
],
url='https://github.com/fitodic/centerline.git',
author='Filip Todic',
author_email='todic.filip@gmail.com',
license='MIT',
packages=['centerline'],
install_requires=[
'GDAL>=2.0.1',
'Fiona>=1.7.0',
'Shapely>=1.5.13',
'numpy>=1.10.4',
'scipy>=0.16.1',
],
extras_require={
'dev': [
'pylama',
'ipdb',
'ipython[all]',
'notebook',
'jupyter',
'isort'
],
'test': [
'coverage',
'pytest>=3.0.0',
'pytest-cov',
'pytest-sugar',
'pytest-runner'
],
'docs': [
'Sphinx',
'sphinx_rtd_theme'
]
},
scripts=[
'bin/create_centerlines',
],
include_package_data=True,
zip_safe=False,
)
setup()
15 changes: 0 additions & 15 deletions tests/test_init.py

This file was deleted.

8 changes: 2 additions & 6 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ def test__shp_to_shp_records_geom_type_is_multilinestring(self):
with fiona.open(DST_SHP) as dst:
for record in dst:
self.assertEqual(
record.get('geometry').get('type'),
EXPECTED_TYPE
)
record.get('geometry').get('type'), EXPECTED_TYPE)

def test__shp_to_shp_record_count_is_3(self):
EXPECTED_COUNT = 3
Expand All @@ -91,9 +89,7 @@ def test__shp_to_geojson_records_geom_type_is_multilinestring(self):
with fiona.open(DST_GEOJSON) as dst:
for record in dst:
self.assertEqual(
record.get('geometry').get('type'),
EXPECTED_TYPE
)
record.get('geometry').get('type'), EXPECTED_TYPE)

def test__shp_to_geojson_record_count_is_3(self):
EXPECTED_COUNT = 3
Expand Down
22 changes: 7 additions & 15 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Point, Polygon
)

from centerline import Centerline
from centerline.main import Centerline


class TestCenterlineSupportedGeometryTypes(TestCase):
Expand Down Expand Up @@ -64,21 +64,17 @@ def test__linestring__raises_valueerror(self):
Centerline(LINESTRING)

def test__multilinestring__raises_valueerror(self):
MULTILINESTRING = MultiLineString(
[((0, 0), (1, 1)), ((-1, 0), (1, 0))]
)
MULTILINESTRING = MultiLineString([((0, 0), (1, 1)), ((-1, 0), (1,
0))])

with self.assertRaises(ValueError):
Centerline(MULTILINESTRING)

def test__geometry_collection__raises_valueerror(self):
GEOMETRY_COLLECTION = GeometryCollection(
(
Point(0, 0),
LineString([(0, 0), (0.8, 0.8), (1.8, 0.95), (2.6, 0.5)]),
Polygon([[0, 0], [0, 4], [4, 4], [4, 0]])
)
)
(Point(0, 0),
LineString([(0, 0), (0.8, 0.8), (1.8, 0.95), (2.6, 0.5)]),
Polygon([[0, 0], [0, 4], [4, 4], [4, 0]])))

with self.assertRaises(ValueError):
Centerline(GEOMETRY_COLLECTION)
Expand All @@ -98,11 +94,7 @@ class TestCenterlineAttributes(TestCase):

def test__object_has_assigned_attributes(self):
POLYGON = Polygon([[0, 0], [0, 4], [4, 4], [4, 0]])
ATTRIBUTES = {
'id': 1,
'name': 'polygon',
'valid': True
}
ATTRIBUTES = {'id': 1, 'name': 'polygon', 'valid': True}

centerline = Centerline(POLYGON, **ATTRIBUTES)

Expand Down

0 comments on commit e0b47b8

Please sign in to comment.