Axes

FlowGeometries.Axes.AbstractUniformAxisType
AbstractUniformAxis{T} <: AbstractRange{T}

Supertype for axes whose spacing is constant and known from their type. Default: UniformAxis.

To add one, implement the three methods AbstractRange already requires — Base.first, Base.step and Base.length — and everything else here follows: indexing, the O(1) reductions, slicing, reversal, and the affine arithmetic. None of the generic methods touch a field, so a subtype may store whatever it likes under whatever names.

Implement similar_axis as well if derived axes should keep the subtype rather than becoming a plain UniformAxis.

source
FlowGeometries.Axes.ConstantVectorType
ConstantVector(value, n)

n copies of value, stored as that value and a length — which is what a uniform axis's per-cell width is.

A genuine AbstractVector: indexing, iteration, broadcasting and collect behave as for fill(value, n). getindex folds to a constant and every reduction below is closed-form.

source
FlowGeometries.Axes.UniformAxisType
UniformAxis(origin, Δ, n)
UniformAxis{T}(origin, Δ, n)

n samples at origin + (i-1)·Δ, stored as those three numbers.

Preferred over range/StepRangeLen for a grid axis:

  • range(0f0; step = 0.1f0, length = n) is a StepRangeLen{Float32, Float64, Float64, Int} — Float32 elements over a Float64 offset and step. UniformAxis{T} computes in T throughout.
  • StepRangeLen's TwicePrecision arithmetic costs measurably for exactness a grid axis does not need. Over 2×10⁶ reads it is 24.0 ms against 16.6 ms here for cos(x[i]), and 4.40 ms against 1.82 ms for the adjacent-gap pattern the grid's per-cell width kernel uses.
  • isbits, so moving an axis to another storage backend is free.

Δ may be negative, for a descending axis. n must be non-negative.

Unlike LinRange this does not pin last to a prescribed endpoint: on a grid the spacing is the primary datum.

An AbstractRange: that gets Base's O(1) searchsorted (flat 42 ns over n = 10 … 10⁷, against 35→69 ns as an AbstractVector) and isa AbstractRange dispatch from other packages.

source
FlowGeometries.Axes.similar_axisMethod
similar_axis(a, origin, Δ, n) -> AbstractUniformAxis

The axis of a's own kind with the given origin, spacing and length: the hook every derived axis goes through — a slice, a reversal, 2a, a .+ c.

Defaults to a UniformAxis, so a subtype that does not define it still gets correct results, just not its own type back.

source
FlowGeometries.Axes.spacingMethod
spacing(x) -> Number

The constant spacing of a uniform axis, read from its type. Signed, so a descending axis reports a negative spacing. Raises for an axis that is not isuniform.

source
FlowGeometries.Axes.spacing_traitMethod
spacing_trait(x) -> UniformSpacing() | NonuniformSpacing()

The axis's spacing trait. UniformAxis and any AbstractRange carry a constant step in their type; every other array is nonuniform.

This is the compile-time question, not the data question: a Vector holding an arithmetic sequence is NonuniformSpacing() because its type does not say otherwise, and no code path here inspects values to decide otherwise — the fast paths are selected by type alone.

source
FlowGeometries.Axes.uniform_axisMethod
uniform_axis(x) -> UniformAxis
uniform_axis(T, x) -> UniformAxis{T}

The UniformAxis equal to x, for any axis whose spacing is known from its type. A nonuniform vector raises, because it has no uniform form: replacing its coordinates with a fitted sequence is a decision only its owner can make, and they can build the axis directly.

source
FlowGeometries.Axes.wrap_signMethod
wrap_sign(x) -> ±1

+1 for an ascending axis and -1 for a descending one: the sign that turns a period magnitude into the wrapped neighbour's offset in index order. A descending axis is routine in stored data, and its wrapped neighbour lies at x[1] - period, not x[1] + period.

source