forked from COINtoolbox/RESSPECT
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Refactoring in support of externally defined feature extractor libraries - i.e. LAISS #73
Merged
drewoldag
merged 5 commits into
main
from
issue/72/refactor-feature-extractor-column-names
Nov 8, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
074863b
Fairly substantial refactor to remove hardcoded column names from `li…
drewoldag 0d50570
Refactoring the section of database.py that builds self.feature_names…
drewoldag 4125946
Adding that all important new line at the end of the file.
drewoldag abe2d5b
Fixing up Dockerfile, adding github action to build image
mtauraso 91cf04e
Make docker compose setup work with new Dockerfile
mtauraso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
73 changes: 73 additions & 0 deletions
73
src/resspect/feature_extractors/feature_extractor_utils.py
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,73 @@ | ||
import itertools | ||
from typing import List | ||
|
||
def make_features_header( | ||
filters: List[str], | ||
features: List[str], | ||
**kwargs | ||
) -> list: | ||
""" | ||
This function returns header list for given filters and features. The default | ||
header names are: ['id', 'redshift', 'type', 'code', 'orig_sample']. | ||
|
||
Parameters | ||
---------- | ||
filters : list | ||
Filter values. e.g. ['g', 'r', 'i', 'z'] | ||
features : list | ||
Feature values. e.g. ['A', 'B'] | ||
with_cost : bool | ||
Flag for adding cost values. Default is False | ||
kwargs | ||
Can include the following flags: | ||
- override_primary_columns: List[str] of primary columns to override the default ones | ||
- with_queryable: flag for adding "queryable" column | ||
- with_last_rmag: flag for adding "last_rmag" column | ||
- with_cost: flag for adding "cost_4m" and "cost_8m" columns | ||
|
||
Returns | ||
------- | ||
header | ||
header list | ||
""" | ||
|
||
header = [] | ||
header.extend(['id', 'redshift', 'type', 'code', 'orig_sample']) | ||
|
||
# There are rare instances where we need to override the primary columns | ||
if kwargs.get('override_primary_columns', False): | ||
header = kwargs.get('override_primary_columns') | ||
|
||
if kwargs.get('with_queryable', False): | ||
header.append('queryable') | ||
if kwargs.get('with_last_rmag', False): | ||
header.append('last_rmag') | ||
|
||
#TODO: find where the 'with_cost' flag is used to make sure we apply there | ||
if kwargs.get('with_cost', False): | ||
header.extend(['cost_4m', 'cost_8m']) | ||
|
||
# Create all pairs of filter + feature strings and append to the header | ||
filter_features = create_filter_feature_names(filters, features) | ||
header += filter_features | ||
|
||
return header | ||
|
||
def create_filter_feature_names(filters: List[str], features: List[str]) -> List[str]: | ||
"""This function returns the list of concatenated filters and features. e.g. | ||
filter = ['g', 'r'], features = ['A', 'B'] => ['gA', 'gB', 'rA', 'rB'] | ||
|
||
Parameters | ||
---------- | ||
filters : List[str] | ||
Filter name list | ||
features : List[str] | ||
Feature name list | ||
|
||
Returns | ||
------- | ||
List[str] | ||
List of filter-feature pairs. | ||
""" | ||
|
||
return [''.join(pair) for pair in itertools.product(filters, features)] |
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
Oops, something went wrong.
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.
@AmandaWasserman Is this logic correct, or should we support any
survey
that we find in theFILTER_SETS
dictionary? i.e.DES
,LSST
, andSNPCC