Skip to content

Expand dimod.make_quadratic documentation#1415

Open
iamashwin99 wants to merge 6 commits intodwavesystems:mainfrom
iamashwin99:patch-1
Open

Expand dimod.make_quadratic documentation#1415
iamashwin99 wants to merge 6 commits intodwavesystems:mainfrom
iamashwin99:patch-1

Conversation

@iamashwin99
Copy link

@iamashwin99 iamashwin99 commented Feb 23, 2026

  • Add example output for make_quadratic function
  • Added notes on variable types in make_quadratic function.

@iamashwin99 iamashwin99 marked this pull request as ready for review February 23, 2026 07:57
Copilot AI review requested due to automatic review settings February 23, 2026 07:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request expands the documentation for the dimod.make_quadratic function by adding explanatory notes about variable types and example output to help users better understand the function's behavior.

Changes:

  • Added a Notes section explaining the three types of variables that appear in the reduced quadratic model (original, product, and auxiliary variables)
  • Added example output showing the BinaryQuadraticModel representation returned by the function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

iamashwin99 and others added 2 commits February 23, 2026 17:47
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@thisac thisac requested a review from JoelPasvolsky February 24, 2026 21:47
Copy link
Contributor

@JoelPasvolsky JoelPasvolsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contributing to the Ocean SDK, @iamashwin99.

The comments below are to keep your additions aligned with Ocean formatting, remove trailing whitespaces, and return a shorter, more easily parsable result.

Comment on lines +319 to +320
>>> bqm
BinaryQuadraticModel({0: -3.5, 1: -1.5, '0*1': -2.5, 'aux0,1': -5.0, 2: 1.5}, {(1, 0): 1.5, ('0*1', 0): 2.5, ('0*1', 1): 2.5, ('aux0,1', 0): 5.0, ('aux0,1', 1): 5.0, ('aux0,1', '0*1'): 5.0, (2, '0*1'): -2.0}, 10.0, 'SPIN')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>> bqm
BinaryQuadraticModel({0: -3.5, 1: -1.5, '0*1': -2.5, 'aux0,1': -5.0, 2: 1.5}, {(1, 0): 1.5, ('0*1', 0): 2.5, ('0*1', 1): 2.5, ('aux0,1', 0): 5.0, ('aux0,1', 1): 5.0, ('aux0,1', '0*1'): 5.0, (2, '0*1'): -2.0}, 10.0, 'SPIN')
>>> list(bqm.variables)
[0, 1, '0*1', 'aux0,1', 2]

More readable and short.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the full bqm would be a better description. It would also give hint about how the auxiliary qubits are generated. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless it provides high value to users (e.g., a list of parameters, typical timing), we try to avoid long outputs because they're not easy to parse, make the example look daunting, and can require maintenance (e.g., the recent backward-incompatible NumPy update that changes formats). My thinking is that such a short example lets users easily copy & paste so those who want to see the exact BQM structure can do so without difficulty. The list output highlights the generated variables you describe and additional, more robust ways to provide an output with more information could be

>>> len(bqm.linear) + len(bqm.quadratic)
12

or

>>> print(bqm.to_polystring())
10 - 3.5*v0 - 1.5*v1 - 2.5*0*1 - 5*aux0,1 + 1.5*v2 + 1.5*v0*v1 + 2.5*v0*0*1 + 2.5*v1*0*1 + 5*v0*aux0,1 + 5*v1*aux0,1 + 5*0*1*aux0,1 - 2*0*1*v2

and even for the latter, preferably shorten it with ellipses for readability, something perhaps like:

>>> print(bqm.to_polystring())
10 - ... 2.5*0*1 - 5*aux0,1 + ... 2.5*v1*0*1 + 5*v0*aux0,1 + 5*v1*aux0,1 + ...

Can one of these or another robust & short output do most of the work? If yes, that would be preferable. Thank you!

iamashwin99 and others added 2 commits February 26, 2026 01:21
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Co-authored-by: Joel Pasvolsky <34041130+JoelPasvolsky@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants