tensorneko-util 0.3.20__py3-none-any.whl → 0.3.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ from typing import overload, Union
2
+ from pathlib import Path
3
+
4
+ from .audio_data import AudioData
5
+ from ...backend.audio_lib import AudioLib
6
+ from ...util.type import T_ARRAY
7
+
8
+
9
+ class AudioWriter:
10
+
11
+ @classmethod
12
+ @overload
13
+ def to(cls, path: Union[str, Path], audio: AudioData, channel_first: bool = True, backend: AudioLib = None
14
+ ) -> None: ...
15
+
16
+ @classmethod
17
+ @overload
18
+ def to(cls, path: Union[str, Path], audio: T_ARRAY, sample_rate: int = 16000, channel_first: bool = True,
19
+ backend: AudioLib = None
20
+ ): ...
21
+
22
+ @overload
23
+ def __new__(cls, path: Union[str, Path], audio: AudioData, channel_first: bool = True, backend: AudioLib = None
24
+ ) -> None: ...
25
+
26
+ @overload
27
+ def __new__(cls, path: Union[str, Path], audio: T_ARRAY, sample_rate: int = 16000, channel_first: bool = True,
28
+ backend: AudioLib = None
29
+ ): ...
@@ -0,0 +1,38 @@
1
+ from typing import Optional, overload, Union
2
+ from pathlib import Path
3
+
4
+ from numpy import ndarray
5
+
6
+ from .video_data import VideoData
7
+ from ...backend.visual_lib import VisualLib
8
+
9
+
10
+ class VideoReader:
11
+
12
+ @classmethod
13
+ def of(cls, path: Union[str, Path], channel_first: bool = True, backend: Optional[VisualLib] = None) -> VideoData:
14
+ ...
15
+
16
+ @classmethod
17
+ def with_indexes(cls, path: Union[str, Path], indexes: ndarray,
18
+ channel_first: bool = True, backend: Optional[VisualLib] = None
19
+ ) -> VideoData:
20
+ ...
21
+
22
+ @classmethod
23
+ @overload
24
+ def with_range(cls, path: Union[str, Path], start: int, end: int, step: int, channel_first: bool = True,
25
+ backend: Optional[VisualLib] = None
26
+ ) -> VideoData:
27
+ ...
28
+
29
+ @classmethod
30
+ @overload
31
+ def with_range(cls, path: Union[str, Path], end: int, channel_first: bool = True,
32
+ backend: Optional[VisualLib] = None
33
+ ) -> VideoData:
34
+ ...
35
+
36
+ def __new__(cls, path: Union[str, Path], channel_first: bool = True, backend: Optional[VisualLib] = None
37
+ ) -> VideoData:
38
+ ...
@@ -0,0 +1,33 @@
1
+ from typing import overload, Optional, Union
2
+ from pathlib import Path
3
+
4
+ from .video_data import VideoData
5
+ from ...backend.visual_lib import VisualLib
6
+ from ...util.type import T_ARRAY
7
+
8
+
9
+ class VideoWriter:
10
+
11
+ @classmethod
12
+ @overload
13
+ def to(cls, path: Union[str, Path], video: VideoData, audio_codec: str = None, channel_first: bool = False,
14
+ backend: VisualLib = None
15
+ ) -> None: ...
16
+
17
+ @classmethod
18
+ @overload
19
+ def to(cls, path: Union[str, Path], video: T_ARRAY, video_fps: float, audio: T_ARRAY = None,
20
+ audio_fps: Optional[int] = None, audio_codec: str = None, channel_first: bool = False,
21
+ backend: VisualLib = None
22
+ ) -> None: ...
23
+
24
+ @overload
25
+ def __new__(cls, path: Union[str, Path], video: VideoData, audio_codec: str = None, channel_first: bool = False,
26
+ backend: VisualLib = None
27
+ ) -> None: ...
28
+
29
+ @overload
30
+ def __new__(cls, path: Union[str, Path], video: T_ARRAY, video_fps: float, audio: T_ARRAY = None,
31
+ audio_fps: Optional[int] = None, audio_codec: str = None, channel_first: bool = False,
32
+ backend: VisualLib = None
33
+ ) -> None: ...
@@ -1,3 +1,9 @@
1
- from .gotify import push_gotify
1
+ from . import gotify
2
2
 
3
- __all__ = ["push_gotify"]
3
+ __all__ = ["gotify"]
4
+
5
+ try:
6
+ from . import postgres
7
+ __all__.append("postgres")
8
+ except ImportError:
9
+ pass
@@ -6,7 +6,7 @@ from typing import Optional
6
6
  from urllib.error import HTTPError
7
7
 
8
8
 
9
- def push_gotify(message: str, url: Optional[str] = None, token: Optional[str] = None, title: Optional[str] = None,
9
+ def push(message: str, url: Optional[str] = None, token: Optional[str] = None, title: Optional[str] = None,
10
10
  priority: int = 0
11
11
  ):
12
12
  """
@@ -21,7 +21,7 @@ def push_gotify(message: str, url: Optional[str] = None, token: Optional[str] =
21
21
 
22
22
  Examples::
23
23
 
24
- push_gotify("This is a test message", "<URL>", "<APP_TOKEN>")
24
+ push("This is a test message", "<URL>", "<APP_TOKEN>")
25
25
  # then the message will be sent to the Gotify server.
26
26
  # title = "<HOST_NAME>", message = "This is a test message", priority = 0
27
27
 
@@ -0,0 +1,66 @@
1
+ import os
2
+ from typing import Any, List, Optional, Tuple
3
+
4
+ import psycopg
5
+
6
+
7
+ def execute(sql: str, db_url: Optional[str] = None) -> Optional[List[Tuple[Any, ...]]]:
8
+ """
9
+ Execute a PostgreSQL database SQL query.
10
+
11
+ Args:
12
+ sql (``str``): The SQL query to be executed.
13
+ db_url (``str``, optional): The URL of the PostgreSQL database. The default value is environment variable DB_URL.
14
+
15
+ Returns:
16
+ ``list[tuple] | None``: The result of the query. If the query is not a SELECT query, then it will return None.
17
+
18
+ Examples::
19
+
20
+ result = execute("SELECT * FROM table_name", "postgresql://user:password@localhost:5432/db_name")
21
+ # then the result will be a list of tuples.
22
+
23
+ execute("INSERT INTO table_name (column1, column2) VALUES (value1, value2)", "postgresql://user:password@localhost:5432/db_name")
24
+ # then the execute will be executed and committed.
25
+ """
26
+ db_url = db_url or os.environ.get("DB_URL")
27
+
28
+ with psycopg.Connection.connect(db_url) as conn:
29
+ with conn.cursor() as cur:
30
+ cur.execute(sql)
31
+ conn.commit()
32
+ if cur.description:
33
+ return cur.fetchall()
34
+ return None
35
+
36
+
37
+ async def execute_async(sql: str, db_url: Optional[str] = None) -> Optional[List[Tuple[Any, ...]]]:
38
+ """
39
+ Execute a PostgreSQL database SQL query with async.
40
+
41
+ Args:
42
+ sql (``str``): The SQL query to be executed.
43
+ db_url (``str``, optional): The URL of the PostgreSQL database. The default value is environment variable DB_URL.
44
+
45
+ Returns:
46
+ ``list[tuple] | None``: The result of the query. If the query is not a SELECT query, then it will return None.
47
+
48
+ Examples::
49
+
50
+ result = await execute_async("SELECT * FROM table_name", "postgresql://user:password@localhost:5432/db_name")
51
+ # then the result will be a list of tuples.
52
+
53
+ await execute_async("INSERT INTO table_name (column1, column2) VALUES (value1, value2)")
54
+ # then the execute will be executed
55
+ """
56
+ db_url = db_url or os.environ.get("DB_URL")
57
+
58
+ if db_url is None:
59
+ raise ValueError("DB_URL environment variable is not set.")
60
+
61
+ async with await psycopg.AsyncConnection.connect(db_url, autocommit=True) as conn:
62
+ async with conn.cursor() as cur:
63
+ await cur.execute(sql)
64
+ if cur.description:
65
+ return await cur.fetchall()
66
+ return None
@@ -0,0 +1,15 @@
1
+ from typing import overload, Union
2
+
3
+ from numpy import ndarray
4
+
5
+
6
+ @overload
7
+ def crop_with_padding(image: ndarray, x1: int, x2: int, y1: int, y2: int, pad_value: Union[int, float] = 0.,
8
+ batch: bool = False
9
+ ) -> ndarray: ...
10
+
11
+
12
+ @overload
13
+ def crop_with_padding(image: ndarray, x1: ndarray, x2: ndarray, y1: ndarray, y2: ndarray,
14
+ pad_value: Union[int, float] = 0., batch: bool = False
15
+ ) -> ndarray: ...
@@ -0,0 +1,23 @@
1
+ from typing import overload, List
2
+
3
+ from numpy import ndarray
4
+
5
+
6
+ @overload
7
+ def sparse2binary(x: ndarray, length: int = None) -> ndarray:
8
+ ...
9
+
10
+
11
+ @overload
12
+ def sparse2binary(x: List[int], length: int = None) -> List[int]:
13
+ ...
14
+
15
+
16
+ @overload
17
+ def binary2sparse(x: ndarray) -> ndarray:
18
+ ...
19
+
20
+
21
+ @overload
22
+ def binary2sparse(x: List[int]) -> List[int]:
23
+ ...
@@ -0,0 +1,38 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Generic, overload
4
+
5
+ from .type import P
6
+
7
+
8
+ class Ref(Generic[P]):
9
+ value: P
10
+ @overload
11
+ def __new__(cls, value: str) -> StringRef: ...
12
+ @overload
13
+ def __new__(cls, value: int) -> IntRef: ...
14
+ @overload
15
+ def __new__(cls, value: float) -> FloatRef: ...
16
+ @overload
17
+ def __new__(cls, value: bool) -> BoolRef: ...
18
+
19
+ class StringRef(Ref[str]):
20
+ def __str__(self) -> str: ...
21
+
22
+ class IntRef(Ref[int]):
23
+ def __int__(self) -> int: ...
24
+
25
+ class FloatRef(Ref[float]):
26
+ def __float__(self) -> float: ...
27
+
28
+ class BoolRef(Ref[bool]):
29
+ def __bool__(self) -> bool: ...
30
+
31
+ @overload
32
+ def ref(value: str) -> StringRef: ...
33
+ @overload
34
+ def ref(value: int) -> IntRef: ...
35
+ @overload
36
+ def ref(value: float) -> FloatRef: ...
37
+ @overload
38
+ def ref(value: bool) -> BoolRef: ...
@@ -1 +1 @@
1
- 0.3.20
1
+ 0.3.22