Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Guilhem Saurel
ndcurves
Commits
875a0ab4
Unverified
Commit
875a0ab4
authored
Feb 11, 2020
by
Fernbach Pierre
Committed by
GitHub
Feb 11, 2020
Browse files
Merge pull request #33 from pFernbach/devel
[Python] Fix issue #32
parents
5f14887a
d740879b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
include/curves/piecewise_curve.h
View file @
875a0ab4
...
...
@@ -212,9 +212,9 @@ struct piecewise_curve : public curve_abc<Time, Numeric, Safe, Point, Point_deri
std
::
size_t
num_curves
()
const
{
return
curves_
.
size
();
}
const
curve_ptr_t
&
curve_at_time
(
const
time_t
t
)
const
{
return
curves_
[
find_interval
(
t
)];
}
curve_ptr_t
curve_at_time
(
const
time_t
t
)
const
{
return
curves_
[
find_interval
(
t
)];
}
const
curve_ptr_t
&
curve_at_index
(
const
std
::
size_t
idx
)
const
{
curve_ptr_t
curve_at_index
(
const
std
::
size_t
idx
)
const
{
if
(
Safe
&&
idx
>=
num_curves
())
{
throw
std
::
length_error
(
"curve_at_index: requested index greater than number of curves in piecewise_curve instance"
);
...
...
python/curves/curves_python.cpp
View file @
875a0ab4
This diff is collapsed.
Click to expand it.
python/test/test.py
View file @
875a0ab4
...
...
@@ -360,6 +360,11 @@ class TestCurves(unittest.TestCase):
pc
.
derivate
(
0.4
,
2
)
pc
.
is_continuous
(
0
)
pc
.
is_continuous
(
1
)
a0
=
pc
.
curve_at_index
(
0
)
self
.
assertTrue
(
array_equal
(
a0
(
0.5
),
pc
(
0.5
)))
self
.
assertTrue
(
a0
==
a
)
a0
=
b
# should not have any effect
self
.
assertTrue
(
array_equal
(
pc
.
curve_at_index
(
0
)(
0.5
),
a
(
0.5
)))
# Test serialization
pc
.
saveAsText
(
"serialization_pc.test"
)
pc_test
=
piecewise
()
...
...
@@ -413,6 +418,13 @@ class TestCurves(unittest.TestCase):
for
i
in
range
(
N
):
self
.
assertTrue
(
isclose
(
polC0
(
time_points
[
i
,
0
]),
points
[:,
i
]).
all
())
c0
=
polC0
.
curve_at_index
(
0
)
self
.
assertEqual
(
c0
.
min
(),
time_points
[
0
])
self
.
assertEqual
(
c0
.
max
(),
time_points
[
1
])
self
.
assertEqual
(
c0
.
dim
(),
3
)
mid_t
=
(
c0
.
max
()
+
c0
.
min
())
/
2.
self
.
assertTrue
(
array_equal
(
polC0
(
mid_t
),
c0
(
mid_t
)))
polC1
=
piecewise
.
FromPointsList
(
points
,
points_derivative
,
time_points
)
self
.
assertEqual
(
polC1
.
min
(),
time_points
[
0
,
0
])
self
.
assertEqual
(
polC1
.
max
(),
time_points
[
-
1
,
0
])
...
...
@@ -500,6 +512,11 @@ class TestCurves(unittest.TestCase):
pc
.
derivate
(
0.4
,
2
)
pc
.
is_continuous
(
0
)
pc
.
is_continuous
(
1
)
a0
=
pc
.
curve_at_index
(
0
)
self
.
assertTrue
(
array_equal
(
a0
(
0.5
),
pc
(
0.5
)))
self
.
assertTrue
(
a0
==
a
)
a0
=
b
# should not have any effect
self
.
assertTrue
(
array_equal
(
pc
.
curve_at_index
(
0
)(
0.5
),
a
(
0.5
)))
# Test serialization
pc
.
saveAsText
(
"serialization_pc.test"
)
pc_test
=
piecewise
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment