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

Feature request: Setup proper imports #195

Open
grburgess opened this issue Sep 30, 2022 · 2 comments
Open

Feature request: Setup proper imports #195

grburgess opened this issue Sep 30, 2022 · 2 comments

Comments

@grburgess
Copy link
Contributor

The way that we do python import * in both 3ML and astromodels is very bad practice as it can lead to namespace collisions. We need to eventually clean this up which will mean that we will have to fix up the docs (and our own scripts).

This will be especially important when we work with packages like gammapy because they may use the same model name and it could cause all kinds of strange bugs.

I have started working on this in a branch, but I think this is a breaking change so something for like a minor version bump.

It would look something like this:

import astromodels as amod

pl = amod.functions_1D.Powerlaw()

ps = amod.sources.PointSource()

for example. Of course, someone could always go through and import everything if they like, but it makes controlling names a lot easier. We would have something similar for 3ML

import threeml as datatools

p = datatools.plugins.OGIPLike()

Thoughts?

@henrikef
Copy link
Contributor

Sounds good, but wouldn't

import threeML
p = threeML.plugins.OGIPLike()

Be less confusing?

@grburgess
Copy link
Contributor Author

The structure is probably something we should discuss, but it would also give us a chance to think about all these startup warning etc. We could make it all more local and stop freaking people out when it loads. I have some ideas, but it would be better to gather our use cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants