[Git][debian-gis-team/pyepr][master] 7 commits: New upstream version 0.9.5
Antonio Valentino
gitlab at salsa.debian.org
Thu Aug 23 21:54:04 BST 2018
Antonio Valentino pushed to branch master at Debian GIS Project / pyepr
Commits:
da9584ba by Antonio Valentino at 2018-08-23T20:12:03Z
New upstream version 0.9.5
- - - - -
6536c016 by Antonio Valentino at 2018-08-23T20:12:05Z
Update upstream source from tag 'upstream/0.9.5'
Update to upstream version '0.9.5'
with Debian dir d748d45cbb03f611fbfa2bafca81b4a6a0c48322
- - - - -
9dc4d948 by Antonio Valentino at 2018-08-23T20:13:04Z
New upstream release
- - - - -
3e2f5b3e by Antonio Valentino at 2018-08-23T20:14:53Z
Refresh all patches
- - - - -
31407917 by Antonio Valentino at 2018-08-23T20:19:53Z
Update debian/rules and .docs file for the new package
- - - - -
a0abcb51 by Antonio Valentino at 2018-08-23T20:23:18Z
Drop debian/python3-epr-dbg.lintian-overrides
- - - - -
b81c3f1d by Antonio Valentino at 2018-08-23T20:45:09Z
Set distribution to unstable
- - - - -
30 changed files:
- − .gitattributes
- .travis.yml
- MANIFEST.in
- Makefile
- README.txt → README.rst
- + appveyor.yml
- + build-manylinux-wheels.sh
- debian/changelog
- debian/patches/0001-Only-use-local-files-for-generating-sphinx-doc.patch
- debian/python-epr-doc.docs
- − debian/python3-epr-dbg.lintian-overrides
- debian/rules
- doc/NEWS.txt → doc/NEWS.rst
- doc/_templates/appveyor.html
- doc/_templates/pypi.html
- doc/bands_example.txt → doc/bands_example.rst
- doc/bitmask_example.txt → doc/bitmask_example.rst
- doc/conf.py
- doc/gdal_export_example.txt → doc/gdal_export_example.rst
- doc/index.txt → doc/index.rst
- doc/interactive_use.txt → doc/interactive_use.rst
- doc/ndvi_example.txt → doc/ndvi_example.rst
- doc/reference.txt → doc/reference.rst
- doc/tutorials.txt → doc/tutorials.rst
- doc/update_example.txt → doc/update_example.rst
- doc/usermanual.txt → doc/usermanual.rst
- requirements.txt
- setup.py
- src/epr.pyx
- tests/test_all.py
Changes:
=====================================
.gitattributes deleted
=====================================
--- a/.gitattributes
+++ /dev/null
@@ -1,5 +0,0 @@
-*.py ident
-*.pyx ident
-*.px[di] ident
-*.txt ident
-
=====================================
.travis.yml
=====================================
--- a/.travis.yml
+++ b/.travis.yml
@@ -7,8 +7,9 @@ python:
- "3.4"
- "3.5"
- "3.6"
- - "3.7-dev"
- # "pypy2.7"
+ # - "3.7"
+ # - "3.8-dev"
+ # - "pypy2.7"
- "pypy3.5"
before_install:
@@ -17,7 +18,7 @@ before_install:
install:
- pip install -r requirements.txt
- - if [[ $TRAVIS_PYTHON_VERSION == '2.6' ]]; then pip install -U unittest2; fi
+ - if [[ $TRAVIS_PYTHON_VERSION < '3.4' ]]; then pip install -U unittest2; fi
- python setup.py build_ext --inplace
script: make PYTHON=python check
=====================================
MANIFEST.in
=====================================
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -7,7 +7,7 @@ recursive-include tests *.py
recursive-include src *.pyx *.pxd *.c
recursive-include epr-api-src *.c *.h
-recursive-include doc *.txt *.py Makefile make.bat *.png
+recursive-include doc *.rst *.txt *.py Makefile make.bat *.png
recursive-include doc/_templates *.html
recursive-include doc/pydoctheme *
recursive-include doc/html *
=====================================
Makefile
=====================================
--- a/Makefile
+++ b/Makefile
@@ -26,7 +26,7 @@ TEST_DATSET = tests/MER_LRC_2PTGMV20000620_104318_00000104X000_00000_00000_0001.
EPRAPIROOT = ../epr-api
.PHONY: default ext cythonize sdist eprsrc fullsdist doc clean distclean \
- check debug data upload
+ check debug data upload manylinux
default: ext
@@ -69,6 +69,7 @@ clean:
$(RM) MANIFEST src/*.c src/*.o *.so
$(RM) tests/*.py[co] doc/sphinxext/*.py[co] README.html
$(MAKE) -C doc clean
+ $(RM) -r doc/_build
find . -name '*~' -delete
distclean: clean
@@ -88,3 +89,8 @@ data: $(TEST_DATSET)
$(TEST_DATSET):
wget -P tests $(TEST_DATSET_URL)
gunzip $@
+
+manylinux:
+ # make fullsdist
+ # docker pull quay.io/pypa/manylinux1_x86_64
+ docker run --rm -v $(shell pwd):/io quay.io/pypa/manylinux1_x86_64 sh /io/build-manylinux-wheels.sh
=====================================
README.txt → README.rst
=====================================
--- a/README.txt
+++ b/README.rst
@@ -6,7 +6,7 @@ ENVISAT Product Reader Python API
:Author: Antonio Valentino
:Contact: antonio.valentino at tiscali.it
:Copyright: 2011-2018, Antonio Valentino <antonio.valentino at tiscali.it>
-:Version: 0.9.4
+:Version: 0.9.5
Introduction
@@ -41,11 +41,11 @@ correctly installed and configured:
with a copy of the PER C API sources)
* a reasonably updated C compiler (build only)
* Cython_ >= 0.15 (build only)
-* unittest2_ (only required for Python < 2.7)
+* unittest2_ (only required for Python < 3.4)
.. _Python2: Python_
.. _Python3: Python_
-.. _PyPy: http://pypy.orgv
+.. _PyPy: http://pypy.org
.. _numpy: http://www.numpy.org
.. _gcc: http://gcc.gnu.org
.. _Cython: http://cython.org
=====================================
appveyor.yml
=====================================
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,81 @@
+# AppVeyor.com is a Continuous Integration service to build and run tests under
+# Windows
+#
+# See also: https://github.com/astropy/astropy/blob/master/appveyor.yml
+
+environment:
+
+ global:
+ PYTHON: "C:\\conda"
+ MINICONDA_VERSION: "latest"
+ CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci-helpers\\appveyor\\windows_sdk.cmd"
+ # PYTHON_ARCH: "64" # needs to be set for CMD_IN_ENV to succeed. If a mix
+ # of 32 bit and 64 bit builds are needed, move this
+ # to the matrix section.
+ CONDA_DEPENDENCIES: "setuptools numpy Cython unittest2"
+ # DEBUG: True
+ # NUMPY_VERSION: "stable"
+
+
+ matrix:
+ - platform: x86
+ PYTHON_VERSION: "2.7"
+ PYTHON_ARCH: "32"
+
+ - PYTHON_VERSION: "2.7"
+ PYTHON_ARCH: "64"
+
+ - platform: x86
+ PYTHON_VERSION: "3.4"
+ PYTHON_ARCH: "32"
+
+ - PYTHON_VERSION: "3.4"
+ PYTHON_ARCH: "64"
+
+ - platform: x86
+ PYTHON_VERSION: "3.5"
+ PYTHON_ARCH: "32"
+
+ - PYTHON_VERSION: "3.5"
+ PYTHON_ARCH: "64"
+
+ - platform: x86
+ PYTHON_VERSION: "3.6"
+ PYTHON_ARCH: "32"
+
+ - PYTHON_VERSION: "3.6"
+ PYTHON_ARCH: "64"
+
+ - platform: x86
+ PYTHON_VERSION: "3.7"
+ PYTHON_ARCH: "32"
+
+ - PYTHON_VERSION: "3.7"
+ PYTHON_ARCH: "64"
+
+install:
+ # conda
+ - "git clone git://github.com/astropy/ci-helpers.git"
+ - "powershell ci-helpers/appveyor/install-miniconda.ps1"
+ - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
+ - "activate test"
+ # epr-api
+ - "git clone -b pyepr https://github.com/avalentino/epr-api.git"
+
+# Not a .NET project, we build the python package in the install step instead
+build: false
+
+test_script:
+ # Build the compiled extension and run the project tests
+ - "%CMD_IN_ENV% python setup.py --epr-api-src=epr-api\\src test"
+
+after_test:
+ # If tests are successful, create a whl package for the project.
+ - "%CMD_IN_ENV% python setup.py --epr-api-src=epr-api\\src bdist_wheel"
+
+artifacts:
+ # Archive the generated wheel package in the ci.appveyor.com build report.
+ - path: dist\*
+
+#on_success:
+# - TODO: upload the content of dist/*.whl to a public wheelhouse
=====================================
build-manylinux-wheels.sh
=====================================
--- /dev/null
+++ b/build-manylinux-wheels.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+# Based on: https://github.com/pypa/python-manylinux-demo 9700d97 17 Dec 2016
+#
+# It is assumed that the docker image has been run as follows::
+#
+# $ make fullsdist
+# $ docker pull quay.io/pypa/manylinux1_x86_64
+# $ docker run --rm -v $(pwd):/io quay.io/pypa/manylinux1_x86_64 /io/build-manylinux-wheels.sh
+#
+# For interactive sessions please use::
+#
+# $ make fullsdist
+# $ docker pull quay.io/pypa/manylinux1_x86_64
+# $ docker run -it -v $(pwd):/io quay.io/pypa/manylinux1_x86_64
+# $ cd /io
+# $ sh build-manylinux-wheels.sh
+
+set -e -x
+
+PKG=pyepr
+
+# Compile wheels
+for PYBIN in /opt/python/*/bin; do
+ "${PYBIN}/pip" install -r /io/requirements.txt
+ "${PYBIN}/pip" wheel /io/dist/${PKG}*.tar.gz -w wheelhouse/
+done
+
+# Bundle external shared libraries into the wheels
+for whl in wheelhouse/${PKG}*.whl; do
+ auditwheel repair "${whl}" -w /io/wheelhouse/
+done
+
+# Install packages and test
+for PYBIN in /opt/python/*/bin/; do
+ "${PYBIN}/pip" install ${PKG} --no-index -f /io/wheelhouse
+ "${PYBIN}/python" /io/tests/test_all.py -v
+done
=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+pyepr (0.9.5-1) unstable; urgency=medium
+
+ * New upstream release.
+ * debian/patches
+ - refresh all patches
+ * Drop debian/python3-epr-dbg.lintian-overrides: no longer necessary.
+
+ -- Antonio Valentino <antonio.valentino at tiscali.it> Thu, 23 Aug 2018 20:23:29 +0000
+
pyepr (0.9.4-3) unstable; urgency=medium
* Team upload.
=====================================
debian/patches/0001-Only-use-local-files-for-generating-sphinx-doc.patch
=====================================
--- a/debian/patches/0001-Only-use-local-files-for-generating-sphinx-doc.patch
+++ b/debian/patches/0001-Only-use-local-files-for-generating-sphinx-doc.patch
@@ -11,7 +11,7 @@ happens any longer (Closes: #726859).
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
-index 0c23523..795fd91 100644
+index 84d729f..148502f 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -139,10 +139,10 @@ html_sidebars = {
=====================================
debian/python-epr-doc.docs
=====================================
--- a/debian/python-epr-doc.docs
+++ b/debian/python-epr-doc.docs
@@ -1,2 +1,2 @@
-README.txt
+README.rst
doc/html
=====================================
debian/python3-epr-dbg.lintian-overrides deleted
=====================================
--- a/debian/python3-epr-dbg.lintian-overrides
+++ /dev/null
@@ -1,3 +0,0 @@
-# False positive, string not included in source
-spelling-error-in-binary * lIK link
-
=====================================
debian/rules
=====================================
--- a/debian/rules
+++ b/debian/rules
@@ -61,11 +61,11 @@ override_dh_strip:
override_dh_installchangelogs:
- dh_installchangelogs -k doc/NEWS.txt
+ dh_installchangelogs -k doc/NEWS.rst
override_dh_compress:
- dh_compress -X.txt -X.html -X.py
+ dh_compress -X.txt -X.rst -X.html -X.py
override_dh_sphinxdoc:
=====================================
doc/NEWS.txt → doc/NEWS.rst
=====================================
--- a/doc/NEWS.txt
+++ b/doc/NEWS.rst
@@ -1,6 +1,21 @@
Change history
==============
+PyEPR 0.9.5 (23/08/2018)
+------------------------
+
+* Fix compatibility with numpy >= 1.14: :func:`np.fromstring`
+ is deprecated.
+* Update the pypi sidebar in the documentation
+* Use `.rst` extension for doc source files
+* Fix setup script to not use system libs if epr-api sources are available
+* Do not access fields of bands after that the product has been closed
+ (fix a segmentation fault on windows)
+* `unittest2`_ is now required for Python < 3.4
+
+.. _unittest2: https://pypi.org/project/unittest2
+
+
PyEPR 0.9.4 (29/04/2018)
------------------------
=====================================
doc/_templates/appveyor.html
=====================================
--- a/doc/_templates/appveyor.html
+++ b/doc/_templates/appveyor.html
@@ -1,5 +1,5 @@
<div>
<p>
-<a href="https://ci.appveyor.com/project/avalentino/pyepr"><img src="https://ci.appveyor.com/api/projects/status/pno3t4bwf3pwqdwi?svg=true" alt="AppVeyor status page"/></a>
+<a href="https://ci.appveyor.com/project/avalentino/pyepr"><img src="https://ci.appveyor.com/api/projects/status/xy8sb0tso761ths5?svg=true" alt="AppVeyor status page"/></a>
</p>
</div>
=====================================
doc/_templates/pypi.html
=====================================
--- a/doc/_templates/pypi.html
+++ b/doc/_templates/pypi.html
@@ -1,17 +1,14 @@
<div>
<p>
-<a href="https://pypi.python.org/pypi/pyepr"><img src="https://pypip.in/version/pyepr/badge.svg" alt="Latest Version"/></a>
+<a href="https://pypi.org/project/pyepr"><img src="https://img.shields.io/pypi/v/pyepr.svg" alt="Latest Version"/></a>
</p>
<p>
-<a href="https://pypi.python.org/pypi/pyepr"><img src="https://pypip.in/py_versions/pyepr/badge.svg" alt="Supported Python versions"/></a>
+<a href="https://pypi.org/project/pyepr"><img src="https://img.shields.io/pypi/pyversions/pyepr.svg" alt="Supported Python versions"/></a>
</p>
<p>
-<a href="https://pypi.python.org/pypi/pyepr"><img src="https://pypip.in/license/pyepr/badge.svg" alt="License"/></a>
+<a href="https://pypi.org/project/pyepr"><img src="https://img.shields.io/pypi/l/pyepr.svg" alt="License"/></a>
</p>
<p>
-<a href="https://pypi.python.org/pypi/pyepr"><img src="https://pypip.in/download/pyepr/badge.svg" alt="Downloads"/></a>
-</p>
-<p>
-<a href="https://pypi.python.org/pypi/pyepr"><img src="https://pypip.in/wheel/pyepr/badge.svg" alt="Wheel Status"/></a>
+<a href="https://pypi.org/project/pyepr"><img src="https://img.shields.io/pypi/wheel/pyepr.svg" alt="Wheel Status"/></a>
</p>
</div>
=====================================
doc/bands_example.txt → doc/bands_example.rst
=====================================
=====================================
doc/bitmask_example.txt → doc/bitmask_example.rst
=====================================
=====================================
doc/conf.py
=====================================
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -58,7 +58,7 @@ templates_path = ['_templates']
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
-source_suffix = '.txt'
+source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
@@ -73,9 +73,9 @@ author = u'Antonio Valentino'
# built documents.
#
# The short X.Y version.
-version = '0.9.4'
+version = '0.9.5'
# The full version, including alpha/beta/rc tags.
-release = version # + '.dev0'
+release = version + '.dev0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
=====================================
doc/gdal_export_example.txt → doc/gdal_export_example.rst
=====================================
--- a/doc/gdal_export_example.txt
+++ b/doc/gdal_export_example.rst
@@ -225,7 +225,7 @@ Complete listing
:language: python
-.. _GDAL: http://www.gdal.org
+.. _GDAL: https://www.gdal.org
.. _PyEPR: https://github.com/avalentino/pyepr
.. _ENVISAT: https://envisat.esa.int
=====================================
doc/index.txt → doc/index.rst
=====================================
--- a/doc/index.txt
+++ b/doc/index.rst
@@ -60,7 +60,8 @@ ENVISAT Product Reader Python API
Online documentation for other PyEpr_ versions:
* `latest <https://pyepr.readthedocs.io/en/latest/>`_ development
- * `0.9.4 <https://pyepr.readthedocs.io/en/v0.9.4/>`_ (latest stable)
+ * `0.9.5 <https://pyepr.readthedocs.io/en/v0.9.5/>`_ (latest stable)
+ * `0.9.4 <https://pyepr.readthedocs.io/en/v0.9.4/>`_
* `0.9.3 <https://pyepr.readthedocs.io/en/v0.9.3/>`_
* `0.9.2 <https://pyepr.readthedocs.io/en/v0.9.2/>`_
* `0.9.1 <https://pyepr.readthedocs.io/en/v0.9.1/>`_
=====================================
doc/interactive_use.txt → doc/interactive_use.rst
=====================================
=====================================
doc/ndvi_example.txt → doc/ndvi_example.rst
=====================================
=====================================
doc/reference.txt → doc/reference.rst
=====================================
=====================================
doc/tutorials.txt → doc/tutorials.rst
=====================================
=====================================
doc/update_example.txt → doc/update_example.rst
=====================================
=====================================
doc/usermanual.txt → doc/usermanual.rst
=====================================
--- a/doc/usermanual.txt
+++ b/doc/usermanual.rst
@@ -62,13 +62,13 @@ Requirements
In order to use PyEPR it is needed that the following software are
correctly installed and configured:
-* Python2_ >= 2.6 or Python3_ >= 3.1
+* Python2_ >= 2.6 or Python3_ >= 3.1 (including PyPy_)
* numpy_ >= 1.5.0
* `EPR API`_ >= 2.2 (optional, since PyEPR 0.7 the source tar-ball comes
with a copy of the EPR C API sources)
* a reasonably updated C compiler [#]_ (build only)
* Cython_ >= 0.19 [#]_ (optional and build only)
-* unittest2_ (only required for Python < 2.7)
+* unittest2_ (only required for Python < 3.4)
.. [#] PyEPR_ has been developed and tested with gcc_ 4.
@@ -81,6 +81,7 @@ correctly installed and configured:
.. _Python2: Python_
.. _Python3: Python_
+.. _PyPy: http://pypy.org
.. _numpy: http://www.numpy.org
.. _gcc: http://gcc.gnu.org
.. _Cython: http://cython.org
=====================================
requirements.txt
=====================================
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
numpy>=1.5
cython>=0.19
+unittest2;python_version<"3.4"
=====================================
setup.py
=====================================
--- a/setup.py
+++ b/setup.py
@@ -74,9 +74,11 @@ class PyEprExtension(Extension, object):
self._include_dirs = []
eprsrcdir = kwargs.pop('eprsrcdir', None)
- super(PyEprExtension, self).__init__(*args, **kwargs)
+ Extension.__init__(self, *args, **kwargs)
+
+ if not any('epr_' in src for src in self.sources):
+ self.sources.extend(self._extra_sources(eprsrcdir))
- self.sources.extend(self._extra_sources(eprsrcdir))
self.setup_requires_cython = False
def _extra_sources(self, eprsrcdir=None):
@@ -84,7 +86,7 @@ class PyEprExtension(Extension, object):
# check for local epr-api sources
if eprsrcdir is None:
- default_eprapisrc = os.path.join('epr-api-src')
+ default_eprapisrc = 'epr-api-src'
if os.path.isdir(default_eprapisrc):
eprsrcdir = default_eprapisrc
@@ -209,6 +211,7 @@ any data field contained in a product file.
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Cython',
'Topic :: Software Development :: Libraries',
@@ -218,15 +221,24 @@ any data field contained in a product file.
platforms=['any'],
license='GPL3',
requires=['numpy'], # XXX: check
+ python_requires='>=2.6, !=3.0.*, !=3.1.*, <4',
)
+def get_collector():
+ import unittest
+ if hasattr(unittest.TestCase, 'subTest'):
+ return 'tests'
+ else:
+ return 'unittest2.collector'
+
+
def setup_package():
ext = get_extension()
config['ext_modules'] = [ext]
if HAVE_SETUPTOOLS:
- config['test_suite'] = 'tests'
+ config['test_suite'] = get_collector()
config.setdefault('setup_requires', []).append('numpy>=1.5')
config.setdefault('install_requires', []).append('numpy>=1.5')
if ext.setup_requires_cython:
=====================================
src/epr.pyx
=====================================
--- a/src/epr.pyx
+++ b/src/epr.pyx
@@ -41,7 +41,7 @@ in a product file.
"""
-__version__ = '0.9.4'
+__version__ = '0.9.5'
from libc cimport errno
from libc cimport stdio
@@ -1682,8 +1682,15 @@ cdef class Band(EprObject):
cdef EPR_SBandId* _ptr
cdef Product _parent
- cdef inline check_closed_product(self):
- self._parent.check_closed_product()
+ cdef inline int check_closed_product(self) except -1:
+ if self._ptr is NULL:
+ raise ValueError('I/O operation on closed file')
+
+ elif self._parent.check_closed_product() == -1:
+ self._ptr = NULL
+ raise
+
+ return 0
property product:
"""The :class:`Product` instance to which this band belongs to."""
@@ -1719,6 +1726,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.sample_model
property data_type:
@@ -1734,6 +1742,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.data_type
property scaling_method:
@@ -1756,6 +1765,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.scaling_method
property scaling_offset:
@@ -1773,6 +1783,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.scaling_offset
property scaling_factor:
@@ -1790,6 +1801,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.scaling_factor
property bm_expr:
@@ -1800,6 +1812,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
if self._ptr.bm_expr is NULL:
return None
else:
@@ -1809,6 +1822,7 @@ cdef class Band(EprObject):
"""The geophysical unit for the band's pixel values."""
def __get__(self):
+ self.check_closed_product()
if self._ptr.unit is NULL:
return None
else:
@@ -1818,6 +1832,7 @@ cdef class Band(EprObject):
"""A short description of the band's contents."""
def __get__(self):
+ self.check_closed_product()
if self._ptr.description is NULL:
return None
else:
@@ -1833,6 +1848,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return <bint>self._ptr.lines_mirrored
property dataset:
@@ -1844,6 +1860,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
cdef EPR_SDatasetId* dataset_id = self._ptr.dataset_ref.dataset_id
cdef const char* name = epr_get_dataset_name(dataset_id)
return self.product.get_dataset(name)
@@ -2124,6 +2141,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.dataset_ref.field_index
property _elem_index:
@@ -2135,6 +2153,7 @@ cdef class Band(EprObject):
"""
def __get__(self):
+ self.check_closed_product()
return self._ptr.dataset_ref.elem_index
@@ -2418,9 +2437,10 @@ cdef class Product(EprObject):
pyepr_check_errors()
self._ptr = NULL
- cdef inline check_closed_product(self):
+ cdef inline int check_closed_product(self) except -1:
if self._ptr is NULL:
raise ValueError('I/O operation on closed file')
+ return 0
cdef inline _check_write_mode(self):
if '+' not in self._mode:
=====================================
tests/test_all.py
=====================================
--- a/tests/test_all.py
+++ b/tests/test_all.py
@@ -19,7 +19,6 @@
# along with PyEPR. If not, see <http://www.gnu.org/licenses/>.
-import io
import os
import re
import sys
@@ -38,11 +37,13 @@ except ImportError:
resource = None
try:
- from unittest import skipIf
+ from unittest import skipIf as _skipIf, TestCase as _TestCase
+ if not hasattr(_TestCase, 'subTest'):
+ raise ImportError
except ImportError:
import unittest2 as unittest
else:
- del skipIf
+ del _skipIf, _TestCase
import unittest
try:
@@ -57,7 +58,7 @@ import epr
EPR_TO_NUMPY_TYPE = {
- #epr.E_TID_UNKNOWN: np.NPY_NOTYPE,
+ # epr.E_TID_UNKNOWN: np.NPY_NOTYPE,
epr.E_TID_UCHAR: np.ubyte,
epr.E_TID_CHAR: np.byte,
epr.E_TID_USHORT: np.ushort,
@@ -67,8 +68,8 @@ EPR_TO_NUMPY_TYPE = {
epr.E_TID_FLOAT: np.float32,
epr.E_TID_DOUBLE: np.double,
epr.E_TID_STRING: np.str,
- #epr.E_TID_SPARE = e_tid_spare,
- #epr.E_TID_TIME = e_tid_time,
+ # epr.E_TID_SPARE = e_tid_spare,
+ # epr.E_TID_TIME = e_tid_time,
}
@@ -96,7 +97,7 @@ def quiet(func):
try:
# using '/dev/null' doesn't work in python 3 because the file
# object coannot be converted into a C FILE*
- #with file(os.devnull) as fd:
+ # with file(os.devnull) as fd:
with tempfile.TemporaryFile('w+') as fd:
sys.stdout = fd
sys.stderr = fd
@@ -515,8 +516,8 @@ class TestProductHighLevelAPI(unittest.TestCase):
self.assertEqual(band.get_name(), ref_band.get_name())
# @TODO: not implemented
- #def test_iter(self):
- # pass
+ # def test_iter(self):
+ # pass
def test_repr(self):
pattern = ('epr\.Product\((?P<name>\w+)\) '
@@ -1375,38 +1376,21 @@ class TestBandOnClosedProduct(unittest.TestCase):
self.assertTrue(isinstance(self.band.product, epr.Product))
def test_properties(self):
- # 'sample_model', 'data_type', 'scaling_method', 'scaling_offset',
- # 'scaling_factor', 'bm_expr', 'unit', 'description', 'lines_mirrored'
- for name in ('spectr_band_index',):
- self.assertRaises(ValueError, getattr, self.band, name)
-
- def test_sample_model_property(self):
- self.assertEqual(self.band.sample_model, 0)
-
- def test_data_type_property(self):
- self.assertEqual(self.band.data_type, 0)
-
- def test_scaling_method_property(self):
- self.assertEqual(self.band.scaling_method, epr.E_SMID_LIN)
-
- def test_scaling_offset_property(self):
- self.assertEqual(self.band.scaling_offset, 0)
-
- def test_scaling_factor_property(self):
- self.assertEqual(self.band.scaling_factor, 0)
- self.assertTrue(isinstance(self.band.scaling_factor, float))
-
- def test_bm_expr_property(self):
- self.assertEqual(self.band.bm_expr, None)
-
- def test_unit_property(self):
- self.assertEqual(self.band.unit, None)
-
- def test_description_property(self):
- self.assertEqual(self.band.description, None)
-
- def test_lines_mirrored_property(self):
- self.assertTrue(isinstance(self.band.lines_mirrored, bool))
+ fields = (
+ 'spectr_band_index',
+ 'sample_model',
+ 'data_type',
+ 'scaling_method',
+ 'scaling_offset',
+ 'scaling_factor',
+ 'bm_expr',
+ 'unit',
+ 'description',
+ 'lines_mirrored',
+ )
+ for name in fields:
+ with self.subTest(field=name):
+ self.assertRaises(ValueError, getattr, self.band, name)
def test_get_name(self):
self.assertRaises(ValueError, self.product.get_band_at, 0)
@@ -1939,14 +1923,14 @@ class TestRecordOnClosedProduct(unittest.TestCase):
product = epr.Product(self.PRODUCT_FILE)
dataset = product.get_dataset(self.DATASET_NAME)
self.record = dataset.read_record(0)
- #self.mph = product.get_mph()
+ # self.mph = product.get_mph()
product.close()
def test_get_num_fields(self):
self.assertEqual(self.record.get_num_fields(), self.NUM_FIELD)
- #def test_get_num_fields_mph(self):
- # self.assertEqual(self.mph.get_num_fields(), 34)
+ # def test_get_num_fields_mph(self):
+ # self.assertEqual(self.mph.get_num_fields(), 34)
def test_print_(self):
self.assertRaises(ValueError, self.record.print_)
@@ -1988,7 +1972,7 @@ class TestField(unittest.TestCase):
FIELD_NUM_ELEMS = 1
FIELD_VALUES = (81,)
FIELD_UNIT = '%'
- #FIELD_OFFSET = 13
+ # FIELD_OFFSET = 13
def setUp(self):
self.product = epr.Product(self.PRODUCT_FILE, self.OPEN_MODE)
@@ -2208,8 +2192,8 @@ class TestFieldWrite(unittest.TestCase):
self.assertNotEqual(data, orig_data)
dtype = epr.get_numpy_dtype(self.FIELD_TYPE)
- data = np.fromstring(data, dtype)
- orig_data = np.fromstring(orig_data, dtype)
+ data = np.frombuffer(data, dtype)
+ orig_data = np.frombuffer(orig_data, dtype).copy()
orig_data[0] = value
npt.assert_array_equal(data, orig_data)
@@ -2269,8 +2253,8 @@ class TestFieldWrite(unittest.TestCase):
self.assertNotEqual(data, orig_data)
dtype = epr.get_numpy_dtype(self.FIELD_TYPE)
- data = np.fromstring(data, dtype)
- orig_data = np.fromstring(orig_data, dtype)
+ data = np.frombuffer(data, dtype)
+ orig_data = np.frombuffer(orig_data, dtype).copy()
orig_data[0] = value
npt.assert_array_equal(data, orig_data)
@@ -2330,8 +2314,8 @@ class TestFieldWrite(unittest.TestCase):
self.assertNotEqual(data, orig_data)
dtype = epr.get_numpy_dtype(self.FIELD_TYPE)
- data = np.fromstring(data, dtype)
- orig_data = np.fromstring(orig_data, dtype)
+ data = np.frombuffer(data, dtype)
+ orig_data = np.frombuffer(orig_data, dtype).copy()
orig_data[20] = value
npt.assert_array_equal(data, orig_data)
@@ -2386,8 +2370,8 @@ class TestFieldWrite(unittest.TestCase):
self.assertNotEqual(data, orig_data)
dtype = epr.get_numpy_dtype(self.FIELD_TYPE)
- data = np.fromstring(data, dtype)
- orig_data = np.fromstring(orig_data, dtype)
+ data = np.frombuffer(data, dtype)
+ orig_data = np.frombuffer(orig_data, dtype).copy()
orig_data += 1
npt.assert_array_equal(data, orig_data)
@@ -2526,11 +2510,11 @@ class TestFieldHighLevelAPI2(unittest.TestCase):
self.assertEqual(len(field), field.get_num_elems())
# @TODO: no e_tid_string field available
- #def test_len_e_tid_string(self):
- # dataset = self.product.get_dataset_at(0)
- # record = dataset.read_record(0)
- # field = record.get_field('???')
- # self.assertEqual(len(field), len(field.get_elem()))
+ # def test_len_e_tid_string(self):
+ # dataset = self.product.get_dataset_at(0)
+ # record = dataset.read_record(0)
+ # field = record.get_field('???')
+ # self.assertEqual(len(field), len(field.get_elem()))
class TestFieldLowLevelAPI(unittest.TestCase):
@@ -2717,7 +2701,7 @@ class TestDsdLowLevelAPI(unittest.TestCase):
self.product.close()
def test_magic(self):
- #self.assertEqual(self.dsd._magic, epr._EPR_MAGIC_DSD_ID)
+ # self.assertEqual(self.dsd._magic, epr._EPR_MAGIC_DSD_ID)
self.assertTrue(isinstance(self.dsd._magic, int))
@@ -2830,11 +2814,9 @@ class TestDataypeFunctions(unittest.TestCase):
def test_epr_to_numpy_dtype(self):
for epr_type in self.TYPE_MAP:
- #with self.subTest(epr_type=epr_type): # TODO: update (new in 3.4)
- # self.assertEqual(
- # epr.get_numpy_dtype(epr_type), self.TYPE_MAP[epr_type])
- self.assertEqual(
- epr.get_numpy_dtype(epr_type), self.TYPE_MAP[epr_type])
+ with self.subTest(epr_type=epr_type):
+ self.assertEqual(
+ epr.get_numpy_dtype(epr_type), self.TYPE_MAP[epr_type])
class TestScalingMethodFunctions(unittest.TestCase):
@@ -2954,5 +2936,6 @@ class TestMemoryLeaks(unittest.TestCase):
if __name__ == '__main__':
print('PyEPR: %s' % epr.__version__)
print('EPR API: %s' % epr.EPR_C_API_VERSION)
+ print('Numpy: %s' % np.__version__)
print('Python: %s' % sys.version)
unittest.main()
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyepr/compare/2bcaf639c73c4f76f6d8b021b20955e02c4e1f40...b81c3f1dad8342a093f2809f06a48bbf43f65d72
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyepr/compare/2bcaf639c73c4f76f6d8b021b20955e02c4e1f40...b81c3f1dad8342a093f2809f06a48bbf43f65d72
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20180823/9f73276e/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list