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

Hugo
Mon, 04 Mar 2024 21:28:33 +0000
General Usage

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?

4 posts - 3 participants

Read full topic