Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-cluster
Commits
d5c8a4df
Commit
d5c8a4df
authored
Feb 26, 2018
by
rusty1s
Browse files
100% codecov
parent
79b935c7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
2 deletions
+19
-2
test/dense_grid.json
test/dense_grid.json
+10
-0
test/sparse_grid.json
test/sparse_grid.json
+6
-0
torch_cluster/functions/grid.py
torch_cluster/functions/grid.py
+3
-2
No files found.
test/dense_grid.json
View file @
d5c8a4df
...
@@ -37,6 +37,16 @@
...
@@ -37,6 +37,16 @@
"batch"
:
[
0
,
0
,
0
,
0
,
0
,
1
,
1
],
"batch"
:
[
0
,
0
,
0
,
0
,
0
,
1
,
1
],
"expected"
:
[
0
,
5
,
1
,
0
,
2
,
6
,
9
],
"expected"
:
[
0
,
5
,
1
,
0
,
2
,
6
,
9
],
"expected_C"
:
6
"expected_C"
:
6
},
{
"name"
:
"Batch with start/end parameter"
,
"position"
:
[[
0
,
0
],
[
11
,
9
],
[
2
,
8
],
[
2
,
2
],
[
8
,
3
],
[
1
,
1
],
[
6
,
6
]],
"size"
:
[
5
,
5
],
"batch"
:
[
0
,
0
,
0
,
0
,
0
,
1
,
1
],
"start"
:
0
,
"end"
:
20
,
"expected"
:
[
0
,
9
,
1
,
0
,
4
,
16
,
21
],
"expected_C"
:
16
}
}
]
]
test/sparse_grid.json
View file @
d5c8a4df
...
@@ -31,5 +31,11 @@
...
@@ -31,5 +31,11 @@
"batch"
:
[
0
,
0
,
0
,
0
,
0
,
1
,
1
],
"batch"
:
[
0
,
0
,
0
,
0
,
0
,
1
,
1
],
"expected"
:
[
0
,
3
,
1
,
0
,
2
,
4
,
5
],
"expected"
:
[
0
,
3
,
1
,
0
,
2
,
4
,
5
],
"expected_batch"
:
[
0
,
0
,
0
,
0
,
1
,
1
]
"expected_batch"
:
[
0
,
0
,
0
,
0
,
1
,
1
]
},
{
"name"
:
"Position tensor"
,
"position"
:
[[[
0
,
0
],
[
9
,
9
]],
[[
0
,
0
],
[
9
,
0
]]],
"size"
:
[
5
,
5
],
"expected"
:
[[
0
,
2
],
[
0
,
1
]]
}
}
]
]
torch_cluster/functions/grid.py
View file @
d5c8a4df
...
@@ -48,12 +48,13 @@ def _fixed_cluster_size(position, size, batch=None, end=None):
...
@@ -48,12 +48,13 @@ def _fixed_cluster_size(position, size, batch=None, end=None):
if
end
is
None
:
if
end
is
None
:
return
_minimal_cluster_size
(
position
,
size
)
return
_minimal_cluster_size
(
position
,
size
)
eps
=
0.000001
#
Model
[start, end).
eps
=
0.000001
#
Simulate
[start, end)
interval
.
if
batch
is
None
:
if
batch
is
None
:
cluster_size
=
((
end
/
size
).
float
()
-
eps
).
long
()
+
1
cluster_size
=
((
end
/
size
).
float
()
-
eps
).
long
()
+
1
else
:
else
:
cluster_size
=
((
end
/
size
[
1
:]).
float
()
-
eps
).
long
()
+
1
cluster_size
=
((
end
/
size
[
1
:]).
float
()
-
eps
).
long
()
+
1
cluster_size
=
torch
.
cat
([
batch
.
max
()
+
1
,
cluster_size
],
dim
=
0
)
max_batch
=
cluster_size
.
new
(
1
).
fill_
(
batch
.
max
()
+
1
)
cluster_size
=
torch
.
cat
([
max_batch
,
cluster_size
],
dim
=
0
)
return
cluster_size
return
cluster_size
...
...
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