{"id":19093702,"url":"https://github.com/juliaarrays/paddedviews.jl","last_synced_at":"2026-05-25T19:30:21.069Z","repository":{"id":19851609,"uuid":"88094696","full_name":"JuliaArrays/PaddedViews.jl","owner":"JuliaArrays","description":"Add virtual padding to the edges of an array","archived":false,"fork":false,"pushed_at":"2024-08-15T21:54:15.000Z","size":92,"stargazers_count":49,"open_issues_count":10,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-02-20T22:25:32.325Z","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/JuliaArrays.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-04-12T20:45:25.000Z","updated_at":"2024-09-10T10:43:51.000Z","dependencies_parsed_at":"2024-01-22T22:01:19.157Z","dependency_job_id":"ca1fe7a3-9dd7-4913-abc8-63589bbfd02f","html_url":"https://github.com/JuliaArrays/PaddedViews.jl","commit_stats":{"total_commits":63,"total_committers":12,"mean_commits":5.25,"dds":0.5238095238095238,"last_synced_commit":"23ae68e732fdbffabe69d7a3855cb10e96e98988"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FPaddedViews.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FPaddedViews.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FPaddedViews.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaArrays%2FPaddedViews.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaArrays","download_url":"https://codeload.github.com/JuliaArrays/PaddedViews.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240142863,"owners_count":19754640,"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-11-09T03:25:46.472Z","updated_at":"2026-05-25T19:30:21.007Z","avatar_url":"https://github.com/JuliaArrays.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PaddedViews\n\n[![][action-img]][action-url]\n[![][pkgeval-img]][pkgeval-url]\n[![][codecov-img]][codecov-url]\n\n## Summary\n\nPaddedViews provides a simple wrapper type, `PaddedView`, to add\n\"virtual\" padding to any array without copying data. Edge values not\nspecified by the array are assigned a `fillvalue`.  Multiple arrays\nmay be \"promoted\" to have common indices using the `paddedviews`\nfunction.\n\n`PaddedView` arrays are read-only, meaning that you cannot assign\nvalues to them. The original array may be extracted using `A =\nparent(P)`, where `P` is a `PaddedView`.\n\n## Examples\n\nFor padding a single array:\n\n```julia\njulia\u003e a = collect(reshape(1:9, 3, 3))\n3×3 Array{Int64,2}:\n 1  4  7\n 2  5  8\n 3  6  9\n\njulia\u003e PaddedView(-1, a, (4, 5))\n4×5 PaddedView(-1, ::Array{Int64,2}, (Base.OneTo(4), Base.OneTo(5))) with eltype Int64:\n  1   4   7  -1  -1\n  2   5   8  -1  -1\n  3   6   9  -1  -1\n -1  -1  -1  -1  -1\n\n julia\u003e PaddedView(-1, a, (1:5,1:5), (2:4,2:4))\n 5×5 PaddedView(-1, OffsetArray(::Array{Int64,2}, 2:4, 2:4), (1:5, 1:5)) with eltype Int64 with indices 1:5×1:5:\n -1  -1  -1  -1  -1\n -1   1   4   7  -1\n -1   2   5   8  -1\n -1   3   6   9  -1\n -1  -1  -1  -1  -1\n\n julia\u003e PaddedView(-1, a, (0:4, 0:4))\n 5×5 PaddedView(-1, ::Array{Int64,2}, (0:4, 0:4)) with eltype Int64 with indices 0:4×0:4:\n  -1  -1  -1  -1  -1\n  -1   1   4   7  -1\n  -1   2   5   8  -1\n  -1   3   6   9  -1\n  -1  -1  -1  -1  -1\n\njulia\u003e PaddedView(-1, a, (5,5), (2,2))\n5×5 PaddedView(-1, OffsetArray(::Array{Int64,2}, 2:4, 2:4), (Base.OneTo(5), Base.OneTo(5))) with eltype Int64:\n -1  -1  -1  -1  -1\n -1   1   4   7  -1\n -1   2   5   8  -1\n -1   3   6   9  -1\n -1  -1  -1  -1  -1\n```\n\nFor padding multiple arrays to have common indices:\n\n```julia\njulia\u003e a1 = reshape([1, 2, 3], 3, 1)\n3×1 Array{Int64,2}:\n 1\n 2\n 3\n\njulia\u003e a2 = [4 5 6]\n1×3 Array{Int64,2}:\n 4  5  6\n\njulia\u003e a1p, a2p = paddedviews(-1, a1, a2);\n\njulia\u003e a1p\n3×3 PaddedView(-1, ::Array{Int64,2}, (Base.OneTo(3), Base.OneTo(3))) with eltype Int64:\n 1  -1  -1\n 2  -1  -1\n 3  -1  -1\n\njulia\u003e a2p\n3×3 PaddedView(-1, ::Array{Int64,2}, (Base.OneTo(3), Base.OneTo(3))) with eltype Int64:\n  4   5   6\n -1  -1  -1\n -1  -1  -1\n```\n\nIf you want original arrays in the center of padded results:\n\n```julia\njulia\u003e a1 = reshape([1, 2, 3], 3, 1)\n3×1 Array{Int64,2}:\n 1\n 2\n 3\n\njulia\u003e a2 = [4 5 6]\n1×3 Array{Int64,2}:\n 4  5  6\n\njulia\u003e a1p, a2p = sym_paddedviews(-1, a1, a2);\n\njulia\u003e a1p\n3×3 PaddedView(-1, ::Array{Int64,2}, (1:3, 0:2)) with eltype Int64 with indices 1:3×0:2:\n -1  1  -1\n -1  2  -1\n -1  3  -1\n\njulia\u003e a2p\n3×3 PaddedView(-1, ::Array{Int64,2}, (0:2, 1:3)) with eltype Int64 with indices 0:2×1:3:\n -1  -1  -1\n  4   5   6\n -1  -1  -1\n```\n\n\nWe can use `dims` keyword to specify the direction of padding for the output arrays as shown above. They can be integers or tuple of integers.\n\n```julia\njulia\u003e a1p, a2p = paddedviews(-1, a1, a2; dims=1);\n\njulia\u003e a1p\n3×1 PaddedView(-1, ::Matrix{Int64}, (Base.OneTo(3), Base.OneTo(1))) with eltype Int64:\n 1\n 2\n 3\n\njulia\u003e a2p\n3×3 PaddedView(-1, ::Matrix{Int64}, (Base.OneTo(3), Base.OneTo(3))) with eltype Int64:\n  4   5   6\n -1  -1  -1\n -1  -1  -1\n\njulia\u003e a1p, a2p = sym_paddedviews(-1, a1, a2; dims=2);\n\njulia\u003e a1p\n3×3 PaddedView(-1, ::Matrix{Int64}, (1:3, 0:2)) with eltype Int64 with indices 1:3×0:2:\n -1  1  -1\n -1  2  -1\n -1  3  -1\n\njulia\u003e a2p\n1×3 PaddedView(-1, ::Matrix{Int64}, (1:1, 1:3)) with eltype Int64 with indices 1:1×1:3:\n 4  5  6\n```\n\n\n\u003c!-- badges and urls --\u003e\n\n[pkgeval-img]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/P/PaddedViews.svg\n[pkgeval-url]: https://juliaci.github.io/NanosoldierReports/pkgeval_badges/report.html\n[action-img]: https://github.com/JuliaArrays/PaddedViews.jl/workflows/CI/badge.svg\n[action-url]: https://github.com/JuliaArrays/PaddedViews.jl/actions\n[codecov-img]: https://codecov.io/github/JuliaArrays/PaddedViews.jl/coverage.svg?branch=master\n[codecov-url]: https://codecov.io/github/JuliaArrays/PaddedViews.jl?branch=master\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaarrays%2Fpaddedviews.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliaarrays%2Fpaddedviews.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaarrays%2Fpaddedviews.jl/lists"}