mergeron_extra 2024.739148.5__tar.gz → 2024.739148.7__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.
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/PKG-INFO +3 -2
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/pyproject.toml +2 -2
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/__init__.py +1 -1
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/xlsxw_helper.py +79 -50
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/README.rst +0 -0
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/proportions_tests.py +0 -0
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/py.types +0 -0
- {mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/tol_colors.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
2
|
Name: mergeron_extra
|
|
3
|
-
Version: 2024.739148.
|
|
3
|
+
Version: 2024.739148.7
|
|
4
4
|
Summary: Tools for users of the mergeron package.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Murthy Kambhampaty
|
|
@@ -15,6 +15,7 @@ Classifier: Operating System :: OS Independent
|
|
|
15
15
|
Classifier: Programming Language :: Python
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
19
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
20
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
21
|
Requires-Dist: aenum (>=3.1.15,<4.0.0)
|
|
@@ -4,7 +4,7 @@ description = "Tools for users of the mergeron package."
|
|
|
4
4
|
authors = ["Murthy Kambhampaty <smk@capeconomics.com>"]
|
|
5
5
|
license = "MIT"
|
|
6
6
|
readme = "README.rst"
|
|
7
|
-
version = "2024.739148.
|
|
7
|
+
version = "2024.739148.7"
|
|
8
8
|
|
|
9
9
|
classifiers = [
|
|
10
10
|
"Development Status :: 4 - Beta",
|
|
@@ -147,7 +147,7 @@ preview = true
|
|
|
147
147
|
python_version = "3.12"
|
|
148
148
|
ignore_missing_imports = false
|
|
149
149
|
strict = true
|
|
150
|
-
enable_incomplete_feature = ["
|
|
150
|
+
enable_incomplete_feature = ["PreciseTupleTypes"]
|
|
151
151
|
|
|
152
152
|
show_column_numbers = true
|
|
153
153
|
show_error_codes = true
|
{mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/xlsxw_helper.py
RENAMED
|
@@ -25,7 +25,7 @@ from __future__ import annotations
|
|
|
25
25
|
|
|
26
26
|
from collections.abc import Sequence
|
|
27
27
|
from types import MappingProxyType
|
|
28
|
-
from typing import Any, ClassVar, Literal, TypeAlias, TypedDict
|
|
28
|
+
from typing import Any, ClassVar, Literal, TypeAlias, TypedDict, overload
|
|
29
29
|
|
|
30
30
|
import numpy as np
|
|
31
31
|
from aenum import Enum, extend_enum, unique # type: ignore
|
|
@@ -219,7 +219,7 @@ class CFmt(Enum): # type: ignore
|
|
|
219
219
|
|
|
220
220
|
"""
|
|
221
221
|
|
|
222
|
-
return extend_enum(cls, _fmt_name, _xlsx_fmt_dict) # type: ignore
|
|
222
|
+
return extend_enum(cls, _fmt_name, MappingProxyType(_xlsx_fmt_dict)) # type: ignore
|
|
223
223
|
|
|
224
224
|
@classmethod
|
|
225
225
|
def ensure_cell_format_spec_tuple(
|
|
@@ -261,7 +261,7 @@ class CFmt(Enum): # type: ignore
|
|
|
261
261
|
def xl_fmt(
|
|
262
262
|
cls,
|
|
263
263
|
_xl_book: Workbook,
|
|
264
|
-
|
|
264
|
+
_cell_format: Sequence[CFmt | Sequence[CFmt]] | CFmt | None,
|
|
265
265
|
/,
|
|
266
266
|
) -> Format:
|
|
267
267
|
"""
|
|
@@ -272,7 +272,7 @@ class CFmt(Enum): # type: ignore
|
|
|
272
272
|
_xl_book
|
|
273
273
|
:code:`xlsxwriter.Workbook` object
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
_cell_format
|
|
276
276
|
:class:`CFmt` enum object, or tuple thereof
|
|
277
277
|
|
|
278
278
|
Raises
|
|
@@ -287,26 +287,26 @@ class CFmt(Enum): # type: ignore
|
|
|
287
287
|
|
|
288
288
|
"""
|
|
289
289
|
|
|
290
|
-
if isinstance(
|
|
291
|
-
return
|
|
292
|
-
elif
|
|
290
|
+
if isinstance(_cell_format, Format):
|
|
291
|
+
return _cell_format
|
|
292
|
+
elif _cell_format is None:
|
|
293
293
|
return _xl_book.add_format(CFmt.XL_DEFAULT.value)
|
|
294
294
|
|
|
295
|
-
|
|
296
|
-
if isinstance(
|
|
297
|
-
cls.ensure_cell_format_spec_tuple(
|
|
298
|
-
for _cf in
|
|
295
|
+
_cell_format_dict: CFmtVal = {}
|
|
296
|
+
if isinstance(_cell_format, Sequence):
|
|
297
|
+
cls.ensure_cell_format_spec_tuple(_cell_format)
|
|
298
|
+
for _cf in _cell_format:
|
|
299
299
|
if isinstance(_cf, Sequence):
|
|
300
300
|
for _cfi in _cf:
|
|
301
|
-
|
|
301
|
+
_cell_format_dict |= _cfi.value
|
|
302
302
|
else:
|
|
303
|
-
|
|
304
|
-
elif isinstance(
|
|
305
|
-
|
|
303
|
+
_cell_format_dict |= _cf.value
|
|
304
|
+
elif isinstance(_cell_format, CFmt):
|
|
305
|
+
_cell_format_dict = _cell_format.value
|
|
306
306
|
else:
|
|
307
307
|
raise ValueError("Improperly specified format specification.")
|
|
308
308
|
|
|
309
|
-
return _xl_book.add_format(
|
|
309
|
+
return _xl_book.add_format(_cell_format_dict)
|
|
310
310
|
|
|
311
311
|
|
|
312
312
|
def write_header(
|
|
@@ -492,7 +492,7 @@ def array_to_sheet(
|
|
|
492
492
|
raise _err
|
|
493
493
|
elif not (
|
|
494
494
|
isinstance(_data_table, Sequence | np.ndarray)
|
|
495
|
-
and
|
|
495
|
+
and isinstance(_data_table[0], Sequence | np.ndarray)
|
|
496
496
|
):
|
|
497
497
|
raise ValueError("Given array must be two-dimensional array.")
|
|
498
498
|
|
|
@@ -550,29 +550,57 @@ def array_to_sheet(
|
|
|
550
550
|
return _bottom_row_id, _right_column_id
|
|
551
551
|
|
|
552
552
|
|
|
553
|
+
@overload
|
|
553
554
|
def scalar_to_sheet(
|
|
554
555
|
_xl_book: Workbook,
|
|
555
556
|
_xl_sheet: Worksheet,
|
|
556
|
-
|
|
557
|
+
_address0: str,
|
|
558
|
+
_value: Any,
|
|
559
|
+
_format: CFmt | Sequence[CFmt | Sequence[CFmt]] | None,
|
|
557
560
|
/,
|
|
558
|
-
|
|
561
|
+
) -> None: ...
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
@overload
|
|
565
|
+
def scalar_to_sheet(
|
|
566
|
+
_xl_book: Workbook,
|
|
567
|
+
_xl_sheet: Worksheet,
|
|
568
|
+
_address0: int,
|
|
569
|
+
_address1: int,
|
|
570
|
+
_value: Any,
|
|
571
|
+
_format: CFmt | Sequence[CFmt | Sequence[CFmt]] | None,
|
|
572
|
+
/,
|
|
573
|
+
) -> None: ...
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
def scalar_to_sheet(
|
|
577
|
+
_xl_book: Workbook, _xl_sheet: Worksheet, /, *_s2s_args: Any
|
|
559
578
|
) -> None:
|
|
560
579
|
"""
|
|
561
580
|
Write to a single cell in a worksheet.
|
|
562
581
|
|
|
563
582
|
Parameters
|
|
564
583
|
----------
|
|
584
|
+
_xl_book
|
|
585
|
+
Workbook object for defining formats, and writing data
|
|
586
|
+
|
|
565
587
|
_xl_sheet
|
|
566
|
-
Worksheet object to which to write the
|
|
588
|
+
Worksheet object to which to write the given scalar
|
|
589
|
+
|
|
590
|
+
_cell_addr
|
|
591
|
+
An Excel cell address string in 'A1' format
|
|
567
592
|
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
in 'A1' format or the row-part in 'Row-column' format
|
|
593
|
+
_address0
|
|
594
|
+
Index-0 row number of destintaion cell
|
|
571
595
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
596
|
+
_address1
|
|
597
|
+
Index-0 column number of destintaion cell
|
|
598
|
+
|
|
599
|
+
_value
|
|
600
|
+
Value to write
|
|
601
|
+
|
|
602
|
+
_format
|
|
603
|
+
Member of :class:`CFmt`, or tuple thereof
|
|
576
604
|
|
|
577
605
|
Raises
|
|
578
606
|
------
|
|
@@ -592,41 +620,42 @@ def scalar_to_sheet(
|
|
|
592
620
|
|
|
593
621
|
"""
|
|
594
622
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
623
|
+
_address: tuple[str] | tuple[int, int]
|
|
624
|
+
_value: Any
|
|
625
|
+
_format: CFmt | Sequence[CFmt | Sequence[CFmt]] | None
|
|
598
626
|
|
|
599
|
-
if isinstance(
|
|
600
|
-
if len(_s2s_args) not in (
|
|
627
|
+
if isinstance(_s2s_args[0], str):
|
|
628
|
+
if len(_s2s_args) not in (2, 3):
|
|
601
629
|
raise ValueError("Incorrect number of arguments.")
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
elif isinstance(
|
|
606
|
-
if
|
|
630
|
+
_address = (_s2s_args[0],)
|
|
631
|
+
_value = _s2s_args[1]
|
|
632
|
+
_format = _s2s_args[2] if len(_s2s_args) == 3 else None
|
|
633
|
+
elif isinstance(_s2s_args[0], int):
|
|
634
|
+
if not isinstance(_s2s_args[1], int) or len(_s2s_args) not in (3, 4):
|
|
607
635
|
print(repr(_s2s_args))
|
|
608
636
|
raise ValueError("Incorrect/incomplete specification for Excel cell data.")
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
637
|
+
_address = _s2s_args[:2]
|
|
638
|
+
_value = _s2s_args[2]
|
|
639
|
+
_format = _s2s_args[3] if len(_s2s_args) == 4 else None
|
|
612
640
|
else:
|
|
613
641
|
raise ValueError("Incorrect/incomplete specification for Excel cell data.")
|
|
614
642
|
|
|
615
643
|
_write_args = (
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
644
|
+
*_address,
|
|
645
|
+
(
|
|
646
|
+
repr(_value)
|
|
647
|
+
if np.ndim(_value) or _value in (np.inf, -np.inf, np.nan)
|
|
648
|
+
else _value
|
|
649
|
+
),
|
|
622
650
|
)
|
|
651
|
+
_write_args += (CFmt.xl_fmt(_xl_book, _format),) if _format else ()
|
|
623
652
|
|
|
624
|
-
if
|
|
653
|
+
if _value is None or _value == "":
|
|
625
654
|
_xl_sheet.write_blank(*_write_args)
|
|
626
655
|
elif (
|
|
627
|
-
isinstance(
|
|
628
|
-
or np.ndim(
|
|
629
|
-
or
|
|
656
|
+
isinstance(_value, str)
|
|
657
|
+
or np.ndim(_value)
|
|
658
|
+
or _value in (np.inf, -np.inf, np.nan)
|
|
630
659
|
):
|
|
631
660
|
_xl_sheet.write_string(*_write_args)
|
|
632
661
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mergeron_extra-2024.739148.5 → mergeron_extra-2024.739148.7}/src/mergeron_extra/tol_colors.py
RENAMED
|
File without changes
|