professor.tools¶This module contains helper functions for common tasks in the Professor system. Some may also be useful for user scripts, such as logging and file/directory handling. professor.tools.io¶Helper module with static methods to check for directories and access rights, and some helpers for file and directory creation and handling, with suitable checks and permissions. The makeDir() function is a handy way to create a readable/writeable directory without having to manually do all the edge-case checks that the native :module:`os` module tools require. The is* tests return true or false, i.e. are just packaged versions of standard I/O functions from os and os.path. The assert* tests, by contrast, raise an IOTestFailed exception if the condition is not met. The isFile* tests actually test that the path is not a directory. This allows use with pipes, links, etc. as well as actual files. Note The exception is raised here and not in the functions where the checks are performed to save some typing, because usually such an IO error means that the script fails. If the script should continue, the exception can be ‘excepted’. Todo Allow user to pass in an error-handling function as an argument, rather than see the exception? Todo Remove test* aliases for I/O asserts.
professor.tools.decorators¶Library with useful method/function decorators: virtualmethod¶A little tool to make interface definition and inheritance easier. Allows completely virtual methods like in C++: C{ virtual void func(...) = 0; } Usage example: >>> class Super:
... @virtualmethod
... def virt(arg1, arg2):
... pass
...
>>>
>>> class Sub(Super):
... def virt(arg1, arg2):
... pass
...
>>> mum = Super()
>>> daughter = Sub()
>>> mum.virt(1, 2)
[...]
VirtualMethodError: virtual method "virt" called!
deprecated¶Use this if you want to log a deprecation method with warning priority everytime a function is called. Usage: >>> def new(*args, **kwargs):
>>> pass
>>>
>>> @deprecated(new)
>>> def old(*args, **kwargs):
>>> pass
>>> old(foo, bar)
>>> # some warning log
professor.tools.stats¶Functions for statistical measures and correlations.
professor.tools.permut¶Tools for generating and handling combinatoric permutations.
professor.tools.eigen¶Functions for handling eigen-decompositions of covariance matrices and the like. Mostly kept general in terms of NumPY/SciPy data objects, although some specifics to MinimizationResult may also occur until there’s an obvious better place to put them.
professor.tools.pointsampling¶Random generator tools for sampling points in a space.
professor.tools.config¶ |