Table of Contents

Class Merger

Namespace
Gym.Merging
Assembly
Gym.dll

The legacy deep merge behind Dict's Merge: nested dictionaries are merged key by key, lists are appended to, values only the right side has are copied in (lists and dictionaries cloned), and two plain values on the same key are settled by MergePrefer. The left side is changed in place.

[Obsolete("The legacy Dict's deep merge: use Gym.Envs.Info.Update (Python's dict.update: the new value wins, one level deep). Removed in 2.0 with Gym.Legacy.")]
public static class Merger
Inheritance
Merger
Inherited Members

Remarks

Obsolete with Dict (DR-56) and removed in 2.0; Update(IEnumerable<KeyValuePair<string, object?>>) replaces it, one level deep with the new value winning, as Python's dict.update. Footguns: lists are concatenated whatever the preference; a fixed-size or read-only left dictionary is returned unmerged, silently; merging a dictionary into a non-expandable IMergable overwrites its existing keys whatever the preference; a right side of any other type merges nothing; and a failing key leaves the keys before it merged.

Methods

Merge(IMergable, IMergable, MergePrefer)

Merges right with left object, appending all lists and merging dictionaries.

public static void Merge(IMergable left, IMergable right, MergePrefer preference)

Parameters

left IMergable

The object that will accept all merges.

right IMergable

The dictionary to take data from.

preference MergePrefer

See the enum values docs.

Exceptions

DictMergingException

Thrown when one key's merge fails; the inner exception is the cause, and the keys before it stay merged.

Merge(IMergable, object, MergePrefer)

Merges right with current dictionary, appending all lists and merging dictionaries.

public static void Merge(IMergable left, object right, MergePrefer preference)

Parameters

left IMergable

The object that will accept all merges.

right object

The dictionary to take data from: an IDictionary, an IMergable or a sequence of string-keyed pairs; anything else merges nothing.

preference MergePrefer

See the enum values docs.

Exceptions

DictMergingException

Thrown when one key's merge fails; the inner exception is the cause, and the keys before it stay merged.

Merge(IDictionary, IDictionary, MergePrefer)

Merges right with left dictionary, appending all lists and merging dictionaries.

public static void Merge(IDictionary left, IDictionary right, MergePrefer prefer = MergePrefer.Old)

Parameters

left IDictionary

The object that will accept all merges.

right IDictionary

The dictionary to take data from.

prefer MergePrefer

See the enum values docs.

Remarks

A null or empty right merges nothing; so does a fixed-size or read-only left, silently.

Exceptions

DictMergingException

Thrown when one key's merge fails; the inner exception is the cause, and the keys before it stay merged.