-
Notifications
You must be signed in to change notification settings - Fork 26
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
Improving the python API #53
Comments
Any comments @MansMeg @paul-buerkner? |
Perhaps this could be an improvement to the dataset API Accessing the loaded data JSON filepo.dataset.values()
Get file path to the data JSON filepo.dataset.file() |
I would appreciate some comments. Do you agree with this change or do you have some concerns? It's also fine to say "My gut reaction is negative but I can't yet articulate why" if that's the case. |
I will go through this later. |
So I think this new structure would be really good. It looks better. I think this would also simplify connecting to Github (and in the future a public database). I think it looks good. |
Great! I'll do the changes soon (probably start of next week) |
Me, Paul and Aki decided that the R package will be the reference implementation for now since this is where we are working now. so I remove this issue from the prototype milestone. If this can be fixed this coming week that would be great, because that when we expect the database prototype to come out. |
That's fine. I'll very likely get these changes done this coming week. |
Here's some potential changes for the python API that I feel could make it better. The R API is not affected.
You can view a README with the new API here: https://github.com/eerolinna/posterior_database/blob/patch-1/python/README.md
Constructing a posterior
Old:
po = Posterior(posterior_name, my_pdb)
New:
po = my_pdb.posterior(posterior_name)
(the old way will still work)
The same applies for model and dataset, so we have
my_pdb.model(model_name)
andmy_pdb.dataset(data_name)
I feel this can makes it clearer that the posterior comes from the posterior database.
Accessing model code
Old (all are equivalent)
New
This drops the unnecessary model prefix.
po.model_code_file_path("stan")
is also shortened topo.code_file("stan")
po.code("stan")
maybe should still bepo.model_code
, or we could just drop it and usepo.model.code("stan")
.po.stan_code()
could perhaps also be dropped, then we'd usepo.model.stan_code()
Accessing model information
Old
New
Drops the model prefix and removes the shortened form
The result from calling these is something like
The slot
model_code
is dropped from the result as this is just an implementation detail andmo.code_file("stan")
already contains this information.Accessing data file
Old
This one I'm not sure what to do about, I feel it's confusing to have both
po.data()
(the actual data, in other words the loaded JSON) andpo.dataset
(which is the PDB concept of a dataset that has a name like "8_schools" and contains both the actual datapo.dataset.data()
and the information about the datasetpo.dataset.information
)Accessing dataset information
Old
New
Same changes as in model information
The result is something like
The slot
data_file
is dropped from the result as this is just an implementation detail andda.data_file()
already contains this information.The text was updated successfully, but these errors were encountered: