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.0.5.tar.gz
(8.1 kB
view hashes)
Built Distributions
Close
Hashes for npy_patcher-1.0.5-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0174611bc66776bc88c1f60416714f6b381531c49e2b9468d042023f7f7813c |
|
MD5 | a19d02a4514aef26cb9096425eb10a0e |
|
BLAKE2b-256 | ece3d49adbcad6ee0021029eb0db2deebf5152c2618514424166f850968881e2 |
Close
Hashes for npy_patcher-1.0.5-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c425101cd47b8bd7401ac034597f6e75ba73d5de7b2aa99a23f53a723e26bd18 |
|
MD5 | 9c2042fa93bca4042fe77fbc319267f0 |
|
BLAKE2b-256 | 60136414a585a149ffb59169050bf4460eab71e4d926eb6cbd63c3d5ce255318 |
Close
Hashes for npy_patcher-1.0.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efdc3a141a39821a5684c1e24f3462972b6642403e08a0feb57789fb8b3b7c6f |
|
MD5 | a97afe87a620f4bdd58b3b4b36c854f8 |
|
BLAKE2b-256 | ffd17f2990e7000610fa1121148a35185b880711ac1322ffcea9cceb9bd7de3b |
Close
Hashes for npy_patcher-1.0.5-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 493903cac5b00b3d21f8283bfe320ab8790a3ff512ad55ddc0d4cc77e2830dc7 |
|
MD5 | 0d0a02e6e8700c0896dc1eb5be06963f |
|
BLAKE2b-256 | 85f1ef1e885331718966bb675ce50e343b898af34b853aad338adf5fd41691b2 |
Close
Hashes for npy_patcher-1.0.5-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc517b5e5f29d11a87a5c19194e4a3175320c72f172dfd4025dfb8ffb1b93eeb |
|
MD5 | b81c46b5159c68b96bfb39668c01d8e5 |
|
BLAKE2b-256 | e3e0a4c32d92e2a746110dc2f6f86c71f456fa3c347c5481662df7d01aab19cf |
Close
Hashes for npy_patcher-1.0.5-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f08cc06f632a7dfc6e2e25ab1fae9f58b6c677ff0d09bab9f3d0deda25f5151 |
|
MD5 | 9f7a893a6b21607b3d6aec644c252611 |
|
BLAKE2b-256 | ac09c520f4cb71cb913eb233f89c085d835920f05a676f86705fce040354c519 |
Close
Hashes for npy_patcher-1.0.5-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63b162b59811d8bf7c2b3778deba5ec9a37afd98b63bc8e321f4e80a8ec184bb |
|
MD5 | 4777fa8a35b7d96e0d7fe7cdcdcd013a |
|
BLAKE2b-256 | 3acf93f446aed21fcb13e5d18a310aa28fc9f3d3cef5a0419ed5c6b6bb51bba3 |
Close
Hashes for npy_patcher-1.0.5-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5592484a6d49203697c513d0c50739aedd82a139ceec9822d0442b73faa80598 |
|
MD5 | 614880b24d5704a962391de834be39db |
|
BLAKE2b-256 | d56078dbae24e383d642fdba8ceee319be14ab43ff75e49bf7e0a9f9080b9f3a |
Close
Hashes for npy_patcher-1.0.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02cb79d55dbbe75d04a9e61aaaee8942c5822ee6d3c596bbaaf1a060980ffd78 |
|
MD5 | f32a4e02e802cc632a64a2e661945215 |
|
BLAKE2b-256 | f883ec1220a296725c2b4e6ec6274626b0552872c386aef8a049cfb3579fa1ec |
Close
Hashes for npy_patcher-1.0.5-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e967e438c47d963e849cac2f34382f0a52f295b6c290949949e5e1919144be9a |
|
MD5 | e997d1dabbf779c81593c4574ab34df8 |
|
BLAKE2b-256 | 289b4241bfd4114dfcb745de6e7a50caf9bf82dbbb8a540af10f120b882f369a |
Close
Hashes for npy_patcher-1.0.5-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0335e83d6cc5d4d67db8ae36f1a5cadbe6bb243af896bfd5062291890ff32b5 |
|
MD5 | 980a674bdf85d2bcf28ba0a01faa5d4a |
|
BLAKE2b-256 | c0d59657b38c81f47aee887601e40b3f5cc38ed971333a6d0b9f81a7af70a8cd |
Close
Hashes for npy_patcher-1.0.5-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cd9eb3fec5ccc938166e277bc74b4ed834578b7f70e1dc2f677bd9b179563e2 |
|
MD5 | bc2eac01178b972a7798efaceba15b24 |
|
BLAKE2b-256 | 4428ef394adcc12a0b07331f5e34a51691f3435de39a50be23e9e32f2f5839ef |
Close
Hashes for npy_patcher-1.0.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3084f0b6c4fe01c358a133fcaf2d3a52c84b7ff68fae319219fa939cb2792a2f |
|
MD5 | a874ea1b266d3b50ebd091906e18aa13 |
|
BLAKE2b-256 | fc08efd89481b3ad788ba9a852d5ae6b799c7865c33782bfdf131bd0cbdc0855 |
Close
Hashes for npy_patcher-1.0.5-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 227a3a335fec74efd850dfbfbda485037fafc55e07dbb22bf74040ad5cb1f6e6 |
|
MD5 | 21de3fea14bf84a022bdfcf228ef8638 |
|
BLAKE2b-256 | 9b29fc467eedf7e08083ad96e6638421c1525601bb9d88d5db337737a2b9985c |
Close
Hashes for npy_patcher-1.0.5-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c42d18e47b1f955312af9df4c66d20e31ef2112fe93e5f8f284c05f2f6bcdce3 |
|
MD5 | ef68b81437ac5187a37bef9f55319e87 |
|
BLAKE2b-256 | e7603519c36574f0312a9bb63b3790c3af8d38cd33abb981b388d523adc415ea |
Close
Hashes for npy_patcher-1.0.5-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a1d8cc66b7d6aeae00faccc85a333eeb0e567e76cd0b245c70261d2596215e4 |
|
MD5 | aaaf1096fcce77f5af70d087343343c7 |
|
BLAKE2b-256 | 1bad6b920bea81ac9feeada5adbb6e1ed6634d319364da2cb77cba344a8603b1 |
Close
Hashes for npy_patcher-1.0.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9140fe56c6f5e9ae3d985c757776f95a95bc4318ee2cfe471519b14b65748110 |
|
MD5 | 3a7964842221273d8c042b9caa20781e |
|
BLAKE2b-256 | b060df48102256cf00ed599a28fbf302d2dbc1762d6a8d365f0a170be1075371 |
Close
Hashes for npy_patcher-1.0.5-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 510f38f7cf7b1723463c76c94ca722b1a3270f98e29812bf8d2acdf7b4bedd73 |
|
MD5 | 5a2f492af8d42e81034bf0c2824b8aa5 |
|
BLAKE2b-256 | 443d43e8cc771f9c275386e4bc82d0bb6ccce77df8067b7f2c1680d30c0167ea |
Close
Hashes for npy_patcher-1.0.5-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6fa3d696cf5c59e602f55cc4e277a73faa65ef33890c1313018e831b89ac702 |
|
MD5 | e6b529af84f1a40dfd12318c078d7a60 |
|
BLAKE2b-256 | 712d463fc5663047ec90a7a9f45ee21ab4d61de5718eda1323c2b3b8a7948c8f |
Close
Hashes for npy_patcher-1.0.5-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d0934893abb7e138f8b192b875b86c59883792698a7bc04e951019176f7436e |
|
MD5 | 91596dca17f3e737cb6944541a66b869 |
|
BLAKE2b-256 | 1e6848b415a080caf79f48e1af791bc6840340704d4ac908656f292b965020df |
Close
Hashes for npy_patcher-1.0.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb597ce5276385003ff6b8b9f5bd56166dd1c01e6f7553c60878614d73b8107c |
|
MD5 | 53a7871805aa0cc2071b3709afb32b4a |
|
BLAKE2b-256 | 075402e79c10a61026b9bc43ec6db5090e9798f7d8fbd13a484455b9e466c0b1 |
Close
Hashes for npy_patcher-1.0.5-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84dd428fcf4f4943cf66500ec8bdbd3c7bd3834836115adf1ec0fa8c4731184b |
|
MD5 | b10f0847a27d7464121550b2f35f9288 |
|
BLAKE2b-256 | a76284b60b5b193728d689f665e588b07f3f09e4b38073024c54fdb86664d779 |
Close
Hashes for npy_patcher-1.0.5-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 320047046a22cd793e3effecc0b07c00cccded5ee54b315ac9da447be5b5a6a7 |
|
MD5 | 68c8478399962f2f5b79abdd9a439549 |
|
BLAKE2b-256 | 6faa063406807a85413600a22e8dd67e452de039f40b06cb32c75d6eef52f7d3 |
Close
Hashes for npy_patcher-1.0.5-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 683f8189c72314a9361a015a0f773257d409d96b226928a419318608497397e8 |
|
MD5 | 162ee44f1a8658e237ebdc819e8156a1 |
|
BLAKE2b-256 | 057fa8404259756079fde6d4cd5d208a29d35e0910fc5fcaf4ef3c096f56768c |
Close
Hashes for npy_patcher-1.0.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b340ce3d9f0193301fca560f1f1ae1b64d325d06f84fb0bf32678c0b5be304d |
|
MD5 | 816366ef8d571a3a97166a1171cd3d49 |
|
BLAKE2b-256 | 7859a4fdf3cfb5cbd16b1404acf6e85275f153e086dcdaf01a1aceb65fbadae1 |
Close
Hashes for npy_patcher-1.0.5-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47bf2c4079904629a8cdcea35d2f6507992902ae6bbefb79a862ecde3fa09a2d |
|
MD5 | b187631c467dd5ee9329558d8179bab9 |
|
BLAKE2b-256 | 9fac8d0d8d139fa1f67529e6dca13241f64026d6c2a901b7e2a0915c0089bbd1 |