pode 0.3.1__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pode
3
- Version: 0.3.1
3
+ Version: 0.4.3
4
4
  Summary: Implementation of an algorithm for a polygon decomposition by Hert, S. and Lumelsky, V., 1998
5
5
  Author: GeorgySk
6
6
  Author-email: skorobogatovgeorgy@gmail.com
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3.8
10
10
  Classifier: Programming Language :: Python :: 3.9
11
11
  Classifier: Programming Language :: Python :: 3.10
12
12
  Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
13
14
  Requires-Dist: gon (>=5.0.0,<6.0.0)
14
15
  Requires-Dist: ground (>=8.1.0,<9.0.0)
15
16
  Requires-Dist: networkx (>=2.8.8,<3.0.0)
@@ -85,8 +86,11 @@ Usage
85
86
  >>> polygon = Polygon(contour)
86
87
  >>> requirements = [Requirement(0.5), Requirement(0.5, point=Point(1, 1))]
87
88
  >>> parts = divide(polygon, requirements)
88
- assert parts[0].area == parts[1].area < polygon.area
89
- assert Point(1, 1) in parts[1]
89
+ >>> parts[0].area == parts[1].area < polygon.area
90
+ True
91
+ >>> Point(1, 1) in parts[1]
92
+ True
93
+
90
94
  ```
91
95
  Currently, the algorithm uses constrained Delaunay triangulation to form convex
92
96
  parts which are used internally for a convex-polygon partition.
@@ -110,7 +114,7 @@ Development
110
114
  #### Preparation
111
115
 
112
116
  Install
113
- [bump2version](https://github.com/c4urself/bump2version#installation).
117
+ [bump-my-version](https://github.com/callowayproject/bump-my-version?tab=readme-ov-file#installation).
114
118
 
115
119
  #### Pre-release
116
120
 
@@ -119,7 +123,7 @@ specification](http://semver.org/).
119
123
 
120
124
  Test bumping version
121
125
  ```bash
122
- bump2version --dry-run --verbose $CATEGORY
126
+ bump-my-version bump --dry-run --verbose $CATEGORY
123
127
  ```
124
128
 
125
129
  where `$CATEGORY` is the target version number category name, possible
@@ -127,7 +131,7 @@ values are `patch`/`minor`/`major`.
127
131
 
128
132
  Bump version
129
133
  ```bash
130
- bump2version --verbose $CATEGORY
134
+ bump-my-version bump --verbose $CATEGORY
131
135
  ```
132
136
 
133
137
  This will set version to `major.minor.patch-alpha`.
@@ -136,12 +140,12 @@ This will set version to `major.minor.patch-alpha`.
136
140
 
137
141
  Test bumping version
138
142
  ```bash
139
- bump2version --dry-run --verbose release
143
+ bump-my-version bump --dry-run --verbose release
140
144
  ```
141
145
 
142
146
  Bump version
143
147
  ```bash
144
- bump2version --verbose release
148
+ bump-my-version bump --verbose release
145
149
  ```
146
150
 
147
151
  This will set version to `major.minor.patch`.
@@ -67,8 +67,11 @@ Usage
67
67
  >>> polygon = Polygon(contour)
68
68
  >>> requirements = [Requirement(0.5), Requirement(0.5, point=Point(1, 1))]
69
69
  >>> parts = divide(polygon, requirements)
70
- assert parts[0].area == parts[1].area < polygon.area
71
- assert Point(1, 1) in parts[1]
70
+ >>> parts[0].area == parts[1].area < polygon.area
71
+ True
72
+ >>> Point(1, 1) in parts[1]
73
+ True
74
+
72
75
  ```
73
76
  Currently, the algorithm uses constrained Delaunay triangulation to form convex
74
77
  parts which are used internally for a convex-polygon partition.
@@ -92,7 +95,7 @@ Development
92
95
  #### Preparation
93
96
 
94
97
  Install
95
- [bump2version](https://github.com/c4urself/bump2version#installation).
98
+ [bump-my-version](https://github.com/callowayproject/bump-my-version?tab=readme-ov-file#installation).
96
99
 
97
100
  #### Pre-release
98
101
 
@@ -101,7 +104,7 @@ specification](http://semver.org/).
101
104
 
102
105
  Test bumping version
103
106
  ```bash
104
- bump2version --dry-run --verbose $CATEGORY
107
+ bump-my-version bump --dry-run --verbose $CATEGORY
105
108
  ```
106
109
 
107
110
  where `$CATEGORY` is the target version number category name, possible
@@ -109,7 +112,7 @@ values are `patch`/`minor`/`major`.
109
112
 
110
113
  Bump version
111
114
  ```bash
112
- bump2version --verbose $CATEGORY
115
+ bump-my-version bump --verbose $CATEGORY
113
116
  ```
114
117
 
115
118
  This will set version to `major.minor.patch-alpha`.
@@ -118,12 +121,12 @@ This will set version to `major.minor.patch-alpha`.
118
121
 
119
122
  Test bumping version
120
123
  ```bash
121
- bump2version --dry-run --verbose release
124
+ bump-my-version bump --dry-run --verbose release
122
125
  ```
123
126
 
124
127
  Bump version
125
128
  ```bash
126
- bump2version --verbose release
129
+ bump-my-version bump --verbose release
127
130
  ```
128
131
 
129
132
  This will set version to `major.minor.patch`.
@@ -1,5 +1,5 @@
1
1
  """Polygon decomposition"""
2
- __version__ = '0.3.1'
2
+ __version__ = '0.4.3'
3
3
 
4
4
  from .pode import (divide,
5
5
  Contour,
@@ -25,7 +25,8 @@ from gon.base import (Contour,
25
25
  Point,
26
26
  Polygon,
27
27
  Segment,
28
- Triangulation)
28
+ Triangulation,
29
+ Vector)
29
30
  from gon.hints import Maybe
30
31
  from ground.base import get_context
31
32
 
@@ -555,6 +556,34 @@ def split(*,
555
556
  return a, b
556
557
  else:
557
558
  ps = Multipoint([low_area_point, high_area_point]).centroid
559
+ if (Vector(low_area_point, pivot_point).orientation_of(ps)
560
+ is Orientation.COLLINEAR):
561
+ index = pivot_index
562
+ while True:
563
+ index -= 1
564
+ temp_point = vertices[index]
565
+ if Vector(low_area_point, pivot_point).orientation_of(
566
+ temp_point) is not Orientation.COLLINEAR:
567
+ new_splitter_tail = Multipoint(
568
+ [temp_point, vertices[index + 1]]).centroid
569
+ break
570
+ new_splitter_head = edge.centroid
571
+ splitter = Segment(new_splitter_tail, new_splitter_head)
572
+ plr_1 = graph.plr(polygon, splitter)
573
+ pll_1 = graph.pll(polygon, splitter)
574
+ pred_by_line = graph.pred_poly_by_line(polygon, edge)
575
+ a = graph.subgraph(pred_by_line)
576
+ b = to_subgraph(predecessors=plr_1.predecessors - pred_by_line,
577
+ old_root=polygon,
578
+ new_root=plr_1.root,
579
+ sites=right_sites,
580
+ graph=graph)
581
+ c = to_subgraph(predecessors=pll_1.predecessors - pred_by_line,
582
+ old_root=polygon,
583
+ new_root=pll_1.root,
584
+ sites=sites - right_sites,
585
+ graph=graph)
586
+ return b, a, c
558
587
  triangle = Polygon(Contour([low_area_point, ps, pivot_point]))
559
588
  edge = (Segment(low_area_point, high_area_point)
560
589
  if pivot_index == 0
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "pode"
3
- version = "0.3.1"
3
+ version = "0.4.3"
4
4
  description = "Implementation of an algorithm for a polygon decomposition by Hert, S. and Lumelsky, V., 1998"
5
5
  authors = ["GeorgySk <skorobogatovgeorgy@gmail.com>"]
6
6
  readme = "README.md"
@@ -13,11 +13,18 @@ networkx = "^2.8.8"
13
13
  sect = "^6.1.0"
14
14
 
15
15
  [tool.poetry.group.dev.dependencies]
16
+ bump-my-version = "^0.18.3"
16
17
  pytest = "^7.2.0"
17
18
  pytest-cov = "^4.0.0"
18
- hypothesis = "^6.61.0"
19
+ hypothesis = "6.99.1"
19
20
  hypothesis-geometry = "^7.3.0"
20
21
 
21
22
  [build-system]
22
23
  requires = ["poetry-core", "poetry>=1.0"]
23
24
  build-backend = "poetry.core.masonry.api"
25
+
26
+ [tool.coverage.run]
27
+ source = ["pode"]
28
+
29
+ [tool.pytest.ini_options]
30
+ addopts = "--verbose -s --hypothesis-profile=default"
pode-0.3.1/setup.py DELETED
@@ -1,33 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['pode']
6
-
7
- package_data = \
8
- {'': ['*']}
9
-
10
- install_requires = \
11
- ['gon>=5.0.0,<6.0.0',
12
- 'ground>=8.1.0,<9.0.0',
13
- 'networkx>=2.8.8,<3.0.0',
14
- 'sect>=6.1.0,<7.0.0']
15
-
16
- setup_kwargs = {
17
- 'name': 'pode',
18
- 'version': '0.3.1',
19
- 'description': 'Implementation of an algorithm for a polygon decomposition by Hert, S. and Lumelsky, V., 1998',
20
- 'long_description': 'pode\n===========\n\n\n[![](https://travis-ci.org/LostFan123/pode.svg?branch=master)](https://travis-ci.org/LostFan123/pode "Travis CI")\n[![](https://dev.azure.com/skorobogatov/pode/_apis/build/status/LostFan123.pode?branchName=master)](https://dev.azure.com/skorobogatov/pode/_build/latest?definitionId=2&branchName=master "Azure Pipelines")\n[![](https://codecov.io/gh/LostFan123/pode/branch/master/graph/badge.svg)](https://codecov.io/gh/LostFan123/pode "Codecov")\n[![](https://img.shields.io/github/license/LostFan123/pode.svg)](https://github.com/LostFan123/pode/blob/master/LICENSE "License")\n[![](https://badge.fury.io/py/pode.svg)](https://badge.fury.io/py/pode "PyPI")\n\nSummary\n-------\n\n`pode` is a Python library that implements an algorithm of \n[Hert, S. and Lumelsky, V., 1998](https://www.worldscientific.com/doi/abs/10.1142/S0218195998000230)\nfor a polygon decomposition into separate parts depending on the area \nrequirements.\n\nMain features are\n- all calculations are robust for floating point numbers\n& precise for integral numbers (like `int`)\n- support for partition of convex/nonconvex polygons with/without holes\n- support for anchored partition, free partition, and a mixture of both \nwhere anchored polygon partition requires the resulting polygon parts to \ncontain specified points called "anchors" or "sites", and free partition does \nnot have any constraints on the resulting geometries. \n- most of the code is covered with property-based tests.\n---\n\nIn what follows\n- `python` is an alias for `python3.8` or any later\nversion (`python3.9` and so on).\n\nInstallation\n------------\n\nInstall the latest `pip` & `setuptools` packages versions:\n ```bash\n python -m pip install --upgrade pip setuptools\n ```\n\n### User\n\nDownload and install the latest stable version from `PyPI` repository:\n ```bash\n python -m pip install --upgrade pode\n ```\n\n### Developer\n\nDownload the latest version from `GitHub` repository\n```bash\ngit clone https://github.com/LostFan123/pode.git\ncd pode\n```\n\nInstall dependencies:\n ```bash\n poetry install\n ```\n\nUsage\n-----\n```python\n>>> from pode import divide, Contour, Point, Polygon, Requirement\n>>> contour = Contour([Point(0, 0), Point(1, 0), Point(1, 1), Point(0, 1)])\n>>> polygon = Polygon(contour)\n>>> requirements = [Requirement(0.5), Requirement(0.5, point=Point(1, 1))]\n>>> parts = divide(polygon, requirements)\nassert parts[0].area == parts[1].area < polygon.area\nassert Point(1, 1) in parts[1]\n```\nCurrently, the algorithm uses constrained Delaunay triangulation to form convex \nparts which are used internally for a convex-polygon partition.\nThis triangulation, however, affects the resulting partition. The resulting \nparts can have zigzag pattern separating different parts. In this way, the \nsolution can be far from being optimal in sense of the number of sides of the\nresulting polygons. Alternatively, we implemented a helper function that would \njoin neighboring triangles if they form a larger convex part. It can be \nimported as `from pode import joined_constrained_delaunay_triangles` and used\nas `divide(polygon, requirements, joined_constrained_delaunay_triangles)`. But, \nin the future, a better algorithm should be implemented, like \n[Greene, D.H., 1983](https://www.goodreads.com/book/show/477772.Advances_in_Computing_Research_Volume_1) \nor [Chazelle, B. and Dobkin, D., 1979](https://dl.acm.org/doi/abs/10.1145/800135.804396).\n\n\nDevelopment\n-----------\n\n### Bumping version\n\n#### Preparation\n\nInstall\n[bump2version](https://github.com/c4urself/bump2version#installation).\n\n#### Pre-release\n\nChoose which version number category to bump following [semver\nspecification](http://semver.org/).\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose $CATEGORY\n```\n\nwhere `$CATEGORY` is the target version number category name, possible\nvalues are `patch`/`minor`/`major`.\n\nBump version\n```bash\nbump2version --verbose $CATEGORY\n```\n\nThis will set version to `major.minor.patch-alpha`. \n\n#### Release\n\nTest bumping version\n```bash\nbump2version --dry-run --verbose release\n```\n\nBump version\n```bash\nbump2version --verbose release\n```\n\nThis will set version to `major.minor.patch`.\n\n#### Notes\n\nTo avoid inconsistency between branches and pull requests,\nbumping version should be merged into `master` branch \nas separate pull request.\n\n### Running tests\n\nPlain:\n ```bash\n pytest\n ```\n\nInside `Docker` container:\n ```bash\n docker-compose --file docker-compose.cpython.yml up\n ```\n\n`Bash` script (e.g. can be used in `Git` hooks):\n ```bash\n ./run-tests.sh\n ```\n or\n ```bash\n ./run-tests.sh cpython\n ```\n\n`PowerShell` script (e.g. can be used in `Git` hooks):\n ```powershell\n .\\run-tests.ps1\n ```\n or\n ```powershell\n .\\run-tests.ps1 cpython\n ```\n',
21
- 'author': 'GeorgySk',
22
- 'author_email': 'skorobogatovgeorgy@gmail.com',
23
- 'maintainer': 'None',
24
- 'maintainer_email': 'None',
25
- 'url': 'None',
26
- 'packages': packages,
27
- 'package_data': package_data,
28
- 'install_requires': install_requires,
29
- 'python_requires': '>=3.8,<4.0',
30
- }
31
-
32
-
33
- setup(**setup_kwargs)
File without changes
File without changes
File without changes