Skip to content

Commit

Permalink
Merge pull request #181 from astrofrog/default-tolerance-style
Browse files Browse the repository at this point in the history
Add missing CLI and INI options for a consistent API
  • Loading branch information
astrofrog authored Oct 19, 2023
2 parents a169531 + a36ac38 commit 0d11e7b
Show file tree
Hide file tree
Showing 15 changed files with 657 additions and 94 deletions.
1 change: 0 additions & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ build:
python: "3.11"

python:
system_packages: false
install:
- method: pip
path: .
Expand Down
30 changes: 17 additions & 13 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ Directory containing baseline images
------------------------------------
| **kwarg**: ``baseline_dir=<path>``
| **CLI**: ``--mpl-baseline-path=<path>``
| **INI**: ---
| **INI**: ``mpl-baseline-path``
| Default: ``baseline/`` *(relative to the test file)*
The directory containing the baseline images that will be compared to the test figures.
The kwarg option (``baseline_dir``) is relative to the test file, while the CLI option (``--mpl-baseline-path``) is relative to where pytest was run.
The kwarg option (``baseline_dir``) is relative to the test file, while the CLI option (``--mpl-baseline-path``) and INI option (``mpl-baseline-path``) are relative to where pytest was run.
Absolute paths can also be used.
If the directory does not exist, it will be created along with any missing parent directories.

Expand Down Expand Up @@ -160,7 +160,7 @@ If you specify a filename that has an extension other than ``png``, you must als
Whether to include the module name in the filename
--------------------------------------------------
| **kwarg**: ---
| **CLI**: ---
| **CLI**: ``--mpl-use-full-test-name``
| **INI**: ``mpl-use-full-test-name``
| Default: ``False``
Expand Down Expand Up @@ -191,15 +191,19 @@ File containing baseline hashes
-------------------------------
| **kwarg**: ``hash_library=<path>``
| **CLI**: ``--mpl-hash-library=<path>``
| **INI**: ---
| **INI**: ``mpl-hash-library = <path>``
| Default: *no hash comparison*
The file containing the baseline hashes that will be compared to the test figures.
Both the kwarg option (``hash_library``) and the CLI option (``--mpl-hash-library``) are relative to the test file.
In this case, the CLI option takes precedence over the kwarg option.
The kwarg option (``hash_library``) is relative to the test file, while the INI option (``mpl-hash-library``) is relative to where pytest was run.
The file must be a JSON file in the same format as one generated by ``--mpl-generate-hash-library``.
If its directory does not exist, it will be created along with any missing parent directories.

.. attention::

For backwards compatibility, the CLI option (``--mpl-hash-library``) is relative to the test file.
Also, the CLI option takes precedence over the kwarg option, but the kwarg option takes precedence over the INI option as usual.

Configuring this option disables baseline image comparison.
If you want to enable both hash and baseline image comparison, which we call :doc:`"hybrid mode" <hybrid_mode>`, you must explicitly set the :ref:`baseline directory configuration option <baseline-dir>`.

Expand All @@ -222,8 +226,8 @@ Adjusting these options *may* allow tests to pass across a range of Matplotlib a
RMS tolerance
-------------
| **kwarg**: ``tolerance=<value>``
| **CLI**: ---
| **INI**: ---
| **CLI**: ``--mpl-default-tolerance=<value>``
| **INI**: ``mpl-default-tolerance = <value>``
| Default: ``2``
The maximum RMS difference between the result image and the baseline image before the test fails.
Expand Down Expand Up @@ -306,8 +310,8 @@ A dictionary of keyword arguments to pass to :func:`matplotlib.pyplot.savefig`.
Matplotlib style
----------------
| **kwarg**: ``style=<name>``
| **CLI**: ---
| **INI**: ---
| **CLI**: ``--mpl-default-style=<name>``
| **INI**: ``mpl-default-style = <name>``
| Default: ``"classic"``
The Matplotlib style to use when saving the figure.
Expand Down Expand Up @@ -336,8 +340,8 @@ See the :func:`matplotlib.style.context` ``style`` documentation for the options
Matplotlib backend
------------------
| **kwarg**: ``backend=<name>``
| **CLI**: ---
| **INI**: ---
| **CLI**: ``--mpl-default-backend=<name>``
| **INI**: ``mpl-default-backend = <name>``
| Default: ``"agg"``
The Matplotlib backend to use when saving the figure.
Expand Down Expand Up @@ -395,7 +399,7 @@ Generate test summaries
-----------------------
| **kwarg**: ---
| **CLI**: ``--mpl-generate-summary={html,json,basic-html}``
| **INI**: ---
| **INI**: ``mpl-generate-summary = {html,json,basic-html}``
| Default: ``None``
This option specifies the format of the test summary report to generate, if any.
Expand Down
Loading

0 comments on commit 0d11e7b

Please sign in to comment.