array-split 0.5.2__tar.gz → 0.7.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- array_split-0.7.1/PKG-INFO +257 -0
- {array_split-0.5.2 → array_split-0.7.1}/README.rst +7 -6
- {array_split-0.5.2 → array_split-0.7.1}/array_split/__init__.py +8 -5
- array_split-0.7.1/array_split/_version.py +21 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split/license.py +7 -6
- {array_split-0.5.2 → array_split-0.7.1}/array_split/logging.py +6 -84
- {array_split-0.5.2 → array_split-0.7.1}/array_split/split.py +94 -104
- array_split-0.7.1/array_split/split_plot.py +41 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split/split_test.py +19 -13
- {array_split-0.5.2 → array_split-0.7.1}/array_split/tests.py +8 -11
- array_split-0.7.1/array_split/unittest.py +184 -0
- array_split-0.7.1/array_split.egg-info/PKG-INFO +257 -0
- array_split-0.7.1/array_split.egg-info/SOURCES.txt +22 -0
- array_split-0.7.1/array_split.egg-info/not-zip-safe +1 -0
- array_split-0.7.1/pyproject.toml +55 -0
- {array_split-0.5.2 → array_split-0.7.1}/setup.cfg +1 -1
- array_split-0.7.1/setup.py +14 -0
- array_split-0.5.2/.appveyor.yml +0 -54
- array_split-0.5.2/.gitignore +0 -8
- array_split-0.5.2/.pylintrc +0 -425
- array_split-0.5.2/.travis.yml +0 -59
- array_split-0.5.2/CONTRIBUTING.rst +0 -84
- array_split-0.5.2/PKG-INFO +0 -147
- array_split-0.5.2/array_split/git_describe.txt +0 -1
- array_split-0.5.2/array_split/unittest.py +0 -352
- array_split-0.5.2/array_split/version.txt +0 -1
- array_split-0.5.2/array_split.egg-info/PKG-INFO +0 -147
- array_split-0.5.2/array_split.egg-info/SOURCES.txt +0 -43
- array_split-0.5.2/docs/joss/codemeta.json +0 -23
- array_split-0.5.2/docs/joss/paper.bib +0 -82
- array_split-0.5.2/docs/joss/paper.md +0 -51
- array_split-0.5.2/docs/source/_templates/autosummary/class.rst +0 -32
- array_split-0.5.2/docs/source/_templates/autosummary/inherits_TestCase_class.rst +0 -32
- array_split-0.5.2/docs/source/about/index.rst +0 -7
- array_split-0.5.2/docs/source/conf.py +0 -422
- array_split-0.5.2/docs/source/contributing/index.rst +0 -4
- array_split-0.5.2/docs/source/examples/index.rst +0 -622
- array_split-0.5.2/docs/source/index.rst +0 -39
- array_split-0.5.2/docs/source/reference/array_split.rst +0 -1
- array_split-0.5.2/docs/source/reference/array_split_license.rst +0 -1
- array_split-0.5.2/docs/source/reference/array_split_logging.rst +0 -1
- array_split-0.5.2/docs/source/reference/array_split_split.rst +0 -1
- array_split-0.5.2/docs/source/reference/array_split_split_test.rst +0 -1
- array_split-0.5.2/docs/source/reference/array_split_tests.rst +0 -1
- array_split-0.5.2/docs/source/reference/array_split_unittest.rst +0 -1
- array_split-0.5.2/docs/source/reference/index.rst +0 -13
- array_split-0.5.2/setup.py +0 -166
- {array_split-0.5.2 → array_split-0.7.1}/LICENSE.txt +0 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split/copyright.txt +0 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split/license.txt +0 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split.egg-info/dependency_links.txt +0 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split.egg-info/requires.txt +0 -0
- {array_split-0.5.2 → array_split-0.7.1}/array_split.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: array_split
|
|
3
|
+
Version: 0.7.1
|
|
4
|
+
Summary: The array_split python package is an enhancement to existing numpy.ndarray functions (such as numpy.array_split) which sub-divide a multi-dimensional array into a number of multi-dimensional sub-arrays (slices)
|
|
5
|
+
Author-email: Shane-J-Latham <array.split@gmail.com>, array-split <array.split@gmail.com>
|
|
6
|
+
License: Copyright (C) 2017 The Australian National University.
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
|
9
|
+
software and associated documentation files (the "Software"), to deal in the Software
|
|
10
|
+
without restriction, including without limitation the rights to use, copy, modify, merge,
|
|
11
|
+
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
|
12
|
+
to whom the Software is furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
15
|
+
substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
18
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
20
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Project-URL: Homepage, https://github.com/array-split/array_split
|
|
24
|
+
Project-URL: Documentation, https://array-split.readthedocs.io/en/latest/
|
|
25
|
+
Project-URL: Repository, https://github.com/array-split/array_split
|
|
26
|
+
Project-URL: Issues, https://github.com/array-split/array_split/issues
|
|
27
|
+
Keywords: multi-dimensional-array,array,sub-array,tile,tiling,splitting,split,partition,partitioning,scipy,numpy,ndarray,domain-decomposition,array-decomposition
|
|
28
|
+
Classifier: Programming Language :: Python :: 3
|
|
29
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
30
|
+
Classifier: Operating System :: OS Independent
|
|
31
|
+
Requires-Python: >=3.8
|
|
32
|
+
Description-Content-Type: text/x-rst
|
|
33
|
+
License-File: LICENSE.txt
|
|
34
|
+
Requires-Dist: numpy>=1.6
|
|
35
|
+
Dynamic: license-file
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
=============
|
|
39
|
+
`array_split`
|
|
40
|
+
=============
|
|
41
|
+
|
|
42
|
+
.. Start of sphinx doc include.
|
|
43
|
+
.. start long description.
|
|
44
|
+
.. start badges.
|
|
45
|
+
|
|
46
|
+
.. image:: https://img.shields.io/pypi/v/array_split.svg
|
|
47
|
+
:target: https://pypi.python.org/pypi/array_split/
|
|
48
|
+
:alt: array_split python package
|
|
49
|
+
.. image:: https://github.com/array-split/array_split/actions/workflows/python-test.yml/badge.svg
|
|
50
|
+
:target: https://github.com/array-split/array_split/actions/workflows/python-test.yml
|
|
51
|
+
:alt: array_split python package
|
|
52
|
+
.. image:: https://readthedocs.org/projects/array-split/badge/?version=stable
|
|
53
|
+
:target: http://array-split.readthedocs.io/en/stable
|
|
54
|
+
:alt: Documentation Status
|
|
55
|
+
.. image:: https://coveralls.io/repos/github/array-split/array_split/badge.svg
|
|
56
|
+
:target: https://coveralls.io/github/array-split/array_split
|
|
57
|
+
:alt: Coveralls Status
|
|
58
|
+
.. image:: https://img.shields.io/pypi/l/array_split.svg
|
|
59
|
+
:target: https://pypi.python.org/pypi/array_split/
|
|
60
|
+
:alt: MIT License
|
|
61
|
+
.. image:: https://img.shields.io/pypi/pyversions/array_split.svg
|
|
62
|
+
:target: https://pypi.python.org/pypi/array_split/
|
|
63
|
+
:alt: array_split python package
|
|
64
|
+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.889078.svg
|
|
65
|
+
:target: https://doi.org/10.5281/zenodo.889078
|
|
66
|
+
.. image:: http://joss.theoj.org/papers/10.21105/joss.00373/status.svg
|
|
67
|
+
:target: http://joss.theoj.org/papers/4b59c7430176ef78c80c6a1100031eb6
|
|
68
|
+
|
|
69
|
+
.. end badges.
|
|
70
|
+
|
|
71
|
+
The `array_split <http://array-split.readthedocs.io/en/latest>`_ python package is
|
|
72
|
+
an enhancement to existing
|
|
73
|
+
`numpy.ndarray <http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html>`_ functions,
|
|
74
|
+
such as
|
|
75
|
+
`numpy.array_split <http://docs.scipy.org/doc/numpy/reference/generated/numpy.array_split.html>`_,
|
|
76
|
+
`skimage.util.view_as_blocks <http://scikit-image.org/docs/0.13.x/api/skimage.util.html#view-as-blocks>`_
|
|
77
|
+
and
|
|
78
|
+
`skimage.util.view_as_windows <http://scikit-image.org/docs/0.13.x/api/skimage.util.html#view-as-windows>`_,
|
|
79
|
+
which sub-divide a multi-dimensional array into a number of multi-dimensional sub-arrays (slices).
|
|
80
|
+
Example application areas include:
|
|
81
|
+
|
|
82
|
+
**Parallel Processing**
|
|
83
|
+
A large (dense) array is partitioned into smaller sub-arrays which can be
|
|
84
|
+
processed concurrently by multiple processes
|
|
85
|
+
(`multiprocessing <https://docs.python.org/3/library/multiprocessing.html>`_
|
|
86
|
+
or `mpi4py <http://pythonhosted.org/mpi4py/>`_) or other memory-limited hardware
|
|
87
|
+
(e.g. GPGPU using `pyopencl <https://mathema.tician.de/software/pyopencl/>`_,
|
|
88
|
+
`pycuda <https://mathema.tician.de/software/pycuda/>`_, etc).
|
|
89
|
+
For GPGPU, it is necessary for sub-array not to exceed the GPU memory and
|
|
90
|
+
desirable for the sub-array shape to be a multiple of the *work-group*
|
|
91
|
+
(`OpenCL <https://en.wikipedia.org/wiki/OpenCL>`_)
|
|
92
|
+
or *thread-block* (`CUDA <https://en.wikipedia.org/wiki/CUDA>`_) size.
|
|
93
|
+
|
|
94
|
+
**File I/O**
|
|
95
|
+
A large (dense) array is partitioned into smaller sub-arrays which can be
|
|
96
|
+
written to individual files
|
|
97
|
+
(as, for example, a
|
|
98
|
+
`HDF5 Virtual Dataset <https://support.hdfgroup.org/HDF5/docNewFeatures/NewFeaturesVirtualDatasetDocs.html>`_).
|
|
99
|
+
It is often desirable for the individual files not to exceed a specified number
|
|
100
|
+
of (Giga) bytes and, for `HDF5 <https://support.hdfgroup.org/HDF5/>`_, it is desirable
|
|
101
|
+
to have the individual file sub-array shape a multiple of
|
|
102
|
+
the `chunk shape <https://support.hdfgroup.org/HDF5/doc1.8/Advanced/Chunking/index.html>`_.
|
|
103
|
+
Similarly, `out of core <https://en.wikipedia.org/wiki/Out-of-core_algorithm>`_
|
|
104
|
+
algorithms for large dense arrays often involve processing the entire data-set as
|
|
105
|
+
a series of *in-core* sub-arrays. Again, it is desirable for the individual sub-array shape
|
|
106
|
+
to be a multiple of the
|
|
107
|
+
`chunk shape <https://support.hdfgroup.org/HDF5/doc1.8/Advanced/Chunking/index.html>`_.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
The `array_split <http://array-split.readthedocs.io/en/latest>`_ package provides the
|
|
111
|
+
means to partition an array (or array shape) using any of the following criteria:
|
|
112
|
+
|
|
113
|
+
- Per-axis indices indicating the *cut* positions.
|
|
114
|
+
- Per-axis number of sub-arrays.
|
|
115
|
+
- Total number of sub-arrays (with optional per-axis *number of sections* constraints).
|
|
116
|
+
- Specific sub-array shape.
|
|
117
|
+
- Specification of *halo* (*ghost*) elements for sub-arrays.
|
|
118
|
+
- Arbitrary *start index* for the shape to be partitioned.
|
|
119
|
+
- Maximum number of bytes for a sub-array with constraints:
|
|
120
|
+
|
|
121
|
+
- sub-arrays are an even multiple of a specified sub-tile shape
|
|
122
|
+
- upper limit on the per-axis sub-array shape
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
Quick Start Example
|
|
126
|
+
===================
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
>>> from array_split import array_split, shape_split
|
|
130
|
+
>>> import numpy as np
|
|
131
|
+
>>>
|
|
132
|
+
>>> ary = np.arange(0, 4*9)
|
|
133
|
+
>>>
|
|
134
|
+
>>> array_split(ary, 4) # 1D split into 4 sections (like numpy.array_split)
|
|
135
|
+
[array([0, 1, 2, 3, 4, 5, 6, 7, 8]),
|
|
136
|
+
array([ 9, 10, 11, 12, 13, 14, 15, 16, 17]),
|
|
137
|
+
array([18, 19, 20, 21, 22, 23, 24, 25, 26]),
|
|
138
|
+
array([27, 28, 29, 30, 31, 32, 33, 34, 35])]
|
|
139
|
+
>>>
|
|
140
|
+
>>> shape_split(ary.shape, 4) # 1D split into 4 parts, returns slice objects
|
|
141
|
+
array([(slice(0, 9, None),), (slice(9, 18, None),), (slice(18, 27, None),), (slice(27, 36, None),)],
|
|
142
|
+
dtype=[('0', 'O')])
|
|
143
|
+
>>>
|
|
144
|
+
>>> ary = ary.reshape(4, 9) # Make ary 2D
|
|
145
|
+
>>> split = shape_split(ary.shape, axis=(2, 3)) # 2D split into 2*3=6 sections
|
|
146
|
+
>>> split.shape
|
|
147
|
+
(2, 3)
|
|
148
|
+
>>> split
|
|
149
|
+
array([[(slice(0, 2, None), slice(0, 3, None)),
|
|
150
|
+
(slice(0, 2, None), slice(3, 6, None)),
|
|
151
|
+
(slice(0, 2, None), slice(6, 9, None))],
|
|
152
|
+
[(slice(2, 4, None), slice(0, 3, None)),
|
|
153
|
+
(slice(2, 4, None), slice(3, 6, None)),
|
|
154
|
+
(slice(2, 4, None), slice(6, 9, None))]],
|
|
155
|
+
dtype=[('0', 'O'), ('1', 'O')])
|
|
156
|
+
>>> sub_arys = [ary[tup] for tup in split.flatten()] # Create sub-array views from slice tuples.
|
|
157
|
+
>>> sub_arys
|
|
158
|
+
[array([[ 0, 1, 2], [ 9, 10, 11]]),
|
|
159
|
+
array([[ 3, 4, 5], [12, 13, 14]]),
|
|
160
|
+
array([[ 6, 7, 8], [15, 16, 17]]),
|
|
161
|
+
array([[18, 19, 20], [27, 28, 29]]),
|
|
162
|
+
array([[21, 22, 23], [30, 31, 32]]),
|
|
163
|
+
array([[24, 25, 26], [33, 34, 35]])]
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
Latest sphinx documentation (including more examples)
|
|
167
|
+
at http://array-split.readthedocs.io/en/latest/.
|
|
168
|
+
|
|
169
|
+
.. end long description.
|
|
170
|
+
|
|
171
|
+
Installation
|
|
172
|
+
============
|
|
173
|
+
|
|
174
|
+
Using ``pip`` (root access required):
|
|
175
|
+
|
|
176
|
+
``pip install array_split``
|
|
177
|
+
|
|
178
|
+
or local user install (no root access required):
|
|
179
|
+
|
|
180
|
+
``pip install --user array_split``
|
|
181
|
+
|
|
182
|
+
or local user install from latest github source:
|
|
183
|
+
|
|
184
|
+
``pip install --user git+git://github.com/array-split/array_split.git#egg=array_split``
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
Requirements
|
|
188
|
+
============
|
|
189
|
+
|
|
190
|
+
Requires `numpy <http://docs.scipy.org/doc/numpy/>`_ version `>= 1.6`,
|
|
191
|
+
python-2 version `>= 2.6` or python-3 version `>= 3.2`.
|
|
192
|
+
|
|
193
|
+
Testing
|
|
194
|
+
=======
|
|
195
|
+
|
|
196
|
+
Run tests (unit-tests and doctest module docstring tests) using::
|
|
197
|
+
|
|
198
|
+
python -m array_split.tests
|
|
199
|
+
|
|
200
|
+
or, from the source tree, run::
|
|
201
|
+
|
|
202
|
+
python setup.py test
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
Travis CI at:
|
|
206
|
+
|
|
207
|
+
https://travis-ci.org/array-split/array_split/
|
|
208
|
+
|
|
209
|
+
and AppVeyor at:
|
|
210
|
+
|
|
211
|
+
https://ci.appveyor.com/project/array-split/array-split
|
|
212
|
+
|
|
213
|
+
Documentation
|
|
214
|
+
=============
|
|
215
|
+
|
|
216
|
+
Latest sphinx generated documentation is at:
|
|
217
|
+
|
|
218
|
+
http://array-split.readthedocs.io/en/latest
|
|
219
|
+
|
|
220
|
+
and at github *gh-pages*:
|
|
221
|
+
|
|
222
|
+
https://array-split.github.io/array_split/
|
|
223
|
+
|
|
224
|
+
Sphinx documentation can be built from the source::
|
|
225
|
+
|
|
226
|
+
python setup.py build_sphinx
|
|
227
|
+
|
|
228
|
+
with the HTML generated in ``docs/_build/html``.
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
Latest source code
|
|
232
|
+
==================
|
|
233
|
+
|
|
234
|
+
Source at github:
|
|
235
|
+
|
|
236
|
+
https://github.com/array-split/array_split
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
Bug Reports
|
|
240
|
+
===========
|
|
241
|
+
|
|
242
|
+
To search for bugs or report them, please use the bug tracker at:
|
|
243
|
+
|
|
244
|
+
https://github.com/array-split/array_split/issues
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
Contributing
|
|
248
|
+
============
|
|
249
|
+
|
|
250
|
+
Check out the `CONTRIBUTING doc <https://github.com/array-split/array_split/blob/dev/CONTRIBUTING.rst>`_.
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
License information
|
|
254
|
+
===================
|
|
255
|
+
|
|
256
|
+
See the file `LICENSE.txt <https://github.com/array-split/array_split/blob/dev/LICENSE.txt>`_
|
|
257
|
+
for terms & conditions, for usage and a DISCLAIMER OF ALL WARRANTIES.
|
|
@@ -10,12 +10,9 @@
|
|
|
10
10
|
.. image:: https://img.shields.io/pypi/v/array_split.svg
|
|
11
11
|
:target: https://pypi.python.org/pypi/array_split/
|
|
12
12
|
:alt: array_split python package
|
|
13
|
-
.. image:: https://
|
|
14
|
-
:target: https://
|
|
15
|
-
:alt:
|
|
16
|
-
.. image:: https://ci.appveyor.com/api/projects/status/oprsw5rfr07m77o0?svg=true
|
|
17
|
-
:target: https://ci.appveyor.com/project/array-split/array-split
|
|
18
|
-
:alt: AppVeyor Status
|
|
13
|
+
.. image:: https://github.com/array-split/array_split/actions/workflows/python-test.yml/badge.svg
|
|
14
|
+
:target: https://github.com/array-split/array_split/actions/workflows/python-test.yml
|
|
15
|
+
:alt: array_split python package
|
|
19
16
|
.. image:: https://readthedocs.org/projects/array-split/badge/?version=stable
|
|
20
17
|
:target: http://array-split.readthedocs.io/en/stable
|
|
21
18
|
:alt: Documentation Status
|
|
@@ -28,6 +25,10 @@
|
|
|
28
25
|
.. image:: https://img.shields.io/pypi/pyversions/array_split.svg
|
|
29
26
|
:target: https://pypi.python.org/pypi/array_split/
|
|
30
27
|
:alt: array_split python package
|
|
28
|
+
.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.889078.svg
|
|
29
|
+
:target: https://doi.org/10.5281/zenodo.889078
|
|
30
|
+
.. image:: http://joss.theoj.org/papers/10.21105/joss.00373/status.svg
|
|
31
|
+
:target: http://joss.theoj.org/papers/4b59c7430176ef78c80c6a1100031eb6
|
|
31
32
|
|
|
32
33
|
.. end badges.
|
|
33
34
|
|
|
@@ -60,15 +60,18 @@ Attributes
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
"""
|
|
63
|
-
|
|
64
|
-
from .
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
|
|
64
|
+
from . import (
|
|
65
|
+
_version,
|
|
66
|
+
split,
|
|
67
|
+
)
|
|
68
|
+
from .license import copyright as _copyright, license as _license
|
|
69
|
+
from .split import ShapeSplitter, array_split, shape_split # noqa: F401
|
|
67
70
|
|
|
68
71
|
__author__ = "Shane J. Latham"
|
|
69
72
|
__license__ = _license()
|
|
70
73
|
__copyright__ = _copyright()
|
|
71
|
-
__version__ = _version()
|
|
74
|
+
__version__ = _version.get_versions()['version']
|
|
72
75
|
|
|
73
76
|
|
|
74
77
|
#: See :data:`array_split.split.ARRAY_BOUNDS`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
# This file was generated by 'versioneer.py' (0.29) from
|
|
3
|
+
# revision-control system data, or from the parent directory name of an
|
|
4
|
+
# unpacked source archive. Distribution tarballs contain a pre-generated copy
|
|
5
|
+
# of this file.
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
|
|
9
|
+
version_json = '''
|
|
10
|
+
{
|
|
11
|
+
"date": "2026-10-10T18:49:13+1100",
|
|
12
|
+
"dirty": false,
|
|
13
|
+
"error": null,
|
|
14
|
+
"full-revisionid": "c83a57c07a2873a72c451ec55c9088f6938cbe87",
|
|
15
|
+
"version": "0.7.1"
|
|
16
|
+
}
|
|
17
|
+
''' # END VERSION_JSON
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_versions():
|
|
21
|
+
return json.loads(version_json)
|
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
To be replaced.
|
|
3
3
|
"""
|
|
4
4
|
# pylint: disable=redefined-builtin
|
|
5
|
-
from
|
|
6
|
-
import pkg_resources as _pkg_resources
|
|
5
|
+
from importlib.resources import files
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
from . import _version
|
|
8
|
+
|
|
9
|
+
__copyright__ = files("array_split").joinpath("copyright.txt").read_bytes().decode()
|
|
9
10
|
__license__ = (
|
|
10
11
|
__copyright__
|
|
11
12
|
+
|
|
12
13
|
"\n\n"
|
|
13
14
|
+
|
|
14
|
-
|
|
15
|
+
files("array_split").joinpath("license.txt").read_bytes().decode()
|
|
15
16
|
)
|
|
16
17
|
__author__ = "Shane J. Latham"
|
|
17
|
-
__version__ =
|
|
18
|
+
__version__ = _version.get_versions()['version']
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def version():
|
|
@@ -77,6 +78,6 @@ Functions
|
|
|
77
78
|
copyright - Returns :mod:`array_split` copyright string.
|
|
78
79
|
version - Returns :mod:`array_split` version string.
|
|
79
80
|
|
|
80
|
-
""" % (license(), copyright())
|
|
81
|
+
""" % (license(), copyright()) # noqa: UP031
|
|
81
82
|
|
|
82
83
|
__all__ = [s for s in dir() if not s.startswith('_')]
|
|
@@ -26,12 +26,11 @@ Classes and Functions
|
|
|
26
26
|
# pylint: disable=wildcard-import
|
|
27
27
|
# pylint: disable=invalid-name
|
|
28
28
|
|
|
29
|
-
from __future__ import absolute_import
|
|
30
|
-
|
|
31
|
-
import sys
|
|
32
29
|
import logging as _builtin_logging
|
|
33
|
-
|
|
34
|
-
from
|
|
30
|
+
import sys
|
|
31
|
+
from logging import *
|
|
32
|
+
|
|
33
|
+
from .license import copyright as _copyright, license as _license, version as _version
|
|
35
34
|
|
|
36
35
|
__author__ = "Shane J. Latham"
|
|
37
36
|
__license__ = _license()
|
|
@@ -39,66 +38,7 @@ __copyright__ = _copyright()
|
|
|
39
38
|
__version__ = _version()
|
|
40
39
|
|
|
41
40
|
|
|
42
|
-
class
|
|
43
|
-
|
|
44
|
-
"""
|
|
45
|
-
A python :obj:`logging.handlers` :samp:`Handler` class for
|
|
46
|
-
splitting logging messages to different streams depending on
|
|
47
|
-
the logging-level.
|
|
48
|
-
"""
|
|
49
|
-
|
|
50
|
-
def __init__(self, outstr=sys.stdout, errstr=sys.stderr, splitlevel=_builtin_logging.WARNING):
|
|
51
|
-
"""
|
|
52
|
-
Initialise with a pair of streams and a threshold level which determines
|
|
53
|
-
the stream where the messages are writting.
|
|
54
|
-
|
|
55
|
-
:type outstr: file-like
|
|
56
|
-
:param outstr: Logging messages are written to this stream if
|
|
57
|
-
the message level is less than :samp:`self.splitLevel`.
|
|
58
|
-
:type errstr: stream
|
|
59
|
-
:param errstr: Logging messages are written to this stream if
|
|
60
|
-
the message level is greater-than-or-equal-to :samp:`self.splitLevel`.
|
|
61
|
-
:type splitlevel: int
|
|
62
|
-
:param splitlevel: Logging level threshold determining split streams for log messages.
|
|
63
|
-
"""
|
|
64
|
-
self.outStream = outstr
|
|
65
|
-
self.errStream = errstr
|
|
66
|
-
self.splitLevel = splitlevel
|
|
67
|
-
_builtin_logging.Handler.__init__(self)
|
|
68
|
-
|
|
69
|
-
def emit(self, record):
|
|
70
|
-
"""
|
|
71
|
-
Mostly copy-paste from :obj:`logging.StreamHandler`.
|
|
72
|
-
"""
|
|
73
|
-
try:
|
|
74
|
-
msg = self.format(record)
|
|
75
|
-
if record.levelno < self.splitLevel:
|
|
76
|
-
stream = self.outStream
|
|
77
|
-
else:
|
|
78
|
-
stream = self.errStream
|
|
79
|
-
fs = "%s\n"
|
|
80
|
-
|
|
81
|
-
try:
|
|
82
|
-
if (isinstance(msg, unicode) and # noqa: F405
|
|
83
|
-
getattr(stream, 'encoding', None)):
|
|
84
|
-
ufs = fs.decode(stream.encoding)
|
|
85
|
-
try:
|
|
86
|
-
stream.write(ufs % msg)
|
|
87
|
-
except UnicodeEncodeError:
|
|
88
|
-
stream.write((ufs % msg).encode(stream.encoding))
|
|
89
|
-
else:
|
|
90
|
-
stream.write(fs % msg)
|
|
91
|
-
except UnicodeError:
|
|
92
|
-
stream.write(fs % msg.encode("UTF-8"))
|
|
93
|
-
|
|
94
|
-
stream.flush()
|
|
95
|
-
except (KeyboardInterrupt, SystemExit):
|
|
96
|
-
raise
|
|
97
|
-
except:
|
|
98
|
-
self.handleError(record)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class _Python3SplitStreamHandler(_builtin_logging.Handler):
|
|
41
|
+
class SplitStreamHandler(_builtin_logging.Handler):
|
|
102
42
|
|
|
103
43
|
"""
|
|
104
44
|
A python :obj:`logging.handlers` :samp:`Handler` class for
|
|
@@ -162,28 +102,10 @@ class _Python3SplitStreamHandler(_builtin_logging.Handler):
|
|
|
162
102
|
self.flush()
|
|
163
103
|
except (KeyboardInterrupt, SystemExit): # pragma: no cover
|
|
164
104
|
raise
|
|
165
|
-
except:
|
|
105
|
+
except Exception: # noqa: BLE001
|
|
166
106
|
self.handleError(record)
|
|
167
107
|
|
|
168
108
|
|
|
169
|
-
if sys.version_info[0] <= 2:
|
|
170
|
-
class SplitStreamHandler(_Python2SplitStreamHandler):
|
|
171
|
-
|
|
172
|
-
"""
|
|
173
|
-
To be replaced.
|
|
174
|
-
"""
|
|
175
|
-
|
|
176
|
-
__doc__ = _Python2SplitStreamHandler.__doc__
|
|
177
|
-
else:
|
|
178
|
-
class SplitStreamHandler(_Python3SplitStreamHandler):
|
|
179
|
-
|
|
180
|
-
"""
|
|
181
|
-
To be replaced.
|
|
182
|
-
"""
|
|
183
|
-
|
|
184
|
-
__doc__ = _Python3SplitStreamHandler.__doc__
|
|
185
|
-
|
|
186
|
-
|
|
187
109
|
def get_formatter(prefix_string="ARRSPLT| "):
|
|
188
110
|
"""
|
|
189
111
|
Returns :obj:`logging.Formatter` object which produces messages
|