[h5py] 32/38: Fix lint issues in the selections modules
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:21:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository h5py.
commit bb72f3bc4d5f4ef66ead9bab81ba005aa25c4484
Author: Andrew Collette <andrew.collette at gmail.com>
Date: Sat May 30 19:07:47 2015 -0600
Fix lint issues in the selections modules
---
h5py/_hl/selections.py | 88 ++++---------------------------------------------
h5py/_hl/selections2.py | 12 +++++--
2 files changed, 17 insertions(+), 83 deletions(-)
diff --git a/h5py/_hl/selections.py b/h5py/_hl/selections.py
index 8f93524..95fe251 100644
--- a/h5py/_hl/selections.py
+++ b/h5py/_hl/selections.py
@@ -7,6 +7,9 @@
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
+# We use __getitem__ side effects, which pylint doesn't like.
+# pylint: disable=pointless-statement
+
"""
High-level access to HDF5 dataspace selections
"""
@@ -20,16 +23,6 @@ import numpy as np
from .. import h5s, h5r
-# Selection types for hyperslabs
-from ..h5s import SELECT_SET as SET
-from ..h5s import SELECT_OR as OR
-from ..h5s import SELECT_AND as AND
-from ..h5s import SELECT_XOR as XOR
-from ..h5s import SELECT_NOTB as NOTB
-from ..h5s import SELECT_NOTA as NOTA
-
-if six.PY3:
- long = int
def select(shape, args, dsid):
""" High-level routine to generate a selection from arbitrary arguments
@@ -119,7 +112,7 @@ class _RegionProxy(object):
""" Takes arbitrary selection terms and produces a RegionReference
object. Selection must be compatible with the dataset.
"""
- selection = select(self.id.shape, args)
+ selection = select(self.id.shape, args, self.id)
return h5r.create(self.id, '.', h5r.DATASET_REGION, selection.id)
class Selection(object):
@@ -198,7 +191,7 @@ class PointSelection(Selection):
"""
def _perform_selection(self, points, op):
-
+ """ Internal method which actually performs the selection """
points = np.asarray(points, order='C', dtype='u8')
if len(points.shape) == 1:
points.shape = (1,points.shape[0])
@@ -306,7 +299,7 @@ class SimpleSelection(Selection):
tshape = tuple(tshape)
chunks = tuple(x//y for x, y in zip(count, tshape))
- nchunks = long(np.product(chunks))
+ nchunks = int(np.product(chunks))
if nchunks == 1:
yield self._id
@@ -319,71 +312,6 @@ class SimpleSelection(Selection):
yield sid
-class HyperSelection(Selection):
-
- """
- Represents multiple overlapping rectangular selections, combined
- with set-like operators. Result is a 1D shape, as with boolean array
- selection. Broadcasting is not supported for these selections.
-
- When created, the entire dataspace is selected. To make
- adjustments to the selection, use the standard NumPy slicing
- syntax, either via __getitem__ (as with simple selections) or via
- __setitem__ and one of the supported operators:
-
- >>> sel = HyperSelection((10,20)) # Initially 200 points
- >>> sel[:,5:15] = False # Now 100 points
- >>> sel[:,10] = True # Now 110 points
- >>> sel[...] = XOR # Now 90 points
-
- Legal operators (in the h5py.selections module) are:
-
- SET
- New selection, wiping out any old one
-
- AND, XOR, OR (or True)
- Logical AND/XOR/OR between new and old selection
-
- NOTA
- Select only regions in new selection which don't intersect the old
-
- NOTB (or False)
- Select only regions in old selection which don't intersect the new
-
- """
-
- def __getitem__(self, args):
- self[args] = SET
- return self
-
- def __setitem__(self, args, op):
-
- if not isinstance(args, tuple):
- args = (args,)
-
- start, count, step, scalar = _handle_simple(self.shape, args)
-
- if not op in (SET, OR, AND, XOR, NOTB, NOTA, True, False):
- raise ValueError("Illegal selection operator")
-
- if op is True:
- op = OR
- elif op is False:
- op = NOTB
-
- seltype = self._id.get_select_type()
-
- if seltype == h5s.SEL_ALL:
- self._id.select_hyperslab((0,)*len(self.shape), self.shape, op=h5s.SELECT_SET)
-
- elif seltype == h5s.SEL_NONE:
- if op in (SET, OR, XOR, NOTA):
- op = SET
- else:
- return
-
- self._id.select_hyperslab(start, count, step, op=op)
-
class FancySelection(Selection):
"""
@@ -429,10 +357,8 @@ class FancySelection(Selection):
raise TypeError("Indexing elements must be in increasing order")
if len(sequenceargs) > 1:
- # TODO: fix this with broadcasting
raise TypeError("Only one indexing vector or array is currently allowed for advanced selection")
if len(sequenceargs) == 0:
- # TODO: fallback to standard selection
raise TypeError("Advanced selection inappropriate")
vectorlength = len(list(sequenceargs.values())[0])
@@ -484,7 +410,7 @@ def _expand_ellipsis(args, rank):
final_args = []
n_args = len(args)
- for idx, arg in enumerate(args):
+ for arg in args:
if arg is Ellipsis:
final_args.extend( (slice(None,None,None),)*(rank-n_args+1) )
diff --git a/h5py/_hl/selections2.py b/h5py/_hl/selections2.py
index d0e1b54..57e68ed 100644
--- a/h5py/_hl/selections2.py
+++ b/h5py/_hl/selections2.py
@@ -7,6 +7,10 @@
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
+"""
+ Implements a portion of the selection operations.
+"""
+
from __future__ import absolute_import
import numpy as np
@@ -26,7 +30,7 @@ def read_dtypes(dataset_dtype, names):
raise ValueError("Field names only allowed for compound types")
elif any(x not in dataset_dtype.names for x in names):
- raise ValueError("Field %s does not appear in this type." % name)
+ raise ValueError("Field does not appear in this type.")
else:
format_dtype = np.dtype([(name, dataset_dtype.fields[name][0]) for name in names])
@@ -71,6 +75,10 @@ def read_selections_scalar(dsid, args):
class ScalarReadSelection(object):
+ """
+ Undocumented.
+ """
+
def __init__(self, fspace, args):
if args == ():
self.mshape = None
@@ -87,7 +95,7 @@ class ScalarReadSelection(object):
yield self.fspace, self.mspace
def select_read(fspace, args):
-
+ """ Undocumented. """
if fspace.shape == ():
return ScalarReadSelection(fspace, args)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git
More information about the debian-science-commits
mailing list