standardize names for classes with inner namespace

release/4.3a0
Duy-Nguyen Ta 2016-11-24 19:22:44 -05:00
parent 0d68f42700
commit c13b964777
4 changed files with 8 additions and 5 deletions

View File

@ -145,7 +145,7 @@ void Constructor::emit_cython_pxd(FileWriter& pxdFile, Str className) const {
void Constructor::emit_cython_pyx(FileWriter& pyxFile, const Class& cls) const {
for (size_t i = 0; i < nrOverloads(); i++) {
ArgumentList args = argumentList(i);
pyxFile.oss << "\tdef " + name_ + "_" + to_string(i) +
pyxFile.oss << "\tdef " + cls.pyxClassName() + "_" + to_string(i) +
"(self, *args, **kwargs):\n";
pyxFile.oss << pyx_resolveOverloadParams(args, true);

View File

@ -156,7 +156,7 @@ void GlobalFunction::emit_cython_pyx_no_overload(FileWriter& file) const {
file.oss << "def " << funcName;
// modify name of function instantiation as python doesn't allow overloads
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
if (templateArgValue_) file.oss << templateArgValue_->name();
if (templateArgValue_) file.oss << templateArgValue_->pyxClassName();
// funtion arguments
file.oss << "(";
argumentList(0).emit_cython_pyx(file);

View File

@ -106,7 +106,7 @@ void Method::emit_cython_pyx_no_overload(FileWriter& file,
file.oss << "\tdef " << funcName;
// modify name of function instantiation as python doesn't allow overloads
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
if (templateArgValue_) file.oss << templateArgValue_->name();
if (templateArgValue_) file.oss << templateArgValue_->pyxClassName();
// funtion arguments
file.oss << "(self";
if (argumentList(0).size() > 0) file.oss << ", ";
@ -132,7 +132,7 @@ void Method::emit_cython_pyx(FileWriter& file, const Class& cls) const {
// doesn't allow overloads
// e.g. template<T={A,B,C}> funcName(...) --> funcNameA, funcNameB, funcNameC
string instantiatedName =
(templateArgValue_) ? funcName + templateArgValue_->name() : funcName;
(templateArgValue_) ? funcName + templateArgValue_->pyxClassName() : funcName;
size_t N = nrOverloads();
// It's easy if there's no overload

View File

@ -201,7 +201,10 @@ public:
/// To refer to a Cython class in pyx, we need to add "pxd.", e.g. pxd.noiseModel_Gaussian
/// see the other function pxd_class_in_pyx for that purpose.
std::string pyxClassName() const {
return pxdClassName();
if (isEigen())
return name_;
else
return qualifiedName("_", 1);
}
/// Python type of function arguments in pyx to interface with normal python scripts