Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/diffpy/srreal/EmptyStructureAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class EmptyStructureAdapter : public StructureAdapter {
throw outofrange;
}

// reusing StructureAdapter::customPQConfig()
// reusing StructureAdapter::diff()

private:
Expand Down
20 changes: 5 additions & 15 deletions src/diffpy/srreal/NoMetaStructureAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
*
******************************************************************************
*
* class NoMetaStructureAdapter -- StructureAdapter proxy class that disables
* customPQConfig of another StructureAdapter instance. This may be used
* for preventing the adapter for diffpy.Structure class from applying
* scale, spdiameter and such metadata to the PDFCalculator.
* class NoMetaStructureAdapter -- deprecated StructureAdapter proxy retained
* for source and serialization compatibility. Structures no longer
* configure calculators through metadata.
*
* nometa -- factory function that returns a NoMetaStructureAdapter
* instance wrapped in StructureAdapterPtr
* nometa -- compatibility function returning the source StructureAdapter
*
*****************************************************************************/

Expand Down Expand Up @@ -88,10 +86,6 @@ const R3::Matrix& NoMetaStructureAdapter::siteCartesianUij(int idx) const {
return msrcstructure->siteCartesianUij(idx);
}

void NoMetaStructureAdapter::customPQConfig(PairQuantity* pq) const {
// disable customPQConfig of the wrapped PairQuantity
}

StructureDifference NoMetaStructureAdapter::diff(
StructureAdapterConstPtr other) const {
StructureDifference sd = this->StructureAdapter::diff(other);
Expand All @@ -118,11 +112,7 @@ StructureAdapterConstPtr NoMetaStructureAdapter::getSourceStructure() const {
// Routines ------------------------------------------------------------------

StructureAdapterPtr nometa(StructureAdapterPtr stru) {
StructureAdapterPtr rv =
std::dynamic_pointer_cast<NoMetaStructureAdapter>(stru)
? stru
: StructureAdapterPtr(new NoMetaStructureAdapter(stru));
return rv;
return stru ? stru : emptyStructureAdapter();
}

} // namespace srreal
Expand Down
15 changes: 6 additions & 9 deletions src/diffpy/srreal/NoMetaStructureAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
*
******************************************************************************
*
* class NoMetaStructureAdapter -- StructureAdapter proxy class that disables
* customPQConfig of another StructureAdapter instance. This may be used
* for preventing the adapter for diffpy.Structure class from applying
* scale, spdiameter and such metadata to the PDFCalculator.
* class NoMetaStructureAdapter -- deprecated StructureAdapter proxy retained
* for source and serialization compatibility. Structures no longer
* configure calculators through metadata.
*
* nometa -- factory function that returns a NoMetaStructureAdapter
* instance wrapped in StructureAdapterPtr
* nometa -- compatibility function returning the source StructureAdapter
*
*****************************************************************************/

Expand Down Expand Up @@ -49,7 +47,6 @@ class DLL_EXPORT NoMetaStructureAdapter : public StructureAdapter {
virtual double siteOccupancy(int idx) const;
virtual bool siteAnisotropy(int idx) const;
virtual const R3::Matrix& siteCartesianUij(int idx) const;
virtual void customPQConfig(PairQuantity* pq) const;
virtual StructureDifference diff(StructureAdapterConstPtr) const;

// methods - own
Expand All @@ -71,10 +68,10 @@ class DLL_EXPORT NoMetaStructureAdapter : public StructureAdapter {

// Routines ------------------------------------------------------------------

/// create NoMetaStructureAdapter from an existing StructureAdapter
/// Return the input adapter unchanged, or the empty adapter for a null input.
DLL_EXPORT StructureAdapterPtr nometa(StructureAdapterPtr stru);

/// create NoMetaStructureAdapter from an adaptable structure object
/// Convert an adaptable structure without creating a proxy.
template <class T>
StructureAdapterPtr nometa(const T& stru) {
StructureAdapterPtr bstru = convertToStructureAdapter(stru);
Expand Down
4 changes: 0 additions & 4 deletions src/diffpy/srreal/NoSymmetryStructureAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ const R3::Matrix& NoSymmetryStructureAdapter::siteCartesianUij(int idx) const {
return msrcstructure->siteCartesianUij(idx);
}

void NoSymmetryStructureAdapter::customPQConfig(PairQuantity* pq) const {
msrcstructure->customPQConfig(pq);
}

StructureDifference NoSymmetryStructureAdapter::diff(
StructureAdapterConstPtr other) const {
StructureDifference sd = this->StructureAdapter::diff(other);
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/srreal/NoSymmetryStructureAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class DLL_EXPORT NoSymmetryStructureAdapter : public StructureAdapter {
virtual double siteOccupancy(int idx) const;
virtual bool siteAnisotropy(int idx) const;
virtual const R3::Matrix& siteCartesianUij(int idx) const;
virtual void customPQConfig(PairQuantity* pq) const;
virtual StructureDifference diff(StructureAdapterConstPtr) const;

// methods - own
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/srreal/PQEvaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ void PQEvaluatorOptimized::updateValue(PairQuantity& pq,
// save current value to override the resetValue call from setStructure
assert(sd.stru1);
pq.stashPartialValue();
// setStructure(stru1) calls stru1->customPQConfig(pq), which may totally
// change pq configuration. If so, revert to full calculation.
// Fall back to a full calculation if assigning the new structure
// changes the calculator's configuration ticker.
assert(pq.ticker() < mvalue_ticker);
pq.setStructure(sd.stru1);
if (pq.ticker() >= mvalue_ticker) {
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/srreal/PairQuantity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const QuantityType& PairQuantity::eval(StructureAdapterPtr stru) {

void PairQuantity::setStructure(StructureAdapterPtr stru) {
mstructure = stru.get() ? stru : emptyStructureAdapter();
mstructure->customPQConfig(this);
this->updateMaskData();
this->resetValue();
}
Expand Down
5 changes: 0 additions & 5 deletions src/diffpy/srreal/StructureAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
namespace diffpy {
namespace srreal {

class PairQuantity;
class StructureDifference;

/// @class StructureAdapter
Expand Down Expand Up @@ -85,10 +84,6 @@ class DLL_EXPORT StructureAdapter
/// Cartesian coordinate system at independent site @param idx
virtual const R3::Matrix& siteCartesianUij(int idx) const = 0;

/// this method allows custom special configuration for a concrete
/// pair of StructureAdapter and PairQuantity objects.
[[deprecated]] virtual void customPQConfig(PairQuantity* pq) const {}

/// Return difference from the other StructureAdapter
virtual StructureDifference diff(StructureAdapterConstPtr) const;

Expand Down
20 changes: 10 additions & 10 deletions src/tests/TestNoMetaStructureAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <diffpy/srreal/PDFCalculator.hpp>
#include <diffpy/serialization.hpp>
#include "test_helpers.hpp"
#include "test_custompqconfig.hpp"

using namespace std;
using namespace diffpy::srreal;
Expand All @@ -42,21 +41,18 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite {
void setUp() {
CxxTest::setAbortTestOnFail(true);
if (!m_pswt) {
StructureAdapterPtr pswt;
pswt = loadTestPeriodicStructure("PbScW25TiO3.stru");
PeriodicAdapterWithPQConfigPtr pswt_pqcfg;
pswt_pqcfg = addCustomPQConfig(pswt);
pswt_pqcfg->cfg["scale"] = 2.5;
m_pswt = pswt_pqcfg;
m_pswt = loadTestPeriodicStructure("PbScW25TiO3.stru");
}
CxxTest::setAbortTestOnFail(false);
}

void test_PDFCalcMeta() {
void test_PDFCalcPreservesConfiguration() {
PDFCalculator pdfc;
pdfc.setRstep(0.1);
pdfc.setRmax(5.0);
TS_ASSERT_EQUALS(1.0, pdfc.getDoubleAttr("scale"));
pdfc.setDoubleAttr("scale", 2.5);
pdfc.setStructure(m_pswt);
TS_ASSERT_EQUALS(2.5, pdfc.getDoubleAttr("scale"));
pdfc.eval(m_pswt);
TS_ASSERT_EQUALS(2.5, pdfc.getDoubleAttr("scale"));
}
Expand All @@ -73,14 +69,18 @@ class TestNoMetaStructureAdapter : public CxxTest::TestSuite {
void test_NoMetaTwice() {
StructureAdapterPtr adpt0 = nometa(m_pswt);
StructureAdapterPtr adpt1 = nometa(adpt0);
TS_ASSERT_EQUALS(m_pswt, adpt0);
TS_ASSERT_EQUALS(adpt0, adpt1);
TS_ASSERT_EQUALS(emptyStructureAdapter(), nometa(StructureAdapterPtr()));
StructureAdapterPtr proxy(new NoMetaStructureAdapter(m_pswt));
TS_ASSERT_EQUALS(proxy, nometa(proxy));
}

void test_serialization() {
using namespace diffpy::serialization;
stringstream storage(ios::in | ios::out | ios::binary);
oarchive oa(storage, ios::binary);
StructureAdapterPtr pswtbare0(nometa(m_pswt));
StructureAdapterPtr pswtbare0(new NoMetaStructureAdapter(m_pswt));
oa << pswtbare0;
iarchive ia(storage, ios::binary);
StructureAdapterPtr pswtbare1;
Expand Down
75 changes: 0 additions & 75 deletions src/tests/test_custompqconfig.hpp

This file was deleted.

Loading