Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PyAVA
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Loic Lehnhoff
PyAVA
Commits
6c450291
Commit
6c450291
authored
2 years ago
by
Loic-Lenof
Browse files
Options
Downloads
Patches
Plain Diff
Sorting points
+added sorting of points => points can be added anywhere on a line
parent
29bfa794
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
args.py
+1
-3
1 addition, 3 deletions
args.py
line_clicker/line_clicker.py
+19
-7
19 additions, 7 deletions
line_clicker/line_clicker.py
with
20 additions
and
10 deletions
args.py
+
1
−
3
View file @
6c450291
...
@@ -110,9 +110,7 @@ def fetch_inputs():
...
@@ -110,9 +110,7 @@ def fetch_inputs():
# verifying arguments
# verifying arguments
try
:
try
:
assert
(
os
.
path
.
exists
(
outputs
)),
(
assert
(
os
.
path
.
exists
(
outputs
)),
(
f
"
\n
InputError: Could not find dir
'
{
outputs
}
'
.
"
f
"
\n
InputError: Could not find dir
'
{
outputs
}
'
.
"
)
"
\n\t
Create a folder that will contain outputs,
"
"
or type in an existing folder with `-out folder_name`.
"
)
assert
(
os
.
path
.
exists
(
explore
)),
(
assert
(
os
.
path
.
exists
(
explore
)),
(
f
"
\n
InputError: Could not find dir
'
{
explore
}
'
.
"
)
f
"
\n
InputError: Could not find dir
'
{
explore
}
'
.
"
)
if
modify_file
:
if
modify_file
:
...
...
This diff is collapsed.
Click to expand it.
line_clicker/line_clicker.py
+
19
−
7
View file @
6c450291
...
@@ -3,6 +3,7 @@ Add default parameters for keys and mousebutton so it can be customized
...
@@ -3,6 +3,7 @@ Add default parameters for keys and mousebutton so it can be customized
"""
"""
##### IMPORTATIONS ######
##### IMPORTATIONS ######
import
warnings
import
numpy
as
np
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
matplotlib.pyplot
as
plt
from
matplotlib.backend_bases
import
MouseButton
from
matplotlib.backend_bases
import
MouseButton
...
@@ -11,7 +12,7 @@ import matplotlib.lines as mlines
...
@@ -11,7 +12,7 @@ import matplotlib.lines as mlines
from
scipy.interpolate
import
interp1d
from
scipy.interpolate
import
interp1d
##### FUNCTIONS #####
##### FUNCTIONS #####
def
to_curve
(
x
,
y
,
kind
):
def
to_curve
(
x
,
y
,
kind
=
"
quadratic
"
):
"""
"""
A function to compute a curvy line between two points.
A function to compute a curvy line between two points.
It interpolates a line with 100 points.
It interpolates a line with 100 points.
...
@@ -36,12 +37,14 @@ def to_curve(x, y, kind):
...
@@ -36,12 +37,14 @@ def to_curve(x, y, kind):
yi : numpy array
yi : numpy array
List of the coordinates of the curve on y-axis.
List of the coordinates of the curve on y-axis.
"""
"""
i
=
np
.
arange
(
len
(
x
))
interp_i
=
np
.
linspace
(
0
,
i
.
max
(),
100
*
i
.
max
())
y
=
y
[
np
.
argsort
(
x
)]
x
=
np
.
sort
(
x
)
xi
=
interp1d
(
i
,
x
,
kind
=
kind
)(
interp_i
)
f
=
interp1d
(
x
,
y
,
kind
=
kind
)
yi
=
interp1d
(
i
,
y
,
kind
=
kind
)(
interp_i
)
xi
=
np
.
linspace
(
x
.
min
(),
x
.
max
(),
100
*
(
len
(
x
)
-
1
))
yi
=
f
(
xi
)
return
xi
,
yi
return
xi
,
yi
...
@@ -360,6 +363,15 @@ class clicker(object):
...
@@ -360,6 +363,15 @@ class clicker(object):
None : updates coords, figure_lines, figure.
None : updates coords, figure_lines, figure.
"""
"""
if
self
.
legend_labels
[
self
.
current_line
]
in
list
(
self
.
coords
.
keys
()):
if
self
.
legend_labels
[
self
.
current_line
]
in
list
(
self
.
coords
.
keys
()):
# does this point already exists ?
if
[
x
,
y
]
in
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]]:
warnings
.
warn
(
"
This point already exists!
"
,
UserWarning
,
stacklevel
=
2
)
else
:
# where should it be inserted ?
here
=
np
.
where
(
np
.
array
(
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]])[:,
0
]
>
x
)[
0
]
if
len
(
here
):
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]].
insert
(
here
[
0
]
,[
x
,
y
])
else
:
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]]
+=
[[
x
,
y
]]
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]]
+=
[[
x
,
y
]]
else
:
else
:
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]]
=
[[
x
,
y
]]
self
.
coords
[
self
.
legend_labels
[
self
.
current_line
]]
=
[[
x
,
y
]]
...
@@ -392,7 +404,7 @@ class clicker(object):
...
@@ -392,7 +404,7 @@ class clicker(object):
curves
=
to_curve
(
curves
=
to_curve
(
np
.
array
(
self
.
coords
[
legend_label
])[:,
0
],
np
.
array
(
self
.
coords
[
legend_label
])[:,
0
],
np
.
array
(
self
.
coords
[
legend_label
])[:,
1
],
np
.
array
(
self
.
coords
[
legend_label
])[:,
1
],
kind
=
"
quadratic
"
)
kind
=
self
.
bspline
)
self
.
figure_bsplines
+=
[
mlines
.
Line2D
(
curves
[
0
],
curves
[
1
],
self
.
figure_bsplines
+=
[
mlines
.
Line2D
(
curves
[
0
],
curves
[
1
],
label
=
legend_label
,
label
=
legend_label
,
color
=
self
.
colors
[
idx
%
len
(
self
.
colors
)],
color
=
self
.
colors
[
idx
%
len
(
self
.
colors
)],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment