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-scatter
Commits
0961269f
Commit
0961269f
authored
Jun 23, 2019
by
rusty1s
Browse files
test empty std
parent
ec8477ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
test/test_std.py
test/test_std.py
+11
-2
No files found.
test/test_std.py
View file @
0961269f
...
@@ -6,10 +6,10 @@ from torch_scatter import scatter_std
...
@@ -6,10 +6,10 @@ from torch_scatter import scatter_std
from
.utils
import
grad_dtypes
as
dtypes
,
devices
,
tensor
from
.utils
import
grad_dtypes
as
dtypes
,
devices
,
tensor
biass
=
[
True
,
False
]
bias
e
s
=
[
True
,
False
]
@
pytest
.
mark
.
parametrize
(
'dtype,device,bias'
,
product
(
dtypes
,
devices
,
biass
))
@
pytest
.
mark
.
parametrize
(
'dtype,device,bias'
,
product
(
dtypes
,
devices
,
bias
e
s
))
def
test_std
(
dtype
,
device
,
bias
):
def
test_std
(
dtype
,
device
,
bias
):
src
=
tensor
([[
2
,
0
,
1
,
4
,
3
],
[
0
,
2
,
1
,
3
,
4
]],
dtype
,
device
)
src
=
tensor
([[
2
,
0
,
1
,
4
,
3
],
[
0
,
2
,
1
,
3
,
4
]],
dtype
,
device
)
index
=
tensor
([[
0
,
0
,
0
,
0
,
0
],
[
1
,
1
,
1
,
1
,
1
]],
torch
.
long
,
device
)
index
=
tensor
([[
0
,
0
,
0
,
0
,
0
],
[
1
,
1
,
1
,
1
,
1
]],
torch
.
long
,
device
)
...
@@ -18,3 +18,12 @@ def test_std(dtype, device, bias):
...
@@ -18,3 +18,12 @@ def test_std(dtype, device, bias):
std
=
src
.
std
(
dim
=-
1
,
unbiased
=
bias
)[
0
].
item
()
std
=
src
.
std
(
dim
=-
1
,
unbiased
=
bias
)[
0
].
item
()
expected
=
tensor
([[
std
,
0
],
[
0
,
std
]],
dtype
,
device
)
expected
=
tensor
([[
std
,
0
],
[
0
,
std
]],
dtype
,
device
)
assert
torch
.
allclose
(
out
,
expected
)
assert
torch
.
allclose
(
out
,
expected
)
@
pytest
.
mark
.
parametrize
(
'dtype,device'
,
product
(
dtypes
,
devices
))
def
test_empty_std
(
dtype
,
device
):
src
=
tensor
([],
dtype
,
device
)
index
=
tensor
([],
torch
.
long
,
device
)
out
=
scatter_std
(
src
,
index
,
dim
=-
1
)
assert
out
.
tolist
()
==
[]
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