Skip to content

Commit e8292b5

Browse files
authored
Merge pull request #55 from SYMSCAE/pq-removal
chore: remove customPQConfig and deprecate NoMetaStructureAdapter
2 parents 607b758 + eeec33e commit e8292b5

10 files changed

Lines changed: 23 additions & 138 deletions

‎src/diffpy/srreal/EmptyStructureAdapter.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class EmptyStructureAdapter : public StructureAdapter
9999
throw outofrange;
100100
}
101101

102-
// reusing StructureAdapter::customPQConfig()
103102
// reusing StructureAdapter::diff()
104103

105104
private:

‎src/diffpy/srreal/NoMetaStructureAdapter.cpp‎

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
*
1313
******************************************************************************
1414
*
15-
* class NoMetaStructureAdapter -- StructureAdapter proxy class that disables
16-
* customPQConfig of another StructureAdapter instance. This may be used
17-
* for preventing the adapter for diffpy.Structure class from applying
18-
* scale, spdiameter and such metadata to the PDFCalculator.
15+
* class NoMetaStructureAdapter -- deprecated StructureAdapter proxy retained
16+
* for source and serialization compatibility. Structures no longer
17+
* configure calculators through metadata.
1918
*
20-
* nometa -- factory function that returns a NoMetaStructureAdapter
21-
* instance wrapped in StructureAdapterPtr
19+
* nometa -- compatibility function returning the source StructureAdapter
2220
*
2321
*****************************************************************************/
2422

@@ -111,12 +109,6 @@ const R3::Matrix& NoMetaStructureAdapter::siteCartesianUij(int idx) const
111109
}
112110

113111

114-
void NoMetaStructureAdapter::customPQConfig(PairQuantity* pq) const
115-
{
116-
// disable customPQConfig of the wrapped PairQuantity
117-
}
118-
119-
120112
StructureDifference
121113
NoMetaStructureAdapter::diff(StructureAdapterConstPtr other) const
122114
{
@@ -151,10 +143,7 @@ NoMetaStructureAdapter::getSourceStructure() const
151143

152144
StructureAdapterPtr nometa(StructureAdapterPtr stru)
153145
{
154-
StructureAdapterPtr rv =
155-
std::dynamic_pointer_cast<NoMetaStructureAdapter>(stru) ? stru :
156-
StructureAdapterPtr(new NoMetaStructureAdapter(stru));
157-
return rv;
146+
return stru ? stru : emptyStructureAdapter();
158147
}
159148

160149
} // namespace srreal

‎src/diffpy/srreal/NoMetaStructureAdapter.hpp‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@
1212
*
1313
******************************************************************************
1414
*
15-
* class NoMetaStructureAdapter -- StructureAdapter proxy class that disables
16-
* customPQConfig of another StructureAdapter instance. This may be used
17-
* for preventing the adapter for diffpy.Structure class from applying
18-
* scale, spdiameter and such metadata to the PDFCalculator.
15+
* class NoMetaStructureAdapter -- deprecated StructureAdapter proxy retained
16+
* for source and serialization compatibility. Structures no longer
17+
* configure calculators through metadata.
1918
*
20-
* nometa -- factory function that returns a NoMetaStructureAdapter
21-
* instance wrapped in StructureAdapterPtr
19+
* nometa -- compatibility function returning the source StructureAdapter
2220
*
2321
*****************************************************************************/
2422

@@ -49,7 +47,6 @@ class NoMetaStructureAdapter : public StructureAdapter
4947
virtual double siteOccupancy(int idx) const;
5048
virtual bool siteAnisotropy(int idx) const;
5149
virtual const R3::Matrix& siteCartesianUij(int idx) const;
52-
virtual void customPQConfig(PairQuantity* pq) const;
5350
virtual StructureDifference diff(StructureAdapterConstPtr) const;
5451

5552
// methods - own
@@ -74,11 +71,11 @@ class NoMetaStructureAdapter : public StructureAdapter
7471

7572
// Routines ------------------------------------------------------------------
7673

77-
/// create NoMetaStructureAdapter from an existing StructureAdapter
74+
/// Return the input adapter unchanged, or the empty adapter for a null input.
7875
StructureAdapterPtr nometa(StructureAdapterPtr stru);
7976

8077

81-
/// create NoMetaStructureAdapter from an adaptable structure object
78+
/// Convert an adaptable structure without creating a proxy.
8279
template <class T>
8380
StructureAdapterPtr nometa(const T& stru)
8481
{

‎src/diffpy/srreal/NoSymmetryStructureAdapter.cpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ const R3::Matrix& NoSymmetryStructureAdapter::siteCartesianUij(int idx) const
108108
}
109109

110110

111-
void NoSymmetryStructureAdapter::customPQConfig(PairQuantity* pq) const
112-
{
113-
msrcstructure->customPQConfig(pq);
114-
}
115-
116-
117111
StructureDifference
118112
NoSymmetryStructureAdapter::diff(StructureAdapterConstPtr other) const
119113
{

‎src/diffpy/srreal/NoSymmetryStructureAdapter.hpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class NoSymmetryStructureAdapter : public StructureAdapter
5151
virtual double siteOccupancy(int idx) const;
5252
virtual bool siteAnisotropy(int idx) const;
5353
virtual const R3::Matrix& siteCartesianUij(int idx) const;
54-
virtual void customPQConfig(PairQuantity* pq) const;
5554
virtual StructureDifference diff(StructureAdapterConstPtr) const;
5655

5756
// methods - own

‎src/diffpy/srreal/PQEvaluator.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ void PQEvaluatorOptimized::updateValue(
247247
// save current value to override the resetValue call from setStructure
248248
assert(sd.stru1);
249249
pq.stashPartialValue();
250-
// setStructure(stru1) calls stru1->customPQConfig(pq), which may totally
251-
// change pq configuration. If so, revert to full calculation.
250+
// Fall back to a full calculation if assigning the new structure
251+
// changes the calculator's configuration ticker.
252252
assert(pq.ticker() < mvalue_ticker);
253253
pq.setStructure(sd.stru1);
254254
if (pq.ticker() >= mvalue_ticker)

‎src/diffpy/srreal/PairQuantity.cpp‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ const QuantityType& PairQuantity::eval(StructureAdapterPtr stru)
6969
void PairQuantity::setStructure(StructureAdapterPtr stru)
7070
{
7171
mstructure = stru.get() ? stru : emptyStructureAdapter();
72-
mstructure->customPQConfig(this);
7372
this->updateMaskData();
7473
this->resetValue();
7574
}

‎src/diffpy/srreal/StructureAdapter.hpp‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
namespace diffpy {
3535
namespace srreal {
3636

37-
class PairQuantity;
3837
class StructureDifference;
3938

4039

@@ -86,11 +85,6 @@ class StructureAdapter :
8685
/// Cartesian coordinate system at independent site @param idx
8786
virtual const R3::Matrix& siteCartesianUij(int idx) const = 0;
8887

89-
/// this method allows custom special configuration for a concrete
90-
/// pair of StructureAdapter and PairQuantity objects.
91-
[[deprecated]] virtual void customPQConfig(PairQuantity* pq) const
92-
{ }
93-
9488
/// Return difference from the other StructureAdapter
9589
virtual StructureDifference diff(StructureAdapterConstPtr) const;
9690

‎src/tests/TestNoMetaStructureAdapter.hpp‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <diffpy/srreal/PDFCalculator.hpp>
2626
#include <diffpy/serialization.hpp>
2727
#include "test_helpers.hpp"
28-
#include "test_custompqconfig.hpp"
2928

3029
using namespace std;
3130
using namespace diffpy::srreal;
@@ -47,23 +46,20 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite
4746
CxxTest::setAbortTestOnFail(true);
4847
if (!m_pswt)
4948
{
50-
StructureAdapterPtr pswt;
51-
pswt = loadTestPeriodicStructure("PbScW25TiO3.stru");
52-
PeriodicAdapterWithPQConfigPtr pswt_pqcfg;
53-
pswt_pqcfg = addCustomPQConfig(pswt);
54-
pswt_pqcfg->cfg["scale"] = 2.5;
55-
m_pswt = pswt_pqcfg;
49+
m_pswt = loadTestPeriodicStructure("PbScW25TiO3.stru");
5650
}
5751
CxxTest::setAbortTestOnFail(false);
5852
}
5953

6054

61-
void test_PDFCalcMeta()
55+
void test_PDFCalcPreservesConfiguration()
6256
{
6357
PDFCalculator pdfc;
6458
pdfc.setRstep(0.1);
6559
pdfc.setRmax(5.0);
66-
TS_ASSERT_EQUALS(1.0, pdfc.getDoubleAttr("scale"));
60+
pdfc.setDoubleAttr("scale", 2.5);
61+
pdfc.setStructure(m_pswt);
62+
TS_ASSERT_EQUALS(2.5, pdfc.getDoubleAttr("scale"));
6763
pdfc.eval(m_pswt);
6864
TS_ASSERT_EQUALS(2.5, pdfc.getDoubleAttr("scale"));
6965
}
@@ -84,7 +80,11 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite
8480
{
8581
StructureAdapterPtr adpt0 = nometa(m_pswt);
8682
StructureAdapterPtr adpt1 = nometa(adpt0);
83+
TS_ASSERT_EQUALS(m_pswt, adpt0);
8784
TS_ASSERT_EQUALS(adpt0, adpt1);
85+
TS_ASSERT_EQUALS(emptyStructureAdapter(), nometa(StructureAdapterPtr()));
86+
StructureAdapterPtr proxy(new NoMetaStructureAdapter(m_pswt));
87+
TS_ASSERT_EQUALS(proxy, nometa(proxy));
8888
}
8989

9090

@@ -93,7 +93,7 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite
9393
using namespace diffpy::serialization;
9494
stringstream storage(ios::in | ios::out | ios::binary);
9595
oarchive oa(storage, ios::binary);
96-
StructureAdapterPtr pswtbare0(nometa(m_pswt));
96+
StructureAdapterPtr pswtbare0(new NoMetaStructureAdapter(m_pswt));
9797
oa << pswtbare0;
9898
iarchive ia(storage, ios::binary);
9999
StructureAdapterPtr pswtbare1;

‎src/tests/test_custompqconfig.hpp‎

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)