opendp / opendp

The core library of differential privacy algorithms powering the OpenDP Project.
https://opendp.org
MIT License
284 stars 46 forks source link

Usability: mismatch between reprs and utility method constructors #1510

Closed mccalluc closed 3 weeks ago

mccalluc commented 3 weeks ago

Ideally, a repr is close to an actual python expression that can be evaluated to obtain the object. A user might think that an object represented as:

VectorDomain(AtomDomain(T=i32))

could be constructed with something like:

dp.VectorDomain(dp.AtomDomain(T=dp.i32))

but they'd be wrong!

*** TypeError: 'DomainDescriptor' object is not callable

They actually want

dp.vector_domain(dp.atom_domain(T=dp.i32))

Is there a way to steer them onto the right course?

This is probably overthinking it, but would it be helpful to define a __call__ method, just to raise an exception?