• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

kwikteam/npy-matlab: Experimental code to read/write NumPy .NPY files in MATLAB

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kwikteam/npy-matlab

开源软件地址(OpenSource Url):

https://github.com/kwikteam/npy-matlab

开源编程语言(OpenSource Language):

Jupyter Notebook 99.5%

开源软件介绍(OpenSource Introduction):

Travis

npy-matlab

Code to read and write NumPy's NPY format (.npy files) in MATLAB.

This is experimental code and still work in progress. For example, this code:

  • Only reads a subset of all possible NPY files, specifically N-D arrays of certain data types.
  • Only writes little endian, fortran (column-major) ordering
  • Only writes with NPY version number 1.0.
  • Always outputs a shape according to matlab's convention, e.g. (10, 1) rather than (10,).

Feel free to open an issue and/or send a pull request for improving the state of this project!

For the complete specification of the NPY format, see the NumPy documentation.

Installation

After downloading npy-matlab as a zip file or via git, just add the npy-matlab directory to your search path:

>> addpath('my-idiosyncratic-path/npy-matlab/npy-matlab')  
>> savepath

Usage example

>> a = rand(5,4,3);
>> writeNPY(a, 'a.npy');
>> b = readNPY('a.npy');
>> sum(a(:)==b(:))
ans =

    60

Tests

Roundtrip testing is performed using Travis CI and GNU Octave, see the .travis.yml file and tests/test_npy_roundtrip.py.

You can also use two "manual testing scripts":

  • See tests/npy.ipynb for Python tests.
  • See tests/test_readNPY.m for MATLAB reading/writing tests.

Memory mapping npy files

See examples/exampleMemmap.m for an example of how to memory map a .npy file in MATLAB, which is not trivial when the file uses C-ordering (i.e., row-major order) rather than Fortran-ordering (i.e., column-major ordering). MATLAB's memory mapping only supports Fortran-ordering, but Python's default is C-ordering so .npy files created with Python defaults are not straightforward to read in MATLAB.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap