Skip to content

Commit

Permalink
Merge pull request #48 from wildlife-dynamics/patrol-observations-bugs
Browse files Browse the repository at this point in the history
fix patrol with no observations bug
  • Loading branch information
ericgitonga authored Sep 25, 2023
2 parents 3bbe5ad + 05f3ba9 commit d8e1658
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions ecoscope/io/earthranger.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ def get_patrol_observations(self, patrols_df, include_patrol_details=False, **kw

try:
observation = self.get_subject_observations(
subject_ids=[subject_id], since=patrol_start_time, until=patrol_end_time
subject_ids=[subject_id], since=patrol_start_time, until=patrol_end_time, **kwargs
)
if include_patrol_details:
observation["patrol_id"] = patrol["id"]
Expand All @@ -738,7 +738,8 @@ def get_patrol_observations(self, patrols_df, include_patrol_details=False, **kw
]
)
)
observations.append(observation)
if len(observation) > 0:
observations.append(observation)
except Exception as e:
print(
f"Getting observations for subject_id={subject_id} start_time={patrol_start_time}"
Expand Down
2 changes: 1 addition & 1 deletion ecoscope/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.4.2"
__version__ = "1.4.3"
3 changes: 2 additions & 1 deletion notebooks/01. IO/EarthRanger_IO.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -614,8 +614,9 @@
"source": [
"patrol_df = er_io.get_patrols()\n",
"\n",
"relocs = er_io.get_observations_for_patrols(\n",
"relocs = er_io.get_patrol_observations(\n",
" patrol_df,\n",
" include_patrol_details=True,\n",
" include_source_details=True,\n",
" include_subject_details=True,\n",
" include_subjectsource_details=True,\n",
Expand Down
4 changes: 2 additions & 2 deletions tests/test_earthranger_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ def test_patch_event(er_io):
pd.testing.assert_frame_equal(result, updated_event)


def test_get_observation_for_patrol(er_io):
def test_get_patrol_observations(er_io):
patrols = er_io.get_patrols()
observations = er_io.get_observations_for_patrols(
observations = er_io.get_patrol_observations(
patrols,
include_source_details=False,
include_subject_details=False,
Expand Down

0 comments on commit d8e1658

Please sign in to comment.