{"id":16705091,"url":"https://github.com/mcabbott/dimarrays.jl","last_synced_at":"2026-01-29T08:41:07.879Z","repository":{"id":61797737,"uuid":"141807470","full_name":"mcabbott/DimArrays.jl","owner":"mcabbott","description":"Julia arrays with dimension labels, and scaling","archived":false,"fork":false,"pushed_at":"2020-02-08T15:04:25.000Z","size":36,"stargazers_count":0,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-13T19:28:29.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcabbott.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-21T11:50:30.000Z","updated_at":"2024-05-09T21:02:10.000Z","dependencies_parsed_at":"2022-10-21T11:00:58.827Z","dependency_job_id":null,"html_url":"https://github.com/mcabbott/DimArrays.jl","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/mcabbott/DimArrays.jl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FDimArrays.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FDimArrays.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FDimArrays.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FDimArrays.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcabbott","download_url":"https://codeload.github.com/mcabbott/DimArrays.jl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcabbott%2FDimArrays.jl/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259509430,"owners_count":22868834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T19:28:38.921Z","updated_at":"2026-01-29T08:41:07.834Z","avatar_url":"https://github.com/mcabbott.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DimArrays.jl\n\nThis packages provides Julia arrays with named dimensions. \nLike the built-in Array type these are mutable objects, \nunlike [NamedArrays](https://github.com/davidavdav/NamedArrays.jl) and [AxisArrays](https://github.com/JuliaArrays/AxisArrays.jl) which are immutable. \n\nThe idea was to have a convenient way to gather results of calculations in a script or notebook, rather than for anything high-performance. \nFor example, here I have a matrix of results at each iteration, and `nest` these into a 3-tensor, whose axis order I need not remember:\n```julia\nusing DimArrays\n\nlist = [];\nfor i=1:33\n    slowcalc = sqrt(i) .* randn(3,13) .+ i\n    push!(list, DimArray(slowcalc, :a, :b, :c ))  # add labels for 1st and 2nd dimensions  \nend\n\nlist3 = nest(list, :iter)   # now i is the 3rd index, and named \"iter\"\n\nusing Statistics\n\nmean(list3, dims=:iter)     # equivalent to dropdims(mean(list3, dims=3), dims=3)\n```\nFor quick plots, dimension names are used for axes and series: \n```julia\nusing Plots\n\nplot(selectdim(list3, :b, 1)' , legend=:bottomright)\n```\nHere `selectdim(list3, :b, 1) == list3[:,1,:]` in contents, but retains the labels.\n\nBesides each dimension's name (which is a Symbol, strings will be converted) it can also store a function, which is used in plotting to scale the axes etc. \n(But only the output, `getindex` uses original integer indices).\nYou can pass a number by which to scale the index, or a dictionary, instead of a function.\n\nFor example, this plots data saved every 4 iterations correctly over the above example:\n```julia\nsaveevery = 4\nlist4 = DimArray([], :iter, saveevery);     # equivalent to function  i-\u003e4i\nfor i=1:33\n    slowcalc = sqrt(i) .* randn(3,23) .+ i\n    slownice = DimArray(slowcalc, [:a, :b], [Dict(1=\u003e\"one\", 2=\u003e\"two\", 3=\u003e\"three\")], :stuff )\n                                            # equivalent to  i-\u003eDict(...)[i]\n    rem(i,saveevery)==0 \u0026\u0026 push!(list4, slownice)\nend\nnest(list4)\n\nplot!(mean(nest(list4), dims=:b)', s=:dash)\n```\n\nIf you do not provide a name for a dimension (or give an empty string \"\") \nthen you can still refer to it by default names like `size(x, :row) == size(x,1)` or `maximum(y, :col)` etc. \nHowever these defaults are not stored, and not manipulated by `transpose(x)` or `kron(x,y)`.\n\nFor now, the list of functions supported is:\n\n* `DimArray`, `DimVector`, `DimMatrix` create one, taking names and functions for dimensions in the order given.\n* `dictvector` defines a DimVector whose function is a Dict. \n* `nest` converts arrays of arrays, and `squeeze` drops dimensions of size 1. \n\nand these built-in functions:\n\n* `selectdim, size` understand a dimension's name.\n* `sum, maximum, minimum, dropdims` and `Statistics.mean, std`: all can be called with a dimension's name, in which case by default `squeeze=true` on that dimension, like `mean(..., dims=:b)` above.\n    They can also be called with a list of dimensions: `sum(x, dims=[1,:c])` etc.\n* `push!, append!, hcat, vcat, transpose, ctranspose, permutedims`.\n* Matrix multiplication `*` will warn (once) if you multiply along directions with mismatched names... which may be a terrible idea.\n    And `kron`ecker products produce new names like `:a_b`.  \n* `collect`, implicitly used by comprehensions like `[ sqrt(n) for n in DimVector(1:10, \"int\")' ]` which thus inherit the names of the array being iterated over.\n\nSince `DimArray \u003c: AbstractArray` anything else will fall back on their methods, and forget the dimension labels. \n\nSee also:\n* [NamedArrays](https://github.com/davidavdav/NamedArrays.jl)\n* [AxisArrays](https://github.com/JuliaArrays/AxisArrays.jl)\n* [RecursiveArrayTools](https://github.com/JuliaDiffEq/RecursiveArrayTools.jl)\n* [JuliennedArrays](https://github.com/bramtayl/JuliennedArrays.jl)\n\nToDo:\n* Make things like `x[:, 1:10:end]` and `hcat(a,b)` update the functions correctly.\n* Figure out Julia 0.7's new broadcasting machinery.\n\nMichael Abbott,\nJanuary 2018, mostly (as I had a grant to write).\n\n\n[![Build Status](https://travis-ci.org/mcabbott/DimArrays.jl.svg?branch=master)](https://travis-ci.org/mcabbott/DimArrays.jl)\n\n\u003c!--\n[![Coverage Status](https://coveralls.io/repos/mcabbott/DimArrays.jl/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/mcabbott/DimArrays.jl?branch=master)\n[![codecov.io](http://codecov.io/github/mcabbott/DimArrays.jl/coverage.svg?branch=master)](http://codecov.io/github/mcabbott/DimArrays.jl?branch=master)\n--\u003e \n\n\u003c!--\nNote to self:\npandoc -o README.html README.md\n--\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcabbott%2Fdimarrays.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcabbott%2Fdimarrays.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcabbott%2Fdimarrays.jl/lists"}