Skip to content
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

Creating a class with .get() function for quick and convenient loading of datasets #10

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
29 changes: 29 additions & 0 deletions unimpeded/unimpeded.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#%%
from anesthetic import read_chains
#%%
class unimpeded:

# which __init__ is better?
"""
def __init__(self, **kwargs):
self.model = kwargs.pop('model', None)
self.data = kwargs.pop('data', None)
self.method = kwargs.pop('method', None)
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use this style

def __init__(self, model, dataset, method, location):
self.model = model
self.dataset = dataset
self.method = method
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these should be arguments of .get. For now one would only want location as a kwarg

self.location = location

def get(self):
if self.location == 'hpc':
samples = read_chains(f"/home/dlo26/rds/rds-dirac-dp192-63QXlf5HuFo/dlo26/{self.method}/{self.model}/{self.dataset}/{self.dataset}_polychord_raw/{self.dataset}") # for hpc
elif self.location == 'local':
samples = read_chains(f"../../{self.method}/{self.model}/{self.dataset}/{self.dataset}_polychord_raw/{self.dataset}")
return samples
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should read from self.location, and have 'hpc' and 'local' processing as part of your own personal scripts.


#%%
database = unimpeded('klcdm', 'bao.sdss_dr16', 'ns', 'local')
samples = database.get()
# %%
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be put into a test function in tests/test_unimpeded.py

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Loading