Skip to content

MoreMaps.jl

A flexible mapping framework for Julia that provides different parallel backends, progress tracking, and iteration patterns.

Features

  • Multiple backends: Sequential, Threaded, Distributed (Pmap), and Daggermap execution

  • Progress tracking: LogLogger, ProgressLogger, TermLogger, and QualityLogger

  • Nested array support: Map over specific leaf types in nested array structures

  • Cartesian (and arbitrary) expansions: Easy combinatorial iteration over inputs

  • Tuple / NamedTuple inputs: Map over Tuples and NamedTuples, returning the same shape

  • DimensionalData support: Map directly over Dimension arguments

Quick Start

julia
using MoreMaps

# Basic usage with default sequential backend
x = rand(100)
C = Chart()
y = map(sqrt, C, x)

# Use threading for parallel execution
C_threaded = Chart(Threaded())
y_threaded = map(sqrt, C_threaded, x)

# Add progress tracking
C_progress = Chart(Threaded(), LogLogger(10))
y_progress = map(sqrt, C_progress, x)
100-element Vector{Float64}:
 0.781206471888972
 0.3462305850833009
 0.9601627877702759
 0.259467737255542
 0.9619202031443926
 0.5076781853947876
 0.8039484125842029
 0.5154530195789261
 0.6138659753022729
 0.7392649255169689

 0.6780922306544371
 0.9070121336698124
 0.7419162552157301
 0.8198371390120802
 0.8766081209138298
 0.44881458450263917
 0.5367292377300185
 0.48388201955454013
 0.7560706146517433

You can also pass a Backend or Progress value (or even the bare type) directly to map, and a default Chart wrapping it will be constructed for you:

julia
using MoreMaps
x = rand(10)
map(sqrt, Threaded(), x)        # equivalent to map(sqrt, Chart(Threaded()), x)
map(sqrt, LogLogger(5), x)      # equivalent to map(sqrt, Chart(LogLogger(5)), x)
10-element Vector{Float64}:
 0.6613306266297984
 0.6669782608723176
 0.4469366867276272
 0.9716317644154471
 0.12501830870081587
 0.6849808430408669
 0.8294139644594563
 0.6408804794869865
 0.7190037174003053
 0.46804857496066654

Basics

The basis of a MoreMaps map is the Chart type, which configures how mapping operations are executed.

A Chart is parameterised by four things:

  • backend: Specifies the execution backend

  • progress: Configures the progress logging behavior

  • leaf: The element type where recursion terminates, used for mapping nested arrays. Stored as a type parameter rather than a field.

  • expansion: Determines how the input iterables are combined (e.g. Cartesian product). Either NoExpansion() or a Function.

A chart can be constructed using keywords or arbitrary-order positional arguments. The default Chart() reproduces Base.map(), and is constructed as:

julia
C = Chart(backend   = Sequential(),    # No parallel execution; similar to Base.map
          progress  = NoProgress(),    # No progress logging
          leaf      = MoreMaps.All,    # Map over each element of the root array, like Base.map
          expansion = NoExpansion())   # Map over the original input arrays, as for Base.map

# Or, using positional arguments in any order. Each argument is dispatched on its
# type: `Backend` -> backend, `Progress` -> progress, `Type` -> leaf, `Function`
# -> expansion.
C = Chart(Sequential(), NoProgress(), MoreMaps.All, NoExpansion())

# Default behavior
C == Chart()

Mapping

Once you have a Chart, pass it to the standard Base.map function:

julia
using MoreMaps

x = rand(10)
C = Chart()
y = map(sqrt, C, x)
y == map(sqrt, x)
true

Tuple and NamedTuple inputs are supported and the result is returned with the same shape:

julia
map(x -> x^2, Chart(), (1, 2, 3))             # -> Tuple
map(x -> x^2, Chart(), (a = 1, b = 2, c = 3)) # -> NamedTuple
(a = 1, b = 4, c = 9)

See the following pages for details on configuring a Chart:

  • Backends - Execution strategies (Sequential, Threaded, Pmap, Daggermap)

  • Progress - Progress tracking options (LogLogger, ProgressLogger, TermLogger, QualityLogger, NoProgress)

  • Leaves - Nested array handling

  • Expansions - Cartesian product and custom iterations