Skip to content

BUG: The input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.F_CONTIGUOUS #27855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AnonymousPlayer2000 opened this issue Nov 26, 2024 · 2 comments
Labels

Comments

@AnonymousPlayer2000
Copy link

AnonymousPlayer2000 commented Nov 26, 2024

Describe the issue:

I find that the input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.F_CONTIGUOUS.

Reproduce the code example:

import numpy as np

a1 = np.array([[[0], [0], [36]], [[1], [-64], [0]], [[-58], [0], [12]], [[-78], [1], [-1]]], order='C')
print("a1.C_CONTIGUOUS:", a1.flags['C_CONTIGUOUS'], "a1.F_CONTIGUOUS:", a1.flags['F_CONTIGUOUS'])
a2 = np.rollaxis(a1, 0, start=2)
print("a2.C_CONTIGUOUS:", a2.flags['C_CONTIGUOUS'], "a2.F_CONTIGUOUS:", a2.flags['F_CONTIGUOUS'])

Error message:

a1.C_CONTIGUOUS: True a1.F_CONTIGUOUS: False
a2.C_CONTIGUOUS: False a2.F_CONTIGUOUS: True

Python and NumPy Versions:

2.1.3
3.10.15 (main, Oct  3 2024, 07:27:34) [GCC 11.2.0]

Runtime Environment:

[{'numpy_version': '2.1.3',
  'python': '3.10.15 (main, Oct  3 2024, 07:27:34) [GCC 11.2.0]',
  'uname': uname_result(system='Linux', release='6.8.0-48-generic', version='#48~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  7 11:24:13 UTC 2', machine='x86_64')},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2'],
                      'not_found': ['AVX512F',
                                    'AVX512CD',
                                    'AVX512_KNL',
                                    'AVX512_KNM',
                                    'AVX512_SKX',
                                    'AVX512_CLX',
                                    'AVX512_CNL',
                                    'AVX512_ICL']}},
 {'architecture': 'Haswell',
  'filepath': '/path/python3.10/site-packages/numpy.libs/libscipy_openblas64_-ff651d7f.so',
  'internal_api': 'openblas',
  'num_threads': 24,
  'prefix': 'libscipy_openblas',
  'threading_layer': 'pthreads',
  'user_api': 'blas',
  'version': '0.3.27'}]

Context for the issue:

I do not find information related to this issue in the doc and can not determine whether this issue is expected or a bug.

@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: reshape returns different array with different order parameter BUG: reshape returns different arrays with different order parameters Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: reshape returns different arrays with different order parameters BUG: reshape returns different arrays with "A"/None Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: reshape returns different arrays with "A"/None BUG: reshape returns different arrays with ("C"/"A") Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: reshape returns different arrays with ("C"/"A") BUG: reshape returns different arrays with (C/A) orders Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: reshape returns different arrays with (C/A) orders BUG: The input and output and rollaxis' has the different orders. Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: The input and output and rollaxis' has the different orders. BUG: The input and output of rollaxis has the different orders. Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: The input and output of rollaxis has the different orders. BUG: The input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.C_CONTIGUOUS. Nov 26, 2024
@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: The input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.C_CONTIGUOUS. BUG: The input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.F_CONTIGUOUS. Nov 26, 2024
@AnonymousPlayer2000
Copy link
Author

I find that the issue is related to the start parameter. When the start is 0 and 1, the input and out's flags.C_CONTIGUOUS and flags.F_CONTIGUOUS are same.

@AnonymousPlayer2000 AnonymousPlayer2000 changed the title BUG: The input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.F_CONTIGUOUS. BUG: The input and output of rollaxis vary in flags.C_CONTIGUOUS and flags.F_CONTIGUOUS Nov 26, 2024
@seberg
Copy link
Member

seberg commented Nov 26, 2024

The behavior is correct, since this always returns a view. (Even otherwise, we don't strictly guarantee preserving this anyway, but often it makes sense to either way.)

@seberg seberg closed this as not planned Won't fix, can't repro, duplicate, stale Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants