DimensionMismatch("arrays could not be broadcast to a common size; )

I’m trying to write a simple for loop!:
for coef in reacions_to_test
in which “reacions_to_test” is 2582-element Vector{Int64}

but I face this error :

DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 2583 and 2")

1 Like

I don’t think it’s possible to give meaningful help without an MWE that reproduces this. The error is relatively clear I think:

julia> rand(5) .* rand(7)
ERROR: DimensionMismatch("arrays could not be broadcast to a common size; got a dimension with lengths 5 and 7")

but how you manage to get it is impossible to tell without an MWE and a stack trace that gives a line number.

If reacions_to_test is the source of the problem (there is a slightly discrepancy because it has length 2582 but the error message says 2583). Then you are trying to broadcast some operation over it and a two-element container, the other container should either have length 1 or the same size as reacions_to_test.