C++ based NumPy N-Dimesional patch extraction.
Project description
npy-cpp-patches
Read N-Dimensional patches from .npy
files. This module is built using C++
and has Python3
bindings.
Data Specifications
- Arrays must be saved in
C-contiguous
format, i.e. NOTFortran-contiguous
. - First dimension is indexed using in a non-contiguous manner. For example, this can be used to extract specific channels within a natural image.
- Next dimensions are specified by a patch shape
C++
vector orPython
tuple. To extract patches of lower dimensionality than that of the data, set the corresponding dimensions to1
.
Python Usage
Install
pip install npy-patcher
Usage
from npy_patcher import PatcherDouble, PatcherFloat, PatcherInt, PatcherLong
# In this example lets say our data has shape (10, 90, 90), and is therefore 3D.
data_fpath = '/my/numpy/file.npy'
patcher = PatcherFloat() # Use PatcherFloat for np.float32 datatype
nc_index = [0, 1, 3, 5, 7] # Non-contiguous index
patch_shape = (30, 30) # Contiguous patch shape.
patch_num = 2
# The patch number indexes the patches (starting from 0). So in our example the index 2 would be equivalent to data[nc_index, 0:30, 60:90]. The variable indexes the patches in C-contiguous manner, i.e. the last dimension has the smallest stride.
patch = patcher.get_patch(data_fpath, nc_index, patch_shape, patch_num)
patch = patch.reshape((5, 30, 30)) # PatcherFloat returns a list, therefore we need to reshape.
C++ Usage
Below is an example written in C++
, equivalent to the Python
usage above.
// test.cpp
#include "src/patcher.hpp"
#include <vector>
#include <string>
int main() {
std::string fpath = "data.npy";
std::vector<size_t> nc_index {0, 1, 3, 5, 7};
std::vector<size_t> patch_shape {30, 30};
size_t patch_num = 2;
Patcher<float> patcher;
// Here the patch object is a contiguous 1D vector
std::vector<float> patch = patcher.get_patch(fpath, nc_index, patch_shape, patch_num);
return 0;
}
You can then build the package, for example using g++
:
$ cd npy-cpp-patches/
$ g++ -std=c++17 -I ./ -g test.cpp src/npy_header.cpp src/pyparse.cpp -o test
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
npy-patcher-1.1.0.tar.gz
(11.6 kB
view hashes)
Built Distributions
Close
Hashes for npy_patcher-1.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c874ec2adc093c847b4115da6d0574d56261740cfccff12c85259d72fcc0b0d |
|
MD5 | 3646cad121c79639f4398cbb24c4cb04 |
|
BLAKE2b-256 | 6c56159dffef2079656312abee47104582b0cad905bc557284377f8128c6b5f3 |
Close
Hashes for npy_patcher-1.1.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 142278ffb021ebeefa2c42349674683fd0a34b28ebedb747a6e2e6e2a5acd2ad |
|
MD5 | 46a79fde6108e475fcb569a77916885a |
|
BLAKE2b-256 | 64c2fe95c5cdf8df4948dfd13699344a910c26064b3bd1d9857a44ce5aa01e1d |
Close
Hashes for npy_patcher-1.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5053d75ccd5a348611442655c8c2beea211138c00a5e616d96b9de0743694f4 |
|
MD5 | c15f193b5dfef87d1cb99981ebe35f9c |
|
BLAKE2b-256 | 300d65f8abb1b72bd674441931abe22b133973c7e1e23c23755870dabc01ea91 |
Close
Hashes for npy_patcher-1.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a249930c9fd13a49c97d27843531a57da825180d0497a88c0a4eb73d1e357c3 |
|
MD5 | 672d53d68ce29de0f55c89ca29923ad9 |
|
BLAKE2b-256 | f541f860b823f4f08332d4f7d18aeb06f6f25004ffd96a6a62d4777b8e9b155d |
Close
Hashes for npy_patcher-1.1.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93991ab868080bac9cf54f6e545d66bf8379b5853404e2b2b6ba480b46155f8c |
|
MD5 | d3074fa2f9fa6a20ab076a8764e5cde4 |
|
BLAKE2b-256 | a87d11d0c3133e04b02d74de007af4d8d2e8fc3dd209edbfc895f5128975cab8 |
Close
Hashes for npy_patcher-1.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1121f357ff9ae08c7fa87ce5dc7f7e7833fabd2af2c3063f99339aef1d4560b |
|
MD5 | aef13a6763885872cf10c95d5cfbe793 |
|
BLAKE2b-256 | 6d511cecbe99f74733113e47e5d4d1482a8b2ab83abef81ae54f2b5b31d1b6b3 |
Close
Hashes for npy_patcher-1.1.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b821098919d78bb684aeac733017222d6a7d58befbab62b0022528c9a3fae506 |
|
MD5 | 3ca3f0e645f559d1a789ebee5d1f3bf4 |
|
BLAKE2b-256 | 151de64af232ef92ec5d80626e983b8c9586a62e0943b3643b14b5162c5dbd80 |
Close
Hashes for npy_patcher-1.1.0-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f925babd76ad1012c38a3da68c87869081a8e10e077f935dcee3798ec8b745 |
|
MD5 | f6ae2c1ad93b7dd3364c8ebcf79e0fc9 |
|
BLAKE2b-256 | 7937de892e75e8189944852bc3a63a5ffb13278654dd96e3c257ceca5c4cf356 |
Close
Hashes for npy_patcher-1.1.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5a917c3993a1b417fa480dc8e669de7700103ccf47c045d46f04910813b4082 |
|
MD5 | 0d838e8f279534af40e12e4ad7aec31a |
|
BLAKE2b-256 | 50b82b63f6d1c66ed4784a9697b3b4132638330391eaa3a2b3ff22ac754d007b |
Close
Hashes for npy_patcher-1.1.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b906cdc533f24d86c81cbdcaa70d8e598e2d89ccb061327a11d59a609c98d8e |
|
MD5 | 25177210f3249881f657092b82db7ca2 |
|
BLAKE2b-256 | 8d61f1c1bd3a6e18004fb1d4f0d132ff0cf1e81b1e8d9a383a5678e41c76e283 |
Close
Hashes for npy_patcher-1.1.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f8eb8add6183d6c247f28bcd2464230a2085855341f0bd4991b5d295b2c4bba |
|
MD5 | fa37ee830e8eac1b838f43f5c019dfe5 |
|
BLAKE2b-256 | 13b1b285a1d6a7dc140abd3bb4a3238b3022e229fa9df1c47ff6b2e114f51c9f |
Close
Hashes for npy_patcher-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72e4c9a61c43f1a4534db4eb8034f378a1cd8d3d96d5d117b8bb3546879326de |
|
MD5 | 1adb58d471761755ea603d2d634d14aa |
|
BLAKE2b-256 | 3905930b4fd296029b93b7ab40ac7976f00ca9bacec394a4c6336eefd517a40f |
Close
Hashes for npy_patcher-1.1.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61aef31d84f439244179bb6fc895c33af4d4e2f375a4da8f7feebad1636647a4 |
|
MD5 | c6f4a59e5a2c81f24743b65a78f1bb31 |
|
BLAKE2b-256 | 6ad26b870cdbc8096b8144f7385d4eed9299348d46508a78423b42db98a44d6f |
Close
Hashes for npy_patcher-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4abab1f6be652cc1cc878fba94fcd911d633845d3f15f4114f3868424c67691e |
|
MD5 | bed6066d1864c132849b21a0cd97be3a |
|
BLAKE2b-256 | 858bde7e1acb6fa77d6a80b7d26d9b41d2c8acac1f7ec499044d66f253266100 |
Close
Hashes for npy_patcher-1.1.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f70eb053f7e841eb2633b642a408ad399e577550a282c6d995fb86327417c88 |
|
MD5 | 6fddccabfc3c3de988efb07c2e356004 |
|
BLAKE2b-256 | 597f3285f4b91981433c77de7402f4d4d70549741609ba81d7d6cd9aa0a1345c |
Close
Hashes for npy_patcher-1.1.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4bfdf0c5874b22ed26ef0d064b5741753535d16e9e82d9abd5d1aad70214696 |
|
MD5 | 354d55b7c5d693b8e2696481a889c848 |
|
BLAKE2b-256 | 024f4d671332a65917585ad0ddc7e918d8ebe7a0cf92979b125b332d5c567c8a |
Close
Hashes for npy_patcher-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ebf41cf7646c4898a2a8bccaaf862b10f59179c96c8238d1a100b71e99b4c14 |
|
MD5 | 3a899a09ae1d223006a62aac5198d966 |
|
BLAKE2b-256 | 76a88c7e0dcbcec1fcfab0b9bf44d34749526a31a0d2a763116f4fd4a4fbc776 |
Close
Hashes for npy_patcher-1.1.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6e520005b091db19db6d1c6b0eaba932e32c9b42370a5b1a03f8abfc479a795 |
|
MD5 | 272bec218d6be91697c10573a604d161 |
|
BLAKE2b-256 | 213d381744a0e7ab6217656680794d35be338f26374f940bf4c70b9095210f14 |
Close
Hashes for npy_patcher-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8972d0fcfb1af829048011c4393106d5bc6758263c08498eece4650ff47b738 |
|
MD5 | 94d89e7786266f3b04faf8299643e06f |
|
BLAKE2b-256 | bd718513759861210b5b2cfd65b4dfd8d797e87e26fb5eb08df32824a7c18382 |
Close
Hashes for npy_patcher-1.1.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c08f83e8896f91e50dc20f452ecfef3b9dd5fba369d9aaccc47e4e17dfebe339 |
|
MD5 | 82d9bfd197b901ac7d5f79424c23d883 |
|
BLAKE2b-256 | b458e7672473d520fa444a1e4b1cefd753b4598651cd3db6cfce86881292e154 |
Close
Hashes for npy_patcher-1.1.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6122ece274166a425aa7c605a946194458c191f90006b61d8a429101f8ade274 |
|
MD5 | 35c154b534ace534ea392b2796f48170 |
|
BLAKE2b-256 | 366fd07ba871437301b88bc7b4968b5b97de8b8aea0e63cd0285aa1ad8991b84 |
Close
Hashes for npy_patcher-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e01e365c520534f92008d9d9cec315aaec8e47f765d41d008470198015ab71d0 |
|
MD5 | d4989821593b8e305b74fb56f9b29f63 |
|
BLAKE2b-256 | 7758426621489619d3f1423eef37824ae65aa2c7d2fbbc6d9b5bbf0ad286932d |
Close
Hashes for npy_patcher-1.1.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16838123d0363da6457e3288335fe4157473e438d2ec6be7e0efebd02bd022df |
|
MD5 | 60189384d39f681d725fcdcc940c9bad |
|
BLAKE2b-256 | 4d22db961c40f530524bbf1a2a1f9145da5110a7e28d462be921f31eefb71d00 |
Close
Hashes for npy_patcher-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 350e10089818afc01f52a78538c1e3a10badc389a5d3abf6676c0b6f52ec5285 |
|
MD5 | 1410a01b060e8465d8347bb293811a3c |
|
BLAKE2b-256 | a39ed088d37f51f2b0bc5e7cd61461aebc90e897374793f3072f087e80729cb6 |
Close
Hashes for npy_patcher-1.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acc557eb2d29bf9762f5800b4b394ff6476e77a660ab33d51e17da0bd3e2f3aa |
|
MD5 | 3a26ce1e0dd4b104a9cc1a9475b64180 |
|
BLAKE2b-256 | aa76bd4c638d670dc5921adf0f978e0cc3ecdfc09b3725df66e3475d953f70b0 |
Close
Hashes for npy_patcher-1.1.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e988493cf7e323b913a6092262f7a52696149bebb2801fd3ca16100e7834bec |
|
MD5 | 7ab560bf9ba45b9b4c844e030294d899 |
|
BLAKE2b-256 | 20ba10b66dc191cfec58e1480be3127784ec5e8942e9d2dba68f5b1a0c6553f6 |
Close
Hashes for npy_patcher-1.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a00a868a633a0f4e8a2aa1b97087d12bd8a80ef1390a2bcea2b5e450f5a0dc69 |
|
MD5 | 8c2f11709660d6f3d804570c994c2b0e |
|
BLAKE2b-256 | 1fec629965387036a3a7e92cb7adad5e4fe5cb3f43eca65a1897a5bc116f0d99 |
Close
Hashes for npy_patcher-1.1.0-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dc30b94cd2ab66a2a00171a9e405b81fd3b6721980df21a6b7cfcb572338acc |
|
MD5 | e8ad6313e02d6ecdc25079ed40d04dec |
|
BLAKE2b-256 | eb401a4a90eddbb4231819fbe33141e62f7c835b818e0ea6c14b15eda6a8fb6a |
Close
Hashes for npy_patcher-1.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c17882ec635db8ae963c46a692ab66db9fddf8a9445db6c678ad6fa5b41f9f1 |
|
MD5 | cfd7df41da3b95a8908b572c70273f52 |
|
BLAKE2b-256 | 2f96136f54fd162388476deffecb976664d8cfae4fe92aa0ed995d0fd13d7759 |
Close
Hashes for npy_patcher-1.1.0-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47aff99b5f8928686ca63e9d96574dc1770249d48eb507180f5ae008c9cf0065 |
|
MD5 | 511383c6de7d87ee6b863a1a0a8dd23c |
|
BLAKE2b-256 | ac47fe6714aee2c1167bab8e047d6c1c075fd1215773cc90dd9e65277359315c |
Close
Hashes for npy_patcher-1.1.0-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9897cfd10ab33d8880a14820f028f81fc46428d33975e18752679289c24aed5 |
|
MD5 | 9c4d5c29d8202152c2c610fdf09e5968 |
|
BLAKE2b-256 | 33a28a308a46e7dca07c9db85bf1f1a54427214655205eb464db2600503556ca |
Close
Hashes for npy_patcher-1.1.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dae5e1c98da62cefccc627ecca8a3dbf3d7843e24ce88e4b6aa1f4c896eb61e |
|
MD5 | 4c370d622f2ef9eb1bba9a0505f89504 |
|
BLAKE2b-256 | 59529ffda85993944b87e1d69675d286f1f36629c31e930fe0d21f7304caf7bf |
Close
Hashes for npy_patcher-1.1.0-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db89015ff09734942d72130c78294f9f48d2065a7e0fd8d6c772af3115f3c2ff |
|
MD5 | b79978996b234a502a2c769799e13e7b |
|
BLAKE2b-256 | 25d3058f3e81661dfc36afc86fead70377ccfdf1083b377ef471c677daa9c545 |
Close
Hashes for npy_patcher-1.1.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 708811f38e7626fcceb1211efe8ec2cf9b5e84cc2651213ab673a03cd2136e8b |
|
MD5 | 9783d373d46a45d89fd573dc9698b65c |
|
BLAKE2b-256 | 9170bd621063e89e3e9c2f37fffaf1cdb70d0ed30e3efd6b66c604f975b865a0 |