Skip to content

Commit

Permalink
Moved all unit tests to a separate folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
luisenp committed Nov 4, 2022
1 parent 2d4cc23 commit 70603be
Show file tree
Hide file tree
Showing 69 changed files with 42 additions and 40 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ run_tests: &run_tests
name: Running tests
working_directory: ~/project
command: |
pytest -s theseus/tests/test_theseus_layer.py
pytest -s theseus -m "cudaext"
pytest -s tests/test_theseus_layer.py
pytest -s tests -m "cudaext"
# -------------------------------------------------------------------------------------
# Jobs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ We support several features that improve computation times and memory consumptio
### Running unit tests (requires `dev` installation)
```bash
python -m pytest theseus
python -m pytest tests
```
By default, unit tests include tests for our CUDA extensions. You can add the option `-m "not cudaext"`
to skip them when installing without CUDA support. Additionally, the tests for sparse solver BaSpaCho are automatically
Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The simplest way to install Theseus from source is by running the following (see
git clone https://github.com/facebookresearch/theseus.git
pip install -e .
python -m pytest theseus
python -m pytest tests
If you are interested in contributing to ``theseus``, instead install using

Expand Down Expand Up @@ -65,7 +65,7 @@ With ``dev`` installation, you can run unit tests via

.. code-block:: bash
python -m pytest theseus
python -m pytest tests
By default, unit tests include tests for our CUDA extensions. You can add the option `-m "not cudaext"`
to skip them when installing without CUDA support. Additionally, the tests for sparse solver BaSpaCho are automatically
Expand Down
2 changes: 1 addition & 1 deletion examples/se2_inverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import torch

import theseus as th
from tests.geometry.test_se2 import create_random_se2
from theseus import LieGroupTensor
from theseus.geometry.lie_group import LieGroup
from theseus.geometry.tests.test_se2 import create_random_se2

# Create two random SE2
rng = torch.Generator()
Expand Down
6 changes: 4 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ def mypy_and_tests(session):
session.install("torch")
session.install("-r", "requirements/dev.txt")
session.run("mypy", "theseus")
session.install("-e", ".", env={'BASPACHO_ROOT_DIR': os.environ.get('BASPACHO_ROOT_DIR')})
session.run("pytest", "theseus", "-m", "(not cudaext)")
session.install(
"-e", ".", env={"BASPACHO_ROOT_DIR": os.environ.get("BASPACHO_ROOT_DIR")}
)
session.run("pytest", "tests", "-m", "(not cudaext)")
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ per-file-ignores =
*__init__.py:F401
# E261,E241,E121,E131,E201,E202: formatting options, to avoid having to
# re-format explicit sparse matrices used for a small example
theseus/extlib/tests/test_baspacho_simple.py:E261,E241,E121,E131,E201,E202
tests/extlib/test_baspacho_simple.py:E261,E241,E121,E131,E201,E202

[mypy]
python_version = 3.7
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch

import theseus as th
from theseus.core.tests.common import BATCH_SIZES_TO_TEST
from tests.core.common import BATCH_SIZES_TO_TEST


def _new_robust_cf(batch_size, loss_cls, generator) -> th.RobustCostFunction:
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import torch

import theseus as th
from theseus.core.tests.common import BATCH_SIZES_TO_TEST
from tests.core.common import BATCH_SIZES_TO_TEST
from theseus.core.vectorizer import _CostFunctionWrapper


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch

import theseus as th
from theseus.core.tests.common import (
from tests.core.common import (
BATCH_SIZES_TO_TEST,
check_another_theseus_function_is_copy,
check_another_theseus_tensor_is_copy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
import torch

import theseus as th
from theseus.core.tests.common import BATCH_SIZES_TO_TEST
from theseus.embodied.collision.tests.utils import (
from tests.core.common import BATCH_SIZES_TO_TEST
from tests.embodied.collision.utils import (
random_origin,
random_scalar,
random_sdf_data,
)
from theseus.geometry.tests.test_se2 import create_random_se2
from tests.geometry.test_se2 import create_random_se2
from theseus.utils import numeric_jacobian


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch

import theseus as th
from theseus.core.tests.common import BATCH_SIZES_TO_TEST
from tests.core.common import BATCH_SIZES_TO_TEST
from theseus.utils import numeric_jacobian

from .utils import random_sdf
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch

import theseus as th
from theseus.core.tests.common import (
from tests.core.common import (
BATCH_SIZES_TO_TEST,
check_another_theseus_function_is_copy,
check_another_theseus_tensor_is_copy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import theseus.core as thcore
import theseus.embodied as thembod
import theseus.geometry as thgeom
from theseus.core.tests.common import (
from tests.core.common import (
BATCH_SIZES_TO_TEST,
check_another_theseus_function_is_copy,
check_another_theseus_tensor_is_copy,
)
from theseus.geometry.tests.test_se2 import create_random_se2
from tests.geometry.test_se2 import create_random_se2
from theseus.utils import numeric_jacobian


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch

import theseus as th
from theseus.core.tests.common import (
from tests.core.common import (
BATCH_SIZES_TO_TEST,
check_another_theseus_function_is_copy,
check_another_theseus_tensor_is_copy,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import theseus as th
from theseus.core import Variable
from theseus.core.tests.common import (
from tests.core.common import (
BATCH_SIZES_TO_TEST,
check_another_theseus_function_is_copy,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import torch

import theseus as th
from theseus.core.tests.common import BATCH_SIZES_TO_TEST
from theseus.geometry.tests.test_se2 import create_random_se2
from tests.core.common import BATCH_SIZES_TO_TEST
from tests.geometry.test_se2 import create_random_se2
from theseus.utils import numeric_jacobian


Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scipy.sparse import csr_matrix, tril


from theseus.extlib.tests.common import run_if_baspacho
from tests.extlib.common import run_if_baspacho
from theseus.utils import random_sparse_binary_matrix, split_into_param_sizes


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np
import pytest # noqa: F401

from theseus.extlib.tests.common import run_if_baspacho
from tests.extlib.common import run_if_baspacho


# fmt: off
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from theseus.constants import TEST_EPS
from theseus.core.cost_function import AutoDiffCostFunction, AutogradMode
from theseus.core.tests.common import BATCH_SIZES_TO_TEST # noqa: F401
from tests.core.common import BATCH_SIZES_TO_TEST # noqa: F401
from theseus.geometry.lie_group_check import set_lie_group_check_enabled
from theseus.geometry.vector import Vector
from theseus.utils import numeric_jacobian
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_operations_mypy_cast():
import mypy.api
except ModuleNotFoundError:
return
result = mypy.api.run(["theseus/geometry/tests/point_types_mypy_check.py"])
result = mypy.api.run(["tests/geometry/point_types_mypy_check.py"])
assert result[2] == 0


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import theseus as th
from theseus.constants import TEST_EPS
from theseus.core.tests.common import check_copy_var
from tests.core.common import check_copy_var
from theseus.utils import numeric_jacobian

from .common import (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import theseus as th
from theseus.constants import EPS
from theseus.core.tests.common import check_copy_var
from tests.core.common import check_copy_var
from theseus.utils import numeric_jacobian

from .common import (
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import theseus as th
from theseus.constants import EPS
from theseus.core.tests.common import check_copy_var
from tests.core.common import check_copy_var

from .common import (
BATCH_SIZES_TO_TEST,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from torch.autograd import gradcheck
from theseus.optimizer.autograd import BaspachoSolveFunction

from theseus.extlib.tests.common import run_if_baspacho
from tests.extlib.common import run_if_baspacho
from theseus.utils import random_sparse_binary_matrix, split_into_param_sizes

import theseus as th
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_sparse_backward_step():


def test_float64_used():
data = torch.load("theseus/optimizer/autograd/tests/bad_sparse_matrix.pth")
data = torch.load("tests/optimizer/autograd/bad_sparse_matrix.pth")
decomp = analyze_AAt(data["struct"].mock_csc_transpose())
delta = CholmodSolveFunction.apply(
data["a"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import pytest # noqa: F401
import torch

from theseus.extlib.tests.common import run_if_baspacho
from theseus.optimizer.autograd.tests.test_baspacho_sparse_backward import (
from tests.extlib.common import run_if_baspacho
from tests.optimizer.autograd.test_baspacho_sparse_backward import (
get_linearization_and_solver_for_random_sparse,
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import theseus as th

from theseus.optimizer.nonlinear.tests.common import run_nonlinear_least_squares_check
from tests.optimizer.nonlinear.common import run_nonlinear_least_squares_check


@pytest.fixture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch # noqa: F401

import theseus as th
from theseus.optimizer.tests.linearization_test_utils import (
from tests.optimizer.linearization_test_utils import (
build_test_objective_and_linear_system,
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch # noqa: F401

import theseus as th
from theseus.optimizer.tests.linearization_test_utils import (
from tests.optimizer.linearization_test_utils import (
build_test_objective_and_linear_system,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import torch

import theseus as th
from theseus.core.tests.common import MockCostFunction, MockCostWeight, MockVar
from tests.core.common import MockCostFunction, MockCostWeight, MockVar


def test_default_variable_ordering():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import torch

import theseus as th
from theseus.core.tests.common import BATCH_SIZES_TO_TEST
from tests.core.common import BATCH_SIZES_TO_TEST
from theseus.theseus_layer import _DLMPerturbation
from theseus.utils import numeric_jacobian

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import theseus as th
import theseus.utils as thutils
from theseus.core.tests.common import (
from tests.core.common import (
MockCostFunction,
MockCostWeight,
MockVar,
Expand Down
File renamed without changes.

0 comments on commit 70603be

Please sign in to comment.