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
385e1bca
"git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "690a77fa6f6e3f301b77204f985669a237042b4e"
Commit
385e1bca
authored
Mar 31, 2018
by
rusty1s
Browse files
graclus assert method
parent
19374a65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
setup.py
setup.py
+1
-1
test/test_graclus.py
test/test_graclus.py
+22
-2
No files found.
setup.py
View file @
385e1bca
...
@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
...
@@ -5,7 +5,7 @@ from setuptools import setup, find_packages
__version__
=
'1.0.0'
__version__
=
'1.0.0'
url
=
'https://github.com/rusty1s/pytorch_cluster'
url
=
'https://github.com/rusty1s/pytorch_cluster'
install_requires
=
[
'cffi'
,
'torch-unique'
]
install_requires
=
[
'cffi'
]
setup_requires
=
[
'pytest-runner'
,
'cffi'
]
setup_requires
=
[
'pytest-runner'
,
'cffi'
]
tests_require
=
[
'pytest'
,
'pytest-cov'
]
tests_require
=
[
'pytest'
,
'pytest-cov'
]
...
...
test/test_graclus.py
View file @
385e1bca
import
torch
import
torch
import
numpy
as
np
from
torch_cluster
import
graclus_cluster
from
torch_cluster
import
graclus_cluster
def
assert_correct_graclus
(
row
,
col
,
cluster
):
row
,
col
,
cluster
=
row
.
numpy
(),
col
.
numpy
(),
cluster
.
numpy
()
# Every node was assigned a cluster.
assert
cluster
.
min
()
>=
0
# There are no more than two nodes in each cluster.
_
,
count
=
np
.
unique
(
cluster
,
return_counts
=
True
)
assert
(
count
>
2
).
max
()
==
0
# Corresponding clusters must be adjacent.
for
n
in
range
(
cluster
.
shape
[
0
]):
assert
(
cluster
[
col
[
row
==
n
]]
==
cluster
[
n
]).
max
()
==
1
def
test_graclus_cluster_cpu
():
def
test_graclus_cluster_cpu
():
row
=
torch
.
LongTensor
([
0
,
0
,
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
])
row
=
torch
.
LongTensor
([
0
,
0
,
1
,
1
,
1
,
2
,
2
,
2
,
3
,
3
])
col
=
torch
.
LongTensor
([
1
,
2
,
0
,
2
,
3
,
0
,
1
,
3
,
1
,
2
])
col
=
torch
.
LongTensor
([
1
,
2
,
0
,
2
,
3
,
0
,
1
,
3
,
1
,
2
])
weight_
=
torch
.
Tensor
([
1
,
2
,
1
,
3
,
2
,
2
,
3
,
1
,
2
,
1
])
weight
=
torch
.
Tensor
([
1
,
2
,
1
,
3
,
2
,
2
,
3
,
1
,
2
,
1
])
cluster
=
graclus_cluster
(
row
,
col
)
cluster
=
graclus_cluster
(
row
,
col
)
cluster
=
graclus_cluster
(
row
,
col
,
weight_
)
assert_correct_graclus
(
row
,
col
,
cluster
)
cluster
=
graclus_cluster
(
row
,
col
,
weight
)
assert_correct_graclus
(
row
,
col
,
cluster
)
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