Coder Social home page Coder Social logo

Comments (3)

schaubh avatar schaubh commented on July 18, 2024

@juan-g-bonilla , I just pushed my setter/getter branch to feature/bsk_715_setterGetter. I'm able to log the private variables now with the get method. However, I wonder if we should make a new utility function in sys_model.i called loggerGet() that logs specifically a variable foo with the method getFoo()? If setters and getters are becoming the norm, then I feel we should make this logging process easier.

Or, can we expand the logger() functionality to see if the variable can be accessed via mod.foo. If not, then try using mod.getFoo(). If that doesn't work, then throw the current error message? That way the logging interface for public variables and getter accessible private variables remains the same?

from basilisk.

juan-g-bonilla avatar juan-g-bonilla commented on July 18, 2024

bsk_715_setterGetter

I see the issue now. The thing is that because we are using raw C arrays, we need to return them from functions as pointers:

double * getFoo();

but then SWIG does not have enough information to transform that into a Python type (because it doesn't know the length of the data). There is really no way to return something like this in C++:

double[3] getFoo();

So we would need to use a more information rich type. I've added some commits with a switch to using std::array<double, 3> and SWIG changes to support that. I've also updated .logger with your idea about automatically finding getters, and it seems to work pretty good. As long as the documentation explains what's going on, I think it's a good change. Feel free to reset and play around with my changes.

Changing from C arrays to std::array might require some code churn, but I think it's step in the right direction anyway. Of course C arrays will still be necessary in C messages, but intermixing C arrays and std::array is pretty painless.

from basilisk.

schaubh avatar schaubh commented on July 18, 2024

Thanks for the support @juan-g-bonilla . I pulled your commits to my branch and will review and integrated. I like the new combined logger() functionality. I think this is a clean solution for the user. I need to update documentation to reflect this, and still keep the explanation on how to do more complex logging.

from basilisk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.