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

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:

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.

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:

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 and didn’t find anything.

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

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

1 Like

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.

1 Like

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.