From d14bc1a238c90fba72ed846128697d0a3e71c4e0 Mon Sep 17 00:00:00 2001 From: Doug Branton Date: Wed, 3 Jan 2024 11:40:11 -0800 Subject: [PATCH] add sync to calc_nobs --- src/tape/ensemble.py | 3 +++ tests/tape_tests/test_ensemble.py | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/src/tape/ensemble.py b/src/tape/ensemble.py index e642263a..0d5fb912 100644 --- a/src/tape/ensemble.py +++ b/src/tape/ensemble.py @@ -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: diff --git a/tests/tape_tests/test_ensemble.py b/tests/tape_tests/test_ensemble.py index 1fcbc664..995b1e82 100644 --- a/tests/tape_tests/test_ensemble.py +++ b/tests/tape_tests/test_ensemble.py @@ -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()