toolbox-utils 5.1.3__tar.gz → 5.2.0__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 (74) hide show
  1. toolbox_utils-5.2.0/.github/dependabot.yml +7 -0
  2. toolbox_utils-5.2.0/.github/workflows/pypi-package.yml +49 -0
  3. toolbox_utils-5.2.0/.github/workflows/tests.yml +95 -0
  4. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/.pre-commit-config.yaml +36 -32
  5. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/BADGES.rst +0 -5
  6. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/CHANGELOG.md +17 -0
  7. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/PKG-INFO +6 -35
  8. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/README.rst +0 -5
  9. toolbox_utils-5.2.0/VERSION +1 -0
  10. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/pyproject.toml +8 -43
  11. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils/tsutils.py +63 -8
  12. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils.egg-info/PKG-INFO +6 -35
  13. toolbox_utils-5.2.0/src/toolbox_utils.egg-info/requires.txt +13 -0
  14. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_date_slice.py +6 -3
  15. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_hbn.py +12 -4
  16. toolbox_utils-5.1.3/.github/dependabot.yml +0 -11
  17. toolbox_utils-5.1.3/.github/workflows/pypi-package.yml +0 -91
  18. toolbox_utils-5.1.3/.github/workflows/tests.yml +0 -58
  19. toolbox_utils-5.1.3/VERSION +0 -1
  20. toolbox_utils-5.1.3/src/toolbox_utils.egg-info/requires.txt +0 -37
  21. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/.deepsource.toml +0 -0
  22. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/.github/workflows/clean-workflow-runs.yml +0 -0
  23. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/.gitignore +0 -0
  24. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/.sourcery.yaml +0 -0
  25. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/AUTHORS.rst +0 -0
  26. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/CONTRIBUTING.rst +0 -0
  27. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/LICENSE.txt +0 -0
  28. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/Makefile +0 -0
  29. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/authors.rst +0 -0
  30. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/conf.py +0 -0
  31. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/contributing.rst +0 -0
  32. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/index.rst +0 -0
  33. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/license.rst +0 -0
  34. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/make.bat +0 -0
  35. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/docs/readme.rst +0 -0
  36. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/setup.cfg +0 -0
  37. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils/__init__.py +0 -0
  38. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils/readers/__init__.py +0 -0
  39. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils/readers/hbn.py +0 -0
  40. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils/readers/plotgen.py +0 -0
  41. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils/readers/wdm.py +0 -0
  42. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils.egg-info/SOURCES.txt +0 -0
  43. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils.egg-info/dependency_links.txt +0 -0
  44. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/src/toolbox_utils.egg-info/top_level.txt +0 -0
  45. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data.wdm +0 -0
  46. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_bi_daily.csv +0 -0
  47. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_bivl.hbn +0 -0
  48. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_end.bivl.csv +0 -0
  49. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_end.daily.csv +0 -0
  50. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_end.monthly.csv +0 -0
  51. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_end.yearly.csv +0 -0
  52. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_flow_stage.xlsx +0 -0
  53. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_period.bivl.csv +0 -0
  54. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_period.daily.csv +0 -0
  55. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_period.monthly.csv +0 -0
  56. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_period.yearly.csv +0 -0
  57. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_plotgen.plt +0 -0
  58. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_simple.csv +0 -0
  59. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_start.bivl.csv +0 -0
  60. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_start.daily.csv +0 -0
  61. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_start.monthly.csv +0 -0
  62. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_start.yearly.csv +0 -0
  63. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_wdm_1.csv +0 -0
  64. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_wdm_2.csv +0 -0
  65. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/data_yearly.hbn +0 -0
  66. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_asbestfreq.py +0 -0
  67. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_dateparse.py +0 -0
  68. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_extract.py +0 -0
  69. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_make_list.py +0 -0
  70. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_period_timestamp.py +0 -0
  71. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_plotgen.py +0 -0
  72. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_range_to_numlist.py +0 -0
  73. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_read.py +0 -0
  74. {toolbox_utils-5.1.3 → toolbox_utils-5.2.0}/tests/test_wdm.py +0 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ version: 2
3
+ updates:
4
+ - package-ecosystem: github-actions
5
+ directory: /
6
+ schedule:
7
+ interval: weekly
@@ -0,0 +1,49 @@
1
+ ---
2
+ # This workflow will install Python dependencies, run tests and lint with
3
+ # a variety of Python versions For more information see:
4
+ # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
5
+
6
+ name: PyPI package tests
7
+
8
+ on: # yamllint disable-line rule:truthy
9
+ push:
10
+ branches: [main]
11
+ pull_request:
12
+ branches: [main]
13
+ workflow_dispatch:
14
+
15
+ jobs:
16
+ tests:
17
+ uses: ./.github/workflows/tests.yml
18
+
19
+ pypi-publish:
20
+ needs: tests
21
+ runs-on: ubuntu-latest
22
+ environment: release
23
+ name: upload release to PyPI
24
+
25
+ permissions:
26
+ # IMPORTANT: this permission is mandatory for trusted publishing
27
+ id-token: write
28
+
29
+ steps:
30
+ - name: Checkout source
31
+ uses: actions/checkout@v4
32
+ with:
33
+ submodules: recursive
34
+
35
+ - name: Build sdist and wheel
36
+ run: |
37
+ python -m pip install build
38
+ python -m build
39
+
40
+ - name: Download artifact
41
+ uses: actions/download-artifact@v4
42
+ with:
43
+ path: dist
44
+ merge-multiple: true
45
+
46
+ - name: Publish package distributions to PyPI
47
+ uses: pypa/gh-action-pypi-publish@release/v1
48
+ with:
49
+ skip-existing: true
@@ -0,0 +1,95 @@
1
+ ---
2
+ # This workflow will install Python dependencies, run tests and lint with
3
+ # a variety of Python versions For more information see:
4
+ # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
5
+
6
+ name: Tests
7
+
8
+ on: # yamllint disable-line rule:truthy
9
+ push:
10
+ branches: [develop]
11
+ pull_request:
12
+ branches: [develop]
13
+ workflow_dispatch:
14
+ workflow_call:
15
+
16
+ jobs:
17
+ test:
18
+ runs-on: ${{ matrix.os }}
19
+
20
+ strategy:
21
+ fail-fast: false
22
+ matrix:
23
+ os: [ubuntu-latest, macos-latest, windows-latest]
24
+ python-versions: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
25
+ pandas-versions: [1.5.3, 2.0.0, 2.2.0, 2.2.3]
26
+ toolchain:
27
+ - {compiler: gcc, version: 13}
28
+ exclude:
29
+ - python-versions: '3.13'
30
+ pandas-versions: 1.5.3
31
+ - python-versions: '3.13'
32
+ pandas-versions: 2.0.0
33
+ - python-versions: '3.13'
34
+ pandas-versions: 2.2.0
35
+ - python-versions: '3.8'
36
+ pandas-versions: 2.2.0
37
+ - python-versions: '3.8'
38
+ pandas-versions: 2.2.3
39
+ - os: windows-latest
40
+ python-versions: '3.8'
41
+ - os: windows-latest
42
+ python-versions: '3.9'
43
+ pandas-versions: 2.2.0
44
+ - os: windows-latest
45
+ python-versions: '3.10'
46
+ pandas-versions: 2.2.0
47
+ - os: windows-latest
48
+ python-versions: '3.11'
49
+ pandas-versions: 2.2.0
50
+ - os: windows-latest
51
+ python-versions: '3.12'
52
+ pandas-versions: 2.2.0
53
+ - os: windows-latest
54
+ python-versions: '3.13'
55
+
56
+ steps:
57
+ - name: Checkout repository
58
+ uses: actions/checkout@v4
59
+ with:
60
+ submodules: recursive
61
+
62
+ - name: Set up Python ${{ matrix.python-versions }}
63
+ uses: actions/setup-python@v5
64
+ with:
65
+ python-version: ${{ matrix.python-versions }}
66
+
67
+ - name: Install dependencies pytest
68
+ run: |
69
+ python -m pip install --upgrade pip
70
+ python -m pip install pytest pytest-cov
71
+
72
+ - name: >
73
+ Install package and dependencies
74
+ version ${{ matrix.pandas-versions }}
75
+ run: >
76
+ python -m pip install
77
+ pandas==${{ matrix.pandas-versions }} 'numpy<2' .
78
+
79
+ - name: Test with pytest
80
+ run: python -m pytest --cov
81
+
82
+ - name: Upload coverage data to coveralls.io
83
+ uses: coverallsapp/github-action@v2
84
+ with:
85
+ parallel: true
86
+
87
+ finish:
88
+ needs: test
89
+ if: ${{ always() }}
90
+ runs-on: ubuntu-latest
91
+ steps:
92
+ - name: Coveralls Finished
93
+ uses: coverallsapp/github-action@v2
94
+ with:
95
+ parallel-finished: true
@@ -2,9 +2,16 @@
2
2
  # See https://pre-commit.com for more information
3
3
  # See https://pre-commit.com/hooks.html for more hooks
4
4
 
5
+ exclude: |
6
+ (?x)^(
7
+ .*\.dods|
8
+ .*\.dmr|
9
+ .*\.dmd
10
+ )$
11
+
5
12
  repos:
6
13
  - repo: https://github.com/pre-commit/pre-commit-hooks
7
- rev: v4.5.0
14
+ rev: v5.0.0
8
15
  hooks:
9
16
  - id: check-case-conflict
10
17
  - id: check-docstring-first
@@ -22,8 +29,32 @@ repos:
22
29
  - id: trailing-whitespace
23
30
  exclude: notebooks/tstoolbox_plot_bash.sh
24
31
 
32
+ - repo: https://github.com/astral-sh/ruff-pre-commit
33
+ # Ruff version.
34
+ rev: v0.9.3
35
+ hooks:
36
+ # Run the linter.
37
+ - id: ruff
38
+ types_or: [python, pyi, jupyter]
39
+ args: [--fix]
40
+ # Run the formatter.
41
+ - id: ruff-format
42
+ types_or: [python, pyi, jupyter]
43
+
44
+ - repo: https://github.com/pycqa/isort
45
+ rev: 6.0.0
46
+ hooks:
47
+ - id: isort
48
+ name: isort (python)
49
+ - id: isort
50
+ name: isort (cython)
51
+ types: [cython]
52
+ - id: isort
53
+ name: isort (pyi)
54
+ types: [pyi]
55
+
25
56
  - repo: https://github.com/pappasam/toml-sort
26
- rev: v0.23.1
57
+ rev: v0.24.2
27
58
  hooks:
28
59
  - id: toml-sort-fix
29
60
  args: [--in-place, --spaces-indent-inline-array, '4']
@@ -51,45 +82,18 @@ repos:
51
82
  - id: beautysh
52
83
  args: [--indent-size, '4']
53
84
 
54
- - repo: https://github.com/psf/black
55
- rev: 24.3.0
56
- hooks:
57
- - id: black
58
- - id: black-jupyter
59
-
60
- - repo: https://github.com/pycqa/isort
61
- rev: 5.13.2
62
- hooks:
63
- - id: isort
64
- name: isort (python)
65
- args: [--profile, black, --filter-files]
66
- - id: isort
67
- name: isort (cython)
68
- types: [cython]
69
- args: [--profile, black, --filter-files]
70
- - id: isort
71
- name: isort (pyi)
72
- types: [pyi]
73
- args: [--profile, black, --filter-files]
74
-
75
85
  - repo: https://github.com/asottile/blacken-docs
76
- rev: 1.16.0
86
+ rev: 1.19.1
77
87
  hooks:
78
88
  - id: blacken-docs
79
89
 
80
90
  - repo: https://github.com/asottile/pyupgrade
81
- rev: v3.15.2
91
+ rev: v3.19.1
82
92
  hooks:
83
93
  - id: pyupgrade
84
94
 
85
95
  - repo: https://github.com/commitizen-tools/commitizen
86
- rev: v3.21.3
96
+ rev: v4.1.1
87
97
  hooks:
88
98
  - id: commitizen
89
99
  stages: [commit-msg]
90
-
91
- - repo: https://github.com/mwouts/jupytext
92
- rev: v1.16.1
93
- hooks:
94
- - id: jupytext
95
- args: [--from, ipynb, --to, auto:percent, --sync]
@@ -18,11 +18,6 @@
18
18
  :target: https://pypi.python.org/pypi/toolbox_utils/
19
19
  :height: 20
20
20
 
21
- .. image:: http://img.shields.io/pypi/dd/toolbox_utils.svg
22
- :alt: toolbox_utils downloads
23
- :target: https://pypi.python.org/pypi/toolbox_utils/
24
- :height: 20
25
-
26
21
  .. image:: https://img.shields.io/pypi/pyversions/toolbox_utils
27
22
  :alt: PyPI - Python Version
28
23
  :target: https://pypi.org/project/toolbox_utils/
@@ -1,3 +1,20 @@
1
+ ## v5.2.0 (2025-05-10)
2
+
3
+ ### Feat
4
+
5
+ - added pandas_offset_by_version function
6
+
7
+ ## v5.1.4 (2024-06-24)
8
+
9
+ ### Fix
10
+
11
+ - finally a version of re.split that does what I want
12
+ - remove debugging print function call
13
+ - only use re.split on strings
14
+ - fix issues from removing tssplit
15
+ - fix representation of dataframes as input_ts
16
+ - fix of parsing list in strings
17
+
1
18
  ## v5.1.3 (2024-06-08)
2
19
 
3
20
  ### Fix
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: toolbox_utils
3
- Version: 5.1.3
3
+ Version: 5.2.0
4
4
  Summary: Python toolbox for common utilities
5
5
  Author-email: Tim Cera <tim@cerazone.net>
6
6
  License: BSD-3-Clause
@@ -29,39 +29,15 @@ Requires-Python: >=3.8
29
29
  Description-Content-Type: text/x-rst
30
30
  License-File: LICENSE.txt
31
31
  Requires-Dist: dateparser
32
- Requires-Dist: numpy
32
+ Requires-Dist: numpy<2.0,>=1.20; python_version <= "3.9"
33
+ Requires-Dist: openpyxl
33
34
  Requires-Dist: pandas[excel]
34
- Requires-Dist: pint!=0.21.*
35
- Requires-Dist: pint<0.22; python_version < "3.9"
35
+ Requires-Dist: pint!=0.21.*,<0.22; python_version < "3.9"
36
36
  Requires-Dist: pint-pandas
37
37
  Requires-Dist: pydantic
38
38
  Requires-Dist: scipy
39
39
  Requires-Dist: tabulate
40
- Provides-Extra: dev
41
- Requires-Dist: bandit; extra == "dev"
42
- Requires-Dist: black; extra == "dev"
43
- Requires-Dist: blacken-docs; extra == "dev"
44
- Requires-Dist: black-nbconvert; extra == "dev"
45
- Requires-Dist: cleanpy; extra == "dev"
46
- Requires-Dist: commitizen; extra == "dev"
47
- Requires-Dist: coverage[toml]; extra == "dev"
48
- Requires-Dist: isort; extra == "dev"
49
- Requires-Dist: mypy; extra == "dev"
50
- Requires-Dist: pre-commit; extra == "dev"
51
- Requires-Dist: pyflakes; extra == "dev"
52
- Requires-Dist: pylama; extra == "dev"
53
- Requires-Dist: pyle; extra == "dev"
54
- Requires-Dist: pylint; extra == "dev"
55
- Requires-Dist: pyre; extra == "dev"
56
- Requires-Dist: pyroma; extra == "dev"
57
- Requires-Dist: pytest; extra == "dev"
58
- Requires-Dist: pytest-cov; extra == "dev"
59
- Requires-Dist: pytest-mpl; extra == "dev"
60
- Requires-Dist: pyupgrade; extra == "dev"
61
- Requires-Dist: twine; extra == "dev"
62
- Requires-Dist: unimport; extra == "dev"
63
- Requires-Dist: velin; extra == "dev"
64
- Requires-Dist: vulture; extra == "dev"
40
+ Dynamic: license-file
65
41
 
66
42
  .. image:: https://github.com/timcera/toolbox_utils/actions/workflows/pypi-package.yml/badge.svg
67
43
  :alt: Tests
@@ -83,11 +59,6 @@ Requires-Dist: vulture; extra == "dev"
83
59
  :target: https://pypi.python.org/pypi/toolbox_utils/
84
60
  :height: 20
85
61
 
86
- .. image:: http://img.shields.io/pypi/dd/toolbox_utils.svg
87
- :alt: toolbox_utils downloads
88
- :target: https://pypi.python.org/pypi/toolbox_utils/
89
- :height: 20
90
-
91
62
  .. image:: https://img.shields.io/pypi/pyversions/toolbox_utils
92
63
  :alt: PyPI - Python Version
93
64
  :target: https://pypi.org/project/toolbox_utils/
@@ -18,11 +18,6 @@
18
18
  :target: https://pypi.python.org/pypi/toolbox_utils/
19
19
  :height: 20
20
20
 
21
- .. image:: http://img.shields.io/pypi/dd/toolbox_utils.svg
22
- :alt: toolbox_utils downloads
23
- :target: https://pypi.python.org/pypi/toolbox_utils/
24
- :height: 20
25
-
26
21
  .. image:: https://img.shields.io/pypi/pyversions/toolbox_utils
27
22
  :alt: PyPI - Python Version
28
23
  :target: https://pypi.org/project/toolbox_utils/
@@ -0,0 +1 @@
1
+ 5.2.0
@@ -3,8 +3,7 @@ build-backend = "setuptools.build_meta"
3
3
  requires = [
4
4
  "setuptools>=45",
5
5
  "setuptools_scm[toml]>=6.2",
6
- "wheel",
7
- "oldest-supported-numpy"
6
+ "wheel"
8
7
  ]
9
8
 
10
9
  [project]
@@ -13,10 +12,10 @@ dynamic = ["readme", "version"]
13
12
  description = "Python toolbox for common utilities"
14
13
  dependencies = [
15
14
  "dateparser",
16
- "numpy",
15
+ "numpy >= 1.20, < 2.0 ; python_version <= '3.9'",
16
+ "openpyxl",
17
17
  "pandas[excel]",
18
- "pint!=0.21.*",
19
- "pint<0.22; python_version < '3.9'",
18
+ "pint != 0.21.*, < 0.22 ; python_version < '3.9'",
20
19
  "pint-pandas",
21
20
  "pydantic",
22
21
  "scipy",
@@ -57,57 +56,24 @@ keywords = [
57
56
  license = {text = "BSD-3-Clause"}
58
57
  requires-python = ">=3.8"
59
58
 
60
- [project.optional-dependencies]
61
- dev = [
62
- "bandit",
63
- "black",
64
- "blacken-docs",
65
- "black-nbconvert",
66
- "cleanpy",
67
- "commitizen",
68
- "coverage[toml]",
69
- "isort",
70
- "mypy",
71
- "pre-commit",
72
- "pyflakes",
73
- "pylama",
74
- "pyle",
75
- "pylint",
76
- "pyre",
77
- "pyroma",
78
- "pytest",
79
- "pytest-cov",
80
- "pytest-mpl",
81
- "pyupgrade",
82
- "twine",
83
- "unimport",
84
- "velin",
85
- "vulture"
86
- ]
87
-
88
59
  [project.urls]
89
60
  documentation = "https://timcera.bitbucket.io/toolbox_utils/docs/index.html#toolbox_utils-documentation"
90
61
  github = "https://github.com/timcera/toolbox_utils"
91
62
  bitbucket = "https://bitbucket.org/timcera/toolbox_utils/src/main/"
92
63
 
93
- [tool.check-manifest]
94
- ignore = [
95
- "docs/_function_autosummary/*",
96
- ".coverage",
97
- ".deepsource.toml",
98
- ".ipynb_checkpoints/*"
99
- ]
100
-
101
64
  [tool.commitizen]
102
65
  name = "cz_conventional_commits"
103
66
  tag_format = "v$version"
104
67
  update_changelog_on_bump = true
105
- version = "5.1.3"
68
+ version = "5.2.0"
106
69
  version_files = ["VERSION"]
107
70
 
108
71
  [tool.isort]
109
72
  profile = "black"
110
73
 
74
+ [tool.pytest.ini_options]
75
+ testpaths = ["tests"]
76
+
111
77
  [tool.setuptools]
112
78
  license-files = ["LICENSE.txt"]
113
79
  include-package-data = true
@@ -117,7 +83,6 @@ readme = {file = "README.rst"}
117
83
  version = {file = "VERSION"}
118
84
 
119
85
  [tool.setuptools.packages.find]
120
- exclude = ["tests*", "examples*", "tools*", "docs*", "toolbox_utils.tests*"]
121
86
  where = ["src"]
122
87
 
123
88
  [tool.setuptools_scm]
@@ -6,7 +6,9 @@ import gzip
6
6
  import inspect
7
7
  import os
8
8
  import platform
9
+ import re
9
10
  import sys
11
+ from ast import literal_eval
10
12
  from collections import OrderedDict
11
13
  from contextlib import suppress
12
14
  from functools import reduce, wraps
@@ -46,6 +48,56 @@ from .readers.wdm import wdm_extract as wdm
46
48
  _ = pint_pandas.version("pint")
47
49
 
48
50
 
51
+ def pandas_offset_by_version(new_offset: str) -> str:
52
+ """
53
+ Convert the time offset code to match the version of pandas.
54
+
55
+ Parameters
56
+ ----------
57
+ offset
58
+ The offset to convert.
59
+
60
+ Returns
61
+ -------
62
+ offset_by_version
63
+ The offset converted to the correct version of pandas.
64
+ """
65
+ new_to_old_freq = {}
66
+ major, minor = pd.__version__.split(".")[:2]
67
+ if (int(major) + int(minor) / 10) < 2.2:
68
+ new_to_old_freq = {
69
+ "Y": "A",
70
+ "ME": "M",
71
+ "BME": "BM",
72
+ "SME": "SM",
73
+ "CBME": "CBM",
74
+ "QE": "Q",
75
+ "BQE": "BQ",
76
+ "BYE": "BY",
77
+ "h": "H",
78
+ "bh": "BH",
79
+ "cbh": "CBH",
80
+ "min": "T",
81
+ "s": "S",
82
+ "ms": "L",
83
+ "us": "U",
84
+ "ns": "N",
85
+ "YE-JAN": "A-JAN",
86
+ "YE-FEB": "A-FEB",
87
+ "YE-MAR": "A-MAR",
88
+ "YE-APR": "A-APR",
89
+ "YE-MAY": "A-MAY",
90
+ "YE-JUN": "A-JUN",
91
+ "YE-JUL": "A-JUL",
92
+ "YE-AUG": "A-AUG",
93
+ "YE-SEP": "A-SEP",
94
+ "YE-OCT": "A-OCT",
95
+ "YE-NOV": "A-NOV",
96
+ "YE-DEC": "A-DEC",
97
+ }
98
+ return new_to_old_freq.get(new_offset, new_offset)
99
+
100
+
49
101
  def normalize_command_line_args(args: List) -> List:
50
102
  """
51
103
  Normalize command line arguments.
@@ -1718,21 +1770,21 @@ def asbestfreq(data: DataFrame, force_freq: Optional[str] = None) -> DataFrame:
1718
1770
  # At this point pd.infer_freq failed probably because of missing values.
1719
1771
  # The following algorithm would not capture things like BQ, BQS
1720
1772
  # ...etc.
1721
- if np.alltrue(data.index.is_year_end):
1773
+ if np.all(data.index.is_year_end):
1722
1774
  infer_freq = "A"
1723
- elif np.alltrue(data.index.is_year_start):
1775
+ elif np.all(data.index.is_year_start):
1724
1776
  infer_freq = "AS"
1725
- elif np.alltrue(data.index.is_quarter_end):
1777
+ elif np.all(data.index.is_quarter_end):
1726
1778
  infer_freq = "Q"
1727
- elif np.alltrue(data.index.is_quarter_start):
1779
+ elif np.all(data.index.is_quarter_start):
1728
1780
  infer_freq = "QS"
1729
- elif np.alltrue(data.index.is_month_end):
1781
+ elif np.all(data.index.is_month_end):
1730
1782
  if np.all(data.index.month == data.index[0].month):
1731
1783
  # Actually yearly with different ends
1732
1784
  infer_freq = f"A-{_ANNUALS[data.index[0].month]}"
1733
1785
  else:
1734
1786
  infer_freq = "M"
1735
- elif np.alltrue(data.index.is_month_start):
1787
+ elif np.all(data.index.is_month_start):
1736
1788
  if np.all(data.index.month == data.index[0].month):
1737
1789
  # Actually yearly with different start
1738
1790
  infer_freq = f"A-{_ANNUALS[data.index[0].month - 1]}"
@@ -2244,7 +2296,6 @@ def read_iso_ts(
2244
2296
 
2245
2297
  # Would want this to be more generic...
2246
2298
  na_values = []
2247
-
2248
2299
  for spc in range(20)[1:]:
2249
2300
  spcs = " " * spc
2250
2301
  na_values.extend([spcs, f"{spcs}nan"])
@@ -2270,7 +2321,10 @@ def read_iso_ts(
2270
2321
  stdin_df = pd.DataFrame()
2271
2322
  for source_index, source in enumerate(sources):
2272
2323
  res = pd.DataFrame()
2273
- parameters = make_list(source)
2324
+ if isinstance(source, str):
2325
+ parameters = re.split(r",(?![^\[]*\])", source)
2326
+ else:
2327
+ parameters = make_list(source)
2274
2328
 
2275
2329
  if isinstance(parameters, list) and parameters:
2276
2330
  fname = parameters.pop(0)
@@ -2294,6 +2348,7 @@ def read_iso_ts(
2294
2348
  args = [i for i in parameters if "=" not in i]
2295
2349
 
2296
2350
  newkwds = dict([i.split("=") for i in parameters if "=" in i])
2351
+ newkwds = {k: literal_eval(v) for k, v in newkwds.items()}
2297
2352
 
2298
2353
  # Command line API
2299
2354
  # Uses hspf_reader or pd.read_* functions.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: toolbox_utils
3
- Version: 5.1.3
3
+ Version: 5.2.0
4
4
  Summary: Python toolbox for common utilities
5
5
  Author-email: Tim Cera <tim@cerazone.net>
6
6
  License: BSD-3-Clause
@@ -29,39 +29,15 @@ Requires-Python: >=3.8
29
29
  Description-Content-Type: text/x-rst
30
30
  License-File: LICENSE.txt
31
31
  Requires-Dist: dateparser
32
- Requires-Dist: numpy
32
+ Requires-Dist: numpy<2.0,>=1.20; python_version <= "3.9"
33
+ Requires-Dist: openpyxl
33
34
  Requires-Dist: pandas[excel]
34
- Requires-Dist: pint!=0.21.*
35
- Requires-Dist: pint<0.22; python_version < "3.9"
35
+ Requires-Dist: pint!=0.21.*,<0.22; python_version < "3.9"
36
36
  Requires-Dist: pint-pandas
37
37
  Requires-Dist: pydantic
38
38
  Requires-Dist: scipy
39
39
  Requires-Dist: tabulate
40
- Provides-Extra: dev
41
- Requires-Dist: bandit; extra == "dev"
42
- Requires-Dist: black; extra == "dev"
43
- Requires-Dist: blacken-docs; extra == "dev"
44
- Requires-Dist: black-nbconvert; extra == "dev"
45
- Requires-Dist: cleanpy; extra == "dev"
46
- Requires-Dist: commitizen; extra == "dev"
47
- Requires-Dist: coverage[toml]; extra == "dev"
48
- Requires-Dist: isort; extra == "dev"
49
- Requires-Dist: mypy; extra == "dev"
50
- Requires-Dist: pre-commit; extra == "dev"
51
- Requires-Dist: pyflakes; extra == "dev"
52
- Requires-Dist: pylama; extra == "dev"
53
- Requires-Dist: pyle; extra == "dev"
54
- Requires-Dist: pylint; extra == "dev"
55
- Requires-Dist: pyre; extra == "dev"
56
- Requires-Dist: pyroma; extra == "dev"
57
- Requires-Dist: pytest; extra == "dev"
58
- Requires-Dist: pytest-cov; extra == "dev"
59
- Requires-Dist: pytest-mpl; extra == "dev"
60
- Requires-Dist: pyupgrade; extra == "dev"
61
- Requires-Dist: twine; extra == "dev"
62
- Requires-Dist: unimport; extra == "dev"
63
- Requires-Dist: velin; extra == "dev"
64
- Requires-Dist: vulture; extra == "dev"
40
+ Dynamic: license-file
65
41
 
66
42
  .. image:: https://github.com/timcera/toolbox_utils/actions/workflows/pypi-package.yml/badge.svg
67
43
  :alt: Tests
@@ -83,11 +59,6 @@ Requires-Dist: vulture; extra == "dev"
83
59
  :target: https://pypi.python.org/pypi/toolbox_utils/
84
60
  :height: 20
85
61
 
86
- .. image:: http://img.shields.io/pypi/dd/toolbox_utils.svg
87
- :alt: toolbox_utils downloads
88
- :target: https://pypi.python.org/pypi/toolbox_utils/
89
- :height: 20
90
-
91
62
  .. image:: https://img.shields.io/pypi/pyversions/toolbox_utils
92
63
  :alt: PyPI - Python Version
93
64
  :target: https://pypi.org/project/toolbox_utils/
@@ -0,0 +1,13 @@
1
+ dateparser
2
+ openpyxl
3
+ pandas[excel]
4
+ pint-pandas
5
+ pydantic
6
+ scipy
7
+ tabulate
8
+
9
+ [:python_version < "3.9"]
10
+ pint!=0.21.*,<0.22
11
+
12
+ [:python_version <= "3.9"]
13
+ numpy<2.0,>=1.20
@@ -1,6 +1,7 @@
1
1
  import pandas as pd
2
2
  import pytest
3
3
  from pandas._libs.tslibs.parsing import DateParseError
4
+ from pandas.errors import ParserError
4
5
 
5
6
 
6
7
  @pytest.mark.parametrize(
@@ -56,14 +57,14 @@ from pandas._libs.tslibs.parsing import DateParseError
56
57
  "invalid_date",
57
58
  "2020-12-31",
58
59
  False,
59
- DateParseError,
60
+ (ValueError, ParserError, DateParseError),
60
61
  ),
61
62
  (
62
63
  pd.DataFrame(index=pd.date_range("2020-01-01", "2020-12-31")),
63
64
  "2020-01-01",
64
65
  "invalid_date",
65
66
  False,
66
- DateParseError,
67
+ (ValueError, ParserError, DateParseError),
67
68
  ),
68
69
  ],
69
70
  ids=[
@@ -88,7 +89,9 @@ def test_date_slice(input_tsd, start_date, end_date, por, expected):
88
89
  input_tsd = pd.DataFrame(index=pd.to_datetime(input_tsd.index))
89
90
 
90
91
  # Act
91
- if isinstance(expected, type) and issubclass(expected, Exception):
92
+ if isinstance(expected, tuple) or (
93
+ isinstance(expected, type) and issubclass(expected, Exception)
94
+ ):
92
95
  with pytest.raises(expected):
93
96
  _date_slice(input_tsd, start_date, end_date, por)
94
97
  else:
@@ -1,5 +1,5 @@
1
1
  """
2
- catalog
2
+ hbn
3
3
  ----------------------------------
4
4
 
5
5
  Tests for `hspf_reader hbn` module.
@@ -11,7 +11,7 @@ from unittest import TestCase
11
11
  import pandas as pd
12
12
  from pandas.testing import assert_frame_equal
13
13
 
14
- from toolbox_utils import tsutils
14
+ import toolbox_utils
15
15
 
16
16
 
17
17
  class TestDescribe(TestCase):
@@ -69,11 +69,19 @@ class TestDescribe(TestCase):
69
69
  1999,1.40244
70
70
  2000,0.0191165
71
71
  """
72
- self.extract = tsutils.asbestfreq(
72
+ self.extract = toolbox_utils.tsutils.asbestfreq(
73
73
  pd.read_csv(BytesIO(self.extract), header=0, index_col=0, parse_dates=True)
74
74
  )
75
75
  self.extract.index = self.extract.index.to_period()
76
76
 
77
77
  def test_extract_one_label_labellist_api(self):
78
- out = tsutils.common_kwds("tests/data_yearly.hbn,yearly,,905,,AGWS")
78
+ out = toolbox_utils.tsutils.common_kwds(
79
+ "tests/data_yearly.hbn,yearly,,905,,AGWS"
80
+ )
81
+ assert_frame_equal(out, self.extract, check_dtype=False)
82
+
83
+ def test_extract_one_label_labellist_api_2(self):
84
+ out = toolbox_utils.readers.hbn.hbn_extract(
85
+ "tests/data_yearly.hbn", "yearly", ["", 905, "", "AGWS"]
86
+ )
79
87
  assert_frame_equal(out, self.extract, check_dtype=False)
@@ -1,11 +0,0 @@
1
- ---
2
- version: 2
3
- updates:
4
- - package-ecosystem: github-actions
5
- directory: /
6
- schedule:
7
- interval: weekly
8
- ignore:
9
- # Optional: Official actions have moving tags like v1;
10
- # if you use those, you don't need updates.
11
- - dependency-name: actions/*
@@ -1,91 +0,0 @@
1
- ---
2
- # This workflow will install Python dependencies, run tests and lint with
3
- # a variety of Python versions For more information see:
4
- # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
5
-
6
- name: PyPI package tests
7
-
8
- on: # yamllint disable-line rule:truthy
9
- push:
10
- branches: [main]
11
- pull_request:
12
- branches: [main]
13
- workflow_dispatch:
14
-
15
- jobs:
16
- test:
17
- name: Test on Python ${{ matrix.python-version }}
18
- runs-on: ubuntu-latest
19
- strategy:
20
- fail-fast: false
21
- matrix:
22
- python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
23
-
24
- steps:
25
- - name: Checkout repository
26
- uses: actions/checkout@v4
27
- with:
28
- submodules: recursive
29
-
30
- - name: Set up Python ${{ matrix.python-version }}
31
- uses: actions/setup-python@v4
32
- with:
33
- python-version: ${{ matrix.python-version }}
34
-
35
- - name: Install dependencies
36
- run: |
37
- sudo apt-get update
38
- python -m pip install --upgrade pip
39
- python -m pip install pytest pytest-cov pytest-mpl
40
- python -m pip install -e .
41
-
42
- - name: Test with pytest
43
- run: |
44
- python -m pytest --cov --mpl
45
-
46
- - name: Upload coverage data to coveralls.io
47
- uses: coverallsapp/github-action@v2
48
- with:
49
- parallel: true
50
-
51
- finish_coveralls:
52
- needs: test
53
- if: ${{ always() }}
54
- runs-on: ubuntu-latest
55
- steps:
56
- - name: Coveralls Finished
57
- uses: coverallsapp/github-action@v2
58
- with:
59
- parallel-finished: true
60
-
61
- pypi-publish:
62
- needs: test
63
- runs-on: ubuntu-latest
64
- environment: release
65
- name: upload release to PyPI
66
-
67
- permissions:
68
- # IMPORTANT: this permission is mandatory for trusted publishing
69
- id-token: write
70
-
71
- steps:
72
- - name: Checkout source
73
- uses: actions/checkout@v4
74
- with:
75
- submodules: recursive
76
-
77
- - name: Build sdist and wheel
78
- run: |
79
- python -m pip install build
80
- python -m build
81
-
82
- - name: Download artifact
83
- uses: actions/download-artifact@v4
84
- with:
85
- path: dist
86
- merge-multiple: true
87
-
88
- - name: Publish package distributions to PyPI
89
- uses: pypa/gh-action-pypi-publish@release/v1
90
- with:
91
- skip-existing: true
@@ -1,58 +0,0 @@
1
- ---
2
- # This workflow will install Python dependencies, run tests and lint with
3
- # a variety of Python versions For more information see:
4
- # https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
5
-
6
- name: Tests
7
-
8
- on: # yamllint disable-line rule:truthy
9
- push:
10
- branches: [develop]
11
- pull_request:
12
- branches: [develop]
13
- workflow_dispatch:
14
-
15
- jobs:
16
- test:
17
- runs-on: ubuntu-latest
18
- strategy:
19
- fail-fast: false
20
- matrix:
21
- python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
22
-
23
- steps:
24
- - name: Checkout repository
25
- uses: actions/checkout@v3
26
- with:
27
- submodules: recursive
28
-
29
- - name: Set up Python ${{ matrix.python-version }}
30
- uses: actions/setup-python@v4
31
- with:
32
- python-version: ${{ matrix.python-version }}
33
-
34
- - name: Install dependencies
35
- run: |
36
- sudo apt-get update
37
- python -m pip install --upgrade pip
38
- python -m pip install pytest pytest-cov pytest-mpl
39
- python -m pip install .
40
-
41
- - name: Test with pytest
42
- run: |
43
- python -m pytest --cov --mpl
44
-
45
- - name: Upload coverage data to coveralls.io
46
- uses: coverallsapp/github-action@v2
47
- with:
48
- parallel: true
49
-
50
- finish:
51
- needs: test
52
- if: ${{ always() }}
53
- runs-on: ubuntu-latest
54
- steps:
55
- - name: Coveralls Finished
56
- uses: coverallsapp/github-action@v2
57
- with:
58
- parallel-finished: true
@@ -1 +0,0 @@
1
- 5.1.3
@@ -1,37 +0,0 @@
1
- dateparser
2
- numpy
3
- pandas[excel]
4
- pint!=0.21.*
5
- pint-pandas
6
- pydantic
7
- scipy
8
- tabulate
9
-
10
- [:python_version < "3.9"]
11
- pint<0.22
12
-
13
- [dev]
14
- bandit
15
- black
16
- blacken-docs
17
- black-nbconvert
18
- cleanpy
19
- commitizen
20
- coverage[toml]
21
- isort
22
- mypy
23
- pre-commit
24
- pyflakes
25
- pylama
26
- pyle
27
- pylint
28
- pyre
29
- pyroma
30
- pytest
31
- pytest-cov
32
- pytest-mpl
33
- pyupgrade
34
- twine
35
- unimport
36
- velin
37
- vulture
File without changes
File without changes
File without changes
File without changes