GithubHelp home page GithubHelp logo

Comments (5)

jgrewe avatar jgrewe commented on September 18, 2024

This is a known bug (#78) and its on the list to-be-killed. Thanks for putting some weight on it!

The workaround is for the moment to set all objects you used to store blocks, data_arrays, files, etc explicitly to None before re-assigning values to it. The following code should work:

file = nix.File.open('foo.h5', nix.FileMode.Overwrite)
file = None
file = nix.File.open('foo.h5', nix.FileMode.Overwrite)

from nixpy.

cgars avatar cgars commented on September 18, 2024

While risking to sound pretentious id like to point out that it might not be the same issue as \

nix_file = nix.File.open('foo.h5', nix.FileMode.ReadWrite)
nix_file = nix.File.open('foo.h5', nix.FileMode.ReadWrite)

does actually work.
I think it might just be that its not possible to overwrite and open h5 file. If this were the case then i think nixpy should simply sthrough a proper error.

from nixpy.

gicmo avatar gicmo commented on September 18, 2024

I am still not sure what exactly is going on in issue #78 but what is going on here is what @cgars already wrote (I think), i.e. that by the time you open the same file in overwrite mode (e.g. the right side of the statement) the file on the right is still open and therefore it doesn't work.

from nixpy.

stoewer avatar stoewer commented on September 18, 2024

The current version of nix/nixpy now behaves like this:

nix_file = nix.File.open('foo.h5', nix.FileMode.Overwrite)
nix_file = nix.File.open('foo.h5', nix.FileMode.Overwrite)

This throws a RuntimeError because an opened file is opened again with truncate mode. I think this is the correct behavior. Reopen a file with other open modes works, which is also OK.

To reopen a file with truncate mode it has to be closed properly. This can be done with close, or by assigning None:

file = nix.File.open('foo.h5', nix.FileMode.Overwrite)
file = None
file = nix.File.open('foo.h5', nix.FileMode.Overwrite)
file = nix.File.open('foo.h5', nix.FileMode.Overwrite)
file.close()
file = nix.File.open('foo.h5', nix.FileMode.Overwrite)

Therefore I suggest to close this issue as well as #78.

from nixpy.

jgrewe avatar jgrewe commented on September 18, 2024

I cross-checked and agree to close this issue.

from nixpy.

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.