Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compilation warnings #1346

Merged
merged 4 commits into from
Aug 2, 2022
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
4 changes: 4 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,10 @@ if env['python_package'] != 'none':
f"Cython is an incompatible version: Found {cython_version} but "
f"{cython_min_version} or newer is required.")
warn_no_full_package = True
elif cython_version < parse_version("3.0.0"):
logger.info(
f"Using Cython version {cython_version} (uses legacy NumPy API)")
env["numpy_1_7_API"] = True
else:
logger.info(f"Using Cython version {cython_version}")

Expand Down
2 changes: 2 additions & 0 deletions include/cantera/numerics/PreconditionerBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class PreconditionerBase
public:
PreconditionerBase() {}

virtual ~PreconditionerBase() {}

//! Set a value at the specified row and column of the jacobian triplet vector
//! @param row row in the jacobian matrix
//! @param col column in the jacobian matrix
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/zeroD/IdealGasConstPressureMoleReactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class IdealGasConstPressureMoleReactor : public MoleReactor
protected:
vector_fp m_hk; //!< Species molar enthalpies

const int m_sidx = 1;
const size_t m_sidx = 1;
};

}
Expand Down
2 changes: 1 addition & 1 deletion include/cantera/zeroD/MoleReactor.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class MoleReactor : public Reactor
virtual void getSurfaceInitialConditions(double* y);

//! const value for the species start index
const int m_sidx = 2;
const size_t m_sidx = 2;
};

}
Expand Down
3 changes: 3 additions & 0 deletions interfaces/cython/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ elif localenv['OS'] == 'Cygwin':
# extract 'pythonX.Y' from 'libpythonX.Y.dll.a'
localenv.Append(LIBS=pylib[3:-6])

if "numpy_1_7_API" in localenv:
localenv.Append(CPPDEFINES="NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION")

localenv["module_ext"] = module_ext
setup_cfg = localenv.SubstFile("setup.cfg", "setup.cfg.in")
readme = localenv.Command("README.rst", "#README.rst", Copy("$TARGET", "$SOURCE"))
Expand Down
22 changes: 10 additions & 12 deletions src/thermo/Elements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static vector<isotopeWeightData> isotopeWeightTable {
// This is implemented as a separate function from elementSymbols() because this pattern
// allows elementSymbols() to return a const reference to the data.
vector<string> elementVectorsFromSymbols() {
vector<string> values;
vector<string> values;
for (const auto& atom : atomicWeightTable) {
values.push_back(atom.symbol);
}
Expand Down Expand Up @@ -279,7 +279,7 @@ double getElementWeight(const std::string& ename)

double getElementWeight(int atomicNumber)
{
size_t num = numElementsDefined();
int num = numElementsDefined();
if (atomicNumber > num || atomicNumber < 1) {
throw IndexError("getElementWeight", "atomicWeightTable", atomicNumber, num);
}
Expand Down Expand Up @@ -309,10 +309,9 @@ string getElementSymbol(const std::string& ename)

string getElementSymbol(int atomicNumber)
{
size_t num = numElementsDefined();
int num = numElementsDefined();
if (atomicNumber > num || atomicNumber < 1) {
throw IndexError("getElementSymbol", "atomicWeightTable", atomicNumber,
num);
throw IndexError("getElementSymbol", "atomicWeightTable", atomicNumber, num);
}
return atomicWeightTable[atomicNumber - 1].symbol;
}
Expand All @@ -335,10 +334,9 @@ string getElementName(const std::string& ename)

string getElementName(int atomicNumber)
{
size_t num = numElementsDefined();
int num = numElementsDefined();
if (atomicNumber > num || atomicNumber < 1) {
throw IndexError("getElementName", "atomicWeightTable", atomicNumber,
num);
throw IndexError("getElementName", "atomicWeightTable", atomicNumber, num);
}
return atomicWeightTable[atomicNumber - 1].fullName;
}
Expand All @@ -349,14 +347,14 @@ int getAtomicNumber(const std::string& ename)
size_t numIsotopes = numIsotopesDefined();
string symbol = trimCopy(ename);
string name = toLowerCopy(symbol);
for (int i = 0; i < numElements; i++) {
for (size_t i = 0; i < numElements; i++) {
if (symbol == atomicWeightTable[i].symbol) {
return i+1;
return i + 1;
} else if (name == atomicWeightTable[i].fullName) {
return i+1;
return i + 1;
}
}
for (int i = 0; i < numIsotopes; i++) {
for (size_t i = 0; i < numIsotopes; i++) {
if (symbol == isotopeWeightTable[i].symbol) {
return isotopeWeightTable[i].atomicNumber;
} else if (name == isotopeWeightTable[i].fullName) {
Expand Down