-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
re-organize tests and added toml as testing/dev dependency
- Loading branch information
1 parent
064b0ac
commit d0f956a
Showing
14 changed files
with
154 additions
and
106 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# ezgatr Tests README | ||
|
||
## Overview | ||
|
||
This directory contains test cases for the `ezgatr` library, ensuring that its components function correctly and as expected. Tests are organized to mirror the sub-module structure of the main package. | ||
|
||
## Test Organization | ||
|
||
- **Sub-module Specific Tests**: Tests for specific sub-modules (e.g., `ezgatr.nn`) reside within corresponding directories under `tests` (e.g., `tests.nn`). | ||
|
||
- **Thematic Tests**: Tests covering specific themes that do not belong to any particular module are placed in the `tests/thematic` directory. For example, `tests.thematic.test_regress_with_clifford.py` ensures that the library's geometric algebra operations align with those of the `clifford` package. | ||
|
||
## Configuration Management | ||
|
||
To avoid hard-coding configurations and to maintain consistency across tests, configurations are centralized into dedicated files. | ||
|
||
- **Core Configurations**: Shared configurations, such as execution devices, numerical precision tolerance, and test data generation parameters, are defined in `tests/config/core.toml`. | ||
|
||
- **Module/Theme-Specific Configurations**: Configurations unique to specific sub-modules or themes are organized in respective files within the `tests/config` directory: | ||
- `interfaces.toml` | ||
- `thematic.toml` | ||
|
||
## File Structure | ||
|
||
``` | ||
tests/ | ||
├── __init__.py | ||
├── conftest.py | ||
├── utils.py | ||
├── config/ | ||
│ ├── __init__.py | ||
│ ├── core.toml | ||
│ ├── interfaces.toml | ||
│ └── thematic.toml | ||
├── interfaces/ | ||
│ ├── __init__.py | ||
│ ├── test_plane.py | ||
│ ├── test_point.py | ||
│ └── ... | ||
├── nn/ | ||
│ ├── __init__.py | ||
│ ├── test_functional.py | ||
│ └── test_modules.py | ||
└── thematic/ | ||
├── __init__.py | ||
├── README.md | ||
├── test_gradient_flow.py | ||
├── test_operator_equivariance.py | ||
└── test_regress_with_clifford.py | ||
``` | ||
|
||
## Forward | ||
|
||
This README provides an introduction to how tests and configurations are organized in the `tests` directory. Future updates will provide more detailed documentation as the test suite expands. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class BasicConfig: | ||
r"""Basic configurations shared across all tests. | ||
Parameters | ||
---------- | ||
rtol : float | ||
Relative tolerance for ``torch.testing.assert_close``. | ||
atol : float | ||
Absolute tolerance for ``torch.testing.assert_close``. | ||
equal_nan : bool | ||
If ``True``, then two ``NaN`` s will be considered equal. | ||
check_device : bool | ||
If ``True``, check that ``input`` and ``other`` are on the same device. | ||
check_dtype : bool | ||
If ``True``, check that ``input`` and ``other`` have the same dtype. | ||
device : str | ||
The device on which tests are executed (e.g., 'cpu', 'cuda'). | ||
max_batch_size : int | ||
Maximum number of sequences within a batch of multi-vectors when | ||
generating random testing data points. | ||
max_context_size : int | ||
Maximum number of multi-vectors within a single sequence when generating | ||
random testing data points. | ||
max_channel_size : int | ||
Maximum number of channels for each multi-vector within a sequence | ||
when generating random testing data points. | ||
""" | ||
rtol: float | ||
atol: float | ||
equal_nan: bool | ||
check_device: bool | ||
check_dtype: bool | ||
device: str | ||
max_batch_size: int | ||
max_context_size: int | ||
max_channel_size: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Core Configurations for ezgatr Tests | ||
|
||
execution_device = "cpu" # The device on which tests are executed (e.g., "cpu", "cuda") | ||
numerical_precision = 1e-5 # The tolerance level for numerical precision in tests | ||
rtol = 1e-5 # Relative tolerance for torch.testing.assert_close | ||
atol = 1e-8 # Absolute tolerance for torch.testing.assert_close | ||
equal_nan = true # If true, then two NaNs will be considered equal | ||
check_device = false # If true, check that input and other are on the same device | ||
check_dtype = true # If true, check that input and other have the same dtype | ||
num_random_data_points = 100 # The number of random data points generated for tests | ||
data_point_size = 256 # The size of each random data point | ||
|
||
# Add additional core configurations as needed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[geometric] | ||
rotation_angles = [0.0, 0.7853981634, 1.5707963268] # 0, π/4, π/2 | ||
translation_mags = [0.0, 1.0, 5.0] | ||
reflection_axes = ["x", "y", "z"] | ||
rtol = 1e-4 | ||
atol = 1e-6 |
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import pathlib | ||
|
||
import pytest | ||
import toml | ||
|
||
from tests.config import BasicConfig | ||
|
||
DIR_TEST = pathlib.Path(".").resolve().parent | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def basic_config(): | ||
r"""Load basic configurations for tests. | ||
This fixture reads the ``core.toml`` file and returns an instance of the `BasicConfig` dataclass | ||
containing the configuration parameters. | ||
Returns | ||
------- | ||
BasicConfig | ||
An instance containing basic test configurations. | ||
""" | ||
with open(DIR_TEST / "config" / "core.toml") as f: | ||
config_data = toml.load(f) | ||
return BasicConfig(**config_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.