pygenutils 16.3.0__tar.gz → 16.3.2__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 (47) hide show
  1. {pygenutils-16.3.0/pygenutils.egg-info → pygenutils-16.3.2}/PKG-INFO +1 -1
  2. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/__init__.py +1 -1
  3. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/number_bases/base_converters.py +1 -1
  4. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/number_bases/mathematical_utils.py +10 -10
  5. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/strings/text_formatters.py +1 -1
  6. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/countdown.py +11 -11
  7. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/program_snippet_exec_timers.py +11 -11
  8. {pygenutils-16.3.0 → pygenutils-16.3.2/pygenutils.egg-info}/PKG-INFO +1 -1
  9. {pygenutils-16.3.0 → pygenutils-16.3.2}/pyproject.toml +1 -1
  10. {pygenutils-16.3.0 → pygenutils-16.3.2}/LICENSE +0 -0
  11. {pygenutils-16.3.0 → pygenutils-16.3.2}/MANIFEST.in +0 -0
  12. {pygenutils-16.3.0 → pygenutils-16.3.2}/README.md +0 -0
  13. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/arrays_and_lists/__init__.py +0 -0
  14. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/arrays_and_lists/conversions.py +0 -0
  15. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/arrays_and_lists/data_manipulation.py +0 -0
  16. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/arrays_and_lists/maths.py +0 -0
  17. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/arrays_and_lists/patterns.py +0 -0
  18. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/audio_and_video/__init__.py +0 -0
  19. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/audio_and_video/audio_and_video_manipulation.py +0 -0
  20. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/audio_and_video/merge_audio_and_video.py +0 -0
  21. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/audio_and_video/merge_audio_or_video.py +0 -0
  22. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/audio_and_video/trim_media.py +0 -0
  23. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/dictionaries/__init__.py +0 -0
  24. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/dictionaries/dict_handler.py +0 -0
  25. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/dictionaries/dict_operators.py +0 -0
  26. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/number_bases/__init__.py +0 -0
  27. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/number_bases/binary_operations.py +0 -0
  28. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/number_bases/bitwise_operators.py +0 -0
  29. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/operative_systems/__init__.py +0 -0
  30. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/operative_systems/os_operations.py +0 -0
  31. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/sets_and_intervals/__init__.py +0 -0
  32. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/sets_and_intervals/interval_handler.py +0 -0
  33. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/sets_and_intervals/sets_handler.py +0 -0
  34. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/strings/__init__.py +0 -0
  35. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/strings/string_handler.py +0 -0
  36. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/__init__.py +0 -0
  37. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/calendar_utils.py +0 -0
  38. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/date_and_time_maths.py +0 -0
  39. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/date_and_time_utils.py +0 -0
  40. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/time_formatters.py +0 -0
  41. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils/time_handling/time_utils.py +0 -0
  42. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils.egg-info/SOURCES.txt +0 -0
  43. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils.egg-info/dependency_links.txt +0 -0
  44. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils.egg-info/requires.txt +0 -0
  45. {pygenutils-16.3.0 → pygenutils-16.3.2}/pygenutils.egg-info/top_level.txt +0 -0
  46. {pygenutils-16.3.0 → pygenutils-16.3.2}/setup.cfg +0 -0
  47. {pygenutils-16.3.0 → pygenutils-16.3.2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygenutils
3
- Version: 16.3.0
3
+ Version: 16.3.2
4
4
  Summary: A comprehensive Python utility library for general-purpose and specialised tasks
5
5
  Author-email: Jon Ander Gabantxo <jagabantxo@gmail.com>
6
6
  License: MIT License
@@ -3,7 +3,7 @@
3
3
 
4
4
  # pygenutils/__init__.py
5
5
 
6
- __version__ = "16.3.0"
6
+ __version__ = "16.3.2"
7
7
 
8
8
  # Define what should be available when using 'from pygenutils import *'
9
9
  __all__ = [
@@ -60,7 +60,7 @@ def _check_input_binary(b):
60
60
  The binary number as a string without the 'b' or '0b' prefix.
61
61
  """
62
62
  b_clean = substring_replacer(substring_replacer(b, "b", ""), "0b", "")
63
- are_only_binaries = find_substring_index(b_clean, "^[01]+$")
63
+ are_only_binaries = find_substring_index(b_clean, r"^[01]+$")
64
64
  if are_only_binaries == -1:
65
65
  raise ValueError("The input binary number is not in the correct format.")
66
66
  return b_clean
@@ -6,11 +6,11 @@ from math import factorial
6
6
  # Define functions #
7
7
  #------------------#
8
8
 
9
- def adapted_factorial(num, decimals):
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 decimal precision.
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
- decimals : int
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:.{decimals}g}"
43
+ result = f"{result:.{significant_digits}g}"
44
44
  except OverflowError:
45
- # Convert to string and round to the desired decimal places
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 roundoff number
48
- if int(result_str[decimals]) >= 5:
49
- prev_num = int(result_str[decimals-1]) + 1
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[decimals-1])
51
+ prev_num = int(result_str[significant_digits-1])
52
52
  # Convert to float
53
- result_adapted = f"{result_str[0]}.{result_str[1:decimals-1]}{prev_num}e+{len(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
 
@@ -64,7 +64,7 @@ def format_string(string2format, arg_obj):
64
64
  IndexError: If there are not enough indices referenced in the string to format.
65
65
  SyntaxError: If there are syntax errors in the formatting object.
66
66
  """
67
- bracket_index_list = find_substring_index(string2format, "{}",
67
+ bracket_index_list = find_substring_index(string2format, r"[{}]",
68
68
  advanced_search=True,
69
69
  all_matches=True)
70
70
 
@@ -99,10 +99,10 @@ def __countdown(time_str, dt_fmt_str):
99
99
 
100
100
  if days > 0:
101
101
  DT_ARGS_DAY = [days, hours, minutes, seconds]
102
- time_display = format_string(TIME_STR_PARTS_FMTS[0], *DT_ARGS_DAY)
102
+ time_display = format_string(TIME_STR_PARTS_FMTS[0], DT_ARGS_DAY)
103
103
  else:
104
104
  DT_ARGS_NODAY = [hours, minutes, seconds]
105
- time_display = format_string(TIME_STR_PARTS_FMTS[1], *DT_ARGS_NODAY)
105
+ time_display = format_string(TIME_STR_PARTS_FMTS[1], DT_ARGS_NODAY)
106
106
 
107
107
  # Rellenar la cadena de visualización para limpiar caracteres sobrantes
108
108
  # Pad the display string to clear any leftover characters
@@ -120,10 +120,16 @@ def __countdown(time_str, dt_fmt_str):
120
120
  days -= 1
121
121
 
122
122
  print("\nTime up!")
123
+
124
+ #---------------------------------#
125
+ # Define parameters and constants # # FIXME: or just "define parameters" even if we aren't going to define any constant?
126
+ #---------------------------------#
127
+
128
+ TIME_STR_PARTS_FMTS = ["{} days {0:02d}:{1:02d}:{2:02d}", "{0:02d}:{1:02d}:{2:02d}"] # TODO: is template elememt indexing and formatting well suited to guide both the user and dev?
123
129
 
124
- #-------------------------#
125
- # Countdown functionality #
126
- #-------------------------#
130
+ #---------------------#
131
+ # Program progression #
132
+ #---------------------#
127
133
 
128
134
  # Ask for the datetime input #
129
135
  DATETIME_STR = input("Introduce any time: ")
@@ -134,9 +140,3 @@ try:
134
140
  __countdown(DATETIME_STR, DT_FMT_STR)
135
141
  except KeyboardInterrupt:
136
142
  print("\nCountdown stopped.")
137
-
138
- #--------------------------#
139
- # Parameters and constants #
140
- #--------------------------#
141
-
142
- TIME_STR_PARTS_FMTS = ["{} days {}:{}:{}", "{}:{}:{}"]
@@ -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
- roundoff=None,
138
+ decimal_places=None,
139
139
  format_time_str=False,
140
140
  return_best_time=False):
141
141
 
142
- # Roundoff validation #
143
- #-#-#-#-#-#-#-#-#-#-#-#
142
+ # Decimal places validation #
143
+ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#
144
144
 
145
145
  param_keys = get_caller_args()
146
- roundoff_arg_pos = find_substring_index(param_keys, "roundoff")
146
+ decimal_places_arg_pos = find_substring_index(param_keys, "decimal_places")
147
147
 
148
- if not isinstance(roundoff, int):
149
- raise TypeError(format_string(TYPE_ERROR_TEMPLATE, f'{param_keys[roundoff_arg_pos]}'))
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=roundoff
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 roundoff is not None:
174
- exec_time_norep = np_round(exec_time_norep, roundoff)
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 roundoff is not None:
196
- exec_time_rep = np_round(exec_time_rep, roundoff)
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)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygenutils
3
- Version: 16.3.0
3
+ Version: 16.3.2
4
4
  Summary: A comprehensive Python utility library for general-purpose and specialised tasks
5
5
  Author-email: Jon Ander Gabantxo <jagabantxo@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pygenutils"
7
- version = "16.3.0"
7
+ version = "16.3.2"
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