Skip to content

Commit

Permalink
Merge 0d98aad into 260e3fe
Browse files Browse the repository at this point in the history
  • Loading branch information
apdavison committed Dec 22, 2020
2 parents 260e3fe + 0d98aad commit 752b2ba
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 46 deletions.
8 changes: 0 additions & 8 deletions .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"
- python: 3.9
Expand Down
2 changes: 1 addition & 1 deletion 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:
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Expand Up @@ -105,6 +105,10 @@ Release 0.3.4
* Updated to test with more recent versions of Python, NumPy and SciPy
* Can now compare equality of lazyarrays to numbers and arrays

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/
Expand Down
4 changes: 2 additions & 2 deletions doc/conf.py
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions doc/installation.txt
Expand Up @@ -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
Expand All @@ -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::
Expand Down
38 changes: 10 additions & 28 deletions lazyarray.py
Expand Up @@ -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
Expand All @@ -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")

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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))
Expand All @@ -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),
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Expand Up @@ -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",
Expand All @@ -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',
]
Expand Down

0 comments on commit 752b2ba

Please sign in to comment.