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.2.2.tar.gz
(12.8 kB
view hashes)
Built Distributions
Close
Hashes for npy_patcher-1.2.2-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63aed65c654f037d12e6e1ae34108dc19423bfa26a9d81d4800f0cd54d5a49bd |
|
MD5 | 3b065c7c131064b69b81126018c37c2d |
|
BLAKE2b-256 | a05a48c5a69d758ff4f4dc80a7d41c14837a5ec6ecec5ceb7dc31953ea4043a3 |
Close
Hashes for npy_patcher-1.2.2-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b64ee6244f96acf61016b51d544381717b820d4c1b3631f640f9b7de507e47d |
|
MD5 | e0078da35f325d6e1951c6c3915ed5c1 |
|
BLAKE2b-256 | a54e35378a1fa6439dbde6fc48d292d39711342acb72c8c91472e7534e4685e0 |
Close
Hashes for npy_patcher-1.2.2-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d5c4dbc9eddc861ee83aadec0eb35c347270f0f3e4e2ec6734fd7fa3372205e |
|
MD5 | 827a789d04cbcb81fc86975b3b88ef00 |
|
BLAKE2b-256 | 3197bac92e44d18915bd9c4d0d04ba867ed25583273deb526ec13af1c08b43c6 |
Close
Hashes for npy_patcher-1.2.2-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67c557803d6a3b5c72a5597fcc94e0c13dcbba96201e1706f10822bcf7325d28 |
|
MD5 | 122982a57245ae395eed2ee3ceb2fa3a |
|
BLAKE2b-256 | 072c50b530acda0acc238131374d6f4e76ee3a3622d68d9ee08f116c4a18a7ee |
Close
Hashes for npy_patcher-1.2.2-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8ca92c09cdb8229bc940a481b1fd85a31a19945e4868a870c8fc35723171e5b |
|
MD5 | 35f4d1fce40118414c94110148efcb3c |
|
BLAKE2b-256 | ebaf25332b61bf4f428c00db0c9ea28178a7feb198ad340b0cdee6fe3a7c380a |
Close
Hashes for npy_patcher-1.2.2-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf6283ab84496ac8cc3944f39b0bc3e86a47c829248b4424c292a1d4c1f28fc7 |
|
MD5 | c743c8a520ef1cc94d70c303b7aa7762 |
|
BLAKE2b-256 | 17e12ffbb01c49f7a5cabbb109029a8f981d4faf59fc2c2c010e3aa5c0208334 |
Close
Hashes for npy_patcher-1.2.2-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca34335e691f07c5f58859be17f93fc473b6dc471c718fe5eaf1169446d83adb |
|
MD5 | d5d27fdd22a81ba3eea44c1142b27c69 |
|
BLAKE2b-256 | f70699d6ed060deaaeb8bf4403ec411e2daeba86ecd04cf0b9e6b331af7a8eb8 |
Close
Hashes for npy_patcher-1.2.2-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba9e8827a514d6961453270c07fb6cea69bd2c9f8c0c2747000b02853a8dc8d2 |
|
MD5 | f96f57dbcbfe390e80db5de7504bd0cb |
|
BLAKE2b-256 | 15539a1dd84e46bc8464b4ec860f3926cea8fb4180f7056070b1614f53bfc0b2 |
Close
Hashes for npy_patcher-1.2.2-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8190cb7cd868038e8cad28cafab1ed19552601e270e7d2a3fab92ec3fd874af2 |
|
MD5 | 86e3072579d223b67547c6e1a802c8c1 |
|
BLAKE2b-256 | 20da60ce2fca0297d52fcd564c993408f8f674b73c5034d37775d89f4882f9c5 |
Close
Hashes for npy_patcher-1.2.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e896e1b2a77840f0ee53b7e409c0298824c428db357ae86ebb88ae87aceb7ed |
|
MD5 | 5d56952fffedaf2d6e92149b534fb549 |
|
BLAKE2b-256 | ef9f13ad2ff74fbd6d2a7bd81d8c9bbf440c8e6466ef908839c841eb589d4a99 |
Close
Hashes for npy_patcher-1.2.2-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cd42e46a36858f010e109bab62d6a944fdf8721645619c10fa30a4aa0b65e96 |
|
MD5 | c09ba80e15d8518b25ad1d0a9ad5d165 |
|
BLAKE2b-256 | 3c29df1b2c8693c184a5ad85a72d9f13e63e70a548b7d8c1c873adf1026182a4 |
Close
Hashes for npy_patcher-1.2.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d74aa6c056f31cd1b52f3222729f15ab3113f3585e18036eddda04e0c567a81d |
|
MD5 | 69f258f5294bf54bf745f5914272f88e |
|
BLAKE2b-256 | b0e607f1e59a3f30e31a9c4f99e03560480ef83902d550c8d3876acbb5217a56 |
Close
Hashes for npy_patcher-1.2.2-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d0a1f4700463d4f7830a815ae9b985e06e12398d029efe399fe69be5a2448de |
|
MD5 | aec57fa235ef22263a0022135b4422a7 |
|
BLAKE2b-256 | 898c249e6b54fb40445f2d36e7866f71075e3384bcb67019af7081b48739ae0c |
Close
Hashes for npy_patcher-1.2.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e619798def46288edb1e57bfa3cb19e6af4a68cd57e2c18dc7e58af6976a1ac |
|
MD5 | 5a92869bec919b5c22c603e307c47a83 |
|
BLAKE2b-256 | 9a49422f35bd53915538b2cf2642c90894012bd0273fabaf6bd87c244d23ea42 |
Close
Hashes for npy_patcher-1.2.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf93c7ca6e255801d310acee825d53cda6e991a7082fb9a0cb29069cda226ce8 |
|
MD5 | 3d3f3c6f33550e69c497b69b7c2a3aaf |
|
BLAKE2b-256 | fe1cdd0b05bad71c13aeba4a2fcf5e9201aab9ced042f7adf6441777793e219d |
Close
Hashes for npy_patcher-1.2.2-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fd4bfeb5798839a0cd11d0efdaa346b18d6f11765df3fdca08887ab09f358bf |
|
MD5 | b12a1fb0c2569d2af2539c33f008bdc1 |
|
BLAKE2b-256 | 0b3652d03245f4ab9850c68676c0ff4895a7d7090c4fc0dadc8974aa690562b6 |
Close
Hashes for npy_patcher-1.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27d0740ef5ce190b484b4bf04754eb7b75f100390bdd56c2aa0651fedb9ae262 |
|
MD5 | dbd0f2e122d194f27104d7cf937875aa |
|
BLAKE2b-256 | 353a30c0dc119c2ea31e74d79dea2c7d3739c099c269559ff04f52258e39961d |
Close
Hashes for npy_patcher-1.2.2-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4775fe277881ca51a2c100f7e9fb0d85027f5bfdffa239f12ef53e13f2d8d8a |
|
MD5 | 2e99f6fcb1d04e0b38f5c63555974ff4 |
|
BLAKE2b-256 | 598e26feaf447e2da93d123fab0ead7cccd05aa4e8a69615c082f186efb1c55c |
Close
Hashes for npy_patcher-1.2.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6662c89bc9ca0f834c795373c0f9dd3cbb7be601b97e1705b17a80868ef0680 |
|
MD5 | b9ca7e17c6c2aa0e96aac9a0df281a92 |
|
BLAKE2b-256 | fb7ffb8a299c069cccd12ad2b66e363aefea51dcc1f24d6a8962b87e83d253b0 |
Close
Hashes for npy_patcher-1.2.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47619f72bc552a3141586d5362e9c64550943c0cf44ca93c57980ffb86c3c57b |
|
MD5 | 3760c318226b99b09fb2148d76a66645 |
|
BLAKE2b-256 | 8a661a2955f843eba902ec24c0860ad69ddffd04f97ab2e12de8becdc1dd76e4 |
Close
Hashes for npy_patcher-1.2.2-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb0aa2217eef0ed2bd96b61b9dc709f474e3451dc0ff55928fa06dc2dca5a772 |
|
MD5 | a12373e43096baca5a3f2c01a9e8bf94 |
|
BLAKE2b-256 | 4bf9b7552f1b674a633c31f4c1278b60c4ec4fa3bdde16f5ff8ccd52633367e0 |
Close
Hashes for npy_patcher-1.2.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 152d988ffa60a0210efaca4d0356bd1b962b6816e537d607aa9dcfbaafa29fff |
|
MD5 | 22fa6ec157b16aaf7d5e3ddcde42e771 |
|
BLAKE2b-256 | 820069e8a6d10161a6f4a0ab8a479a1d0e85621eb762af91eb26af041c433e88 |
Close
Hashes for npy_patcher-1.2.2-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24f89f496a33249186d45e9d451643483135ab22659766cfb8392ec79e379589 |
|
MD5 | 9d6806fda8a44e0fdac4aa0d0388121d |
|
BLAKE2b-256 | 024d1e8577963a74bbfc62ab50c1aa82d1fc6b62ea67239db564a2731152723d |
Close
Hashes for npy_patcher-1.2.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a8632d42013ec1cfd9369a73e156f0ca7dca69df3bf301911994827d3907e7f |
|
MD5 | ebb82890777a1426e316137b7c28fe93 |
|
BLAKE2b-256 | 8f6fec816fcce9db7a81e379e3a3e353227372282628e792ff22ca06ca264af8 |
Close
Hashes for npy_patcher-1.2.2-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58feb9c33cc72ee16750a232705228122e6e812e210546f337b7c9a78d4e3cc7 |
|
MD5 | 7f4b6b9f61ce85ab0d4c434f1a0714f2 |
|
BLAKE2b-256 | 007ed99c2c1203f0f01952aa2e2c10f3cdbbae62895bafb08e36e59b4080bda5 |
Close
Hashes for npy_patcher-1.2.2-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 458b4f71658c1ce72d419cf3011df9a9d514b2b112406816118eff7b60e58f6b |
|
MD5 | 3ad1d21de6f6834fe0eee4a74e89cde7 |
|
BLAKE2b-256 | 2e6330ac0462df8bdff9d817df9a63301104fcdcabbd8bc2f3ef2bc9ae793090 |
Close
Hashes for npy_patcher-1.2.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42b5d11f3beb3910c9c58032131f20588943f28bf2d7d1baae28e87f2d15ae7e |
|
MD5 | 37af3f19ac8b632d03427a30a1da7a68 |
|
BLAKE2b-256 | b04cd5bb607b38ae1176122a716a80f8abe629d94249f148208acd5fead07a98 |
Close
Hashes for npy_patcher-1.2.2-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5b2dff2a0b3c55e011cc705af503b86f2560a04e78443b992d93c5085269ac3 |
|
MD5 | 756144c5923cbba2eb874d77c1ebf233 |
|
BLAKE2b-256 | d2a13ee1a03d9ade3dc2331f1f69a6246a41033882ff0af8f3770228797de244 |
Close
Hashes for npy_patcher-1.2.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe7d58b919e57247b522dcb75d8c052a398335cde6e7ed06655a07c0bcc9a950 |
|
MD5 | abecab28e5f13003b175fa4456c3f48b |
|
BLAKE2b-256 | bf2c2de00c8ff7acf4073d81096782113376693d185947abedc13d79bb5dd1b0 |
Close
Hashes for npy_patcher-1.2.2-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b53cb0871d8ba9c08d9e8fa3f54488fe3633ca280c1414a99ddf50cdaeca2589 |
|
MD5 | c25479f7c9203013bbee8c963ec17675 |
|
BLAKE2b-256 | ba883929d61567743a3df3ee081c66b749e9c1dcfc6747db603b05466b971a0f |
Close
Hashes for npy_patcher-1.2.2-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46b713723b667bb2f7faf9e1a882f937089aed2502299adb253268c82cfe0e5e |
|
MD5 | 4db69d83c750ac85bff9d57f2032c2e6 |
|
BLAKE2b-256 | ff84ad8bf792a6e73a3d7c523ca6dfa5d265623dfb1c87266b057eed902b515f |
Close
Hashes for npy_patcher-1.2.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d52deabf03c40fc2b56bd26cbcf21a2f8b4859e64fe44afeff2108610916d80 |
|
MD5 | a21c7aeeee9a75767bfbdbb6628bc8f4 |
|
BLAKE2b-256 | dab84b0b3dee0e0cd4cfe64175b3ca71c046a3d99446b11ae18d3f079a7dbf49 |
Close
Hashes for npy_patcher-1.2.2-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b68bb3d2d0bea51c4c49713d04420f42d1df91c2fafab93e23f8434747119e6a |
|
MD5 | 76813fbd8951e9f93fd350cbbb79053a |
|
BLAKE2b-256 | e20c74e6595d7167522fd0e380763244afc1a3a70d5a19d2a9ff4897c3cb8dd8 |
Close
Hashes for npy_patcher-1.2.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39ea46cf1f6de32d365fdfad0027a2df7bea02a7420336f4c9caf59ba94bc075 |
|
MD5 | f93c7efc447a2d9f41c29064d30e332c |
|
BLAKE2b-256 | 9cff01fe1d22ee59ccf2d6f64212c532ab6731b380cfb9f7ef523986e3e9ae86 |