Skip to content

Commit e1d36ca

Browse files
ArmavicaricardoV94
authored andcommitted
Move tests outside of code directory
1 parent 562e51e commit e1d36ca

File tree

94 files changed

+160
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+160
-156
lines changed

.github/workflows/tests.yml

+61-61
Original file line numberDiff line numberDiff line change
@@ -38,65 +38,65 @@ jobs:
3838
python-version: ["3.10"]
3939
test-subset:
4040
- |
41-
pymc/tests/test_util.py
42-
pymc/tests/test_pytensorf.py
43-
pymc/tests/test_math.py
44-
pymc/tests/backends/test_base.py
45-
pymc/tests/backends/test_ndarray.py
46-
pymc/tests/step_methods/hmc/test_hmc.py
47-
pymc/tests/test_func_utils.py
48-
pymc/tests/distributions/test_shape_utils.py
49-
pymc/tests/distributions/test_mixture.py
41+
tests/test_util.py
42+
tests/test_pytensorf.py
43+
tests/test_math.py
44+
tests/backends/test_base.py
45+
tests/backends/test_ndarray.py
46+
tests/step_methods/hmc/test_hmc.py
47+
tests/test_func_utils.py
48+
tests/distributions/test_shape_utils.py
49+
tests/distributions/test_mixture.py
5050
5151
- |
52-
pymc/tests/distributions/test_continuous.py
53-
pymc/tests/distributions/test_multivariate.py
52+
tests/distributions/test_continuous.py
53+
tests/distributions/test_multivariate.py
5454
5555
- |
56-
pymc/tests/distributions/test_bound.py
57-
pymc/tests/distributions/test_censored.py
58-
pymc/tests/distributions/test_simulator.py
59-
pymc/tests/sampling/test_forward.py
60-
pymc/tests/sampling/test_population.py
61-
pymc/tests/stats/test_convergence.py
62-
pymc/tests/stats/test_log_likelihood.py
63-
pymc/tests/distributions/test_distribution.py
64-
pymc/tests/distributions/test_discrete.py
56+
tests/distributions/test_bound.py
57+
tests/distributions/test_censored.py
58+
tests/distributions/test_simulator.py
59+
tests/sampling/test_forward.py
60+
tests/sampling/test_population.py
61+
tests/stats/test_convergence.py
62+
tests/stats/test_log_likelihood.py
63+
tests/distributions/test_distribution.py
64+
tests/distributions/test_discrete.py
6565
6666
- |
67-
pymc/tests/tuning/test_scaling.py
68-
pymc/tests/tuning/test_starting.py
69-
pymc/tests/distributions/test_dist_math.py
70-
pymc/tests/distributions/test_transform.py
71-
pymc/tests/sampling/test_mcmc.py
72-
pymc/tests/sampling/test_parallel.py
73-
pymc/tests/test_printing.py
67+
tests/tuning/test_scaling.py
68+
tests/tuning/test_starting.py
69+
tests/distributions/test_dist_math.py
70+
tests/distributions/test_transform.py
71+
tests/sampling/test_mcmc.py
72+
tests/sampling/test_parallel.py
73+
tests/test_printing.py
7474
7575
- |
76-
pymc/tests/distributions/test_timeseries.py
77-
pymc/tests/gp/test_cov.py
78-
pymc/tests/gp/test_gp.py
79-
pymc/tests/gp/test_mean.py
80-
pymc/tests/gp/test_util.py
81-
pymc/tests/test_model.py
82-
pymc/tests/test_model_graph.py
83-
pymc/tests/ode/test_ode.py
84-
pymc/tests/ode/test_utils.py
85-
pymc/tests/step_methods/hmc/test_quadpotential.py
76+
tests/distributions/test_timeseries.py
77+
tests/gp/test_cov.py
78+
tests/gp/test_gp.py
79+
tests/gp/test_mean.py
80+
tests/gp/test_util.py
81+
tests/test_model.py
82+
tests/test_model_graph.py
83+
tests/ode/test_ode.py
84+
tests/ode/test_utils.py
85+
tests/step_methods/hmc/test_quadpotential.py
8686
8787
- |
88-
pymc/tests/distributions/test_truncated.py
89-
pymc/tests/logprob/test_abstract.py
90-
pymc/tests/logprob/test_censoring.py
91-
pymc/tests/logprob/test_composite_logprob.py
92-
pymc/tests/logprob/test_cumsum.py
93-
pymc/tests/logprob/test_joint_logprob.py
94-
pymc/tests/logprob/test_mixture.py
95-
pymc/tests/logprob/test_rewriting.py
96-
pymc/tests/logprob/test_scan.py
97-
pymc/tests/logprob/test_tensor.py
98-
pymc/tests/logprob/test_transforms.py
99-
pymc/tests/logprob/test_utils.py
88+
tests/distributions/test_truncated.py
89+
tests/logprob/test_abstract.py
90+
tests/logprob/test_censoring.py
91+
tests/logprob/test_composite_logprob.py
92+
tests/logprob/test_cumsum.py
93+
tests/logprob/test_joint_logprob.py
94+
tests/logprob/test_mixture.py
95+
tests/logprob/test_rewriting.py
96+
tests/logprob/test_scan.py
97+
tests/logprob/test_tensor.py
98+
tests/logprob/test_transforms.py
99+
tests/logprob/test_utils.py
100100
101101
fail-fast: false
102102
runs-on: ${{ matrix.os }}
@@ -164,10 +164,10 @@ jobs:
164164
floatx: [float64]
165165
python-version: ["3.8"]
166166
test-subset:
167-
- pymc/tests/variational/test_approximations.py pymc/tests/variational/test_callbacks.py pymc/tests/variational/test_inference.py pymc/tests/variational/test_opvi.py pymc/tests/test_initial_point.py
168-
- pymc/tests/test_model.py pymc/tests/sampling/test_mcmc.py
169-
- pymc/tests/gp/test_cov.py pymc/tests/gp/test_gp.py pymc/tests/gp/test_mean.py pymc/tests/gp/test_util.py pymc/tests/ode/test_ode.py pymc/tests/ode/test_utils.py pymc/tests/smc/test_smc.py pymc/tests/sampling/test_parallel.py
170-
- pymc/tests/step_methods/test_metropolis.py pymc/tests/step_methods/test_slicer.py pymc/tests/step_methods/hmc/test_nuts.py pymc/tests/step_methods/test_compound.py pymc/tests/step_methods/hmc/test_hmc.py
167+
- tests/variational/test_approximations.py tests/variational/test_callbacks.py tests/variational/test_inference.py tests/variational/test_opvi.py tests/test_initial_point.py
168+
- tests/test_model.py tests/sampling/test_mcmc.py
169+
- tests/gp/test_cov.py tests/gp/test_gp.py tests/gp/test_mean.py tests/gp/test_util.py tests/ode/test_ode.py tests/ode/test_utils.py tests/smc/test_smc.py tests/sampling/test_parallel.py
170+
- tests/step_methods/test_metropolis.py tests/step_methods/test_slicer.py tests/step_methods/hmc/test_nuts.py tests/step_methods/test_compound.py tests/step_methods/hmc/test_hmc.py
171171

172172
fail-fast: false
173173
runs-on: ${{ matrix.os }}
@@ -238,16 +238,16 @@ jobs:
238238
python-version: ["3.9"]
239239
test-subset:
240240
- |
241-
pymc/tests/sampling/test_parallel.py
242-
pymc/tests/test_data.py
243-
pymc/tests/test_model.py
241+
tests/sampling/test_parallel.py
242+
tests/test_data.py
243+
tests/test_model.py
244244
245245
- |
246-
pymc/tests/sampling/test_mcmc.py
246+
tests/sampling/test_mcmc.py
247247
248248
- |
249-
pymc/tests/backends/test_arviz.py
250-
pymc/tests/variational/test_updates.py
249+
tests/backends/test_arviz.py
250+
tests/variational/test_updates.py
251251
fail-fast: false
252252
runs-on: ${{ matrix.os }}
253253
env:
@@ -312,7 +312,7 @@ jobs:
312312
floatx: [float64]
313313
python-version: ["3.9"]
314314
test-subset:
315-
- pymc/tests/sampling/test_jax.py pymc/tests/sampling/test_mcmc_external.py
315+
- tests/sampling/test_jax.py tests/sampling/test_mcmc_external.py
316316
fail-fast: false
317317
runs-on: ${{ matrix.os }}
318318
env:
@@ -383,7 +383,7 @@ jobs:
383383
floatx: [float32]
384384
python-version: ["3.10"]
385385
test-subset:
386-
- pymc/tests/sampling/test_mcmc.py pymc/tests/ode/test_ode.py pymc/tests/ode/test_utils.py
386+
- tests/sampling/test_mcmc.py tests/ode/test_ode.py tests/ode/test_utils.py
387387
fail-fast: false
388388
runs-on: ${{ matrix.os }}
389389
env:

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
recursive-include pymc/tests/data *
1+
recursive-include tests/data *
22
recursive-include source *
33
# because of an upload-size limit by PyPI, we're temporarily removing docs from the tarball:
44
recursive-exclude docs *

codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ coverage:
2020
base: auto
2121

2222
ignore:
23-
- "pymc/tests/*"
23+
- "tests/*"
2424
- "pymc/_version.py"
2525

2626
comment:

docs/source/contributing/implementing_distribution.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -233,14 +233,14 @@ pm.logcdf(blah, [-0.5, 1.5]).eval()
233233

234234
## 3. Adding tests for the new `RandomVariable`
235235

236-
Tests for new `RandomVariables` are mostly located in `pymc/tests/distributions/test_*.py`.
236+
Tests for new `RandomVariables` are mostly located in `tests/distributions/test_*.py`.
237237
Most tests can be accommodated by the default `BaseTestDistributionRandom` class, which provides default tests for checking:
238238
1. Expected inputs are passed to the `rv_op` by the `dist` `classmethod`, via `check_pymc_params_match_rv_op`
239239
1. Expected (exact) draws are being returned, via `check_pymc_draws_match_reference`
240240
1. Shape variable inference is correct, via `check_rv_size`
241241

242242
```python
243-
from pymc.tests.distributions.util import BaseTestDistributionRandom, seeded_scipy_distribution_builder
243+
from tests.distributions.util import BaseTestDistributionRandom, seeded_scipy_distribution_builder
244244

245245
class TestBlah(BaseTestDistributionRandom):
246246

@@ -279,7 +279,7 @@ class TestBlahAltParam2(BaseTestDistributionRandom):
279279

280280
```
281281

282-
Custom tests can also be added to the class as is done for the {class}`~pymc.tests.distributions.test_continuous.TestFlat`.
282+
Custom tests can also be added to the class as is done for the {class}`~tests.distributions.test_continuous.TestFlat`.
283283

284284
### Note on `check_rv_size` test:
285285

@@ -292,7 +292,7 @@ tests_to_run = ["check_rv_size"]
292292
```
293293

294294
This is usually needed for Multivariate distributions.
295-
You can see an example in {class}`~pymc.tests.distributions.test_multivariate.TestDirichlet`.
295+
You can see an example in {class}`~tests.distributions.test_multivariate.TestDirichlet`.
296296

297297
### Notes on `check_pymcs_draws_match_reference` test
298298

@@ -302,17 +302,17 @@ The latter kind of test (if warranted) can be performed with the aid of `pymc_ra
302302
This kind of test only makes sense if there is a good independent generator reference (i.e., not just the same composition of NumPy / SciPy calls that is done inside `rng_fn`).
303303

304304
Finally, when your `rng_fn` is doing something more than just calling a NumPy or SciPy method, you will need to set up an equivalent seeded function with which to compare for the exact draws (instead of relying on `seeded_[scipy|numpy]_distribution_builder`).
305-
You can find an example in {class}`~pymc.tests.distributions.test_continuous.TestWeibull`, whose `rng_fn` returns `beta * np.random.weibull(alpha, size=size)`.
305+
You can find an example in {class}`~tests.distributions.test_continuous.TestWeibull`, whose `rng_fn` returns `beta * np.random.weibull(alpha, size=size)`.
306306

307307

308308
## 4. Adding tests for the `logp` / `logcdf` methods
309309

310310
Tests for the `logp` and `logcdf` mostly make use of the helpers `check_logp`, `check_logcdf`, and
311-
`check_selfconsistency_discrete_logcdf` implemented in `~pymc.tests.distributions.util`
311+
`check_selfconsistency_discrete_logcdf` implemented in `~tests.distributions.util`
312312

313313
```python
314-
from pymc.tests.distributions.util import check_logp, check_logcdf, Domain
315-
from pymc.tests.helpers import select_by_precision
314+
from tests.helpers import select_by_precision
315+
from tests.distributions.util import check_logp, check_logcdf, Domain
316316

317317
R = Domain([-np.inf, -2.1, -1, -0.01, 0.0, 0.01, 1, 2.1, np.inf])
318318
Rplus = Domain([0, 0.01, 0.1, 0.9, 0.99, 1, 1.5, 2, 100, np.inf])
@@ -382,7 +382,7 @@ which checks if:
382382

383383
import pytest
384384
from pymc.distributions import Blah
385-
from pymc.tests.distributions.util import assert_moment_is_expected
385+
from tests.distributions.util import assert_moment_is_expected
386386

387387
@pytest.mark.parametrize(
388388
"param1, param2, size, expected",

docs/source/contributing/running_the_test_suite.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Therefore, we recommend to run just specific tests that target the parts of the
1919

2020
To run all tests from a single file:
2121
```bash
22-
pytest -v pymc/tests/test_model.py
22+
pytest -v tests/test_model.py
2323
```
2424

2525
```{tip}
@@ -31,7 +31,7 @@ By using the `-k` flag, you can filter for test cases that match a certain patte
3131
For example, the following command runs all test cases from `test_model.py` that have "coord" in their name:
3232

3333
```bash
34-
pytest -v pymc/tests/test_model.py -k coord
34+
pytest -v tests/test_model.py -k coord
3535
```
3636

3737

@@ -40,7 +40,7 @@ Note that because you are not running the entire test suite, the coverage will b
4040
But you can still watch for specific line numbers of the code that you're working on.
4141

4242
```bash
43-
pytest -v --cov=pymc --cov-report term-missing pymc/tests/<name of test>.py
43+
pytest -v --cov=pymc --cov-report term-missing tests/<name of test>.py
4444
```
4545

4646
When you are reasonably confident about the changes you made, you can push the changes and open a pull request.

pymc/data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def get_data(filename):
6363
-------
6464
BytesIO of the data
6565
"""
66-
data_pkg = "pymc.tests"
66+
data_pkg = "tests"
6767
try:
6868
content = pkgutil.get_data(data_pkg, os.path.join("data", filename))
6969
except FileNotFoundError:

scripts/check_all_tests_are_covered.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def find_testfiles():
2323
dp_repo = Path(__file__).parent.parent
2424
all_tests = {
2525
str(fp.relative_to(dp_repo)).replace(os.sep, "/")
26-
for fp in (dp_repo / "pymc" / "tests").glob("**/test_*.py")
26+
for fp in (dp_repo / "tests").glob("**/test_*.py")
2727
}
2828
_log.info("Found %i tests in total.", len(all_tests))
2929
return all_tests

scripts/run_mypy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def check_no_unexpected_results(mypy_lines: Iterator[str]):
159159
args, _ = parser.parse_known_args()
160160

161161
cp = subprocess.run(
162-
["mypy", "--show-error-codes", "--exclude", "pymc/tests", "pymc"],
162+
["mypy", "--show-error-codes", "--exclude", "tests", "pymc"],
163163
capture_output=True,
164164
)
165165
output = cp.stdout.decode()

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tool:pytest]
2-
testpaths = pymc/tests
2+
testpaths = tests
33

44
[coverage:run]
55
omit = *examples*

pymc/tests/variational/__init__.py renamed to tests/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
import pymc as pm
16+
17+
_log = pm._log
File renamed without changes.

pymc/tests/backends/fixtures.py renamed to tests/backends/fixtures.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import pytest
2323

2424
from pymc.backends import base
25-
from pymc.tests import models
25+
from tests import models
2626

2727

2828
class ModelBackendSetupTestCase:

pymc/tests/backends/test_arviz.py renamed to tests/backends/test_arviz.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def test_overwrite_model_coords_dims(self):
326326
assert np.all(idata2.constant_data.x.dim2.values == np.array(["c1", "c2"]))
327327

328328
def test_missing_data_model(self):
329-
# source pymc/pymc/tests/test_missing.py
329+
# source tests/test_missing.py
330330
data = ma.masked_values([1, 2, -1, 4, -1], value=-1)
331331
model = pm.Model()
332332
with model:
File renamed without changes.

pymc/tests/backends/test_ndarray.py renamed to tests/backends/test_ndarray.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import pytest
1818

1919
from pymc.backends import base, ndarray
20-
from pymc.tests.backends import fixtures as bf
20+
from tests.backends import fixtures as bf
2121

2222
STATS1 = [{"a": np.float64, "b": bool}]
2323

File renamed without changes.
File renamed without changes.
File renamed without changes.

pymc/tests/distributions/test_continuous.py renamed to tests/distributions/test_continuous.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from pymc.logprob.joint_logprob import logp
3333
from pymc.logprob.utils import ParameterValueError
3434
from pymc.pytensorf import floatX
35-
from pymc.tests.distributions.util import (
35+
from tests.distributions.util import (
3636
BaseTestDistributionRandom,
3737
Circ,
3838
Domain,
@@ -49,8 +49,8 @@
4949
seeded_numpy_distribution_builder,
5050
seeded_scipy_distribution_builder,
5151
)
52-
from pymc.tests.helpers import select_by_precision
53-
from pymc.tests.logprob.utils import create_pytensor_params, scipy_logprob_tester
52+
from tests.helpers import select_by_precision
53+
from tests.logprob.utils import create_pytensor_params, scipy_logprob_tester
5454

5555
try:
5656
from polyagamma import polyagamma_cdf, polyagamma_pdf, random_polyagamma

pymc/tests/distributions/test_discrete.py renamed to tests/distributions/test_discrete.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
from pymc.logprob.joint_logprob import logp
3434
from pymc.logprob.utils import ParameterValueError
3535
from pymc.pytensorf import floatX
36-
from pymc.tests.distributions.util import (
36+
from pymc.vartypes import discrete_types
37+
from tests.distributions.util import (
3738
BaseTestDistributionRandom,
3839
Bool,
3940
Domain,
@@ -57,8 +58,7 @@
5758
seeded_numpy_distribution_builder,
5859
seeded_scipy_distribution_builder,
5960
)
60-
from pymc.tests.logprob.utils import create_pytensor_params, scipy_logprob_tester
61-
from pymc.vartypes import discrete_types
61+
from tests.logprob.utils import create_pytensor_params, scipy_logprob_tester
6262

6363

6464
def discrete_weibull_logpmf(value, q, beta):

pymc/tests/distributions/test_dist_math.py renamed to tests/distributions/test_dist_math.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
)
3838
from pymc.logprob.utils import ParameterValueError
3939
from pymc.pytensorf import floatX
40-
from pymc.tests.checks import close_to
41-
from pymc.tests.helpers import verify_grad
40+
from tests.checks import close_to
41+
from tests.helpers import verify_grad
4242

4343

4444
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)