Giter Site home page Giter Site logo

Comments (3)

mcabbott avatar mcabbott commented on June 18, 2024

BTW, the quick-and-dirty "fix" is to copy LinearAlgebra and insert this all over the place:

julia> LinearAlgebra.require_one_based_indexing(zeros(3))
true

julia> LinearAlgebra.require_one_based_indexing(zeros(0:2))
ERROR: ArgumentError: offset arrays are not supported but got an array with index other than 1

(Only exists on Julia 1.2 & up, obviously trivial to roll your own.) Of course better to fix things to allow offsets, but not a bad first step to forbid them.

from logexpfunctions.jl.

yurivish avatar yurivish commented on June 18, 2024

Agreed, using Base.require_one_based_indexing would be an improvement over the current state of affairs. It's documented in the devdocs, though as you say only available on Julia 1.2 and up.

What is zeros(0:2)? On Julia 1.5.3 and 1.6 I get an error:

julia> zeros(0:2)
ERROR: MethodError: no method matching zeros(::Type{Float64}, ::Tuple{UnitRange{Int64}})
Closest candidates are:
  zeros(::Type{T}, ::Union{Integer, AbstractUnitRange}...) where T at array.jl:521
  zeros(::Type{T}, ::Tuple{}) where T at array.jl:529
  zeros(::Type{T}, ::Tuple{Vararg{Integer,N}}) where {T, N} at array.jl:524
  ...
Stacktrace:
 [1] zeros(::Tuple{UnitRange{Int64}}) at ./array.jl:522
 [2] zeros(::UnitRange{Int64}) at ./array.jl:520
 [3] top-level scope at REPL[13]:1
``

from logexpfunctions.jl.

andreasnoack avatar andreasnoack commented on June 18, 2024

I think it would be almost as simple to just fix all the loops to loop over the values instead of the indices.

from logexpfunctions.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.