1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
%global _empty_manifest_terminate_build 0
Name: python-ballpark
Version: 1.4.0
Release: 1
Summary: Better human-readable numbers.
License: ISC
URL: https://github.com/debrouwere/python-ballpark/
Source0: https://mirrors.nju.edu.cn/pypi/web/packages/8f/5b/e259db671525c63202885c2cad5fc90cf095a65149a2ad3a7586fa73180f/ballpark-1.4.0.tar.gz
BuildArch: noarch
%description
When people think of human-readable numbers, they think of rounding to
two decimal places and adding a thousands separator. 12,214.17 is
already quite an improvement over 12214.16666667. But standard formats
for human-readable numbers still have various flaws:
- even with a thousands separator, at a glance you might easily mistake
a billion for a trillion
- even when rounding, an amount like 12,214.17 dollars is a lot of
number noise for communicating 12.2K
- scientific notation leads to exponents like ``1.22e4`` which are hard
to interpret because we're used to working with thousands, millions
and billions – orders of magnitudes that are multiples of three
- when comparing multiple measurements of the same underlying variable,
like the yearly sales numbers for 2010-2015, it's annoying to have
some numbers in thousands and other numbers in millions – you want
consistency so that digits in the same position are of the same
magnitude
``python-ballpark`` introduces *business notation*, an offshoot of
`engineering
notation <https://en.wikipedia.org/wiki/Engineering_notation>`__, for
producing better human-readable numbers.
Install with ``pip install ballpark`` or ``pip3 install ballpark``.
What it looks like
~~~~~~~~~~~~~~~~~~
+---------------------+-----------------------+-----------------+-----------------+
| numbers | rounded | engineering | **business |
| | | notation | notation** |
+=====================+=======================+=================+=================+
| 11234.22, | 11,234.22, | 11.2E+3, | 11K, 233K, |
| 233000.55, | 233,000.55, | 233E+3, 1.18E+6 | 1,180K |
| 1175125.2 | 1,175,125.2 | | |
+---------------------+-----------------------+-----------------+-----------------+
| 111, 1111.23, | 111, 1,111.23, | 111, 1.11E+3, | 0.11K, 1.11K, |
| 1175125.234 | 1,175,125.23 | 1.18E+6 | 1,180.00K |
+---------------------+-----------------------+-----------------+-----------------+
How to use it
~~~~~~~~~~~~~
>>> from ballpark import human, scientific, engineering, business, ballpark
>>> business([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # business notation is also aliased as `ballpark`
>>> ballpark([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # or use the shortcut functions
>>> from ballpark import H, S, E, B
>>> B([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # all notations accept single numbers too, but then we can't guarantee
>>> # that all numbers will have the same prefix (kilo, mega etc.)
>>> [B(value) for value in [11234.22, 233000.55, 1175125.2]]
['11.2K', '233K', '1.18M']
How it works
~~~~~~~~~~~~
business(values, precision=3, prefix=True, prefixes=SI, statistic=median)
- **precision:** the amount of significant digits. When necessary,
``business`` will round beyond the decimal sign as well: in the
example above, ``1175125.2`` was turned into ``1,180K`` rather than
``1,175K`` to retain only 3 significant digits.
- **prefix:** whether to use SI prefixes like m (milli), K (kilo) and
so on instead of scientific exponents like E+03.
- **prefixes:** a mapping of orders of magnitude to prefixes, e.g.
``{-3: 'm', 3: 'K'}``, allowing you to customize the prefixes, for
example using B for billion instead of T for tera.
- **statistic:** a function to produce the reference number. The
reference number determines the order of magnitude and precision for
the entire group of numbers, so that for example when the reference
number is 23.3K, smaller numbers like 1.1K won't gain a decimal place
and larger numbers like 1,180K won't jump an order of magnitude to
1.18M. The median often works well, but if you want more precision
for small outliers, try ``ballpark.statistics.Q1`` or even Python's
builtin ``min``.
%package -n python3-ballpark
Summary: Better human-readable numbers.
Provides: python-ballpark
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-pip
%description -n python3-ballpark
When people think of human-readable numbers, they think of rounding to
two decimal places and adding a thousands separator. 12,214.17 is
already quite an improvement over 12214.16666667. But standard formats
for human-readable numbers still have various flaws:
- even with a thousands separator, at a glance you might easily mistake
a billion for a trillion
- even when rounding, an amount like 12,214.17 dollars is a lot of
number noise for communicating 12.2K
- scientific notation leads to exponents like ``1.22e4`` which are hard
to interpret because we're used to working with thousands, millions
and billions – orders of magnitudes that are multiples of three
- when comparing multiple measurements of the same underlying variable,
like the yearly sales numbers for 2010-2015, it's annoying to have
some numbers in thousands and other numbers in millions – you want
consistency so that digits in the same position are of the same
magnitude
``python-ballpark`` introduces *business notation*, an offshoot of
`engineering
notation <https://en.wikipedia.org/wiki/Engineering_notation>`__, for
producing better human-readable numbers.
Install with ``pip install ballpark`` or ``pip3 install ballpark``.
What it looks like
~~~~~~~~~~~~~~~~~~
+---------------------+-----------------------+-----------------+-----------------+
| numbers | rounded | engineering | **business |
| | | notation | notation** |
+=====================+=======================+=================+=================+
| 11234.22, | 11,234.22, | 11.2E+3, | 11K, 233K, |
| 233000.55, | 233,000.55, | 233E+3, 1.18E+6 | 1,180K |
| 1175125.2 | 1,175,125.2 | | |
+---------------------+-----------------------+-----------------+-----------------+
| 111, 1111.23, | 111, 1,111.23, | 111, 1.11E+3, | 0.11K, 1.11K, |
| 1175125.234 | 1,175,125.23 | 1.18E+6 | 1,180.00K |
+---------------------+-----------------------+-----------------+-----------------+
How to use it
~~~~~~~~~~~~~
>>> from ballpark import human, scientific, engineering, business, ballpark
>>> business([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # business notation is also aliased as `ballpark`
>>> ballpark([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # or use the shortcut functions
>>> from ballpark import H, S, E, B
>>> B([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # all notations accept single numbers too, but then we can't guarantee
>>> # that all numbers will have the same prefix (kilo, mega etc.)
>>> [B(value) for value in [11234.22, 233000.55, 1175125.2]]
['11.2K', '233K', '1.18M']
How it works
~~~~~~~~~~~~
business(values, precision=3, prefix=True, prefixes=SI, statistic=median)
- **precision:** the amount of significant digits. When necessary,
``business`` will round beyond the decimal sign as well: in the
example above, ``1175125.2`` was turned into ``1,180K`` rather than
``1,175K`` to retain only 3 significant digits.
- **prefix:** whether to use SI prefixes like m (milli), K (kilo) and
so on instead of scientific exponents like E+03.
- **prefixes:** a mapping of orders of magnitude to prefixes, e.g.
``{-3: 'm', 3: 'K'}``, allowing you to customize the prefixes, for
example using B for billion instead of T for tera.
- **statistic:** a function to produce the reference number. The
reference number determines the order of magnitude and precision for
the entire group of numbers, so that for example when the reference
number is 23.3K, smaller numbers like 1.1K won't gain a decimal place
and larger numbers like 1,180K won't jump an order of magnitude to
1.18M. The median often works well, but if you want more precision
for small outliers, try ``ballpark.statistics.Q1`` or even Python's
builtin ``min``.
%package help
Summary: Development documents and examples for ballpark
Provides: python3-ballpark-doc
%description help
When people think of human-readable numbers, they think of rounding to
two decimal places and adding a thousands separator. 12,214.17 is
already quite an improvement over 12214.16666667. But standard formats
for human-readable numbers still have various flaws:
- even with a thousands separator, at a glance you might easily mistake
a billion for a trillion
- even when rounding, an amount like 12,214.17 dollars is a lot of
number noise for communicating 12.2K
- scientific notation leads to exponents like ``1.22e4`` which are hard
to interpret because we're used to working with thousands, millions
and billions – orders of magnitudes that are multiples of three
- when comparing multiple measurements of the same underlying variable,
like the yearly sales numbers for 2010-2015, it's annoying to have
some numbers in thousands and other numbers in millions – you want
consistency so that digits in the same position are of the same
magnitude
``python-ballpark`` introduces *business notation*, an offshoot of
`engineering
notation <https://en.wikipedia.org/wiki/Engineering_notation>`__, for
producing better human-readable numbers.
Install with ``pip install ballpark`` or ``pip3 install ballpark``.
What it looks like
~~~~~~~~~~~~~~~~~~
+---------------------+-----------------------+-----------------+-----------------+
| numbers | rounded | engineering | **business |
| | | notation | notation** |
+=====================+=======================+=================+=================+
| 11234.22, | 11,234.22, | 11.2E+3, | 11K, 233K, |
| 233000.55, | 233,000.55, | 233E+3, 1.18E+6 | 1,180K |
| 1175125.2 | 1,175,125.2 | | |
+---------------------+-----------------------+-----------------+-----------------+
| 111, 1111.23, | 111, 1,111.23, | 111, 1.11E+3, | 0.11K, 1.11K, |
| 1175125.234 | 1,175,125.23 | 1.18E+6 | 1,180.00K |
+---------------------+-----------------------+-----------------+-----------------+
How to use it
~~~~~~~~~~~~~
>>> from ballpark import human, scientific, engineering, business, ballpark
>>> business([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # business notation is also aliased as `ballpark`
>>> ballpark([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # or use the shortcut functions
>>> from ballpark import H, S, E, B
>>> B([11234.22, 233000.55, 1175125.2])
['11K', '233K', '1,180K']
>>>
>>> # all notations accept single numbers too, but then we can't guarantee
>>> # that all numbers will have the same prefix (kilo, mega etc.)
>>> [B(value) for value in [11234.22, 233000.55, 1175125.2]]
['11.2K', '233K', '1.18M']
How it works
~~~~~~~~~~~~
business(values, precision=3, prefix=True, prefixes=SI, statistic=median)
- **precision:** the amount of significant digits. When necessary,
``business`` will round beyond the decimal sign as well: in the
example above, ``1175125.2`` was turned into ``1,180K`` rather than
``1,175K`` to retain only 3 significant digits.
- **prefix:** whether to use SI prefixes like m (milli), K (kilo) and
so on instead of scientific exponents like E+03.
- **prefixes:** a mapping of orders of magnitude to prefixes, e.g.
``{-3: 'm', 3: 'K'}``, allowing you to customize the prefixes, for
example using B for billion instead of T for tera.
- **statistic:** a function to produce the reference number. The
reference number determines the order of magnitude and precision for
the entire group of numbers, so that for example when the reference
number is 23.3K, smaller numbers like 1.1K won't gain a decimal place
and larger numbers like 1,180K won't jump an order of magnitude to
1.18M. The median often works well, but if you want more precision
for small outliers, try ``ballpark.statistics.Q1`` or even Python's
builtin ``min``.
%prep
%autosetup -n ballpark-1.4.0
%build
%py3_build
%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .
%files -n python3-ballpark -f filelist.lst
%dir %{python3_sitelib}/*
%files help -f doclist.lst
%{_docdir}/*
%changelog
* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 1.4.0-1
- Package Spec generated
|