# Problems with function \`diff()\`: objects of type Int64 are not callable

**URL:** <https://discourse.julialang.org/t/problems-with-function-diff-objects-of-type-int64-are-not-callable/111161>\
**Category:** General Usage\
**Tags:** time-series, diff\
**Created:** [March 4, 2024, 9:28pm UTC](https://discourse.julialang.org/t/problems-with-function-diff-objects-of-type-int64-are-not-callable/111161 "2024-03-04T21:28:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Post date:** [March 4, 2024, 9:28pm UTC](https://discourse.julialang.org/t/problems-with-function-diff-objects-of-type-int64-are-not-callable/111161/1 "2024-03-04T21:28:33Z")

</div>

I am currently working on a series of predictive tests and decided to write a script, `Script A`, to gather a series of different models in one place. This makes the process faster and facilitates the comparison of results.

When I run `Script A`, a `Julia environment` is loaded, data are read from a SQL file, and instructions are followed line by line, as expected. A function called `forecast_with_lstm` is called and is run as expected.

Then I need to use the same code, but reading data from a XLSX file. I made a copy of `Script A` and called it `Script B`, replaced the function `read_data` that reads SQL files with a few lines of codes to read XLSX files. When I ran the code, I noticed an error in the `forecast_with_lstm` function.

All the rest remains the same — the only thing that changed was the way data were read. My intention was to eventually update the `read_data` function to include both data file formats, but I was surprised at the error.

I investigated further and found out that when running `Script B`, inside of `forecast_with_lstm`, the line `training_data = diff(training_data)` returns the following error:

```julia
ERROR: MethodError: objects of type Int64 are not callable
Maybe you forgot to use an operator such as *, ^, %, / etc. ?

```

To test things out, I decided to run all lines from `Script B` before `forecast_with_lstm` and ran the following command.

```julia
arr = [1,2,3]
diff(arr)

```

I got the same error message. However, when I did the very same thing for `Script A`, I got the correct answer:

```julia
2-element Vector{Int64}:
 1
 1

```

Since both scripts load the same packages, I didn’t the problem would be related with package `XLSX.jl`. To be sure, I looked for `diff` in the [package’s webpage](https://felipenoris.github.io/XLSX.jl/stable/search/?q=diff) and didn’t find anything.

Does anyone know what could be happening? Or how I should go about finding the root of the problem?

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [March 4, 2024, 9:30pm UTC](https://discourse.julialang.org/t/problems-with-function-diff-objects-of-type-int64-are-not-callable/111161/2 "2024-03-04T21:30:21Z")

</div>

I suspect somewhere in `Script B` you define a variable `diff=<some int64 value>`, this is shadowing the `diff` function.

---

<div class="post-metadata">

**Author:** ![JonasWickman](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@JonasWickman](https://discourse.julialang.org/u/JonasWickman)\
**Post date:** [March 4, 2024, 9:32pm UTC](https://discourse.julialang.org/t/problems-with-function-diff-objects-of-type-int64-are-not-callable/111161/3 "2024-03-04T21:32:07Z")

</div>

Perhaps you’ve already tried this but my first thought is that you’ve accidentally named a variable `diff` in your `script B`. Try text searching for `diff` in `script B`.

---

<div class="post-metadata">

**Author:** ![Hugo](https://avatars.discourse-cdn.com/v4/letter/h/b38774/32.png) [@Hugo](https://discourse.julialang.org/u/Hugo)\
**Post date:** [March 4, 2024, 11:30pm UTC](https://discourse.julialang.org/t/problems-with-function-diff-objects-of-type-int64-are-not-callable/111161/4 "2024-03-04T23:30:17Z")

</div>

Thank you, @contradict and @JonasWickman. That was exactly what had happened. I add named a variable as `diff` and the error message didn’t immediately make me think of that.
