Giter Site home page Giter Site logo

Comments (12)

WilliamTambellini avatar WilliamTambellini commented on August 16, 2024 1

Hi Dirk, thanks. Carl has found an easy way to support compressed npz/npy and should patch cnpy soon.
To be continued.
Kind

from cnpy.

rogersce avatar rogersce commented on August 16, 2024 1

Dirk, you totally get a vote :) universal preference seems in favor of no extra dependencies, so I'll see if I can retool this to work with zlib

from cnpy.

rogersce avatar rogersce commented on August 16, 2024 1

@dirk: I thought libzip would be much easier, but zlib wasn't too bad bc there was already code to manually parse the zip headers/footers. I'd agree fewer/more common deps are more preferable for the reasons you outlined.

I put up some new code up that will load using zlib, no more dependencies on libzip. I tried a few examples with npy_compressed and it seemed ok. inefficient in how it allocates memory but I will fix that later.

from cnpy.

WilliamTambellini avatar WilliamTambellini commented on August 16, 2024

When trying to open a compressed npz/npy (generated by np.savez_compressed()) with cnpy I indeed got an exception:
cnpy.cpp:92: void cnpy::parse_npy_header(FILE*, unsigned int&, unsigned int*&, unsigned int&, bool&): Assertion `littleEndian' failed.
@eddelbuettel: do you mean you have some patch that would allow cnpy to open/read compressed npz/npy files ?
Kind

from cnpy.

eddelbuettel avatar eddelbuettel commented on August 16, 2024

Not npz but we handle npy -- as we can just rely on libz to read from a compressed stream. It's all over in the repo I linked to, including some test cases. But it is set up for R users so you may not be able to read everything easily but there is eg tests tests/ directory.

You could call R (ie via Rscript) to have RcppCNPy read the compressed file and write it uncompressed...

from cnpy.

rogersce avatar rogersce commented on August 16, 2024

I pushed some code to read npz files using libzip, which is now a dependency. William do you mind giving it a go and see if it works for you?

Itd be preferable to use either zlib or libzip, not both, I'll have to look into this a little later

from cnpy.

eddelbuettel avatar eddelbuettel commented on August 16, 2024

I don't get to vote on what you do with CNPy ... but I have a weak preference for zlib because R already uses it. Else users of RcppCNPy will have to get libzip-dev to build. Which is probably only a minor nuisance as that should be common, but still "zlib is free" in our use case.

from cnpy.

eddelbuettel avatar eddelbuettel commented on August 16, 2024

Out of curiousity, is one of the two "easier" or "cheaper" for you? On Linux it doesn't really matter ...

from cnpy.

WilliamTambellini avatar WilliamTambellini commented on August 16, 2024

Hi Carl, thank you.
I ve just tested and it seems to work.
Now, like @eddelbuettel, I would also have a preference for removing the dependency to libzip.
Have you considered using some of these pure zlib solutions as for example "miniz": single self contained header, no library, no dependency:
https://github.com/richgel999/miniz
Cheers
W.

from cnpy.

wolfv avatar wolfv commented on August 16, 2024

I just used your code as source of inspiration to read/write NPZ files for xtensor: https://github.com/wolfv/xtensor-io/blob/master/include/xtensor-io/xnpz.hpp

It's got the added ability to compress the ZIP NPY files, and the zip contents modification date is initialized correctly :) With a bit of work it could be adapted for a non-xtensor use case, I guess ...

from cnpy.

WilliamTambellini avatar WilliamTambellini commented on August 16, 2024

@rogersce Hi Carl, I ve just tested and seems to work. Thank you.
In order to track upcoming changes/enhancements, what about adding a version in the sources: for example:
const versionMajor = 0;
const versionMinor = 1;
or creating a 1.0 branch ?
Kind

from cnpy.

rogersce avatar rogersce commented on August 16, 2024

@wolfv That's great! Glad it was useful. Writing out compressed NPY zips from C++ would be an awesome feature, when I get a chance I'll take a look at your code in depth and try to add that back into cnpy. Of course, if you think it could be done easily and want to submit a pull request, I wouldn't say no to that, either, haha :)

from cnpy.

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.