Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
visualizer-echarts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
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
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
Owen Graham
visualizer-echarts
Commits
db4bc397
Verified
Commit
db4bc397
authored
1 year ago
by
Owen Graham
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused `smooth_batch()` function
parent
b1d50757
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
visualizer/data.py
+1
-31
1 addition, 31 deletions
visualizer/data.py
with
1 addition
and
31 deletions
visualizer/data.py
+
1
−
31
View file @
db4bc397
#!/usr/bin/env python3
from
collections
import
namedtuple
from
datetime
import
datetime
,
timedelta
,
timezone
from
datetime
import
datetime
,
timezone
import
json
import
os
from
urllib.parse
import
quote
...
...
@@ -59,36 +59,6 @@ def query_hourly_data(station_name, year, smooth=False):
yield
translate_api_line
(
api_line
,
api_cols
)
def
smooth_batch
(
datapoints
):
"""
Group 10-minute data into ten-to, o-clock, and ten-after trios.
"""
# Seconds and microseconds are presumed to be zero.
minute_marks
=
tuple
(
timedelta
(
minutes
=
x
)
for
x
in
(
-
10
,
0
,
10
))
required_mark_i
=
1
# Index of o-clock in `minute_marks`
# Find the absolute hour and the minute mark `dt` belongs to.
def
hour_of
(
dt
):
for
i
,
minute_mark
in
enumerate
(
minute_marks
):
shifted
=
dt
-
minute_mark
if
shifted
.
minute
==
0
:
return
shifted
,
i
return
None
,
None
batch
=
[
None
]
*
len
(
minute_marks
)
batch_hour
=
None
for
point
in
datapoints
:
point_hour
,
mark_i
=
hour_of
(
point
.
dt
)
if
point_hour
is
None
:
continue
if
point_hour
!=
batch_hour
:
if
batch
[
required_mark_i
]
is
not
None
:
yield
batch
batch
=
[
None
]
*
len
(
minute_marks
)
batch_hour
=
point_hour
batch
[
mark_i
]
=
point
if
batch
[
required_mark_i
]
is
not
None
:
yield
batch
def
translate_api_line
(
api_line
,
api_cols
):
(
date_str
,
time_str
,
*
variables
)
=
(
api_line
[
col
]
for
col
in
api_cols
)
dt_naive
=
datetime
.
strptime
(
f
'
{
date_str
}
{
time_str
}
'
,
'
%Y-%m-%d %H:%M
'
)
...
...
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