Skip to content
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

Copy of a fortran array uses unnecessary transpose #1257

Closed
EmilyBourne opened this issue Dec 14, 2022 · 3 comments · Fixed by #1256
Closed

Copy of a fortran array uses unnecessary transpose #1257

EmilyBourne opened this issue Dec 14, 2022 · 3 comments · Fixed by #1256
Labels
blocked Cannot be solved/merged until something else is fixed bug Language:Fortran

Comments

@EmilyBourne
Copy link
Member

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

Provide code to reproduce the behavior:

    a = np.array([[1,  2,  4,  8, 16],
             [1,  2,  4,  8, 16],
             [1,  2,  4,  8, 16],
             [1,  2,  4,  8, 16],
             [1,  2,  4,  8, 16]], order="F")
    b = np.array(a, order="F")

Error details

Provide the generated code, or the error message:

    allocate(a(0:4_i64, 0:4_i64))
    a = transpose(reshape([[1_i64, 2_i64, 4_i64, 8_i64, 16_i64], [1_i64, &
          2_i64, 4_i64, 8_i64, 16_i64], [1_i64, 2_i64, 4_i64, 8_i64, &
          16_i64], [1_i64, 2_i64, 4_i64, 8_i64, 16_i64], [1_i64, 2_i64, &
          4_i64, 8_i64, 16_i64]], [5_i64, 5_i64]))
    allocate(b(0:4_i64, 0:4_i64))
    b = transpose(a)

Expected behavior

a should not be transposed to create b

Language

Fortran

Additional context

Identified in PR #1256

@EmilyBourne EmilyBourne added bug Language:Fortran blocked Cannot be solved/merged until something else is fixed labels Dec 14, 2022
@EmilyBourne
Copy link
Member Author

EmilyBourne commented Dec 14, 2022

Blocked by #1128

@EmilyBourne
Copy link
Member Author

Blocked by #1258 as tests can't be added

@EmilyBourne
Copy link
Member Author

Duplicate of #1241

@EmilyBourne EmilyBourne marked this as a duplicate of #1241 Aug 15, 2023
@EmilyBourne EmilyBourne linked a pull request Aug 15, 2023 that will close this issue
yguclu added a commit that referenced this issue Aug 25, 2023
- Ensure `np.array` can be called with one variable argument (previously
this caused an infinite loop over the elements of the array).
- Simplify `_print_NumpyArray` to reduce duplication and fix #1241 and
fix duplicate #1257.
- Improve `np.array` implementation to correct the default order and add
the `ndmin` parameter.
- Add tests for new code.
- Clean up `test_arrays.py` so failures reference the relevant issue,
tuples use `==` instead of `np.array_equal`, and a more comprehensive
check is carried out on returned arrays including checking the datatype
and ordering.

---------

Co-authored-by: EmilyBourne <louise.bourne@gmail.com>
Co-authored-by: Yaman Güçlü <yaman.guclu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Cannot be solved/merged until something else is fixed bug Language:Fortran
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant