bs-python-utils 0.9.3__tar.gz → 1.0.1__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.
Files changed (91) hide show
  1. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/PKG-INFO +19 -7
  2. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/README.md +16 -4
  3. bs_python_utils-1.0.1/bs_python_utils/Timer.py +1 -0
  4. bs_python_utils-1.0.1/bs_python_utils/bivariate_quantiles.py +1 -0
  5. bs_python_utils-1.0.1/bs_python_utils/bs_altair.py +1 -0
  6. bs_python_utils-1.0.1/bs_python_utils/bs_logging.py +1 -0
  7. bs_python_utils-1.0.1/bs_python_utils/bs_mathstr.py +1 -0
  8. bs_python_utils-1.0.1/bs_python_utils/bs_mem.py +1 -0
  9. bs_python_utils-1.0.1/bs_python_utils/bs_opt.py +1 -0
  10. bs_python_utils-1.0.1/bs_python_utils/bs_plots.py +1 -0
  11. bs_python_utils-1.0.1/bs_python_utils/bs_seaborn.py +1 -0
  12. bs_python_utils-1.0.1/bs_python_utils/bs_sparse_gaussian.py +1 -0
  13. bs_python_utils-1.0.1/bs_python_utils/bsmplutils.py +1 -0
  14. bs_python_utils-1.0.1/bs_python_utils/bsnputils.py +1 -0
  15. bs_python_utils-1.0.1/bs_python_utils/bssputils.py +1 -0
  16. bs_python_utils-1.0.1/bs_python_utils/bsstats.py +1 -0
  17. bs_python_utils-1.0.1/bs_python_utils/bsutils.py +1 -0
  18. bs_python_utils-1.0.1/bs_python_utils/chebyshev.py +1 -0
  19. bs_python_utils-1.0.1/bs_python_utils/core/__init__.py +1 -0
  20. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/core}/bs_mem.py +1 -1
  21. bs_python_utils-1.0.1/bs_python_utils/data_anal/__init__.py +1 -0
  22. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/data_anal}/pandas_utils.py +2 -2
  23. bs_python_utils-1.0.1/bs_python_utils/distance_covariances.py +1 -0
  24. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_altair.py +1 -1
  25. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_distance_covariances.py +5 -1
  26. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_mem.py +1 -1
  27. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_mpl.py +1 -1
  28. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_opt.py +3 -3
  29. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_seaborn.py +5 -1
  30. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_sklearn.py +1 -1
  31. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/examples/examples_sparse_gaussian.py +2 -1
  32. bs_python_utils-1.0.1/bs_python_utils/numerical/__init__.py +1 -0
  33. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/numerical}/bs_sparse_gaussian.py +2 -2
  34. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/numerical}/bsnputils.py +1 -1
  35. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/numerical}/bssputils.py +2 -2
  36. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/numerical}/chebyshev.py +2 -2
  37. bs_python_utils-1.0.1/bs_python_utils/opt/__init__.py +1 -0
  38. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/opt}/bs_opt.py +3 -3
  39. bs_python_utils-1.0.1/bs_python_utils/pandas_utils.py +1 -0
  40. bs_python_utils-1.0.1/bs_python_utils/sklearn_utils.py +1 -0
  41. bs_python_utils-1.0.1/bs_python_utils/stats/__init__.py +1 -0
  42. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/stats}/bivariate_quantiles.py +88 -43
  43. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/stats}/bsstats.py +7 -3
  44. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/stats}/distance_covariances.py +2 -2
  45. bs_python_utils-1.0.1/bs_python_utils/streamlit_utils.py +1 -0
  46. bs_python_utils-1.0.1/bs_python_utils/viz/__init__.py +1 -0
  47. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/viz}/bs_altair.py +2 -2
  48. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/viz}/bsmplutils.py +1 -1
  49. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils.egg-info/PKG-INFO +19 -7
  50. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils.egg-info/SOURCES.txt +26 -0
  51. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils.egg-info/requires.txt +2 -2
  52. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/pyproject.toml +6 -5
  53. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bivariate_quantiles.py +3 -3
  54. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bs_opt.py +1 -1
  55. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bs_sparse_gaussian.py +1 -1
  56. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bsnputils.py +2 -2
  57. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bssputils.py +1 -1
  58. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bsstats.py +1 -1
  59. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_bsutils.py +1 -1
  60. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_chebyshev.py +3 -3
  61. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_nptri.py +1 -1
  62. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_random_draws.py +3 -3
  63. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/tests/test_sklearn_utils.py +4 -3
  64. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/LICENSE +0 -0
  65. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid1prec13.txt +0 -0
  66. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid1prec17.txt +0 -0
  67. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid1prec9.txt +0 -0
  68. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid2prec13.txt +0 -0
  69. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid2prec17.txt +0 -0
  70. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid2prec9.txt +0 -0
  71. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid3prec13.txt +0 -0
  72. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid3prec17.txt +0 -0
  73. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid3prec9.txt +0 -0
  74. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec13.txt +0 -0
  75. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec17.txt +0 -0
  76. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec9.txt +0 -0
  77. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec13.txt +0 -0
  78. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec17.txt +0 -0
  79. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec9.txt +0 -0
  80. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils/__init__.py +0 -0
  81. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/core}/Timer.py +0 -0
  82. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/core}/bs_logging.py +0 -0
  83. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/core}/bs_mathstr.py +0 -0
  84. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/core}/bsutils.py +0 -0
  85. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/data_anal}/sklearn_utils.py +0 -0
  86. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/viz}/bs_plots.py +0 -0
  87. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/viz}/bs_seaborn.py +0 -0
  88. {bs_python_utils-0.9.3/bs_python_utils → bs_python_utils-1.0.1/bs_python_utils/viz}/streamlit_utils.py +0 -0
  89. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils.egg-info/dependency_links.txt +0 -0
  90. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/bs_python_utils.egg-info/top_level.txt +0 -0
  91. {bs_python_utils-0.9.3 → bs_python_utils-1.0.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bs-python-utils
3
- Version: 0.9.3
3
+ Version: 1.0.1
4
4
  Summary: Utilities programs for my Python code
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -16,7 +16,7 @@ Requires-Dist: numpy>=2.3.3
16
16
  Requires-Dist: pandas>=2.3.2
17
17
  Requires-Dist: pre-commit>=4.3.0
18
18
  Requires-Dist: pytest>=8.4.2
19
- Requires-Dist: mypy
19
+ Requires-Dist: mypy>=1.18
20
20
  Requires-Dist: ruff>=0.14.0
21
21
  Requires-Dist: scikit-learn>=1.7.2
22
22
  Requires-Dist: scipy>=1.16.2
@@ -25,16 +25,22 @@ Requires-Dist: statsmodels>=0.14.5
25
25
  Requires-Dist: streamlit>=1.49.1
26
26
  Requires-Dist: vega-datasets>=0.9.0
27
27
  Requires-Dist: colorama>=0.4.6
28
- Requires-Dist: pyarrow>=21.0.0
28
+ Requires-Dist: pyarrow>=23.0.0
29
29
  Dynamic: license-file
30
30
 
31
31
  ## bs-python-utils
32
32
 
33
+ [![PyPI version](https://img.shields.io/pypi/v/bs-python-utils)](https://pypi.org/project/bs-python-utils/)
34
+ <!--
35
+ [![Release](https://img.shields.io/github/v/release/bsalanie/bs-python-utils)](https://github.com/bsalanie/bs-python-utils/releases)
36
+ -->
37
+ [![Build status](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/main.yml?branch=main)](https://github.com/bsalanie/bs-python-utils/actions/workflows/main.yml?query=branch%3Amain)
38
+ <!--
39
+ [![Tests](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/tests.yml?branch=main&label=tests)](https://github.com/bsalanie/bs-python-utils/actions/workflows/tests.yml?query=branch%3Amain)
40
+ -->
41
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils)](https://github.com/bsalanie/bs-python-utils/commits/main)
33
42
  ![GitHub last commit](https://img.shields.io/github/last-commit/bsalanie/bs-python-utils)
34
-
35
- <!-- [![Release](https://img.shields.io/github/v/release/bsalanie/bs-python-utils)](https://img.shields.io/github/v/release/bsalanie/bs-python-utils) -->
36
-
37
- [![Build status](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/main.yml?branch=main)](https://github.com/bsalanie/bs-python-utils/actions/workflows/main.yml?query=branch%3Amain) <!-- [![codecov](https://codecov.io/gh/bsalanie/bs-python-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/bsalanie/bs-python-utils) --> <!-- [![Commit activity](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils)](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils) --> [![License](https://img.shields.io/github/license/bsalanie/bs-python-utils)](https://img.shields.io/github/license/bsalanie/bs-python-utils)
43
+ [![License](https://img.shields.io/github/license/bsalanie/bs-python-utils)](https://img.shields.io/github/license/bsalanie/bs-python-utils)
38
44
 
39
45
  **My Python utilities**.
40
46
 
@@ -43,6 +49,12 @@ Dynamic: license-file
43
49
 
44
50
  ### Release notes
45
51
 
52
+ #### 1.0.1 (May 9, 2026)
53
+ Fixed badges.
54
+
55
+ #### 1.0 (May 9, 2026)
56
+ Created subpackages (no change in the API).
57
+
46
58
  #### 0.9 (March 18, 2026)
47
59
  Improved bivariate quantiles.
48
60
 
@@ -1,10 +1,16 @@
1
1
  ## bs-python-utils
2
2
 
3
+ [![PyPI version](https://img.shields.io/pypi/v/bs-python-utils)](https://pypi.org/project/bs-python-utils/)
4
+ <!--
5
+ [![Release](https://img.shields.io/github/v/release/bsalanie/bs-python-utils)](https://github.com/bsalanie/bs-python-utils/releases)
6
+ -->
7
+ [![Build status](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/main.yml?branch=main)](https://github.com/bsalanie/bs-python-utils/actions/workflows/main.yml?query=branch%3Amain)
8
+ <!--
9
+ [![Tests](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/tests.yml?branch=main&label=tests)](https://github.com/bsalanie/bs-python-utils/actions/workflows/tests.yml?query=branch%3Amain)
10
+ -->
11
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils)](https://github.com/bsalanie/bs-python-utils/commits/main)
3
12
  ![GitHub last commit](https://img.shields.io/github/last-commit/bsalanie/bs-python-utils)
4
-
5
- <!-- [![Release](https://img.shields.io/github/v/release/bsalanie/bs-python-utils)](https://img.shields.io/github/v/release/bsalanie/bs-python-utils) -->
6
-
7
- [![Build status](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/main.yml?branch=main)](https://github.com/bsalanie/bs-python-utils/actions/workflows/main.yml?query=branch%3Amain) <!-- [![codecov](https://codecov.io/gh/bsalanie/bs-python-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/bsalanie/bs-python-utils) --> <!-- [![Commit activity](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils)](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils) --> [![License](https://img.shields.io/github/license/bsalanie/bs-python-utils)](https://img.shields.io/github/license/bsalanie/bs-python-utils)
13
+ [![License](https://img.shields.io/github/license/bsalanie/bs-python-utils)](https://img.shields.io/github/license/bsalanie/bs-python-utils)
8
14
 
9
15
  **My Python utilities**.
10
16
 
@@ -13,6 +19,12 @@
13
19
 
14
20
  ### Release notes
15
21
 
22
+ #### 1.0.1 (May 9, 2026)
23
+ Fixed badges.
24
+
25
+ #### 1.0 (May 9, 2026)
26
+ Created subpackages (no change in the API).
27
+
16
28
  #### 0.9 (March 18, 2026)
17
29
  Improved bivariate quantiles.
18
30
 
@@ -0,0 +1 @@
1
+ from bs_python_utils.core.Timer import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.stats.bivariate_quantiles import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.viz.bs_altair import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.core.bs_logging import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.core.bs_mathstr import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.core.bs_mem import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.opt.bs_opt import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.viz.bs_plots import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.viz.bs_seaborn import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.numerical.bs_sparse_gaussian import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.viz.bsmplutils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.numerical.bsnputils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.numerical.bssputils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.stats.bsstats import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.core.bsutils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.numerical.chebyshev import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ # core: general utilities — bsutils, Timer, bs_logging, bs_mathstr, bs_mem
@@ -13,7 +13,7 @@ import tracemalloc
13
13
 
14
14
  import pandas as pd
15
15
 
16
- from bs_python_utils.bsutils import print_stars
16
+ from bs_python_utils.core.bsutils import print_stars
17
17
 
18
18
 
19
19
  def _obj_size_fmt(num: int) -> str:
@@ -0,0 +1 @@
1
+ # data: Pandas and scikit-learn utilities
@@ -11,8 +11,8 @@ from itertools import product
11
11
  import numpy as np
12
12
  import pandas as pd
13
13
 
14
- from bs_python_utils.bsnputils import bs_error_abort, check_vector_or_matrix
15
- from bs_python_utils.bsutils import print_stars
14
+ from bs_python_utils.core.bsutils import bs_error_abort, print_stars
15
+ from bs_python_utils.numerical.bsnputils import check_vector_or_matrix
16
16
 
17
17
 
18
18
  def bspd_print(
@@ -0,0 +1 @@
1
+ from bs_python_utils.stats.distance_covariances import * # noqa: F401, F403
@@ -5,7 +5,7 @@ import numpy as np
5
5
  from vega_datasets import data
6
6
 
7
7
 
8
- from bs_python_utils.bs_altair import (
8
+ from bs_python_utils.viz.bs_altair import (
9
9
  alt_boxes,
10
10
  alt_density,
11
11
  alt_faceted_densities,
@@ -2,7 +2,11 @@
2
2
 
3
3
  import numpy as np
4
4
 
5
- from bs_python_utils.distance_covariances import dcov_dcor, pdcov_pdcor, pvalue_pdcov
5
+ from bs_python_utils.stats.distance_covariances import (
6
+ dcov_dcor,
7
+ pdcov_pdcor,
8
+ pvalue_pdcov,
9
+ )
6
10
 
7
11
  # example page 2396 of Szekely and Rizzo 2014
8
12
  n = 2000
@@ -4,7 +4,7 @@ import tracemalloc
4
4
 
5
5
  import numpy as np
6
6
 
7
- from bs_python_utils.bs_mem import (
7
+ from bs_python_utils.core.bs_mem import (
8
8
  memory_display_top,
9
9
  memory_display_top_diffs,
10
10
  memory_usage,
@@ -2,7 +2,7 @@
2
2
 
3
3
  import numpy as np
4
4
 
5
- from bs_python_utils.bsmplutils import bs_mpl_plot_dcm_fit
5
+ from bs_python_utils.viz.bsmplutils import bs_mpl_plot_dcm_fit
6
6
 
7
7
  n_obs = 100
8
8
  n_y = 4
@@ -2,14 +2,14 @@
2
2
 
3
3
  import numpy as np
4
4
 
5
- from bs_python_utils.bs_opt import (
5
+ from bs_python_utils.core.bsutils import print_stars
6
+ from bs_python_utils.numerical.bssputils import describe_array
7
+ from bs_python_utils.opt.bs_opt import (
6
8
  acc_grad_descent,
7
9
  armijo_alpha,
8
10
  barzilai_borwein_alpha,
9
11
  minimize_some_fixed,
10
12
  )
11
- from bs_python_utils.bssputils import describe_array
12
- from bs_python_utils.bsutils import print_stars
13
13
 
14
14
  print_stars("Testing acc_grad_descent")
15
15
 
@@ -3,7 +3,11 @@
3
3
  import matplotlib.pyplot as plt
4
4
  import seaborn as sns
5
5
 
6
- from bs_python_utils.bs_seaborn import bs_regplot, bs_sns_bar_x_byf, bs_sns_bar_x_byfg
6
+ from bs_python_utils.viz.bs_seaborn import (
7
+ bs_regplot,
8
+ bs_sns_bar_x_byf,
9
+ bs_sns_bar_x_byfg,
10
+ )
7
11
 
8
12
  cars = sns.load_dataset("mpg")
9
13
 
@@ -4,7 +4,7 @@ import matplotlib.pyplot as plt
4
4
  import numpy as np
5
5
  from sklearn.preprocessing import PolynomialFeatures, StandardScaler
6
6
 
7
- from bs_python_utils.sklearn_utils import skl_npreg_lasso
7
+ from bs_python_utils.data_anal.sklearn_utils import skl_npreg_lasso
8
8
 
9
9
  n_obs = 10000
10
10
  X1 = -2.0 + 3.0 * np.random.uniform(size=n_obs)
@@ -1,9 +1,10 @@
1
1
  """Integrate x -> x**4 over N(0, 1) using the sparse Gaussian grids."""
2
2
 
3
3
  from typing import cast
4
+
4
5
  import numpy as np
5
6
 
6
- from bs_python_utils.bs_sparse_gaussian import setup_sparse_gaussian
7
+ from bs_python_utils.numerical.bs_sparse_gaussian import setup_sparse_gaussian
7
8
 
8
9
 
9
10
  def sum_x_to_the_fourth(x: np.ndarray) -> np.ndarray:
@@ -0,0 +1 @@
1
+ # numerical: NumPy/SciPy utilities, Chebyshev, sparse Gaussian integration
@@ -16,8 +16,8 @@ from importlib import resources
16
16
 
17
17
  import numpy as np
18
18
 
19
- from bs_python_utils.bsnputils import TwoArrays
20
- from bs_python_utils.bsutils import bs_error_abort
19
+ from bs_python_utils.numerical.bsnputils import TwoArrays
20
+ from bs_python_utils.core.bsutils import bs_error_abort
21
21
 
22
22
 
23
23
  def read_grid_file(grid_name: str) -> np.ndarray:
@@ -35,7 +35,7 @@ from typing import Any, Callable, Iterable, Union, cast
35
35
  import numpy as np
36
36
  from numpy.polynomial import Polynomial
37
37
 
38
- from bs_python_utils.bsutils import bs_error_abort
38
+ from bs_python_utils.core.bsutils import bs_error_abort
39
39
 
40
40
  # some useful types
41
41
  TwoArrays = tuple[np.ndarray, np.ndarray]
@@ -12,8 +12,8 @@ import numpy as np
12
12
  import scipy.stats as sts
13
13
  from scipy.interpolate import UnivariateSpline
14
14
 
15
- from bs_python_utils.bsnputils import check_vector, rice_stderr
16
- from bs_python_utils.bsutils import bs_error_abort, print_stars
15
+ from bs_python_utils.numerical.bsnputils import check_vector, rice_stderr
16
+ from bs_python_utils.core.bsutils import bs_error_abort, print_stars
17
17
 
18
18
 
19
19
  def describe_array(v: np.ndarray, name: str | None = "v") -> Any:
@@ -28,7 +28,7 @@ from typing import cast
28
28
  import numpy as np
29
29
  import numpy.polynomial.chebyshev as ncheb
30
30
 
31
- from bs_python_utils.bsnputils import (
31
+ from bs_python_utils.numerical.bsnputils import (
32
32
  ArrayFunctionOfArray,
33
33
  FloatOrArray,
34
34
  TwoArrays,
@@ -36,7 +36,7 @@ from bs_python_utils.bsnputils import (
36
36
  check_square,
37
37
  check_vector,
38
38
  )
39
- from bs_python_utils.bsutils import bs_error_abort
39
+ from bs_python_utils.core.bsutils import bs_error_abort
40
40
 
41
41
 
42
42
  @dataclass
@@ -0,0 +1 @@
1
+ # opt: optimization algorithms and wrappers
@@ -25,9 +25,9 @@ import numpy as np
25
25
  import scipy.linalg as spla
26
26
  import scipy.optimize as spopt
27
27
 
28
- from bs_python_utils.bsnputils import TwoArrays, check_vector, npmaxabs
29
- from bs_python_utils.bsutils import bs_error_abort, print_stars
30
- from bs_python_utils.Timer import timeit
28
+ from bs_python_utils.numerical.bsnputils import TwoArrays, check_vector, npmaxabs
29
+ from bs_python_utils.core.bsutils import bs_error_abort, print_stars
30
+ from bs_python_utils.core.Timer import timeit
31
31
 
32
32
  ScalarFunctionAndGradient = Callable[
33
33
  [np.ndarray, Iterable, Optional[bool]], Union[float, tuple[float, np.ndarray]]
@@ -0,0 +1 @@
1
+ from bs_python_utils.data_anal.pandas_utils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ from bs_python_utils.data_anal.sklearn_utils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ # stats: statistics — TSLS, nonparametric estimation, bivariate quantiles, distance covariances
@@ -1,39 +1,41 @@
1
- """This takes in observations of a bivariate random variable `y`
2
- and computes vector quantiles and vector ranks à la
3
- [Chernozhukov-Galichon-Hallin-Henry (*Ann. Stats.* 2017)](
4
- https://projecteuclid.org/journals/annals-of-statistics/volume-45/
5
- issue-1/MongeKantorovich-depth-quantiles-ranks-and-signs/10.1214/16-AOS1450.full).
1
+ """Bivariate vector quantiles and ranks.
6
2
 
3
+ This module implements the bivariate case of the vector quantiles and vector
4
+ ranks construction of Chernozhukov, Galichon, Hallin, and Henry (2017).
7
5
 
8
- Note:
9
- if the math looks strange in the documentation, just reload the page.
6
+ The main workflow is:
10
7
 
11
- The sequence of steps is as follows:
8
+ 1. Solve for the dual weights ``v`` with :func:`_solve_for_v`.
9
+ 2. Evaluate quantiles with :func:`bivariate_quantiles_v` or
10
+ :func:`bivariate_quantiles`.
11
+ 3. Read off barycentric ranks with :func:`bivariate_ranks`.
12
12
 
13
- 1. optimize the weights: `v = solve_for_v(y, n_nodes)` given `n_nodes` Chebyshev nodes for numerical integration
14
- 2. to obtain the $(u_1,u_2)$ quantiles for $(u_1, u_2)\\in [0,1]$, run
15
- `qtiles_y = bivariate_quantiles_v(y, v, u1, u2)`
16
- 3. to compute the vector ranks for all points in the sample (the barycenters
17
- of the cells in the power diagram):
18
- `ranks_y = bivariate_ranks_v(y, v, n_nodes)`
19
-
20
- Steps 1 and 2 can be combined: `qtiles_y = bivariate_quantiles(y, v, u1, u2, n_nodes)`
21
-
22
- Steps 1 and 3 can be combined: `ranks_y = bivariate_ranks(y, n_nodes)`
13
+ References:
14
+ Chernozhukov, Galichon, Hallin, and Henry. "Monge-Kantorovich Depth,
15
+ Quantiles, Ranks and Signs." *Annals of Statistics* 45(1), 2017.
23
16
  """
24
17
 
25
18
  from typing import cast
26
19
 
27
20
  import numpy as np
28
21
 
29
- from bs_python_utils.bs_opt import minimize_free, print_optimization_results
30
- from bs_python_utils.bsnputils import TwoArrays, npmaxabs
31
- from bs_python_utils.bsutils import bs_error_abort
32
- from bs_python_utils.chebyshev import Interval, cheb_get_nodes_1d
22
+ from bs_python_utils.core.bsutils import bs_error_abort
23
+ from bs_python_utils.numerical.bsnputils import TwoArrays, npmaxabs
24
+ from bs_python_utils.numerical.chebyshev import Interval, cheb_get_nodes_1d
25
+ from bs_python_utils.opt.bs_opt import minimize_free, print_optimization_results
33
26
 
34
27
 
35
28
  def _compute_ad(y: np.ndarray) -> TwoArrays:
36
- """Build the `A` and `dy2` matrices used in the dual optimisation."""
29
+ """Compute matrices used in the dual optimization.
30
+
31
+ Args:
32
+ y: Observations with shape ``(n, 2)``.
33
+
34
+ Returns:
35
+ A tuple ``(a_mat, dy2)`` where ``a_mat`` contains the pairwise slope
36
+ ratios and ``dy2`` contains pairwise differences in the second
37
+ coordinate.
38
+ """
37
39
  y1 = y[:, 0]
38
40
  dy1 = np.subtract.outer(y1, y1)
39
41
  y2 = y[:, 1]
@@ -47,7 +49,22 @@ def _compute_ad(y: np.ndarray) -> TwoArrays:
47
49
  def _compute_m_M(
48
50
  v: np.ndarray, a_mat: np.ndarray, dy2: np.ndarray, tau1_nodes: np.ndarray
49
51
  ) -> TwoArrays:
50
- """Build the `m` and `M` matrices used in the dual optimisation."""
52
+ """Compute the lower and upper bounds used in the dual optimization.
53
+
54
+ Args:
55
+ v: Dual weights of length ``n``.
56
+ a_mat: Pairwise slope matrix returned by :func:`_compute_ad`.
57
+ dy2: Pairwise differences in the second coordinate.
58
+ tau1_nodes: Quadrature nodes for the first coordinate.
59
+
60
+ Returns:
61
+ A tuple ``(m, M)`` with arrays of shape ``(n, len(tau1_nodes))``.
62
+
63
+ Warning:
64
+ The (rare) ``dy2 == 0`` case currently raises warnings in computing ``b_mat``.
65
+ That logic works for the present implementation but should be refactored into a cleaner, more explicit
66
+ branch.
67
+ """
51
68
  dv = np.subtract.outer(v, v)
52
69
  b_mat = dv / dy2
53
70
  np.fill_diagonal(dy2, 0.0)
@@ -69,15 +86,19 @@ def _compute_m_M(
69
86
 
70
87
 
71
88
  def bivariate_quantiles_v(y: np.ndarray, tau: np.ndarray, v: np.ndarray) -> np.ndarray:
72
- """Evaluate vector quantiles for a given set of dual weights.
89
+ """Evaluate vector quantiles for fixed dual weights.
73
90
 
74
91
  Args:
75
92
  y: Observations with shape ``(n, 2)``.
76
- tau: Evaluation points in ``[0, 1]^2`` (shape ``(m, 2)``).
77
- v: Dual weights solving the optimal transport problem (length ``n``).
93
+ tau: Evaluation points in ``[0, 1]^2`` with shape ``(m, 2)``.
94
+ v: Dual weights solving the optimal transport problem, with length
95
+ ``n``.
78
96
 
79
97
  Returns:
80
98
  Array of quantile locations with shape ``(m, 2)``.
99
+
100
+ Raises:
101
+ SystemExit: If ``tau`` does not have exactly two columns.
81
102
  """
82
103
  if tau.shape[1] != 2:
83
104
  bs_error_abort("tau must have two columns")
@@ -88,16 +109,19 @@ def bivariate_quantiles_v(y: np.ndarray, tau: np.ndarray, v: np.ndarray) -> np.n
88
109
  def _objgrad(
89
110
  v: np.ndarray, args: list, gr: bool = False
90
111
  ) -> float | tuple[float, np.ndarray, np.ndarray]:
91
- """computes the expectation of $\\psi(U, v)$ and perhaps its gradient wrt `v` or the bivariate ranks
112
+ """Evaluate the objective and optionally its gradient.
92
113
 
93
114
  Args:
94
- v: an `(n-1)`-vector
95
- args: a list of other arguments `[y, a_mat, dy2, tau1_nodes, tau1_weights, verbose]`
96
- gr: if `False`, we only return the value of the objective function
97
- if `True`, we also return the gradient and the bivariate ranks
115
+ v: Free dual variables of length ``n - 1``.
116
+ args: Positional arguments ``[y, a_mat, dy2, tau1_nodes, tau1_weights,
117
+ verbose]``.
118
+ gr: Whether to also return the gradient and the barycentric ranks.
98
119
 
99
120
  Returns:
100
- the value of the expectation and perhaps its gradient and the bivariate ranks
121
+ If ``gr`` is ``False``, returns the scalar objective value.
122
+
123
+ If ``gr`` is ``True``, returns a tuple ``(obj_val, grad_val,
124
+ bivrank)``.
101
125
  """
102
126
  y = args[0]
103
127
  y1 = y[:, 0]
@@ -136,10 +160,28 @@ def _objgrad(
136
160
 
137
161
 
138
162
  def _obj(v: np.ndarray, args: list):
163
+ """Return only the objective value.
164
+
165
+ Args:
166
+ v: Free dual variables.
167
+ args: Positional arguments passed to :func:`_objgrad`.
168
+
169
+ Returns:
170
+ Scalar objective value.
171
+ """
139
172
  return _objgrad(v, args)
140
173
 
141
174
 
142
175
  def _grad(v: np.ndarray, args: list):
176
+ """Return only the objective gradient.
177
+
178
+ Args:
179
+ v: Free dual variables.
180
+ args: Positional arguments passed to :func:`_objgrad`.
181
+
182
+ Returns:
183
+ Objective gradient.
184
+ """
143
185
  res_objg = cast(tuple[float, np.ndarray], _objgrad(v, args, gr=True))
144
186
  grad_val = res_objg[1]
145
187
  verbose = args[-1]
@@ -149,17 +191,20 @@ def _grad(v: np.ndarray, args: list):
149
191
 
150
192
 
151
193
  def _solve_for_v(y: np.ndarray, n_nodes: int = 32, verbose: bool = False) -> TwoArrays:
152
- """Solve the dual optimisation to obtain the optimal weights ``v`` and the bivariate ranks
194
+ """Solve the dual optimization problem for the sample.
153
195
 
154
196
  Args:
155
197
  y: Observations with shape ``(n, 2)``.
156
- n_nodes: Number of Chebyshev nodes for the quadrature.
198
+ n_nodes: Number of Chebyshev nodes used for quadrature.
157
199
  verbose: Print optimisation diagnostics when ``True``.
158
200
 
159
201
  Returns:
160
- Array of length ``n`` containing the optimal weights (including the
161
- residual term).
162
- Array of shape ``(n, 2)`` containing the bivariate ranks (the barycenters of the cells in the power diagram).
202
+ A tuple ``(vstar, bivranks)`` where ``vstar`` has length ``n`` and
203
+ ``bivranks`` has shape ``(n, 2)``.
204
+
205
+ Raises:
206
+ SystemExit: If the optimization fails or if ``y`` is not
207
+ two-dimensional.
163
208
  """
164
209
  d = y.shape[1]
165
210
 
@@ -194,7 +239,7 @@ def bivariate_ranks(
194
239
  n_nodes: int = 32,
195
240
  verbose: bool = False,
196
241
  ) -> np.ndarray:
197
- """Compute the barycentric ranks of each observation.
242
+ """Compute barycentric ranks for each observation.
198
243
 
199
244
  Args:
200
245
  y: Observations with shape ``(n, 2)``.
@@ -216,16 +261,16 @@ def bivariate_ranks(
216
261
  def bivariate_quantiles(
217
262
  y: np.ndarray, tau: np.ndarray, n_nodes: int = 32, verbose: bool = False
218
263
  ) -> np.ndarray:
219
- """Solve for the dual weights then evaluate bivariate quantiles.
264
+ """Solve for the dual weights and evaluate bivariate quantiles.
220
265
 
221
266
  Args:
222
- y: Observations, shape ``(n, 2)``.
223
- tau: Query points in ``[0, 1]^2`` (shape ``(m, 2)``).
267
+ y: Observations with shape ``(n, 2)``.
268
+ tau: Query points in ``[0, 1]^2`` with shape ``(m, 2)``.
224
269
  n_nodes: Number of Chebyshev nodes for the quadrature.
225
270
  verbose: Print optimisation diagnostics when ``True``.
226
271
 
227
272
  Returns:
228
- Bivariate quantiles at ``u``.
273
+ Bivariate quantiles evaluated at ``tau``.
229
274
  """
230
275
  v, _ = _solve_for_v(y, n_nodes, verbose)
231
276
  return bivariate_quantiles_v(y, tau, v)
@@ -15,9 +15,13 @@ from sklearn.neighbors import KernelDensity
15
15
  from statsmodels.nonparametric._kernel_base import EstimatorSettings
16
16
  from statsmodels.nonparametric.kernel_regression import KernelReg
17
17
 
18
- from bs_python_utils.bsnputils import check_matrix, check_vector, check_vector_or_matrix
19
- from bs_python_utils.bssputils import spline_reg
20
- from bs_python_utils.bsutils import bs_error_abort
18
+ from bs_python_utils.numerical.bsnputils import (
19
+ check_matrix,
20
+ check_vector,
21
+ check_vector_or_matrix,
22
+ )
23
+ from bs_python_utils.numerical.bssputils import spline_reg
24
+ from bs_python_utils.core.bsutils import bs_error_abort
21
25
 
22
26
 
23
27
  @dataclass
@@ -14,8 +14,8 @@ from typing import cast
14
14
 
15
15
  import numpy as np
16
16
 
17
- from bs_python_utils.bsnputils import check_square, check_vector_or_matrix
18
- from bs_python_utils.bsutils import bs_error_abort
17
+ from bs_python_utils.numerical.bsnputils import check_square, check_vector_or_matrix
18
+ from bs_python_utils.core.bsutils import bs_error_abort
19
19
 
20
20
 
21
21
  @dataclass
@@ -0,0 +1 @@
1
+ from bs_python_utils.viz.streamlit_utils import * # noqa: F401, F403
@@ -0,0 +1 @@
1
+ # viz: plotting — Matplotlib, Seaborn, Altair, Streamlit
@@ -27,8 +27,8 @@ import numpy as np
27
27
  import pandas as pd
28
28
  from altair_saver import save as alt_save
29
29
 
30
- from bs_python_utils.bsnputils import check_matrix, check_vector
31
- from bs_python_utils.bsutils import bs_error_abort
30
+ from bs_python_utils.numerical.bsnputils import check_matrix, check_vector
31
+ from bs_python_utils.core.bsutils import bs_error_abort
32
32
 
33
33
 
34
34
  def _maybe_save(ch: alt.Chart, save: str | None = None):
@@ -10,7 +10,7 @@ import matplotlib.axes as axes
10
10
  import matplotlib.pyplot as plt
11
11
  import numpy as np
12
12
 
13
- from bs_python_utils.bsutils import bs_error_abort
13
+ from bs_python_utils.core.bsutils import bs_error_abort
14
14
 
15
15
 
16
16
  def ax_text(ax: axes.Axes, str_txt: str, x: float, y: float) -> axes.Axes:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bs-python-utils
3
- Version: 0.9.3
3
+ Version: 1.0.1
4
4
  Summary: Utilities programs for my Python code
5
5
  Requires-Python: >=3.12
6
6
  Description-Content-Type: text/markdown
@@ -16,7 +16,7 @@ Requires-Dist: numpy>=2.3.3
16
16
  Requires-Dist: pandas>=2.3.2
17
17
  Requires-Dist: pre-commit>=4.3.0
18
18
  Requires-Dist: pytest>=8.4.2
19
- Requires-Dist: mypy
19
+ Requires-Dist: mypy>=1.18
20
20
  Requires-Dist: ruff>=0.14.0
21
21
  Requires-Dist: scikit-learn>=1.7.2
22
22
  Requires-Dist: scipy>=1.16.2
@@ -25,16 +25,22 @@ Requires-Dist: statsmodels>=0.14.5
25
25
  Requires-Dist: streamlit>=1.49.1
26
26
  Requires-Dist: vega-datasets>=0.9.0
27
27
  Requires-Dist: colorama>=0.4.6
28
- Requires-Dist: pyarrow>=21.0.0
28
+ Requires-Dist: pyarrow>=23.0.0
29
29
  Dynamic: license-file
30
30
 
31
31
  ## bs-python-utils
32
32
 
33
+ [![PyPI version](https://img.shields.io/pypi/v/bs-python-utils)](https://pypi.org/project/bs-python-utils/)
34
+ <!--
35
+ [![Release](https://img.shields.io/github/v/release/bsalanie/bs-python-utils)](https://github.com/bsalanie/bs-python-utils/releases)
36
+ -->
37
+ [![Build status](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/main.yml?branch=main)](https://github.com/bsalanie/bs-python-utils/actions/workflows/main.yml?query=branch%3Amain)
38
+ <!--
39
+ [![Tests](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/tests.yml?branch=main&label=tests)](https://github.com/bsalanie/bs-python-utils/actions/workflows/tests.yml?query=branch%3Amain)
40
+ -->
41
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils)](https://github.com/bsalanie/bs-python-utils/commits/main)
33
42
  ![GitHub last commit](https://img.shields.io/github/last-commit/bsalanie/bs-python-utils)
34
-
35
- <!-- [![Release](https://img.shields.io/github/v/release/bsalanie/bs-python-utils)](https://img.shields.io/github/v/release/bsalanie/bs-python-utils) -->
36
-
37
- [![Build status](https://img.shields.io/github/actions/workflow/status/bsalanie/bs-python-utils/main.yml?branch=main)](https://github.com/bsalanie/bs-python-utils/actions/workflows/main.yml?query=branch%3Amain) <!-- [![codecov](https://codecov.io/gh/bsalanie/bs-python-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/bsalanie/bs-python-utils) --> <!-- [![Commit activity](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils)](https://img.shields.io/github/commit-activity/m/bsalanie/bs-python-utils) --> [![License](https://img.shields.io/github/license/bsalanie/bs-python-utils)](https://img.shields.io/github/license/bsalanie/bs-python-utils)
43
+ [![License](https://img.shields.io/github/license/bsalanie/bs-python-utils)](https://img.shields.io/github/license/bsalanie/bs-python-utils)
38
44
 
39
45
  **My Python utilities**.
40
46
 
@@ -43,6 +49,12 @@ Dynamic: license-file
43
49
 
44
50
  ### Release notes
45
51
 
52
+ #### 1.0.1 (May 9, 2026)
53
+ Fixed badges.
54
+
55
+ #### 1.0 (May 9, 2026)
56
+ Created subpackages (no change in the API).
57
+
46
58
  #### 0.9 (March 18, 2026)
47
59
  Improved bivariate quantiles.
48
60
 
@@ -42,6 +42,15 @@ bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid4prec9.txt
42
42
  bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec13.txt
43
43
  bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec17.txt
44
44
  bs_python_utils/GaussHermiteSparseGrids/GHsparseGrid5prec9.txt
45
+ bs_python_utils/core/Timer.py
46
+ bs_python_utils/core/__init__.py
47
+ bs_python_utils/core/bs_logging.py
48
+ bs_python_utils/core/bs_mathstr.py
49
+ bs_python_utils/core/bs_mem.py
50
+ bs_python_utils/core/bsutils.py
51
+ bs_python_utils/data_anal/__init__.py
52
+ bs_python_utils/data_anal/pandas_utils.py
53
+ bs_python_utils/data_anal/sklearn_utils.py
45
54
  bs_python_utils/examples/examples_altair.py
46
55
  bs_python_utils/examples/examples_distance_covariances.py
47
56
  bs_python_utils/examples/examples_mem.py
@@ -50,6 +59,23 @@ bs_python_utils/examples/examples_opt.py
50
59
  bs_python_utils/examples/examples_seaborn.py
51
60
  bs_python_utils/examples/examples_sklearn.py
52
61
  bs_python_utils/examples/examples_sparse_gaussian.py
62
+ bs_python_utils/numerical/__init__.py
63
+ bs_python_utils/numerical/bs_sparse_gaussian.py
64
+ bs_python_utils/numerical/bsnputils.py
65
+ bs_python_utils/numerical/bssputils.py
66
+ bs_python_utils/numerical/chebyshev.py
67
+ bs_python_utils/opt/__init__.py
68
+ bs_python_utils/opt/bs_opt.py
69
+ bs_python_utils/stats/__init__.py
70
+ bs_python_utils/stats/bivariate_quantiles.py
71
+ bs_python_utils/stats/bsstats.py
72
+ bs_python_utils/stats/distance_covariances.py
73
+ bs_python_utils/viz/__init__.py
74
+ bs_python_utils/viz/bs_altair.py
75
+ bs_python_utils/viz/bs_plots.py
76
+ bs_python_utils/viz/bs_seaborn.py
77
+ bs_python_utils/viz/bsmplutils.py
78
+ bs_python_utils/viz/streamlit_utils.py
53
79
  tests/test_bivariate_quantiles.py
54
80
  tests/test_bs_opt.py
55
81
  tests/test_bs_sparse_gaussian.py
@@ -9,7 +9,7 @@ numpy>=2.3.3
9
9
  pandas>=2.3.2
10
10
  pre-commit>=4.3.0
11
11
  pytest>=8.4.2
12
- mypy
12
+ mypy>=1.18
13
13
  ruff>=0.14.0
14
14
  scikit-learn>=1.7.2
15
15
  scipy>=1.16.2
@@ -18,4 +18,4 @@ statsmodels>=0.14.5
18
18
  streamlit>=1.49.1
19
19
  vega-datasets>=0.9.0
20
20
  colorama>=0.4.6
21
- pyarrow>=21.0.0
21
+ pyarrow>=23.0.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bs-python-utils"
3
- version = "0.9.3"
3
+ version = "1.0.1"
4
4
  description = "Utilities programs for my Python code"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"
@@ -16,7 +16,7 @@ dependencies = [
16
16
  "pandas>=2.3.2",
17
17
  "pre-commit>=4.3.0",
18
18
  "pytest>=8.4.2",
19
- "mypy",
19
+ "mypy>=1.18",
20
20
  "ruff>=0.14.0",
21
21
  "scikit-learn>=1.7.2",
22
22
  "scipy>=1.16.2",
@@ -25,11 +25,12 @@ dependencies = [
25
25
  "streamlit>=1.49.1",
26
26
  "vega-datasets>=0.9.0",
27
27
  "colorama>=0.4.6",
28
- "pyarrow>=21.0.0",
28
+ "pyarrow>=23.0.0",
29
29
  ]
30
30
 
31
- [tool.setuptools]
32
- packages = ["bs_python_utils"]
31
+ [tool.setuptools.packages.find]
32
+ where = ["."]
33
+ include = ["bs_python_utils*"]
33
34
 
34
35
  [tool.setuptools.package-data]
35
36
  "bs_python_utils" = ["examples/*", "examples/**/*", "GaussHermiteSparseGrids/*"]
@@ -1,10 +1,10 @@
1
1
  import numpy as np
2
2
 
3
- from bs_python_utils.bivariate_quantiles import (
3
+ from bs_python_utils.numerical.bsnputils import npmaxabs
4
+ from bs_python_utils.stats.bivariate_quantiles import (
4
5
  _compute_ad,
5
6
  _solve_for_v,
6
7
  )
7
- from bs_python_utils.bsnputils import npmaxabs
8
8
 
9
9
 
10
10
  def test_bivariate_ranks():
@@ -24,7 +24,7 @@ def test_bivariate_ranks():
24
24
  y[:, 1] == y[k, 1]
25
25
  )
26
26
 
27
- assert npmaxabs(bivranks - bivranks_th) < 0.01
27
+ assert npmaxabs(bivranks - bivranks_th) < 0.1
28
28
 
29
29
 
30
30
  def test_compute_ad():
@@ -1,6 +1,6 @@
1
1
  import numpy as np
2
2
 
3
- from bs_python_utils import bs_opt
3
+ from bs_python_utils.opt import bs_opt
4
4
 
5
5
 
6
6
  def quadratic_objective(x, args):
@@ -2,7 +2,7 @@ from math import isclose
2
2
 
3
3
  import numpy as np
4
4
 
5
- from bs_python_utils.bs_sparse_gaussian import setup_sparse_gaussian
5
+ from bs_python_utils.numerical.bs_sparse_gaussian import setup_sparse_gaussian
6
6
 
7
7
 
8
8
  def test_sparse_gaussian():
@@ -2,7 +2,8 @@ from math import exp, isclose, log, pi, sqrt
2
2
 
3
3
  import numpy as np
4
4
 
5
- from bs_python_utils.bsnputils import (
5
+ from bs_python_utils.core.bsutils import bsexp, bslog
6
+ from bs_python_utils.numerical.bsnputils import (
6
7
  bs_sqrt_pdmatrix,
7
8
  bsgrid,
8
9
  ecdf,
@@ -23,7 +24,6 @@ from bs_python_utils.bsnputils import (
23
24
  print_quantiles,
24
25
  rice_stderr,
25
26
  )
26
- from bs_python_utils.bsutils import bsexp, bslog
27
27
 
28
28
 
29
29
  def test_print_quantiles_vec():
@@ -1,7 +1,7 @@
1
1
  import numpy as np
2
2
  import scipy.stats as sts
3
3
 
4
- from bs_python_utils import bssputils
4
+ from bs_python_utils.numerical import bssputils
5
5
 
6
6
 
7
7
  def test_describe_array_reports_std_deviation(capsys):
@@ -1,6 +1,6 @@
1
1
  import numpy as np
2
2
 
3
- from bs_python_utils import bsstats
3
+ from bs_python_utils.stats import bsstats
4
4
 
5
5
 
6
6
  def test_proj_Z_multivariate_degree_two():
@@ -2,7 +2,7 @@ from math import exp, isclose, log, sqrt
2
2
 
3
3
  import numpy as np
4
4
 
5
- from bs_python_utils.bsutils import (
5
+ from bs_python_utils.core.bsutils import (
6
6
  bs_projection_point,
7
7
  bs_switch,
8
8
  bscomb,
@@ -3,9 +3,9 @@ from math import exp, isclose, sqrt
3
3
  import numpy as np
4
4
  import pytest
5
5
 
6
- from bs_python_utils.bsnputils import FloatOrArray, bsgrid
7
- from bs_python_utils.bsutils import bs_error_abort
8
- from bs_python_utils.chebyshev import (
6
+ from bs_python_utils.core.bsutils import bs_error_abort
7
+ from bs_python_utils.numerical.bsnputils import FloatOrArray, bsgrid
8
+ from bs_python_utils.numerical.chebyshev import (
9
9
  Interval,
10
10
  Rectangle,
11
11
  cheb_eval_fun_at_nodes_1d,
@@ -1,6 +1,6 @@
1
1
  import numpy as np
2
2
 
3
- from bs_python_utils.bsnputils import set_elements_abovebelow_diagonal
3
+ from bs_python_utils.numerical.bsnputils import set_elements_abovebelow_diagonal
4
4
 
5
5
 
6
6
  def test_nptril():
@@ -1,6 +1,6 @@
1
1
  import numpy as np
2
2
 
3
- from bs_python_utils.bsstats import emcee_draw, kde_resample
3
+ from bs_python_utils.stats.bsstats import emcee_draw, kde_resample
4
4
 
5
5
 
6
6
  def log_gauss2(x, *args):
@@ -25,8 +25,8 @@ def test_emcee_draw():
25
25
 
26
26
  def test_kde_resample():
27
27
  n_obs, n_dims = 10_000, 2
28
- rng = np.random.default_rng()
28
+ rng = np.random.default_rng(seed=45678)
29
29
  x = rng.normal(size=(n_obs, n_dims))
30
30
  samples, _ = kde_resample(x, 10_000)
31
31
  assert np.allclose(np.mean(samples, 0), np.mean(x, 0), atol=0.1)
32
- assert np.allclose(np.var(samples, 0), np.var(x, 0), atol=0.1)
32
+ assert np.allclose(np.var(samples, 0), np.var(x, 0), atol=0.15)
@@ -1,8 +1,9 @@
1
- import numpy as np
1
+ from typing import cast
2
2
 
3
3
  import matplotlib.pyplot as plt
4
+ import numpy as np
4
5
 
5
- from bs_python_utils import sklearn_utils
6
+ from bs_python_utils.data_anal import sklearn_utils
6
7
 
7
8
 
8
9
  def test_skl_npreg_lasso_returns_predictions_and_model():
@@ -29,7 +30,7 @@ def test_skl_npreg_lasso_returns_predictions_and_model():
29
30
  assert model.named_steps["lasso"].fit_intercept is False
30
31
 
31
32
  # ensure pipeline can predict out-of-sample without errors
32
- preds_new = model.predict(X[:5])
33
+ preds_new = cast(np.ndarray, model.predict(X[:5]))
33
34
  assert preds_new.shape == (5,)
34
35
 
35
36
 
File without changes