exoplanet-dev / exoplanet

Fast & scalable MCMC for all your exoplanet needs!
https://docs.exoplanet.codes
MIT License
206 stars 52 forks source link

Add type hinting #193

Open grburgess opened 3 years ago

grburgess commented 3 years ago

I would suggest (though it is again stylist and not required) to start adding type hints as it is being moved into the standard python world. This helps many code editors with completion and allows for robust tests using type checkers such as mypy.

Though this is not my field, I can see this code as being a framework where other researchers import it and build future models, thus type hinting would keep them from stumbling over the various inputs and outputs related to theano and pymc3 which are vital to the functionality of the code. I note that neither of these frameworks are typed, but the size of exoplanet is manageable enough (with lots of contributors) to slowly add this in.

grburgess commented 3 years ago

linking: https://github.com/openjournals/joss-reviews/issues/3285#

dfm commented 3 years ago

@grburgess: If you don't mind, I propose splitting this into two issues: (1) Fill in some missing docstrings and (2) type annotations.

I would argue that type hinting is out of scope for now since the underlying libraries (numpy and theano/aesara) only have very limited support for typing at the moment (e.g. https://github.com/numpy/numpy/issues/7370 & https://github.com/pymc-devs/aesara/issues/200). Since these are the main return types of all of the exoplanet methods, I've found that the added benefit is currently somewhat limited. In the long run, I would very much like to add this so I'm following the conversations closely! What do you think about that @grburgess?

grburgess commented 3 years ago

I will split it up.

grburgess commented 3 years ago

@dfm I agree that for the time being it is only icing on the cake at the moment and can be ignored for the review. The real power for now is when using editors that support LSP. The code completion and code hinting become a very powerful tool for real time code and syntax checking.

dfm commented 3 years ago

Great - yes, it really is awesome for code completion, etc. I have a few other projects (that don't depend on numpy) where I've loved using Python typing.

I'm going to remove the joss label on this issue and leave it open as a future feature request. Hopefully sooner rather than later!

grburgess commented 3 years ago

I can also take a stab at putting some hinting in as PRs.

dfm commented 3 years ago

That would be very awesome if you're keen, but no pressure!