MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _check_within_range

Function _check_within_range

tensorflow/contrib/graph_editor/subgraph.py:52–70  ·  view source on GitHub ↗

Check is the mapping is valid. Args: mapping: an iterable of integer. n: define the input domain as [0, n-1]. Note that the mapping can be under-complete, that is, it can only contain a subset of the integers on [0, n-1]. repetition: if True repetition are allowed (the fun

(mapping, n, repetition)

Source from the content-addressed store, hash-verified

50
51
52def _check_within_range(mapping, n, repetition):
53 """Check is the mapping is valid.
54
55 Args:
56 mapping: an iterable of integer.
57 n: define the input domain as [0, n-1]. Note that the mapping can be
58 under-complete, that is, it can only contain a subset of the integers on
59 [0, n-1].
60 repetition: if True repetition are allowed (the function is surjective)
61 otherwise repetition are not allowed (the function is injective).
62 Raises:
63 ValueError: if the mapping is out of range ot if repetition is False and
64 the mapping has some repetition.
65 """
66 for i in mapping:
67 if not 0 <= i < n:
68 raise ValueError("Out of [0, {}[ range: {}".format(n, i))
69 if not repetition and len(set(mapping)) != len(mapping):
70 raise ValueError("Found repetition in mapping: {}".format(mapping))
71
72
73class SubGraphView(object):

Callers 2

_remap_inputsMethod · 0.85
_remap_outputsMethod · 0.85

Calls 1

formatMethod · 0.45

Tested by

no test coverage detected