pygenutils 16.3.0__tar.gz → 16.3.1__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.
- {pygenutils-16.3.0/pygenutils.egg-info → pygenutils-16.3.1}/PKG-INFO +1 -1
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/__init__.py +1 -1
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/number_bases/mathematical_utils.py +10 -10
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/program_snippet_exec_timers.py +11 -11
- {pygenutils-16.3.0 → pygenutils-16.3.1/pygenutils.egg-info}/PKG-INFO +1 -1
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pyproject.toml +1 -1
- {pygenutils-16.3.0 → pygenutils-16.3.1}/LICENSE +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/MANIFEST.in +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/README.md +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/arrays_and_lists/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/arrays_and_lists/conversions.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/arrays_and_lists/data_manipulation.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/arrays_and_lists/maths.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/arrays_and_lists/patterns.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/audio_and_video/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/audio_and_video/audio_and_video_manipulation.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/audio_and_video/merge_audio_and_video.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/audio_and_video/merge_audio_or_video.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/audio_and_video/trim_media.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/dictionaries/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/dictionaries/dict_handler.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/dictionaries/dict_operators.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/number_bases/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/number_bases/base_converters.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/number_bases/binary_operations.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/number_bases/bitwise_operators.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/operative_systems/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/operative_systems/os_operations.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/sets_and_intervals/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/sets_and_intervals/interval_handler.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/sets_and_intervals/sets_handler.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/strings/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/strings/string_handler.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/strings/text_formatters.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/__init__.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/calendar_utils.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/countdown.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/date_and_time_maths.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/date_and_time_utils.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/time_formatters.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/time_utils.py +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils.egg-info/SOURCES.txt +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils.egg-info/dependency_links.txt +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils.egg-info/requires.txt +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils.egg-info/top_level.txt +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/setup.cfg +0 -0
- {pygenutils-16.3.0 → pygenutils-16.3.1}/setup.py +0 -0
|
@@ -6,11 +6,11 @@ from math import factorial
|
|
|
6
6
|
# Define functions #
|
|
7
7
|
#------------------#
|
|
8
8
|
|
|
9
|
-
def adapted_factorial(num,
|
|
9
|
+
def adapted_factorial(num, significant_digits):
|
|
10
10
|
"""
|
|
11
11
|
Calculate the factorial of a number with precise formatting control.
|
|
12
12
|
|
|
13
|
-
For standard-sized results, formats the output using the specified
|
|
13
|
+
For standard-sized results, formats the output using the specified precision.
|
|
14
14
|
For extremely large factorials that would cause an OverflowError during formatting,
|
|
15
15
|
converts the result to scientific notation with appropriate rounding.
|
|
16
16
|
|
|
@@ -18,7 +18,7 @@ def adapted_factorial(num, decimals):
|
|
|
18
18
|
----------
|
|
19
19
|
num : int | float
|
|
20
20
|
The number for which to calculate the factorial
|
|
21
|
-
|
|
21
|
+
significant_digits : int
|
|
22
22
|
The number of significant digits to include in the result
|
|
23
23
|
|
|
24
24
|
Returns
|
|
@@ -40,17 +40,17 @@ def adapted_factorial(num, decimals):
|
|
|
40
40
|
result = factorial(num)
|
|
41
41
|
|
|
42
42
|
try:
|
|
43
|
-
result = f"{result:.{
|
|
43
|
+
result = f"{result:.{significant_digits}g}"
|
|
44
44
|
except OverflowError:
|
|
45
|
-
# Convert to string and round to the desired
|
|
45
|
+
# Convert to string and round to the desired significant digits
|
|
46
46
|
result_str = str(result)
|
|
47
|
-
# Take into account the number next to the
|
|
48
|
-
if int(result_str[
|
|
49
|
-
prev_num = int(result_str[
|
|
47
|
+
# Take into account the number next to the significant digits position
|
|
48
|
+
if int(result_str[significant_digits]) >= 5:
|
|
49
|
+
prev_num = int(result_str[significant_digits-1]) + 1
|
|
50
50
|
else:
|
|
51
|
-
prev_num = int(result_str[
|
|
51
|
+
prev_num = int(result_str[significant_digits-1])
|
|
52
52
|
# Convert to float
|
|
53
|
-
result_adapted = f"{result_str[0]}.{result_str[1:
|
|
53
|
+
result_adapted = f"{result_str[0]}.{result_str[1:significant_digits-1]}{prev_num}e+{len(result_str)-1}"
|
|
54
54
|
else:
|
|
55
55
|
result_adapted = result
|
|
56
56
|
|
{pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/time_handling/program_snippet_exec_timers.py
RENAMED
|
@@ -135,18 +135,18 @@ def program_exec_timer(mode, module="time", frac_precision=3):
|
|
|
135
135
|
def snippet_exec_timer(snippet_str,
|
|
136
136
|
repeats=None,
|
|
137
137
|
trials=int(1e4),
|
|
138
|
-
|
|
138
|
+
decimal_places=None,
|
|
139
139
|
format_time_str=False,
|
|
140
140
|
return_best_time=False):
|
|
141
141
|
|
|
142
|
-
#
|
|
143
|
-
|
|
142
|
+
# Decimal places validation #
|
|
143
|
+
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
|
144
144
|
|
|
145
145
|
param_keys = get_caller_args()
|
|
146
|
-
|
|
146
|
+
decimal_places_arg_pos = find_substring_index(param_keys, "decimal_places")
|
|
147
147
|
|
|
148
|
-
if not isinstance(
|
|
149
|
-
raise TypeError(format_string(TYPE_ERROR_TEMPLATE, f'{param_keys[
|
|
148
|
+
if not isinstance(decimal_places, int):
|
|
149
|
+
raise TypeError(format_string(TYPE_ERROR_TEMPLATE, f'{param_keys[decimal_places_arg_pos]}'))
|
|
150
150
|
|
|
151
151
|
# Set keyword argument dictionary for float time parsing #
|
|
152
152
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
|
|
@@ -154,7 +154,7 @@ def snippet_exec_timer(snippet_str,
|
|
|
154
154
|
float_time_parsing_kwargs = dict(
|
|
155
155
|
module="str",
|
|
156
156
|
origin="arbitrary",
|
|
157
|
-
frac_precision=
|
|
157
|
+
frac_precision=decimal_places
|
|
158
158
|
)
|
|
159
159
|
|
|
160
160
|
# Execution time in the specified number of trials with no repeats #
|
|
@@ -170,8 +170,8 @@ def snippet_exec_timer(snippet_str,
|
|
|
170
170
|
exec_time_norep = timeit.repeat(snippet_str, repeat=1, number=10000)[0]
|
|
171
171
|
"""
|
|
172
172
|
|
|
173
|
-
if
|
|
174
|
-
exec_time_norep = np_round(exec_time_norep,
|
|
173
|
+
if decimal_places is not None:
|
|
174
|
+
exec_time_norep = np_round(exec_time_norep, decimal_places)
|
|
175
175
|
|
|
176
176
|
if not format_time_str:
|
|
177
177
|
time_unit_str = SEC_TIME_UNIT_STR
|
|
@@ -192,8 +192,8 @@ def snippet_exec_timer(snippet_str,
|
|
|
192
192
|
number=trials,
|
|
193
193
|
globals=globals())
|
|
194
194
|
|
|
195
|
-
if
|
|
196
|
-
exec_time_rep = np_round(exec_time_rep,
|
|
195
|
+
if decimal_places is not None:
|
|
196
|
+
exec_time_rep = np_round(exec_time_rep, decimal_places)
|
|
197
197
|
|
|
198
198
|
# Compute best time
|
|
199
199
|
best_time = min(exec_time_rep)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pygenutils"
|
|
7
|
-
version = "16.3.
|
|
7
|
+
version = "16.3.1"
|
|
8
8
|
license = {file = "LICENSE"}
|
|
9
9
|
description = "A comprehensive Python utility library for general-purpose and specialised tasks"
|
|
10
10
|
keywords = ["utilities", "python", "general-purpose", "file handling", "string processing"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pygenutils-16.3.0 → pygenutils-16.3.1}/pygenutils/audio_and_video/audio_and_video_manipulation.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|