Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LDV Specification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
ASTRON SDC
LDV Specification
Commits
b4323341
Commit
b4323341
authored
2 years ago
by
Fanna Lautenbach
Browse files
Options
Downloads
Patches
Plain Diff
fix n_bins for unique values and change formatting to 3 decimals
parent
97938437
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!50
fix n_bins for unique values and change formatting to 3 decimals
Pipeline
#41507
passed
2 years ago
Stage: test
Stage: build
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ldvspec/lofardata/tests/test_util_funcs.py
+29
-3
29 additions, 3 deletions
ldvspec/lofardata/tests/test_util_funcs.py
ldvspec/lofardata/views.py
+3
-2
3 additions, 2 deletions
ldvspec/lofardata/views.py
with
32 additions
and
5 deletions
ldvspec/lofardata/tests/test_util_funcs.py
+
29
−
3
View file @
b4323341
...
@@ -60,7 +60,7 @@ class ComputeInputsHistogram(unittest.TestCase):
...
@@ -60,7 +60,7 @@ class ComputeInputsHistogram(unittest.TestCase):
self
.
assertEqual
(
53832140800
,
max_size
)
self
.
assertEqual
(
53832140800
,
max_size
)
self
.
assertEqual
(
2
,
biggest_bucket
)
self
.
assertEqual
(
2
,
biggest_bucket
)
self
.
assertListEqual
([
1
,
2
,
2
,
0
,
0
,
1
],
counts
)
self
.
assertListEqual
([
1
,
2
,
2
,
0
,
0
,
1
],
counts
)
self
.
assertListEqual
([
'
20.3GB
'
,
'
25.3GB
'
,
'
30.
3
GB
'
,
'
35.2GB
'
,
'
40.2GB
'
,
'
45.
2
GB
'
,
'
50.1GB
'
],
bins
)
self
.
assertListEqual
([
'
20.
33
3GB
'
,
'
25.3
00
GB
'
,
'
30.
267
GB
'
,
'
35.2
34
GB
'
,
'
40.2
01
GB
'
,
'
45.
168
GB
'
,
'
50.1
35
GB
'
],
bins
)
def
test_single_range
(
self
):
def
test_single_range
(
self
):
test_data
=
{
"
surls
"
:
[{
"
size
"
:
1
,
"
surl
"
:
"
test
"
},
test_data
=
{
"
surls
"
:
[{
"
size
"
:
1
,
"
surl
"
:
"
test
"
},
...
@@ -77,7 +77,7 @@ class ComputeInputsHistogram(unittest.TestCase):
...
@@ -77,7 +77,7 @@ class ComputeInputsHistogram(unittest.TestCase):
self
.
assertEqual
(
1
,
max_size
)
self
.
assertEqual
(
1
,
max_size
)
self
.
assertEqual
(
6
,
biggest_bucket
)
self
.
assertEqual
(
6
,
biggest_bucket
)
self
.
assertListEqual
([
6
],
counts
)
self
.
assertListEqual
([
6
],
counts
)
self
.
assertListEqual
([
'
0.5B
'
,
'
1.5B
'
],
bins
)
self
.
assertListEqual
([
'
0.5
00
B
'
,
'
1.5
00
B
'
],
bins
)
def
test_extreme_wide_range
(
self
):
def
test_extreme_wide_range
(
self
):
test_data
=
{
"
surls
"
:
[{
"
size
"
:
1
,
"
surl
"
:
"
test
"
},
test_data
=
{
"
surls
"
:
[{
"
size
"
:
1
,
"
surl
"
:
"
test
"
},
...
@@ -94,4 +94,30 @@ class ComputeInputsHistogram(unittest.TestCase):
...
@@ -94,4 +94,30 @@ class ComputeInputsHistogram(unittest.TestCase):
self
.
assertEqual
(
1000000000000000000
,
max_size
)
self
.
assertEqual
(
1000000000000000000
,
max_size
)
self
.
assertEqual
(
5
,
biggest_bucket
)
self
.
assertEqual
(
5
,
biggest_bucket
)
self
.
assertListEqual
([
5
,
0
,
0
,
0
,
0
,
1
],
counts
)
# TODO: if this is the case, adapt it to logarithmic scale
self
.
assertListEqual
([
5
,
0
,
0
,
0
,
0
,
1
],
counts
)
# TODO: if this is the case, adapt it to logarithmic scale
self
.
assertListEqual
([
'
1.0B
'
,
'
148.0PB
'
,
'
296.1PB
'
,
'
444.1PB
'
,
'
592.1PB
'
,
'
740.1PB
'
,
'
888.2PB
'
],
bins
)
self
.
assertListEqual
([
'
1.000B
'
,
'
148.030PB
'
,
'
296.059PB
'
,
'
444.089PB
'
,
'
592.119PB
'
,
'
740.149PB
'
,
'
888.178PB
'
],
bins
)
def
test_two_ranges
(
self
):
test_data
=
{
"
surls
"
:
[{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97873920
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
},
{
"
size
"
:
97884160
,
"
surl
"
:
"
test
"
}]}
min_size
,
max_size
,
n_bins
,
counts
,
biggest_bucket
,
bins
=
compute_inputs_histogram
(
test_data
)
self
.
assertEqual
(
2
,
n_bins
)
self
.
assertEqual
(
97873920
,
min_size
)
self
.
assertEqual
(
97884160
,
max_size
)
self
.
assertEqual
(
8
,
biggest_bucket
)
self
.
assertListEqual
([
8
,
7
],
counts
)
# TODO: if this is the case, adapt it to logarithmic scale
self
.
assertListEqual
([
'
93.340MB
'
,
'
93.345MB
'
,
'
93.350MB
'
],
bins
)
This diff is collapsed.
Click to expand it.
ldvspec/lofardata/views.py
+
3
−
2
View file @
b4323341
...
@@ -73,7 +73,8 @@ def compute_inputs_histogram(inputs):
...
@@ -73,7 +73,8 @@ def compute_inputs_histogram(inputs):
min_size
=
inputs_sizes
.
min
()
min_size
=
inputs_sizes
.
min
()
max_size
=
inputs_sizes
.
max
()
max_size
=
inputs_sizes
.
max
()
n_bins
=
1
if
min_size
==
max_size
else
(
inputs_sizes
.
__len__
()
if
inputs_sizes
.
__len__
()
<
100
else
100
)
n_distinct_sizes
=
numpy
.
unique
(
inputs_sizes
).
__len__
()
n_bins
=
n_distinct_sizes
if
n_distinct_sizes
<
100
else
100
counts
,
buckets
=
numpy
.
histogram
(
inputs_sizes
,
bins
=
n_bins
,
range
=
(
min_size
,
max_size
))
counts
,
buckets
=
numpy
.
histogram
(
inputs_sizes
,
bins
=
n_bins
,
range
=
(
min_size
,
max_size
))
formatted_bins
=
[
format_size
(
bucket
)
%
bucket
for
bucket
in
buckets
]
formatted_bins
=
[
format_size
(
bucket
)
%
bucket
for
bucket
in
buckets
]
...
@@ -85,7 +86,7 @@ def format_size(num, suffix="B"):
...
@@ -85,7 +86,7 @@ def format_size(num, suffix="B"):
return
"
-
"
return
"
-
"
for
unit
in
[
""
,
"
K
"
,
"
M
"
,
"
G
"
,
"
T
"
,
"
P
"
,
"
E
"
,
"
Z
"
]:
for
unit
in
[
""
,
"
K
"
,
"
M
"
,
"
G
"
,
"
T
"
,
"
P
"
,
"
E
"
,
"
Z
"
]:
if
abs
(
num
)
<
1024.0
:
if
abs
(
num
)
<
1024.0
:
return
f
"
{
num
:
3.
1
f
}{
unit
}{
suffix
}
"
return
f
"
{
num
:
3.
3
f
}{
unit
}{
suffix
}
"
num
/=
1024.0
num
/=
1024.0
return
f
"
{
num
:
.
1
f
}
Yi
{
suffix
}
"
return
f
"
{
num
:
.
1
f
}
Yi
{
suffix
}
"
...
...
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