Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.io.base
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.io.base
Merge requests
!42
Improve support for writing and reading scalars in hdf5
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Improve support for writing and reading scalars in hdf5
hdf5-scalar-support
into
master
Overview
0
Commits
1
Pipelines
2
Changes
2
Merged
Amir MOHAMMADI
requested to merge
hdf5-scalar-support
into
master
3 years ago
Overview
0
Commits
1
Pipelines
2
Changes
2
Expand
0
0
Merge request reports
Compare
master
version 1
fe73d8e8
3 years ago
master (base)
and
latest version
latest version
797aeb75
1 commit,
3 years ago
version 1
fe73d8e8
1 commit,
3 years ago
2 files
+
24
−
18
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
bob/io/base/test/test_hdf5.py
+
14
−
14
Options
@@ -7,29 +7,24 @@
"""
Tests for the base HDF5 infrastructure
"""
import
os
import
random
import
tempfile
import
numpy
as
np
from
bob.io.base
import
load
,
save
from
..test_utils
import
temporary_filename
def
read_write_check
(
data
):
def
read_write_check
(
data
,
numpy_assert
=
True
):
"""
Testing loading and save different file types
"""
tmpname
=
temporary_filename
()
try
:
save
(
data
,
tmpname
)
data2
=
load
(
tmpname
)
finally
:
os
.
unlink
(
tmpname
)
assert
np
.
allclose
(
data
,
data2
,
atol
=
10e-5
,
rtol
=
10e-5
)
with
tempfile
.
NamedTemporaryFile
(
prefix
=
"
bobtest_
"
,
suffix
=
"
.hdf5
"
)
as
f
:
save
(
data
,
f
.
name
)
data2
=
load
(
f
.
name
)
if
numpy_assert
:
assert
np
.
allclose
(
data
,
data2
,
atol
=
10e-5
,
rtol
=
10e-5
)
else
:
assert
data
==
data2
def
test_type_support
():
@@ -54,3 +49,8 @@ def test_type_support():
read_write_check
(
np
.
array
(
data
,
np
.
float64
))
read_write_check
(
np
.
array
(
data
,
np
.
complex64
))
read_write_check
(
np
.
array
(
data
,
np
.
complex128
))
def
test_scalar_support
():
for
oracle
in
(
1
,
1.0
,
1j
,
"
a
"
,
True
):
read_write_check
(
oracle
,
numpy_assert
=
False
)
Loading