-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14458d8
commit c0eeb0e
Showing
4 changed files
with
60 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
from numpy.testing import assert_almost_equal | ||
from numpy.testing import assert_equal | ||
import numpy as np | ||
|
||
from adler.utilities.tests_utilities import get_test_data_filepath | ||
from adler.dataclasses.dataclass_utilities import get_data_table | ||
from adler.dataclasses.SSObject import SSObject | ||
|
||
|
||
def test_construct_SSObject_from_data_table(): | ||
ssoid = 8268570668335894776 | ||
test_db_path = get_test_data_filepath("testing_database.db") | ||
|
||
filter_list = ["r", "g"] | ||
|
||
filter_dependent_columns = "" | ||
|
||
for filter_name in filter_list: | ||
filter_string = "{}_H, {}_G12, {}_HErr, {}_G12Err, {}_Ndata, ".format( | ||
filter_name, filter_name, filter_name, filter_name, filter_name | ||
) | ||
|
||
filter_dependent_columns += filter_string | ||
|
||
test_query = f""" | ||
SELECT | ||
discoverySubmissionDate, firstObservationDate, arc, numObs, | ||
{filter_dependent_columns} | ||
maxExtendedness, minExtendedness, medianExtendedness | ||
FROM | ||
SSObject | ||
WHERE | ||
ssObjectId = {ssoid} | ||
""" | ||
|
||
data_table = get_data_table(test_query, sql_filename=test_db_path) | ||
test_SSObject = SSObject.construct_from_data_table(ssoid, filter_list, data_table) | ||
|
||
assert test_SSObject.ssObjectId == 8268570668335894776 | ||
assert test_SSObject.filter_list == filter_list | ||
assert_almost_equal(test_SSObject.discoverySubmissionDate, 60218.0, decimal=6) | ||
assert_almost_equal(test_SSObject.firstObservationDate, 60220.01958, decimal=6) | ||
assert_almost_equal(test_SSObject.arc, 3342.05859375, decimal=6) | ||
assert test_SSObject.numObs == 94 | ||
assert_almost_equal(test_SSObject.H, [19.80589294, 20.29232597], decimal=6) | ||
assert_almost_equal(test_SSObject.G12, [1.52932608, 1.72339332], decimal=6) | ||
assert_almost_equal(test_SSObject.Herr, [0.01974303, 0.0302103], decimal=6) | ||
assert_almost_equal(test_SSObject.G12err, [0.05071714, 0.04049731], decimal=6) | ||
assert_equal(test_SSObject.nData, [38.0, 9.0]) | ||
assert_equal(test_SSObject.maxExtendedness, 0.0) | ||
assert_equal(test_SSObject.minExtendedness, 0.0) | ||
assert_equal(test_SSObject.medianExtendedness, 0.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters