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

similar: always return a PencilArray #83

Merged
merged 3 commits into from
Jul 14, 2023
Merged

similar: always return a PencilArray #83

merged 3 commits into from
Jul 14, 2023

Conversation

jipolanco
Copy link
Owner

This PR changes the behaviour of similar(u::PencilArray, [T], [dims]) when the dims argument is passed.

First note that we cannot construct a PencilArray which is "similar" to u but having different dimensions, since in that case we would need to generate a new Pencil configuration which is not supported.

For this reason, and to make sure that the return type doesn't depend on the value of dims, calling similar used to return a non-distributed array (most often a regular Array) whenever dims was passed.

Now, we instead make sure that similar always returns a PencilArray. This is in particular needed if one wants to combine PencilArray, StructArrays and DiffEq.jl. So, when dims is passed, we now throw an error if dims is different from the size of u.

This PR changes the behaviour of `similar(u::PencilArray, [T], [dims])`
when the `dims` argument is passed.

First note that we cannot construct a `PencilArray` which is "similar"
to `u` but having different dimensions, since in that case we would need
to generate a new `Pencil` configuration which is not supported.

For this reason, and to make sure that the return type doesn't depend on
the value of `dims`, calling `similar` used to return a non-distributed
array (most often a regular `Array`) whenever `dims` was passed.

Now, we instead make sure that `similar` always returns a `PencilArray`.
This is in particular needed if one wants to combine PencilArray,
StructArrays and DiffEq.jl. So, when `dims` is passed, we now throw an
error if `dims` is different from the size of `u`.
@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2023

Codecov Report

Merging #83 (e46f30a) into master (4bcee2e) will increase coverage by 0.08%.
The diff coverage is 100.00%.

❗ Current head e46f30a differs from pull request most recent head 2cfd8af. Consider uploading reports for the commit 2cfd8af to get more accurate results

@@            Coverage Diff             @@
##           master      #83      +/-   ##
==========================================
+ Coverage   96.67%   96.76%   +0.08%     
==========================================
  Files          24       24              
  Lines        1233     1235       +2     
==========================================
+ Hits         1192     1195       +3     
+ Misses         41       40       -1     
Impacted Files Coverage Δ
src/arrays.jl 94.16% <100.00%> (+0.94%) ⬆️

[skip ci]
@jipolanco jipolanco merged commit a293148 into master Jul 14, 2023
@jipolanco jipolanco deleted the similar_dims branch July 14, 2023 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants