Giter Club home page Giter Club logo

structuredgrids.jl's Introduction

Build Status codecov

StructuredGrids.jl

Tiny package for lazy structured grids:

julia> using StructuredGrids

julia> g = grid(-2:2, 1:3)
5×3 StructuredGrid.Grid{Tuple{Int64,Int64},2,Tuple{UnitRange{Int64},UnitRange{Int64}}}:
 (-2, 1)  (-2, 2)  (-2, 3)
 (-1, 1)  (-1, 2)  (-1, 3)
 (0, 1)   (0, 2)   (0, 3) 
 (1, 1)   (1, 2)   (1, 3) 
 (2, 1)   (2, 2)   (2, 3)
 
 julia> g[2,2]
 (-1, 2)

It's more or less the same as Iterators.product(-2:2, 1:3), but it allows indexing as well and subtypes AbstractArray.

structuredgrids.jl's People

Contributors

haampie avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

mingtaoli

structuredgrids.jl's Issues

Failure on edge cases

Hi there, someone pointed out this package to me when I tried to solve the same problem resulting in ProductArrays currently in the registering process. It might make sense to stop its publishing now, but I also noticed that you did not cover a few edge cases making the behavior of StructuredGrid not quite the same as the collected product.Iterator. This is something ProductArray promises (I would count any failure to do so as a bug). Here are the edge cases:

julia> grid([1 2; 3 4], [:a, :b])
2×2 StructuredGrids.Grid{Tuple{Int64, Symbol}, 2, Tuple{Matrix{Int64}, Vector{Symbol}}}:
 (1, :a)  (1, :b)
 (3, :a)  (3, :b)

julia> Iterators.product([1 2; 3 4], [:a, :b]) |> collect
2×2×2 Array{Tuple{Int64, Symbol}, 3}:
[:, :, 1] =
 (1, :a)  (2, :a)
 (3, :a)  (4, :a)

[:, :, 2] =
 (1, :b)  (2, :b)
 (3, :b)  (4, :b)

julia> grid(1:2, (:a, :b))
Error showing value of type StructuredGrids.Grid{Tuple{Int64, Symbol}, 2, Tuple{UnitRange{Int64}, Tuple{Symbol, Symbol}}}:
ERROR: MethodError: no method matching axes(::Tuple{Symbol, Symbol}, ::Int64)
Closest candidates are:
  axes(::Tuple) at tuple.jl:28
  axes(::Number, ::Integer) at number.jl:83
  axes(::Base.Broadcast.Broadcasted{<:Any, <:Tuple{Vararg{T, N}} where T}, ::Integer) where N at broadcast.jl:227
  ...
Stacktrace:
  [1] _axes (repeats 2 times)
    @ ~/.julia/packages/StructuredGrids/ndiJn/src/StructuredGrids.jl:17 [inlined]
...

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.