arraykit 1.2.1__tar.gz → 1.3.0__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.
- {arraykit-1.2.1/arraykit.egg-info → arraykit-1.3.0}/PKG-INFO +6 -1
- {arraykit-1.2.1 → arraykit-1.3.0}/README.rst +5 -0
- arraykit-1.3.0/VERSION +2 -0
- {arraykit-1.2.1 → arraykit-1.3.0/arraykit.egg-info}/PKG-INFO +6 -1
- {arraykit-1.2.1 → arraykit-1.3.0}/setup.py +1 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/__init__.py +1 -1
- {arraykit-1.2.1 → arraykit-1.3.0}/src/__init__.pyi +1 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/_arraykit.c +1 -1
- {arraykit-1.2.1 → arraykit-1.3.0}/src/methods.c +46 -1
- {arraykit-1.2.1 → arraykit-1.3.0}/src/methods.h +4 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_util.py +19 -0
- arraykit-1.2.1/VERSION +0 -2
- {arraykit-1.2.1 → arraykit-1.3.0}/LICENSE.txt +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/MANIFEST.in +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/arraykit.egg-info/SOURCES.txt +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/arraykit.egg-info/dependency_links.txt +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/arraykit.egg-info/requires.txt +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/arraykit.egg-info/top_level.txt +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/pyproject.toml +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/setup.cfg +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/array_go.c +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/array_go.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/array_to_tuple.c +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/array_to_tuple.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/auto_map.c +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/auto_map.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/block_index.c +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/block_index.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/delimited_to_arrays.c +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/delimited_to_arrays.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/py.typed +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/tri_map.c +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/tri_map.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/src/utilities.h +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_array_go.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_astype_array.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_auto_map.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_auto_map_property.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_block_index.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_delimited_to_arrays.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_delimited_to_arrays_integration.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_delimited_to_arrays_property.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_nonzero_1d.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_nonzero_1d_property.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_objectable.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_pyi.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_split_after_count.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_tri_map.py +0 -0
- {arraykit-1.2.1 → arraykit-1.3.0}/test/test_type_discovery.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: arraykit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Array utilities for StaticFrame
|
|
5
5
|
Author: Christopher Ariza, Brandt Bucher, Charles Burkland
|
|
6
6
|
License-Expression: MIT
|
|
@@ -64,6 +64,11 @@ ArrayKit requires the following:
|
|
|
64
64
|
What is New in ArrayKit
|
|
65
65
|
-------------------------
|
|
66
66
|
|
|
67
|
+
1.3.0
|
|
68
|
+
............
|
|
69
|
+
|
|
70
|
+
Added ``slice_to_unit()``.
|
|
71
|
+
|
|
67
72
|
|
|
68
73
|
1.2.1
|
|
69
74
|
............
|
arraykit-1.3.0/VERSION
ADDED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: arraykit
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: Array utilities for StaticFrame
|
|
5
5
|
Author: Christopher Ariza, Brandt Bucher, Charles Burkland
|
|
6
6
|
License-Expression: MIT
|
|
@@ -64,6 +64,11 @@ ArrayKit requires the following:
|
|
|
64
64
|
What is New in ArrayKit
|
|
65
65
|
-------------------------
|
|
66
66
|
|
|
67
|
+
1.3.0
|
|
68
|
+
............
|
|
69
|
+
|
|
70
|
+
Added ``slice_to_unit()``.
|
|
71
|
+
|
|
67
72
|
|
|
68
73
|
1.2.1
|
|
69
74
|
............
|
|
@@ -28,6 +28,7 @@ from ._arraykit import count_iteration as count_iteration
|
|
|
28
28
|
from ._arraykit import first_true_1d as first_true_1d
|
|
29
29
|
from ._arraykit import first_true_2d as first_true_2d
|
|
30
30
|
from ._arraykit import slice_to_ascending_slice as slice_to_ascending_slice
|
|
31
|
+
from ._arraykit import slice_to_unit as slice_to_unit
|
|
31
32
|
from ._arraykit import array_to_tuple_array as array_to_tuple_array
|
|
32
33
|
from ._arraykit import array_to_tuple_iter as array_to_tuple_iter
|
|
33
34
|
from ._arraykit import nonzero_1d as nonzero_1d
|
|
@@ -37,4 +38,3 @@ from ._arraykit import astype_array as astype_array
|
|
|
37
38
|
from ._arraykit import AutoMap as AutoMap
|
|
38
39
|
from ._arraykit import FrozenAutoMap as FrozenAutoMap
|
|
39
40
|
from ._arraykit import NonUniqueError as NonUniqueError
|
|
40
|
-
|
|
@@ -207,5 +207,6 @@ def is_objectable_dt64(__array: np.ndarray, /) -> bool: ...
|
|
|
207
207
|
def is_objectable(__array: np.ndarray, /) -> bool: ...
|
|
208
208
|
def astype_array(__array: np.ndarray, __dtype: np.dtype | None, /) -> np.ndarray: ...
|
|
209
209
|
def slice_to_ascending_slice(__slice: slice, __size: int) -> slice: ...
|
|
210
|
+
def slice_to_unit(__slice: slice, /) -> int: ...
|
|
210
211
|
def array_to_tuple_array(__array: np.ndarray) -> np.ndarray: ...
|
|
211
212
|
def array_to_tuple_iter(__array: np.ndarray) -> tp.Iterator[tp.Tuple[tp.Any, ...]]: ...
|
|
@@ -22,6 +22,7 @@ static PyMethodDef arraykit_methods[] = {
|
|
|
22
22
|
{"column_1d_filter", column_1d_filter, METH_O, NULL},
|
|
23
23
|
{"row_1d_filter", row_1d_filter, METH_O, NULL},
|
|
24
24
|
{"slice_to_ascending_slice", slice_to_ascending_slice, METH_VARARGS, NULL},
|
|
25
|
+
{"slice_to_unit", slice_to_unit, METH_O, NULL},
|
|
25
26
|
{"array_deepcopy",
|
|
26
27
|
(PyCFunction)array_deepcopy,
|
|
27
28
|
METH_VARARGS | METH_KEYWORDS,
|
|
@@ -157,4 +158,3 @@ PyInit__arraykit(void)
|
|
|
157
158
|
#endif
|
|
158
159
|
return m;
|
|
159
160
|
}
|
|
160
|
-
|
|
@@ -60,10 +60,55 @@ slice_to_ascending_slice(PyObject *Py_UNUSED(m), PyObject *args) {
|
|
|
60
60
|
&PyLong_Type, &size)) {
|
|
61
61
|
return NULL;
|
|
62
62
|
}
|
|
63
|
-
// will delegate NULL on
|
|
63
|
+
// will delegate NULL on error
|
|
64
64
|
return AK_slice_to_ascending_slice(slice, PyLong_AsSsize_t(size));
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
PyObject *
|
|
68
|
+
slice_to_unit(PyObject *Py_UNUSED(m), PyObject *a)
|
|
69
|
+
{
|
|
70
|
+
if (!PySlice_Check(a)) {
|
|
71
|
+
return PyErr_Format(PyExc_TypeError,
|
|
72
|
+
"Expected a slice, not %s",
|
|
73
|
+
Py_TYPE(a)->tp_name);
|
|
74
|
+
}
|
|
75
|
+
PyObject* py_start = ((PySliceObject*)a)->start;
|
|
76
|
+
PyObject* py_stop = ((PySliceObject*)a)->stop;
|
|
77
|
+
PyObject* py_step = ((PySliceObject*)a)->step;
|
|
78
|
+
|
|
79
|
+
if (py_stop == Py_None) {
|
|
80
|
+
return PyLong_FromLong(-1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Py_ssize_t step = 1;
|
|
84
|
+
if (py_step != Py_None) {
|
|
85
|
+
step = PyLong_AsSsize_t(py_step);
|
|
86
|
+
if (step == -1 && PyErr_Occurred()) {
|
|
87
|
+
return NULL;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (step != 1) {
|
|
91
|
+
return PyLong_FromLong(-1);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Py_ssize_t start = 0;
|
|
95
|
+
if (py_start != Py_None) {
|
|
96
|
+
start = PyLong_AsSsize_t(py_start);
|
|
97
|
+
if (start == -1 && PyErr_Occurred()) {
|
|
98
|
+
return NULL;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
Py_ssize_t stop = PyLong_AsSsize_t(py_stop);
|
|
102
|
+
if (stop == -1 && PyErr_Occurred()) {
|
|
103
|
+
return NULL;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (start < 0 || stop < 0 || stop - start != 1) {
|
|
107
|
+
return PyLong_FromLong(-1);
|
|
108
|
+
}
|
|
109
|
+
return PyLong_FromSsize_t(start);
|
|
110
|
+
}
|
|
111
|
+
|
|
67
112
|
PyObject *
|
|
68
113
|
column_2d_filter(PyObject *Py_UNUSED(m), PyObject *a)
|
|
69
114
|
{
|
|
@@ -14,6 +14,10 @@ row_1d_filter(PyObject *Py_UNUSED(m), PyObject *a);
|
|
|
14
14
|
PyObject *
|
|
15
15
|
slice_to_ascending_slice(PyObject *Py_UNUSED(m), PyObject *args);
|
|
16
16
|
|
|
17
|
+
// Return an integer when a slice is exactly a single positive-position unit, else -1.
|
|
18
|
+
PyObject *
|
|
19
|
+
slice_to_unit(PyObject *Py_UNUSED(m), PyObject *a);
|
|
20
|
+
|
|
17
21
|
// Reshape if necessary a flat ndim 1 array into a 2D array with one columns and rows of length.
|
|
18
22
|
// related example: https://github.com/RhysU/ar/blob/master/ar-python.cpp
|
|
19
23
|
PyObject *
|
|
@@ -23,6 +23,7 @@ from arraykit import count_iteration
|
|
|
23
23
|
from arraykit import first_true_1d
|
|
24
24
|
from arraykit import first_true_2d
|
|
25
25
|
from arraykit import slice_to_ascending_slice
|
|
26
|
+
from arraykit import slice_to_unit
|
|
26
27
|
from arraykit import array_to_tuple_array
|
|
27
28
|
from arraykit import array_to_tuple_iter
|
|
28
29
|
|
|
@@ -953,6 +954,24 @@ class TestUnit(unittest.TestCase):
|
|
|
953
954
|
slice(1, 2, None)
|
|
954
955
|
)
|
|
955
956
|
|
|
957
|
+
def test_slice_to_unit_a(self) -> None:
|
|
958
|
+
self.assertEqual(slice_to_unit(slice(3, 4)), 3)
|
|
959
|
+
self.assertEqual(slice_to_unit(slice(0, 1)), 0)
|
|
960
|
+
self.assertEqual(slice_to_unit(slice(None, 1)), 0)
|
|
961
|
+
|
|
962
|
+
def test_slice_to_unit_b(self) -> None:
|
|
963
|
+
self.assertEqual(slice_to_unit(slice(0, 2)), -1)
|
|
964
|
+
self.assertEqual(slice_to_unit(slice(5, 5)), -1)
|
|
965
|
+
self.assertEqual(slice_to_unit(slice(0, 1, 2)), -1)
|
|
966
|
+
self.assertEqual(slice_to_unit(slice(0, 1, -1)), -1)
|
|
967
|
+
self.assertEqual(slice_to_unit(slice(0, None)), -1)
|
|
968
|
+
self.assertEqual(slice_to_unit(slice(None, 2)), -1)
|
|
969
|
+
self.assertEqual(slice_to_unit(slice(-1, 0)), -1)
|
|
970
|
+
|
|
971
|
+
def test_slice_to_unit_c(self) -> None:
|
|
972
|
+
with self.assertRaises(TypeError):
|
|
973
|
+
_ = slice_to_unit(3)
|
|
974
|
+
|
|
956
975
|
|
|
957
976
|
if __name__ == '__main__':
|
|
958
977
|
unittest.main()
|
arraykit-1.2.1/VERSION
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|