csdigit 0.3__tar.gz → 0.5__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. {csdigit-0.3 → csdigit-0.5}/.github/workflows/ci.yml +4 -4
  2. {csdigit-0.3 → csdigit-0.5}/.github/workflows/multi-platforms.yml +1 -1
  3. {csdigit-0.3 → csdigit-0.5}/.github/workflows/python-app.yml +3 -3
  4. {csdigit-0.3 → csdigit-0.5}/.github/workflows/python-package.yml +2 -2
  5. {csdigit-0.3 → csdigit-0.5}/.gitignore +4 -0
  6. csdigit-0.5/AGENTS.md +140 -0
  7. csdigit-0.5/CHANGELOG.md +42 -0
  8. {csdigit-0.3/src/csdigit.egg-info → csdigit-0.5}/PKG-INFO +5 -5
  9. csdigit-0.5/benches/bench_csd.py +21 -0
  10. csdigit-0.5/benches/verify_output.py +52 -0
  11. csdigit-0.5/compare-py-cpp-rs.md +513 -0
  12. {csdigit-0.3 → csdigit-0.5}/docs/conf.py +1 -0
  13. csdigit-0.5/docs/examples/plot_csd_conversion.py +20 -0
  14. csdigit-0.5/docs/examples/plot_csd_distribution.py +30 -0
  15. csdigit-0.5/docs/figures_demo.md +25 -0
  16. {csdigit-0.3 → csdigit-0.5}/docs/index.md +1 -0
  17. csdigit-0.5/mypy.ini +6 -0
  18. {csdigit-0.3 → csdigit-0.5}/setup.cfg +4 -6
  19. csdigit-0.5/src/csdigit/__init__.py +10 -0
  20. {csdigit-0.3 → csdigit-0.5}/src/csdigit/cli.py +0 -6
  21. {csdigit-0.3 → csdigit-0.5}/src/csdigit/csd.py +23 -47
  22. {csdigit-0.3 → csdigit-0.5}/src/csdigit/csd_multiplier.py +92 -41
  23. {csdigit-0.3 → csdigit-0.5}/src/csdigit/lcsre.py +0 -5
  24. {csdigit-0.3 → csdigit-0.5/src/csdigit.egg-info}/PKG-INFO +5 -5
  25. {csdigit-0.3 → csdigit-0.5}/src/csdigit.egg-info/SOURCES.txt +9 -1
  26. {csdigit-0.3 → csdigit-0.5}/src/csdigit.egg-info/requires.txt +0 -3
  27. csdigit-0.5/src/csdigit.egg-info/scm_file_list.json +81 -0
  28. csdigit-0.5/src/csdigit.egg-info/scm_version.json +8 -0
  29. {csdigit-0.3 → csdigit-0.5}/src/pycsd/dev/csd_numbers.py +0 -2
  30. {csdigit-0.3 → csdigit-0.5}/src/pycsd/run_tests.py +1 -1
  31. csdigit-0.5/src/pycsd/test/__init__.py +3 -0
  32. {csdigit-0.3 → csdigit-0.5}/src/pycsd/test/decimal_tests.py +2 -2
  33. {csdigit-0.3 → csdigit-0.5}/tests/test_csd_multiplier.py +78 -0
  34. csdigit-0.3/CHANGELOG.md +0 -7
  35. csdigit-0.3/IFLOW.md +0 -75
  36. csdigit-0.3/mypy.ini +0 -21
  37. csdigit-0.3/src/csdigit/__init__.py +0 -16
  38. csdigit-0.3/src/pycsd/test/__init__.py +0 -3
  39. {csdigit-0.3 → csdigit-0.5}/.coveragerc +0 -0
  40. {csdigit-0.3 → csdigit-0.5}/.github/workflows/codecov.yml +0 -0
  41. {csdigit-0.3 → csdigit-0.5}/.github/workflows/jekyll-gh-pages.yml +0 -0
  42. {csdigit-0.3 → csdigit-0.5}/.github/workflows/python-publish.yml +0 -0
  43. {csdigit-0.3 → csdigit-0.5}/.isort.cfg +0 -0
  44. {csdigit-0.3 → csdigit-0.5}/.pre-commit-config.yaml +0 -0
  45. {csdigit-0.3 → csdigit-0.5}/.readthedocs.yml +0 -0
  46. {csdigit-0.3 → csdigit-0.5}/.vscode/settings.json +0 -0
  47. {csdigit-0.3 → csdigit-0.5}/AUTHORS.md +0 -0
  48. {csdigit-0.3 → csdigit-0.5}/CONTRIBUTING.md +0 -0
  49. {csdigit-0.3 → csdigit-0.5}/GEMINI.md +0 -0
  50. {csdigit-0.3 → csdigit-0.5}/LICENSE.txt +0 -0
  51. {csdigit-0.3 → csdigit-0.5}/README.md +0 -0
  52. {csdigit-0.3 → csdigit-0.5}/_config.yml +0 -0
  53. {csdigit-0.3 → csdigit-0.5}/benches/test_bench.py +0 -0
  54. {csdigit-0.3 → csdigit-0.5}/docs/Makefile +0 -0
  55. {csdigit-0.3 → csdigit-0.5}/docs/_static/.gitignore +0 -0
  56. {csdigit-0.3 → csdigit-0.5}/docs/authors.md +0 -0
  57. {csdigit-0.3 → csdigit-0.5}/docs/changelog.md +0 -0
  58. {csdigit-0.3 → csdigit-0.5}/docs/contributing.md +0 -0
  59. {csdigit-0.3 → csdigit-0.5}/docs/license.md +0 -0
  60. {csdigit-0.3 → csdigit-0.5}/docs/readme.md +0 -0
  61. {csdigit-0.3 → csdigit-0.5}/docs/requirements.txt +0 -0
  62. {csdigit-0.3 → csdigit-0.5}/environment.yml +0 -0
  63. {csdigit-0.3 → csdigit-0.5}/experiments/notes.md +0 -0
  64. {csdigit-0.3 → csdigit-0.5}/experiments/random_gen.py +0 -0
  65. {csdigit-0.3 → csdigit-0.5}/pyproject.toml +0 -0
  66. {csdigit-0.3 → csdigit-0.5}/requirements/README.md +0 -0
  67. {csdigit-0.3 → csdigit-0.5}/requirements/default.txt +0 -0
  68. {csdigit-0.3 → csdigit-0.5}/requirements/doc.txt +0 -0
  69. {csdigit-0.3 → csdigit-0.5}/requirements/extras.txt +0 -0
  70. {csdigit-0.3 → csdigit-0.5}/requirements/test.txt +0 -0
  71. {csdigit-0.3 → csdigit-0.5}/requirements.txt +0 -0
  72. {csdigit-0.3 → csdigit-0.5}/setup.py +0 -0
  73. {csdigit-0.3 → csdigit-0.5}/src/csdigit/py.typed +0 -0
  74. {csdigit-0.3 → csdigit-0.5}/src/csdigit.egg-info/dependency_links.txt +0 -0
  75. {csdigit-0.3 → csdigit-0.5}/src/csdigit.egg-info/not-zip-safe +0 -0
  76. {csdigit-0.3 → csdigit-0.5}/src/csdigit.egg-info/top_level.txt +0 -0
  77. {csdigit-0.3 → csdigit-0.5}/src/pycsd/README +0 -0
  78. {csdigit-0.3 → csdigit-0.5}/src/pycsd/__init__.py +0 -0
  79. {csdigit-0.3 → csdigit-0.5}/src/pycsd/csd/__init__.py +0 -0
  80. {csdigit-0.3 → csdigit-0.5}/src/pycsd/csd/csd.py +0 -0
  81. {csdigit-0.3 → csdigit-0.5}/src/pycsd/csd_orig.py +0 -0
  82. {csdigit-0.3 → csdigit-0.5}/src/pycsd/from_csd +0 -0
  83. {csdigit-0.3 → csdigit-0.5}/src/pycsd/test/test_csd_decimals.py +0 -0
  84. {csdigit-0.3 → csdigit-0.5}/src/pycsd/test/test_csd_integers.py +0 -0
  85. {csdigit-0.3 → csdigit-0.5}/src/pycsd/test/test_to_and_fro_10bits.py +0 -0
  86. {csdigit-0.3 → csdigit-0.5}/src/pycsd/to_csd +0 -0
  87. {csdigit-0.3 → csdigit-0.5}/tests/conftest.py +0 -0
  88. {csdigit-0.3 → csdigit-0.5}/tests/test_cli.py +0 -0
  89. {csdigit-0.3 → csdigit-0.5}/tests/test_csd.py +0 -0
  90. {csdigit-0.3 → csdigit-0.5}/tests/test_lcsre.py +0 -0
  91. {csdigit-0.3 → csdigit-0.5}/tox.ini +0 -0
@@ -32,9 +32,9 @@ jobs:
32
32
  outputs:
33
33
  wheel-distribution: ${{ steps.wheel-distribution.outputs.path }}
34
34
  steps:
35
- - uses: actions/checkout@v3
35
+ - uses: actions/checkout@v4
36
36
  with: { fetch-depth: 0 } # deep clone for setuptools-scm
37
- - uses: actions/setup-python@v4
37
+ - uses: actions/setup-python@v5
38
38
  id: setup-python
39
39
  with: { python-version: "3.11" }
40
40
  # - name: Run static analysis and format checkers
@@ -68,8 +68,8 @@ jobs:
68
68
  - windows-latest
69
69
  runs-on: ${{ matrix.platform }}
70
70
  steps:
71
- - uses: actions/checkout@v3
72
- - uses: actions/setup-python@v4
71
+ - uses: actions/checkout@v4
72
+ - uses: actions/setup-python@v5
73
73
  id: setup-python
74
74
  with:
75
75
  python-version: ${{ matrix.python }}
@@ -10,7 +10,7 @@ jobs:
10
10
  os: ["ubuntu-latest", "windows-latest"]
11
11
  version: ["3.10", "3.12"]
12
12
  steps:
13
- - uses: actions/checkout@v3
13
+ - uses: actions/checkout@v4
14
14
  - uses: conda-incubator/setup-miniconda@v3
15
15
  with:
16
16
  activate-environment: test
@@ -14,9 +14,9 @@ jobs:
14
14
  runs-on: ubuntu-latest
15
15
 
16
16
  steps:
17
- - uses: actions/checkout@v2
17
+ - uses: actions/checkout@v4
18
18
  - name: Set up Python 3.9
19
- uses: actions/setup-python@v2
19
+ uses: actions/setup-python@v5
20
20
  with:
21
21
  python-version: 3.9
22
22
  - name: Install dependencies
@@ -37,7 +37,7 @@ jobs:
37
37
  - name: Codecov
38
38
  # You may pin to the exact commit or the version.
39
39
  # uses: codecov/codecov-action@29386c70ef20e286228c72b668a06fd0e8399192
40
- uses: codecov/codecov-action@v1.5.2
40
+ uses: codecov/codecov-action@v4
41
41
  with:
42
42
  # Repository upload token - get it from codecov.io. Required only for private repositories
43
43
  token: ${{ secrets.CODECOV_TOKEN }}
@@ -18,9 +18,9 @@ jobs:
18
18
  python-version: ["3.10", "3.12"]
19
19
 
20
20
  steps:
21
- - uses: actions/checkout@v2
21
+ - uses: actions/checkout@v4
22
22
  - name: Set up Python ${{ matrix.python-version }}
23
- uses: actions/setup-python@v2
23
+ uses: actions/setup-python@v5
24
24
  with:
25
25
  python-version: ${{ matrix.python-version }}
26
26
  - name: Install dependencies
@@ -176,3 +176,7 @@ MANIFEST
176
176
 
177
177
  # my stuffs
178
178
  .hypothesis
179
+
180
+ # Cache dirs
181
+ .ruff_cache/
182
+ .benchmarks/
csdigit-0.5/AGENTS.md ADDED
@@ -0,0 +1,140 @@
1
+ # AGENTS.md - Agent Guidelines for csdigit
2
+
3
+ ## Build, Lint, and Test Commands
4
+
5
+ ### Testing
6
+ ```bash
7
+ # Run all tests
8
+ pytest
9
+
10
+ # Run a single test file
11
+ pytest tests/test_csd.py
12
+
13
+ # Run a single test function
14
+ pytest tests/test_csd.py::test_csd_special
15
+
16
+ # Run tests matching a pattern
17
+ pytest -k "to_csdnnz"
18
+
19
+ # Run with coverage
20
+ pytest --cov csdigit --cov-report term-missing
21
+
22
+ # Run with hypothesis and pytest-benchmark (both in testing extras)
23
+ pytest --benchmark-only
24
+ ```
25
+
26
+ Note: `addopts` in `setup.cfg` is commented out — coverage/verbose are NOT enabled by default, so pass `--cov` explicitly.
27
+
28
+ ### Linting and Formatting
29
+ ```bash
30
+ # Run all pre-commit hooks (recommended before committing)
31
+ pre-commit run --all-files
32
+
33
+ # Individual tools
34
+ black src/csdigit tests/ # Format code
35
+ isort src/csdigit tests/ # Sort imports (black profile)
36
+ flake8 src/ tests/ # Lint (max line length: 256)
37
+ mypy src/ # Type check (Python 3.12 target)
38
+ ```
39
+
40
+ ### Build
41
+ ```bash
42
+ tox -e build # Build sdist + wheel
43
+ tox -e clean # Remove build artifacts
44
+ ```
45
+
46
+ ### Documentation
47
+ ```bash
48
+ tox -e docs # Build HTML docs
49
+ tox -e doctests # Run doctests
50
+ tox -e linkcheck # Check broken links
51
+ ```
52
+
53
+ ## Code Style Guidelines
54
+
55
+ ### Imports
56
+ - **Order**: stdlib → third-party → local (enforced by isort)
57
+ - **Tooling**: isort with Black profile (`.isort.cfg`, `known_first_party = csdigit`)
58
+ - Type hints from `typing` module: `List`, `Sequence`, `Tuple`, `Union`
59
+
60
+ ### Formatting
61
+ - **Formatter**: Black (23.7.0)
62
+ - **Line length**: 256 characters (configured in setup.cfg)
63
+ - **Linting**: flake8 ignores E203, W503 (Black-compatible)
64
+ - **Pre-commit**: Enforced via `.pre-commit-config.yaml`
65
+
66
+ ### Type Hints
67
+ - **Required**: All function parameters and return types
68
+ - **Style**: `param: type`, `-> ReturnType` (e.g., `def to_csd(decimal_value: float, places: int) -> str`)
69
+
70
+ ### Naming Conventions
71
+ - **Functions**: snake_case (e.g., `to_csd`, `to_csdnnz`, `longest_repeated_substring`)
72
+ - **Private helpers**: Prefix with underscore (e.g., `_csd_str_to_int`)
73
+ - **Variables**: lowercase_with_underscores
74
+ - **Constants**: UPPER_CASE
75
+
76
+ ### Docstrings
77
+ - **Style**: Sphinx/reStructuredText with `:param:`, `:type:`, `:return:`
78
+ - **Examples**: Include `>>>` doctest examples in every public function
79
+ - **Module docs**: Start with a descriptive module docstring
80
+ ```python
81
+ def to_csd(decimal_value: float, places: int) -> str:
82
+ """
83
+ The `to_csd` function converts a given decimal number to its Canonical Signed Digit (CSD)
84
+ representation with a specified number of decimal places.
85
+
86
+ :param decimal_value: The decimal value to be converted
87
+ :type decimal_value: float
88
+ :param places: The number of decimal places to include
89
+ :type places: int
90
+ :return: CSD string representation
91
+
92
+ Examples:
93
+ >>> to_csd(28.5, 2)
94
+ '+00-00.+0'
95
+ """
96
+ ```
97
+
98
+ ### Error Handling
99
+ - **Pattern**: Log-and-continue for invalid CSD characters, not exceptions
100
+ ```python
101
+ else:
102
+ logging.info(f"Encounter unknown character {digit}")
103
+ ```
104
+ - **Deprecation**: Mark old functions with `.. deprecated::` (e.g., `to_decimal_using_pow`)
105
+ - **Testing**: Use `caplog` to assert log messages and `pytest.raises` for exceptions
106
+
107
+ ### Testing Patterns
108
+ - **Framework**: pytest with hypothesis property-based tests and pytest-benchmark
109
+ - **Coverage**: `.coveragerc` with branch coverage, `source = csdigit`
110
+ - **Naming**: `test_*` prefix with descriptive names
111
+ - **Hypothesis**: Use `given`/`assume` for round-trip properties
112
+ ```python
113
+ def test_csd_special() -> None:
114
+ number = -342343593459544395894535439534985
115
+ assert number == to_decimal(to_csd_i(number))
116
+ ```
117
+
118
+ ### Pre-commit Hooks
119
+ - trailing-whitespace, check-added-large-files, check-ast, check-json,
120
+ check-merge-conflict, check-xml, check-yaml, debug-statements,
121
+ end-of-file-fixer, requirements-txt-fixer, mixed-line-ending,
122
+ isort (5.12.0), black (23.7.0), flake8 (6.1.0)
123
+ - Excludes `docs/conf.py` and `src/pycsd/`
124
+
125
+ ### Configuration Files
126
+ - `setup.cfg`: Package metadata, flake8 settings (line length 256)
127
+ - `pyproject.toml`: Build system (setuptools_scm)
128
+ - `tox.ini`: Test environments (default, build, clean, docs, doctests, linkcheck, publish)
129
+ - `.isort.cfg`: Import sorting (Black profile, `known_first_party = csdigit`)
130
+ - `mypy.ini`: Type checking (Python 3.12)
131
+ - `.coveragerc`: Branch coverage config
132
+
133
+ ## Key Project Context
134
+
135
+ csdigit is a Canonical Signed Digit (CSD) conversion library:
136
+ - **Core functions**: `to_csd`, `to_csd_i`, `to_csdnnz`, `to_csdnnz_i` (decimal → CSD), `to_decimal`, `to_decimal_using_pow` (CSD → decimal)
137
+ - **CSD multiplier**: `csd_multiplier.py` generates hardware multiplier Verilog from CSD strings, using `lcsre.py` (longest repeated substring) for sub-expression sharing
138
+ - **CLI**: Available via `python -m csdigit.cli` (no console_scripts entry point)
139
+ - **Key dependencies**: None at runtime (pure stdlib: `logging`, `math`); `hypothesis` + `pytest-benchmark` for testing
140
+ - **Used by**: [multiplierless](https://github.com/luk036/multiplierless)
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ ## Version 0.5 (2026-10-09)
4
+
5
+ ### Bug Fixes
6
+ - **Package metadata**: Replaced the PyScaffold placeholder description and URLs in `setup.cfg` with the real csdigit project info. (#78f1f81)
7
+ - **Ruff warnings**: Resolved F403/E402/F821 warnings in the test files. (#9444e6f)
8
+ - **mypy config**: Removed the duplicate `ignore_missing_imports` entry from `mypy.ini`. (#ec86626)
9
+
10
+ ### Testing & Code Quality
11
+ - **Multiplier tests**: Added `tests/test_csd_multiplier.py` (+78 lines) covering the CSD multiplier generators. (#64e3603)
12
+
13
+ ### Code Cleanup
14
+ - **`MultiplierSpec` + shared `validate_csd`**: Introduced a `MultiplierSpec` parameter object and a single `validate_csd` helper so `generate_csd_multipliers` no longer takes bare positional tuples and both generators share one CSD format rule (legacy tuples still accepted). (#64e3603)
15
+ - **Simplified `to_decimal()`**: Extracted the duplicated parsing logic into a `_csd_str_to_int` helper. (#1f6e397)
16
+ - **Removed AI slop**: Stripped boilerplate from docstrings and comments and removed unused imports from the benchmark files. (#70b8612, #17d9897)
17
+ - **Formatting**: Formatted the benchmark files with black. (#e5f5873)
18
+
19
+ ### Documentation
20
+ - **AGENTS.md**: Added agent guidelines for the repository. (#f6d7977)
21
+ - **Python/C++/Rust comparison**: Added `compare-py-cpp-rs.md`. (#ec86626)
22
+
23
+ ### Build & CI
24
+ - **Updated GitHub Actions**: `checkout`→v4, `setup-python`→v5, `codecov-action`→v4. (#e7bd7f3)
25
+
26
+ ## Version 0.4 (2026-07-16)
27
+
28
+ ### Documentation
29
+ - **Sphinx docs with plot_directive and svgbob**: Enabled matplotlib `plot_directive` for auto-generated figures and `sphinxcontrib.svgbob` for ASCII-to-SVG diagrams. Added CSD distribution and conversion example plots under `docs/examples/`. Added svgbob diagram to `csd.py` module docstring. (#a6e57f8)
30
+
31
+ ### Code Cleanup
32
+ - **Removed PyScaffold boilerplate**: Deleted `skeleton.py` and `test_skeleton.py` (unused Fibonacci CLI scaffold). (#27813b4)
33
+ - **Dropped Python < 3.9 compat**: Removed `importlib-metadata` conditional dependency and compat guard from `__init__.py` (project now targets 3.10+). (#27813b4)
34
+ - **Config cleanup**: Removed dead `fibonacci = skeleton:run` entry point from `setup.cfg` and unused `ignore_missing_imports` from `mypy.ini`. (#27813b4)
35
+ - **Removed stale files**: Deleted `IFLOW.md` and duplicate `LICENSE`. (#27813b4)
36
+ - **Updated `.gitignore`**: Added `.ruff_cache/` and `.benchmarks/`. (#27813b4)
37
+
38
+ ### Build & CI
39
+ - **CI repair**: Fixed broken `entry_points` configuration and lingering `skeleton` imports breaking the CI pipeline. (#0b2459b)
40
+
41
+ ### Testing & Code Quality
42
+ - **Benchmark & verification scripts**: Added `benches/bench_csd.py` and `benches/verify_output.py` for performance tracking and output verification. (#09da08a)
@@ -1,18 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: csdigit
3
- Version: 0.3
4
- Summary: Add a short description here!
5
- Home-page: https://github.com/pyscaffold/pyscaffold/
3
+ Version: 0.5
4
+ Summary: Canonical Signed Digit Conversion in Python
5
+ Home-page: https://github.com/luk036/csdigit
6
6
  Author: Wai-Shing Luk
7
7
  Author-email: luk036@gmail.com
8
8
  License: MIT
9
- Project-URL: Documentation, https://pyscaffold.org/
9
+ Project-URL: Documentation, https://csdigit.readthedocs.io/en/latest/
10
+ Project-URL: Source, https://github.com/luk036/csdigit
10
11
  Platform: any
11
12
  Classifier: Development Status :: 4 - Beta
12
13
  Classifier: Programming Language :: Python
13
14
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
14
15
  License-File: LICENSE.txt
15
- Requires-Dist: importlib-metadata; python_version < "3.9"
16
16
  Provides-Extra: testing
17
17
  Requires-Dist: setuptools; extra == "testing"
18
18
  Requires-Dist: pytest; extra == "testing"
@@ -0,0 +1,21 @@
1
+ import timeit
2
+
3
+
4
+ def bench(name, stmt, globals_dict=None, number=50000):
5
+ if globals_dict is None:
6
+ globals_dict = globals()
7
+ t = timeit.timeit(stmt, globals=globals_dict, number=number)
8
+ ns_per_op = t * 1e9 / number
9
+ print(f" {name:<30} {ns_per_op:>8.1f} ns/op ({number} iters)")
10
+
11
+
12
+ print("=== CSD Benchmarks (Python) ===")
13
+ bench("to_csd(28.5, 10)", "to_csd(28.5, 10)")
14
+ bench("to_csd_i(28)", "to_csd_i(28)")
15
+ bench("to_csdnnz(28.5, 4)", "to_csdnnz(28.5, 4)")
16
+ bench("to_decimal('+00-00.+0')", "to_decimal('+00-00.+0')")
17
+ bench("to_decimal_using_pow('+00-00')", "to_decimal_using_pow('+00-00')")
18
+ bench("to_csd(0.0, 10) [zero]", "to_csd(0.0, 10)")
19
+ bench("to_csd(-28.5, 10) [neg]", "to_csd(-28.5, 10)")
20
+ bench("to_csd(0.5, 10) [small]", "to_csd(0.5, 10)")
21
+ bench("to_csd(1024.75, 10) [large]", "to_csd(1024.75, 10)")
@@ -0,0 +1,52 @@
1
+ from csdigit.csd import (
2
+ to_csd,
3
+ to_csd_i,
4
+ to_csdnnz,
5
+ to_csdnnz_i,
6
+ to_decimal,
7
+ to_decimal_using_pow,
8
+ )
9
+
10
+ print("=== to_csd (float) ===")
11
+ for v, p in [
12
+ (28.5, 2),
13
+ (-0.5, 2),
14
+ (0.0, 2),
15
+ (2.5, 4),
16
+ (0.0, 0),
17
+ (7.0, 0),
18
+ (-7.0, 0),
19
+ (28.5, 0),
20
+ ]:
21
+ res = to_csd(v, p)
22
+ print(f' to_csd({v}, {p}) = "{res}"')
23
+
24
+ print()
25
+ print("=== to_csd_i (integer) ===")
26
+ for v in [28, 0, -28, 7, -7, 1, -1]:
27
+ res = to_csd_i(v)
28
+ print(f' to_csd_i({v}) = "{res}"')
29
+
30
+ print()
31
+ print("=== to_decimal ===")
32
+ for s in ["+00-00.+", "0.-", "0", "0.0", "0.+", "0.-", "0.++", "0.-+", "+00-00"]:
33
+ res = to_decimal(s)
34
+ print(f' to_decimal("{s}") = {res}')
35
+
36
+ print()
37
+ print("=== to_decimal_using_pow (integer CSD) ===")
38
+ for s in ["+00-00", "0", "-00+00"]:
39
+ res = to_decimal_using_pow(s)
40
+ print(f' to_decimal_using_pow("{s}") = {res}')
41
+
42
+ print()
43
+ print("=== to_csdnnz (float, limited nnz) ===")
44
+ for v, n in [(28.5, 4), (-0.5, 4), (0.0, 4), (0.5, 4), (0.0, 0), (28.5, 2), (28.5, 1)]:
45
+ res = to_csdnnz(v, n)
46
+ print(f' to_csdnnz({v}, {n}) = "{res}"')
47
+
48
+ print()
49
+ print("=== to_csdnnz_i (integer, limited nnz) ===")
50
+ for v, n in [(28, 4), (0, 4)]:
51
+ res = to_csdnnz_i(v, n)
52
+ print(f' to_csdnnz_i({v}, {n}) = "{res}"')