Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Uhlmann Group
Python Spline Fitting Toolbox
Commits
6a300bc8
Verified
Commit
6a300bc8
authored
Mar 22, 2021
by
Julien Jerphanion
Browse files
Use private class attributes for error messages
parent
df1a0aa0
Pipeline
#140510
failed with stage
in 13 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
28 deletions
+28
-28
sft/spline/basis.py
sft/spline/basis.py
+13
-13
sft/spline/curve_models.py
sft/spline/curve_models.py
+15
-15
No files found.
sft/spline/basis.py
View file @
6a300bc8
...
...
@@ -7,7 +7,7 @@ import abc
class
Basis
(
abc
.
ABC
):
unimplemented
M
essage
=
"This method is not implemented."
_
unimplemented
_m
essage
=
"This method is not implemented."
def
__init__
(
self
,
multigenerator
,
support
):
self
.
multigenerator
=
multigenerator
...
...
@@ -15,27 +15,27 @@ class Basis(abc.ABC):
@
abc
.
abstractmethod
def
value
(
self
,
x
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
@
abc
.
abstractmethod
def
firstDerivativeValue
(
self
,
x
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
@
abc
.
abstractmethod
def
secondDerivativeValue
(
self
,
x
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
@
abc
.
abstractmethod
def
filterSymmetric
(
self
,
s
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
@
abc
.
abstractmethod
def
filterPeriodic
(
self
,
s
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
@
abc
.
abstractmethod
def
refinementMask
(
self
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
@
property
def
support
(
self
):
...
...
@@ -591,13 +591,13 @@ class H3(Basis):
return
val
def
filterPeriodic
(
self
,
s
):
raise
NotImplementedError
(
SplineGenerator
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
def
refinementMask
(
self
):
raise
NotImplementedError
(
SplineGenerator
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
def
filterSymmetric
(
self
,
s
):
raise
NotImplementedError
(
SplineGenerator
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
class
HE3
(
Basis
):
...
...
@@ -734,13 +734,13 @@ class HE3(Basis):
raise
RuntimeError
(
"HE3 isn't twice differentiable."
)
def
filterPeriodic
(
self
,
s
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
def
refinementMask
(
self
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
def
filterSymmetric
(
self
,
s
):
raise
NotImplementedError
(
Basis
.
unimplemented
M
essage
)
raise
NotImplementedError
(
Basis
.
_
unimplemented
_m
essage
)
def
multinomial
(
...
...
sft/spline/curve_models.py
View file @
6a300bc8
...
...
@@ -8,13 +8,13 @@ from scipy import integrate
class
SplineCurve
:
wrong
D
imension
M
essage
=
"It looks like coefs is a 2D array with second "
\
_
wrong
_d
imension
_m
essage
=
"It looks like coefs is a 2D array with second "
\
"dimension different than two. I don't know how "
\
"to handle this yet."
wrong
A
rray
S
ize
M
essage
=
"It looks like coefs is neither a 1 nor a 2D "
\
_
wrong
_a
rray
_s
ize
_m
essage
=
"It looks like coefs is neither a 1 nor a 2D "
\
"array. I don't know how to handle this yet."
no
C
oefs
M
essage
=
"This model doesn't have any coefficients."
unimplemented
M
essage
=
"This function is not implemented."
_
no
_c
oefs
_m
essage
=
"This model doesn't have any coefficients."
_
unimplemented
_m
essage
=
"This function is not implemented."
# A cache from pair (M, sampling_rate) to phi matrices
...
...
@@ -216,7 +216,7 @@ class SplineCurve:
def
draw
(
self
,
dimensions
):
if
self
.
coefs
is
None
:
raise
RuntimeError
(
self
.
no
C
oefs
M
essage
)
raise
RuntimeError
(
self
.
_
no
_c
oefs
_m
essage
)
if
len
(
self
.
coefs
.
shape
)
!=
2
or
self
.
coefs
.
shape
[
1
]
!=
2
:
raise
RuntimeError
(
"draw() can only be used with 2D curves."
)
...
...
@@ -276,12 +276,12 @@ class SplineCurve:
filter
=
self
.
basis
.
filterSymmetric
if
len
(
knots
.
shape
)
>
2
:
raise
RuntimeError
(
self
.
wrong
A
rray
S
ize
M
essage
)
raise
RuntimeError
(
self
.
_
wrong
_a
rray
_s
ize
_m
essage
)
elif
len
(
knots
.
shape
)
==
1
:
self
.
_coefs
=
filter
(
knots
)
elif
len
(
knots
.
shape
)
==
2
:
if
knots
.
shape
[
1
]
!=
2
:
raise
RuntimeError
(
self
.
wrong
D
imension
M
essage
)
raise
RuntimeError
(
self
.
_
wrong
_d
imension
_m
essage
)
else
:
coefsX
=
filter
(
knots
[:,
0
])
coefsY
=
filter
(
knots
[:,
1
])
...
...
@@ -420,7 +420,7 @@ class SplineCurve:
f
"even=true"
,
DeprecationWarning
)
if
self
.
coefs
is
None
:
raise
RuntimeError
(
self
.
no
C
oefs
M
essage
)
raise
RuntimeError
(
self
.
_
no
_c
oefs
_m
essage
)
if
len
(
self
.
coefs
.
shape
)
==
1
or
(
len
(
self
.
coefs
.
shape
)
==
2
and
self
.
coefs
.
shape
[
1
]
==
2
...
...
@@ -448,13 +448,13 @@ class SplineCurve:
curve
=
curve
[
~
np
.
all
(
curve
==
0
,
axis
=
1
)]
else
:
raise
RuntimeError
(
self
.
wrong
A
rray
S
ize
M
essage
)
raise
RuntimeError
(
self
.
_
wrong
_a
rray
_s
ize
_m
essage
)
return
np
.
stack
(
curve
)
def
parameterToWorld
(
self
,
t
,
dt
=
False
):
if
self
.
coefs
is
None
:
raise
RuntimeError
(
SplineCurve
.
no
C
oefs
M
essage
)
raise
RuntimeError
(
SplineCurve
.
_
no
_c
oefs
_m
essage
)
ts
=
np
.
array
([
self
.
_wrapIndex
(
t
,
k
)
for
k
in
range
(
self
.
M
)])
f
=
self
.
basis
.
firstDerivativeValue
if
dt
else
self
.
basis
.
value
...
...
@@ -522,24 +522,24 @@ class HermiteSplineCurve(SplineCurve):
raise
RuntimeError
(
self
.
coefTangentMismatchMessage
)
if
len
(
knots
.
shape
)
>
2
:
raise
RuntimeError
(
SplineCurve
.
wrong
A
rray
S
ize
M
essage
)
raise
RuntimeError
(
SplineCurve
.
_
wrong
_a
rray
_s
ize
_m
essage
)
if
len
(
knots
.
shape
)
==
2
and
knots
.
shape
[
1
]
!=
2
:
raise
RuntimeError
(
SplineCurve
.
wrong
D
imension
M
essage
)
raise
RuntimeError
(
SplineCurve
.
_
wrong
_d
imension
_m
essage
)
self
.
_coefs
=
knots
self
.
_tangents
=
tangentAtKnots
def
setCoefsFromDenseContour
(
self
,
contourPoints
,
tangentAtPoints
):
# TODO
raise
NotImplementedError
(
SplineCurve
.
unimplemented
M
essage
)
raise
NotImplementedError
(
SplineCurve
.
_
unimplemented
_m
essage
)
def
setCoefsFromBinaryMask
(
self
,
binaryMask
):
# TODO
raise
NotImplementedError
(
SplineCurve
.
unimplemented
M
essage
)
raise
NotImplementedError
(
SplineCurve
.
_
unimplemented
_m
essage
)
def
parameterToWorld
(
self
,
t
,
dt
=
False
):
if
self
.
coefs
is
None
:
raise
RuntimeError
(
SplineCurve
.
no
C
oefs
M
essage
)
raise
RuntimeError
(
SplineCurve
.
_
no
_c
oefs
_m
essage
)
value
=
0.0
for
k
in
range
(
0
,
self
.
M
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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