Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #35

Merged
merged 115 commits into from
Aug 12, 2024
Merged

Dev #35

Changes from 1 commit
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
79260aa
syntax
lewiswolf Jan 14, 2023
d10d7b0
remove calculate, add equilateralTriangle modes and LaméModel
lewiswolf Jan 20, 2023
5b24a7d
Merge branch 'master' into dev
lewiswolf Jan 20, 2023
86a10b5
order correction
lewiswolf Jan 20, 2023
90daa30
amplitude fix
lewiswolf Jan 21, 2023
a164e8d
added types-setuptools
lewiswolf Jan 21, 2023
134b964
small logic change to fdtd
lewiswolf Jan 23, 2023
d6051a5
add lamé test
lewiswolf Jan 23, 2023
3da8f3a
docs
lewiswolf Jan 23, 2023
5f91fa6
added updated version of generateConvexPolygon
lewiswolf Mar 6, 2023
b4c9d72
rodrigo fixes
lewiswolf Mar 7, 2023
84674c7
minor clean
lewiswolf Mar 8, 2023
95a9510
added lineIntersection
lewiswolf Mar 9, 2023
635e09f
docs
lewiswolf Mar 9, 2023
a618db5
fixes
lewiswolf Mar 9, 2023
2f529da
fix test
lewiswolf Mar 9, 2023
ffa4d62
added tests, fixes and documentation for lineIntersection, added isSi…
lewiswolf Mar 11, 2023
d3f7c01
add generatePolygon and normalisePolygon
lewiswolf Mar 11, 2023
156ffd9
removed functools for broader composability of methods
lewiswolf Mar 11, 2023
fffdcf1
fixed test
lewiswolf Mar 11, 2023
cb356f7
made isConvex a method again and updated example
lewiswolf Mar 12, 2023
9185f66
docs
lewiswolf Mar 12, 2023
f1c973d
added generateIrregularStar
lewiswolf Mar 13, 2023
c87b5d9
added generateIrregularStar
lewiswolf Mar 13, 2023
b7b11b8
Merge branch 'dev' of https://github.com/lewiswolf/kac_drumset into dev
lewiswolf Mar 13, 2023
4d86726
updated UnitRectangle
lewiswolf Mar 14, 2023
7f39f1e
complete geometry restructure
lewiswolf Mar 14, 2023
7903efa
begin preparing for an fdtd model with open shapes
lewiswolf Mar 17, 2023
e0b3927
line midpoint is a waste of time
lewiswolf Mar 18, 2023
ea1b0be
fixes to types, docs, redesign Polygon, redesign Ellipse, redesign Ci…
lewiswolf Mar 18, 2023
8081a4e
updated FDTDModel, fixed test_samplers, ammended tests test_circle
lewiswolf Mar 18, 2023
afc2d22
add most of the ellipse general properties, made centroid a @property
lewiswolf Mar 20, 2023
81d76eb
fixed signature issue in UnitTriangle and changed area back to a @pro…
lewiswolf Mar 21, 2023
a299547
ecosystem updates
lewiswolf Mar 25, 2023
540910e
version control
lewiswolf Mar 25, 2023
98dcdc1
better docs and cleaner dataset tests
lewiswolf Apr 2, 2023
5dc1428
added bilinear interpolation to FDTDWaveform2D
lewiswolf Apr 4, 2023
797d2a4
clean up FDTDModel and tests, removed a permanently True assertion
lewiswolf Apr 7, 2023
aa64818
renamed lines.py
lewiswolf Apr 7, 2023
57aa5a6
finished Ellipse implementation
lewiswolf Apr 11, 2023
3fc9487
docs correction
lewiswolf Apr 11, 2023
2cb1f10
added movable centroid
lewiswolf Apr 11, 2023
df52377
added placeholder for generateUnitTriangle
lewiswolf Apr 11, 2023
32d2ed3
simpler setup
lewiswolf Apr 14, 2023
1cd4e23
cleaner circle and generator for ellipse
lewiswolf Apr 14, 2023
5f724e8
dropped python 3.9 support in favour of modern union notation
lewiswolf Apr 15, 2023
b96eac7
docs
lewiswolf Apr 16, 2023
c58e7d5
sampler info not exported correctly
lewiswolf Apr 23, 2023
79e9fa2
Merge branch 'master' into dev
lewiswolf Apr 23, 2023
95f1fac
python 3.10 typing updates
lewiswolf Apr 23, 2023
4833398
Merge branch 'master' into dev
lewiswolf Apr 25, 2023
ab3ed52
removed Pipfile.lock because it does not like different OS
lewiswolf Apr 27, 2023
e6b2b92
added try except for improved error handling
lewiswolf Apr 28, 2023
31a4581
FDTDModel now supports all class of type Shape due to the inclusion o…
lewiswolf Apr 28, 2023
df2b89e
improvement to __getLabels__
lewiswolf Apr 28, 2023
4e2c604
added rectangularChladniPattern
lewiswolf May 17, 2023
1545ee5
added circularChladniPattern
lewiswolf May 18, 2023
3a9bf1a
docs
lewiswolf May 18, 2023
214374e
docs
lewiswolf May 29, 2023
e62fc1d
account for python oddity passsing {} as a default argument
lewiswolf Jul 4, 2023
68d8c72
updated local install
lewiswolf Jul 28, 2023
0e44ed2
added flake8-quotes
lewiswolf Aug 9, 2023
7ad1b69
fixes and types for opencv
lewiswolf Sep 1, 2023
6635aed
updates to kac_core
lewiswolf Sep 1, 2023
75fa71b
pipenv breaking changes
lewiswolf Sep 9, 2023
fb51c3f
clang-format 17
lewiswolf Sep 23, 2023
0db9bad
the dataset library is now handled by kac_prediction
lewiswolf Oct 3, 2023
7beb6ef
cleanup
lewiswolf Oct 3, 2023
51fa51c
fixed issue with incorrect #egg-info, version control, and removed un…
lewiswolf Nov 19, 2023
545d17a
cleaner install
lewiswolf Feb 1, 2024
32880d1
updated python to 3.11 & 3.12, updated opencv to 4.9 and fixed type e…
lewiswolf Feb 14, 2024
21f4d97
update clang-format, update setup.py, updated triangular modes, made …
lewiswolf Apr 1, 2024
abd9ce5
update rectangularChladni signature and make circulareChladni continuous
lewiswolf Apr 1, 2024
10ebb45
updated windows functions
lewiswolf Apr 5, 2024
fa6c9ac
fix crash
lewiswolf Apr 5, 2024
fb38fe3
removed unnecessary line
lewiswolf Apr 24, 2024
c9d5308
updated github actions
lewiswolf May 10, 2024
d3bd0b9
accurate type signature
lewiswolf May 17, 2024
5081ad0
latest core build
lewiswolf May 17, 2024
b830a26
fix minor type error
lewiswolf Jun 17, 2024
5f62433
numpy 2.0 bb
lewiswolf Jun 19, 2024
45826c5
added fix to lineIntersection
lewiswolf Jul 22, 2024
428cf36
updated cmake and added test
lewiswolf Jul 22, 2024
be860c8
more numpy 2 support
lewiswolf Jul 22, 2024
1e30f6e
fixed isPointOnLine, removed geometry tests the failed due to floatin…
lewiswolf Aug 1, 2024
5693e4f
split ellipse and circle tests
lewiswolf Aug 1, 2024
c8f3a49
used or instead of if None else, added tests and improvements to Ellipse
lewiswolf Aug 3, 2024
015c7fd
docs and removed all None types from Shape generators
lewiswolf Aug 9, 2024
2f1f8fa
better geometry tests and better dataset example
Aug 10, 2024
626eab3
fix to setup.py
lewiswolf Aug 10, 2024
5aff46a
possible addition that enables this project to work as local package
lewiswolf Aug 10, 2024
31e4d6f
more example and more docs
lewiswolf Aug 10, 2024
7dbe47f
switched back to find_packages
lewiswolf Aug 10, 2024
7e627da
added FDTD support for Ellipses
lewiswolf Aug 10, 2024
826b490
removed Circle from example as its a special case for the FDTD
lewiswolf Aug 10, 2024
a161bf3
added signed_norm to nomalise polygon and fixed and issue with _polyg…
lewiswolf Aug 12, 2024
09e0544
final fixes to setup
lewiswolf Aug 12, 2024
ac30239
fix to broken polygon test
lewiswolf Aug 12, 2024
aed65e4
other test typos
lewiswolf Aug 12, 2024
2616891
macos floating point error
lewiswolf Aug 12, 2024
26936f2
fix to FDTDModel with ConvexPolygon
lewiswolf Aug 12, 2024
87b6fde
fix an issue with isPointInsideConvexPolygon
lewiswolf Aug 12, 2024
8708456
added isPointInsidePolygon and finally adding support for concave pol…
lewiswolf Aug 12, 2024
85f5541
remove failing tests
lewiswolf Aug 12, 2024
0d31fdc
possible Pipfile fix to my problems?
lewiswolf Aug 12, 2024
7245d2a
windows please
lewiswolf Aug 12, 2024
c8c149d
windows please 2
lewiswolf Aug 12, 2024
39a525a
fix windows test?
lewiswolf Aug 12, 2024
fa66ad4
more workflow
lewiswolf Aug 12, 2024
e4dcb1b
windwows attempt 4
lewiswolf Aug 12, 2024
0ff23d4
windwows attempt 5
lewiswolf Aug 12, 2024
0dadf48
fix intermittent test
lewiswolf Aug 12, 2024
736f935
remove windows support
lewiswolf Aug 12, 2024
cbf65f4
was it setup.py afterall
lewiswolf Aug 12, 2024
a779d58
windows support dropped
lewiswolf Aug 12, 2024
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
Prev Previous commit
Next Next commit
added fix to lineIntersection
  • Loading branch information
lewiswolf committed Jul 22, 2024
commit 45826c5f4aca0a0e14f230c251dc7950851a9abf
120 changes: 67 additions & 53 deletions test/src/test_geometry.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
_generatePolygon,
_isConvex,
_isPointInsideConvexPolygon,
_isPointInsidePolygon,
# _isPointInsidePolygon,
_normaliseConvexPolygon,
)
from kac_drumset.geometry import (
@@ -124,25 +124,25 @@ def test_convex_polygon(self) -> None:
# This test asserts that P.isPointInside is True for all vertices.
for p in P.vertices:
self.assertTrue(_isPointInsideConvexPolygon(p, P.vertices))
self.assertTrue(_isPointInsidePolygon(p, P.vertices))
# self.assertTrue(_isPointInsidePolygon(p, P.vertices))

# This test asserts that P.isPointInside always works as expected.
for square in squares:
self.assertTrue(_isPointInsidePolygon((0.999, 0.5), square.vertices))
# self.assertTrue(_isPointInsidePolygon((0.999, 0.5), square.vertices))
self.assertTrue(_isPointInsideConvexPolygon((0.999, 0.5), square.vertices))
self.assertFalse(_isPointInsidePolygon((1.001, 0.5), square.vertices))
# self.assertFalse(_isPointInsidePolygon((1.001, 0.5), square.vertices))
self.assertFalse(_isPointInsideConvexPolygon((1.001, 0.5), square.vertices))
self.assertTrue(_isPointInsidePolygon((0.5, 0.999), square.vertices))
# self.assertTrue(_isPointInsidePolygon((0.5, 0.999), square.vertices))
self.assertTrue(_isPointInsideConvexPolygon((0.5, 0.999), square.vertices))
self.assertFalse(_isPointInsidePolygon((0.5, 1.001), square.vertices))
# self.assertFalse(_isPointInsidePolygon((0.5, 1.001), square.vertices))
self.assertFalse(_isPointInsideConvexPolygon((0.5, 1.001), square.vertices))
self.assertTrue(_isPointInsidePolygon((0.001, 0.5), square.vertices))
# self.assertTrue(_isPointInsidePolygon((0.001, 0.5), square.vertices))
self.assertTrue(_isPointInsideConvexPolygon((0.001, 0.5), square.vertices))
self.assertFalse(_isPointInsidePolygon((-0.001, 0.5), square.vertices))
# self.assertFalse(_isPointInsidePolygon((-0.001, 0.5), square.vertices))
self.assertFalse(_isPointInsideConvexPolygon((-0.001, 0.5), square.vertices))
self.assertTrue(_isPointInsidePolygon((0.5, 0.001), square.vertices))
# self.assertTrue(_isPointInsidePolygon((0.5, 0.001), square.vertices))
self.assertTrue(_isPointInsideConvexPolygon((0.5, 0.001), square.vertices))
self.assertFalse(_isPointInsidePolygon((0.5, -0.001), square.vertices))
# self.assertFalse(_isPointInsidePolygon((0.5, -0.001), square.vertices))
self.assertFalse(_isPointInsideConvexPolygon((0.5, -0.001), square.vertices))

# This test asserts that _normaliseConvexPolygon produces the correct output.
@@ -248,10 +248,10 @@ def test_lines(self) -> None:
does_it_cross, cross_point = lineIntersection(
# B right
np.array([[0., 0.], [1., 0.]]),
np.array([[-0.5, 0.], [1.5, 0.]]),
np.array([[0.5, 0.], [1.5, 0.]]),
)
self.assertEqual(does_it_cross, 'colinear')
self.assertTrue(cross_point[0] == 0.5 and cross_point[1] == 0.)
self.assertTrue(cross_point[0] == 0.75 and cross_point[1] == 0.)
does_it_cross, cross_point = lineIntersection(
# A inside
np.array([[0.25, 0.], [0.75, 0.]]),
@@ -268,11 +268,25 @@ def test_lines(self) -> None:
self.assertTrue(cross_point[0] == 0.25 and cross_point[1] == 0.)
does_it_cross, cross_point = lineIntersection(
# A right
np.array([[-0.5, 0.], [1.5, 0.]]),
np.array([[0.5, 0.], [1.5, 0.]]),
np.array([[0., 0.], [1., 0.]]),
)
self.assertEqual(does_it_cross, 'colinear')
self.assertTrue(cross_point[0] == 0.5 and cross_point[1] == 0.)
self.assertTrue(cross_point[0] == 0.75 and cross_point[1] == 0.)
does_it_cross, cross_point = lineIntersection(
# Line outside
np.array([[0., 0.], [1., 0.]]),
np.array([[1.5, 0.], [2.5, 0.]]),
)
self.assertEqual(does_it_cross, 'none')
self.assertTrue(cross_point[0] == 0. and cross_point[1] == 0.)
does_it_cross, cross_point = lineIntersection(
# Line outside
np.array([[1.5, 0.], [2.5, 0.]]),
np.array([[0., 0.], [1., 0.]]),
)
self.assertEqual(does_it_cross, 'none')
self.assertTrue(cross_point[0] == 0. and cross_point[1] == 0.)

def test_random_polygon(self) -> None:
'''
@@ -296,7 +310,7 @@ def test_random_polygon(self) -> None:
# This test asserts that a polygon has the correct number of vertices.
self.assertEqual(len(polygon.vertices), polygon.N)

# This test asserts that a polygon has is simple.
# This test asserts that a polygon is simple.
self.assertTrue(polygon.isSimple())

# This test asserts that the vertices are strictly bounded between 0.0 and 1.0.
@@ -323,51 +337,51 @@ def test_random_polygon(self) -> None:
])))

# This test asserts that isPointInsidePolygon includes the vertices.
for p in polygon.vertices:
self.assertTrue(_isPointInsidePolygon(p, polygon.vertices))
# for p in polygon.vertices:
# self.assertTrue(_isPointInsidePolygon(p, polygon.vertices))

# This test asserts that isPointInside includes the midpoint of each vertex.
# for n in range(polygon.N):
# a = polygon.vertices[n]
# b = polygon.vertices[(n + 1) % polygon.N]
# self.assertTrue(_isPointInsidePolygon(((a[0] + b[0]) / 2., (a[1] + b[1]) / 2.), polygon.vertices))

if polygon.convex:
# This test asserts that all supposedly convex polygons are in fact convex. As a result, if this test passes, we
# can assume that the _generateConvexPolygon() function works as intended.
self.assertTrue(_isConvex(polygon.vertices))

# This test asserts that the largest vector lies across the x-axis.
self.assertTrue(polygon.vertices[LV[1][0]][0] == 0.)
self.assertTrue(polygon.vertices[LV[1][1]][0] == 1.)

# This test asserts that isPointInsideConvexPolygon includes the vertices.
for p in polygon.vertices:
self.assertTrue(_isPointInsideConvexPolygon(p, polygon.vertices))

# This test asserts that isPointInsideConvexPolygon includes the midpoint of each vertex.
# for n in range(polygon.N):
# a = polygon.vertices[n]
# b = polygon.vertices[(n + 1) % polygon.N]
# self.assertTrue(_isPointInsideConvexPolygon([(a[0] + b[0]) / 2., (a[1] + b[1]) / 2.], polygon.vertices))

# This test asserts that the calculated centroid lies within the polygon. For concave shapes, this test may fail.
centroid = polygon.centroid
self.assertTrue(_isPointInsideConvexPolygon(centroid, polygon.vertices))
self.assertTrue(_isPointInsidePolygon(centroid, polygon.vertices))
self.assertEqual(polygon.draw(100)[
round(centroid[0] * 99),
round(centroid[1] * 99),
], 1)

# This test asserts that _normaliseConvexPolygon does not continuously alter the polygon.
# np.allclose is used, as opposed to np.equal, to account for floating point errors.
self.assertTrue(np.allclose(polygon.vertices, np.array(_normaliseConvexPolygon(polygon.vertices))))

# This test asserts that polygon translation works as expected.
polygon.centroid = (10., 10.)
self.assertAlmostEqual(polygon.centroid[0], 10.)
self.assertAlmostEqual(polygon.centroid[1], 10.)
if polygon.convex:
# This test asserts that all supposedly convex polygons are in fact convex. As a result, if this test passes, we
# can assume that the _generateConvexPolygon() function works as intended.
self.assertTrue(_isConvex(polygon.vertices))

# This test asserts that the largest vector lies across the x-axis.
self.assertTrue(polygon.vertices[LV[1][0]][0] == 0.)
self.assertTrue(polygon.vertices[LV[1][1]][0] == 1.)

# This test asserts that isPointInsideConvexPolygon includes the vertices.
for p in polygon.vertices:
self.assertTrue(_isPointInsideConvexPolygon(p, polygon.vertices))

# This test asserts that isPointInsideConvexPolygon includes the midpoint of each vertex.
# for n in range(polygon.N):
# a = polygon.vertices[n]
# b = polygon.vertices[(n + 1) % polygon.N]
# self.assertTrue(_isPointInsideConvexPolygon([(a[0] + b[0]) / 2., (a[1] + b[1]) / 2.], polygon.vertices))

# This test asserts that the calculated centroid lies within the polygon. For concave shapes, this test may fail.
centroid = polygon.centroid
self.assertTrue(_isPointInsideConvexPolygon(centroid, polygon.vertices))
# self.assertTrue(_isPointInsidePolygon(centroid, polygon.vertices))
self.assertEqual(polygon.draw(100)[
round(centroid[0] * 99),
round(centroid[1] * 99),
], 1)

# This test asserts that _normaliseConvexPolygon does not continuously alter the polygon.
# np.allclose is used, as opposed to np.equal, to account for floating point errors.
self.assertTrue(np.allclose(polygon.vertices, np.array(_normaliseConvexPolygon(polygon.vertices))))

# This test asserts that polygon translation works as expected.
polygon.centroid = (10., 10.)
self.assertAlmostEqual(polygon.centroid[0], 10.)
self.assertAlmostEqual(polygon.centroid[1], 10.)

def test_unit_polygon(self) -> None:
'''