-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM-37703: Use InMemoryDatasetHandle and drop DatasetRef from test #80
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
084f43d
Use InMemoryDatasetHandle rather than mocked implementation
timj 0c284b3
Use a resolved DatasetRef
timj f84f60b
Remove the DatasetRef completely from test
timj a28f6bc
Update pre-commit configuration
timj cce5369
Add flake8 to pre-commit
timj File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,34 +29,8 @@ | |
import pandas as pd | ||
from lsst.analysis.tools.tasks import CatalogMatchConfig, CatalogMatchTask | ||
from lsst.daf.base import PropertyList | ||
from lsst.daf.butler import DatasetRef, DatasetType, DimensionUniverse, StorageClass | ||
from lsst.meas.algorithms import ReferenceObjectLoader | ||
|
||
|
||
class MockSourceTableRef: | ||
"""Replicate functionality of `DeferredDatasetHandle`""" | ||
|
||
def __init__(self, source_table, ref=None, dataId=None): | ||
self.source_table = source_table | ||
self.ref = ref | ||
self.dataId = dataId | ||
|
||
def get(self, parameters={}, **kwargs): | ||
"""Retrieve the specified dataset using the API of the Gen3 Butler. | ||
Parameters | ||
---------- | ||
parameters : `dict`, optional | ||
Parameter dictionary. Supported key is ``columns``. | ||
Returns | ||
------- | ||
dataframe : `pandas.DataFrame` | ||
dataframe, cut to the specified columns. | ||
""" | ||
if "columns" in parameters: | ||
_columns = parameters["columns"] | ||
return self.source_table[_columns] | ||
else: | ||
return self.source_table.copy() | ||
from lsst.pipe.base import InMemoryDatasetHandle | ||
|
||
|
||
class MockDataId: | ||
|
@@ -65,10 +39,6 @@ class MockDataId: | |
def __init__(self, region): | ||
self.region = region | ||
|
||
datasetDimensions = DimensionUniverse().extract(["htm7"]) | ||
datasetType = DatasetType("gaia_dr2_20200414", datasetDimensions, StorageClass("SimpleCatalog")) | ||
self.ref = DatasetRef(datasetType, {"htm7": "mockRefCat"}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out this ref wasn't needed at all so I simply deleted it. |
||
|
||
|
||
class TestCatalogMatch(unittest.TestCase): | ||
"""Test CatalogMatchTask""" | ||
|
@@ -143,7 +113,7 @@ def _make_refCat(self, starIds, starRas, starDecs, poly): | |
------- | ||
refDataId : MockDataId | ||
Object that replicates the functionality of a dataId | ||
deferredRefCat : MockSourceTableRef | ||
deferredRefCat : InMemoryDatasetHandle | ||
Object that replicates the functionality of a `DeferredDatasetRef` | ||
""" | ||
refSchema = afwTable.SimpleTable.makeMinimalSchema() | ||
|
@@ -160,7 +130,7 @@ def _make_refCat(self, starIds, starRas, starDecs, poly): | |
record.setDec(lsst.geom.Angle(starDecs[i], lsst.geom.degrees)) | ||
record.set(fluxKey, 1) | ||
refDataId = MockDataId(poly) | ||
deferredRefCat = MockSourceTableRef(refCat, ref=refDataId.ref) | ||
deferredRefCat = InMemoryDatasetHandle(refCat, storageClass="SimpleCatalog", htm7="mockRefCat") | ||
return refDataId, deferredRefCat | ||
|
||
def _make_objectCat(self, starIds, starRas, starDecs): | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like this parameter is ever used because it looks like this code has been copied from an implementation that had been used for pandas DataFrame objects -- the tests pass and SimpleCatalog is not configured to understand a columns parameter.