Code Monkey home page Code Monkey logo

Comments (7)

blink1073 avatar blink1073 commented on July 19, 2024

Sounds reasonable, will do.

from oct2py.

blink1073 avatar blink1073 commented on July 19, 2024

Actually, when I looked closer this is not as easy as it appears. The file name is used by both python and Octave, and I do not see a clean place to use a context. Were you intending to use a context as a user, or was this intended to be an implementation fix?

from oct2py.

graingert avatar graingert commented on July 19, 2024

You'd have to expose the context to the user: with octave() as oc: ...
On Jun 9, 2013 11:16 PM, "Steven Silvester" [email protected]
wrote:

Actually, when I looked closer this is not as easy as it appears. The file
name is used by both python and Octave, and I do not see a clean place to
use a context. Were you intending to use a context as a user, or was this
intended to be an implementation fix?


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-19174949
.

from oct2py.

blink1073 avatar blink1073 commented on July 19, 2024

Right, but that does not solve the problem of the same file needing to be opened independently by Octave and Python. I cannot pass a file handle to Octave, so far as I know.

from oct2py.

graingert avatar graingert commented on July 19, 2024

You can create a NamedTemporaryFile that is deleted at the end of the
context
On Jun 9, 2013 11:41 PM, "Steven Silvester" [email protected]
wrote:

Right, but that does not solve the problem of the same file needing to be
opened independently by Octave and Python. I cannot pass a file handle to
Octave, so far as I know.


Reply to this email directly or view it on GitHubhttps://github.com//issues/9#issuecomment-19175403
.

from oct2py.

blink1073 avatar blink1073 commented on July 19, 2024

Okay, sorry I've been away for so long. Oct2py can now be used with context. I could not find a way to use the NamedTemporaryFile context manager, since I have to return control from within the__enter__ function (resulting in the file being deleted). Instead I clear the files upon closing or when the __exit__ function is called.

Example:

    oc = Oct2Py()
    with oc as oc1:
        ones = oc1.ones(1)
    assert ones == np.ones(1)

    with oc as oc2:
        zeros = oc2.zeros(3)
    assert np.allclose(zeros, np.zeros((3, 3)))

from oct2py.

blink1073 avatar blink1073 commented on July 19, 2024

I'm calling this one licked. Thanks again.

from oct2py.

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.