Open yymao opened 6 years ago
Yes, I agree that having a standalone validation function (C) will be the best way of testing compliance with the standard. I think we can provide reference implementations and a standalone validation function at the same time in this repo.
Sure. I think my earlier confusion came from that I thought that SPECIFICATION
was written for who's working on (A) and (B). If SPECIFICATION
is intended to instruct who will implement (C) then it makes perfect sense.
The hash function you just added in the specification and also be a function in this module (in my example above it would look like desccosmo.hash(cosmo)
).
I think the specification should still be useful to people implementing their own class (case A). I guess you could think of it as the "documentation" of code (C). People doing (B) don't need to worry about it, but people writing their own implementations do need to follow the spec.
Yep, sure.
@philbull I move the discussion here so we can be more focused without jamming the tjp channel.
I think we are on the right track here already, but I want to further distinguish different use cases and what (in my opinion) this repo's rule would be.
I think there are 3 different use cases:
Here, (C) is really just the combination of a subset of (A) and a subset of (B). However, by splitting (C) from (A) and (B), we can enforce the specification with code. In other words, instead of just asking people who writes (A) and (B) to conform to the specification, we can use (C) to make sure they do conform to the specification.
So, I think what we want to do is to implement is (C) (in both C and Python), and by doing so, we would have automatically fully specified our specification.
Here's an some examples (in Python only) of this imaginary (C) module which I call
desccosmo
A function takes a cosmology object from other module:
A custom class that modifies the base class:
A totally different cosmology object but conforming to the specification:
Saving a conforming cosmology object to file and loading from file: (using an API similar to that of
json
)As always, comments are welcome. And thanks to @philbull again for taking a lead on this!