Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve doc testing #55

Merged
merged 4 commits into from
Jul 12, 2024
Merged

Conversation

arcondello
Copy link
Member

@arcondello arcondello commented Jul 12, 2024

Match the SDK's doc theme and add doctests to CI.

Closes #54
Also fixes some doc errors introduced in #42 and #53

@arcondello arcondello force-pushed the docs/flat-symbols branch 10 times, most recently from 04c182d to 65a6287 Compare July 12, 2024 17:06
@arcondello arcondello requested a review from JoelPasvolsky July 12, 2024 17:09
@arcondello arcondello marked this pull request as ready for review July 12, 2024 17:09
@arcondello arcondello added bug Something isn't working documentation Improvements or additions to documentation labels Jul 12, 2024
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.

LGTM, thanks!

@@ -85,31 +77,15 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Line 51:

language = 'en'

Let's start getting rid of WARNING: Invalid configuration value found: 'language = None'. Update your configuration to a valid language code. Falling back to 'en' (English).

@@ -164,8 +164,7 @@ for symbols of a model without using labels.
>>> with model.lock():
... for symbol in model.iter_decisions():
... symbol.set_state(0, [2])
... model.objective.state(0) == -4
True
... assert model.objective.state(0) == -4
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about this: it save one line but at the cost of slightly less understandable code for less experienced users and the replacement of a False output were it to not obtain by an error state, which is not desirable

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that NumPy either returns True or np.True_ depending on the version. So doctests may fail in either case. I believe assert is fairly clear even to novice Python users.

Copy link
Contributor

@JoelPasvolsky JoelPasvolsky Jul 12, 2024

Choose a reason for hiding this comment

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

Or could print the value (print(model.objective.state(0)))

Copy link
Member Author

Choose a reason for hiding this comment

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

Is that really clearer than assert? Both are built-in Python operations. If we cannot assume that they know about assert, then can we assume they know print?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, they all know print

Copy link
Contributor

Choose a reason for hiding this comment

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

Originally we moved from print() statements to using equals to get a True because we worried about changes to the format of the output over time (mostly unordered lists and sets) but here that's not a concern

Copy link
Member Author

Choose a reason for hiding this comment

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

I am comfortable assuming that they know assert as well.

Copy link
Member Author

@arcondello arcondello Jul 12, 2024

Choose a reason for hiding this comment

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

changes to the format of the output over time (mostly unordered lists and sets) but here that's not a concern

Is it not? NumPy could decide to change the str() representation of np.True_.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I meant print the value: print(model.objective.state(0)) and showing its output (that will be used by the doctest)

Copy link
Member Author

@arcondello arcondello Jul 12, 2024

Choose a reason for hiding this comment

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

That will return np.float64(4.0) or 4 depending on the NumPy version

@arcondello arcondello merged commit 3c8e14c into dwavesystems:main Jul 12, 2024
32 checks passed
@arcondello arcondello deleted the docs/flat-symbols branch July 12, 2024 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Docs reference incorrect version
2 participants