Rename ImmutableArray to ReadOnlyArray (#293)

This commit is contained in:
Jonathan Tims 2020-09-30 18:54:20 +01:00 коммит произвёл GitHub
Родитель 568cb96cda
Коммит 0be0aefe1d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
10 изменённых файлов: 98 добавлений и 97 удалений

Просмотреть файл

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.Linq;
@ -86,7 +87,7 @@ namespace Microsoft.ML.Probabilistic.Compiler
targetAssemblyName = asmName.Name;
options = options
.WithPublicSign(true)
.WithCryptoPublicKey(System.Collections.Immutable.ImmutableArray.Create(pk));
.WithCryptoPublicKey(ImmutableArray.Create(pk));
}
var compilation = CSharpCompilation.Create(targetAssemblyName, allTrees, references, options);
var model = compilation.GetSemanticModel(primaryTree);

Просмотреть файл

@ -18,13 +18,13 @@ namespace Microsoft.ML.Probabilistic.Collections
/// Represents an immutable array.
/// </summary>
/// <remarks>
/// This is a partial reimplementation of System.Collections.Immutable.ImmutableArray.
/// This is a partial reimplementation of System.Collections.Immutable.ReadOnlyArray.
/// Once we can move to netcore-only codebase, this type can be removed.
/// API is supposed to be a subset of the real thing to ease migration in future.
/// </remarks>
[Serializable]
[DataContract]
public struct ImmutableArray<T> : IReadOnlyList<T>
public struct ReadOnlyArray<T> : IReadOnlyList<T>
{
/// <summary>
/// Regular array that holds data.
@ -33,22 +33,22 @@ namespace Microsoft.ML.Probabilistic.Collections
private readonly T[] array;
/// <summary>
/// Initializes a new instance of the <see cref="ImmutableArray{T}"/> structure.
/// Initializes a new instance of the <see cref="ReadOnlyArray{T}"/> structure.
/// </summary>
private ImmutableArray(T[] array)
private ReadOnlyArray(T[] array)
{
this.array = array;
}
/// <summary>
/// Creates a new instance of <see cref="ImmutableArray{T}"/> by copying elements of
/// Creates a new instance of <see cref="ReadOnlyArray{T}"/> by copying elements of
/// <paramref name="sequence"/>.
/// </summary>
[Construction("CloneArray")]
public static ImmutableArray<T> CreateCopy(IEnumerable<T> sequence) =>
new ImmutableArray<T>(sequence.ToArray());
public static ReadOnlyArray<T> CreateCopy(IEnumerable<T> sequence) =>
new ReadOnlyArray<T>(sequence.ToArray());
public static ImmutableArray<T> Empty => new ImmutableArray<T>(Array.Empty<T>());
public static ReadOnlyArray<T> Empty => new ReadOnlyArray<T>(Array.Empty<T>());
/// <inheritdoc/>
public T this[int index] => this.array[index];
@ -67,25 +67,25 @@ namespace Microsoft.ML.Probabilistic.Collections
/// <remarks>
/// This is value-type non-virtual version of enumerator that is used by compiler in foreach loops.
/// </remarks>
public ImmutableArraySegmentEnumerator<T> GetEnumerator() =>
new ImmutableArraySegmentEnumerator<T>(this, 0, this.array.Length);
public ReadOnlyArraySegmentEnumerator<T> GetEnumerator() =>
new ReadOnlyArraySegmentEnumerator<T>(this, 0, this.array.Length);
/// <inheritdoc/>
IEnumerator<T> IEnumerable<T>.GetEnumerator() =>
new ImmutableArraySegmentEnumerator<T>(this, 0, this.array.Length);
new ReadOnlyArraySegmentEnumerator<T>(this, 0, this.array.Length);
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() =>
new ImmutableArraySegmentEnumerator<T>(this, 0, this.array.Length);
new ReadOnlyArraySegmentEnumerator<T>(this, 0, this.array.Length);
public override bool Equals(object o) => o is ImmutableArray<T> that && this == that;
public override bool Equals(object o) => o is ReadOnlyArray<T> that && this == that;
public override int GetHashCode() => this.array.GetHashCode();
public static bool operator ==(ImmutableArray<T> left, ImmutableArray<T> right) =>
public static bool operator ==(ReadOnlyArray<T> left, ReadOnlyArray<T> right) =>
left.array == right.array;
public static bool operator !=(ImmutableArray<T> left, ImmutableArray<T> right) =>
public static bool operator !=(ReadOnlyArray<T> left, ReadOnlyArray<T> right) =>
left.array != right.array;
public class Builder
@ -103,9 +103,9 @@ namespace Microsoft.ML.Probabilistic.Collections
public int Count => this.array.Length;
public ImmutableArray<T> MoveToImmutable()
public ReadOnlyArray<T> MoveToImmutable()
{
var result = new ImmutableArray<T>(this.array);
var result = new ReadOnlyArray<T>(this.array);
this.array = Array.Empty<T>();
return result;
}
@ -115,12 +115,12 @@ namespace Microsoft.ML.Probabilistic.Collections
/// <summary>
/// A version if <see cref="ArraySegment{T}"/> which can not be mutated.
/// </summary>
public struct ImmutableArraySegment<T> : IReadOnlyList<T>
public struct ReadOnlyArraySegment<T> : IReadOnlyList<T>
{
/// <summary>
/// Underlying read-only array.
/// </summary>
private readonly ImmutableArray<T> array;
private readonly ReadOnlyArray<T> array;
/// <summary>
/// Index of the first element which belongs to this segment.
@ -133,9 +133,9 @@ namespace Microsoft.ML.Probabilistic.Collections
private readonly int length;
/// <summary>
/// Initializes a new instance of <see cref="ImmutableArraySegment{T}"/> structure.
/// Initializes a new instance of <see cref="ReadOnlyArraySegment{T}"/> structure.
/// </summary>
public ImmutableArraySegment(ImmutableArray<T> array, int begin, int length)
public ReadOnlyArraySegment(ReadOnlyArray<T> array, int begin, int length)
{
Argument.CheckIfInRange(begin >= 0 && begin <= array.Count, nameof(begin), "Segment begin should be in the range [0, array.Count]");
Argument.CheckIfInRange(length >= 0 && length <= array.Count - begin, nameof(length), "Segment length should be in the range [0, array.Count - begin]");
@ -164,27 +164,27 @@ namespace Microsoft.ML.Probabilistic.Collections
/// <remarks>
/// This is value-type non-virtual version of enumerator that is used by compiler in foreach loops.
/// </remarks>
public ImmutableArraySegmentEnumerator<T> GetEnumerator() =>
new ImmutableArraySegmentEnumerator<T>(this.array, this.begin, this.begin + this.length);
public ReadOnlyArraySegmentEnumerator<T> GetEnumerator() =>
new ReadOnlyArraySegmentEnumerator<T>(this.array, this.begin, this.begin + this.length);
/// <inheritdoc/>
IEnumerator<T> IEnumerable<T>.GetEnumerator() =>
new ImmutableArraySegmentEnumerator<T>(this.array, this.begin, this.begin + this.length);
new ReadOnlyArraySegmentEnumerator<T>(this.array, this.begin, this.begin + this.length);
/// <inheritdoc/>
IEnumerator IEnumerable.GetEnumerator() =>
new ImmutableArraySegmentEnumerator<T>(this.array, this.begin, this.begin + this.length);
new ReadOnlyArraySegmentEnumerator<T>(this.array, this.begin, this.begin + this.length);
}
/// <summary>
/// Enumerator for immutable arrays and immutable array segments.
/// </summary>
public struct ImmutableArraySegmentEnumerator<T> : IEnumerator<T>
public struct ReadOnlyArraySegmentEnumerator<T> : IEnumerator<T>
{
/// <summary>
/// Underlying immutable array.
/// </summary>
private readonly ImmutableArray<T> array;
private readonly ReadOnlyArray<T> array;
/// <summary>
/// Index of the first element which belongs segment begin enumerated.
@ -202,9 +202,9 @@ namespace Microsoft.ML.Probabilistic.Collections
private int pointer;
/// <summary>
/// Initializes a new instance of <see cref="ImmutableArraySegment{T}"/> structure.
/// Initializes a new instance of <see cref="ReadOnlyArraySegment{T}"/> structure.
/// </summary>
internal ImmutableArraySegmentEnumerator(ImmutableArray<T> array, int begin, int end)
internal ReadOnlyArraySegmentEnumerator(ReadOnlyArray<T> array, int begin, int end)
{
this.array = array;
this.begin = begin;
@ -237,29 +237,29 @@ namespace Microsoft.ML.Probabilistic.Collections
}
}
public static class ImmutableArray
public static class ReadOnlyArray
{
public static ImmutableArray<T>.Builder CreateBuilder<T>(int size) =>
new ImmutableArray<T>.Builder(size);
public static ReadOnlyArray<T>.Builder CreateBuilder<T>(int size) =>
new ReadOnlyArray<T>.Builder(size);
public static ImmutableArray<T> Create<T>() => ImmutableArray<T>.Empty;
public static ReadOnlyArray<T> Create<T>() => ReadOnlyArray<T>.Empty;
public static ImmutableArray<T> Create<T>(T elem)
public static ReadOnlyArray<T> Create<T>(T elem)
{
var builder = new ImmutableArray<T>.Builder(1) {[0] = elem};
var builder = new ReadOnlyArray<T>.Builder(1) {[0] = elem};
return builder.MoveToImmutable();
}
public static ImmutableArray<T> Create<T>(T elem1, T elem2)
public static ReadOnlyArray<T> Create<T>(T elem1, T elem2)
{
var builder = new ImmutableArray<T>.Builder(2) {[0] = elem1, [1] = elem2};
var builder = new ReadOnlyArray<T>.Builder(2) {[0] = elem1, [1] = elem2};
return builder.MoveToImmutable();
}
/// <summary>
/// Syntactic sugar for `ReadOnlyArray{T}.CreateCopy(sequence)`
/// </summary>
public static ImmutableArray<T> ToImmutableArray<T>(this IEnumerable<T> sequence) =>
ImmutableArray<T>.CreateCopy(sequence);
public static ReadOnlyArray<T> ToReadOnlyArray<T>(this IEnumerable<T> sequence) =>
ReadOnlyArray<T>.CreateCopy(sequence);
}
}

Просмотреть файл

@ -414,8 +414,8 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
var usesGroups = false;
var hasOnlyForwardTransitions = true;
var resultStates = ImmutableArray.CreateBuilder<StateData>(this.states.Count);
var resultTransitions = ImmutableArray.CreateBuilder<Transition>(this.transitions.Count - this.numRemovedTransitions);
var resultStates = ReadOnlyArray.CreateBuilder<StateData>(this.states.Count);
var resultTransitions = ReadOnlyArray.CreateBuilder<Transition>(this.transitions.Count - this.numRemovedTransitions);
var nextResultTransitionIndex = 0;
for (var i = 0; i < resultStates.Count; ++i)

Просмотреть файл

@ -32,13 +32,13 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// <summary>
/// All automaton states.
/// </summary>
public readonly ImmutableArray<StateData> States;
public readonly ReadOnlyArray<StateData> States;
/// <summary>
/// All automaton transitions. Transitions for the same state are stored as a contiguous block
/// inside this array.
/// </summary>
public readonly ImmutableArray<Transition> Transitions;
public readonly ReadOnlyArray<Transition> Transitions;
/// <summary>
/// Gets value indicating whether this automaton is epsilon-free.
@ -84,8 +84,8 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
[Construction("StartStateIndex", "States", "Transitions", "IsEpsilonFree", "UsesGroups", "IsDeterminized", "IsZero", "IsEnumerable")]
public DataContainer(
int startStateIndex,
ImmutableArray<StateData> states,
ImmutableArray<Transition> transitions,
ReadOnlyArray<StateData> states,
ReadOnlyArray<Transition> transitions,
bool isEpsilonFree,
bool usesGroups,
bool? isDeterminized,
@ -176,8 +176,8 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
{
this.flags = (Flags)info.GetValue(nameof(this.flags), typeof(Flags));
this.StartStateIndex = (int)info.GetValue(nameof(this.StartStateIndex), typeof(int));
this.States = ((StateData[])info.GetValue(nameof(this.States), typeof(StateData[]))).ToImmutableArray();
this.Transitions = ((Transition[])info.GetValue(nameof(this.Transitions), typeof(Transition[]))).ToImmutableArray();
this.States = ((StateData[])info.GetValue(nameof(this.States), typeof(StateData[]))).ToReadOnlyArray();
this.Transitions = ((Transition[])info.GetValue(nameof(this.Transitions), typeof(Transition[]))).ToReadOnlyArray();
if (!this.IsConsistent())
{

Просмотреть файл

@ -329,24 +329,24 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// <summary>
/// A mapping from state ids to weights. This array is sorted by state Id.
/// </summary>
private readonly ImmutableArray<WeightedState> weightedStates;
private readonly ReadOnlyArray<WeightedState> weightedStates;
private readonly int singleStateIndex;
public WeightedStateSet(int stateIndex)
{
this.weightedStates = default(ImmutableArray<WeightedState>);
this.weightedStates = default(ReadOnlyArray<WeightedState>);
this.singleStateIndex = stateIndex;
}
public WeightedStateSet(ImmutableArray<WeightedState> weightedStates)
public WeightedStateSet(ReadOnlyArray<WeightedState> weightedStates)
{
Debug.Assert(weightedStates.Count > 0);
Debug.Assert(IsSorted(weightedStates));
if (weightedStates.Count == 1)
{
Debug.Assert(weightedStates[0].Weight == Weight.One);
this.weightedStates = default(ImmutableArray<WeightedState>);
this.weightedStates = default(ReadOnlyArray<WeightedState>);
this.singleStateIndex = weightedStates[0].Index;
}
else
@ -357,12 +357,12 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
}
public int Count =>
(this.weightedStates == default(ImmutableArray<WeightedState>))
(this.weightedStates == default(ReadOnlyArray<WeightedState>))
? 1
: this.weightedStates.Count;
public WeightedState this[int index] =>
(this.weightedStates == default(ImmutableArray<WeightedState>))
(this.weightedStates == default(ReadOnlyArray<WeightedState>))
? new WeightedState(this.singleStateIndex, Weight.One)
: this.weightedStates[index];
@ -444,7 +444,7 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// <summary>
/// Checks weather states array is sorted in ascending order by Index.
/// </summary>
private static bool IsSorted(ImmutableArray<WeightedState> array)
private static bool IsSorted(ReadOnlyArray<WeightedState> array)
{
for (var i = 1; i < array.Count; ++i)
{
@ -520,7 +520,7 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
MergeRepeatedEntries(weightsClone);
var maxWeight = NormalizeWeights(weightsClone);
return (new WeightedStateSet(weightsClone.ToImmutableArray()), maxWeight);
return (new WeightedStateSet(weightsClone.ToReadOnlyArray()), maxWeight);
}
private static void MergeRepeatedEntries(List<WeightedState> weightedStates)

Просмотреть файл

@ -24,17 +24,17 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// </remarks>
public struct State : IEquatable<State>
{
private readonly ImmutableArray<StateData> states;
private readonly ReadOnlyArray<StateData> states;
private readonly ImmutableArray<Transition> transitions;
private readonly ReadOnlyArray<Transition> transitions;
/// <summary>
/// Initializes a new instance of <see cref="State"/> class. Used internally by automaton implementation
/// to wrap StateData for use in public Automaton APIs.
/// </summary>
internal State(
ImmutableArray<StateData> states,
ImmutableArray<Transition> transitions,
ReadOnlyArray<StateData> states,
ReadOnlyArray<Transition> transitions,
int index)
{
this.states = states;
@ -57,8 +57,8 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// </summary>
public bool CanEnd => this.Data.CanEnd;
public ImmutableArraySegment<Transition> Transitions =>
new ImmutableArraySegment<Transition>(
public ReadOnlyArraySegment<Transition> Transitions =>
new ReadOnlyArraySegment<Transition>(
this.transitions,
this.Data.FirstTransitionIndex,
this.Data.TransitionsCount);

Просмотреть файл

@ -25,12 +25,12 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// <summary>
/// Cached value of this.owner.Data.states. Cached for performance.
/// </summary>
internal readonly ImmutableArray<StateData> states;
internal readonly ReadOnlyArray<StateData> states;
/// <summary>
/// Cached value of this.owner.Data.states. Cached for performance.
/// </summary>
internal readonly ImmutableArray<Transition> transitions;
internal readonly ReadOnlyArray<Transition> transitions;
/// <summary>
/// Initializes instance of <see cref="StateCollection"/>.

Просмотреть файл

@ -65,8 +65,8 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
/// <summary>
/// Cached states representation of states for zero automaton.
/// </summary>
private static readonly ImmutableArray<StateData> SingleState =
ImmutableArray.Create(new StateData(0, 0, Weight.Zero));
private static readonly ReadOnlyArray<StateData> SingleState =
ReadOnlyArray.Create(new StateData(0, 0, Weight.Zero));
/// <summary>
/// The maximum number of states an automaton can have.
@ -1678,7 +1678,7 @@ namespace Microsoft.ML.Probabilistic.Distributions.Automata
this.Data = new DataContainer(
0,
SingleState,
ImmutableArray<Transition>.Empty,
ReadOnlyArray<Transition>.Empty,
isEpsilonFree: true,
usesGroups: false,
isDeterminized: true,

Просмотреть файл

@ -142,7 +142,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
/// The probabilities need to be normalized. The character ranges need to be sorted.
/// The created objects takes ownership of the character range list.
/// </remarks>
private DiscreteChar(ImmutableArray<CharRange> ranges, int rangeCount) =>
private DiscreteChar(ReadOnlyArray<CharRange> ranges, int rangeCount) =>
this.data_ = Storage.Create(ranges);
private DiscreteChar(Storage storage) => this.data_ = storage;
@ -906,7 +906,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
/// Gets an array of character ranges with associated probabilities.
/// </summary>
/// <value>An array of character ranges with associated probabilities.</value>
public ImmutableArray<CharRange> Ranges => this.Data.Ranges;
public ReadOnlyArray<CharRange> Ranges => this.Data.Ranges;
/// <summary>
/// Creates a distribution which is uniform over all characters
@ -1347,7 +1347,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
}
internal static IEnumerable<CharRangePair> CombineRanges(
ImmutableArray<CharRange> ranges1, ImmutableArray<CharRange> ranges2)
ReadOnlyArray<CharRange> ranges1, ReadOnlyArray<CharRange> ranges2)
{
var rangeIndex1 = 0;
var rangeIndex2 = 0;
@ -1374,7 +1374,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
}
Weight ProcessRange(
ImmutableArray<CharRange> ranges,
ReadOnlyArray<CharRange> ranges,
int startInclusive,
ref int index,
ref int endExclusive)
@ -1434,7 +1434,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
/// <remarks>
/// This class is serializable but is not marked with <see cref="SerializableAttribute"/> and
/// <see cref="DataContractAttribute"/> because we have to implement serialization manually
/// due to Newtonsoft.Json not deserializing <see cref="ImmutableArray{T}"/> properly without
/// due to Newtonsoft.Json not deserializing <see cref="ReadOnlyArray{T}"/> properly without
/// "JsonObjectAttribute". Which can't be added because Infer.NET has no explicit dependency
/// on Newtonsoft.Json.
/// </remarks>
@ -1448,7 +1448,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
/// <remarks>
/// The character probabilities must be kept normalized by applying <see cref="StorageBuilder.NormalizeProbabilities"/> when necessary.
/// </remarks>
public ImmutableArray<CharRange> Ranges { get; }
public ReadOnlyArray<CharRange> Ranges { get; }
public char? Point { get; }
@ -1489,7 +1489,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
#region Constructor and factory methods
private Storage(
ImmutableArray<CharRange> ranges,
ReadOnlyArray<CharRange> ranges,
char? point,
CharClasses charClasses,
string regexRepresentation,
@ -1518,7 +1518,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
}
public static Storage CreateUncached(
ImmutableArray<CharRange> ranges,
ReadOnlyArray<CharRange> ranges,
char? point,
CharClasses charClasses = CharClasses.Unknown,
string regexRepresentation = null,
@ -1529,7 +1529,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
}
public static Storage Create(
ImmutableArray<CharRange> ranges,
ReadOnlyArray<CharRange> ranges,
CharClasses charClasses = CharClasses.Unknown,
string regexRepresentation = null,
string symbolRepresentation = null)
@ -1539,7 +1539,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
: CreateUncached(ranges, null, charClasses, regexRepresentation, symbolRepresentation);
}
public static Storage CreatePoint(char point, ImmutableArray<CharRange> ranges) =>
public static Storage CreatePoint(char point, ReadOnlyArray<CharRange> ranges) =>
StorageCache.GetPointMass(point, ranges);
public static Storage CreatePoint(char point) =>
@ -1624,7 +1624,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
#region Properties
// TODO: Assumes that there are no ranges with zero probability
private static bool IsRangesPointMass(ImmutableArray<CharRange> ranges) =>
private static bool IsRangesPointMass(ReadOnlyArray<CharRange> ranges) =>
ranges.Count > 0 && Math.Abs(ranges[0].Probability.LogValue - Weight.One.LogValue) < Eps;
/// <summary>
@ -1661,7 +1661,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
{
var ranges = (CharRange[]) info.GetValue(nameof(Ranges), typeof(CharRange[]));
var classes = (CharClasses) info.GetValue(nameof(CharClasses), typeof(CharClasses));
return Storage.Create(ranges.ToImmutableArray(), classes);
return Storage.Create(ranges.ToReadOnlyArray(), classes);
}
public void GetObjectData(SerializationInfo info)
@ -1691,7 +1691,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
var charClasses = (CharClasses)readInt32();
return Storage.Create(ranges.ToImmutableArray(), charClasses);
return Storage.Create(ranges.ToReadOnlyArray(), charClasses);
}
#endregion
@ -1873,7 +1873,7 @@ namespace Microsoft.ML.Probabilistic.Distributions
string WordCharRanges(string baseRange) => baseRange + "09__";
Uniform = Storage.CreateUncached(
ImmutableArray.Create(new CharRange(char.MinValue, CharRangeEndExclusive, UniformProb)),
ReadOnlyArray.Create(new CharRange(char.MinValue, CharRangeEndExclusive, UniformProb)),
null,
CharClasses.Uniform,
UniformRegexRepresentation,
@ -1906,14 +1906,14 @@ namespace Microsoft.ML.Probabilistic.Distributions
PointMasses = new Storage[CharRangeEndExclusive];
}
public static Storage GetPointMass(char point, ImmutableArray<CharRange>? ranges)
public static Storage GetPointMass(char point, ReadOnlyArray<CharRange>? ranges)
{
if (PointMasses[point] == null)
{
PointMasses[point] = Storage.CreateUncached(
ranges.HasValue
? ranges.Value
: ImmutableArray.Create(new CharRange(point, point + 1, Weight.One)),
: ReadOnlyArray.Create(new CharRange(point, point + 1, Weight.One)),
point);
}
@ -2074,13 +2074,13 @@ namespace Microsoft.ML.Probabilistic.Distributions
return
maximumProbability.HasValue
? Storage.CreateUncached(
this.ranges.ToImmutableArray(),
this.ranges.ToReadOnlyArray(),
null,
this.charClasses,
this.regexRepresentation,
this.symbolRepresentation)
: Storage.Create(
this.ranges.ToImmutableArray(),
this.ranges.ToReadOnlyArray(),
this.charClasses,
this.regexRepresentation,
this.symbolRepresentation);

Просмотреть файл

@ -929,10 +929,10 @@ namespace Microsoft.ML.Probabilistic.Tests
var automaton1 = StringAutomaton.FromData(
new StringAutomaton.DataContainer(
0,
ImmutableArray.Create(
ReadOnlyArray.Create(
new StringAutomaton.StateData(0, 1, Weight.One),
new StringAutomaton.StateData(1, 0, Weight.One)),
ImmutableArray.Create(
ReadOnlyArray.Create(
new StringAutomaton.Transition(DiscreteChar.PointMass('a'), Weight.One, 1)),
isEpsilonFree: true,
usesGroups: false,
@ -947,8 +947,8 @@ namespace Microsoft.ML.Probabilistic.Tests
var automaton2 = StringAutomaton.FromData(
new StringAutomaton.DataContainer(
0,
ImmutableArray.Create(new StringAutomaton.StateData(0, 0, Weight.Zero)),
ImmutableArray<StringAutomaton.Transition>.Empty,
ReadOnlyArray.Create(new StringAutomaton.StateData(0, 0, Weight.Zero)),
ReadOnlyArray<StringAutomaton.Transition>.Empty,
isEpsilonFree: true,
usesGroups: false,
isDeterminized: true,
@ -961,8 +961,8 @@ namespace Microsoft.ML.Probabilistic.Tests
() => StringAutomaton.FromData(
new StringAutomaton.DataContainer(
0,
ImmutableArray<StringAutomaton.StateData>.Empty,
ImmutableArray<StringAutomaton.Transition>.Empty,
ReadOnlyArray<StringAutomaton.StateData>.Empty,
ReadOnlyArray<StringAutomaton.Transition>.Empty,
isEpsilonFree: true,
usesGroups: false,
isDeterminized: false,
@ -974,8 +974,8 @@ namespace Microsoft.ML.Probabilistic.Tests
() => StringAutomaton.FromData(
new StringAutomaton.DataContainer(
0,
ImmutableArray.Create(new StringAutomaton.StateData(0, 0, Weight.Zero)),
ImmutableArray<StringAutomaton.Transition>.Empty,
ReadOnlyArray.Create(new StringAutomaton.StateData(0, 0, Weight.Zero)),
ReadOnlyArray<StringAutomaton.Transition>.Empty,
isEpsilonFree: false,
usesGroups: false,
isDeterminized: null,
@ -987,8 +987,8 @@ namespace Microsoft.ML.Probabilistic.Tests
() => StringAutomaton.FromData(
new StringAutomaton.DataContainer(
0,
ImmutableArray.Create(new StringAutomaton.StateData(0, 1, Weight.Zero)),
ImmutableArray.Create(new StringAutomaton.Transition(Option.None, Weight.One, 1)),
ReadOnlyArray.Create(new StringAutomaton.StateData(0, 1, Weight.Zero)),
ReadOnlyArray.Create(new StringAutomaton.Transition(Option.None, Weight.One, 1)),
isEpsilonFree: false,
usesGroups: false,
isDeterminized: null,
@ -1000,8 +1000,8 @@ namespace Microsoft.ML.Probabilistic.Tests
() => StringAutomaton.FromData(
new StringAutomaton.DataContainer(
0,
ImmutableArray.Create(new StringAutomaton.StateData(0, 1, Weight.One)),
ImmutableArray.Create(new StringAutomaton.Transition(Option.None, Weight.One, 2)),
ReadOnlyArray.Create(new StringAutomaton.StateData(0, 1, Weight.One)),
ReadOnlyArray.Create(new StringAutomaton.Transition(Option.None, Weight.One, 2)),
true,
false,
isDeterminized: null,