Replies: 1 comment 4 replies
-
|
Have you read https://github.com/jorenham/optype? I want to focus in on the guide: https://github.com/jorenham/optype?tab=readme-ov-file#optype-1
Pretty much everything in the Cosmology API would fall under the 1. removing all higher-level protocols.These are just intersection types that significantly simplify typing a high-level function.
vs If a user wants to granularly type a function then we provide both intermediate intersection types and the nitty-gritty low-level 2. rename all low-level protocols to match the function they contain.Aren't they already? This is CamelCase. Any Python linter will be unhappy with if the class is snake_cased, like 3. Classes w/in classes🤮 . Oh no! Summary.I think we were already careful to write this Pythonically and ended up with something very close to how If in GLASS you don't want to use the high-level protocols, then don't? 🧐 |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Over the past couple of weeks, I have been trying to work more with the Cosmology API, for a number of projects that we want to integrate into GLASS.
I have come to think the Cosmology API would be massively simplified if we
This is a radical change, so let me explain by way of example.
This is the only always-correct, fully-consistent, and flexible solution I have found. It supports all standard and non-standard cosmologies, as well as perturbations, and whatever else we might come up with in the future.
And if type intersections ever make it into Python, then it won't even be necessary to define the helper protocols.
Edit: There actually is a mypy extension that supports protocol intersections: https://github.com/klausweiss/typing-protocol-intersection
Assuming that in
cosmology.apiwe might do the suggestedthen the above example could be typed as
which to me seems like a fantastic way to do this.
Beta Was this translation helpful? Give feedback.
All reactions