Git Product home page Git Product logo

Comments (2)

cgohlke avatar cgohlke commented on July 30, 2024

The issue seems that the transposed array is F_CONTIGUOUS and bottleneck wrongly uses the first non-zero stride for iteration. This patch fixes this issue for me but I have not tested it thoroughly on Windows:

diff --git a/bottleneck/include/iterators.h b/bottleneck/include/iterators.h
index 1f5120a..c70c46a 100644
--- a/bottleneck/include/iterators.h
+++ b/bottleneck/include/iterators.h
@@ -108,7 +108,7 @@ static inline void init_iter_all(iter *it, PyArrayObject *a, int ravel, int anyo
         for (i = ndim - 1; i > -1; i--) {
             /* protect against length zero  strides such as in
        * np.ones((2, 2))[..., np.newaxis] */
-            if (strides[i] == 0) {
+            if ((strides[i] == 0) || (shape[i] == 1)) {
                 continue;
             }
             it->astride = strides[i];
@@ -122,7 +122,7 @@ static inline void init_iter_all(iter *it, PyArrayObject *a, int ravel, int anyo
             for (i = 0; i < ndim; i++) {
                 /* protect against length zero  strides such as in
          * np.ones((2, 2), order='F')[np.newaxis, ...] */
-                if (strides[i] == 0) {
+                if ((strides[i] == 0) || (shape[i] == 1)) {
                     continue;
                 }
                 it->astride = strides[i];

The shape, strides, and flags of the transposed array are:

(1, 121, 192)

(185856, 8, 968)

  C_CONTIGUOUS : False
  F_CONTIGUOUS : True
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  WRITEBACKIFCOPY : False
  UPDATEIFCOPY : False

from bottleneck.

cgohlke avatar cgohlke commented on July 30, 2024

Probably a duplicate of #381 and fixed by #382.

from bottleneck.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.