scipy / scipy_doctest

Floating-point aware doctesting
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

ENH: make collection strategy user configurable in the pytest layer #128

Closed ev-br closed 6 months ago

ev-br commented 6 months ago

This is a breaking change: the default collection strategy changes from "api" to vanilla pytest.

Add a cmdline option, --doctest-collect={None, api}

The default is now the vanilla doctest collection, strategy=None. To select strategy='api', use the command flag

$ pytest --doctest-modules --doctest-collect=api

When to use what. strategy='api' is meant for packages with non-trivial internal structure and where you only enfore doctests correctness for public objects.

For individual single-file modules, you probably want strategy=None.

closes gh-114

P.S. I manually checked

<Dir scipy>
  <Dir build-install>
    <Dir lib>
      <Dir python3.10>
        <Dir site-packages>
          <Package scipy>
            <Package linalg>
              <DTModule _basic.py>
                <DoctestItem scipy.linalg._basic.det>
                <DoctestItem scipy.linalg._basic.inv>
                <DoctestItem scipy.linalg._basic.lstsq>
                <DoctestItem scipy.linalg._basic.matmul_toeplitz>
                <DoctestItem scipy.linalg._basic.matrix_balance>
                <DoctestItem scipy.linalg._basic.pinv>
                <DoctestItem scipy.linalg._basic.pinvh>
                <DoctestItem scipy.linalg._basic.solve>
                <DoctestItem scipy.linalg._basic.solve_banded>
                <DoctestItem scipy.linalg._basic.solve_circulant>
                <DoctestItem scipy.linalg._basic.solve_toeplitz>
                <DoctestItem scipy.linalg._basic.solve_triangular>
                <DoctestItem scipy.linalg._basic.solveh_banded>
<Dir scipy>
  <Dir build-install>
    <Dir lib>
      <Dir python3.10>
        <Dir site-packages>
          <Package scipy>
            <Package linalg>
              <DTModule _basic.py>
                <DoctestItem scipy.linalg._basic.det>

Note the need to specify the full dotted name of the doctested object.

ev-br commented 6 months ago

@Sheila-nk WDYT?

ev-br commented 6 months ago

Note to self: remember to update https://github.com/scipy/scipy/pull/20127 when this lands.

Sheila-nk commented 6 months ago

I think it's great you made the collection strategy configurable. Looks good to me! 🚀

ev-br commented 6 months ago

Let's roll with it then. More tweaks are on the way based on the combination of this and gh-133. Thanks Sheila.

ev-br commented 6 months ago

Did not mean to squash-merge. Not a big deal though.