httk.core package

Submodules

httk.core.basic module

Basic help functions

httk.core.basic.anonymous_symbol_to_int(symb)[source]
httk.core.basic.breath_first_idxs(dim=1, start=None, end=None, perm=True, negative=False)[source]
httk.core.basic.create_tmpdir()[source]
httk.core.basic.destroy_tmpdir(tmpdir)[source]
httk.core.basic.flatten(l)[source]
httk.core.basic.int_to_anonymous_symbol(i)[source]
httk.core.basic.is_sequence(arg)[source]
httk.core.basic.is_unary(e)[source]
httk.core.basic.main()[source]
httk.core.basic.micro_pyawk(ioa, search, results=None, debug=False, debugfunc=None, postdebugfunc=None)[source]

Small awk-mimicking search routine.

‘f’ is stream object to search through. ‘search’ is the “search program”, a list of lists/tuples with 3 elements; i.e., [[regex,test,run],[regex,test,run],...] ‘results’ is a an object that your search program will have access to for storing results.

Here regex is either as a Regex object, or a string that we compile into a Regex. test and run are callable objects.

This function goes through each line in filename, and if regex matches that line and test(results,line)==True (or test == None) we execute run(results,match), where match is the match object from running Regex.match.

The default results is an empty dictionary. Passing a results object let you interact with it in run() and test(). Hence, in many occasions it is thus clever to use results=self.

Returns: results

httk.core.basic.mkdir_p(path)[source]
httk.core.basic.nested_split(s, start, stop)[source]
httk.core.basic.parse_parexpr(string)[source]

Generate parenthesized contents in string as pairs (level, contents).

class httk.core.basic.rewindable_iterator(iterator)[source]

Bases: object

next()[source]
rewind(rewindstr=None)[source]
httk.core.basic.tuple_to_str(t)[source]

httk.core.citation module

Keep track of citation information for different parts of httk, so that this info can be printed out on program exit. Turn on either explicitly by calling httk.config.print_citations_at_exit() from your program, or implicitly for all software using httk by setting ‘auto_print_citations_at_exit=yes’ in httk.cfg

Right now this is mostly a proof of concept code, and was added in response to a concern that co-authors of the software would not get credit. We should extend this to add a facility to make it easier to track and acknowledge citations also of the data being used.

httk.core.citation.add_ext_citation(software, author)[source]
httk.core.citation.add_src_citation(module, author)[source]
httk.core.citation.dont_print_citations_at_exit()[source]
httk.core.citation.print_citations()[source]
httk.core.citation.print_citations_at_exit()[source]

httk.core.code module

class httk.core.code.Code(name, version)[source]

Bases: httk.core.httkobject.HttkObject

Object for keeping track of httk data about a computer software or script

add_ref(ref)[source]
add_refs(refs)[source]
add_tag(tag, val)[source]
add_tags(tags)[source]
classmethod create(name, version, refs=None, tags=None)[source]

Create a Computation object.

get_refs()[source]
get_tag(tag)[source]
get_tags()[source]
class httk.core.code.CodeRef(code, reference)[source]

Bases: httk.core.httkobject.HttkObject

class httk.core.code.CodeTag(structure, tag, value)[source]

Bases: httk.core.httkobject.HttkObject

httk.core.code.main()[source]

httk.core.computation module

class httk.core.computation.Computation(computation_date, description, code, manifest_hash, signatures, keys, relpath, project_counter, added_date=None)[source]

Bases: httk.core.httkobject.HttkObject

Object for keeping track of httk data about a specific computation run

add_project(project)[source]
add_projects(projects)[source]
add_ref(ref)[source]
add_refs(refs)[source]
add_tag(tag, val)[source]
add_tags(tags)[source]
added_date
classmethod create(computation_date, description, code, manifest_hash, signatures, keys, project_counter, relpath, added_date=None)[source]

Create a Computation object.

get_projects()[source]
get_refs()[source]
get_tag(tag)[source]
get_tags()[source]
class httk.core.computation.ComputationProject(computation, project)[source]

Bases: httk.core.httkobject.HttkObject

classmethod create(computation, project)[source]

Create a Computation object.

class httk.core.computation.ComputationRef(computation, reference)[source]

Bases: httk.core.httkobject.HttkObject

class httk.core.computation.ComputationRelated(main_computation, other_computation, relation)[source]

Bases: httk.core.httkobject.HttkObject

Object for keeping track of httk data about a specific computation run

classmethod create(main_computation, other_computation, relation)[source]

Create a Computation object.

class httk.core.computation.ComputationTag(computation, tag, value)[source]

Bases: httk.core.httkobject.HttkObject

class httk.core.computation.Result(computation)[source]

Bases: httk.core.httkobject.HttkObject

Intended as a base class for results tables for computations

classmethod create(computation)[source]

Create a Computation object.

httk.core.computation.main()[source]

httk.core.console module

httk.core.console.cerr(*args)[source]
httk.core.console.cout(*args)[source]

httk.core.crypto module

Provides a few central and very helpful functions for cryptographic hashes, etc.

httk.core.crypto.generate_keys(public_key_path, secret_key_path)[source]

Generates a public and a private key pair and stores them in respective files

httk.core.crypto.get_crypto_signature(message, secret_key_path)[source]
httk.core.crypto.hexhash_ioa(ioa, prepend=None)[source]
httk.core.crypto.hexhash_str(data, prepend=None)[source]
httk.core.crypto.main()[source]
httk.core.crypto.manifest_dir(basedir, manifestfile, excludespath, keydir, sk, pk, debug=False, force=False)[source]
httk.core.crypto.read_keys(keydir)[source]
httk.core.crypto.sha256file(filename)[source]
httk.core.crypto.tuple_to_hexhash(t)[source]
httk.core.crypto.tuple_to_str(t)[source]
httk.core.crypto.verify_crytpo_signature(signature, message, public_key)[source]
httk.core.crypto.verify_crytpo_signature_old(signature, message, public_key_path)[source]

httk.core.ed25519 module

httk.core.ed25519.H(m)[source]
httk.core.ed25519.Hint(m)[source]
httk.core.ed25519.bit(h, i)[source]
httk.core.ed25519.checkvalid(s, m, pk)[source]
httk.core.ed25519.decodeint(s)[source]
httk.core.ed25519.decodepoint(s)[source]
httk.core.ed25519.edwards(P, Q)[source]
httk.core.ed25519.encodeint(y)[source]
httk.core.ed25519.encodepoint(P)[source]
httk.core.ed25519.expmod(b, e, m)[source]
httk.core.ed25519.inv(x)[source]
httk.core.ed25519.isoncurve(P)[source]
httk.core.ed25519.main()[source]
httk.core.ed25519.publickey(sk)[source]
httk.core.ed25519.scalarmult(P, e)[source]
httk.core.ed25519.signature(m, sk, pk)[source]
httk.core.ed25519.xrecover(y)[source]

httk.core.geometry module

Basic geometry helper functions

httk.core.geometry.hull_z(points, zs)[source]

points: a list of points=(x,y,..) with zs= a list of z values; a convex half-hull is constructed over negative z-values

returns data on the following format.:

{
  'hull_points': indices in points list for points that make up the convex hull, 
   'interior_points':indices for points in the interior, 
   'interior_zs':interior_zs
   'zs_on_hull': hull z values for each point (for points on the hull, the value of the hull if this point is excluded)
   'closest_points': list of best linear combination of other points for each point 
   'closest_weights': weights of best linear combination of other points for each point 
}

where hull_points and interior_points are lists of the points on the hull and inside the hull. and

hull_zs is a list of z-values that the hull would have at that point, had this point not been included. interior_zs is a list of z-values that the hull has at the interior points.
httk.core.geometry.is_any_part_of_cube_inside_cell(cell, midpoint, side)[source]

Checks if any part of a cube is inside the cell spanned by the vectors in cell

httk.core.geometry.is_point_inside_cell(cell, point)[source]

Checks if a given triple-vector is inside the cell given by the basis matrix in cell

httk.core.geometry.is_point_inside_tetra(tetra, point)[source]

Checks if a point is inside the tretrahedra spanned by the coordinates in tetra

httk.core.geometry.numpy_quickhull_2d(sample)[source]
httk.core.geometry.simplex_le_solver(a, b, c)[source]

Minimizie func = a[0]*x + a[1]*y + a[2]*z + ... With constraints:

b[0,0]x + b[0,1]y + b[0,2]z + ... <= c[0]
b[1,0]x + b[1,1]y + b[1,2]z + ... <= c[1]
...
x,y,z, ... >= 0

Algorithm adapted from ‘taw9’, http://taw9.hubpages.com/hub/Simplex-Algorithm-in-Python

httk.core.httkobject module

class httk.core.httkobject.HttkObject[source]

Bases: object

get_codependent_data()[source]
hexhash[source]
classmethod new_from(other)[source]
to(newtype)[source]
to_tuple(use_hexhash=False)[source]
classmethod types()[source]
classmethod use(old)[source]
class httk.core.httkobject.HttkPlugin[source]

Bases: object

class httk.core.httkobject.HttkPluginPlaceholder(plugininfo=None)[source]

Bases: object

class httk.core.httkobject.HttkPluginWrapper(plugin=None)[source]

Bases: object

class httk.core.httkobject.HttkTypedProperty(property_type, fget=None, fset=None, fdel=None, doc=None)[source]

Bases: property

httk.core.httkobject.httk_typed_init(t, **kargs)[source]
httk.core.httkobject.httk_typed_init_delayed(t, **kargs)[source]
httk.core.httkobject.httk_typed_property(t)[source]
httk.core.httkobject.httk_typed_property_delayed(t)[source]
httk.core.httkobject.httk_typed_property_resolve(cls, propname)[source]

httk.core.ioadapters module

class httk.core.ioadapters.IoAdapterFileAppender(f, name=None)[source]

Bases: object

Io adapter for access to data as a python file object

close()[source]
classmethod use(other)[source]
class httk.core.ioadapters.IoAdapterFileReader(f, name=None, deletefilename=None, close=False)[source]

Bases: object

Io adapter for easy handling of io.

close()[source]
classmethod use(other)[source]
class httk.core.ioadapters.IoAdapterFileWriter(f, name=None, close=False)[source]

Bases: object

Io adapter for access to data as a python file object

close()[source]
classmethod use(other)[source]
class httk.core.ioadapters.IoAdapterFilename(filename, name=None, deletefilename=None)[source]

Bases: object

Universal io adapter, helps handling the passing of filenames, files, and strings to functions that deal with io

close()[source]
classmethod use(other)[source]
class httk.core.ioadapters.IoAdapterString(string=None, name=None)[source]

Bases: object

Universal io adapter, helps handling the passing of filenames, files, and strings to functions that deal with io

close()[source]
string
classmethod use(other)[source]
class httk.core.ioadapters.IoAdapterStringList(stringlist, name=None)[source]

Bases: object

Universal io adapter, helps handling the passing of filenames, files, and strings to functions that deal with io

classmethod use(other)[source]
httk.core.ioadapters.cleveropen(filename, mode, *args)[source]
httk.core.ioadapters.universal_opener(other)[source]
httk.core.ioadapters.zdecompressor(f, mode, *args)[source]

Read a classic unix compress .Z type file.

httk.core.project module

class httk.core.project.Project(name, description, project_key, keys)[source]

Bases: httk.core.httkobject.HttkObject

add_ref(ref)[source]
add_refs(refs)[source]
add_tag(tag, val)[source]
add_tags(tags)[source]
classmethod create(name, description, project_key, keys)[source]

Create a Project object.

get_refs()[source]
get_tag(tag)[source]
get_tags()[source]
class httk.core.project.ProjectOwner(project, owner_key)[source]

Bases: httk.core.httkobject.HttkObject

classmethod create(project, owner)[source]

Create a Project object.

class httk.core.project.ProjectRef(project, reference)[source]

Bases: httk.core.httkobject.HttkObject

class httk.core.project.ProjectTag(project, tag, value)[source]

Bases: httk.core.httkobject.HttkObject

httk.core.project.main()[source]

httk.core.reference module

class httk.core.reference.Author(last_name, given_names)[source]

Bases: httk.core.httkobject.HttkObject

Object for keeping track of tags for other objects

classmethod create(last_name, given_names)[source]

Create a Author object.

class httk.core.reference.Reference(ref, authors=None, editors=None, journal=None, journal_issue=None, journal_volume=None, page_first=None, page_last=None, title=None, year=None, book_publisher=None, book_publisher_city=None, book_title=None)[source]

Bases: httk.core.httkobject.HttkObject

A reference citation

classmethod create(ref=None, authors=None, editors=None, journal=None, journal_issue=None, journal_volume=None, page_first=None, page_last=None, title=None, year=None, book_publisher=None, book_publisher_city=None, book_title=None)[source]

Create a Reference object.

httk.core.reference.main()[source]

httk.core.signature module

class httk.core.signature.Signature(signature_data, key)[source]

Bases: httk.core.httkobject.HttkObject

classmethod create(signature_data, key)[source]

Create a Computation object.

class httk.core.signature.SignatureKey(keydata, description)[source]

Bases: httk.core.httkobject.HttkObject

classmethod create(keydata, description)[source]

Create a Computation object.

httk.core.signature.main()[source]

httk.core.template module

httk.core.template.apply_template(template, output, envglobals=None, envlocals=None)[source]

Simple Python template engine.

The file ‘template’ is turned into a new file ‘output’ replacing the following: $name -> the value of the variable ‘name’ in the scope provided by locals and globals. $(python statement) -> result of evaluating the python statment. ${some python code} -> text on stdout from running that python code.

Note: it is safe for the code inside the template to load the file it eventually will replace.

httk.core.template.apply_templates(inputpath, outpath, template_suffixes='template', envglobals=None, envlocals=None, mkdir=True)[source]

Apply one or a series of templates throughout directory tree.

template_suffixes: string or list of strings that are the suffixes of templates that are to be applied. name: subdirectory in which to apply the template, defaults to last subrun created, or ‘.’ if no subrun have been created.

Module contents

httk core module

Basic utilities and data definitions that are used throughout the httk code.

A few of the most important components:
fracvector: our general matrix object used to allow exact representation of arrays to allow, e.g., exact matching
of coordinates to existing structures in the database.

ioadapters: our classes for generic handling of IO to files, streams, etc.

structure: our basic definition of a “structure of atoms”