Skip to content

Commit

Permalink
Remove Python 2.7 support code at start of v0.10 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Oct 6, 2019
1 parent 1f22b92 commit 0083e73
Show file tree
Hide file tree
Showing 25 changed files with 276 additions and 502 deletions.
12 changes: 2 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ language: python
dist: "xenial"
sudo: true
python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"
# command to install dependencies
Expand All @@ -22,11 +20,7 @@ install:
- sudo apt-get install tesseract-ocr
# We do this conditionally because it saves us some downloading if the
# version is the same.
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
Expand All @@ -47,9 +41,7 @@ install:
# Force upgraded scikit-image
# - conda install --yes scikit-image
# Hyperspy is now an optional dependency for 3.6 onwards
- if [[ "$TRAVIS_PYTHON_VERSION" == "3.7" ]] || [[ "$TRAVIS_PYTHON_VERSION" == "3.6" ]] ; then
conda install hyperspy;
fi
- conda install hyperspy
# Now we unistall the stable stoner - use force to stop downgrading packages!
- conda remove --yes --force stoner
- pip install coveralls
Expand Down
7 changes: 2 additions & 5 deletions Stoner/Analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from scipy.optimize import curve_fit
from scipy.signal import savgol_filter

from .compat import python_v3, string_types, int_types, index_types, get_func_params
from .compat import string_types, int_types, index_types, get_func_params
from .tools import isNone, isiterable, all_type, istuple
from .core.exceptions import assertion
from .analysis.utils import (
Expand All @@ -25,10 +25,7 @@
from copy import deepcopy as copy

# from matplotlib.pylab import * #Surely not?
if python_v3:
from inspect import getfullargspec
else:
from inspect import getargspec as getfullargspec
from inspect import getfullargspec


class AnalysisMixin(object):
Expand Down
16 changes: 2 additions & 14 deletions Stoner/Core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@
from numpy import NaN # pylint: disable=unused-import
import numpy.ma as _ma_

from .compat import (
python_v3,
string_types,
int_types,
index_types,
get_filedialog,
classproperty,
str2bytes,
_pattern_type,
)
from .compat import string_types, int_types, index_types, get_filedialog, classproperty, str2bytes, _pattern_type
from .tools import all_type, operator, isiterable, islike_list, get_option

from .core.exceptions import StonerLoadError, StonerSetasError, StonerUnrecognisedFormat
Expand Down Expand Up @@ -719,10 +710,7 @@ def __lshift__(self, other):
"""
newdata = DataFile()
if isinstance(other, string_types):
if python_v3:
lines = map(lambda x: x, other.splitlines())
else:
lines = itertools.imap(lambda x: x, other.splitlines())
lines = map(lambda x: x, other.splitlines())
newdata.__read_iterable(lines)
elif isiterable(other):
newdata.__read_iterable(other)
Expand Down
8 changes: 3 additions & 5 deletions Stoner/Fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"wlfit",
]
import Stoner.Core as _SC_
from .compat import python_v3, string_types
from .compat import string_types
from . import Data
from functools import wraps
import numpy as _np_
Expand All @@ -84,10 +84,8 @@
import scipy.constants as cnst

try:
if python_v3:
from configparser import ConfigParser as SafeConfigParser
else:
from ConfigParser import SafeConfigParser
from configparser import ConfigParser as SafeConfigParser

except ImportError:
SafeConfigParser = None

Expand Down
45 changes: 11 additions & 34 deletions Stoner/Image/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,14 @@
from Stoner import Data
from Stoner.tools import istuple, fix_signature, islike_list, get_option
from Stoner.compat import (
python_v3,
string_types,
get_filedialog,
int_types,
) # Some things to help with Python2 and Python3 compatibility
import inspect
from functools import wraps

if python_v3:
from io import BytesIO as StreamIO
else:
from cStringIO import StringIO as StreamIO
from io import BytesIO as StreamIO


IMAGE_FILES = [("Tiff File", "*.tif;*.tiff"), ("PNG files", "*.png", "Numpy Files", "*.npy")]
Expand Down Expand Up @@ -164,9 +160,6 @@ class ImageArray(np.ma.MaskedArray, metadataObject):

# now initialise class

if not python_v3: # Ugh what a horrible hack!
_mask = np.ma.MaskedArray([]).mask

def __new__(cls, *args, **kargs):
"""Construct an ImageArray object.
Expand Down Expand Up @@ -1236,33 +1229,17 @@ def __iadd__(self, other):
result = __add_core__(result, other)
return result

if python_v3:

def __truediv__(self, other):
"""Implement the divide operator"""
result = self.clone
result = __div_core__(result, other)
return result

def __itruediv__(self, other):
"""Implement the inplace divide operator"""
result = self
result = __div_core__(result, other)
return result

else:
def __truediv__(self, other):
"""Implement the divide operator"""
result = self.clone
result = __div_core__(result, other)
return result

def __div__(self, other):
"""Implement the divide operator"""
result = self.clone
result = __div_core__(result, other)
return result

def __idiv__(self, other):
"""Implement the inplace divide operator"""
result = self
result = __div_core__(result, other)
return result
def __itruediv__(self, other):
"""Implement the inplace divide operator"""
result = self
result = __div_core__(result, other)
return result

def __sub__(self, other):
"""Implement the subtract operator"""
Expand Down
2 changes: 1 addition & 1 deletion Stoner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

from os import path as _path_

__version_info__ = ("0", "9", "0")
__version_info__ = ("0", "10", "0dev")
__version__ = ".".join(__version_info__)

__home__ = _path_.realpath(_path_.dirname(__file__))
Expand Down
7 changes: 2 additions & 5 deletions Stoner/analysis/fitting/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from scipy.odr import Model as odrModel
from scipy.optimize import curve_fit, differential_evolution

from Stoner.compat import python_v3, string_types, index_types, get_func_params
from Stoner.compat import string_types, index_types, get_func_params
from Stoner.tools import isNone, isiterable, islike_list, _attribute_store

try: # Allow lmfit to be optional
Expand All @@ -34,10 +34,7 @@
from copy import deepcopy as copy

# from matplotlib.pylab import * #Surely not?
if python_v3:
from inspect import getfullargspec
else:
from inspect import getargspec as getfullargspec
from inspect import getfullargspec


class odr_Model(odrModel):
Expand Down

0 comments on commit 0083e73

Please sign in to comment.