-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update requirements.in * Fix some unittests * Fix tests/gordo/server unit-tests * Update black * Fix issue with packaging dependencie * Fix tests/gordo/serializer unit-tests * black reformating * Fix docstring unit-tests * Remove debug lines from unit-test * verbose=0 for predict * Fix mypy complains * black reformating * create_instance function * Docstring Examples * Using create_instance in from_defintion module * Black reformating * Fix mypy issue * Fix test_client.py unit-tests * Update full_requirements.txt * tensorflow>=2.11,<2.13 * Remove one debug assert message
- Loading branch information
Showing
16 changed files
with
314 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from typing import get_origin, get_args, Union | ||
|
||
try: | ||
from types import UnionType # type: ignore | ||
except ImportError: | ||
UnionType = None | ||
|
||
|
||
def _is_exact_tuple_type(tp) -> bool: | ||
if tp is tuple: | ||
return True | ||
origin = get_origin(tp) | ||
return origin is tuple | ||
|
||
|
||
def is_tuple_type(tp) -> bool: | ||
""" | ||
Check if this type is a tuple. | ||
Examples | ||
-------- | ||
>>> from typing import Optional, Tuple | ||
>>> is_tuple_type(tuple) | ||
True | ||
>>> is_tuple_type(Optional[tuple[int, int]]) | ||
True | ||
>>> is_tuple_type(Tuple[str, str]) | ||
True | ||
>>> is_tuple_type(list[str]) | ||
False | ||
Parameters | ||
---------- | ||
tp | ||
Type for check. | ||
Returns | ||
------- | ||
""" | ||
if _is_exact_tuple_type(tp): | ||
return True | ||
origin = get_origin(tp) | ||
if origin is Union or (UnionType is not None and origin is UnionType): | ||
args = get_args(tp) | ||
for arg in args: | ||
if not _is_exact_tuple_type(arg) and not (arg is type(None)): | ||
return False | ||
return True | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.