Skip to content

Commit ac35a0c

Browse files
committed
Preserve ticker for unchanged ("all", symbol) mask.
Do not advance ticker in a repeated call of PairQuantity::setTypeMask("all", smbl, mask) as it does not change the effective mask.
1 parent a55cd49 commit ac35a0c

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/diffpy/srreal/PairQuantity.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,14 @@ setTypeMask(string smbli, string smblj, bool mask)
300300
{
301301
const string& sk = (ALLATOMSSTR != smbli) ? smbli : smblj;
302302
TypeMaskStorage::iterator tpmsk;
303+
TypeMaskStorage::iterator skip = mtypemask.find(smblij);
303304
for (tpmsk = mtypemask.begin(); tpmsk != mtypemask.end();)
304305
{
305-
if (sk == tpmsk->first.first || sk == tpmsk->first.second)
306+
const bool eraseitem = (tpmsk != skip) &&
307+
(sk == tpmsk->first.first || sk == tpmsk->first.second);
308+
if (eraseitem)
306309
{
307-
modified = true;
310+
if (mask != tpmsk->second) modified = true;
308311
tpmsk = mtypemask.erase(tpmsk);
309312
}
310313
else ++tpmsk;

src/tests/TestPairCounter.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,23 @@ class TestPairCounter : public CxxTest::TestSuite
108108
pcount.setTypeMask("A", "B", false);
109109
EventTicker et2 = pcount.ticker();
110110
TS_ASSERT_LESS_THAN(et1, et2);
111-
pcount.setPairMask(0, 0, false);
111+
pcount.setTypeMask("A", "all", false);
112112
EventTicker et3 = pcount.ticker();
113113
TS_ASSERT_LESS_THAN(et2, et3);
114-
pcount.setPairMask(0, 0, false);
114+
pcount.setTypeMask("A", "all", false);
115115
TS_ASSERT_EQUALS(et3, pcount.ticker());
116+
pcount.setTypeMask("A", "all", true);
117+
EventTicker et4 = pcount.ticker();
118+
TS_ASSERT_LESS_THAN(et3, et4);
119+
pcount.setPairMask(0, 0, false);
120+
EventTicker et5 = pcount.ticker();
121+
TS_ASSERT_LESS_THAN(et4, et5);
122+
pcount.setPairMask(0, 0, false);
123+
TS_ASSERT_EQUALS(et5, pcount.ticker());
116124
pcount.setPairMask(0, 5, true);
117-
TS_ASSERT_EQUALS(et3, pcount.ticker());
125+
TS_ASSERT_EQUALS(et5, pcount.ticker());
118126
pcount.setPairMask(0, 5, false);
119-
TS_ASSERT_LESS_THAN(et3, pcount.ticker());
127+
TS_ASSERT_LESS_THAN(et5, pcount.ticker());
120128
}
121129

122130

0 commit comments

Comments
 (0)