jipolanco / PencilArrays.jl

Distributed Julia arrays using the MPI protocol
https://jipolanco.github.io/PencilArrays.jl/dev/
MIT License
60 stars 8 forks source link

`similar`: always return a `PencilArray` #83

Closed jipolanco closed 1 year ago

jipolanco commented 1 year ago

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 commented 1 year ago

Codecov Report

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

:exclamation: 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%) :arrow_up: