Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions src/acquisition/covidcast/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,36 +231,6 @@ def insert_or_update_batch(self, cc_rows, batch_size=2**20, commit_partial=False
self._cursor.execute(drop_tmp_table_sql)
return total

def get_data_stdev_across_locations(self, max_day):
"""
Return the standard deviation of daily data over all locations, for all
(source, signal, geo_type) tuples.

`max_day`: base the standard deviation on data up to, and including, but
not after, this day (e.g. for a stable result over time)
"""

sql = '''
SELECT
`source`,
`signal`,
`geo_type`,
COALESCE(STD(`value`), 0) AS `aggregate_stdev`
FROM
`covidcast`
WHERE
`time_type` = 'day' AND
`time_value` <= %s
GROUP BY
`source`,
`signal`,
`geo_type`
'''

args = (max_day,)
self._cursor.execute(sql, args)
return list(self._cursor)

def get_covidcast_meta(self):
"""Compute and return metadata on all non-WIP COVIDcast signals."""

Expand Down
26 changes: 0 additions & 26 deletions tests/acquisition/covidcast/test_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,32 +73,6 @@ def test_count_all_rows_query(self):
self.assertIn('select count(1)', sql)
self.assertIn('from `covidcast`', sql)

def test_get_data_stdev_across_locations_query(self):
"""Query to get signal-level standard deviation looks sensible.

NOTE: Actual behavior is tested by integration test.
"""

args = ('max_day',)
mock_connector = MagicMock()
database = Database()
database.connect(connector_impl=mock_connector)

database.get_data_stdev_across_locations(*args)

connection = mock_connector.connect()
cursor = connection.cursor()
self.assertTrue(cursor.execute.called)

sql, args = cursor.execute.call_args[0]
expected_args = ('max_day',)
self.assertEqual(args, expected_args)

sql = sql.lower()
self.assertIn('select', sql)
self.assertIn('`covidcast`', sql)
self.assertIn('std(', sql)

def test_update_covidcast_meta_cache_query(self):
"""Query to update the metadata cache looks sensible.

Expand Down