Various utility functions and classes.
A collection of classes providing containers. These use the abstract base classes (ABCs) from collections module to satisfy isinstance() criteria for API provision.
Bases: AChemKit.utils.bag.FrozenBag, _abcoll.MutableSet
A Bag is like a set, but can contain duplicates.
Also, a Bag is like a list, but is always ordered.
Bases: _abcoll.Set
A Bag is like a set, but can contain duplicates.
Also, a Bag is like a list, but is always ordered.
Note: objects must be both hashable and sortable. By default, python objects are sorted by id(), but this is not consistent. As there is no easy way to test this, if you get wierd results this may be the cause.
Bases: AChemKit.utils.bag.OrderedFrozenBag, _abcoll.MutableSet
Like a Bag, but iterating will keep the order things were put in. New items are added to the end of the OrderedBag - if you need anything else you can convert it to a tuple or list and make a new bag.
Comparisons are still as for a Bag so OrderedBag([1,2,1]) == OrderedBag([2,1,1]) will return True.
Bases: _abcoll.Set
Like a FrozenBag, but iterating will keep the order things were put in.
Comparisons are still as for a FrozenBag so OrderedFrozenBag([1,2,1]) == OrderedFrozenBag([2,1,1]) will return True.
Bases: object
This is the test harness for AChemKit.utils.bag.
Bases: AChemKit.utils.bag_test.TestFrozenBag
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
alias of Bag
Bases: unittest.TestCase
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
alias of FrozenBag
Bases: AChemKit.utils.bag_test.TestOrderedFrozenBag, AChemKit.utils.bag_test.TestBag
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
alias of OrderedBag
Bases: AChemKit.utils.bag_test.TestFrozenBag
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
alias of OrderedFrozenBag
A library to manage .dot files
There are existing python libraries for this, but they do not always do it correctly (e.g. PyDot does not respect order within a .dot file).
Bases: UserDict.DictMixin
Repsents a graphviz .dot file (also known as .gv).
Uses a dictionary-like interface via the :class:~`UserDict.DictMixin` class.
To produce .dot output, cast to string e.g. str(mysimpledot)
Contains three types of graph objects:
These can be set and accessed by standard slice notation (e.g. dot[nodename] = {}).
Node names and subgraph names are unique but multiple parallel edges are permitted. However, slice notation (e.g. dot[(from, to)]) cannot cope with this. Therefore, when there are multiple parallel edges, accessing any of them returns a tuple of all their attributes as dictionaries. To create multiple parallel edges you must use the add() method
Names of nodes and subgraphs, attribute keys, and attribute values should all be graphviz compatible. Some attempt to wrap string attribute values in quotes will be made so that the use of plain python strings is accepted by graphviz.
Very little checking and enforcement is performed. This means that you can use them in ways not originally intended; for example, you can se attributes that no graphviz programme will recognize. But, it also means you can break it by doing odd things to them.
Guaranteed to add the passed key/value to self, even if it is a duplicate.
Returns a tuple of all things matching that key.
Designed for multiple edges, but will also work with single edges, nodes, or subgraphs. This provides a unified interface.
Return a tuple of the keys.
Calls the specified drawing program to turn this into an image.
Use args to pass extra arguments, particularly -o to specify an output filename.
Follows the same format as subprocess calls.
Various small functions that can get lumped together into this module.
Samples a provided distribution at random.
Distribution can be a single number (int or float), always returns the same value
Distribution can be a sequence (list or tuple) which will be uniformly sampled from Duplicates can be used to adjust frequencies.
Distribution can be a mapping (dict) where the keys are things to be returned and values are the relative weightings.
Given some sequences — strings, tuples, lists, etc — return the longest subsequence common to all sequences.
Returns the amount of memory free, in megabytes
This is the test harness for AChemKit.utils.utils.
Bases: unittest.TestCase
Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.