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_list
iterable
ornumpy.ndarray
, required Sequence of vertex degree distribution.
- size_list
iterable
ornumpy.ndarray
, required Sequence of facet size distribution.
- blocked_sets
list
of integer-valuedtuple
objects (optional, defaultNone
) Facets that must be respected for non-inclusion.
- verbose
bool
(optional, defaultFalse
) If
True
, progress information will be shown.- **kwargskeyword arguments
Keyword arguments to be passed to base type constructor.
- degree_list
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)))
-
static
get_distinct_selection
(size, degs, blocked_sets, level_map)[source]¶ Select a candidate facet (of size
size
).- Parameters
- size
int
Number of vertices to make the facet.
- degs
list
ofint
Sequence of wanting/residual vertex degree distribution.
- blocked_sets
list
of integer-valuedtuple
objects (optional, defaultNone
) Facets that must be respected for non-inclusion.
- level_map
dict
- size
- Returns
- facet
tuple
The candidate facet.
- facet
Notes
Note that _ = vtx degree at original view, vid = vtx index at original view, level_map[vid] = vtx index at current view.
-
sample_candidate_facet
(size, valid_trials=None)[source]¶ - Parameters
- size
int
Number of vertices to make the facet.
- valid_trials
- size
-
validate
(facet) -> (<class 'bool'>, <class 'str'>)[source]¶ This function must return True in order for the candidate facet to be considered.
- Parameters
- facet
tuple
The candidate facet.
- facet
- Returns
- token
(bool, str)
A tuple of the form
(ind, reason)
, whereind
is the indicator for whether the candidate facet passes the validations andreason
explains why they fail.
- token
- Raises
- NoMoreBalls
simplicial_test.custom_exceptions.NoMoreBalls
if we depleted this level and wanted to go up (i.e., from lv to lv - 1).
- SimplicialSignal
simplicial_test.custom_exceptions.SimplicialSignal
Signal that indicates a simplicial instance has been found.
- NoMoreBalls
Validators¶
-
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.
validate_issubset_blocked_sets
(candidate_facet, blocked_sets=None)[source]¶
Custom exceptions¶
Utility functions¶
-
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
-
degree_list
: List¶
-
levels_traj
: List¶
-
size_list
: List¶
-
-
simplicial_test.utils.
accel_asc
(n)[source]¶ source: http://jeromekelleher.net/generating-integer-partitions.html
-
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.
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.
simplify_blocked_sets
(bsets)[source]¶ No more inclusive blocked sets.
- Parameters
- bsets
iterable
of integer-valuedtuple
objects Facets that must be respected for non-inclusion, or “blocked sets (of facets)”.
- bsets
- Returns
- simplified_bsets
list
of integer-valuedtuple
objects Simplified blocked sets, of which redundancy is removed.
- simplified_bsets
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,)]