format-multiple-errors 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/PKG-INFO +13 -3
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/README.md +9 -2
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/__main__.py +13 -5
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/pandas.py +8 -2
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors.egg-info/PKG-INFO +13 -3
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors.egg-info/SOURCES.txt +1 -0
- format_multiple_errors-0.0.3/format_multiple_errors.egg-info/requires.txt +4 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/pyproject.toml +4 -1
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/tests/test_pandas.py +1 -1
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/LICENSE +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/__init__.py +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/formatter.py +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/typing.py +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors.egg-info/dependency_links.txt +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors.egg-info/entry_points.txt +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors.egg-info/top_level.txt +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/setup.cfg +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/tests/test_cli.py +0 -0
- {format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/tests/test_format.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: format_multiple_errors
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: A small widget to be able to format multiple, asymmetric errors easily.
|
|
5
5
|
Author-email: Ed Bennett <e.j.bennett@swansea.ac.uk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/edbennett/format_multiple_errors
|
|
@@ -11,6 +11,9 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
+
Provides-Extra: tables
|
|
15
|
+
Requires-Dist: pandas; extra == "tables"
|
|
16
|
+
Requires-Dist: jinja2; extra == "tables"
|
|
14
17
|
|
|
15
18
|
# format_multiple_errors
|
|
16
19
|
|
|
@@ -28,9 +31,16 @@ $$(6.829 \pm 0.013 {}^{+0.104}_{-0.096})\times10^{5}$$
|
|
|
28
31
|
|
|
29
32
|
## Installation
|
|
30
33
|
|
|
31
|
-
To install, open a terminal and run:
|
|
34
|
+
To install the bare library, open a terminal and run:
|
|
32
35
|
|
|
33
|
-
pip install
|
|
36
|
+
pip install format-multiple-errors
|
|
37
|
+
|
|
38
|
+
If you will be formatting tables,
|
|
39
|
+
additional dependencies are required.
|
|
40
|
+
To install these,
|
|
41
|
+
instead run
|
|
42
|
+
|
|
43
|
+
pip install format-multiple-errors[tables]
|
|
34
44
|
|
|
35
45
|
|
|
36
46
|
## Usage as a library
|
|
@@ -14,9 +14,16 @@ $$(6.829 \pm 0.013 {}^{+0.104}_{-0.096})\times10^{5}$$
|
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
17
|
-
To install, open a terminal and run:
|
|
17
|
+
To install the bare library, open a terminal and run:
|
|
18
18
|
|
|
19
|
-
pip install
|
|
19
|
+
pip install format-multiple-errors
|
|
20
|
+
|
|
21
|
+
If you will be formatting tables,
|
|
22
|
+
additional dependencies are required.
|
|
23
|
+
To install these,
|
|
24
|
+
instead run
|
|
25
|
+
|
|
26
|
+
pip install format-multiple-errors[tables]
|
|
20
27
|
|
|
21
28
|
|
|
22
29
|
## Usage as a library
|
{format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/__main__.py
RENAMED
|
@@ -10,8 +10,10 @@ from sys import exit, stderr
|
|
|
10
10
|
|
|
11
11
|
try:
|
|
12
12
|
import pandas as pd
|
|
13
|
+
|
|
14
|
+
have_pandas = True
|
|
13
15
|
except ImportError:
|
|
14
|
-
|
|
16
|
+
have_pandas = False
|
|
15
17
|
|
|
16
18
|
from .formatter import format_multiple_errors
|
|
17
19
|
from .pandas import format_dataframe_errors, ColumnSpec
|
|
@@ -34,7 +36,7 @@ def _format_numbers(args: Namespace) -> None:
|
|
|
34
36
|
|
|
35
37
|
def _check_pandas() -> None:
|
|
36
38
|
"""Check if Pandas is available; complain and exit if not."""
|
|
37
|
-
if
|
|
39
|
+
if not have_pandas:
|
|
38
40
|
print(
|
|
39
41
|
"Pandas is not installed, but is required to process a table.",
|
|
40
42
|
file=stderr,
|
|
@@ -76,7 +78,7 @@ def _float_or_pair(arg: str) -> float | tuple[float, float]:
|
|
|
76
78
|
if len(split_arg) == 1:
|
|
77
79
|
return float(arg)
|
|
78
80
|
elif len(split_arg) == 2:
|
|
79
|
-
return
|
|
81
|
+
return (float(split_arg[0]), float(split_arg[1]))
|
|
80
82
|
else:
|
|
81
83
|
message = f"Can't parse {arg} as a number or pair of numbers."
|
|
82
84
|
raise ValueError(message)
|
|
@@ -94,13 +96,19 @@ def _parse_columnspec(arg: str) -> str | ColumnSpec:
|
|
|
94
96
|
if not isinstance(split_arg[0], str):
|
|
95
97
|
raise ValueError("First column has to be a single central value.")
|
|
96
98
|
|
|
97
|
-
error_columns = []
|
|
99
|
+
error_columns: list[str | tuple[str, str]] = []
|
|
98
100
|
for error_spec in split_arg[1:]:
|
|
99
101
|
split_error = error_spec.split("-")
|
|
100
102
|
if len(split_error) == 1:
|
|
101
103
|
error_columns.append(error_spec)
|
|
104
|
+
elif len(split_error) == 2:
|
|
105
|
+
error_columns.append((split_error[0], split_error[1]))
|
|
102
106
|
else:
|
|
103
|
-
|
|
107
|
+
message = (
|
|
108
|
+
f"Expected one or two components in error_spec {error_spec}, "
|
|
109
|
+
f"found {len(split_error)}."
|
|
110
|
+
)
|
|
111
|
+
raise ValueError(message)
|
|
104
112
|
|
|
105
113
|
return ColumnSpec(split_arg[0], *error_columns)
|
|
106
114
|
|
{format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/pandas.py
RENAMED
|
@@ -57,7 +57,7 @@ def _format_column(value: pd.Series, *errors: pd.Series, **fme_kwargs) -> pd.Ser
|
|
|
57
57
|
return pd.Series(data=formatted_errors, index=index)
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
def _tuplify(columns: list[pd.Series]) -> pd.Series:
|
|
60
|
+
def _tuplify(columns: list[pd.Series] | tuple[pd.Series]) -> pd.Series:
|
|
61
61
|
"""
|
|
62
62
|
Turn columns into one column of tuples.
|
|
63
63
|
Given a list of Pandas Series, returns a single Series
|
|
@@ -142,7 +142,13 @@ class ColumnSpec:
|
|
|
142
142
|
Specification of columns to include in calls to `format_dataframe_errors()`
|
|
143
143
|
"""
|
|
144
144
|
|
|
145
|
-
def __init__(
|
|
145
|
+
def __init__(
|
|
146
|
+
self,
|
|
147
|
+
value: str,
|
|
148
|
+
*errors: str | tuple[str, str],
|
|
149
|
+
name: str | None = None,
|
|
150
|
+
**fme_kwargs,
|
|
151
|
+
):
|
|
146
152
|
"""
|
|
147
153
|
Specify a set of columns to turn into a single column containing formatted
|
|
148
154
|
values and uncertainties.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: format_multiple_errors
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: A small widget to be able to format multiple, asymmetric errors easily.
|
|
5
5
|
Author-email: Ed Bennett <e.j.bennett@swansea.ac.uk>
|
|
6
6
|
Project-URL: Homepage, https://github.com/edbennett/format_multiple_errors
|
|
@@ -11,6 +11,9 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Requires-Python: >=3.9
|
|
12
12
|
Description-Content-Type: text/markdown
|
|
13
13
|
License-File: LICENSE
|
|
14
|
+
Provides-Extra: tables
|
|
15
|
+
Requires-Dist: pandas; extra == "tables"
|
|
16
|
+
Requires-Dist: jinja2; extra == "tables"
|
|
14
17
|
|
|
15
18
|
# format_multiple_errors
|
|
16
19
|
|
|
@@ -28,9 +31,16 @@ $$(6.829 \pm 0.013 {}^{+0.104}_{-0.096})\times10^{5}$$
|
|
|
28
31
|
|
|
29
32
|
## Installation
|
|
30
33
|
|
|
31
|
-
To install, open a terminal and run:
|
|
34
|
+
To install the bare library, open a terminal and run:
|
|
32
35
|
|
|
33
|
-
pip install
|
|
36
|
+
pip install format-multiple-errors
|
|
37
|
+
|
|
38
|
+
If you will be formatting tables,
|
|
39
|
+
additional dependencies are required.
|
|
40
|
+
To install these,
|
|
41
|
+
instead run
|
|
42
|
+
|
|
43
|
+
pip install format-multiple-errors[tables]
|
|
34
44
|
|
|
35
45
|
|
|
36
46
|
## Usage as a library
|
|
@@ -10,6 +10,7 @@ format_multiple_errors.egg-info/PKG-INFO
|
|
|
10
10
|
format_multiple_errors.egg-info/SOURCES.txt
|
|
11
11
|
format_multiple_errors.egg-info/dependency_links.txt
|
|
12
12
|
format_multiple_errors.egg-info/entry_points.txt
|
|
13
|
+
format_multiple_errors.egg-info/requires.txt
|
|
13
14
|
format_multiple_errors.egg-info/top_level.txt
|
|
14
15
|
tests/test_cli.py
|
|
15
16
|
tests/test_format.py
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "format_multiple_errors"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.3"
|
|
8
8
|
authors = [{name="Ed Bennett", email="e.j.bennett@swansea.ac.uk"}]
|
|
9
9
|
description = "A small widget to be able to format multiple, asymmetric errors easily."
|
|
10
10
|
readme = "README.md"
|
|
@@ -22,6 +22,9 @@ classifiers = [
|
|
|
22
22
|
[project.scripts]
|
|
23
23
|
format_multiple_errors = "format_multiple_errors.__main__:cli"
|
|
24
24
|
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
tables = ["pandas", "jinja2"]
|
|
27
|
+
|
|
25
28
|
[tool.coverage.report]
|
|
26
29
|
exclude_lines = [
|
|
27
30
|
"if __name__ == .__main__.:"
|
|
@@ -131,7 +131,7 @@ def test_format_dataframe_columnspecs(df):
|
|
|
131
131
|
"b",
|
|
132
132
|
ColumnSpec("c_value", "c_error", name="c", abbreviate=True),
|
|
133
133
|
ColumnSpec(
|
|
134
|
-
"d_value", "
|
|
134
|
+
"d_value", ("d_upper", "d_lower"), "d_systematic", name="d", abbreviate=True
|
|
135
135
|
),
|
|
136
136
|
]
|
|
137
137
|
result = format_dataframe_errors(df, columns, abbreviate=False)
|
|
File without changes
|
{format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/__init__.py
RENAMED
|
File without changes
|
{format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/formatter.py
RENAMED
|
File without changes
|
{format_multiple_errors-0.0.2 → format_multiple_errors-0.0.3}/format_multiple_errors/typing.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|