# Revisiting dedispersion

**URL:** <https://discourse.julialang.org/t/revisiting-dedispersion/78500>\
**Category:** New to Julia\
**Created:** [March 26, 2022, 4:58am UTC](https://discourse.julialang.org/t/revisiting-dedispersion/78500 "2022-03-26T04:58:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ujjwal\_Panda](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ujjwal_panda/32/34628_2.png) [@Ujjwal\_Panda](https://discourse.julialang.org/u/Ujjwal_Panda)\
**Post date:** [March 26, 2022, 4:58am UTC](https://discourse.julialang.org/t/revisiting-dedispersion/78500/1 "2022-03-26T04:58:21Z")

</div>

Hey folks 😁 ! Last time I asked for some performance tips on a code that was trying to implement the operation of dedispersion in Julia. Unfortunately, that code turned out to be incorrect. The code now up on the repository here: [https://github.com/astrogewgaw/DeDisp.jl](https://github.com/astrogewgaw/DeDisp.jl), implements the algorithm correctly. Therefore, I have no choice but to repeat the question asked last time 😅: what can I do to increase the performance of this code? Any tips?

MWE:

```julia
using DeDisp

A = rand(Int8, 4096, 10000)
B = dd(A, 500.0, 200.0, 81.96e-6, 50.0)

```

PS: Thanks for all the help @jw3126, @goerch and @baggepinnen last time! I am really sorry that you wasted your efforts on what turned out to be wrong code 😓. I am (a bit shamelessly) counting on your help yet again.

---

<div class="post-metadata">

**Author:** ![jw3126](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jw3126/32/3086_2.png) [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Post date:** [March 26, 2022, 5:42am UTC](https://discourse.julialang.org/t/revisiting-dedispersion/78500/2 "2022-03-26T05:42:12Z")

</div>

> I am (a bit shamelessly) counting on your help yet again.

I am happy to help again. However, I think the important lesson here is to really make sure the code is correct before making it fast. So maybe you should add some tests, before trying to speed things up. For instance you could calculate some small examples with another battle tested library and add unit tests, that your method gives approximately the same results.

---

<div class="post-metadata">

**Author:** ![Ujjwal\_Panda](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ujjwal_panda/32/34628_2.png) [@Ujjwal\_Panda](https://discourse.julialang.org/u/Ujjwal_Panda)\
**Post date:** [March 26, 2022, 7:02am UTC](https://discourse.julialang.org/t/revisiting-dedispersion/78500/3 "2022-03-26T07:02:14Z")

</div>

> So maybe you should add some tests

I am looking into that 👍 . The only thing is that testing this package is not trivial, mostly because I am not sure how to verify the test results (expect by eye). The other thing is that other battle-tested libraries are in C and only usable via a command line interface. Maybe I could compare the final outputs from both packages somehow? Anyways, the idea is to have testing and docs ready by the time I get to the `v0.1.0` release.

---

<div class="post-metadata">

**Author:** ![goerch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/goerch/32/29122_2.png) [@goerch](https://discourse.julialang.org/u/goerch)\
**Post date:** [March 26, 2022, 11:26am UTC](https://discourse.julialang.org/t/revisiting-dedispersion/78500/4 "2022-03-26T11:26:25Z")

</div>

> [@Ujjwal\_Panda](#):
>
> ```julia
> using DeDisp
> 
> A = rand(Int8, 4096, 10000)
> B = dd(A, 500.0, 200.0, 81.96e-6, 50.0)
> 
> ```

Trying it results in `ERROR: ArgumentError: invalid Array dimensions` for me. I see `nt′ = -7989`?

---

<div class="post-metadata">

**Author:** ![Ujjwal\_Panda](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ujjwal_panda/32/34628_2.png) [@Ujjwal\_Panda](https://discourse.julialang.org/u/Ujjwal_Panda)\
**Post date:** [March 26, 2022, 3:16pm UTC](https://discourse.julialang.org/t/revisiting-dedispersion/78500/5 "2022-03-26T15:16:44Z")

</div>

Hey @goerch! I could reproduce that on my end as well, which means that you have landed on a bug. I hope to try and solve this today. EDIT: I filed this issue on the GitHub repository myself, no worries 😁 !
