Comments (10)
In GitLab by @valentjn on May 7, 2016, 10:58
"Good" version of _wrap_OptScalarFunction_eval
:
SWIGINTERN PyObject *_wrap_OptScalarFunction_eval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
sgpp::optimization::ScalarFunction *arg1 = (sgpp::optimization::ScalarFunction *) 0 ;
sgpp::base::DataVector *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
Swig::Director *director = 0;
bool upcall = false;
double result;
if (!PyArg_ParseTuple(args,(char *)"OO:OptScalarFunction_eval",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_sgpp__optimization__ScalarFunction, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OptScalarFunction_eval" "', argument " "1"" of type '" "sgpp::optimization::ScalarFunction *""'");
}
arg1 = reinterpret_cast< sgpp::optimization::ScalarFunction * >(argp1);
res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_sgpp__base__DataVector, 0 | 0);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OptScalarFunction_eval" "', argument " "2"" of type '" "sgpp::base::DataVector const &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OptScalarFunction_eval" "', argument " "2"" of type '" "sgpp::base::DataVector const &""'");
}
arg2 = reinterpret_cast< sgpp::base::DataVector * >(argp2);
director = SWIG_DIRECTOR_CAST(arg1);
upcall = (director && (director->swig_get_self()==obj0));
try {
{
try {
if (upcall) {
Swig::DirectorPureVirtualException::raise("sgpp::optimization::ScalarFunction::eval");
} else {
result = (double)(arg1)->eval((sgpp::base::DataVector const &)*arg2);
}
} catch (const std::exception& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
}
}
} catch (Swig::DirectorException&) {
SWIG_fail;
}
resultobj = SWIG_From_double(static_cast< double >(result));
return resultobj;
fail:
return NULL;
}
from sgpp.
In GitLab by @valentjn on May 7, 2016, 10:59
"Bad" version of _wrap_OptScalarFunction_eval
:
SWIGINTERN PyObject *_wrap_OptScalarFunction_eval(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
sgpp::optimization::ScalarFunction *arg1 = (sgpp::optimization::ScalarFunction *) 0 ;
sgpp::base::DataVector *arg2 = 0 ;
void *argp1 = 0 ;
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
std::shared_ptr< sgpp::base::DataVector const > tempshared2 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
Swig::Director *director = 0;
bool upcall = false;
double result;
if (!PyArg_ParseTuple(args,(char *)"OO:OptScalarFunction_eval",&obj0,&obj1)) SWIG_fail;
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_sgpp__optimization__ScalarFunction, 0 | 0 );
if (!SWIG_IsOK(res1)) {
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OptScalarFunction_eval" "', argument " "1"" of type '" "sgpp::optimization::ScalarFunction *""'");
}
arg1 = reinterpret_cast< sgpp::optimization::ScalarFunction * >(argp1);
{
int newmem = 0;
res2 = SWIG_ConvertPtrAndOwn(obj1, &argp2, SWIGTYPE_p_std__shared_ptrT_sgpp__base__DataVector_t, 0 , &newmem);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OptScalarFunction_eval" "', argument " "2"" of type '" "sgpp::base::DataVector const &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OptScalarFunction_eval" "', argument " "2"" of type '" "sgpp::base::DataVector const &""'");
}
if (newmem & SWIG_CAST_NEW_MEMORY) {
tempshared2 = *reinterpret_cast< std::shared_ptr< const sgpp::base::DataVector > * >(argp2);
delete reinterpret_cast< std::shared_ptr< const sgpp::base::DataVector > * >(argp2);
arg2 = const_cast< sgpp::base::DataVector * >(tempshared2.get());
} else {
arg2 = const_cast< sgpp::base::DataVector * >(reinterpret_cast< std::shared_ptr< const sgpp::base::DataVector > * >(argp2)->get());
}
}
director = SWIG_DIRECTOR_CAST(arg1);
upcall = (director && (director->swig_get_self()==obj0));
try {
{
try {
if (upcall) {
Swig::DirectorPureVirtualException::raise("sgpp::optimization::ScalarFunction::eval");
} else {
result = (double)(arg1)->eval((sgpp::base::DataVector const &)*arg2);
}
} catch (const std::exception& e) {
SWIG_exception(SWIG_RuntimeError, e.what());
}
}
} catch (Swig::DirectorException&) {
SWIG_fail;
}
resultobj = SWIG_From_double(static_cast< double >(result));
return resultobj;
fail:
return NULL;
}
from sgpp.
In GitLab by @valentjn on May 14, 2016, 09:03
Confirmed on current master
.
from sgpp.
In GitLab by @valentjn on May 15, 2016, 16:15
diff -ub
(ignoring whitespace) of the two versions above:
--- /home/valentjn/swig_bad.cpp 2016-05-15 15:46:12.444554848 +0200
+++ /home/valentjn/swig_good.cpp 2016-05-15 15:46:20.700535665 +0200
@@ -6,7 +6,6 @@
int res1 = 0 ;
void *argp2 = 0 ;
int res2 = 0 ;
- std::shared_ptr< sgpp::base::DataVector const > tempshared2 ;
PyObject * obj0 = 0 ;
PyObject * obj1 = 0 ;
Swig::Director *director = 0;
@@ -19,23 +18,14 @@
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "OptScalarFunction_eval" "', argument " "1"" of type '" "sgpp::optimization::ScalarFunction *""'");
}
arg1 = reinterpret_cast< sgpp::optimization::ScalarFunction * >(argp1);
- {
- int newmem = 0;
- res2 = SWIG_ConvertPtrAndOwn(obj1, &argp2, SWIGTYPE_p_std__shared_ptrT_sgpp__base__DataVector_t, 0 , &newmem);
+ res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_sgpp__base__DataVector, 0 | 0);
if (!SWIG_IsOK(res2)) {
SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "OptScalarFunction_eval" "', argument " "2"" of type '" "sgpp::base::DataVector const &""'");
}
if (!argp2) {
SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "OptScalarFunction_eval" "', argument " "2"" of type '" "sgpp::base::DataVector const &""'");
}
- if (newmem & SWIG_CAST_NEW_MEMORY) {
- tempshared2 = *reinterpret_cast< std::shared_ptr< const sgpp::base::DataVector > * >(argp2);
- delete reinterpret_cast< std::shared_ptr< const sgpp::base::DataVector > * >(argp2);
- arg2 = const_cast< sgpp::base::DataVector * >(tempshared2.get());
- } else {
- arg2 = const_cast< sgpp::base::DataVector * >(reinterpret_cast< std::shared_ptr< const sgpp::base::DataVector > * >(argp2)->get());
- }
- }
+ arg2 = reinterpret_cast< sgpp::base::DataVector * >(argp2);
director = SWIG_DIRECTOR_CAST(arg1);
upcall = (director && (director->swig_get_self()==obj0));
try {
I don't really understand what this function is really doing. It seems to be called from OptScalarFunction.eval
in pysgpp_swig.py
... Fixing this would be great as this bug prevents one of the core examples from working. Not only that, it basically renders the complete optimization module unusable from Python :frowning2:
from sgpp.
In GitLab by @valentjn on May 15, 2016, 16:32
The director class SwigDirector_OptScalarFunction
in pysgpp_wrap.h
/pysgpp_wrap.cc
(in particular the eval
function) seems to be identical...
from sgpp.
In GitLab by @valentjn on May 15, 2016, 16:53
What I'm not getting right now is what _wrap_OptScalarFunction_eval
has to do with anything. That bug occurs when calling the abstract eval
method within C++ code, and that should trigger SwigDirector_OptScalarFunction::eval
which should call the user-defined Python code, which sees the wrong type of argument like described above.
On the other side, _wrap_OptScalarFunction_eval
is called (from my point of view) when executing eval
on the Python side for an object inheriting from pysgpp.OptScalarFunction
like that one at the very top.
So in my mind, these two are different pairs of shoes. I cannot be understanding it correctly...
from sgpp.
In GitLab by @valentjn on May 15, 2016, 16:55
Since this is a major bug in my eyes (and since I'm clueless), I will revert the relevant part of 9514d92 if we don't find another workaround. @fabianfranzelin Any ideas?
from sgpp.
In GitLab by @valentjn on May 17, 2016, 16:41
Status changed to closed by commit 711dc8c
from sgpp.
In GitLab by @valentjn on May 17, 2016, 16:45
After talking to @fabianfranzelin, we temporarily commented out that functionality, removing the SWIG support of LearnerSGDE
as well.
At the next coding days, we definitely have to look into the consistent use of smart pointers within SG++ and how to correctly propagate them with SWIG.
from sgpp.
In GitLab by @valentjn on May 18, 2016, 10:24
mentioned in commit 711dc8c
from sgpp.
Related Issues (20)
- Issues Installing on Windoze HOT 4
- Travis Minimal. Job Boost Libraries Missing HOT 1
- SG++ lacks clear contributing policies
- Condense evalDx & evalDxDx for certain Bsplines
- Copyright & style (& linter?) checks for Python code
- Python 3.8 support on Windows HOT 2
- Issue With MatLab Binaries HOT 9
- error: โnโ not specified in enclosing โparallelโ HOT 4
- Better release automation with travis HOT 1
- MinGW and localtime_r HOT 3
- DataMatrix::resizeToSubMatrix off-by-two error
- DataMatrix::resizeRowsCols returns wrong matrix HOT 3
- pysgpp fails to import on linux HOT 3
- Avoiding LF/CRLF line terminations issues
- Missing extensions directory (compiling with GCC under Linux) HOT 1
- build fails on AArch64, Fedora 33
- pysgpp does not work on Windows with Python 3.8+ HOT 1
- Several compiler warnings with MSVC++ HOT 1
- Julia API HOT 2
- Compilation problem newer versions because of depreceated "distutils" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sgpp.