Skip to content

Commit

Permalink
Merge pull request #341 from lincc-frameworks/sync_calc_nobs
Browse files Browse the repository at this point in the history
Add lazy_sync_tables call to calc_nobs
  • Loading branch information
dougbrn authored Jan 3, 2024
2 parents 3b3790b + d14bc1a commit 1644284
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tape/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,9 @@ def calc_nobs(self, by_band=False, label="nobs", temporary=True):
The ensemble object with nobs columns added to the object table.
"""

# Perform sync if either table is dirty
self._lazy_sync_tables("all")

if by_band:
# repartition the result to align with object
if self.object.known_divisions:
Expand Down
8 changes: 8 additions & 0 deletions tests/tape_tests/test_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -1205,9 +1205,17 @@ def test_calc_nobs(data_fixture, request, by_band, multi_partition):
# Drop the existing nobs columns
ens.object = ens.object.drop(["nobs_g", "nobs_r", "nobs_total"], axis=1)

# Make sure syncs work, do novel query to remove some sources
ens._lazy_sync_tables("all") # do an initial sync to clear state
ens.source.query("index != 88472468910699998").update_ensemble()
assert ens.source.is_dirty()

# Calculate nobs
ens.calc_nobs(by_band)

# Check to make sure a sync was performed
assert not ens.source.is_dirty()

# Check that things turned out as we expect
lc = ens.object.loc[88472935274829959].compute()

Expand Down

0 comments on commit 1644284

Please sign in to comment.