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
Commits
095f5131
There was a problem fetching the pipeline summary.
Commit
095f5131
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Plain Diff
Merge branch 'issue_6' into 'master'
Require C-contiguous/aligned array for writing (fixes
#6
) See merge request
!11
parents
fd7511d4
d0708ec3
No related branches found
No related tags found
1 merge request
!11
Require C-contiguous/aligned array for writing (fixes #6)
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/io/base/__init__.py
+8
-0
8 additions, 0 deletions
bob/io/base/__init__.py
bob/io/base/test_file.py
+3
-0
3 additions, 0 deletions
bob/io/base/test_file.py
with
11 additions
and
0 deletions
bob/io/base/__init__.py
+
8
−
0
View file @
095f5131
# import Libraries of other lib packages
# import Libraries of other lib packages
import
numpy
import
bob.core
import
bob.core
# import our own Library
# import our own Library
...
@@ -176,6 +177,9 @@ def save(array, filename, create_directories = False):
...
@@ -176,6 +177,9 @@ def save(array, filename, create_directories = False):
if
create_directories
:
if
create_directories
:
create_directories_safe
(
os
.
path
.
dirname
(
filename
))
create_directories_safe
(
os
.
path
.
dirname
(
filename
))
# requires data is c-contiguous and aligned, will create a copy otherwise
array
=
numpy
.
require
(
array
,
requirements
=
(
'
C_CONTIGUOUS
'
,
'
ALIGNED
'
))
return
File
(
filename
,
'
w
'
).
write
(
array
)
return
File
(
filename
,
'
w
'
).
write
(
array
)
# Just to make it homogenous with the C++ API
# Just to make it homogenous with the C++ API
...
@@ -204,6 +208,10 @@ def append(array, filename):
...
@@ -204,6 +208,10 @@ def append(array, filename):
``position`` : int
``position`` : int
See :py:meth:`File.append`
See :py:meth:`File.append`
"""
"""
# requires data is c-contiguous and aligned, will create a copy otherwise
array
=
numpy
.
require
(
array
,
requirements
=
(
'
C_CONTIGUOUS
'
,
'
ALIGNED
'
))
return
File
(
filename
,
'
a
'
).
append
(
array
)
return
File
(
filename
,
'
a
'
).
append
(
array
)
def
peek
(
filename
):
def
peek
(
filename
):
...
...
This diff is collapsed.
Click to expand it.
bob/io/base/test_file.py
+
3
−
0
View file @
095f5131
...
@@ -208,6 +208,7 @@ def test_hdf5():
...
@@ -208,6 +208,7 @@ def test_hdf5():
array_readwrite
(
"
.h5
"
,
a2
)
array_readwrite
(
"
.h5
"
,
a2
)
array_readwrite
(
'
.h5
'
,
a3
)
array_readwrite
(
'
.h5
'
,
a3
)
array_readwrite
(
"
.h5
"
,
a4
)
array_readwrite
(
"
.h5
"
,
a4
)
array_readwrite
(
'
.h5
'
,
a3
[:,::
2
,::
2
,::
2
])
#test non-contiguous
# arrayset writing tests
# arrayset writing tests
a1
=
[]
a1
=
[]
...
@@ -274,6 +275,7 @@ def test_tensorfile():
...
@@ -274,6 +275,7 @@ def test_tensorfile():
array_readwrite
(
'
.tensor
'
,
a1
)
array_readwrite
(
'
.tensor
'
,
a1
)
array_readwrite
(
"
.tensor
"
,
a2
)
array_readwrite
(
"
.tensor
"
,
a2
)
array_readwrite
(
"
.tensor
"
,
a3
)
array_readwrite
(
"
.tensor
"
,
a3
)
array_readwrite
(
'
.tensor
'
,
a3
[::
2
,::
2
])
#test non-contiguous
# arrayset writing tests
# arrayset writing tests
a1
=
[]
a1
=
[]
...
@@ -302,6 +304,7 @@ def test_csv():
...
@@ -302,6 +304,7 @@ def test_csv():
array_readwrite
(
'
.csv
'
,
a1
,
close
=
True
)
array_readwrite
(
'
.csv
'
,
a1
,
close
=
True
)
array_readwrite
(
"
.csv
"
,
a2
,
close
=
True
)
array_readwrite
(
"
.csv
"
,
a2
,
close
=
True
)
array_readwrite
(
'
.csv
'
,
a3
,
close
=
True
)
array_readwrite
(
'
.csv
'
,
a3
,
close
=
True
)
array_readwrite
(
'
.csv
'
,
a3
[::
2
,::
2
],
close
=
True
)
#test non-contiguous
# arrayset writing tests
# arrayset writing tests
a1
=
[]
a1
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment