From 4f8e55a448c821a3500b26cca5ebbcdf3d92efc1 Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Tue, 22 Dec 2020 18:09:33 +0000 Subject: [PATCH] Remove support for Python 2.7 --- .travis.yml | 8 -------- LICENSE | 2 +- changelog.txt | 5 +++++ doc/conf.py | 4 ++-- doc/installation.txt | 10 +++++----- lazyarray.py | 38 ++++++++++---------------------------- setup.py | 3 +-- 7 files changed, 24 insertions(+), 46 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9b5be1d..fa21962 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,27 +1,19 @@ language: python sudo: false python: - - 2.7 - 3.4 - 3.6 - 3.9 env: - - NUMPY_VERSION="1.8.2" SCIPY_VERSION="0.14.1" - NUMPY_VERSION="1.12.1" SCIPY_VERSION="0.17.1" - NUMPY_VERSION="1.13.1" SCIPY_VERSION="0.19.1" - NUMPY_VERSION="1.19.4" SCIPY_VERSION="1.5.4" matrix: exclude: - - python: 2.7 - env: NUMPY_VERSION="1.19.4" SCIPY_VERSION="1.5.4" - python: 3.4 env: NUMPY_VERSION="1.19.4" SCIPY_VERSION="1.5.4" - - python: 3.6 - env: NUMPY_VERSION="1.8.2" SCIPY_VERSION="0.14.1" - python: 3.6 env: NUMPY_VERSION="1.12.1" SCIPY_VERSION="0.17.1" - - python: 3.9 - env: NUMPY_VERSION="1.8.2" SCIPY_VERSION="0.14.1" - python: 3.9 env: NUMPY_VERSION="1.12.1" SCIPY_VERSION="0.17.1" install: diff --git a/LICENSE b/LICENSE index 2521a12..cb1f20a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2012-20120, Andrew P. Davison, Joël Chavas and Elodie Legouée (CNRS) +Copyright (c) 2012-2020, Andrew P. Davison, Joël Chavas and Elodie Legouée (CNRS) All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/changelog.txt b/changelog.txt index a2e5ec8..4bf8afd 100644 --- a/changelog.txt +++ b/changelog.txt @@ -98,6 +98,11 @@ Release 0.3.3 * Do not raise a "shape mismatch" `ValueError` if the value shape is empty. +Release 0.4.0 +============= + +* Drop support for Python 2.7 + .. _`#3`: https://bitbucket.org/apdavison/lazyarray/issue/3/ .. _`#4`: https://bitbucket.org/apdavison/lazyarray/issue/4/ diff --git a/doc/conf.py b/doc/conf.py index 7b96ac5..ac3319d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -50,9 +50,9 @@ # built documents. # # The short X.Y version. -version = '0.3' +version = '0.4' # The full version, including alpha/beta/rc tags. -release = '0.3.4' +release = '0.4.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/installation.txt b/doc/installation.txt index 378bb02..ac9ffb2 100644 --- a/doc/installation.txt +++ b/doc/installation.txt @@ -5,8 +5,8 @@ Installation Dependencies ============ - * Python >= 2.7 - * numpy_ >= 1.8 (or >= 1.12 for Python 3) + * Python >= 3.4 + * numpy_ >= 1.12 * (optional) scipy_ >= 0.14 Installing from the Python Package Index @@ -21,12 +21,12 @@ to have administrator privileges on the machine you are installing on). To download and install manually, download: - https://pypi.python.org/packages/source/l/lazyarray/lazyarray-0.3.4.tar.gz + https://pypi.python.org/packages/source/l/lazyarray/lazyarray-0.4.0.tar.gz Then:: - $ tar xzf lazyarray-0.3.4.tar.gz - $ cd lazyarray-0.3.4 + $ tar xzf lazyarray-0.4.0.tar.gz + $ cd lazyarray-0.4.0 $ python setup.py install or:: diff --git a/lazyarray.py b/lazyarray.py index f5d0527..a039610 100644 --- a/lazyarray.py +++ b/lazyarray.py @@ -6,12 +6,11 @@ Copyright Andrew P. Davison, Joël Chavas and Elodie Legouée (CNRS), 2012-2020 """ -from __future__ import division import numbers import operator from copy import deepcopy import collections -from functools import wraps +from functools import wraps, reduce import logging import numpy @@ -23,24 +22,7 @@ have_scipy = False -__version__ = "0.3.4" - -# stuff for Python 3 compatibility -try: - long -except NameError: - long = int - -try: - reduce -except NameError: - from functools import reduce - -try: - basestring -except NameError: - basestring = str - +__version__ = "0.4.0" logger = logging.getLogger("lazyarray") @@ -85,7 +67,7 @@ def partial_shape(addr, full_shape): Calculate the size of the sub-array represented by `addr` """ def size(x, max): - if isinstance(x, (int, long, numpy.integer)): + if isinstance(x, (int, numpy.integer)): return None elif isinstance(x, slice): y = min(max, x.stop or max) # slice limits can go past the bounds @@ -167,7 +149,7 @@ def __init__(self, value, shape=None, dtype=None): """ Create a new lazy array. - `value` : may be an int, long, float, bool, NumPy array, iterator, + `value` : may be an int, float, bool, NumPy array, iterator, generator or a function, `f(i)` or `f(i,j)`, depending on the dimensions of the array. @@ -178,7 +160,7 @@ def __init__(self, value, shape=None, dtype=None): self.dtype = dtype self.operations = [] - if isinstance(value, basestring): + if isinstance(value, str): raise TypeError("An larray cannot be created from a string") elif isinstance(value, larray): if shape is not None and value.shape is not None: @@ -290,7 +272,7 @@ def size(self): @property def is_homogeneous(self): """True if all the elements of the array are the same.""" - hom_base = isinstance(self.base_value, (int, long, numpy.integer, float, bool)) \ + hom_base = isinstance(self.base_value, (int, numpy.integer, float, bool)) \ or type(self.base_value) == self.dtype \ or (isinstance(self.dtype, type) and isinstance(self.base_value, self.dtype)) hom_ops = all(obj.is_homogeneous for f, obj in self.operations if isinstance(obj, larray)) @@ -314,7 +296,7 @@ def _array_indices(self, addr): self.check_bounds(addr) def axis_indices(x, max): - if isinstance(x, (int, long, numpy.integer)): + if isinstance(x, (int, numpy.integer)): return x elif isinstance(x, slice): # need to handle negative values in slice return numpy.arange((x.start or 0), @@ -369,7 +351,7 @@ def _partially_evaluate(self, addr, simplify=False): base_val = self.base_value else: base_val = self._homogeneous_array(addr) * self.base_value - elif isinstance(self.base_value, (int, long, numpy.integer, float, bool)): + elif isinstance(self.base_value, (int, numpy.integer, float, bool)): base_val = self._homogeneous_array(addr) * self.base_value elif isinstance(self.base_value, numpy.ndarray): base_val = self.base_value[addr] @@ -408,7 +390,7 @@ def is_boolean_array(arr): return hasattr(arr, 'dtype') and arr.dtype == bool def check_axis(x, size): - if isinstance(x, (int, long, numpy.integer)): + if isinstance(x, (int, numpy.integer)): lower = upper = x elif isinstance(x, slice): lower = x.start or 0 @@ -485,7 +467,7 @@ def evaluate(self, simplify=False, empty_val=0): x = self.base_value else: x = self.base_value * numpy.ones(self._shape, dtype=self.dtype) - elif isinstance(self.base_value, (int, long, numpy.integer, float, bool, numpy.bool_)): + elif isinstance(self.base_value, (int, numpy.integer, float, bool, numpy.bool_)): x = self.base_value * numpy.ones(self._shape, dtype=self.dtype) elif isinstance(self.base_value, numpy.ndarray): x = self.base_value diff --git a/setup.py b/setup.py index 6e88ca0..9d3c725 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='lazyarray', - version='0.3.4', + version='0.4.0', py_modules=['lazyarray'], license='Modified BSD', author="Andrew P. Davison", @@ -21,7 +21,6 @@ 'License :: OSI Approved :: BSD License', 'Natural Language :: English', 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', 'Programming Language :: Python :: 3', 'Topic :: Scientific/Engineering', ]