Core modules

Test class

class simplicial_test.Test.Test(degree_list, size_list, verbose=False, **kwargs)[source]

Bases: simplicial_test.utils.SimplexRegistrar

Base class for SimplicialCheck.

Parameters
degree_listiterable or numpy.ndarray, required

Sequence of vertex degree distribution.

size_listiterable or numpy.ndarray, required

Sequence of facet size distribution.

blocked_setslist of integer-valued tuple objects (optional, default None)

Facets that must be respected for non-inclusion.

verbosebool (optional, default False)

If True, progress information will be shown.

**kwargskeyword arguments

Keyword arguments to be passed to base type constructor.

Examples

>>> from simplicial_test import *
>>> degree_list, size_list = ([2, 1, 3, 2, 1], [3, 2, 2, 2])
>>> st = Test(degree_list, size_list, verbose=False)
>>> is_simplicial, facets = st.is_simplicial()
>>> print(is_simplicial, facets)
(True, ((0, 1, 3), (0, 2), (0, 4), (1, 2)))
fids2facets()[source]

Translate current selected facet ids to facets.

static get_distinct_selection(size, degs, blocked_sets, level_map)[source]

Select a candidate facet (of size size).

Parameters
sizeint

Number of vertices to make the facet.

degslist of int

Sequence of wanting/residual vertex degree distribution.

blocked_setslist of integer-valued tuple objects (optional, default None)

Facets that must be respected for non-inclusion.

level_mapdict
Returns
facettuple

The candidate facet.

Notes

Note that _ = vtx degree at original view, vid = vtx index at original view, level_map[vid] = vtx index at current view.

is_simplicial()[source]
sample_candidate_facet(size, valid_trials=None)[source]
Parameters
sizeint

Number of vertices to make the facet.

valid_trials
validate(facet) -> (<class 'bool'>, <class 'str'>)[source]

This function must return True in order for the candidate facet to be considered.

Parameters
facettuple

The candidate facet.

Returns
token(bool, str)

A tuple of the form (ind, reason), where ind is the indicator for whether the candidate facet passes the validations and reason explains why they fail.

Raises
NoMoreBallssimplicial_test.custom_exceptions.NoMoreBalls

if we depleted this level and wanted to go up (i.e., from lv to lv - 1).

SimplicialSignalsimplicial_test.custom_exceptions.SimplicialSignal

Signal that indicates a simplicial instance has been found.

Validators

simplicial_test.validators.basic_validations_degs_and_sizes(degs, sizes)[source]
simplicial_test.validators.get_nonshielding_vids(n, shielding_facets)[source]
simplicial_test.validators.get_shielding_facets_when_vids_filled(current_facets, blocked_sets, must_be_filled_vids, exempt_vids=None)[source]

TODO: this function can be further simplified, along with the function::validate_reduced_seq The function works when one have “must_be_filled_vids” – it goes by searching already existing facets, And find out the slots that must not be chosen in order to avoid clashes.

Parameters
current_facets
blocked_sets
must_be_filled_vids
exempt_vids
simplicial_test.validators.get_wanting_slots(degs, facet)[source]

Used in the greedy case only.

Parameters
degs: wanting degrees
facet: candidate facet
simplicial_test.validators.preprocess(sorted_d, sorted_s)[source]
simplicial_test.validators.simple_validate(degs, sizes, facet)[source]
simplicial_test.validators.validate_issubset_blocked_sets(candidate_facet, blocked_sets=None)[source]
simplicial_test.validators.validate_nonshielding(curent_sizes, wanting_degs, non_shielding)[source]

Verify that the sum of non-shielding slots not be less than the number of the remaining facets.

Parameters
curent_sizes
wanting_degs
non_shielding
simplicial_test.validators.validate_reduced_seq(wanting_degs, sizes, current_facets, blocked_sets, verbose=False) -> (<class 'bool'>, <class 'tuple'>)[source]

Custom exceptions

exception simplicial_test.custom_exceptions.GoToNextLevel(*args)[source]

Bases: Exception

exception simplicial_test.custom_exceptions.NoMoreBalls(*args)[source]

Bases: Exception

exception simplicial_test.custom_exceptions.SimplicialSignal(*args)[source]

Bases: Exception

Utility functions

class simplicial_test.utils.SimplexRegistrar[source]

Bases: object

register(name) -> (<class 'tuple'>, <class 'int'>)[source]
class simplicial_test.utils.SimplicialDepot(degree_list: List, size_list: List, simplicial: bool = False, facets: tuple = (), prev_d: dict = <factory>, prev_s: dict = <factory>, prev_b: dict = <factory>, mappers: dict = <factory>, exempts: dict = <factory>, collects: dict = <factory>, candidates: dict = <factory>, valid_trials: dict = <factory>, levels_traj: List = <factory>, conv_time: int = 0)[source]

Bases: object

add_to_time_counter(level)[source]
candidates: dict
collects: dict
compute_level_map(level, mapping2shrinked)[source]
conv_time: int = 0
cutoff: int
degree_list: List
exempts: dict
facets: tuple = ()
levels_traj: List
mappers: dict
prev_b: dict
prev_d: dict
prev_s: dict
simplicial: bool = False
size_list: List
valid_trials: dict
simplicial_test.utils.accel_asc(n)[source]

source: http://jeromekelleher.net/generating-integer-partitions.html

simplicial_test.utils.compute_joint_seq(facets) -> (<class 'list'>, <class 'list'>)[source]
simplicial_test.utils.filter_blocked_facets(blocked_facets, exempt_vids)[source]

Supposedly every existing facet will block potential facets in the next level; however, this only applies if it contains exempt_vids because these vertices will be shared by next-level candidates.

Parameters
blocked_facets
exempt_vids
simplicial_test.utils.flatten(nested_list)[source]
simplicial_test.utils.get_indices_of_k_in_blocked_sets(blocked_sets, k)[source]
simplicial_test.utils.get_partition(n=1, sortby='asc')[source]
simplicial_test.utils.get_seq2seq_mapping(degs)[source]
simplicial_test.utils.if_facets_simplicial(facets)bool[source]
simplicial_test.utils.pair_one_by_one(size_list, degree_list) -> (<class 'list'>, <class 'list'>, <class 'int'>)[source]

This function is used to pair up the ones in size/deg lists, since this is the only plausible situation. Note that it is only applied when level=0.

Parameters
size_list
degree_list
simplicial_test.utils.prune_included_facets(bsets)[source]

Alias of simplify_blocked_sets.

simplicial_test.utils.read_hyperedge_list(path, delimiter=',')[source]
simplicial_test.utils.remove_ones(sizes, wanting_degs, choose_from=None)[source]
simplicial_test.utils.simplify_blocked_sets(bsets)[source]

No more inclusive blocked sets.

Parameters
bsetsiterable of integer-valued tuple objects

Facets that must be respected for non-inclusion, or “blocked sets (of facets)”.

Returns
simplified_bsetslist of integer-valued tuple objects

Simplified blocked sets, of which redundancy is removed.

Examples

>>> bsets = ((7, 44, 109, 273), (7, 273), (44, 273), (109, 273), (2,), (4,), (44,), (56,))
>>> simplified_bsets = simplify_blocked_sets(bsets)
>>> print(simplified_bsets)
[(7, 44, 109, 273), (2,), (4,), (56,)]
simplicial_test.utils.sort_callback(facets)[source]
simplicial_test.utils.sort_facets(facets)[source]
simplicial_test.utils.sort_helper(st)list[source]
simplicial_test.utils.transform_facets(facets, mapping, to='l+1')set[source]
simplicial_test.utils.write_simplicial_list(el, path)[source]