boris-behav-obs 8.27.6__py2.py3-none-any.whl → 8.27.7__py2.py3-none-any.whl

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.
@@ -379,15 +379,16 @@ def check_project_integrity(
379
379
  media_file_available: bool = True,
380
380
  ) -> str:
381
381
  """
382
- check project integrity
383
- check if behaviors in observations are in ethogram
384
- check unpaired state events
385
- check if timestamp between -2147483647 and 2147483647 (2**31 - 1)
386
- check if behavior belong to behavioral category that do not more exist
387
- check for leading and trailing spaces and special chars in modifiers
388
- check if media file are available
389
- check if media length available
390
- check independent variables
382
+ check project integrity:
383
+ * check if coded behaviors are defined in ethogram
384
+ * check unpaired state events
385
+ * check if timestamp between -2147483647 and 2147483647 (2**31 - 1)
386
+ * check if behavior belong to behavioral category that do not more exist
387
+ * check for leading and trailing spaces and special chars in modifiers
388
+ * check if media file are available (optional)
389
+ * check if media length available
390
+ * check independent variables
391
+ * check if coded subjects are defines
391
392
 
392
393
  Args:
393
394
  pj (dict): BORIS project
@@ -398,7 +399,7 @@ def check_project_integrity(
398
399
  Returns:
399
400
  str: message
400
401
  """
401
- out = ""
402
+ out: str = ""
402
403
 
403
404
  # check if coded behaviors are defined in ethogram
404
405
  r = check_coded_behaviors(pj)
@@ -521,6 +522,14 @@ def check_project_integrity(
521
522
  f" is not allowed for {var_label} (choose between {defined_set_var_label[var_label]})<br>"
522
523
  )
523
524
 
525
+ # check if coded subjects are defined in the subjects list
526
+ subjects_list: list = [pj[cfg.SUBJECTS][x]["name"] for x in pj[cfg.SUBJECTS]]
527
+ coded_subjects = set(util.flatten_list([[y[1] for y in pj[cfg.OBSERVATIONS][x].get(cfg.EVENTS, [])] for x in pj[cfg.OBSERVATIONS]]))
528
+
529
+ for subject in coded_subjects:
530
+ if subject and subject not in subjects_list:
531
+ out += f"The coded subject <b>{subject}</b> is not defined in the subjects list.<br>You can use the <b>Explore project</b> to fix it.<br><br>"
532
+
524
533
  return out
525
534
 
526
535
 
boris/utilities.py CHANGED
@@ -505,6 +505,19 @@ def group_events(pj: dict, obs_id: str, include_modifiers: bool = False) -> dict
505
505
  return {"error": ""}
506
506
 
507
507
 
508
+ def flatten_list(nested_list) -> list:
509
+ """
510
+ Flatten a list of lists.
511
+ """
512
+ flattened: list = []
513
+ for item in nested_list:
514
+ if isinstance(item, list):
515
+ flattened.extend(flatten_list(item))
516
+ else:
517
+ flattened.append(item)
518
+ return flattened
519
+
520
+
508
521
  def get_current_states_modifiers_by_subject(
509
522
  state_behaviors_codes: list, events: list, subjects: dict, time_: dec, include_modifiers: bool = False
510
523
  ) -> dict:
boris/version.py CHANGED
@@ -20,5 +20,5 @@ This file is part of BORIS.
20
20
 
21
21
  """
22
22
 
23
- __version__ = "8.27.6"
24
- __version_date__ = "2024-08-21"
23
+ __version__ = "8.27.7"
24
+ __version_date__ = "2024-08-23"