diff --git a/code/numpy/numerical.c b/code/numpy/numerical.c index 76f8c225..9a3ee322 100644 --- a/code/numpy/numerical.c +++ b/code/numpy/numerical.c @@ -546,10 +546,6 @@ static mp_obj_t numerical_argmin_argmax_ndarray(ndarray_obj_t *ndarray, mp_obj_t } m_del(int32_t, strides, ULAB_MAX_DIMS); - - if(results->len == 1) { - return mp_binary_get_val_array(results->dtype, results->array, 0); - } return ulab_tools_restore_dims(ndarray, results, keepdims, _shape_strides); } // we should never get to this point diff --git a/code/ulab.c b/code/ulab.c index f3bba0f4..f80bf620 100644 --- a/code/ulab.c +++ b/code/ulab.c @@ -33,7 +33,7 @@ #include "user/user.h" #include "utils/utils.h" -#define ULAB_VERSION 6.7.2 +#define ULAB_VERSION 6.7.3 #define xstr(s) str(s) #define str(s) #s diff --git a/docs/manual/source/conf.py b/docs/manual/source/conf.py index 8db23fbc..c525ee24 100644 --- a/docs/manual/source/conf.py +++ b/docs/manual/source/conf.py @@ -27,7 +27,7 @@ author = 'Zoltán Vörös' # The full version, including alpha/beta/rc tags -release = '6.7.2' +release = '6.7.3' # -- General configuration --------------------------------------------------- diff --git a/docs/ulab-change-log.md b/docs/ulab-change-log.md index d79b7827..11fd65e6 100644 --- a/docs/ulab-change-log.md +++ b/docs/ulab-change-log.md @@ -1,3 +1,9 @@ +Sun, 26 Jan 2025 + +version 6.7.3 + + fix keepdims for min, max, argmin, argmax + Sun, 19 Jan 2025 version 6.7.2 diff --git a/docs/ulab-convert.ipynb b/docs/ulab-convert.ipynb index c81e0fd3..1c7a8430 100644 --- a/docs/ulab-convert.ipynb +++ b/docs/ulab-convert.ipynb @@ -61,7 +61,7 @@ "author = 'Zoltán Vörös'\n", "\n", "# The full version, including alpha/beta/rc tags\n", - "release = '6.7.2'\n", + "release = '6.7.3'\n", "\n", "\n", "# -- General configuration ---------------------------------------------------\n", @@ -217,7 +217,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2022-02-09T06:27:21.647179Z", @@ -258,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2022-02-09T06:27:42.024028Z", diff --git a/docs/ulab-numerical.ipynb b/docs/ulab-numerical.ipynb index d8a70d89..7be30092 100644 --- a/docs/ulab-numerical.ipynb +++ b/docs/ulab-numerical.ipynb @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2022-01-07T19:16:37.453883Z", @@ -245,115 +245,11 @@ "\n", "**WARNING:** Difference to `numpy`: the `out` keyword argument is not implemented.\n", "\n", - "These functions follow the same pattern, and work with generic iterables, and `ndarray`s. `min`, and `max` return the minimum or maximum of a sequence. If the input array is two-dimensional, the `axis` keyword argument can be supplied, in which case the minimum/maximum along the given axis will be returned. If `axis=None` (this is also the default value), the minimum/maximum of the flattened array will be determined.\n", + "These functions follow the same pattern, and work with generic iterables, and `ndarray`s. `min`, and `max` return the minimum or maximum of a sequence. If the input array is two-dimensional, the `axis` keyword argument can be supplied, in which case the minimum/maximum along the given axis will be returned. If `axis=None` (this is also the default value), the minimum/maximum of the flattened array will be determined. The functions also accept the `keepdims=True` or `keepdims=False` keyword argument. The latter case is the default, while the former keeps the dimensions (the number of axes) of the supplied array. \n", "\n", "`argmin/argmax` return the position (index) of the minimum/maximum in the sequence." ] }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "ExecuteTime": { - "end_time": "2020-10-17T21:26:22.507996Z", - "start_time": "2020-10-17T21:26:22.492543Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "array([1.0, 2.0, 3.0], dtype=float64)\n", - "array([], dtype=float64)\n", - "[] 0\n", - "array([1.0, 2.0, 3.0], dtype=float64)\n", - "array([], dtype=float64)\n", - "\n", - "\n" - ] - } - ], - "source": [ - "%%micropython -unix 1\n", - "\n", - "from ulab import numpy as np\n", - "\n", - "a = np.array([1, 2, 3])\n", - "print(a)\n", - "print(a[-1:-1:-3])\n", - "try:\n", - " sa = list(a[-1:-1:-3])\n", - " la = len(sa)\n", - "except IndexError as e:\n", - " sa = str(e)\n", - " la = -1\n", - " \n", - "print(sa, la)\n", - "\n", - "a[-1:-1:-3] = np.ones(0)\n", - "print(a)\n", - "\n", - "b = np.ones(0) + 1\n", - "print(b)" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "ExecuteTime": { - "end_time": "2020-10-17T21:54:49.123748Z", - "start_time": "2020-10-17T21:54:49.093819Z" - } - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "array([], dtype=float64)\n", - "\n", - "\n" - ] - } - ], - "source": [ - "%%micropython -unix 1\n", - "\n", - "from ulab import numpy as np\n", - "\n", - "a = np.array([1, 2, 3])\n", - "print(a[0:1:-3])" - ] - }, - { - "cell_type": "code", - "execution_count": 81, - "metadata": { - "ExecuteTime": { - "end_time": "2020-10-17T20:59:58.285134Z", - "start_time": "2020-10-17T20:59:58.263605Z" - } - }, - "outputs": [ - { - "data": { - "text/plain": [ - "(0,)" - ] - }, - "execution_count": 81, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "a = np.array([1, 2, 3])\n", - "np.ones(0, dtype=uint8) / np.zeros(0, dtype=uint16)\n", - "np.ones(0).shape" - ] - }, { "cell_type": "code", "execution_count": 10, @@ -400,6 +296,43 @@ "print('min of b (axis=1):', np.min(b, axis=1))" ] }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a: array([[0.0, 1.0, 2.0, 3.0],\n", + " [4.0, 5.0, 6.0, 7.0],\n", + " [8.0, 9.0, 10.0, 11.0]], dtype=float64)\n", + "\n", + "min of a (axis=1):\n", + " array([[0.0],\n", + " [4.0],\n", + " [8.0]], dtype=float64)\n", + "\n", + "min of a (axis=0):\n", + " array([[0.0, 1.0, 2.0, 3.0]], dtype=float64)\n", + "\n", + "\n" + ] + } + ], + "source": [ + "%%micropython -unix 1\n", + "\n", + "from ulab import numpy as np\n", + "\n", + "a = np.array(range(12)).reshape((3, 4))\n", + "\n", + "print('a:', a)\n", + "print('\\nmin of a (axis=1):\\n', np.min(a, axis=1, keepdims=True))\n", + "print('\\nmin of a (axis=0):\\n', np.min(a, axis=0, keepdims=True))" + ] + }, { "cell_type": "markdown", "metadata": {},