Skip to content

Instantly share code, notes, and snippets.

Avatar

Zachary P Christensen Tokazama

View GitHub Profile
View GraphTraits.jl
module GraphTraits
abstract type GraphStyle end
GraphStyle(x) = GraphStyle(typeof(x))
GraphStyle(::Type{T}) where {T} = throw(MethodError(GraphStyle, T))
vertex_type(x) = vertex_type(typeof(x))
vertex_type(::Type{T}) where {T} = throw(MethodError(vertex_type, T))
View composable_indices.jl
abstract type AccessStyle end
struct LinearElement <: AccessStyle end
struct CartesianElement <: AccessStyle end
struct LinearCollection <: AccessStyle end
struct CartesianCollection <: AccessStyle end
@Tokazama
Tokazama / layouts.jl
Created Jun 3, 2021
Partial conceptualization of layouts interface
View layouts.jl
if VERSION < v"1.6"
struct ComposedFunction{O,I} <: Function
outer::O
inner::I
ComposedFunction{O, I}(outer, inner) where {O, I} = new{O, I}(outer, inner)
ComposedFunction(outer, inner) = new{Core.Typeof(outer),Core.Typeof(inner)}(outer, inner)
end
(c::ComposedFunction)(x...; kw...) = c.outer(c.inner(x...; kw...))
end
View AxisIndicesGraphs.jl
module AxisIndicesGraphs
using AxisIndices, LightGraphs, SimpleWeightedGraphs
using Base: to_index, @propagate_inbounds
struct AxisIndicesGraph{T,G<:AbstractGraph{T},AI} <: AbstractGraph{T}
graph::G
axes::AI
@Tokazama
Tokazama / plot_tick_shortcuts.jl
Last active Jan 23, 2020
Easier interaction with plots.
View plot_tick_shortcuts.jl
"""
ticklabels(scene)
Returns the all the axis tick labels.
"""
function ticklabels(scene)
axis = scene[Axis]
@assert !isnothing(axis)
return axis.ticks.ranges_labels[][2]
end
@Tokazama
Tokazama / named_array_traits.jl
Last active Sep 18, 2019
Ideas for unifying array naming conventions in Julia.
View named_array_traits.jl
import Base: tail, to_dim
struct Dim{Sym} end
const TimeDim = Dim{:time}()
const ColorDim = Dim{:color}()
struct HasDimNames{T} end
HasDimNames(x::T) where T = HasDimNames(T)
HasDimNames(::Type{T}) where T = HasDimNames{false}()