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.6.tar.gz
(11.3 kB
view hashes)
Built Distributions
Close
Hashes for npy_patcher-1.0.6-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386ad2077aad81d21e83d66428ae94e5acef2095296fe24f8d53f4baf7a9e75c |
|
MD5 | 239ee05f0f9a73e916610127c6e6ff7d |
|
BLAKE2b-256 | ca97a794155146efe53ede5106afaecb02f68e687d869b815223fa9a564ba6f0 |
Close
Hashes for npy_patcher-1.0.6-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 058aaed77f14430e89e3b1f8d707e841b8efdb28a7e50d32faec9198e6f0061b |
|
MD5 | 1da19b45c76137ae60980f59f24c24b9 |
|
BLAKE2b-256 | 83e3a7420f0b491a3fa9f7551e606d1b994c7769d209b59bce220fae14af23af |
Close
Hashes for npy_patcher-1.0.6-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b521bcf647c8c29b9ffb62755f45f76b8585748cb62685e5000bd61498d1331 |
|
MD5 | e32c011b62348e4285e50b83ba3d6cad |
|
BLAKE2b-256 | 0f300f9ada364679247a40babffcc7f077ad6869c4da866252058a943bd95f16 |
Close
Hashes for npy_patcher-1.0.6-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31c000e935742274a4cecd6e4dbd0f7d69f7ba40977abd7c6e6deabb3bc9495c |
|
MD5 | de7514e970f363cb8fd4f18b08d04047 |
|
BLAKE2b-256 | 0729c7e8d313819b730d9f7d07bb7eeb7d6d07482890a4beca384c0435e62390 |
Close
Hashes for npy_patcher-1.0.6-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12de2f5494451f418fb64c4c018ce04d5c2dff9eb303d95cbcf06e00fa7290ca |
|
MD5 | 3e54a5af4fa377d643c77c3c11eabfd6 |
|
BLAKE2b-256 | 10cda4d8f6c212933a9de1758add9769e7fc61b7d1d367463990334f0751c906 |
Close
Hashes for npy_patcher-1.0.6-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59e862d0f3f2ee29d0eafddb062f2cbb6e23a63104ea10b80ed2ba563ae91e6f |
|
MD5 | 3d957a6685dbdeb0072363cdd7da4383 |
|
BLAKE2b-256 | 3cc2d30280d11ab5bbd3763b9cdd9c714f0047c2406d5817fa4520ba99bd4b57 |
Close
Hashes for npy_patcher-1.0.6-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 057542dd01389f29ee1cec0e3be575c5072166a1a99c333b5b6e6e23acced303 |
|
MD5 | 879ffef43dbc51df00ab0f0f44a94b66 |
|
BLAKE2b-256 | 878a96b83a81434c496e8126efae235a95c61d5707feb19c14466c9e61a81e64 |
Close
Hashes for npy_patcher-1.0.6-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a31b013d998ea4043267d7b24c5d876e26c64bd60d6d34e03efeb53d7acce53c |
|
MD5 | 87a3a1750a785205b5e617f1bf5da205 |
|
BLAKE2b-256 | 096a93ccd0ac2c7d42d9638307885c98ff30de978ec4fa7338d9184e5f9ffeaf |
Close
Hashes for npy_patcher-1.0.6-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e284826ae350b021aaa2fdecc7e1a25a45879f4469ad33e6984ea8ff43d96849 |
|
MD5 | d6b0ec6f48a5e8fb4ce208758557acfc |
|
BLAKE2b-256 | eb020be0934e69537e3359cec1c844a797a22dd1caa6d70ab474be5470b974ba |
Close
Hashes for npy_patcher-1.0.6-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0acd7988208d1068b97afcbe0b6b3d4b54bb1d0d589911309c0f6fea4233df0c |
|
MD5 | 8c9ed2f3f8cdfdbb630e8ab04a80a166 |
|
BLAKE2b-256 | 8df6c8843e40fa82d985113a8027ac744136af75c722c2b8420ac6d996b6b1a6 |
Close
Hashes for npy_patcher-1.0.6-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7df8287a64686715fa1d03c6787700ad722bb773721d44da5d1177b63d79c43b |
|
MD5 | 6c0e87080166d62880196aa88dfd1210 |
|
BLAKE2b-256 | e8971599004d01a65adeb884f6fb7969d3f74358805da528462e64ced12144b5 |
Close
Hashes for npy_patcher-1.0.6-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1d122e1fec02695542b8f5ab9d6a2759b6de204fcf0d8c9771c3941ee4b5ee7 |
|
MD5 | 6c6be7fa9e51371a2b11d26204eba9d9 |
|
BLAKE2b-256 | e482646ef43dfd1429bf4a6472b35620d7e7dffa55797669b0c2b5d0e656eaff |
Close
Hashes for npy_patcher-1.0.6-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd9b557f8acfe6a6abd672a9a97622241409013fe9c1f21513022b1353f0e676 |
|
MD5 | b896fe7c1996d1c613f76060cc8ce3df |
|
BLAKE2b-256 | ff271195bdd98b1bf42670e5f7e339582d7c42489f60e979311d2667753e96e8 |
Close
Hashes for npy_patcher-1.0.6-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bba7bbaa369757f8753f0282a3c0db8ff211017f6c6aaed9c503a33b7e6c551 |
|
MD5 | 11c0a5a11958dc00ad900e3f7b38d1e6 |
|
BLAKE2b-256 | de2e463687a57f4f102c0f075a6c9ed3dedab98d54c998f4fb7941bc237ddd36 |
Close
Hashes for npy_patcher-1.0.6-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7d26a67d89360dd8c8a14636c6c86d83288418cc37ead91e17ca3faf98e3897 |
|
MD5 | 62221162f5a1fd1fa58051975004aef6 |
|
BLAKE2b-256 | 2f4a9f7daf1f5bda93e5b08c4547e82ebe7bac3540e4e505c2bc7f532fdb5fa8 |
Close
Hashes for npy_patcher-1.0.6-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d70974847700d0dfe3b2564b6d830e208df5003539672a9ae0693cfce0776fe1 |
|
MD5 | e5366e18754583168fb4040f2f9e0d5a |
|
BLAKE2b-256 | 935f04fdccd946852533076c5ef68efafd8746043eda1e42ba945a56f8cf17fa |
Close
Hashes for npy_patcher-1.0.6-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f75defc3eec6f903cbcb763d83412778ba8e7dbdd85e76b84b8a1d8583209ac |
|
MD5 | 4c0d8fcb41fc7ec2aad67b7a992c8c22 |
|
BLAKE2b-256 | f2593fcbb0f56976a6da8342d6fbb76f6aebe5cb9b16deea0506ef3ab597ea1d |
Close
Hashes for npy_patcher-1.0.6-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcf4ad83d4da28c6ac6a7523cd4ca1d9cc2040154868f9546a3664986130a823 |
|
MD5 | 5107654a8c15e2245f7ebbf3447e9f71 |
|
BLAKE2b-256 | cdb0a8bea17696199e7e7491efde148f384000f8fe5b55c21f903f860da4549f |
Close
Hashes for npy_patcher-1.0.6-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1472c0d9ae32c696e6b8bb77f5937b25ec16d584dd074ce08c7074b613d3552c |
|
MD5 | 45164c3eaf62fa0230b15142bc6bd184 |
|
BLAKE2b-256 | 0521760810c86b8199a5f4bfa25d68559e03693f844cbb19ac26dbf6daa26187 |
Close
Hashes for npy_patcher-1.0.6-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c96f40a6b3ca3f8a49c23b0494ecc83bafc54dd7d053a76fc7e41de060f0a59 |
|
MD5 | d467045a4ac21a3c2b6c5ff6b5a349a6 |
|
BLAKE2b-256 | a55323838f799413bc208ef0f95b20ea79683ee30e2e6629ca987394235c7370 |
Close
Hashes for npy_patcher-1.0.6-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d1085f61022705fe508c2edf6ea7b38e255b9c9658fe83ed5b9db206b67ebc8 |
|
MD5 | fc528e5e8bc44449a077903a41ecf59d |
|
BLAKE2b-256 | 47f9925e4e9f0da6e5d85d48bfeadaa52631649a77614cce3dbf811037b8fd95 |
Close
Hashes for npy_patcher-1.0.6-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26120dfbc63a9e0315734f4d358a1f3233215c65dea9c3597e51a18674d37804 |
|
MD5 | 05e4bebb2ca5e7ec9623c23ca001d507 |
|
BLAKE2b-256 | fd5bc8b85273df72d67871467949a96cd94525484048799dab3e42d21677696b |
Close
Hashes for npy_patcher-1.0.6-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 409fcd3d231aa6f8d74abfa37f7b82351a7f8cab7bf7dea4ed2f3b5a670e5c84 |
|
MD5 | ec786a8476956774f63b0be93042af58 |
|
BLAKE2b-256 | 180d5123c4cec5589c124f31190544e343c615f234f0b128cececda95dd30646 |
Close
Hashes for npy_patcher-1.0.6-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3407b42335754097543c9a7e6d70088edc40ae7a6fdcd919a388ab2d9dfaaf86 |
|
MD5 | 71e52032c111b2697cbb809a00d542cc |
|
BLAKE2b-256 | 3441720fa09530c1ab9e4205b9b99e6dad85c99016f69f16ee037a3caf65fbf4 |
Close
Hashes for npy_patcher-1.0.6-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad7d57388c7f48228a076af8b05f5382c6c5aeda5825e59a45e4a4b1414b0b9a |
|
MD5 | da99567bb6e14e0a082a1ddc4d600d56 |
|
BLAKE2b-256 | d723ebc57fc3b4da3968afaab00d4db3d16ab047d1518298136faa85b25fa45c |
Close
Hashes for npy_patcher-1.0.6-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e07d770c8df1d91fcb825432991c255172252ba420edd8e441cbf430fe51461 |
|
MD5 | 651964e68584b56e4719e2a23359df21 |
|
BLAKE2b-256 | 8dc49930131bece6d22e43c6821580dd97bf888faa08247d6f27126c10d46122 |