cave-utils 3.4.2__tar.gz → 3.4.4__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 (41) hide show
  1. {cave_utils-3.4.2 → cave_utils-3.4.4}/LICENSE +0 -0
  2. {cave_utils-3.4.2 → cave_utils-3.4.4}/NOTICE.md +0 -0
  3. {cave_utils-3.4.2/cave_utils.egg-info → cave_utils-3.4.4}/PKG-INFO +1 -1
  4. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/__init__.py +0 -0
  5. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/__init__.py +0 -0
  6. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/appBar.py +0 -0
  7. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/extraKwargs.py +0 -0
  8. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/globalOutputs.py +0 -0
  9. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/groupedOutputs.py +0 -0
  10. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/mapFeatures.py +0 -0
  11. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/maps.py +0 -0
  12. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/pages.py +3 -0
  13. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/panes.py +0 -0
  14. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api/settings.py +0 -0
  15. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api_utils/__init__.py +0 -0
  16. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api_utils/general.py +0 -0
  17. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api_utils/validator.py +0 -0
  18. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/api_utils/validator_utils.py +0 -0
  19. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/arguments.py +0 -0
  20. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/builders/__init__.py +0 -0
  21. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/builders/groups.py +47 -10
  22. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/custom_coordinates.py +0 -0
  23. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/geo_utils.py +0 -0
  24. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/log.py +0 -0
  25. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils/socket.py +0 -0
  26. {cave_utils-3.4.2 → cave_utils-3.4.4/cave_utils.egg-info}/PKG-INFO +1 -1
  27. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils.egg-info/SOURCES.txt +1 -0
  28. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils.egg-info/dependency_links.txt +0 -0
  29. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils.egg-info/requires.txt +0 -0
  30. {cave_utils-3.4.2 → cave_utils-3.4.4}/cave_utils.egg-info/top_level.txt +0 -0
  31. {cave_utils-3.4.2 → cave_utils-3.4.4}/pyproject.toml +1 -1
  32. {cave_utils-3.4.2 → cave_utils-3.4.4}/setup.cfg +1 -1
  33. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_arguments.py +0 -0
  34. cave_utils-3.4.4/test/test_builders_date_groups.py +85 -0
  35. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_builders_groups.py +0 -0
  36. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_custom_coordinates.py +0 -0
  37. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_geo_utils.py +0 -0
  38. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_log.py +0 -0
  39. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_socket.py +0 -0
  40. {cave_utils-3.4.2 → cave_utils-3.4.4}/test/test_validator.py +0 -0
  41. {cave_utils-3.4.2 → cave_utils-3.4.4}/README.md +0 -0
File without changes
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cave_utils
3
- Version: 3.4.2
3
+ Version: 3.4.4
4
4
  Summary: Python wrapper for api use in the cave_app
5
5
  Author-email: Connor Makowski <conmak@mit.edu>
6
6
  Project-URL: Homepage, https://github.com/mit-cave/cave_utils
@@ -173,6 +173,7 @@ class pages_data_star_charts(ApiValidator):
173
173
  distributionVariant: str | None = None,
174
174
  xAxisOrder: str | None = None,
175
175
  showNA: bool = False,
176
+ filters: list[dict] | None = None,
176
177
  **kwargs,
177
178
  ):
178
179
  """
@@ -259,6 +260,7 @@ class pages_data_star_charts(ApiValidator):
259
260
  * `"alpha_descending"`: Orders the x-axis in reverse alphabetical order.
260
261
  * **Note**: If left unspecified (i.e., `None`), it will default to `"default"`.
261
262
  * **`showNA`**: `[bool]` = `False` &rarr; Whether to display missing or filtered values in both the chart tooltip and the axis.
263
+ * **`filters`**: `[dict]` = `None` &rarr; A list of filter dictionaries to apply to the chart data.
262
264
 
263
265
  [area chart]: https://en.wikipedia.org/wiki/Area_chart
264
266
  [bar chart]: https://en.wikipedia.org/wiki/Bar_chart
@@ -277,6 +279,7 @@ class pages_data_star_charts(ApiValidator):
277
279
  [waterfall chart]: https://en.wikipedia.org/wiki/Waterfall_chart
278
280
  [distribution chart]: https://en.wikipedia.org/wiki/Probability_distribution
279
281
  """
282
+ # TODO: Document and validate filters
280
283
  if type == "globalOutput":
281
284
  chartType_options = ["bar", "line", "table", "overview"]
282
285
  elif type == "groupedOutput":
@@ -209,6 +209,8 @@ class DateGroupsBuilder(GroupsUtils):
209
209
  include_month_week: bool = False,
210
210
  include_month_day: bool = False,
211
211
  include_week_day: bool = True,
212
+ month_as_name: bool = False,
213
+ week_day_as_name: bool = False,
212
214
  ) -> None:
213
215
  """
214
216
  Initialize a date group builder.
@@ -228,6 +230,8 @@ class DateGroupsBuilder(GroupsUtils):
228
230
  * **`include_month_week`**: `[bool]` = `False` &rarr; Whether or not to include the month and week in the group.
229
231
  * **`include_month_day`**: `[bool]` = `False` &rarr; Whether or not to include the month and day in the group.
230
232
  * **`include_week_day`**: `[bool]` = `True` &rarr; Whether or not to include the week day in the group.
233
+ * **`month_as_name`**: `[bool]` = `False` &rarr; Whether or not to use the month name instead of the month number.
234
+ * **`week_day_as_name`**: `[bool]` = `False` &rarr; Whether or not to use the week day name instead of the week day number.
231
235
 
232
236
  Returns:
233
237
 
@@ -245,6 +249,8 @@ class DateGroupsBuilder(GroupsUtils):
245
249
  self.include_month_week = include_month_week
246
250
  self.include_month_day = include_month_day
247
251
  self.include_week_day = include_week_day
252
+ self.month_as_name = month_as_name
253
+ self.week_day_as_name = week_day_as_name
248
254
  self.date_objects = self.__get_date_objects__(date_data=date_data)
249
255
  self.__gen_structures__()
250
256
 
@@ -323,11 +329,23 @@ class DateGroupsBuilder(GroupsUtils):
323
329
  self.data_structure["year_day"] = [i.strftime("%Y-%j") for i in self.date_objects]
324
330
  self.group_keys.append("year_day")
325
331
  if self.include_month:
326
- self.levels_structure["month"] = {
327
- "name": "Month",
328
- "ordering": sorted(list(set([i.strftime("%m") for i in self.date_objects]))),
329
- }
330
- self.data_structure["month"] = [i.strftime("%m") for i in self.date_objects]
332
+ if self.month_as_name:
333
+ self.levels_structure["month"] = {
334
+ "name": "Month",
335
+ "ordering": [
336
+ i[1]
337
+ for i in sorted(
338
+ list(set([(i.month, i.strftime("%B")) for i in self.date_objects]))
339
+ )
340
+ ],
341
+ }
342
+ self.data_structure["month"] = [i.strftime("%B") for i in self.date_objects]
343
+ else:
344
+ self.levels_structure["month"] = {
345
+ "name": "Month",
346
+ "ordering": sorted(list(set([i.strftime("%m") for i in self.date_objects]))),
347
+ }
348
+ self.data_structure["month"] = [i.strftime("%m") for i in self.date_objects]
331
349
  self.group_keys.append("month")
332
350
  if self.include_month_week:
333
351
  self.levels_structure["month_week"] = {
@@ -344,11 +362,30 @@ class DateGroupsBuilder(GroupsUtils):
344
362
  self.data_structure["month_day"] = [i.strftime("%m-%d") for i in self.date_objects]
345
363
  self.group_keys.append("month_day")
346
364
  if self.include_week_day:
347
- self.levels_structure["week_day"] = {
348
- "name": "Week Day",
349
- "ordering": sorted(list(set([i.strftime("%w") for i in self.date_objects]))),
350
- }
351
- self.data_structure["week_day"] = [i.strftime("%w") for i in self.date_objects]
365
+ if self.week_day_as_name:
366
+ self.levels_structure["week_day"] = {
367
+ "name": "Week Day",
368
+ "ordering": [
369
+ i[1]
370
+ for i in sorted(
371
+ list(
372
+ set(
373
+ [
374
+ (int(i.strftime("%w")), i.strftime("%A"))
375
+ for i in self.date_objects
376
+ ]
377
+ )
378
+ )
379
+ )
380
+ ],
381
+ }
382
+ self.data_structure["week_day"] = [i.strftime("%A") for i in self.date_objects]
383
+ else:
384
+ self.levels_structure["week_day"] = {
385
+ "name": "Week Day",
386
+ "ordering": sorted(list(set([i.strftime("%w") for i in self.date_objects]))),
387
+ }
388
+ self.data_structure["week_day"] = [i.strftime("%w") for i in self.date_objects]
352
389
  self.group_keys.append("week_day")
353
390
 
354
391
  def get_id(self, *args, **kwargs):
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cave_utils
3
- Version: 3.4.2
3
+ Version: 3.4.4
4
4
  Summary: Python wrapper for api use in the cave_app
5
5
  Author-email: Connor Makowski <conmak@mit.edu>
6
6
  Project-URL: Homepage, https://github.com/mit-cave/cave_utils
@@ -31,6 +31,7 @@ cave_utils/api_utils/validator_utils.py
31
31
  cave_utils/builders/__init__.py
32
32
  cave_utils/builders/groups.py
33
33
  test/test_arguments.py
34
+ test/test_builders_date_groups.py
34
35
  test/test_builders_groups.py
35
36
  test/test_custom_coordinates.py
36
37
  test/test_geo_utils.py
@@ -12,7 +12,7 @@ build-backend = "setuptools.build_meta"
12
12
 
13
13
  [project]
14
14
  name = "cave_utils"
15
- version = "3.4.2"
15
+ version = "3.4.4"
16
16
  description = "Python wrapper for api use in the cave_app"
17
17
  authors = [
18
18
  {name="Connor Makowski", email="conmak@mit.edu"}
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = cave_utils
3
- version = 3.4.2
3
+ version = 3.4.4
4
4
  description_file = README.md
5
5
 
6
6
  [options]
@@ -0,0 +1,85 @@
1
+ from cave_utils.builders.groups import DateGroupsBuilder
2
+
3
+ date_data = ["2023-01-01", "2023-02-01"]
4
+
5
+ # Test 1: Basic
6
+ builder = DateGroupsBuilder(
7
+ group_name="Dates",
8
+ date_data=date_data,
9
+ include_month=True,
10
+ include_week_day=True,
11
+ )
12
+ serialized = builder.serialize()
13
+
14
+ # Check month is numbers
15
+ # We have dates from 2023-01-01 to 2023-02-01.
16
+ # Months: 01, 02
17
+ assert "01" in serialized["data"]["month"]
18
+ assert "02" in serialized["data"]["month"]
19
+ assert serialized["levels"]["month"]["ordering"] == ["01", "02"]
20
+
21
+ # Check week day is numbers
22
+ # We have all days of week in that range.
23
+ assert serialized["levels"]["week_day"]["ordering"] == ["0", "1", "2", "3", "4", "5", "6"]
24
+
25
+ # Test 2: Names
26
+ builder_names = DateGroupsBuilder(
27
+ group_name="Dates",
28
+ date_data=date_data,
29
+ include_month=True,
30
+ include_week_day=True,
31
+ month_as_name=True,
32
+ week_day_as_name=True,
33
+ )
34
+ serialized_names = builder_names.serialize()
35
+
36
+ # Check month is names
37
+ assert "January" in serialized_names["data"]["month"]
38
+ assert "February" in serialized_names["data"]["month"]
39
+ assert serialized_names["levels"]["month"]["ordering"] == ["January", "February"]
40
+
41
+ # Check week day is names
42
+ assert "Sunday" in serialized_names["data"]["week_day"]
43
+ assert "Monday" in serialized_names["data"]["week_day"]
44
+ # Ordering should be Sunday, Monday, Tuesday...
45
+ expected_ordering = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
46
+ assert serialized_names["levels"]["week_day"]["ordering"] == expected_ordering
47
+
48
+ # Test 3: All Features
49
+ builder_all = DateGroupsBuilder(
50
+ group_name="Dates",
51
+ date_data=date_data,
52
+ include_year=True,
53
+ include_year_month=True,
54
+ include_year_month_day=True,
55
+ include_year_week=True,
56
+ include_year_day=True,
57
+ include_month=True,
58
+ include_month_week=True,
59
+ include_month_day=True,
60
+ include_week_day=True,
61
+ )
62
+ serialized_all = builder_all.serialize()
63
+
64
+ # Check keys exist
65
+ expected_keys = [
66
+ "year",
67
+ "year_month",
68
+ "year_month_day",
69
+ "year_week",
70
+ "year_day",
71
+ "month",
72
+ "month_week",
73
+ "month_day",
74
+ "week_day",
75
+ ]
76
+ for key in expected_keys:
77
+ assert key in serialized_all["data"]
78
+ assert key in serialized_all["levels"]
79
+
80
+ # Check some values
81
+ assert 2023 in serialized_all["data"]["year"]
82
+ assert "2023-01" in serialized_all["data"]["year_month"]
83
+ assert "2023-01-01" in serialized_all["data"]["year_month_day"]
84
+
85
+ print("DateGroupsBuilder Tests: Passed!")
File without changes
File without changes