Orderlygen Documentation

This page contains the Orderlygen Package documentation.

The icdfa Module

Module to define ICDFA functions and possibly, configure use for Cython.

Question: Why make a bunch of static methods instead of keeping the
layout flat at the module level?
Response: This is really just to keep things clean for autocomplete. This
module is going to do some magic to transparently provide Cythonified functions, when present. We’d like to hide this from the users.
cmpy.orderlygen.icdfa.ICDFA

alias of ICDFA__cython

cmpy.orderlygen.icdfa.get_ICDFA(pure=False)

Returns the ICDFA class.

Parameters:

pure : bool

If True, then a pure Python ICDFA generator is returned. If False, then the ICDFA class that is returned will be optimized if Cython extensions were installed. Otherwise, it will be a pure python ICDFA class.

The pyicdfa Module

Pure Python ICDFA functions.

cmpy.orderlygen.pyicdfa.B(n, k, t=1)
Return the number of ICDFAs for the given number of nodes and
alphabet size.
Parameters:

t : int

If 1, then the number is for incomplete ICDFAs. If 0, then the number is for complete ICDFAs.

n : int

The number of nodes in the ICDFAs

k : int

The alphabet size for the ICDFAs

Returns:

num : int

The number of complete (t=0) or incomplete (t=1) ICDFAs over n states

with k symbols.

class cmpy.orderlygen.pyicdfa.N_matrix(n, k, t=1)

Bases: object

Methods

values_using_table(m, j)
values_using_table(m, j)
cmpy.orderlygen.pyicdfa.icdfa_to_int(delta, n, k, t=1, validate=False)

Returns the integer corresponding to the ICDFA transition function.

Parameters:

delta : list

The transition function for the ICDFA.

n : int

The number of nodes in the ICDFA.

k : int

The number of symbols in the alphabet of the ICDFA.

t : int

If 1, then the id represents an incomplete ICDFA. If 0, then the id represents a complete ICDFA.

Returns:

integer : int

An integer corresponding to the ICDFA transition function.

cmpy.orderlygen.pyicdfa.icdfa_to_machine(delta, n, k, create_using=None, validate=False)

Returns a machine corresponding to the ICDFA transition function.

Parameters:

delta : list

A list of ints of length n*k. The ICDFA transition function.

n : int

The number of nodes in the ICDFA.

k : int

The number of symbols in the alphabet of the ICDFA.

create_using : callable | None

The callable which returns an instance used to populate the machine. If None, then a RecurrentEpsilonMachine instance is returned.

validate : boolean | False

If True, then the given ICDFA is checked to be valid. If False, no validation is performed.

Returns:

machine : machine

The machine corresponding to the ICDFA transition function.

cmpy.orderlygen.pyicdfa.int_to_icdfa(integer, n, k, t=1)

Returns the transition function for the ICDFA with id integer.

Parameters:

integer : int

The integer corresponding to the ICDFA.

n : int

The number of nodes in the ICDFA.

k : int

The number of symbols in the alphabet of the ICDFA.

t : int

If 1, then the id represents an incomplete ICDFA. If 0, then the id represents a complete ICDFA.

Returns:

delta : list, (n*k )

An integer array of length n*k, representing the transition function.

cmpy.orderlygen.pyicdfa.int_to_machine(integer, n, k, t=1, create_using=None)

Returns a machine corresponding to the ICDFA with id integer.

Parameters:

integer : int

The integer corresponding to the ICDFA.

n : int

The number of nodes in the ICDFA.

k : int

The number of symbols in the alphabet of the ICDFA.

t : int

If 1, then the id represents an incomplete ICDFA. If 0, then the id represents a complete ICDFA.

create_using : callable | None

The callable which returns an instance used to populate the machine. If None, then a RecurrentEpsilonMachine instance is returned.

Returns:

machine : machine

The machine corresponding to the ICDFA with id integer.

cmpy.orderlygen.pyicdfa.is_valid_flag(f, n, k, t=1)
Checks that the given flag has a valid structure for the specified
number of nodes and alphabet size.
Parameters:

f : list

The flag for the ICDFA.

n : int

The number of nodes in the ICDFA.

k : int

The alphabet size for the ICDFA.

t : int | 1

If t=1, the ICDFA is incomplete. If t=0, the ICDFA is complete.

Returns:

bool :

True if the flag is valid. False if the flag is invalid.

cmpy.orderlygen.pyicdfa.is_valid_string(delta, n, k, t=1)
Checks that the given ICDFA string is valid for the specified number of
states and alphabet size.
Parameters:

delta : list

The string (or transition function) for the ICDFA.

n : int

The number of nodes in the ICDFA.

k : int

The alphabet size for the ICDFA.

t : int | 1

If t=1, the ICDFA is incomplete. If t=0, the ICDFA is complete.

Returns:

bool :

True if the string is valid. False if the string is invalid.

cmpy.orderlygen.pyicdfa.machine_to_icdfa(machine, start, alphabet=None, test_unifilar=True, mapping=False)

Returns the transition function correpsonding to machine.

Parameters:

machine : machine

The machine to be represented as an ICDFA.

start : node

A node in the machine from which the ICDFA string representation is constructed. The machine must be accessible from this node.

Returns:

delta : list

The transition function corresponding to the ICDFA.

nodeIndices : dict

The mapping from nodes to indices. This is returned only if mapping is True.

cmpy.orderlygen.pyicdfa.machine_to_icdfas_iter(machine, alphabet=None, test_unifilar=True, mapping=False)

Iterator over possible ICDFAs correpsonding to machine.

Parameters:

machine : machine

The machine to be represented as an ICDFA.

cmpy.orderlygen.pyicdfa.machine_to_int(machine, start, t=1, alphabet=None, test_unifilar=True)

Returns the integer correpsonding to the ICDFA represented by machine.

Parameters:

machine : machine

The ICDFA.

start : node

A node in the machine from which the ICDFA string representation is constructed. The machine must be accessible from this node.

Returns:

integer : int

The integer corresponding to the ICDFA.

cmpy.orderlygen.pyicdfa.machine_to_ints_iter(machine, t=1, alphabet=None, test_unifilar=True)

Iterator over possible ICDFAs correpsonding to machine.

Parameters:

machine : machine

The machine to be represented as an ICDFA.

cmpy.orderlygen.pyicdfa.n_f(n, k, f, t=1)
Part of the icdfa_to_int() algorithm. Given a flag, determine the integer
in the enumeration sequence the first ICDFA with the that flag.
Parameters:

n : int

The number of nodes in the ICDFA.

k : int

The alphabet size for the ICDFA.

f : list

The flag for the ICDFA.

t : int | 1

If t=1, the ICDFA is incomplete. If t=0, the ICDFA is complete.

Returns:

nf : int

The integer for the first ICDFA that has the given flag.

cmpy.orderlygen.pyicdfa.n_r(n, k, f, delta, t=1)
Part of the icdfa_to_int() algorithm. Given the flag and string for an
ICDFA, determine the integer for where the given ICDFA occurs relative to all ICDFAs with the given flag.
Parameters:

n : int

The number of nodes in the ICDFA.

k : int

The alphabet size for the ICDFA.

f : list

The flag for the ICDFA.

delta : list

The string (or transition function) for the ICDFA.

t : int | 1

If t=1, the ICDFA is incomplete. If t=0, the ICDFA is complete.

Returns:

nr : int

The integer for where the given ICDFA occurs among all ICDFAs with the

given flag. (The first ICDFA with this flag is 0.)

cmpy.orderlygen.pyicdfa.string_to_flag(delta, n, k, t=1)

Return the flag that corresponds to the DFA string s.

Parameters:

delta : list

The string (or transition function) for the ICDFA.

n : int

The number of nodes in the ICDFA.

k : int

The number of symbols in the alphabet of the ICDFA.

t : int

If 1, then the given flag is for an incomplete ICDFA. If 0, then the given flag is for a complete ICDFA.