Skip to content

Commit 76d04d6

Browse files
committed
no f strings
1 parent 5a006f7 commit 76d04d6

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

setup.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
WITH_CUDA = torch.cuda.is_available() and CUDA_HOME is not None
1212
if os.getenv('FORCE_CUDA', '0') == '1':
1313
WITH_CUDA = True
14-
if os.getenv('FORCE_NON_CUDA', '0') == '1':
14+
if os.getenv('FORCE_CPU', '0') == '1':
1515
WITH_CUDA = False
1616

1717
BUILD_DOCS = os.getenv('BUILD_DOCS', '0') == '1'
@@ -23,39 +23,37 @@ def get_extensions():
2323
extra_compile_args = {'cxx': [], 'nvcc': []}
2424
extra_link_args = []
2525

26-
# Windows users: Edit both of these to contain your VS include path, i.e.:
27-
# extra_compile_args['cxx'] += ['-I{VISUAL_STUDIO_DIR}\\include']
28-
# extra_compile_args['nvcc'] += ['-I{VISUAL_STUDIO_DIR}\\include']
29-
3026
if WITH_CUDA:
3127
Extension = CUDAExtension
3228
define_macros += [('WITH_CUDA', None)]
3329
nvcc_flags = os.getenv('NVCC_FLAGS', '')
3430
nvcc_flags = [] if nvcc_flags == '' else nvcc_flags.split(' ')
3531
nvcc_flags += ['-arch=sm_35', '--expt-relaxed-constexpr']
36-
extra_compile_args['cxx'] += ['-O0']
3732
extra_compile_args['nvcc'] += nvcc_flags
38-
if sys.platform == 'win32':
3933

34+
if sys.platform == 'win32':
4035
extra_link_args = ['cusparse.lib']
4136
else:
4237
extra_link_args = ['-lcusparse', '-l', 'cusparse']
4338

44-
if sys.platform == 'win32':
45-
extra_compile_args['cxx'] += ['/MP']
46-
4739
extensions_dir = osp.join(osp.dirname(osp.abspath(__file__)), 'csrc')
4840
main_files = glob.glob(osp.join(extensions_dir, '*.cpp'))
4941
extensions = []
5042
for main in main_files:
5143
name = main.split(os.sep)[-1][:-4]
5244

53-
sources = [main, osp.join(extensions_dir, 'cpu', f'{name}_cpu.cpp')]
54-
if WITH_CUDA:
55-
sources += [osp.join(extensions_dir, 'cuda', f'{name}_cuda.cu')]
45+
sources = [main]
46+
47+
path = osp.join(extensions_dir, 'cpu', name + '_cpu.cpp')
48+
if osp.exists(path):
49+
sources += [path]
50+
51+
path = osp.join(extensions_dir, 'cuda', name + '_cuda.cu')
52+
if WITH_CUDA and osp.exists(path):
53+
sources += [path]
5654

5755
extension = Extension(
58-
f'torch_sparse._{name}',
56+
'torch_sparse._' + name,
5957
sources,
6058
include_dirs=[extensions_dir],
6159
define_macros=define_macros,
@@ -73,14 +71,15 @@ def get_extensions():
7371

7472
setup(
7573
name='torch_sparse',
76-
version='0.5.0',
74+
version='0.5.1',
7775
author='Matthias Fey',
7876
author_email='[email protected]',
7977
url='https://github.com/rusty1s/pytorch_sparse',
8078
description=('PyTorch Extension Library of Optimized Autograd Sparse '
8179
'Matrix Operations'),
8280
keywords=['pytorch', 'sparse', 'sparse-matrices', 'autograd'],
8381
license='MIT',
82+
python_requires='>=3.5',
8483
install_requires=install_requires,
8584
setup_requires=setup_requires,
8685
tests_require=tests_require,

torch_sparse/add.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def add(src: SparseTensor, other: torch.Tensor) -> SparseTensor:
1414
elif other.size(0) == 1 and other.size(1) == src.size(1): # Col-wise...
1515
other = other.squeeze(0)[col]
1616
else:
17-
raise ValueError(f'Size mismatch: Expected size ({src.size(0)}, 1,'
18-
f' ...) or (1, {src.size(1)}, ...), but got size '
19-
f'{other.size()}.')
17+
raise ValueError(
18+
'Size mismatch: Expected size ({}, 1, ...) or (1, {}, ...), but '
19+
'got size {}.'.format(src.size(0), src.size(1), other.size()))
2020

2121
if value is not None:
2222
value = other.to(value.dtype).add_(value)
@@ -34,9 +34,9 @@ def add_(src: SparseTensor, other: torch.Tensor) -> SparseTensor:
3434
elif other.size(0) == 1 and other.size(1) == src.size(1): # Col-wise...
3535
other = other.squeeze(0)[col]
3636
else:
37-
raise ValueError(f'Size mismatch: Expected size ({src.size(0)}, 1,'
38-
f' ...) or (1, {src.size(1)}, ...), but got size '
39-
f'{other.size()}.')
37+
raise ValueError(
38+
'Size mismatch: Expected size ({}, 1, ...) or (1, {}, ...), but '
39+
'got size {}.'.format(src.size(0), src.size(1), other.size()))
4040

4141
if value is not None:
4242
value = value.add_(other.to(value.dtype))

torch_sparse/cat.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def cat(tensors: List[SparseTensor], dim: int) -> SparseTensor:
138138
return tensors[0].set_value(value, layout='coo')
139139
else:
140140
raise IndexError(
141-
(f'Dimension out of range: Expected to be in range of '
142-
f'[{-tensors[0].dim()}, {tensors[0].dim() - 1}, but got {dim}]'))
141+
'Dimension out of range: Expected to be in range of [{}, {}], but '
142+
'got {}.'.format(-tensors[0].dim(), tensors[0].dim() - 1, dim))
143143

144144

145145
@torch.jit.script

torch_sparse/mul.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ def mul(src: SparseTensor, other: torch.Tensor) -> SparseTensor:
1414
elif other.size(0) == 1 and other.size(1) == src.size(1): # Col-wise...
1515
other = other.squeeze(0)[col]
1616
else:
17-
raise ValueError(f'Size mismatch: Expected size ({src.size(0)}, 1,'
18-
f' ...) or (1, {src.size(1)}, ...), but got size '
19-
f'{other.size()}.')
17+
raise ValueError(
18+
'Size mismatch: Expected size ({}, 1, ...) or (1, {}, ...), but '
19+
'got size {}.'.format(src.size(0), src.size(1), other.size()))
2020

2121
if value is not None:
2222
value = other.to(value.dtype).mul_(value)
@@ -34,9 +34,9 @@ def mul_(src: SparseTensor, other: torch.Tensor) -> SparseTensor:
3434
elif other.size(0) == 1 and other.size(1) == src.size(1): # Col-wise...
3535
other = other.squeeze(0)[col]
3636
else:
37-
raise ValueError(f'Size mismatch: Expected size ({src.size(0)}, 1,'
38-
f' ...) or (1, {src.size(1)}, ...), but got size '
39-
f'{other.size()}.')
37+
raise ValueError(
38+
'Size mismatch: Expected size ({}, 1, ...) or (1, {}, ...), but '
39+
'got size {}.'.format(src.size(0), src.size(1), other.size()))
4040

4141
if value is not None:
4242
value = value.mul_(other.to(value.dtype))

torch_sparse/tensor.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -487,21 +487,22 @@ def __repr__(self: SparseTensor) -> str:
487487
i = ' ' * 6
488488
row, col, value = self.coo()
489489
infos = []
490-
infos += [f'row={indent(row.__repr__(), i)[len(i):]}']
491-
infos += [f'col={indent(col.__repr__(), i)[len(i):]}']
490+
infos += ['row={}'.format(indent(row.__repr__(), i)[len(i):])]
491+
infos += ['col={}'.format(indent(col.__repr__(), i)[len(i):])]
492492

493493
if value is not None:
494-
infos += [f'val={indent(value.__repr__(), i)[len(i):]}']
494+
infos += ['val={}'.format(indent(value.__repr__(), i)[len(i):])]
495495

496496
infos += [
497-
f'size={tuple(self.sizes())}, '
498-
f'nnz={self.nnz()}, '
499-
f'density={100 * self.density():.02f}%'
497+
'size={}, '.format(tuple(self.sizes())) +
498+
'nnz={}, '.format(self.nnz()) +
499+
'density={:.02f}%'.format(100 * self.density())
500500
]
501+
501502
infos = ',\n'.join(infos)
502503

503504
i = ' ' * (len(self.__class__.__name__) + 1)
504-
return f'{self.__class__.__name__}({indent(infos, i)[len(i):]})'
505+
return '{}({})'.format(self.__class__.__name__, indent(infos, i)[len(i):])
505506

506507

507508
SparseTensor.share_memory_ = share_memory_

0 commit comments

Comments
 (0)