Skip to content

The methods "get_something()" should be "something()" #1346

@1ucian0

Description

@1ucian0

@jaygambetta expressed discontent with methods of the shape get_something(). It seems he is not the only one.

A quick grep returned:

  • qiskit/tools/visualization/_matplotlib.py: get_index(self) See The methods "get_something()" should be "something()" #1346 (comment)
  • qiskit/result/_result.py:
    • get_status(self)
    • get_circuit_status(self, icircuit)
    • get_job_id(self)
    • get_ran_qasm(self, name)
    • get_data(self, circuit=None)
    • get_counts(self, circuit=None)
    • get_statevector(self, circuit=None)
    • get_unitary(self, circuit=None)
    • get_snapshots(self, circuit=None)
    • get_snapshot(self, slot=None, circuit=None)
    • get_names(self)
    • get_qubitpol_vs_xval(self, nqubits, xvals_dict=None)
  • qiskit/backends/ibmq/api/ibmqconnector.py: The methods "get_something()" should be "something()" #1346 (comment)
    • get_job_url(config, hub=None, group=None, project=None)
    • get_backend_stats_url(config, backend_type, hub=None)
    • get_backend_properties_url(config, backend_type, hub=None)
    • get_backend_url(config, hub, group, project)
    • def get_token(self)
    • get_user_id(self)
    • get_config(self)
    • get_job(self, id_job, hub=None, group=None, project=None,..)
    • get_jobs(self, limit=10, skip=0, backend=None, only_completed=False,...)
    • get_status_job(self, id_job, hub=None, group=None, project=None,...)
    • get_status_jobs(self, limit=10, skip=0, backend=None, filter=None,...)
  • qiskit/backends/baseprovider.py: get_backend(self, name=None, **kwargs)
  • qiskit/backends/aer/aerprovider.py: get_backend(self, name=None, **kwargs) The methods "get_something()" should be "something()" #1346 (comment)
  • qiskit/unrollers/_unrollerbackend.py: get_output(self) The methods "get_something()" should be "something()" #1346 (comment)
  • qiskit/unrollers/_dagbackend.py: get_output(self) The methods "get_something()" should be "something()" #1346 (comment)
  • qiskit/unrollers/_jsonbackend.py: get_output(self) The methods "get_something()" should be "something()" #1346 (comment)
  • qiskit/mapper/_coupling.py:
    • get_qubits(self)
    • get_edges(self)
  • qiskit/mapper/_layout.py:
    • get_bits(self)
    • get_wires(self)
  • qiskit/dagcircuit/_dagcircuit.py`:
    • get_qubits(self)
    • get_op_nodes(self, op=None)
    • get_named_nodes(self, name)
    • get_cnot_nodes(self)
  • qiskit/qasm/_qasm.py:
    • get_filename(self)
    • get_tokens(self)
  • qiskit/qasm/_qasmparser.py: get_tokens(self)

In many situations the prefiex get_ simply can be removed. In others, it can be replaced by more specific, like generate_output. If there is a set_something, in that case I think get_something makes sense.

Since this change affects a lot of things, do it in several PRs please.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstype: qaIssues and PRs that relate to testing and code quality

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions