Preconditions¶
- graspologic.preconditions.check_argument_types(value, required_types, message)[source]¶
Raises a TypeError if the provided
valueis not one of therequired_types- Parameters:
- valueAny
The argument to test for valid type
- required_typesUnion[type, Tuple[type, ...]]
A type or a n-ary tuple of types to test for validity
- messagestr
The message to use as the body of the TypeError
- Raises:
- TypeError if the type is not one of the
required_types
- TypeError if the type is not one of the
- Parameters:
- Return type:
None
- graspologic.preconditions.check_optional_argument_types(value, required_types, message)[source]¶
Raises a TypeError if the provided
valueis not one of therequired_types, unless it is None. A None value is treated as a valid type.- Parameters:
- valueAny
The argument to test for valid type
- required_typesUnion[type, Tuple[type, ...]]
A type or a n-ary tuple of types to test for validity
- messagestr
The message to use as the body of the TypeError
- Raises:
- TypeError if the type is not one of the
required_types, unless it is None
- TypeError if the type is not one of the
- Parameters:
- Return type:
None
- graspologic.preconditions.check_argument(check, message)[source]¶
Raises a ValueError if the provided check is false
>>> from graspologic import preconditions >>> x = 5 >>> preconditions.check_argument(x < 5, "x must be less than 5") Traceback (most recent call last): ... ValueError: x must be less than 5
- Parameters:
- valueAny
The argument to test for valid type
- required_typesUnion[type, Tuple[type, ...]]
A type or a n-ary tuple of types to test for validity
- messagestr
The message to use as the body of the TypeError
- Raises:
- TypeError if the type is not one of the
required_types
- TypeError if the type is not one of the
- Parameters:
- Return type:
None
- graspologic.preconditions.is_real_weighted(graph, weight_attribute='weight')[source]¶
Checks every edge in
graphto ascertain whether it has:a
weight_attributekey in the data dictionary for the edgeif that
weight_attributevalue is a subclass of numbers.Real
If any edge fails this test, it returns
False, elseTrue- Parameters:
- graphUnion[nx.Graph, nx.DiGraph]
The networkx graph to test
- weight_attributestr (default="weight")
The edge dictionary data attribute that holds the weight. Default is
weight.
- Returns:
- bool
Trueif every edge has a numericweight_attributeweight,Falseif any edge fails this test
- Parameters:
- Return type: