add method toFormat to get number format from character

This commit is contained in:
wmayer
2017-08-20 18:50:13 +02:00
parent 858df142e2
commit 533a78026a
3 changed files with 24 additions and 18 deletions
+4 -12
View File
@@ -631,19 +631,11 @@ void QuantityPy::setFormat(Py::Tuple arg)
#endif
if (fmtstr.size() != 1)
throw Py::ValueError("Invalid format character");
switch (fmtstr.front()) {
case 'f':
fmt.format = QuantityFormat::Fixed;
break;
case 'e':
fmt.format = QuantityFormat::Scientific;
break;
case 'g':
fmt.format = QuantityFormat::Default;
break;
default:
bool ok;
fmt.format = Base::QuantityFormat::toFormat(fmtstr.front(), &ok);
if (!ok)
throw Py::ValueError("Invalid format character");
}
getQuantityPtr()->setFormat(fmt);
}