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.8.tar.gz
(11.3 kB
view hashes)
Built Distributions
Close
Hashes for npy_patcher-1.0.8-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf88ec9830f8330135fc7447660380acd3ee5f730e4d5ba9a57b52fd4c261407 |
|
MD5 | cd421b21d64a5a17edb045cb787c7c6c |
|
BLAKE2b-256 | 975f4e6fe83b133706410a99ed650cd74b25aeb218a0c03a178547c41f0629e8 |
Close
Hashes for npy_patcher-1.0.8-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6ef5d481db508def3eea01b1fb8b9ef1299c30f29434d79df015aee72bcf19b |
|
MD5 | 8e0be1de448b6dbd2dae6d2d0150c1dc |
|
BLAKE2b-256 | 3f13ea267fbc13b75c921738ee8e533862d98719b4ff6949b377580ad87cfb12 |
Close
Hashes for npy_patcher-1.0.8-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c6f3538ab498712785872bfd7608f2ce1ceb0d8e528941bd076e2d8a3314cef |
|
MD5 | 7bfd2547b42955e292d0129d8e6653b1 |
|
BLAKE2b-256 | b0c2812d387814b84d91aeaeb5927c1a591d65b7ffbc7aa94ccd97bd8208cce5 |
Close
Hashes for npy_patcher-1.0.8-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 105f466cddc26e4330ed0b6104130c2fb2031b7cde9953745be9fdd3e0c6e213 |
|
MD5 | 907eac49ad13818297b95e90c12af61f |
|
BLAKE2b-256 | f8582208e2ebfa675f50225a0c73c08e23ac3881be9bc4c89f55098f564a71d9 |
Close
Hashes for npy_patcher-1.0.8-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 991103e37b85e2ee4590beb4663f548d7547e6c03d5f7502c0e3f197dcfa89c0 |
|
MD5 | 171cd80bdce51cf003e52de1a2e17627 |
|
BLAKE2b-256 | c503ab48d4b2d9541591a5fecfc097cf8133505b10dbc1b8247116497c31d806 |
Close
Hashes for npy_patcher-1.0.8-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e922fe0d3ba7f2f025bc7c19ea3cbf2de5d781e2e52dc7a041cc1ad29ffd2a7e |
|
MD5 | 2987dc3de667de6f6659fb3e4a5d27b5 |
|
BLAKE2b-256 | 5028e467db86874dc9eddb9834ac0c913ab65b51d07cabdbbba925428788eb1f |
Close
Hashes for npy_patcher-1.0.8-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66e47d21d455f331862ef27a8b02f79014a359bdd923cfdabc208a8fca5a863e |
|
MD5 | 467fa0bc949b833cf035efa85426cca0 |
|
BLAKE2b-256 | d02dc4f51f3a11afdbed996d1709bbb2c236b99d5c132263b7fac5901dd4fc3f |
Close
Hashes for npy_patcher-1.0.8-pp37-pypy37_pp73-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d259b068b6c0d4efcf7a92d480ff9edb051466376eac74829669506b248f4637 |
|
MD5 | 3b5d9cad7638f0314663047c7d918b8d |
|
BLAKE2b-256 | dd9ac916b0a785b28185f775113b4980f88f8497248667664e088b342b1ab2d4 |
Close
Hashes for npy_patcher-1.0.8-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b559879173a24b9ff67fbfd17ac9bd1fa2f747294e6630658c4fc48fd89f8474 |
|
MD5 | 293f58aa9ed530dd694fe6ad3205b328 |
|
BLAKE2b-256 | d144c5e3ee0b74d8fa515a10217be66d379a5d243872dcfe18e116016b06d58b |
Close
Hashes for npy_patcher-1.0.8-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59b8baf8e75800f51496a8bb989be45ff07f70dac17fcd6482b889b15580ccb0 |
|
MD5 | 96258932bc0c28b94a27fb076d599a54 |
|
BLAKE2b-256 | 99c5db5705e54f746600d893dc88948efee2e2150546bb20724403af69477d2a |
Close
Hashes for npy_patcher-1.0.8-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8d4675220eafc7642cdc685ea0912aa16365428172252c0e444cceadd08444a |
|
MD5 | e34c237c16b9db50034cb29d5a6d02ac |
|
BLAKE2b-256 | f6726ffa3b31054669f81df8cd802da3198fd985663c5a155ea3075e4e7815ff |
Close
Hashes for npy_patcher-1.0.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b1bfaf640642c4520d419883ec4a9d5202afde19c16143e2b62f6c52c911ef3 |
|
MD5 | 1ca465beb88381a25d9faaaa2c767550 |
|
BLAKE2b-256 | fea254862478ea2e67597fc00449b1e7b7ec0023143766a9b60ed33c716ec580 |
Close
Hashes for npy_patcher-1.0.8-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58cd20eff41bd1997cd0aa125ffb2e5da0797ec93754646316530c05474a16d1 |
|
MD5 | 7e557ccb7ff922af29c73c31cc79cadc |
|
BLAKE2b-256 | 89910fb2ec771c8fbd57fdd91faa02c2ba6b7fefa45d0b3e03a37386ac0cdf86 |
Close
Hashes for npy_patcher-1.0.8-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86ffc01caca8e7e6f8e8001e4142619098362e2091cbc8f1e8d73452abb0cce1 |
|
MD5 | a4744ca1f1eb17a257d606f64475528c |
|
BLAKE2b-256 | 1aeeeabd7d232f9ea4cc663de26cfa6b33353fd395cd272c034ccceeaf5f9756 |
Close
Hashes for npy_patcher-1.0.8-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | add2d7dd10c2072caf30aa83bf114aac8111caf757f9ca68f815a44082691f1e |
|
MD5 | f6aeab11d145cde89d0553e61ec64bfc |
|
BLAKE2b-256 | 47baacc9862ba75f8fb1bdbcc3bb51baecf144f3ab3fb166f0f2365b8a39dcd4 |
Close
Hashes for npy_patcher-1.0.8-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd09751ca727c3cc1e5ba35703f69192267ff91c2a5de4ef114d5dcf67cd1fd2 |
|
MD5 | a799b53ee4b8b5212bf598137b13cce9 |
|
BLAKE2b-256 | bd34a9f630b3107bdc858dd34146d6b168e848a4eb37321dc6a9bea9d36850a9 |
Close
Hashes for npy_patcher-1.0.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6c39eefe14bf2b20e91d5e871065de14de4578f9b68f91762208f5e9b4da8a5 |
|
MD5 | 930e32d501b6d4363d086e088d1ca39b |
|
BLAKE2b-256 | 17183b7c3d10ba65d52f84d8fdca57db6913320f61a6c3ec356eb5d80a6b5a06 |
Close
Hashes for npy_patcher-1.0.8-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d31a729bef27260d3d0925ff334e1bf53b2a8fd2060344fc4cc148d5d76ec9e6 |
|
MD5 | cf554726a84388214f08064189fe3b15 |
|
BLAKE2b-256 | 4fbe3ba863b778cdc9e7286515756d674f1e2196f6063ce88ec0cb171c762c45 |
Close
Hashes for npy_patcher-1.0.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41335a70c59854aba4f9713812e2dd43822accf2698fe5cda4ce768532b4513e |
|
MD5 | 59159a224cd8740e4d565445a12cac74 |
|
BLAKE2b-256 | cdc9e61d7c947e534e7639e124e15c91874955a330a1100fab4d0beb5e41b92a |
Close
Hashes for npy_patcher-1.0.8-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64dfd93e4f25d6256da05b09c891d09b28738a51947971d5eee92792f81ab8bc |
|
MD5 | 152bba6c2b9f37b3578ffe110146487f |
|
BLAKE2b-256 | a06c7f4c5bc52ab236cc362247d011a6bc5f5d42a378465f87aadc528249b6c7 |
Close
Hashes for npy_patcher-1.0.8-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71e9c0f7e1770a35f0be457b08721802cc9c110826eb8d8981848e750c5f8146 |
|
MD5 | dace17d7df87087d027d4896279b5f19 |
|
BLAKE2b-256 | 1c44669c5fe0b42925d153c937f4b8cd7c9f85503fcac4953f7569c918e54602 |
Close
Hashes for npy_patcher-1.0.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 902fd3acad4bc2e2d29556943397cc583437c720cc1dcd2f7cca5eb0e56ae1cd |
|
MD5 | 4376df81355c8e148f507aaee5041431 |
|
BLAKE2b-256 | d07d63587a1c4a743408f80183a1318b4cf66752b9e699b6f8f8102da93b702b |
Close
Hashes for npy_patcher-1.0.8-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d46ee227b65cadcd84737e7423975d90af18f6be6066e16b89935a2f0b2a4ca7 |
|
MD5 | f9446c439b66e0543b96d92a2e45806d |
|
BLAKE2b-256 | 7a8e241a47908777b0ca2eeb940af9d2a75f09188e773d5866af20f0cf3f6001 |
Close
Hashes for npy_patcher-1.0.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c5625b4194a501ec0028af60059d53506c04225026168fd487d98577bb1741 |
|
MD5 | daa46ec3783e13f02f42df921814bcb4 |
|
BLAKE2b-256 | 7dd063d3360123eb9e154c4c225d22ea5ef350aeca05a1645b564f9177c5b950 |
Close
Hashes for npy_patcher-1.0.8-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd163801b27fe2d5eb5144727712c4ea367a76ce1e992a67022a99e8c6fd5585 |
|
MD5 | 95f0989ac31dd23c5c5d84fbaac4aafa |
|
BLAKE2b-256 | c2d4bc1004c2e3cfac612fbf4a87a0b0ee58d35ce57ebd882432bda9140f3794 |
Close
Hashes for npy_patcher-1.0.8-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68e7b5ab38f0ab1ab7b516e09dddc8c81fb4d61ed739525add5a712e6fe0b095 |
|
MD5 | ff01942ae5675e6f27e7c1d50de50684 |
|
BLAKE2b-256 | 21d7c2d095ee524bb67eb7ecc56bbcfab8f4c121b9c563283dd724a6209c815b |
Close
Hashes for npy_patcher-1.0.8-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06d26ca389d9b701f5df88c47576d5c845987976b1cb6909ef58825705ddac84 |
|
MD5 | 0b6bacf6dc2b4a84b5a44d93f896fb2f |
|
BLAKE2b-256 | 83db08e7bc05b8817cfab899894f380b6dfef84262834ec54959b05564f2e4cb |
Close
Hashes for npy_patcher-1.0.8-cp37-cp37m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5766d4b9f57474797a0b003799f4a12d56beeb288b6362e4e34504b949b4cd83 |
|
MD5 | 20f97f3a2211343b7a9cfe0c0dd338db |
|
BLAKE2b-256 | de6c9ed5140f704270a8b73420b2da291a96b4b14e12f1360aae5a86e7e8d0f1 |
Close
Hashes for npy_patcher-1.0.8-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af5a162af71cecfda6398d9edddcc83c6bcaac49d24e6107af090ed506d71e8e |
|
MD5 | 93c279fa60869428e8d51c9ecafa5ceb |
|
BLAKE2b-256 | f61f0fede9cf4096890356d69a1686a16a550cdf1ccd297d42337ac21542751a |
Close
Hashes for npy_patcher-1.0.8-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e3fffd5f114ea91b1e4c3527dc26c6703f5de15882a5d5f7829c68d6b17d69a |
|
MD5 | 858cde7f840c1df6bd2e85b17f06cc93 |
|
BLAKE2b-256 | 8736ed708e10a68927bc368ac6ef3abf460bcbe9e77f5d5761719236ff0983dd |
Close
Hashes for npy_patcher-1.0.8-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbe23827cd1d4f1d8591058676d9d12dbb4ed116c9bb5a80fda06cb56cc6b7b3 |
|
MD5 | 0058c21c91f012e4460801558ff06113 |
|
BLAKE2b-256 | 907c5057c7abc7e93452c17e4d7c7d7f2096734d37ac9277c534042ee33c9843 |
Close
Hashes for npy_patcher-1.0.8-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 001a5b2390dfc37a197e762db5eddacc78185215e53ddeb574b99d769a3b8405 |
|
MD5 | 8dc2c266dde81607fba067b8d4a359ee |
|
BLAKE2b-256 | 5e8cc8c05f76c846669ff2c6a7ea3a1104bc74915e7171265a235ff664856516 |
Close
Hashes for npy_patcher-1.0.8-cp36-cp36m-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3cd4b5bf47144fd438f9820402b5b06a9a145a186c14d82a8a16167824a28dd |
|
MD5 | 705f3e7d6aa9b8ad85030de7ad9798be |
|
BLAKE2b-256 | 1600c3d6ee186b6db364e2b67e686cc1f78629b91550ccc273bc97be08922bd3 |
Close
Hashes for npy_patcher-1.0.8-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1596c267e0a1d2d4bde24ef5e91e81385c0c40f89ad9df9296abba8151d23f5d |
|
MD5 | 81cf5099a739a933c3bccde262b107e7 |
|
BLAKE2b-256 | 0605bbd183a252d9ce32057b9ce89c39cb60f70bbf1b4bf1f6abf5fe1bf20a0c |