Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
A
anamnesis
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
naf
anamnesis
Commits
390a968d
Commit
390a968d
authored
Feb 27, 2020
by
Mark Hymers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for newer flake8 error messages
Signed-off-by:
Mark Hymers
<
mark.hymers@ynic.york.ac.uk
>
parent
94ba7b60
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
27 additions
and
26 deletions
+27
-26
anamnesis/abstract.py
anamnesis/abstract.py
+5
-5
anamnesis/tests/test_abstract.py
anamnesis/tests/test_abstract.py
+14
-14
doc/source/tutorials/test_script2_defaultgroup.py
doc/source/tutorials/test_script2_defaultgroup.py
+3
-3
doc/source/tutorials/test_script2_write.py
doc/source/tutorials/test_script2_write.py
+3
-3
setup.cfg
setup.cfg
+2
-0
setup.py
setup.py
+0
-1
No files found.
anamnesis/abstract.py
View file @
390a968d
...
...
@@ -525,11 +525,11 @@ class AbstractAnam(object):
# Now read any old-style lists in.
# This is for backwards compatibility only
for
l
in
lists
:
if
isinstance
(
l
,
bytes
):
l
=
l
.
decode
(
'utf-8'
)
hname
=
'LIST_'
+
l
setattr
(
ret
,
l
,
AnamList
.
from_oldstyle_hdf5
(
subgroup
,
hname
))
for
l
i
in
lists
:
if
isinstance
(
l
i
,
bytes
):
l
i
=
li
.
decode
(
'utf-8'
)
hname
=
'LIST_'
+
l
i
setattr
(
ret
,
l
i
,
AnamList
.
from_oldstyle_hdf5
(
subgroup
,
hname
))
# Tell the object to sort itself out if a Anam object
if
isinstance
(
ret
,
AbstractAnam
):
...
...
anamnesis/tests/test_abstract.py
View file @
390a968d
...
...
@@ -286,8 +286,8 @@ class AbstractWritingTest(AnamTestBase):
def
test_write_list_of_objects
(
self
):
"""Check that we can save and restore a list of objects"""
l
=
[
ExampleWriter
(
1
),
ExampleWriter
(
2
),
ExampleWriter
(
3
)]
a
=
ExampleListWriter
(
l
)
l
i
=
[
ExampleWriter
(
1
),
ExampleWriter
(
2
),
ExampleWriter
(
3
)]
a
=
ExampleListWriter
(
l
i
)
self
.
write_it
(
'test.hdf5'
,
a
)
b
=
self
.
read_it
(
'test.hdf5'
,
ExampleListWriter
)
assert
(
isinstance
(
b
,
ExampleListWriter
))
...
...
@@ -331,8 +331,8 @@ class AbstractWritingTest(AnamTestBase):
def
test_write_empty_dict
(
self
):
"""Check that we can save and restore an empty dictionary"""
l
=
{}
a
=
ExampleDictWriter
(
l
)
l
i
=
{}
a
=
ExampleDictWriter
(
l
i
)
self
.
write_it
(
'test.hdf5'
,
a
)
b
=
self
.
read_it
(
'test.hdf5'
,
ExampleDictWriter
)
assert
(
isinstance
(
b
,
ExampleDictWriter
))
...
...
@@ -341,8 +341,8 @@ class AbstractWritingTest(AnamTestBase):
def
test_write_basic_dict
(
self
):
"""Check that we can save and restore a basic dictionary"""
l
=
{
'A'
:
1
,
'B'
:
2
}
a
=
ExampleDictWriter
(
l
)
l
i
=
{
'A'
:
1
,
'B'
:
2
}
a
=
ExampleDictWriter
(
l
i
)
self
.
write_it
(
'test.hdf5'
,
a
)
b
=
self
.
read_it
(
'test.hdf5'
,
ExampleDictWriter
)
assert
(
isinstance
(
b
,
ExampleDictWriter
))
...
...
@@ -354,10 +354,10 @@ class AbstractWritingTest(AnamTestBase):
def
test_write_dict_with_objects
(
self
):
"""Check that we can save and restore a dictionary containing
objects"""
l
=
{
'a'
:
ExampleWriter
(
1
),
2
:
ExampleWriter
(
2
),
3
:
ExampleWriter
(
3
)}
a
=
ExampleDictWriter
(
l
)
l
i
=
{
'a'
:
ExampleWriter
(
1
),
2
:
ExampleWriter
(
2
),
3
:
ExampleWriter
(
3
)}
a
=
ExampleDictWriter
(
l
i
)
self
.
write_it
(
'test.hdf5'
,
a
)
b
=
self
.
read_it
(
'test.hdf5'
,
ExampleDictWriter
)
assert
(
isinstance
(
b
,
ExampleDictWriter
))
...
...
@@ -370,10 +370,10 @@ class AbstractWritingTest(AnamTestBase):
def
test_write_dict_with_dict
(
self
):
"""Check that we can save and restore a dictionary containing a
dictionary"""
l
=
{
'a'
:
ExampleWriter
(
1
),
2
:
{
'c'
:
99
,
'd'
:
100
,
'e'
:
ExampleWriter
(
'blah'
)},
3
:
ExampleWriter
(
3
)}
a
=
ExampleDictWriter
(
l
)
l
i
=
{
'a'
:
ExampleWriter
(
1
),
2
:
{
'c'
:
99
,
'd'
:
100
,
'e'
:
ExampleWriter
(
'blah'
)},
3
:
ExampleWriter
(
3
)}
a
=
ExampleDictWriter
(
l
i
)
self
.
write_it
(
'test.hdf5'
,
a
)
b
=
self
.
read_it
(
'test.hdf5'
,
ExampleDictWriter
)
...
...
doc/source/tutorials/test_script2_defaultgroup.py
View file @
390a968d
...
...
@@ -5,7 +5,7 @@ from test_classes2 import ComplexPerson, ComplexPlace # noqa: F401
# Load the classes from the HDF5 file using
# the default hdf5group names
s
=
ComplexPerson
.
from_hdf5file
(
'test_script2.hdf5'
)
l
=
ComplexPlace
.
from_hdf5file
(
'test_script2.hdf5'
)
l
oc
=
ComplexPlace
.
from_hdf5file
(
'test_script2.hdf5'
)
# Show that we have reconstructed the object
print
(
"Person"
)
...
...
@@ -15,5 +15,5 @@ print(s.age)
print
(
"Place"
)
print
(
type
(
l
))
print
(
l
.
location
)
print
(
type
(
l
oc
))
print
(
l
oc
.
location
)
doc/source/tutorials/test_script2_write.py
View file @
390a968d
...
...
@@ -14,8 +14,8 @@ s = ComplexPerson('Anna', 45)
print
(
s
.
name
)
print
(
s
.
age
)
l
=
ComplexPlace
(
'York'
)
print
(
l
.
location
)
l
oc
=
ComplexPlace
(
'York'
)
print
(
l
oc
.
location
)
t
=
ComplexTrain
(
'Glasgow'
)
print
(
t
.
destination
)
...
...
@@ -23,7 +23,7 @@ print(t.destination)
# Serialise the person and place to disk
f
=
h5py
.
File
(
'test_script2.hdf5'
,
'w'
)
s
.
to_hdf5
(
f
.
create_group
(
s
.
hdf5_defaultgroup
))
l
.
to_hdf5
(
f
.
create_group
(
l
.
hdf5_defaultgroup
))
l
oc
.
to_hdf5
(
f
.
create_group
(
loc
.
hdf5_defaultgroup
))
t
.
to_hdf5
(
f
.
create_group
(
t
.
hdf5_defaultgroup
))
f
.
close
()
...
...
setup.cfg
View file @
390a968d
[flake8]
max-line-length=120
exclude=build/
[build_sphinx]
source-dir = doc/source
build-dir = doc/build
...
...
setup.py
View file @
390a968d
#!/usr/bin/python
import
sys
import
os
from
setuptools
import
setup
# Scripts
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment