Skip to content

Commit

Permalink
Some minor cleaning up.
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 22, 2019
1 parent f53b0b0 commit 7914033
Show file tree
Hide file tree
Showing 15 changed files with 117 additions and 119 deletions.
26 changes: 13 additions & 13 deletions src/plugins/dataStore/DataStore/src/datastorepythonwrapper.cpp
Expand Up @@ -55,13 +55,6 @@ static bool initNumPy()

//==============================================================================

typedef struct {
PyDictObject mDict;
SimulationSupport::SimulationDataUpdatedFunction *mSimulationDataUpdatedFunction;
} DataStoreValuesDictObject;

//==============================================================================

static DataStoreValue * getDataStoreValue(PyObject *pValuesDict, PyObject *pKey)
{
// Get and return a DataStoreValue item from a values dictionary
Expand Down Expand Up @@ -93,6 +86,13 @@ static PyObject * DataStoreValuesDict_subscript(PyObject *pValuesDict,

//==============================================================================

typedef struct {
PyDictObject mDict;
SimulationSupport::SimulationDataUpdatedFunction *mSimulationDataUpdatedFunction;
} DataStoreValuesDictObject;

//==============================================================================

static int DataStoreValuesDict_ass_subscript(PyObject *pValuesDict,
PyObject *pKey, PyObject *pValue)
{
Expand Down Expand Up @@ -143,8 +143,8 @@ static PyMappingMethods DataStoreValuesDict_as_mapping = {
static PyObject * DataStoreValuesDict_repr(DataStoreValuesDictObject *pValuesDict)
{
// A string representation of a values dictionary
// Note: this is a modified version of dict_repr() from dictobject.c in
// Python's C source code...
// Note: this is a modified version of dict_repr() from dictobject.c in the
// Python source code...

PyDictObject *mp = reinterpret_cast<PyDictObject *>(pValuesDict);
Py_ssize_t i = Py_ReprEnter(reinterpret_cast<PyObject *>(mp));
Expand Down Expand Up @@ -319,9 +319,9 @@ DataStorePythonWrapper::DataStorePythonWrapper(PyObject *pModule,

PyType_Ready(&DataStoreValuesDict_Type);

PythonQtSupport::registerClass(&OpenCOR::DataStore::DataStore::staticMetaObject);
PythonQtSupport::registerClass(&OpenCOR::DataStore::DataStoreValue::staticMetaObject);
PythonQtSupport::registerClass(&OpenCOR::DataStore::DataStoreVariable::staticMetaObject);
PythonQtSupport::registerClass(&DataStore::staticMetaObject);
PythonQtSupport::registerClass(&DataStoreValue::staticMetaObject);
PythonQtSupport::registerClass(&DataStoreVariable::staticMetaObject);

PythonQtSupport::addInstanceDecorators(this);
}
Expand Down Expand Up @@ -394,7 +394,7 @@ PyObject * DataStorePythonWrapper::dataStoreVariablesDict(const DataStoreVariabl

PyObject *res = PyDict_New();

foreach (DataStoreVariable *dataStoreVariable, pDataStoreVariables) {
for (auto dataStoreVariable : pDataStoreVariables) {
PythonQtSupport::addObject(res, dataStoreVariable->uri(), dataStoreVariable);
}

Expand Down
20 changes: 12 additions & 8 deletions src/plugins/datastoreinterface.cpp
Expand Up @@ -55,6 +55,8 @@ namespace DataStore {
DataStoreArray::DataStoreArray(quint64 pSize) :
mSize(pSize)
{
// Allocate our data

mData = new double[pSize] {};
}

Expand All @@ -71,7 +73,7 @@ quint64 DataStoreArray::size() const

double * DataStoreArray::data() const
{
// Return a pointer to our data
// Return our data

return mData;
}
Expand All @@ -80,7 +82,7 @@ double * DataStoreArray::data() const

double DataStoreArray::data(quint64 pPosition) const
{
// Return the value at the given position
// Return the data value at the given position

Q_ASSERT((pPosition < mSize) && (mData != nullptr));

Expand All @@ -91,7 +93,7 @@ double DataStoreArray::data(quint64 pPosition) const

void DataStoreArray::reset()
{
// Clear our data
// Reset our data

memset(mData, 0, mSize*Solver::SizeOfDouble);
}
Expand Down Expand Up @@ -253,7 +255,7 @@ void DataStoreVariableRun::addValue(double pValue)

DataStoreArray * DataStoreVariableRun::array() const
{
// Return our data array
// Return our array

return mArray;
}
Expand Down Expand Up @@ -437,10 +439,12 @@ quint64 DataStoreVariable::size(int pRun) const
{
// Return our size for the given run

if (mRuns.isEmpty()) {
return 0;
}

if (pRun == -1) {
return (!mRuns.isEmpty())?
mRuns.last()->size():
0;
return mRuns.last()->size();
}

return ((pRun >= 0) && (pRun < mRuns.count()))?
Expand All @@ -452,7 +456,7 @@ quint64 DataStoreVariable::size(int pRun) const

DataStoreArray * DataStoreVariable::array(int pRun) const
{
// Return the data array for the given run, if any
// Return the array for the given run, if any

if (mRuns.isEmpty()) {
return nullptr;
Expand Down
72 changes: 36 additions & 36 deletions src/plugins/miscellaneous/Core/i18n/Core_fr.ts
Expand Up @@ -19,22 +19,38 @@
<source>Test</source>
<translation></translation>
</message>
<message>
<source>Open Remote File</source>
<translation>Ouvrir Fichier À Distance</translation>
</message>
<message>
<source>File</source>
<translation>Fichier</translation>
</message>
<message>
<source>Import Remote File</source>
<translation>Importer Fichier À Distance</translation>
</message>
<message>
<source>&lt;strong&gt;%1&lt;/strong&gt; could not be saved locally (%2).</source>
<translation>&lt;strong&gt;%1&lt;/strong&gt; n&apos;a pas pu être sauvegardé localement (%2).</translation>
</message>
<message>
<source>&lt;strong&gt;%1&lt;/strong&gt; could not be imported (%2).</source>
<translation>&lt;strong&gt;%1&lt;/strong&gt; n&apos;a pas pu être importé (%2).</translation>
</message>
<message>
<source>Open File</source>
<translation>Ouvrir Fichier</translation>
</message>
<message>
<source>Open Remote File</source>
<translation>Ouvrir Fichier À Distance</translation>
</message>
<message>
<source>&lt;strong&gt;%1&lt;/strong&gt; could not be opened.</source>
<translation>&lt;strong&gt;%1&lt;/strong&gt; n&apos;a pas pu être ouvert.</translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened.</source>
<translation>&apos;%1&apos; n&apos;a pas pu être ouvert.</translation>
</message>
<message>
<source>Open</source>
<translation>Ouvrir</translation>
Expand All @@ -43,6 +59,10 @@
<source>&lt;strong&gt;%1&lt;/strong&gt; could not be opened (%2).</source>
<translation>&lt;strong&gt;%1&lt;/strong&gt; n&apos;a pas pu être ouvert (%2).</translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened (%2).</source>
<translation>&apos;%1&apos; n&apos;a pas pu être ouvert (%2).</translation>
</message>
<message>
<source>File Modified</source>
<translation>Fichier Modifié</translation>
Expand Down Expand Up @@ -156,28 +176,8 @@
<translation>Le fichier est en train d&apos;être édité, il n&apos;est donc pas possible de changer de vue pour le moment</translation>
</message>
<message>
<source>Import Remote File</source>
<translation>Importer Fichier À Distance</translation>
</message>
<message>
<source>&lt;strong&gt;%1&lt;/strong&gt; could not be saved locally (%2).</source>
<translation>&lt;strong&gt;%1&lt;/strong&gt; n&apos;a pas pu être sauvegardé localement (%2).</translation>
</message>
<message>
<source>&lt;strong&gt;%1&lt;/strong&gt; could not be imported (%2).</source>
<translation>&lt;strong&gt;%1&lt;/strong&gt; n&apos;a pas pu être importé (%2).</translation>
</message>
<message>
<source>%s:%d: &apos;%s&apos; did not get created.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened (%2).</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened.</source>
<translation type="unfinished"></translation>
<source>&apos;%1&apos; could not be created.</source>
<translation>&apos;%1&apos; n&apos;a pas pu être créé.</translation>
</message>
</context>
<context>
Expand Down Expand Up @@ -506,6 +506,14 @@
<source>ms</source>
<translation></translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened.</source>
<translation>&apos;%1&apos; n&apos;a pas pu être ouvert.</translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened (%2).</source>
<translation>&apos;%1&apos; n&apos;a pas pu être ouvert (%2).</translation>
</message>
<message>
<source>All Files</source>
<translation>Tous Fichiers</translation>
Expand All @@ -527,16 +535,8 @@
<translation>Veuillez choisir un répertoire vide.</translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>FATAL ERROR | %s:%d: &apos;%s&apos; did not get created.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>&apos;%1&apos; could not be opened (%2).</source>
<translation type="unfinished"></translation>
<source>&apos;%1&apos; could not be created.</source>
<translation>&apos;%1&apos; n&apos;a pas pu être créé.</translation>
</message>
</context>
</TS>
4 changes: 2 additions & 2 deletions src/plugins/miscellaneous/Core/src/centralwidget.cpp
Expand Up @@ -901,9 +901,9 @@ QString CentralWidget::openRemoteFile(const QString &pUrl, bool pShowWarning)

if (status != FileManager::Status::Created) {
#ifdef QT_DEBUG
qFatal("FATAL ERROR | %s:%d: '%s' did not get created.", __FILE__, __LINE__, qPrintable(fileNameOrUrl));
qFatal("FATAL ERROR | %s:%d: '%s' could not be created.", __FILE__, __LINE__, qPrintable(fileNameOrUrl));
#else
return tr("%s:%d: '%s' did not get created.").arg(__FILE__, __LINE__).arg(fileNameOrUrl);
return tr("'%1' could not be created.").arg(fileNameOrUrl);
#endif
}

Expand Down
7 changes: 4 additions & 3 deletions src/plugins/miscellaneous/Core/src/corecliutils.cpp
Expand Up @@ -624,16 +624,17 @@ QString openRemoteFile(const QString &pUrl)

if (!fileManagerInstance->newFile(fileName, fileContents)) {
#ifdef QT_DEBUG
qFatal("FATAL ERROR | %s:%d: '%s' did not get created.", __FILE__, __LINE__, qPrintable(fileNameOrUrl));
qFatal("FATAL ERROR | %s:%d: '%s' could not be created.", __FILE__, __LINE__, qPrintable(fileNameOrUrl));
#else
return QObject::tr("FATAL ERROR | %s:%d: '%s' did not get created.").arg(__FILE__, __LINE__).arg(fileNameOrUrl);
return QObject::tr("'%1' could not be created.").arg(fileNameOrUrl);
#endif
}
} else {
// We were not able to retrieve the contents of the remote file, so
// let the user know about it

return QObject::tr("'%1' could not be opened (%2).").arg(fileNameOrUrl, formatMessage(errorMessage));
return QObject::tr("'%1' could not be opened (%2).").arg(fileNameOrUrl)
.arg(formatMessage(errorMessage));
}
}
// We now have the file so open it, which will add it to the file manager
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/miscellaneous/Core/src/coreplugin.cpp
Expand Up @@ -707,7 +707,7 @@ void CorePlugin::newFile()
// Make sure that the file has indeed been created

if (createStatus != FileManager::Status::Created) {
qFatal("FATAL ERROR | %s:%d: the new file did not get created.", __FILE__, __LINE__);
qFatal("FATAL ERROR | %s:%d: the new file could not be created.", __FILE__, __LINE__);
}
#endif
}
Expand Down
34 changes: 13 additions & 21 deletions src/plugins/solver/CVODESolver/src/cvodesolver.cpp
Expand Up @@ -139,16 +139,6 @@ CvodeSolver::~CvodeSolver()

//==============================================================================

void CvodeSolver::initialize(double pVoi, int pRatesStatesCount,
double *pConstants, double *pRates,
double *pStates, double *pAlgebraic,
ComputeRatesFunction pComputeRates)
{
initialize(pVoi, pRatesStatesCount, pConstants, pRates, pStates, pAlgebraic, pComputeRates, 0, 0, 0);
}

//==============================================================================

void CvodeSolver::initialize(double pVoi, int pRatesStatesCount,
double *pConstants, double *pRates,
double *pStates, double *pAlgebraic,
Expand Down Expand Up @@ -402,36 +392,38 @@ void CvodeSolver::initialize(double pVoi, int pRatesStatesCount,
mSensitivityVectors = N_VCloneVectorArrayEmpty_Serial(mSensitivityVectorsSize, mStatesVector);

for (int i = 0, iMax = mSensitivityVectorsSize; i < iMax; ++i) {
#ifdef Q_OS_MAC
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
NV_DATA_S(mSensitivityVectors[i]) = pGradients;
#ifdef Q_OS_MAC
#pragma clang diagnostic pop
#endif
N_VectorContent_Serial(mSensitivityVectors[i]->content)->data = pGradients;

pGradients += pRatesStatesCount;
}

// Initialise sensitivity code

CVodeSensInit1(mSolver, mSensitivityVectorsSize, CV_SIMULTANEOUS, NULL, mSensitivityVectors);
CVodeSensInit1(mSolver, mSensitivityVectorsSize, CV_SIMULTANEOUS, nullptr, mSensitivityVectors);

CVodeSensEEtolerances(mSolver);

CVodeSetSensErrCon(mSolver, SUNTRUE);

CVodeSetSensDQMethod(mSolver, CV_CENTERED, 0.0);

// Specify which constants will have gradients calculated

CVodeSetSensParams(mSolver, mUserData->constants(), NULL, pGradientsIndices);
CVodeSetSensParams(mSolver, mUserData->constants(), nullptr, pGradientsIndices);
}
}

//==============================================================================

void CvodeSolver::initialize(double pVoi, int pRatesStatesCount,
double *pConstants, double *pRates,
double *pStates, double *pAlgebraic,
ComputeRatesFunction pComputeRates)
{
initialize(pVoi, pRatesStatesCount, pConstants, pRates, pStates, pAlgebraic, pComputeRates, 0, nullptr, nullptr);
}

//==============================================================================

void CvodeSolver::reinitialize(double pVoi)
{
// Reinitialise our CVODES object
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/solver/CVODESolver/src/cvodesolver.h
Expand Up @@ -137,14 +137,14 @@ class CvodeSolver : public OpenCOR::Solver::OdeSolver
public:
~CvodeSolver() override;

void initialize(double pVoi, int pRatesStatesCount, double *pConstants,
double *pRates, double *pStates, double *pAlgebraic,
ComputeRatesFunction pComputeRates) override;
void initialize(double pVoi, int pRatesStatesCount, double *pConstants,
double *pRates, double *pStates, double *pAlgebraic,
ComputeRatesFunction pComputeRates,
int pGradientsCount, int *pGradientsIndices,
double *pGradients) override;
void initialize(double pVoi, int pRatesStatesCount, double *pConstants,
double *pRates, double *pStates, double *pAlgebraic,
ComputeRatesFunction pComputeRates) override;
void reinitialize(double pVoi) override;

void solve(double &pVoi, double pVoiEnd) const override;
Expand Down
Expand Up @@ -263,7 +263,7 @@ void CellMLSupportPlugin::newCellmlFile()
// Make sure that the file has indeed been created

if (createStatus != Core::FileManager::Status::Created) {
qFatal("FATAL ERROR | %s:%d: the new CellML file did not get created.", __FILE__, __LINE__);
qFatal("FATAL ERROR | %s:%d: the new CellML file could not be created.", __FILE__, __LINE__);
}
#endif
}
Expand Down
Expand Up @@ -142,7 +142,7 @@ void PythonQtSupportPlugin::pluginsInitialized(const Plugins &pLoadedPlugins)

// Register wrappers for every plugin that has a Python interface

foreach (Plugin *plugin, pLoadedPlugins) {
for (auto plugin : pLoadedPlugins) {
PythonInterface *pythonInterface = qobject_cast<PythonInterface *>(plugin->instance());

if (pythonInterface) {
Expand Down

0 comments on commit 7914033

Please sign in to comment.