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
0d9699b5
Commit
0d9699b5
authored
Dec 21, 2017
by
rusty1s
Browse files
doctests
parent
ea62ccd2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
13 deletions
+31
-13
docs/source/conf.py
docs/source/conf.py
+9
-6
setup.py
setup.py
+2
-1
torch_scatter/functions/add.py
torch_scatter/functions/add.py
+20
-6
No files found.
docs/source/conf.py
View file @
0d9699b5
...
@@ -2,14 +2,16 @@ import os
...
@@ -2,14 +2,16 @@ import os
import
sys
import
sys
import
datetime
import
datetime
import
sphinx_rtd_theme
import
sphinx_rtd_theme
import
doctest
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
'../..'
))
sys
.
path
.
insert
(
0
,
os
.
path
.
abspath
(
'../..'
))
from
torch_scatter
import
__version__
from
torch_scatter
import
__version__
# noqa
extensions
=
[
extensions
=
[
'sphinx.ext.autodoc'
,
'sphinx.ext.autodoc'
,
'sphinx.ext.doctest'
,
'sphinx.ext.doctest'
,
'sphinx.ext.intersphinx'
,
'sphinx.ext.mathjax'
,
'sphinx.ext.mathjax'
,
'sphinx.ext.napoleon'
,
'sphinx.ext.napoleon'
,
'sphinx.ext.viewcode'
,
'sphinx.ext.viewcode'
,
...
@@ -19,12 +21,13 @@ extensions = [
...
@@ -19,12 +21,13 @@ extensions = [
source_suffix
=
'.rst'
source_suffix
=
'.rst'
master_doc
=
'index'
master_doc
=
'index'
project
=
'pytorch_scatter'
copyright
=
'{}, Matthias Fey'
.
format
(
datetime
.
datetime
.
now
().
year
)
author
=
'Matthias Fey'
author
=
'Matthias Fey'
project
=
'pytorch_scatter'
version
=
__version__
copyright
=
'{}, {}'
.
format
(
datetime
.
datetime
.
now
().
year
,
author
)
release
=
__version__
version
=
release
=
__version__
html_theme
=
'sphinx_rtd_theme'
html_theme
=
'sphinx_rtd_theme'
html_theme_path
=
[
sphinx_rtd_theme
.
get_html_theme_path
()]
html_theme_path
=
[
sphinx_rtd_theme
.
get_html_theme_path
()]
doctest_default_flags
=
doctest
.
NORMALIZE_WHITESPACE
intersphinx_mapping
=
{
'python'
:
(
'https://docs.python.org/'
,
None
)}
setup.py
View file @
0d9699b5
from
os
import
path
as
osp
from
os
import
path
as
osp
from
setuptools
import
setup
,
find_packages
from
setuptools
import
setup
,
find_packages
import
build
# noqa
from
torch_scatter
import
__version__
from
torch_scatter
import
__version__
import
build
# noqa
install_requires
=
[
'cffi'
]
install_requires
=
[
'cffi'
]
setup_requires
=
[
'pytest-runner'
,
'cffi'
]
setup_requires
=
[
'pytest-runner'
,
'cffi'
]
tests_require
=
[
'pytest'
]
tests_require
=
[
'pytest'
]
...
...
torch_scatter/functions/add.py
View file @
0d9699b5
...
@@ -30,18 +30,32 @@ def scatter_add_(output, index, input, dim=0):
...
@@ -30,18 +30,32 @@ def scatter_add_(output, index, input, dim=0):
input (Tensor): The source tensor
input (Tensor): The source tensor
dim (int, optional): The axis along which to index
dim (int, optional): The axis along which to index
Example
::
.. testsetup
::
>> input = torch.Tensor([[2, 0, 1, 4, 3], [0,2, 1, 3, 4]])
import torch
>> index = torch.LongTensor([[4, 5, 2, 3], [0, 0, 2, 2, 1]])
from torch_scatter import scatter_add_
>> output = torch.zeros(2, 6)
>> scatter_add_(output, index, input, dim=1)
.. testcode::
input = torch.Tensor([[2, 0, 1, 4, 3], [0, 2, 1, 3, 4]])
index = torch.LongTensor([[4, 5, 4, 2, 3], [0, 0, 2, 2, 1]])
output = torch.zeros(2, 6)
scatter_add_(output, index, input, dim=1)
print(output)
.. testoutput::
0 0 4 3 3 0
0 0 4 3 3 0
2 4 4 0 0 0
2 4 4 0 0 0
[torch.FloatTensor of size 2x6]
[torch.FloatTensor of size 2x6]
"""
"""
return
output
.
scatter_add_
(
dim
,
index
,
input
)
return
output
.
scatter_add_
(
dim
,
index
,
input
)
# .. testoutput::
# 0 0 4 3 3 0
# 2 4 4 0 0 0
# [torch.FloatTensor of size 2x6]
def
scatter_add
(
index
,
input
,
dim
=
0
,
size
=
None
,
fill_value
=
0
):
def
scatter_add
(
index
,
input
,
dim
=
0
,
size
=
None
,
fill_value
=
0
):
...
...
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