Commit c68c7e84 authored by Mark Hymers's avatar Mark Hymers

Flake8 fixes

Signed-off-by: Mark Hymers's avatarMark Hymers <mark.hymers@ynic.york.ac.uk>
parent 78e3f2da
......@@ -2,8 +2,8 @@
# vim: set expandtab ts=4 sw=4:
from .abstract import * # noqa: F403
from .mpihandler import * # noqa: F403
from .options import AnamOptions # noqa: F401
from .register import find_class, register_class, ClassRegister # noqa: F401
from .store import Store # noqa: F401
from .abstract import * # noqa: F403,F401
from .mpihandler import * # noqa: F403,F401
from .options import AnamOptions # noqa: F403,F401
from .register import find_class, register_class, ClassRegister # noqa: F403,F401
from .store import Store # noqa: F403,F401
This diff is collapsed.
......@@ -127,12 +127,14 @@ class MPIHandler(object):
def abort(self):
self.handler.abort()
__all__.append('MPIHandler')
def mpi_print(txt):
print("NODE %s: %s" % (MPIHandler().rank, txt))
__all__.append('mpi_print')
# Some test code
......
......@@ -58,8 +58,8 @@ class MPI4PyImplementor(object):
return self.mpi.recv(None, source=source, tag=tag, status=status)
else:
raise Exception("Rank %d cannot understand MPI recieve type "
"%s, expecting ANAM or NORMAL" %
(self.rank, t))
"%s, expecting ANAM or NORMAL" %
(self.rank, t))
def send(self, obj=None, dest=0, tag=0):
if hasattr(obj, 'get_hdf5name') and hasattr(obj, 'send'):
......@@ -91,8 +91,8 @@ class MPI4PyImplementor(object):
return self.mpi.bcast(None, root=root)
else:
raise Exception("Rank %d cannot understand MPI broadcast "
"type %s, expecting ANAM or NORMAL" %
(self.rank, t))
"type %s, expecting ANAM or NORMAL" %
(self.rank, t))
else:
if hasattr(data_in, 'get_hdf5name') and hasattr(data_in, 'bcast'):
self.mpi.bcast('ANAM', root=root)
......
......@@ -56,4 +56,5 @@ class NullMPIImplementor(object):
def abort(self):
return
__all__.append('NullMPIImplementor')
......@@ -34,4 +34,5 @@ class AnamOptions(object):
if self.progress > 0:
target.write(s)
__all__.append('AnamOptions')
......@@ -185,4 +185,5 @@ def find_class(name):
return None
__all__ = ['register_class', 'find_class']
......@@ -37,5 +37,6 @@ class Store(AbstractAnam):
def __ne__(self, other):
return not self.__eq__(other)
__all__.append('Store')
register_class(Store)
......@@ -33,7 +33,7 @@ def find_path(varname, sentinal, subdir=None):
# Our test file
if not isfile(join(dir, sentinal)):
raise Exception("%s does not seem to contain sentinal "
"file %s" % (varname, sentinal))
"file %s" % (varname, sentinal))
return abspath(dir)
......@@ -81,6 +81,7 @@ def array_assert(a, b, decimal=None, **kwargs):
from numpy.testing import assert_almost_equal
assert_almost_equal(a, b, decimal, *kwargs)
__all__.append('array_assert')
......@@ -140,4 +141,5 @@ class AnamTestBase(unittest.TestCase):
abs_filename = join(self.tempdir, filename)
os.stat(abs_filename)
__all__.append('AnamTestBase')
......@@ -8,5 +8,6 @@ from ..register import register_class
class AutoLoadTestCase():
pass
__all__ = ['AutoLoadTestCase']
register_class(AutoLoadTestCase)
......@@ -17,5 +17,6 @@ class NameMapTestCase(AbstractAnam):
self._classvarname = 'foo'
__all__ = ['NameMapTestCase']
register_class(NameMapTestCase)
......@@ -16,7 +16,7 @@ DATADIR = anamtestpath()
# Tests that involve writing are grouped in a class
from ..abstract import AbstractAnam, register_class
from ..abstract import AbstractAnam, register_class # noqa: F402
class TestDictWriter(AbstractAnam):
......@@ -28,6 +28,7 @@ class TestDictWriter(AbstractAnam):
self.ddat = setvals
register_class(TestDictWriter)
......@@ -40,6 +41,7 @@ class TestListWriter(AbstractAnam):
self.ldat = setvals
register_class(TestListWriter)
......@@ -52,6 +54,7 @@ class TestWriter(AbstractAnam):
self.dat = setvals
register_class(TestWriter)
......@@ -75,6 +78,7 @@ class TestArrayContainer(AbstractAnam):
# by object ID for test purposes
return id(self) == id(other)
register_class(TestArrayContainer)
......@@ -486,6 +490,7 @@ class AbstractWritingTest(AnamTestBase):
def test_classname(self):
"""Check that we correctly check alias names"""
from ..abstract import AbstractAnam
class AliasNameTest(AbstractAnam):
hdf5_aliases = ['test.this.is.an.alias']
......@@ -979,6 +984,7 @@ class AbstractCollectionTest(AnamTestBase):
c += 1
assert(c == 2)
class AnamDictTest(AnamTestBase):
def test_create_anam_dict(self):
"""Test creation of anam dict"""
......@@ -1031,7 +1037,6 @@ class AnamNamemapTest(AnamTestBase):
def test_namemap_readwrite(self):
"""Test use of namemap functionality with new file"""
import h5py
from ..abstract import obj_from_hdf5file
from .namemap_example import NameMapTestCase
n = NameMapTestCase()
......@@ -1043,7 +1048,7 @@ class AnamNamemapTest(AnamTestBase):
f = h5py.File(join(self.tempdir, 'testnm.hdf5'), 'r')
assert('filevarname' in f['nmtest'].attrs)
blah = NameMapTestCase.from_hdf5(f['nmtest'])
NameMapTestCase.from_hdf5(f['nmtest'])
f.close()
assert(isinstance(n, NameMapTestCase))
......
......@@ -13,7 +13,8 @@ if sys.version_info.major == 2:
else:
from io import StringIO
from ..test import AnamTestBase
from ..test import AnamTestBase # noqa: E402
class OptionsTest(AnamTestBase):
def test_init_options(self):
......@@ -46,7 +47,6 @@ class OptionsTest(AnamTestBase):
def test_write_progress(self):
"""Check that we write appropriately with progress set"""
from sys import stdout
from ..options import AnamOptions
a = AnamOptions()
a.progress = 0
......@@ -68,7 +68,6 @@ class OptionsTest(AnamTestBase):
def test_write_verbose(self):
"""Check that we write appropriately with verbose set"""
from sys import stdout
from ..options import AnamOptions
a = AnamOptions()
a.verbose = 0
......@@ -87,4 +86,3 @@ class OptionsTest(AnamTestBase):
t = s.read()
assert(t == "Should be written")
s.close()
......@@ -2,6 +2,7 @@
from anamnesis import AbstractAnam, register_class
class SimplePerson(AbstractAnam):
hdf5_outputs = ['name', 'age']
......@@ -12,4 +13,5 @@ class SimplePerson(AbstractAnam):
self.name = name
self.age = age
register_class(SimplePerson)
......@@ -2,6 +2,7 @@
from anamnesis import AbstractAnam, register_class
class ComplexPerson(AbstractAnam):
hdf5_outputs = ['name', 'age']
......@@ -16,6 +17,7 @@ class ComplexPerson(AbstractAnam):
self.name = name
self.age = age
register_class(ComplexPerson)
......@@ -30,6 +32,7 @@ class ComplexPlace(AbstractAnam):
self.location = location
register_class(ComplexPlace)
......
......@@ -2,6 +2,7 @@
from anamnesis import AbstractAnam, AnamCollection, register_class
class CollectableSubjectStats(AbstractAnam):
hdf5_outputs = ['zstats', 'rts']
......@@ -18,10 +19,12 @@ class CollectableSubjectStats(AbstractAnam):
self.zstats = zstats
self.rts = rts
register_class(CollectableSubjectStats)
class StatsCollection(AnamCollection):
anam_combine = ['zstats', 'rts']
register_class(StatsCollection)
#!/usr/bin/python3
import h5py
from anamnesis import obj_from_hdf5file
import test_classes1
import test_classes1 # noqa: F401
# Load the class from the HDF5 file
s = obj_from_hdf5file('test_script1.hdf5')
......
#!/usr/bin/python3
import h5py
from anamnesis import obj_from_hdf5group, ClassRegister
# Register our class prefix so that we autoload our objects. This
......
#!/usr/bin/python3
import h5py
from anamnesis import obj_from_hdf5file
import test_classes2
import test_classes2 # noqa: F401
# Demonstrate reading a file which has the old class name
# in the HDF5 file
......
#!/usr/bin/python3
import h5py
from anamnesis import obj_from_hdf5file
from test_classes2 import ComplexPerson, ComplexPlace
from test_classes2 import ComplexPerson, ComplexPlace # noqa: F401
# Load the classes from the HDF5 file using
# the default hdf5group names
......
......@@ -26,5 +26,3 @@ p = obj_from_hdf5file('test_script2_extradata.hdf5')
# Show that we recovered the object and the extra data
print(p)
print(p.extra_data)
#!/usr/bin/python3
import h5py
from anamnesis import obj_from_hdf5file
from test_classes2 import ComplexPerson
from test_classes2 import ComplexPerson # noqa: F401
# Load the train object and watch for the printed output from the
# init_from_hdf5 function
p = obj_from_hdf5file('test_script2.hdf5', 'train')
#!/usr/bin/python3
import h5py
import numpy as np
from anamnesis import obj_from_hdf5file
import test_classes3
import test_classes3 # noqa: F401
# Load our collection of data
c = obj_from_hdf5file('test_script3.hdf5')
......@@ -21,5 +18,3 @@ c.update_cache()
# Demonstrate that we have access to stacked versions of the data
print(c.zstats.shape)
print(c.rts.shape)
......@@ -23,5 +23,3 @@ for person in range(5):
f = h5py.File('test_script3.hdf5', 'w')
collection.to_hdf5(f.create_group('data'))
f.close()
#!/usr/bin/python3
import h5py
from anamnesis import obj_from_hdf5file
# Read from our store
......@@ -9,4 +7,3 @@ s = obj_from_hdf5file('test_script4.hdf5')
print(s.extra_data['airport_from'])
print(s.extra_data['airport_to'])
......@@ -8,11 +8,9 @@ from anamnesis import Store
s = Store()
s.extra_data['airport_from'] = 'Manchester'
s.extra_data['airport_to'] = 'Schipol'
s.extra_data['airport_to'] = 'Schipol'
# Write the store into a file
f = h5py.File('test_script4.hdf5', 'w')
s.to_hdf5(f.create_group('data'))
f.close()
[flake8]
max-line-length=120
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
......@@ -2,7 +2,7 @@
import sys
import os
from setuptools import setup, find_packages
from setuptools import setup
# Scripts
scripts = []
......@@ -14,7 +14,7 @@ if len(sys.argv) == 2 and sys.argv[1] == '--list-scripts':
# Allow us to build on readthedocs which doesn't have MPI
install_requires = ['h5py', 'sphinx_rtd_theme']
if not 'READTHEDOCS' in os.environ:
if 'READTHEDOCS' not in os.environ:
install_requires += ['mpi4py']
name = 'anamnesis'
......@@ -22,9 +22,9 @@ version = '1.0'
release = '1.0.0'
setup(
name = name,
name=name,
version = release,
version=release,
description='Object serialisation to/from HDF5 and via MPI',
......@@ -59,21 +59,21 @@ setup(
keywords='hdf5 mpi serialisation',
packages = ['anamnesis', 'anamnesis.test',
'anamnesis.test.data',
'anamnesis.tests'],
packages=['anamnesis', 'anamnesis.test',
'anamnesis.test.data',
'anamnesis.tests'],
package_data = {
package_data={
'anamnesis.test.data': ['*.hdf5']
},
install_requires = install_requires,
install_requires=install_requires,
extras_require={
'test': ['coverage'],
},
command_options = {
command_options={
'build_sphinx': {
'project': ('setup.py', name),
'version': ('setup.py', name),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment