Skip to content

Commit

Permalink
Remove string_types, which is a remnant of Python 2 support (#654)
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
cclauss authored Sep 14, 2022
1 parent 3961a2f commit 07c3dcf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pywt/_dwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
upcoef as _upcoef, downcoef as _downcoef,
dwt_max_level as _dwt_max_level,
dwt_coeff_len as _dwt_coeff_len)
from ._utils import string_types, _as_wavelet
from ._utils import _as_wavelet


__all__ = ["dwt", "idwt", "downcoef", "upcoef", "dwt_max_level",
Expand Down Expand Up @@ -61,7 +61,7 @@ def dwt_max_level(data_len, filter_len):
"""
if isinstance(filter_len, Wavelet):
filter_len = filter_len.dec_len
elif isinstance(filter_len, string_types):
elif isinstance(filter_len, str):
if filter_len in wavelist(kind='discrete'):
filter_len = Wavelet(filter_len).dec_len
else:
Expand Down
12 changes: 2 additions & 10 deletions pywt/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,12 @@
# See COPYING for license details.
import inspect
import numpy as np
import sys
from collections.abc import Iterable

from ._extensions._pywt import (Wavelet, ContinuousWavelet,
DiscreteContinuousWavelet, Modes)


# define string_types as in six for Python 2/3 compatibility
if sys.version_info[0] == 3:
string_types = str,
else:
string_types = basestring,


def _as_wavelet(wavelet):
"""Convert wavelet name to a Wavelet object."""
if not isinstance(wavelet, (ContinuousWavelet, Wavelet)):
Expand Down Expand Up @@ -48,7 +40,7 @@ def _wavelets_per_axis(wavelet, axes):
"""
axes = tuple(axes)
if isinstance(wavelet, string_types + (Wavelet, )):
if isinstance(wavelet, (str, Wavelet)):
# same wavelet on all axes
wavelets = [_as_wavelet(wavelet), ] * len(axes)
elif isinstance(wavelet, Iterable):
Expand Down Expand Up @@ -84,7 +76,7 @@ def _modes_per_axis(modes, axes):
"""
axes = tuple(axes)
if isinstance(modes, string_types + (int, )):
if isinstance(modes, (int, str)):
# same wavelet on all axes
modes = [Modes.from_object(modes), ] * len(axes)
elif isinstance(modes, Iterable):
Expand Down

0 comments on commit 07c3dcf

Please sign in to comment.