IMP logo
IMP Reference Guide  develop.c5f265b,2019/04/25
The Integrative Modeling Platform
IMP::test Namespace Reference

Support for running tests of IMP functionality. More...

Detailed Description

Support for running tests of IMP functionality.

Most of this is centered around the Python unittest module.

Info

Author(s): Ben Webb, Daniel Russel

Maintainer: benmwebb

License: LGPL This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Publications:

Classes

class  ApplicationTestCase
 Super class for simple IMP application test cases. More...
 
class  DirectorObjectChecker
 Check to make sure the number of director references is as expected. More...
 
class  RefCountChecker
 Check to make sure the number of C++ object references is as expected. More...
 
class  TestCase
 Super class for IMP test cases. More...
 

Functions

def main
 Run a set of tests; similar to unittest.main(). More...
 
def numerical_derivative
 Calculate the derivative of the single-value function func at point val. More...
 
def temporary_directory
 Simple context manager to make a temporary directory. More...
 
def temporary_working_directory
 Simple context manager to run in a temporary directory. More...
 
def xyz_numerical_derivatives
 Calculate the x,y and z derivatives of the scoring function sf on the xyz particle. More...
 

Standard module functions

All IMP modules have a set of standard functions to help get information about the module and about files associated with the module.

std::string get_module_version ()
 
std::string get_module_name ()
 
std::string get_data_path (std::string file_name)
 Return the full path to one of this module's data files. More...
 
std::string get_example_path (std::string file_name)
 Return the full path to one of this module's example files. More...
 

Function Documentation

std::string IMP::test::get_data_path ( std::string  file_name)

Return the full path to one of this module's data files.

To read the data file "data_library" that was placed in the data directory of this module, do something like

std::ifstream in(IMP::test::get_data_path("data_library"));

This will ensure that the code works both when IMP is installed or if used via the setup_environment.sh script.

Note
Each module has its own data directory, so be sure to use this function from the correct module.
std::string IMP::test::get_example_path ( std::string  file_name)

Return the full path to one of this module's example files.

To read the example file "example_protein.pdb" that was placed in the examples directory of this module, do something like

std::ifstream in(IMP::test::get_example_path("example_protein.pdb"));

This will ensure that the code works both when IMP is installed or if used via the setup_environment.sh script.

Note
Each module has its own example directory, so be sure to use this function from the correct module.
def IMP.test.main (   args,
  keys 
)

Run a set of tests; similar to unittest.main().

Obviates the need to separately import the 'unittest' module, and ensures that main() is from the same unittest module that the IMP.test testcases are. In addition, turns on some extra checks (e.g. trying to use deprecated code will cause an exception to be thrown).

Note
This function is only available in Python.

Definition at line 1133 of file test/__init__.py.

def IMP.test.numerical_derivative (   func,
  val,
  step 
)

Calculate the derivative of the single-value function func at point val.

The derivative is calculated using simple finite differences starting with the given step; Richardson extrapolation is then used to extrapolate the derivative at step=0.

Note
This function is only available in Python.

Definition at line 399 of file test/__init__.py.

def IMP.test.temporary_directory (   dir = None)

Simple context manager to make a temporary directory.

The temporary directory has the same lifetime as the context manager (i.e. it is created at the start of the 'with' block, and deleted at the end of the block).

Parameters
dirIf given, the temporary directory is made as a subdirectory of that directory, rather than in the default temporary directory location (e.g. /tmp)
Returns
the full path to the temporary directory.
Note
This function is only available in Python.

Definition at line 384 of file test/__init__.py.

def IMP.test.temporary_working_directory ( )

Simple context manager to run in a temporary directory.

While the context manager is active (within the 'with' block) the current working directory is set to a temporary directory. When the context manager exists, the working directory is reset and the temporary directory deleted.

Note
This function is only available in Python.

Definition at line 370 of file test/__init__.py.

def IMP.test.xyz_numerical_derivatives (   sf,
  xyz,
  step 
)

Calculate the x,y and z derivatives of the scoring function sf on the xyz particle.

The derivatives are approximated numerically using the numerical_derivatives() function.

Note
This function is only available in Python.

Definition at line 435 of file test/__init__.py.