bulum 0.3.1__tar.gz → 0.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 (54) hide show
  1. {bulum-0.3.1/src/bulum.egg-info → bulum-0.3.2}/PKG-INFO +1 -1
  2. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/utils/datetime_functions.py +32 -20
  3. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/version.py +1 -1
  4. {bulum-0.3.1 → bulum-0.3.2/src/bulum.egg-info}/PKG-INFO +1 -1
  5. {bulum-0.3.1 → bulum-0.3.2}/LICENSE.md +0 -0
  6. {bulum-0.3.1 → bulum-0.3.2}/README.md +0 -0
  7. {bulum-0.3.1 → bulum-0.3.2}/setup.cfg +0 -0
  8. {bulum-0.3.1 → bulum-0.3.2}/setup.py +0 -0
  9. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/__init__.py +0 -0
  10. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/clim/__init__.py +0 -0
  11. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/clim/clim.py +0 -0
  12. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/demo.py +0 -0
  13. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/__init__.py +0 -0
  14. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/csv_io.py +0 -0
  15. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/general_io.py +0 -0
  16. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/idx_io.py +0 -0
  17. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/idx_io_native.py +0 -0
  18. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/iqqm_out_reader.py +0 -0
  19. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/lqn_io.py +0 -0
  20. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/io/res_csv_io.py +0 -0
  21. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/maps/__init__.py +0 -0
  22. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/maps/station_maps.py +0 -0
  23. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/__init__.py +0 -0
  24. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/altair_plots.py +0 -0
  25. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/ensemble_altair_plots.py +0 -0
  26. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/node_diagrams.py +0 -0
  27. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/plot_functions.py +0 -0
  28. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/plotly_helpers.py +0 -0
  29. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/tests/__init__.py +0 -0
  30. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/plots/tests/test_plot_functions.py +0 -0
  31. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/__init__.py +0 -0
  32. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/aggregate_stats.py +0 -0
  33. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/ensemble_stats.py +0 -0
  34. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/negflo.py +0 -0
  35. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/negflo_helpers.py +0 -0
  36. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/reliability_stats_class.py +0 -0
  37. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/stochastic_data_check.py +0 -0
  38. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/storage_level_assessment.py +0 -0
  39. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/swflo2s/__init__.py +0 -0
  40. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stats/swflo2s/swflo2s.py +0 -0
  41. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stoch/__init__.py +0 -0
  42. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stoch/analyse.py +0 -0
  43. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/stoch/generate.py +0 -0
  44. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/test_circular_import.py +0 -0
  45. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/trans/__init__.py +0 -0
  46. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/trans/transformers.py +0 -0
  47. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/utils/__init__.py +0 -0
  48. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/utils/dataframe_extensions.py +0 -0
  49. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/utils/dataframe_functions.py +0 -0
  50. {bulum-0.3.1 → bulum-0.3.2}/src/bulum/utils/interpolation.py +0 -0
  51. {bulum-0.3.1 → bulum-0.3.2}/src/bulum.egg-info/SOURCES.txt +0 -0
  52. {bulum-0.3.1 → bulum-0.3.2}/src/bulum.egg-info/dependency_links.txt +0 -0
  53. {bulum-0.3.1 → bulum-0.3.2}/src/bulum.egg-info/requires.txt +0 -0
  54. {bulum-0.3.1 → bulum-0.3.2}/src/bulum.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bulum
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Open source python library for assessing hydrologic model results in Queensland
5
5
  Home-page: https://github.com/odhydrology/bulum
6
6
  Author: Chas Egan
@@ -1,4 +1,5 @@
1
1
  import calendar
2
+ import warnings
2
3
  from datetime import datetime, timedelta
3
4
  from typing import Iterable, Optional, cast, overload
4
5
 
@@ -51,8 +52,8 @@ def standardize_datestring_format(values: list[str]) -> list[str]:
51
52
  Converts a list of date strings into a list of date strings in the format YYYY-MM-DD.
52
53
 
53
54
  This function automatically detects the input date format and converts all dates
54
- to the standard ISO 8601 format (YYYY-MM-DD). Tested over the range 0001-01-01
55
- to 9999-12-31.
55
+ to the standard ISO 8601 format (YYYY-MM-DD). Uses numpy datetime64 for efficient
56
+ processing. Tested over the range 0001-01-01 to 9999-12-31.
56
57
 
57
58
  Parameters
58
59
  ----------
@@ -70,10 +71,13 @@ def standardize_datestring_format(values: list[str]) -> list[str]:
70
71
  ['2023-12-25', '2023-12-26']
71
72
  """
72
73
  date_format = get_date_format(values[0])
74
+
73
75
  try:
76
+ # Use numpy datetime64 for efficient conversion
74
77
  np_dates = to_np_datetimes64d(values, date_fmt=date_format)
75
78
  except ValueError as e:
76
79
  if "End date format does not match start date format" in str(e):
80
+ # Handle mixed date formats by converting end date to match start format
77
81
  end_date_format = get_date_format(values[-1])
78
82
  placeholder_values = ["" for _ in values]
79
83
  placeholder_values[0] = values[0]
@@ -81,7 +85,10 @@ def standardize_datestring_format(values: list[str]) -> list[str]:
81
85
  np_dates = to_np_datetimes64d(placeholder_values, date_fmt=date_format)
82
86
  else:
83
87
  raise e
84
- return [str(t) for t in np_dates]
88
+
89
+ # Convert numpy datetime64 to clean YYYY-MM-DD strings by taking first 10 characters
90
+ # This strips any timestamp component (e.g., "T00:00:00.000000")
91
+ return [str(t)[:10] for t in np_dates]
85
92
 
86
93
 
87
94
  def standardise_datestring_format(values):
@@ -93,34 +100,33 @@ def to_np_datetimes64d(values: list[str], date_fmt: str = r'%Y-%m-%d',
93
100
  *, check_length: bool = True) -> np.typing.NDArray[np.datetime64]:
94
101
  """Convert a list of date strings to numpy datetime64[D] array.
95
102
 
96
- This function efficiently converts consecutive date strings to numpy datetime64
97
- arrays with day precision. It handles edge cases at the end of the representable
98
- date range (9999-12-31).
99
-
100
- You can turn off the length checking to pass in two dates and receive an
101
- array with all dates between the specified dates (inclusive). See the second
102
- example below.
103
+ This function efficiently converts date strings to numpy datetime64 arrays with
104
+ day precision. It generates all dates between the first and last date in the input.
105
+ Handles edge cases at the end of the representable date range (9999-12-31).
103
106
 
104
107
  Parameters
105
108
  ----------
106
109
  values : list[str]
107
- List of consecutive date strings to convert.
110
+ List of date strings to convert. Can also accept pandas Series.
111
+ Generates all dates from first to last date (inclusive).
108
112
  date_fmt : str, default '%Y-%m-%d'
109
113
  The date format string for parsing the input dates.
110
114
  check_length : bool, default True
111
115
  Whether to validate that the number of generated dates matches the input length.
112
- Set to False to skip consecutive date validation.
116
+ If True and lengths don't match, issues a warning but still returns all dates
117
+ between start and end. Set to False to suppress the warning.
113
118
 
114
119
  Returns
115
120
  -------
116
121
  np.typing.NDArray[np.datetime64]
117
- Numpy array of consecutive datetime64[D] values from start to end date.
122
+ Numpy array of datetime64[D] values from first to last date (inclusive).
123
+ Returns all dates in the range, regardless of input length.
118
124
 
119
- Raises
120
- ------
121
- ValueError
125
+ Warns
126
+ -----
127
+ UserWarning
122
128
  If check_length is True and the number of generated dates doesn't match
123
- the input length, indicating non-consecutive dates.
129
+ the input length, indicating non-consecutive dates or gaps.
124
130
 
125
131
  Examples
126
132
  --------
@@ -131,6 +137,10 @@ def to_np_datetimes64d(values: list[str], date_fmt: str = r'%Y-%m-%d',
131
137
  >>> len(to_np_datetimes64d(['2023-01-01', '2023-01-03'], check_length=False))
132
138
  3
133
139
  """
140
+ # Convert pandas Series to list if needed (most robust fix for pandas Series indexing)
141
+ if hasattr(values, 'tolist'):
142
+ values = values.tolist()
143
+
134
144
  start_date = datetime.strptime(values[0], date_fmt)
135
145
  try:
136
146
  end_date = datetime.strptime(values[-1], date_fmt)
@@ -146,9 +156,11 @@ def to_np_datetimes64d(values: list[str], date_fmt: str = r'%Y-%m-%d',
146
156
  np_dates = np.arange(start_date, end_date + timedelta(days=1), dtype='datetime64[D]')
147
157
 
148
158
  if check_length and len(np_dates) != len(values):
149
- raise ValueError(f"Date sequence validation failed: Expected {len(np_dates)} consecutive dates "
150
- f"between {start_date} and {end_date} but found {len(values)} values. "
151
- f"This suggests non-consecutive dates or gaps in the sequence.")
159
+ warnings.warn(f"Date sequence validation: Expected {len(np_dates)} consecutive dates "
160
+ f"between {start_date} and {end_date} but found {len(values)} values. "
161
+ f"This suggests non-consecutive dates or gaps in the sequence. "
162
+ f"Returning all dates between start and end.",
163
+ UserWarning, stacklevel=2)
152
164
  return np_dates
153
165
 
154
166
 
@@ -2,4 +2,4 @@
2
2
  # 1) we don't load dependencies by storing it in __init__.py
3
3
  # 2) we can import it in setup.py for the same reason
4
4
  # 3) we can import it into your module
5
- __version__ = '0.3.1'
5
+ __version__ = '0.3.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: bulum
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Open source python library for assessing hydrologic model results in Queensland
5
5
  Home-page: https://github.com/odhydrology/bulum
6
6
  Author: Chas Egan
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