Skip to content
Snippets Groups Projects
Unverified Commit 93584e76 authored by Stephan Kuschel's avatar Stephan Kuschel Committed by GitHub
Browse files

Merge pull request #268 from skuschel/dev

fix flake8 and update .gitignore
parents 0bbd078b 7bf660a3
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,7 @@ target/ ...@@ -68,7 +68,7 @@ target/
.pydevproject .pydevproject
*.png *.png
*.swp *.swp
.idea/
# there might be ipython notebooks # there might be ipython notebooks
.ipynb_checkpoints .ipynb_checkpoints
......
...@@ -220,7 +220,7 @@ class Dumpreader_ifc(with_metaclass(abc.ABCMeta, FieldAnalyzer)): ...@@ -220,7 +220,7 @@ class Dumpreader_ifc(with_metaclass(abc.ABCMeta, FieldAnalyzer)):
for key in self._simgridkeys(): for key in self._simgridkeys():
try: try:
return self.gridpoints(key, axis) return self.gridpoints(key, axis)
except(KeyError): except KeyError:
pass pass
raise KeyError raise KeyError
...@@ -234,7 +234,7 @@ class Dumpreader_ifc(with_metaclass(abc.ABCMeta, FieldAnalyzer)): ...@@ -234,7 +234,7 @@ class Dumpreader_ifc(with_metaclass(abc.ABCMeta, FieldAnalyzer)):
offset = self.gridoffset(key, axis) offset = self.gridoffset(key, axis)
n = self.gridpoints(key, axis) n = self.gridpoints(key, axis)
return np.array([offset, offset + self.gridspacing(key, axis) * n]) return np.array([offset, offset + self.gridspacing(key, axis) * n])
except(KeyError): except KeyError:
pass pass
raise KeyError('Unable to resolve "simexent" for axis "{:}"'.format(axis)) raise KeyError('Unable to resolve "simexent" for axis "{:}"'.format(axis))
......
...@@ -74,7 +74,7 @@ class Sdfreader(Dumpreader_ifc): ...@@ -74,7 +74,7 @@ class Sdfreader(Dumpreader_ifc):
import sdf import sdf
try: try:
sdfversion = sdf.__version__ sdfversion = sdf.__version__
except(AttributeError): except AttributeError:
sdfversion = '0.0.0' sdfversion = '0.0.0'
if sdfversion < '2.2.0': if sdfversion < '2.2.0':
raise ImportError('Upgrade sdf package to 2.2.0 or higher.') raise ImportError('Upgrade sdf package to 2.2.0 or higher.')
...@@ -210,7 +210,7 @@ class Sdfreader(Dumpreader_ifc): ...@@ -210,7 +210,7 @@ class Sdfreader(Dumpreader_ifc):
12: lambda s: self['Particles/Charge/' + s].data} 12: lambda s: self['Particles/Charge/' + s].data}
try: try:
ret = options[attribid](species) ret = options[attribid](species)
except(IndexError): except IndexError:
raise KeyError('Attribute "{}" of species "{}" not found.'.format(attrib, species)) raise KeyError('Attribute "{}" of species "{}" not found.'.format(attrib, species))
return ret return ret
......
...@@ -124,7 +124,7 @@ class OpenPMDreader(Dumpreader_ifc): ...@@ -124,7 +124,7 @@ class OpenPMDreader(Dumpreader_ifc):
try: try:
gs = self.gridspacing(k, None) gs = self.gridspacing(k, None)
return len(gs) return len(gs)
except(KeyError): except KeyError:
pass pass
raise KeyError('number of simdimensions could not be retrieved for {}'.format(self)) raise KeyError('number of simdimensions could not be retrieved for {}'.format(self))
...@@ -170,7 +170,7 @@ class OpenPMDreader(Dumpreader_ifc): ...@@ -170,7 +170,7 @@ class OpenPMDreader(Dumpreader_ifc):
if offsetkey is not None: if offsetkey is not None:
data += self.data(offsetkey.format(species)) data += self.data(offsetkey.format(species))
ret = np.asarray(data, dtype=np.float64) ret = np.asarray(data, dtype=np.float64)
except(IndexError): except IndexError:
raise KeyError raise KeyError
return ret return ret
......
...@@ -88,7 +88,7 @@ class Hdf5reader(Dumpreader_ifc): ...@@ -88,7 +88,7 @@ class Hdf5reader(Dumpreader_ifc):
axis = helper.axesidentify[axis] axis = helper.axesidentify[axis]
try: try:
return np.float64(self["ElecMultiField"][..., axis]) return np.float64(self["ElecMultiField"][..., axis])
except(KeyError): except KeyError:
return None return None
def dataB(self, axis, **kwargs): def dataB(self, axis, **kwargs):
...@@ -96,7 +96,7 @@ class Hdf5reader(Dumpreader_ifc): ...@@ -96,7 +96,7 @@ class Hdf5reader(Dumpreader_ifc):
axis = helper.axesidentify[axis] axis = helper.axesidentify[axis]
try: try:
return np.float64(self["MagMultiField"][..., axis]) return np.float64(self["MagMultiField"][..., axis])
except(KeyError): except KeyError:
return None return None
def grid(self, axis): def grid(self, axis):
......
...@@ -88,7 +88,7 @@ def histogramdd(data, **kwargs): ...@@ -88,7 +88,7 @@ def histogramdd(data, **kwargs):
if shape[0] > 3 and len(shape) == 2: # (N, D) array if shape[0] > 3 and len(shape) == 2: # (N, D) array
# data[:,i] will create a view consuming only microseconds # data[:,i] will create a view consuming only microseconds
data = [data[:, i] for i in range(shape[1])] data = [data[:, i] for i in range(shape[1])]
except(AttributeError): except AttributeError:
pass pass
# upcast 1D if length 1 dimensions are omitted # upcast 1D if length 1 dimensions are omitted
...@@ -122,7 +122,7 @@ def histogramdd(data, **kwargs): ...@@ -122,7 +122,7 @@ def histogramdd(data, **kwargs):
if not np.isscalar(ranges[ax][i]): if not np.isscalar(ranges[ax][i]):
# if value can be accessed it must be a scalar value # if value can be accessed it must be a scalar value
raise ValueError('range="{}" not properly formatted.'.format(kwrange)) raise ValueError('range="{}" not properly formatted.'.format(kwrange))
except(TypeError): except TypeError:
ranges[ax][i] = f(d) ranges[ax][i] = f(d)
kwrange = ranges kwrange = ranges
......
...@@ -79,7 +79,7 @@ class _SingleSpecies(object): ...@@ -79,7 +79,7 @@ class _SingleSpecies(object):
if species not in dumpreader.listSpecies(): if species not in dumpreader.listSpecies():
# A better way would be to test if len(self) == 0, # A better way would be to test if len(self) == 0,
# but that may require heavy IO # but that may require heavy IO
raise(KeyError('species "{:}" does not exist in {:}'.format(species, dumpreader))) raise KeyError('species "{:}" does not exist in {:}'.format(species, dumpreader))
self.species = species self.species = species
self._dumpreader = dumpreader self._dumpreader = dumpreader
self.compresslog = [] self.compresslog = []
...@@ -136,7 +136,7 @@ class _SingleSpecies(object): ...@@ -136,7 +136,7 @@ class _SingleSpecies(object):
elif key in ['mass', 'charge']: elif key in ['mass', 'charge']:
try: try:
ret = self._dumpreader.getSpecies(self.species, key) ret = self._dumpreader.getSpecies(self.species, key)
except(KeyError): except KeyError:
# in the special case of mass or charge try to deduce mass or charge # in the special case of mass or charge try to deduce mass or charge
# from the species name. # from the species name.
self._idfy = identifyspecies(self.species) self._idfy = identifyspecies(self.species)
...@@ -321,7 +321,7 @@ class _SingleSpecies(object): ...@@ -321,7 +321,7 @@ class _SingleSpecies(object):
for source in [np, scipy.constants]: for source in [np, scipy.constants]:
try: try:
_vars[name] = getattr(source, name) _vars[name] = getattr(source, name)
except(AttributeError): except AttributeError:
pass pass
if name not in _vars: if name not in _vars:
raise KeyError('"{}" not found!'.format(name)) raise KeyError('"{}" not found!'.format(name))
...@@ -509,7 +509,7 @@ class MultiSpecies(object): ...@@ -509,7 +509,7 @@ class MultiSpecies(object):
if ignore_missing_species: if ignore_missing_species:
try: try:
self._ssas.append(_SingleSpecies(dumpreader, species)) self._ssas.append(_SingleSpecies(dumpreader, species))
except(KeyError): except KeyError:
pass pass
else: else:
self._ssas.append(_SingleSpecies(dumpreader, species)) self._ssas.append(_SingleSpecies(dumpreader, species))
...@@ -649,7 +649,7 @@ class MultiSpecies(object): ...@@ -649,7 +649,7 @@ class MultiSpecies(object):
return self.__call_sp(expr) return self.__call_sp(expr)
try: try:
bs = basestring # python2 bs = basestring # python2
except(NameError): except NameError:
bs = str # python3 bs = str # python3
if isinstance(expr, bs): if isinstance(expr, bs):
# create temporary ScalarProperty object # create temporary ScalarProperty object
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment