tket icon indicating copy to clipboard operation
tket copied to clipboard

Make the use of python properties/getters more consistent

Open yao-cqc opened this issue 2 years ago • 6 comments

For instance, Circuit.n_gates is a property while Circuit.n_2qb_gates and Circuit.n_1qb_gates are methods. I'm also not sure whether Circuit.depth should be a method or a property.

yao-cqc avatar Apr 11 '23 10:04 yao-cqc

I also spotted this recently. For me it would make sense to have all of these as properties as they are all characteristics of the Circuit object itself.

CalMacCQ avatar Apr 12 '23 16:04 CalMacCQ

I'd agree with having them as properties! * Seyon's suggestion for methods makes more sense

sjdilkes avatar Apr 13 '23 09:04 sjdilkes

I would actually advocate for make them all methods - they all require computation, some of them non-trivial, having then as methods makes that clear.

ss2165 avatar Apr 13 '23 09:04 ss2165

However...this is an API breaking change, one I don't think is important enough to break API contract. @cqc-alec what do you think?

ss2165 avatar Apr 13 '23 09:04 ss2165

if we're going with methods we could go with Circuit.get_metric() perhaps?

The word 'get' seems to communicate that it is a method that calculates something rather than a property.

CalMacCQ avatar Apr 13 '23 09:04 CalMacCQ

Yeah I don't think we should break the API for this. We could introduce new methods though, with names prefixed by get_ as Callum suggests.

cqc-alec avatar Apr 13 '23 09:04 cqc-alec

This issue has been automatically marked as stale.

github-actions[bot] avatar Jun 12 '24 05:06 github-actions[bot]

No specific action here; closing until we have a better idea of enhanced API.

cqc-alec avatar Jun 12 '24 08:06 cqc-alec