pygenutils 16.2.3__tar.gz → 16.3.0__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.2.3/pygenutils.egg-info → pygenutils-16.3.0}/PKG-INFO +1 -1
  2. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/__init__.py +1 -1
  3. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/arrays_and_lists/data_manipulation.py +3 -3
  4. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/arrays_and_lists/patterns.py +1 -1
  5. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/audio_and_video/audio_and_video_manipulation.py +7 -7
  6. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/audio_and_video/merge_audio_or_video.py +3 -3
  7. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/audio_and_video/trim_media.py +3 -3
  8. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/dictionaries/dict_operators.py +2 -2
  9. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/number_bases/base_converters.py +37 -18
  10. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/operative_systems/os_operations.py +24 -24
  11. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/sets_and_intervals/interval_handler.py +7 -6
  12. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/sets_and_intervals/sets_handler.py +2 -2
  13. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/date_and_time_maths.py +18 -14
  14. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/program_snippet_exec_timers.py +11 -3
  15. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/time_formatters.py +94 -84
  16. {pygenutils-16.2.3 → pygenutils-16.3.0/pygenutils.egg-info}/PKG-INFO +1 -1
  17. {pygenutils-16.2.3 → pygenutils-16.3.0}/pyproject.toml +1 -1
  18. {pygenutils-16.2.3 → pygenutils-16.3.0}/LICENSE +0 -0
  19. {pygenutils-16.2.3 → pygenutils-16.3.0}/MANIFEST.in +0 -0
  20. {pygenutils-16.2.3 → pygenutils-16.3.0}/README.md +0 -0
  21. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/arrays_and_lists/__init__.py +0 -0
  22. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/arrays_and_lists/conversions.py +0 -0
  23. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/arrays_and_lists/maths.py +0 -0
  24. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/audio_and_video/__init__.py +0 -0
  25. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/audio_and_video/merge_audio_and_video.py +0 -0
  26. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/dictionaries/__init__.py +0 -0
  27. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/dictionaries/dict_handler.py +0 -0
  28. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/number_bases/__init__.py +0 -0
  29. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/number_bases/binary_operations.py +0 -0
  30. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/number_bases/bitwise_operators.py +0 -0
  31. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/number_bases/mathematical_utils.py +0 -0
  32. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/operative_systems/__init__.py +0 -0
  33. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/sets_and_intervals/__init__.py +0 -0
  34. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/strings/__init__.py +0 -0
  35. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/strings/string_handler.py +0 -0
  36. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/strings/text_formatters.py +0 -0
  37. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/__init__.py +0 -0
  38. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/calendar_utils.py +0 -0
  39. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/countdown.py +0 -0
  40. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/date_and_time_utils.py +0 -0
  41. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils/time_handling/time_utils.py +0 -0
  42. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils.egg-info/SOURCES.txt +0 -0
  43. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils.egg-info/dependency_links.txt +0 -0
  44. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils.egg-info/requires.txt +0 -0
  45. {pygenutils-16.2.3 → pygenutils-16.3.0}/pygenutils.egg-info/top_level.txt +0 -0
  46. {pygenutils-16.2.3 → pygenutils-16.3.0}/setup.cfg +0 -0
  47. {pygenutils-16.2.3 → pygenutils-16.3.0}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygenutils
3
- Version: 16.2.3
3
+ Version: 16.3.0
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.2.3"
6
+ __version__ = "16.3.0"
7
7
 
8
8
  # Define what should be available when using 'from pygenutils import *'
9
9
  __all__ = [
@@ -165,7 +165,7 @@ def sort_1d_basic(arr, reverse=False):
165
165
  elif isinstance(arr, list):
166
166
  arr = flatten_list(arr)
167
167
 
168
- # Operations #
168
+ # Program progression #
169
169
  for i in range(len(arr)):
170
170
  current = i
171
171
  for k in range(i+1, len(arr)):
@@ -305,7 +305,7 @@ def revert_1d_basic(arr, procedure="index"):
305
305
  elif isinstance(arr, list):
306
306
  arr = flatten_list(arr)
307
307
 
308
- # Operations #
308
+ # Program progression #
309
309
  arr_len = len(arr)-1
310
310
  if procedure == "iterative":
311
311
  for i in range(arr_len//2):
@@ -593,7 +593,7 @@ def extract_1d_unique_basic(arr, procedure="dict", sort=False, reverse=False):
593
593
  elif isinstance(arr, list):
594
594
  arr = flatten_list(arr)
595
595
 
596
- # Operations #
596
+ # Program progression #
597
597
  if procedure == "dict":
598
598
  unique_key_dict = dict.fromkeys(arr)
599
599
  unique_val_arr = list(unique_key_dict.keys())
@@ -64,7 +64,7 @@ def find_item_basic(obj, obj2find):
64
64
  elif isinstance(obj, list):
65
65
  obj = flatten_list(obj)
66
66
 
67
- # Operations #
67
+ # Program progression #
68
68
  length = len(obj)
69
69
  sorted_obj = sort_1d_basic(obj)
70
70
 
@@ -290,8 +290,8 @@ def merge_media_files(audio_files,
290
290
  _validate_files(video_file_list, "Video file list (arg number 0)")
291
291
  _validate_files(audio_file_list, "Audio file list (arg number 1)")
292
292
 
293
- # Operations #
294
- #-#-#-#-#-#-#-
293
+ # Program progression #
294
+ #-#-#-#-#-#-#-#-#-#-#-#
295
295
 
296
296
  # Generate default output file names if not provided
297
297
  if output_file_list is None:
@@ -464,7 +464,7 @@ def merge_individual_media_files(media_inputs,
464
464
  """
465
465
 
466
466
  # Validations #
467
- #-------------#
467
+ #-#-#-#-#-#-#-#
468
468
 
469
469
  # Audio bitrate fraction validation
470
470
  if audio_bitrate_fraction is not None and (not isinstance(audio_bitrate_fraction, int) or audio_bitrate_fraction < 1):
@@ -506,8 +506,8 @@ def merge_individual_media_files(media_inputs,
506
506
  raise ValueError("Input list contains both audio and video files. "
507
507
  "Only one type is allowed.")
508
508
 
509
- # Operations #
510
- #------------#
509
+ # Program progression #
510
+ #-#-#-#-#-#-#-#-#-#-#-#
511
511
 
512
512
  # Generate default output file names if not provided #
513
513
  if not output_file_name:
@@ -748,8 +748,8 @@ def cut_media_files(media_inputs,
748
748
  if not isinstance(overwrite, bool):
749
749
  raise ValueError("'overwrite' must be a boolean value.")
750
750
 
751
- # Operations #
752
- #------------#
751
+ # Program progression #
752
+ #---------------------#
753
753
 
754
754
  # If output file list is not provided, create default names
755
755
  if output_file_list is None:
@@ -80,9 +80,9 @@ RETURN_OUTPUT_NAME = False
80
80
  ENCODING = "utf-8"
81
81
  SHELL = True
82
82
 
83
- #------------#
84
- # Operations #
85
- #------------#
83
+ #---------------------#
84
+ # Program progression #
85
+ #---------------------#
86
86
 
87
87
  merge_individual_media_files(
88
88
  MEDIA_INPUT,
@@ -81,9 +81,9 @@ RETURN_OUTPUT_NAME = False
81
81
  ENCODING = "utf-8"
82
82
  SHELL = True
83
83
 
84
- #------------#
85
- # Operations #
86
- #------------#
84
+ #---------------------#
85
+ # Program progression #
86
+ #---------------------#
87
87
 
88
88
  cut_media_files(
89
89
  MEDIA_INPUT,
@@ -82,8 +82,8 @@ def dict_value_basic_operator(dict_list,
82
82
  raise ValueError ("Invalid basic operator sign. "
83
83
  f"Choose one from {list(ALLOWED_CALC_DICT.keys())}.")
84
84
 
85
- # Operations #
86
- #-#-#-#-#-#-#-
85
+ # Program progression #
86
+ #-#-#-#-#-#-#-#-#-#-#-#
87
87
 
88
88
  # Perform the computation #
89
89
  operation = ALLOWED_CALC_DICT.get(math_operator)
@@ -92,7 +92,7 @@ def _check_input_int(x):
92
92
  # Procedure checker #
93
93
  #-#-#-#-#-#-#-#-#-#-#
94
94
 
95
- def _procedure_checker(arg):
95
+ def _procedure_checker(arg, procedure_opts):
96
96
  """
97
97
  Checks if the provided procedure is valid.
98
98
 
@@ -105,8 +105,8 @@ def _procedure_checker(arg):
105
105
  ------
106
106
  ValueError : If the procedure is not valid.
107
107
  """
108
- if arg not in PROCEDURE_OPTS:
109
- raise ValueError(f"Unsupported procedure. Choose one from {PROCEDURE_OPTS}.")
108
+ if arg not in procedure_opts:
109
+ raise ValueError(f"Unsupported procedure. Choose one from {procedure_opts}.")
110
110
 
111
111
  # Frequently used bases #
112
112
  #-----------------------#
@@ -130,15 +130,12 @@ def dec2bin_basic(n):
130
130
  The binary representation of the input number.
131
131
  """
132
132
  n_checked = _check_input_int(n)
133
- b = ''
134
- while True:
133
+ b = "" # or '_bin', so that we understand the var name better?
134
+ while n_checked >= 1:
135
135
  floordiv, mod = divmod(n_checked,2)
136
136
  b += str(mod)
137
- if floordiv == 0:
138
- break
139
137
  n_checked //= 2
140
- b_actual = b[::-1]
141
- return b_actual
138
+ return b[::-1]
142
139
 
143
140
  # Advanced #
144
141
  #-#-#-#-#-#-
@@ -162,7 +159,7 @@ def base2bin(n, procedure="format_string", zero_pad=4):
162
159
  str
163
160
  The binary representation of the input number.
164
161
  """
165
- _procedure_checker(procedure)
162
+ _procedure_checker(procedure, NUMBER_CONVERSION_PROCEDURE_OPTS)
166
163
 
167
164
  if procedure == "default":
168
165
  n_bin = bin(n)
@@ -188,7 +185,7 @@ def base2oct(n, procedure="format_string", zero_pad=4):
188
185
  str
189
186
  The octal representation of the input number.
190
187
  """
191
- _procedure_checker(procedure)
188
+ _procedure_checker(procedure, NUMBER_CONVERSION_PROCEDURE_OPTS)
192
189
 
193
190
  if procedure == "default":
194
191
  n_oct = oct(n)
@@ -214,7 +211,7 @@ def base2hex(n, procedure="format_string", zero_pad=4):
214
211
  str
215
212
  The hexadecimal representation of the input number.
216
213
  """
217
- _procedure_checker(procedure)
214
+ _procedure_checker(procedure, NUMBER_CONVERSION_PROCEDURE_OPTS)
218
215
 
219
216
  if procedure == "default":
220
217
  if isinstance(n, float):
@@ -246,7 +243,7 @@ def bin2dec(n_bin):
246
243
  n = int(n_bin, base=2)
247
244
  return n
248
245
 
249
- def bin2dec_basic(b):
246
+ def bin2dec_basic(b, procedure="loop"):
250
247
  """
251
248
  Converts a binary number to decimal, using mathematical operations
252
249
  by definition (hence the name 'basic').
@@ -257,6 +254,12 @@ def bin2dec_basic(b):
257
254
  The binary number as a string.
258
255
  It can contain the 'b' or '0b' prefix. If so, the function
259
256
  will take into account the string without the prefix.
257
+ procedure : str
258
+ The procedure to use for conversion. Options are:
259
+ - 'list_comprehension': Uses a list comprehension with enumerate for a more
260
+ functional approach. Might be more memory intensive for large numbers.
261
+ - 'loop': Uses a traditional for loop with enumerate. More memory efficient
262
+ as it doesn't create an intermediate list.
260
263
 
261
264
  Returns
262
265
  -------
@@ -264,13 +267,28 @@ def bin2dec_basic(b):
264
267
  The decimal equivalent of the binary number.
265
268
  """
266
269
 
270
+ # Validations #
271
+ ###############
272
+
273
+ # Procedure #
274
+ _procedure_checker(procedure, BIN2DEC_PROCEDURE_OPTS)
275
+
276
+ # Number input #
267
277
  b_checked = _check_input_binary(b)
268
278
  lb = len(b_checked)
269
279
 
270
- res = 0
271
- for bit_pos, i_str in enumerate(range(lb-1,-1,-1)):
272
- res += int(b_checked[i_str]) * 2 ** bit_pos
273
- return res
280
+ # Calculation #
281
+ ###############
282
+
283
+ if procedure == "list_comprehension":
284
+ summands_iter = [int(b_checked[i]) * 2 ** pos for pos, i in enumerate(range(lb-1,-1,-1))]
285
+ res = sum(summands_iter)
286
+
287
+ elif procedure == "loop":
288
+ res = 0
289
+ for pos, i in enumerate(range(lb-1,-1,-1)):
290
+ res += int(b_checked[i]) * 2 ** pos
291
+ return res
274
292
 
275
293
 
276
294
  def oct2dec(n_oct):
@@ -360,4 +378,5 @@ def convert_among_arbitraries(x, base):
360
378
  # Parameters and constants #
361
379
  #--------------------------#
362
380
 
363
- PROCEDURE_OPTS = ['default', 'format_string']
381
+ BIN2DEC_PROCEDURE_OPTS = ['list_comprehension', 'loop']
382
+ NUMBER_CONVERSION_PROCEDURE_OPTS = ['default', 'format_string']
@@ -139,7 +139,7 @@ def os_system_helper(command, capture_output):
139
139
  """
140
140
 
141
141
  # Validations #
142
- #-------------#
142
+ #-#-#-#-#-#-#-#
143
143
 
144
144
  # Command and class #
145
145
  if not isinstance(command, str):
@@ -150,8 +150,8 @@ def os_system_helper(command, capture_output):
150
150
  if capture_output:
151
151
  raise ValueError("os.system cannot capture output.")
152
152
 
153
- # Operations #
154
- #------------#
153
+ # Program progression #
154
+ #-#-#-#-#-#-#-#-#-#-#-#
155
155
 
156
156
  # Execute the command
157
157
  exit_code = os.system(command)
@@ -180,7 +180,7 @@ def os_popen_helper(command, capture_output):
180
180
  """
181
181
 
182
182
  # Validations #
183
- #-------------#
183
+ #-#-#-#-#-#-#-#
184
184
 
185
185
  # Command and class #
186
186
  if not isinstance(command, str):
@@ -191,8 +191,8 @@ def os_popen_helper(command, capture_output):
191
191
  if not capture_output:
192
192
  raise ValueError("os.popen must capture output.")
193
193
 
194
- # Operations #
195
- #------------#
194
+ # Program progression #
195
+ #-#-#-#-#-#-#-#-#-#-#-#
196
196
 
197
197
  # Capture the output
198
198
  output = os.popen(command).read()
@@ -231,26 +231,26 @@ def subprocess_popen_helper(command, capture_output, encoding, return_output_nam
231
231
  """
232
232
  from subprocess import Popen, PIPE
233
233
 
234
- # Set text parameter (if not provided, use encoding as a fallback)
234
+ # Set text parameter (if not provided, use encoding as a fallback) #
235
235
  text_param = text if text is not None else bool(encoding)
236
236
 
237
- # Define the I/O streams
237
+ # Define the I/O streams #
238
238
  pipe_kwargs = dict(stdin=PIPE, stdout=PIPE, stderr=PIPE) if capture_output else {}
239
239
 
240
- # Execute the command
240
+ # Execute the command #
241
241
  process = Popen(command, **pipe_kwargs, text=text_param)
242
242
 
243
- # Wait for command to complete
243
+ # Wait for command to complete #
244
244
  process.wait()
245
245
 
246
- # Initialise return dictionary with return code
246
+ # Initialise return dictionary with return code #
247
247
  return_dict = {"return_code": process.returncode}
248
248
 
249
- # Add errors if available
249
+ # Add errors if available #
250
250
  if hasattr(process, "errors"):
251
251
  return_dict["errors"] = process.errors
252
252
 
253
- # Only capture stdin, stdout, stderr if output capturing was requested
253
+ # Only capture stdin, stdout, stderr if output capturing was requested #
254
254
  if capture_output:
255
255
  if return_output_name:
256
256
  # Return file descriptor names
@@ -281,7 +281,7 @@ def subprocess_popen_helper(command, capture_output, encoding, return_output_nam
281
281
  else:
282
282
  return_dict["stderr"] = process.stderr.read().decode(encoding) if encoding else process.stderr.read()
283
283
 
284
- # Return the compiled result dictionary
284
+ # Return the compiled result dictionary #
285
285
  return return_dict
286
286
 
287
287
 
@@ -351,16 +351,16 @@ def subprocess_run_helper(command, capture_output, encoding, shell, text):
351
351
  """
352
352
  from subprocess import run
353
353
 
354
- # Set text parameter (if not provided, use encoding as a fallback)
354
+ # Set text parameter (if not provided, use encoding as a fallback) #
355
355
  text_param = text if text is not None else bool(encoding)
356
356
 
357
- # Execute the command and capture output if requested
357
+ # Execute the command and capture output if requested #
358
358
  result = run(command, capture_output=capture_output, text=text_param, shell=shell)
359
359
 
360
- # Initialise return dictionary with return code
360
+ # Initialise return dictionary with return code #
361
361
  return_dict = {"return_code": result.returncode}
362
362
 
363
- # Only process stdout/stderr if they were captured
363
+ # Only process stdout/stderr if they were captured #
364
364
  if capture_output:
365
365
  # Add stdout and stderr to the return dictionary if available
366
366
  if hasattr(result, "stdout"):
@@ -430,10 +430,10 @@ def exit_info(process_exit_info_obj, check_stdout=True, check_stderr=True, check
430
430
  raise RuntimeError("Command string interpreted as a path. "
431
431
  "Please check the command.")
432
432
  else:
433
- # Check if we're dealing with a dictionary or a CompletedProcess object
433
+ # Check if we're dealing with a dictionary or a CompletedProcess object #
434
434
  is_dict = isinstance(process_exit_info_obj, dict)
435
435
 
436
- # Get return code - handle both dict and CompletedProcess objects
436
+ # Get return code - handle both dict and CompletedProcess objects #
437
437
  if is_dict:
438
438
  return_code = process_exit_info_obj.get("return_code")
439
439
  # Check if we have any output information
@@ -446,7 +446,7 @@ def exit_info(process_exit_info_obj, check_stdout=True, check_stderr=True, check
446
446
  has_stdout = hasattr(process_exit_info_obj, "stdout")
447
447
  has_stderr = hasattr(process_exit_info_obj, "stderr")
448
448
 
449
- # Print stdout if available and requested
449
+ # Print stdout if available and requested #
450
450
  if check_stdout:
451
451
  if is_dict and has_stdout and process_exit_info_obj.get("stdout"):
452
452
  print(f"STDOUT\n{'='*6}")
@@ -455,7 +455,7 @@ def exit_info(process_exit_info_obj, check_stdout=True, check_stderr=True, check
455
455
  print(f"STDOUT\n{'='*6}")
456
456
  print(process_exit_info_obj.stdout)
457
457
 
458
- # Print stderr if available and requested
458
+ # Print stderr if available and requested #
459
459
  if check_stderr:
460
460
  if is_dict and has_stderr and process_exit_info_obj.get("stderr"):
461
461
  print(f"STDERR\n{'='*6}")
@@ -464,7 +464,7 @@ def exit_info(process_exit_info_obj, check_stdout=True, check_stderr=True, check
464
464
  print(f"STDERR\n{'='*6}")
465
465
  print(process_exit_info_obj.stderr)
466
466
 
467
- # Check return code if requested
467
+ # Check return code if requested #
468
468
  if check_return_code:
469
469
  if return_code == 0:
470
470
  print("Process completed successfully with return code 0")
@@ -482,7 +482,7 @@ def exit_info(process_exit_info_obj, check_stdout=True, check_stderr=True, check
482
482
  raise RuntimeError("An error occurred during command execution: "
483
483
  f"{format_string(NONZERO_EXIT_STATUS_TEMPLATE, format_args_error)}")
484
484
 
485
- # If return code checking is disabled, just return True
485
+ # If return code checking is disabled, just return True #
486
486
  return True
487
487
 
488
488
  # %%
@@ -104,11 +104,12 @@ def define_interval(left_limit, right_limit, constructor="pandas", closed="both"
104
104
  """
105
105
 
106
106
  # Input validation #
107
- #------------------#
107
+ #-#-#-#-#-#-#-#-#-#-
108
+
108
109
  _validate_interval_parameters(left_limit, right_limit, constructor, closed)
109
110
 
110
- # Operations #
111
- #------------#
111
+ # Program progression #
112
+ #-#-#-#-#-#-#-#-#-#-#-#
112
113
 
113
114
  if constructor == "intervaltree":
114
115
  print(f"WARNING: intervals constructed using constructor '{constructor}' "
@@ -167,7 +168,7 @@ def basic_interval_operator(interval_array,
167
168
  """
168
169
 
169
170
  # Input validation #
170
- #------------------#
171
+ #-#-#-#-#-#-#-#-#-#-
171
172
 
172
173
  particular_constructor_opts = INTERVAL_CONSTRUCTOR_OPTIONS[:2]
173
174
  all_args = get_caller_args()
@@ -187,8 +188,8 @@ def basic_interval_operator(interval_array,
187
188
  if isinstance(interval_array, list) and any(isinstance(item, list) for item in interval_array):
188
189
  interval_array = flatten_list(interval_array)
189
190
 
190
- # Operations #
191
- #------------#
191
+ # Program progression #
192
+ #-#-#-#-#-#-#-#-#-#-#-#
192
193
 
193
194
  try:
194
195
  if constructor == "pandas" and operator == "union" and force_union:
@@ -67,8 +67,8 @@ def sets_operator(array_of_sets1,
67
67
  if array_of_sets2 is not None and isinstance(array_of_sets2, list) and any(isinstance(item, list) for item in array_of_sets2):
68
68
  array_of_sets2 = flatten_list(array_of_sets2)
69
69
 
70
- # Operations #
71
- #-#-#-#-#-#-#-
70
+ # Program progression #
71
+ #-#-#-#-#-#-#-#-#-#-#-#
72
72
 
73
73
  if constructor == "default":
74
74
  if operator == "cartesian_product":
@@ -80,9 +80,11 @@ def _validate_option(arg_iterable, error_class, error_str):
80
80
  #-------#
81
81
 
82
82
  # Sum and subtract operations #
83
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
83
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
84
84
 
85
85
  # Main method #
86
+ #-#-#-#-#-#-#-#
87
+
86
88
  def sum_dt_objects(dt_obj_list,
87
89
  dt_fmt_str="%T",
88
90
  operation="sum",
@@ -151,8 +153,8 @@ def sum_dt_objects(dt_obj_list,
151
153
  arg_iterable_output_format = (output_format, TIME_OUTPUT_FORMAT_OPTIONS)
152
154
  _validate_option(arg_iterable_output_format, ValueError, INVALID_OUTPUT_FORMAT_TEMPLATE)
153
155
 
154
- # Operations #
155
- ##############
156
+ # Program progression #
157
+ #######################
156
158
 
157
159
  # Time delta object conversions #
158
160
  timedelta_list = []
@@ -171,6 +173,8 @@ def sum_dt_objects(dt_obj_list,
171
173
 
172
174
 
173
175
  # Auxiliary methods #
176
+ #-#-#-#-#-#-#-#-#-#-#
177
+
174
178
  def extract_dt_part(datetime_obj, part="time", arg_list=None):
175
179
  """
176
180
  Return the time or date part of a datetime object.
@@ -205,13 +209,13 @@ def extract_dt_part(datetime_obj, part="time", arg_list=None):
205
209
 
206
210
 
207
211
  # Time average #
208
- #-#-#-#-#-#-#-#-
212
+ #~~~~~~~~~~~~~~#
209
213
 
210
214
  # Adapted from https://stackoverflow.com/questions/12033905/using-python-to-create-an-average-out-of-a-list-of-times
211
215
  # and refined with ChatGPT
212
216
 
213
217
  # Main method #
214
- ###############
218
+ #-#-#-#-#-#-#-#
215
219
 
216
220
  def dt_average(dt_obj_list,
217
221
  time_fmt_str="%T",
@@ -270,8 +274,8 @@ def dt_average(dt_obj_list,
270
274
  arg_iterable_output_format = (output_format, TIME_OUTPUT_FORMAT_OPTIONS)
271
275
  _validate_option(arg_iterable_output_format, ValueError, INVALID_OUTPUT_FORMAT_TEMPLATE)
272
276
 
273
- # Operations #
274
- ##############
277
+ # Program progression #
278
+ #######################
275
279
 
276
280
  angles = [_dt_to_radians(dt_obj, "datetime", time_fmt_str) for dt_obj in dt_obj_list]
277
281
  avg_angle = _average_angle(angles)
@@ -283,7 +287,7 @@ def dt_average(dt_obj_list,
283
287
 
284
288
 
285
289
  # Auxiliary methods #
286
- #####################
290
+ #-#-#-#-#-#-#-#-#-#-#
287
291
 
288
292
  def _dt_to_radians(t, convert_to="datetime", time_fmt_str=None):
289
293
  """
@@ -401,7 +405,7 @@ def _radians_to_time_of_day(rads):
401
405
  #-------#
402
406
 
403
407
  # Sum and subtract operations #
404
- #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
408
+ #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
405
409
 
406
410
  def sum_date_objects(date_list,
407
411
  operation="sum",
@@ -465,8 +469,8 @@ def sum_date_objects(date_list,
465
469
  arg_iterable_output_format = (output_format, TIME_OUTPUT_FORMAT_OPTIONS)
466
470
  _validate_option(arg_iterable_output_format, ValueError, INVALID_OUTPUT_FORMAT_TEMPLATE)
467
471
 
468
- # Operations #
469
- ##############
472
+ # Program progression #
473
+ #######################
470
474
 
471
475
  # Perform the aritmethical operations #
472
476
  total_date = parse_dt_string(date_list[0], dt_fmt_str)
@@ -582,7 +586,7 @@ def _add_dates_with_year_gap(date1, date2, operation):
582
586
 
583
587
 
584
588
  # Natural years #
585
- #-#-#-#-#-#-#-#-#
589
+ #~~~~~~~~~~~~~~#
586
590
 
587
591
  def natural_year(dt_start, dt_end, dt_fmt_str=None,
588
592
  method="pandas",
@@ -641,8 +645,8 @@ def natural_year(dt_start, dt_end, dt_fmt_str=None,
641
645
  "must be a boolean.")
642
646
 
643
647
 
644
- # Operations #
645
- #·#·#·#·#·#·#·
648
+ # Program progression #
649
+ #·#·#·#·#·#·#·#·#·#·#·#
646
650
 
647
651
  # Convert input objects to datetime objects #
648
652
  #############################################
@@ -102,7 +102,7 @@ def program_exec_timer(mode, module="time", frac_precision=3):
102
102
  global ti
103
103
 
104
104
  # Input validations #
105
- #-------------------#
105
+ #-#-#-#-#-#-#-#-#-#-#
106
106
 
107
107
  # Module #
108
108
  _validate_option("Module", module, MODULE_LIST)
@@ -110,8 +110,8 @@ def program_exec_timer(mode, module="time", frac_precision=3):
110
110
  # Fractional second precision #
111
111
  _validate_precision(frac_precision, max_prec=6)
112
112
 
113
- # Operations #
114
- #------------#
113
+ # Program progression #
114
+ #-#-#-#-#-#-#-#-#-#-#-#
115
115
 
116
116
  if mode == "start":
117
117
  ti = MODULE_OPERATION_DICT[module]()
@@ -140,6 +140,8 @@ def snippet_exec_timer(snippet_str,
140
140
  return_best_time=False):
141
141
 
142
142
  # Roundoff validation #
143
+ #-#-#-#-#-#-#-#-#-#-#-#
144
+
143
145
  param_keys = get_caller_args()
144
146
  roundoff_arg_pos = find_substring_index(param_keys, "roundoff")
145
147
 
@@ -147,6 +149,8 @@ def snippet_exec_timer(snippet_str,
147
149
  raise TypeError(format_string(TYPE_ERROR_TEMPLATE, f'{param_keys[roundoff_arg_pos]}'))
148
150
 
149
151
  # Set keyword argument dictionary for float time parsing #
152
+ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
153
+
150
154
  float_time_parsing_kwargs = dict(
151
155
  module="str",
152
156
  origin="arbitrary",
@@ -154,6 +158,8 @@ def snippet_exec_timer(snippet_str,
154
158
  )
155
159
 
156
160
  # Execution time in the specified number of trials with no repeats #
161
+ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
162
+
157
163
  if repeats is None:
158
164
  exec_time_norep = timeit.timeit(setup=snippet_str,
159
165
  number=trials,
@@ -178,6 +184,8 @@ def snippet_exec_timer(snippet_str,
178
184
  print_format_string(NOREP_EXEC_TIME_INFO_TEMPLATE, format_args_exec_timer1)
179
185
 
180
186
  # Execution time in the specified number of trials for several repeats #
187
+ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-
188
+
181
189
  else:
182
190
  exec_time_rep = timeit.repeat(setup=snippet_str,
183
191
  repeat=repeats,
@@ -7,12 +7,12 @@
7
7
 
8
8
  # Standard modules #
9
9
  import time
10
- from datetime import datetime
10
+ from datetime import datetime, timedelta
11
11
 
12
12
  # Third-party modules #
13
13
  import numpy as np
14
14
  import pandas as pd
15
- from dateutil import parser
15
+ from dateutil.parser import parse
16
16
 
17
17
  #------------------------#
18
18
  # Import project modules #
@@ -204,7 +204,7 @@ def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns",
204
204
  """
205
205
 
206
206
  # Input validation #
207
- ####################
207
+ #-#-#-#-#-#-#-#-#-#-
208
208
 
209
209
  # Module #
210
210
  allowed_modules = list(TIME_STR_PARSING_DICT.keys())
@@ -215,7 +215,7 @@ def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns",
215
215
  raise ValueError("A datetime format string must be provided for non-pandas modules.")
216
216
 
217
217
  # Time string parsing #
218
- #######################
218
+ #-#-#-#-#-#-#-#-#-#-#-#
219
219
 
220
220
  try:
221
221
  parse_func = TIME_STR_PARSING_DICT.get(module)
@@ -245,7 +245,7 @@ def parse_dt_string(datetime_str, dt_fmt_str=None, module="datetime", unit="ns",
245
245
  #--------------------------#
246
246
 
247
247
  # Main function #
248
- #-#-#-#-#-#-#-#-#
248
+ #~~~~~~~~~~~~~~~#
249
249
 
250
250
  def parse_float_dt(datetime_float,
251
251
  frac_precision=None,
@@ -308,14 +308,14 @@ def parse_float_dt(datetime_float,
308
308
  """
309
309
 
310
310
  # Input validation #
311
- ####################
311
+ #-#-#-#-#-#-#-#-#-#-
312
312
 
313
313
  # Module #
314
314
  allowed_modules = ["str"] + list(FLOATED_TIME_PARSING_DICT.keys())
315
315
  _validate_option("Object type conversion", module, allowed_modules)
316
316
 
317
317
  # Time formatting string #
318
- if module != "str" and not dt_fmt_str:
318
+ if module == "str" and not dt_fmt_str:
319
319
  raise ValueError("You must provide a formatting string.")
320
320
 
321
321
  # Fractional second precision #
@@ -325,7 +325,7 @@ def parse_float_dt(datetime_float,
325
325
  _validate_unit(unit, module)
326
326
 
327
327
  # Floated time parsing #
328
- ########################
328
+ #-#-#-#-#-#-#-#-#-#-#-#-
329
329
 
330
330
  if module == "str":
331
331
  return _parse_float_to_string(datetime_float,
@@ -341,7 +341,7 @@ def parse_float_dt(datetime_float,
341
341
 
342
342
 
343
343
  # Auxiliary functions #
344
- #-#-#-#-#-#-#-#-#-#-#-#
344
+ #~~~~~~~~~~~~~~~~~~~~~#
345
345
 
346
346
  def _parse_float_to_string(floated_time,
347
347
  frac_precision,
@@ -433,7 +433,7 @@ def _float_dt_parser(floated_time, module, unit, dayfirst, yearfirst):
433
433
  """
434
434
 
435
435
  # Input validation #
436
- ####################
436
+ #-#-#-#-#-#-#-#-#-#-
437
437
 
438
438
  # Module #
439
439
  allowed_modules = list(FLOATED_TIME_PARSING_DICT.keys())
@@ -443,7 +443,7 @@ def _float_dt_parser(floated_time, module, unit, dayfirst, yearfirst):
443
443
  _validate_unit(unit, module)
444
444
 
445
445
  # Calculate datetime object #
446
- #############################
446
+ #-#-#-#-#-#-#-#-#-#-#-#-#-#-#
447
447
 
448
448
  datetime_obj = FLOATED_TIME_PARSING_DICT.get(module)(floated_time, unit, dayfirst, yearfirst)
449
449
  return datetime_obj
@@ -514,19 +514,19 @@ def _format_arbitrary_dt(floated_time, frac_precision):
514
514
  # %% PARSING AMONG COMPLEX DATA OBJECTS
515
515
 
516
516
  # Main functions #
517
- #--------------#
517
+ #----------------#
518
518
 
519
519
  # All except 'float' #
520
- #-#-#-#-#-#-#-#-#-#-#-
520
+ #~~~~~~~~~~~~~~~~~~~~#
521
521
 
522
522
  def dt_obj_converter(datetime_obj,
523
- convert_to,
524
- unit="s",
525
- float_class="d",
526
- int_class="int",
527
- dt_fmt_str=None,
528
- dayfirst=False,
529
- yearfirst=False):
523
+ convert_to,
524
+ unit="s",
525
+ float_class="d",
526
+ int_class="int",
527
+ dt_fmt_str=None,
528
+ dayfirst=False,
529
+ yearfirst=False):
530
530
 
531
531
  """
532
532
  Convert a date/time object to another, including float and string representation.
@@ -604,16 +604,24 @@ def dt_obj_converter(datetime_obj,
604
604
  """
605
605
 
606
606
  # Input validation #
607
- ####################
607
+ #-#-#-#-#-#-#-#-#-#-
608
608
 
609
609
  # Object type to convert to #
610
610
  if not convert_to:
611
611
  raise ValueError("Argument 'convert_to' not provided.")
612
612
 
613
613
  # Helper function to perform conversion and handle exceptions
614
- def perform_conversion(conversion_dict, obj, *args):
614
+ def perform_conversion(conversion_dict, obj, **kwargs):
615
615
  try:
616
- return conversion_dict.get(convert_to)(obj, *args)
616
+ return conversion_dict.get(convert_to)(
617
+ obj,
618
+ kwargs.get("unit"),
619
+ kwargs.get("float_class"),
620
+ kwargs.get("int_class"),
621
+ kwargs.get("dt_fmt_str"),
622
+ kwargs.get("dayfirst"),
623
+ kwargs.get("yearfirst"),
624
+ )
617
625
  except Exception as err:
618
626
  raise RuntimeError(f"Error during conversion to '{convert_to}': {err}")
619
627
 
@@ -625,8 +633,8 @@ def dt_obj_converter(datetime_obj,
625
633
  _validate_option("Numpy float precision class", float_class, _FLOAT_CLASS_LIST)
626
634
  _validate_option("Numpy integer precision class", int_class, _INT_CLASS_LIST)
627
635
 
628
- # Operations #
629
- ##############
636
+ # Program progression #
637
+ #-#-#-#-#-#-#-#-#-#-#-#
630
638
 
631
639
  # Get the object type's name #
632
640
  obj_type = get_type_str(datetime_obj, lowercase=True)
@@ -647,9 +655,11 @@ def dt_obj_converter(datetime_obj,
647
655
  #---------------------#
648
656
 
649
657
  # Exclusively to 'float' #
650
- #-#-#-#-#-#-#-#-#-#-#-#-#-
658
+ #~~~~~~~~~~~~~~~~~~~~~~~~#
651
659
 
652
660
  # Scalar complex data #
661
+ #-#-#-#-#-#-#-#-#-#-#-#
662
+
653
663
  def _total_dt_unit(datetime_obj, unit, float_class=None, int_class=None):
654
664
  """
655
665
  Convert a datetime object into total time based on the specified unit
@@ -680,13 +690,13 @@ def _total_dt_unit(datetime_obj, unit, float_class=None, int_class=None):
680
690
  If an error occurs during the conversion process.
681
691
  """
682
692
  # Input validation #
683
- #------------------#
693
+ ####################
684
694
 
685
695
  # Current function name #
686
696
  current_function = get_func_name()
687
697
 
688
- # Operations #
689
- #------------#
698
+ # Program progression #
699
+ #######################
690
700
 
691
701
  unit_factor = UNIT_FACTOR_DICT.get(unit)
692
702
  obj_type = get_type_str(datetime_obj, lowercase=True)
@@ -809,7 +819,7 @@ def _to_string(dt_obj, unit, dt_fmt_str):
809
819
  return dt_obj.strftime(dt_fmt_str)
810
820
 
811
821
  # Handle np.ndarray with datetime-like objects
812
- if isinstance(dt_obj, np.ndarray()):
822
+ if isinstance(dt_obj, np.ndarray):
813
823
  try:
814
824
  dt_obj = np.vectorize(lambda x: _to_datetime_aux(x, unit).strftime(dt_fmt_str))(dt_obj)
815
825
  except Exception as e:
@@ -819,7 +829,7 @@ def _to_string(dt_obj, unit, dt_fmt_str):
819
829
  # Handle pd.Series
820
830
  if isinstance(dt_obj, pd.Series):
821
831
  try:
822
- return dt_obj.apply(lambda dfs_col: dfs_col.dt.strftime(dt_fmt_str)
832
+ return dt_obj.apply(lambda dfs_col: dfs_col.strftime(dt_fmt_str)
823
833
  if hasattr(dfs_col, 'strftime') else str(dfs_col))
824
834
  except Exception as e:
825
835
  raise ValueError(f"Error in converting pd.Series to string: {e}")
@@ -879,11 +889,11 @@ def __time_component_to_float(t):
879
889
  time_component_float : int
880
890
  Seconds relative to the Unix epoch.
881
891
  """
882
- time_component_float = datetime.timedelta(hours=t.hour,
883
- minutes=t.minute,
884
- seconds=t.second,
885
- microseconds=t.microsecond)
886
- return time_component_float
892
+ time_component_float = timedelta(hours=t.hour,
893
+ minutes=t.minute,
894
+ seconds=t.second,
895
+ microseconds=t.microsecond)
896
+ return time_component_float.total_seconds()
887
897
 
888
898
 
889
899
  def _to_datetime(dt_obj, unit=None):
@@ -1052,14 +1062,14 @@ _INT_CLASS_LIST = [np.int8, np.int16, "i", np.float32, "int", np.int64]
1052
1062
  #--------------------------#
1053
1063
 
1054
1064
  # Time parsing #
1055
- #--------------#
1065
+ #~~~~~~~~~~~~~~#
1056
1066
 
1057
1067
  # String #
1058
1068
  #-#-#-#-#-
1059
1069
 
1060
1070
  TIME_STR_PARSING_DICT = {
1061
1071
  "datetime" : lambda datetime_str, dt_fmt_str: datetime.strptime(datetime_str, dt_fmt_str),
1062
- "dateutil" : lambda datetime_str, dt_fmt_str: parser.parse(datetime_str, dt_fmt_str),
1072
+ "dateutil" : lambda datetime_str, dt_fmt_str: parse(datetime_str),
1063
1073
  "pandas" : lambda datetime_str, dt_fmt_str, unit, dayfirst=False, yearfirst=False : pd.to_datetime(datetime_str, format=dt_fmt_str, dayfirst=dayfirst, yearfirst=yearfirst),
1064
1074
  "numpy" : lambda datetime_str, _, unit : np.datetime64(datetime_str, unit),
1065
1075
  "arrow" : lambda datetime_str, dt_fmt_str: _arrow_get_with_import(datetime_str, dt_fmt_str)
@@ -1081,63 +1091,63 @@ FLOATED_TIME_PARSING_DICT = {
1081
1091
 
1082
1092
  # To other objects #
1083
1093
  DT_OBJ_CONVERSION_DICT = {
1084
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : dt_obj.timestamp(),
1085
- "time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : dt_obj.timetuple(),
1086
- "pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(_tzinfo_remover(dt_obj), unit, dayfirst, yearfirst),
1087
- "numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_numpy(_tzinfo_remover(dt_obj), unit),
1088
- "arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
1089
- "str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
1094
+ "float" : lambda dt_obj, _, __, ___, ____, _____, ______ : dt_obj.timestamp(),
1095
+ "time" : lambda dt_obj, _, __, ___, ____, _____, ______ : dt_obj.timetuple(),
1096
+ "pandas" : lambda dt_obj, unit, __, ___, ____, dayfirst, yearfirst : _to_pandas(_tzinfo_remover(dt_obj), unit, dayfirst, yearfirst),
1097
+ "numpy" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_numpy(_tzinfo_remover(dt_obj), unit),
1098
+ "arrow" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_arrow(dt_obj),
1099
+ "str" : lambda dt_obj, unit, __, ___, dt_fmt_str, _____, ______ : _to_string(dt_obj, unit, dt_fmt_str)
1090
1100
  }
1091
1101
 
1092
1102
  DT64_OBJ_CONVERSION_DICT = {
1093
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
1094
- "datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
1095
- "time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
1096
- "pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(dt_obj, unit, dayfirst, yearfirst),
1097
- "arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
1098
- "str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(_to_datetime(dt_obj), unit, dt_fmt_str)
1103
+ "float" : lambda dt_obj, unit, float_class, __, ___, _____, ______ : _to_float(dt_obj, unit, float_class),
1104
+ "datetime" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_datetime(dt_obj, unit),
1105
+ "time" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_time_struct(dt_obj, unit),
1106
+ "pandas" : lambda dt_obj, unit, __, ___, ____, dayfirst, yearfirst : _to_pandas(dt_obj, unit, dayfirst, yearfirst),
1107
+ "arrow" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_arrow(dt_obj),
1108
+ "str" : lambda dt_obj, unit, __, ___, dt_fmt_str, _____, ______ : _to_string(_to_datetime(dt_obj), unit, dt_fmt_str)
1099
1109
  }
1100
1110
 
1101
1111
  DT_TIME_OBJ_CONVERSION_DICT = {
1102
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
1103
- "datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
1104
- "time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
1105
- "pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(_to_datetime(dt_obj), unit, dayfirst, yearfirst),
1106
- "numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_numpy(_to_datetime(dt_obj), unit),
1107
- "arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
1108
- "str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
1112
+ "float" : lambda dt_obj, unit, float_class, __, ___, _____, ______ : _to_float(dt_obj, unit, float_class),
1113
+ "datetime" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_datetime(dt_obj, unit),
1114
+ "time" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_time_struct(dt_obj),
1115
+ "pandas" : lambda dt_obj, unit, __, ___, ____, dayfirst, yearfirst : _to_pandas(_to_datetime(dt_obj), unit, dayfirst, yearfirst),
1116
+ "numpy" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_numpy(_to_datetime(dt_obj), unit),
1117
+ "arrow" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_arrow(dt_obj),
1118
+ "str" : lambda dt_obj, unit, __, ___, dt_fmt_str, _____, ______ : _to_string(dt_obj, unit, dt_fmt_str)
1109
1119
  }
1110
1120
 
1111
1121
  TIMESTAMP_OBJ_CONVERSION_DICT = {
1112
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
1113
- "datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
1114
- "time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
1115
- "numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : dt_obj.to_numpy(),
1116
- "arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
1117
- "str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
1122
+ "float" : lambda dt_obj, unit, float_class, __, ___, _____, ______ : _to_float(dt_obj, unit, float_class),
1123
+ "datetime" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_datetime(dt_obj, unit),
1124
+ "time" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_time_struct(dt_obj),
1125
+ "numpy" : lambda dt_obj, _, __, ___, ____, _____, ______ : dt_obj.to_numpy(),
1126
+ "arrow" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_arrow(dt_obj),
1127
+ "str" : lambda dt_obj, unit, __, ___, dt_fmt_str, _____, ______ : _to_string(dt_obj, unit, dt_fmt_str)
1118
1128
  }
1119
1129
 
1120
1130
  ARROW_OBJ_CONVERSION_DICT = {
1121
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
1122
- "datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
1123
- "time" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_time_struct(dt_obj),
1124
- "pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_pandas(dt_obj, unit, dayfirst, yearfirst),
1125
- "numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_numpy(dt_obj, unit),
1126
- "str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
1131
+ "float" : lambda dt_obj, unit, float_class, __, ___, _____, ______ : _to_float(dt_obj, unit, float_class),
1132
+ "datetime" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_datetime(dt_obj, unit),
1133
+ "time" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_time_struct(dt_obj),
1134
+ "pandas" : lambda dt_obj, unit, __, ___, ____, dayfirst, yearfirst : _to_pandas(dt_obj, unit, dayfirst, yearfirst),
1135
+ "numpy" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_numpy(dt_obj, unit),
1136
+ "str" : lambda dt_obj, unit, __, ___, dt_fmt_str, _____, ______ : _to_string(dt_obj, unit, dt_fmt_str)
1127
1137
  }
1128
1138
 
1129
1139
  TIME_STT_OBJ_CONVERSION_DICT = {
1130
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_float(dt_obj, unit, float_class),
1131
- "datetime" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
1132
- "pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : pd.Timestamp(*dt_obj[:6], unit=unit),
1133
- "numpy" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : np.datetime64(datetime(*dt_obj[:6]), unit),
1134
- "arrow" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_arrow(dt_obj),
1140
+ "float" : lambda dt_obj, unit, float_class, __, ___, _____, ______ : _to_float(dt_obj, unit, float_class),
1141
+ "datetime" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_datetime(dt_obj, unit),
1142
+ "pandas" : lambda dt_obj, unit, __, ___, ____, _____, ______ : pd.Timestamp(*dt_obj[:6], unit=unit),
1143
+ "numpy" : lambda dt_obj, unit, __, ___, ____, _____, ______ : np.datetime64(datetime(*dt_obj[:6]), unit),
1144
+ "arrow" : lambda dt_obj, _, __, ___, ____, _____, ______ : _to_arrow(dt_obj),
1135
1145
  }
1136
1146
 
1137
1147
  _DT_LIKE_OBJ_CONVERSION_DICT = {
1138
- "float" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _total_dt_unit(dt_obj, unit, float_class, int_class),
1139
- "pandas" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_datetime(dt_obj, unit),
1140
- "str" : lambda dt_obj, unit=None, float_class=None, int_class=None, dt_fmt_str=None, dayfirst=False, yearfirst=False : _to_string(dt_obj, unit, dt_fmt_str)
1148
+ "float" : lambda dt_obj, unit, float_class, int_class, ___, _____, ______ : _total_dt_unit(dt_obj, unit, float_class, int_class),
1149
+ "pandas" : lambda dt_obj, unit, __, ___, ____, _____, ______ : _to_datetime(dt_obj, unit),
1150
+ "str" : lambda dt_obj, unit, __, ___, dt_fmt_str, _____, ______ : _to_string(dt_obj, unit, dt_fmt_str)
1141
1151
  }
1142
1152
 
1143
1153
  # Enumerate all possibilities #
@@ -1155,13 +1165,13 @@ CONVERSION_OPT_DICT = {
1155
1165
 
1156
1166
  # Exclusively to floated time #
1157
1167
  _TOTAL_TIME_UNIT_DICT = {
1158
- "datetime" : lambda dt_obj, _ : dt_obj.timestamp(),
1159
- "datetime64" : lambda dt_obj, unit, float_class : dt_obj.astype(f"timedelta64[{unit}]").astype(float_class),
1160
- "struct_time" : lambda dt_obj, _ : datetime(*dt_obj[:6]),
1161
- "arrow" : lambda dt_obj, _ : dt_obj.float_timestamp,
1162
- "dataframe" : lambda dt_obj, _, int_class, unit_factor : _total_dt_complex_data(dt_obj, int_class, unit_factor),
1163
- "series" : lambda dt_obj, _, int_class, unit_factor : _total_dt_complex_data(dt_obj, int_class, unit_factor),
1164
- "ndarray" : lambda dt_obj, unit, float_class, _ : dt_obj.astype(f"datetime64[{unit}]").astype(float_class)
1168
+ "datetime" : lambda dt_obj, _, __, ___, ____ : dt_obj.timestamp(),
1169
+ "datetime64" : lambda dt_obj, unit, float_class, _, __ : dt_obj.astype(f"timedelta64[{unit}]").astype(float_class),
1170
+ "struct_time" : lambda dt_obj, _, __, ___, ____ : datetime(*dt_obj[:6]),
1171
+ "arrow" : lambda dt_obj, _, __, ___, ____ : dt_obj.float_timestamp,
1172
+ "dataframe" : lambda dt_obj, _, __, int_class, unit_factor : _total_dt_complex_data(dt_obj, int_class, unit_factor),
1173
+ "series" : lambda dt_obj, _, __, int_class, unit_factor : _total_dt_complex_data(dt_obj, int_class, unit_factor),
1174
+ "ndarray" : lambda dt_obj, unit, float_class, _, __ : dt_obj.astype(f"datetime64[{unit}]").astype(float_class)
1165
1175
  }
1166
1176
 
1167
1177
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygenutils
3
- Version: 16.2.3
3
+ Version: 16.3.0
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.2.3"
7
+ version = "16.3.0"
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