GalacticDynamics / unxt

Unitful Quantities in JAX
https://unxt.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11 stars 3 forks source link

Renaming the `constructor` method #211

Closed nstarman closed 3 days ago

nstarman commented 2 weeks ago

While it's very explicit and closely follows the terminology in the Python data model it's just so verbose.

x = Quantity.constructor(...)

Replacement options:

  1. make: pros: explicit that it's making something. cons: maybe vague what it's making. Could be a MakeFile?
  2. new: pros: it evokes __new__, to which it is similar. cons: same as make.
  3. create: 🤷 meh
  4. from_: pros: 1) it closely follows the classmethod constructor pattern 2) it's kinda similar to dict.fromkeys, and 3) it fits naturally into any bespoke constructors we add in the future, e.g from_file (which might call jnp.load). cons: ?

@adrn @jnibauer what are your thoughts on the above options / do you have any others?

Once we decide for unxt I'll propagate this up to coordinax and galax.

nstarman commented 1 week ago

@adrn @jnibauer the more I think about it the more I like from_. It's the closest we have to existing constructor patterns and it also makes it clear that we aren't making or creating the arguments, but making a new Quantity from the arguments.

adrn commented 3 days ago

This is updated