carpentries-incubator / carpentries-incubator/lesson-parallel-python
Update solutions to Mandelbrot exercise
- Dominant language
- Dockerfile
- Stars
- 11
- Forks
- 15
- Avg merge
- 3m
- Merged PRs (30d)
- 3
Description
The solution posted [here](https://github.com/esciencecenter-digital-skills/parallel-python-workbench/blob/1012b0b92720332b9e2dc33c674b9d1a23c4dea6/episodes/exercise-with-fractals.md?plain=1#L340C55-L340C55) :
```
@guvectorize([(complex128[:, :], int64, int64[:, :])],
"(n,m),()->(n,m)",
nopython=True)
```
uses 2D arrays - complex128[:,:] - while `guvectorize` will turn a function for 1D arrays into a function suitable for 2D arrays when a 2D argument is used in the call.
So the function and its decorator should be written as operating on 1D arrays.
Or written for 2D and use a 3D argument in the call.
See the example from the [Numba documentation](https://numba.pydata.org/numba-doc/dev/user/vectorize.html#the-guvectorize-decorator):
```
The nice thing is that NumPy will automatically dispatch over more complicated inputs, depending on their shapes:
```
Original issue raised by @HannoSpreeuw, https://github.com/esciencecenter-digital-skills/parallel-python-workbench/issues/18
Contributor guide
Assessment
This issue has not been assessed yet.