3.1.13. horton.utils
– Utility functions¶
-
horton.utils.
typecheck_geo
(coordinates=None, numbers=None, pseudo_numbers=None, need_coordinates=True, need_numbers=True, need_pseudo_numbers=True)¶ Type check a molecular geometry specification
Arguments:
- coordinates
- A (N, 3) float array with Cartesian coordinates of the atoms.
- numbers
- A (N,) int vector with the atomic numbers.
Optional arguments:
- pseudo_numbers
- A (N,) float array with pseudo-potential core charges.
- need_coordinates
- When set to False, the coordinates can be None, are not type checked and not returned.
- need_numbers
- When set to False, the numbers can be None, are not type checked and not returned.
- need_pseudo_numbers
- When set to False, the pseudo_numbers can be None, are not type checked and not returned.
Returns:
[natom]
+ all arguments that were type checked. The pseudo_numbers argument is converted to a floating point array.
-
horton.utils.
check_type
(name, instance, *Classes)¶ Check type of argument with given name against list of types
Arguments:
- name
- The name of the argument being checked.
- instance
- The object being checked.
- Classes
- A list of allowed types.
-
horton.utils.
check_options
(name, select, *options)¶ Check if a select is in the list of options. If not raise ValueError
Arguments:
- name
- The name of the argument.
- select
- The value of the argument.
- options
- A list of allowed options.
-
horton.utils.
doc_inherit
(base_class)¶ Docstring inheriting method descriptor
doc_inherit decorator
Usage:
class Foo(object): def foo(self): "Frobber" pass class Bar(Foo): @doc_inherit(Foo) def foo(self): pass
Now,
Bar.foo.__doc__ == Bar().foo.__doc__ == Foo.foo.__doc__ == "Frobber"