bs-python-utils 0.8.2__tar.gz → 0.8.3__tar.gz
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.
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/PKG-INFO +2 -1
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_logging.py +72 -1
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils.egg-info/PKG-INFO +2 -1
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils.egg-info/requires.txt +1 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/pyproject.toml +2 -1
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/LICENSE +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/README.md +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid1prec13.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid1prec17.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid1prec9.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid2prec13.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid2prec17.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid2prec9.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid3prec13.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid3prec17.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid3prec9.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec13.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec17.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec9.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec13.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec17.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec9.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/Timer.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/__init__.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bivariate_quantiles.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_altair.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_mathstr.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_mem.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_opt.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_plots.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_seaborn.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bs_sparse_gaussian.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bsmplutils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bsnputils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bssputils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bsstats.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/bsutils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/chebyshev.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/distance_covariances.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_altair.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_distance_covariances.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_mem.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_mpl.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_opt.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_seaborn.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_sklearn.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_sparse_gaussian.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/pandas_utils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/sklearn_utils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/streamlit_utils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils.egg-info/SOURCES.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils.egg-info/dependency_links.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils.egg-info/top_level.txt +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/setup.cfg +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bivariate_quantiles.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bs_opt.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bs_sparse_gaussian.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bsnputils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bssputils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bsstats.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_bsutils.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_chebyshev.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_nptri.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_random_draws.py +0 -0
- {bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/tests/test_sklearn_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bs-python-utils
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.3
|
|
4
4
|
Summary: Utilities programs for my Python code
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -24,6 +24,7 @@ Requires-Dist: seaborn>=0.13.2
|
|
|
24
24
|
Requires-Dist: statsmodels>=0.14.5
|
|
25
25
|
Requires-Dist: streamlit>=1.49.1
|
|
26
26
|
Requires-Dist: vega-datasets>=0.9.0
|
|
27
|
+
Requires-Dist: colorama>=0.4.6
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
## bs-python-utils
|
|
@@ -1,14 +1,82 @@
|
|
|
1
1
|
"""Utilities for logging:
|
|
2
2
|
|
|
3
|
+
* `get_logger` creates and returns a logger with colored output
|
|
3
4
|
* `init_logger` initializes and returns a customized logger
|
|
4
|
-
* `log_execution`
|
|
5
|
+
* `log_execution` is a decorator to log entry into and ext from a function.
|
|
5
6
|
"""
|
|
6
7
|
|
|
7
8
|
import functools
|
|
8
9
|
import logging
|
|
10
|
+
import sys
|
|
9
11
|
from pathlib import Path
|
|
10
12
|
from typing import Callable
|
|
11
13
|
|
|
14
|
+
from colorama import Fore, Style, init
|
|
15
|
+
|
|
16
|
+
# Initialize colorama
|
|
17
|
+
init(autoreset=True)
|
|
18
|
+
|
|
19
|
+
COLOR_MAP = {
|
|
20
|
+
"DEBUG": Fore.CYAN,
|
|
21
|
+
"INFO": Fore.GREEN,
|
|
22
|
+
"WARNING": Fore.YELLOW,
|
|
23
|
+
"ERROR": Fore.RED,
|
|
24
|
+
"CRITICAL": Fore.MAGENTA,
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ColorFormatter(logging.Formatter):
|
|
29
|
+
def format(self, record):
|
|
30
|
+
# Mirror the standard Formatter logic so we still get message, asctime, and exception text
|
|
31
|
+
record.message = record.getMessage()
|
|
32
|
+
if self.usesTime():
|
|
33
|
+
record.asctime = self.formatTime(record, self.datefmt)
|
|
34
|
+
|
|
35
|
+
color = COLOR_MAP.get(record.levelname, "")
|
|
36
|
+
level = f"{color}{record.levelname}{Style.RESET_ALL}"
|
|
37
|
+
output = f"{record.asctime} [{record.name}] {level}: {record.message}"
|
|
38
|
+
|
|
39
|
+
if record.exc_info and not record.exc_text:
|
|
40
|
+
record.exc_text = self.formatException(record.exc_info)
|
|
41
|
+
if record.exc_text:
|
|
42
|
+
output = f"{output}\n{record.exc_text}"
|
|
43
|
+
|
|
44
|
+
return output
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_logger(
|
|
48
|
+
name: str,
|
|
49
|
+
level=logging.INFO,
|
|
50
|
+
log_to_file: bool = False,
|
|
51
|
+
) -> logging.Logger:
|
|
52
|
+
"""Create and return a logger with colored output.
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
name: Name of the logger.
|
|
56
|
+
level: Minimum logging level.
|
|
57
|
+
log_to_file: If True, also log to a file named '{name}.log'.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
Configured logger instance.
|
|
61
|
+
|
|
62
|
+
Examples:
|
|
63
|
+
>>> logger = get_logger("my_logger", level=logging.DEBUG, log_to_file=True)
|
|
64
|
+
>>> logger.debug("This is a debug message.")
|
|
65
|
+
"""
|
|
66
|
+
logger = logging.getLogger(name)
|
|
67
|
+
if logger.handlers:
|
|
68
|
+
return logger # Already configured
|
|
69
|
+
logger.setLevel(level)
|
|
70
|
+
formatter = ColorFormatter("%(asctime)s", datefmt="%H:%M:%S")
|
|
71
|
+
stream_handler = logging.StreamHandler(sys.stdout)
|
|
72
|
+
stream_handler.setFormatter(formatter)
|
|
73
|
+
logger.addHandler(stream_handler)
|
|
74
|
+
if log_to_file:
|
|
75
|
+
file_handler = logging.FileHandler(f"{name}.log")
|
|
76
|
+
file_handler.setFormatter(formatter)
|
|
77
|
+
logger.addHandler(file_handler)
|
|
78
|
+
return logger
|
|
79
|
+
|
|
12
80
|
|
|
13
81
|
def init_logger(
|
|
14
82
|
logger_name: str,
|
|
@@ -95,3 +163,6 @@ def log_execution(func: Callable) -> Callable:
|
|
|
95
163
|
return result
|
|
96
164
|
|
|
97
165
|
return wrapper
|
|
166
|
+
|
|
167
|
+
return wrapper
|
|
168
|
+
return wrapper
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bs-python-utils
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.3
|
|
4
4
|
Summary: Utilities programs for my Python code
|
|
5
5
|
Requires-Python: >=3.12
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -24,6 +24,7 @@ Requires-Dist: seaborn>=0.13.2
|
|
|
24
24
|
Requires-Dist: statsmodels>=0.14.5
|
|
25
25
|
Requires-Dist: streamlit>=1.49.1
|
|
26
26
|
Requires-Dist: vega-datasets>=0.9.0
|
|
27
|
+
Requires-Dist: colorama>=0.4.6
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
## bs-python-utils
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "bs-python-utils"
|
|
3
|
-
version = "0.8.
|
|
3
|
+
version = "0.8.3"
|
|
4
4
|
description = "Utilities programs for my Python code"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.12"
|
|
@@ -24,6 +24,7 @@ dependencies = [
|
|
|
24
24
|
"statsmodels>=0.14.5",
|
|
25
25
|
"streamlit>=1.49.1",
|
|
26
26
|
"vega-datasets>=0.9.0",
|
|
27
|
+
"colorama>=0.4.6",
|
|
27
28
|
]
|
|
28
29
|
|
|
29
30
|
[tool.setuptools]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_seaborn.py
RENAMED
|
File without changes
|
{bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_sklearn.py
RENAMED
|
File without changes
|
{bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils/examples/examples_sparse_gaussian.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{bs_python_utils-0.8.2 → bs_python_utils-0.8.3}/bs_python_utils.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|