LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
145 stars 68 forks source link

Implementation of new object-oriented API doesn't play nice with VS Code #1112

Open tilmantroester opened 1 year ago

tilmantroester commented 1 year ago

I like OOP but playing around with the new API I found that it doesn't play nice with editors. In the example

cosmo = ccl.CosmologyVanillaLCDM()
cosmo.angular_cl

VS Code recognises that cosmo.angular_cl is a function but seems unable to infer the signature or access the docstring. If the current method to inject the functions as methods start working with tooltips, I think we should amend the docstring to explicitly state that the method is injected into the Cosmology object and the original function can be found in some other place.

For developers, cases like https://github.com/LSSTDESC/CCL/blob/master/pyccl/cosmology.py#L517 are confusing, since ctrl+f for "get_camb_pk_lin" does not yield any results in cosmology.py, even though one would expect that from it being used as a method of Cosmology. Internally I'd avoid this kind of dynamically created APIs to keep the code easy to read and maintain.