Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preprocessing unit tests #45

Closed
sfluegel05 opened this issue Aug 24, 2024 · 3 comments
Closed

Preprocessing unit tests #45

sfluegel05 opened this issue Aug 24, 2024 · 3 comments
Assignees

Comments

@sfluegel05
Copy link
Collaborator

sfluegel05 commented Aug 24, 2024

We already have some tests for data preprocessing. However, those are more integration tests that capture the behaviour of the tool as a whole than unit tests for specific functions.
In order to efficiently test the different preprocessing functionalities, we need to add some smaller-scale unit tests. Those should not include real data, but sample input values that can be generated from scratch.

Here are the classes / functions that should be covered (from the implementation in the protein_prediction branch
reader.py:

  • DataReader: to_data()
  • ChemDataReader: _read_data()
  • DeepChemDataReader: _read_data()
  • SelfiesReader: _read_data()
  • ProteinDataReader: _read_data()
    collate.py:
  • DefaultCollator: __call__()
  • RaggedCollator: __call__(), process_label_rows()
    datasets/base.py
  • XYBaseDataModule: _filter_labels()
  • DynamicDataset: get_test_split(), get_train_val_splits_given_test()
    datasets/chebi.py
  • _ChEBIDataExtractor: _extract_class_hierarchy(), _graph_to_raw_dataset(), _load_dict(), _setup_pruned_test_set()
  • ChEBIOverX: select_classes()
  • ChEBIOverXPartial: extract_class_hierarchy()
  • term_callback()
    datasets/go_uniprot.py:
  • _GOUniprotDataExtractor: _extract_class_hierarchy(), term_callback(), _graph_to_raw_dataset(), _get_swiss_to_go_mapping(), _load_dict()
  • _GoUniProtOverX: select_classes()
    datasets/tox21.py:
  • Tox21MolNet: setup_processed(), _load_data_from_file()
  • Tox21Challenge: setup_processed(), _load_data_from_file(), _load_dict()

For some functions, it is necessary to read from / write to files. Instead of real files, I would suggest to use mock objects (see e.g. this comment)

@aditya0by0 aditya0by0 mentioned this issue Aug 29, 2024
31 tasks
@aditya0by0 aditya0by0 linked a pull request Aug 29, 2024 that will close this issue
31 tasks
@sfluegel05 sfluegel05 changed the title Additional unit tests Preprocessing unit tests Sep 19, 2024
@aditya0by0
Copy link
Collaborator

aditya0by0 commented Sep 21, 2024

How to Run All Tests in a Given Folder

To run all unit tests in a specific folder using Python's unittest framework, you can use the unittest discover command.

Command Example:

python -m unittest discover -s <test_folder> -t <top-level-directory> -p "<pattern>" 

Explanation of Parameters:

  • -s <test_folder>: This specifies the folder to search for test files. In our case, <test_folder> would be the path to the directory containing the tests (e.g., tests/unit).

  • -p <pattern>: (Optional) This allows you to define a file name pattern for matching the test files. For example:

    • -p "*_test.py" will match files like example_test.py.
    • -p "test_*.py" will match files like test_example.py.
    • If omitted, the default is test*.py (files starting with test).
  • -t <top_level_directory>: Specifies the top-level directory of the project (root). This is necessary when the tests are located in a subdirectory but need to be executed within the context of the top-level project directory. This is where Python will consider the root of the project for resolving module imports during testing.

Running All Tests in tests/unit Folder Example:

python -m unittest discover -s G:\github-aditya0by0\python-chebai\tests\unit -t G:\github-aditya0by0\python-chebai

image

@aditya0by0
Copy link
Collaborator

  • Tox21MolNet: setup_processed(), _load_data_from_file()

The test case for above class is not added/covered in this issue, due to issue #53. It will added after completion of the issue.

@sfluegel05 sfluegel05 removed a link to a pull request Nov 4, 2024
31 tasks
@sfluegel05
Copy link
Collaborator Author

sfluegel05 commented Nov 6, 2024

The toxicity-related tests have not been merged yet. They will be included in #56 (see also issue #53)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants