{"id":20500575,"url":"https://github.com/juliaapproximation/compositetypes.jl","last_synced_at":"2025-03-05T19:33:55.215Z","repository":{"id":61797551,"uuid":"359372061","full_name":"JuliaApproximation/CompositeTypes.jl","owner":"JuliaApproximation","description":"A common interface for composite types, which may consist of several components","archived":false,"fork":false,"pushed_at":"2024-04-07T14:33:22.000Z","size":137,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-02-20T20:37:57.348Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JuliaApproximation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-04-19T07:44:26.000Z","updated_at":"2024-04-07T13:22:45.000Z","dependencies_parsed_at":"2024-11-15T18:22:47.683Z","dependency_job_id":"63fec9df-f02c-413e-91af-75ee3d8740e0","html_url":"https://github.com/JuliaApproximation/CompositeTypes.jl","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.2857142857142857,"last_synced_commit":"a4e0ab33e397268eec33461286270d5751f0c52e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FCompositeTypes.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FCompositeTypes.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FCompositeTypes.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuliaApproximation%2FCompositeTypes.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuliaApproximation","download_url":"https://codeload.github.com/JuliaApproximation/CompositeTypes.jl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242092320,"owners_count":20070501,"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-15T18:21:41.197Z","updated_at":"2025-03-05T19:33:55.175Z","avatar_url":"https://github.com/JuliaApproximation.png","language":"Julia","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CompositeTypes.jl\n\n[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaApproximation.github.io/CompositeTypes.jl/dev)\n[![Build Status](https://github.com/JuliaApproximation/CompositeTypes.jl/workflows/CI/badge.svg)](https://github.com/JuliaApproximation/CompositeTypes.jl/actions)\n[![Coverage Status](https://codecov.io/gh/JuliaApproximation/CompositeTypes.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaApproximation/CompositeTypes.jl)\n[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)\n\n\nCompositeTypes.jl defines an interface for types that consist of multiple components.\n\n## Interface\n\nThe package defines:\n- `iscomposite(x)`: true if `x` is a composite object\n- `components(x)`: returns the components of `x`\n- `component(x, I...)`: returns `components(x)[I...]`\n- `ncomponents(x)`: the number of components of `x`\n- `setcomponent!(x, v, I...)`: (if applicable) set a component to a given value\n\nA type can declare to be composite simply by implementing `components(x)`, and\nreturning something with non-zero `length`.\n\n## Indexing\n\nThe submodule `Indexing` defines a generic way to index components of a\ncomposite object. For example, using the `DomainSets.jl` package:\n```julia\njulia\u003e using DomainSets, CompositeTypes.Indexing\n\njulia\u003e d = UnitCube(3); components(d)\n3-element Vector{UnitInterval{Float64}}:\n 0.0..1.0 (Unit)\n 0.0..1.0 (Unit)\n 0.0..1.0 (Unit)\n\njulia\u003e d[Component(1)]\n 0.0..1.0 (Unit)\n\njulia\u003e d[Component(1):Component(2)]\n2-element Vector{UnitInterval{Float64}}:\n 0.0..1.0 (Unit)\n 0.0..1.0 (Unit)\n```\n\n## Display\n\nComposite types can opt-in to a structured multi-line representation by\ndefining a display stencil and specializing `show`. An example, again using\nthe `DomainSets.jl` package:\n```julia\njulia\u003e using DomainSets\n\njulia\u003e boundary(UnitCube(3))\nD₄ ∪ D₁ ∪ D₃\n\nD₁ = (0.0..1.0 (Unit)) × D₂ × (0.0..1.0 (Unit))\nD₂ = Point{Float64}(0.0) ∪ Point{Float64}(1.0)\nD₃ = (0.0..1.0 (Unit)) × (0.0..1.0 (Unit)) × D₂\nD₄ = D₂ × (0.0..1.0 (Unit)) × (0.0..1.0 (Unit))\n```\nThe display routines recursively evaluate display stencils of all objects\nappearing in the stencil of an object, up to a maximum recursion depth. An\nattempt is made to define symbols, such that the output remains somewhat\nreadable.\n\nBoth the `ProductDomain` and `UnionDomain` types are composite types. They\ncombine their components using a `combinationsymbol`, in this case `∪` and `×`.\nThe output above is achieved with the definitions, for `ProductDomain`:\n```julia\nusing CompositeTypes.Display\nDisplay.combinationsymbol(d::ProductDomain) = Display.Symbol('×')\nDisplay.displaystencil(d::ProductDomain) = composite_displaystencil(d)\n\nshow(io::IO, mime::MIME\"text/plain\", d::ProductDomain) = composite_show(io, mime, d)\nshow(io::IO, d::ProductDomain) = composite_show_compact(io, d)\n```\nThe invocation of `show` with the `mime` argument indicates that a multi-line\nrepresentation can be shown. The shorter `show(io, x)` function typically expects\na one-line representation. Types can choose to implement either function. Typically\nthe longer version is the most useful, while for the compact version it may be\nsafer to rely on Julia's default.\n\nA type can define a custom display stencil, which is a vector in which each string\nor character ends up being displayed, and each object is replaced by its own\ndisplay stencil or by a compact string representation. For example:\n```julia\nDisplay.displaystencil(object::LinearMap) = [object.A, \" * x + \", object.b]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaapproximation%2Fcompositetypes.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliaapproximation%2Fcompositetypes.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliaapproximation%2Fcompositetypes.jl/lists"}