Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.measure
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.measure
Commits
7ed0fdca
There was a problem fetching the pipeline summary.
Commit
7ed0fdca
authored
8 years ago
by
Manuel Günther
Browse files
Options
Downloads
Patches
Plain Diff
Implemented load_score_with_generator function using csv.DictReader
parent
5a688f7d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!20
Resolve "load_scores extremely memory hungry"
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/measure/load.py
+5
-8
5 additions, 8 deletions
bob/measure/load.py
with
5 additions
and
8 deletions
bob/measure/load.py
+
5
−
8
View file @
7ed0fdca
...
...
@@ -319,7 +319,7 @@ COLUMNS = {
}
def
load_score_with_generator
(
filename
,
ncolumns
=
None
):
"""
Load scores using :py:class:`csv.
r
eader` and yield the scores line by line in a dictionary.
"""
Load scores using :py:class:`csv.
DictR
eader` and yield the scores line by line in a dictionary.
Parameters:
...
...
@@ -351,13 +351,10 @@ def load_score_with_generator(filename, ncolumns=None):
elif
ncolumns
not
in
(
4
,
5
):
raise
ValueError
(
"
ncolumns of 4 and 5 are supported only.
"
)
names
=
COLUMNS
[
ncolumns
]
r
=
csv
.
reader
(
open_file
(
filename
,
mode
=
'
rb
'
),
delimiter
=
'
'
)
for
n
,
splits
in
enumerate
(
r
):
assert
len
(
splits
)
==
ncolumns
,
"
The line %d: %s of file %s is not compatible
"
%
(
n
,
"
"
.
join
(
splits
),
filename
)
splits
[
-
1
]
=
float
(
splits
[
-
1
])
yield
{
names
[
i
]
:
splits
[
i
]
for
i
in
range
(
ncolumns
)}
reader
=
csv
.
DictReader
(
open_file
(
filename
,
mode
=
'
rb
'
),
fieldnames
=
COLUMNS
[
ncolumns
],
delimiter
=
'
'
)
for
splits
in
reader
:
splits
[
'
score
'
]
=
float
(
splits
[
'
score
'
])
yield
splits
def
get_negatives_positives_from_generator
(
score_lines
):
"""
Take the output of :py:func:`load_score_with_generator` and return negatives and positives. This
...
...
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