Skip to content

Commit 2606503

Browse files
committed
Try to import Callable from collections.abc (closes #133)
1 parent e1cd919 commit 2606503

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ name: Unit Tests
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [ master, develop ]
99
pull_request:
10-
branches: [ master ]
10+
branches: [ master, develop ]
1111

1212
jobs:
1313
build:
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: [2.7, 3.6, 3.7, 3.8, 3.9]
19+
python-version: [2.7, 3.6, 3.7, 3.8, 3.9, "3.10"]
2020

2121
steps:
2222
- uses: actions/checkout@v2

spectral/algorithms/transforms.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from __future__ import absolute_import, division, print_function, unicode_literals
66

7-
import collections
7+
try:
8+
from collections.abc import Callable
9+
except:
10+
from collections import Callable
811
import numpy as np
912

1013

@@ -85,7 +88,7 @@ def __call__(self, X):
8588
__init__.
8689
'''
8790
if not isinstance(X, np.ndarray):
88-
if hasattr(X, 'transform') and isinstance(X.transform, collections.Callable):
91+
if hasattr(X, 'transform') and isinstance(X.transform, Callable):
8992
return X.transform(self)
9093
else:
9194
raise TypeError('Unable to apply transform to object.')

spectral/tests/spytest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
from __future__ import absolute_import, division, print_function, unicode_literals
66

7-
import collections
7+
try:
8+
from collections.abc import Callable
9+
except:
10+
from collections import Callable
811
import sys
912

1013
class SpyTest(object):
@@ -39,7 +42,7 @@ def flush(self):
3942
pass
4043
null = NullStdOut()
4144
methods = [getattr(self, s) for s in sorted(dir(self)) if s.startswith('test_')]
42-
methods = [m for m in methods if isinstance(m, collections.Callable)]
45+
methods = [m for m in methods if isinstance(m, Callable)]
4346
stdout = sys.stdout
4447
for method in methods:
4548
print(format('Testing ' + method.__name__.split('_', 1)[-1],

0 commit comments

Comments
 (0)