Skip to content

Commit df5779b

Browse files
author
Jack Dermody
committed
changed table strings to use 4 bytes instead of 2 by default
1 parent f080ebf commit df5779b

18 files changed

+555
-324
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,4 @@
7070
/BrightData.DataFrame/obj
7171
/BrightData.DataFrame/bin
7272
.aider*
73+
/.idea/.idea.BrightWire/.idea

BrightData/Analysis/CastToDoubleNumericAnalysis.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ internal class ConvertToDoubleNumericAnalysis<T>(uint writeCount = Consts.MaxWri
1616

1717
public NumericAnalyser<double> Analysis { get; } = new(writeCount);
1818

19-
public void Add(T val)
19+
public void Add(T obj)
2020
{
21-
Analysis.Add(_converter.Convert(val));
21+
Analysis.Add(_converter.Convert(obj));
2222
}
2323

2424
public void AddObject(object obj)

BrightData/Analysis/DimensionAnalyser.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,8 @@ internal class DimensionAnalyser : IDataAnalyser<IReadOnlyTensor<float>>
1919
public void Add(IReadOnlyTensor<float> obj)
2020
{
2121
uint x = 0, y = 0, z = 0, c = 0;
22-
if (obj is IHaveTensor4DDimensions tensor4D) {
23-
if (TensorCount == null || tensor4D.Count > TensorCount)
24-
TensorCount = c = tensor4D.ColumnCount;
25-
}
26-
if (obj is IHaveTensor3DDimensions tensor3D) {
27-
if (ZDimension == null || tensor3D.Depth > ZDimension)
28-
ZDimension = z = tensor3D.Depth;
29-
}
22+
if (obj is IHaveTensor4DDimensions tensor4D && (TensorCount == null || tensor4D.Count > TensorCount)) TensorCount = c = tensor4D.ColumnCount;
23+
if (obj is IHaveTensor3DDimensions tensor3D && (ZDimension == null || tensor3D.Depth > ZDimension)) ZDimension = z = tensor3D.Depth;
3024
if (obj is IHaveMatrixDimensions matrix) {
3125
if (XDimension == null || matrix.ColumnCount > XDimension)
3226
XDimension = x = matrix.ColumnCount;

BrightData/Analysis/NormalisationModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public NormalisationModel(NormalizationType type, MetaData analysedMetaData)
4343
throw new NotImplementedException();
4444
}
4545
else
46-
throw new Exception("Metadata did not indicate numeric data that has been analyzed");
46+
throw new InvalidOperationException("Metadata did not indicate numeric data that has been analyzed");
4747

4848
Divide = divide;
4949
Subtract = subtract;

BrightData/Analysis/NumericAnalyser.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,30 @@ internal class NumericAnalyser<T>(uint writeCount = Consts.MaxWriteCount) : Onli
1717
T _mode, _l2;
1818
ulong _highestCount;
1919

20-
public override void Add(T val)
20+
public override void Add(T value)
2121
{
22-
base.Add(val);
22+
base.Add(value);
2323

2424
// find the min and the max
25-
if (val < Min)
26-
Min = val;
27-
if (val > Max)
28-
Max = val;
25+
if (value < Min)
26+
Min = value;
27+
if (value > Max)
28+
Max = value;
2929

3030
// add to distinct values
31-
if (_distinct.TryGetValue(val, out var count))
32-
_distinct[val] = ++count;
31+
if (_distinct.TryGetValue(value, out var count))
32+
_distinct[value] = ++count;
3333
else
34-
_distinct.Add(val, count = 1);
34+
_distinct.Add(value, count = 1);
3535

3636
if (count > _highestCount) {
3737
_highestCount = count;
38-
_mode = val;
38+
_mode = value;
3939
}
4040

4141
// calculate norms
42-
L1Norm += T.Abs(val);
43-
_l2 += val * val;
42+
L1Norm += T.Abs(value);
43+
_l2 += value * value;
4444
}
4545

4646
public void Append(ReadOnlySpan<T> span)

BrightData/BrightData.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949

5050
<ItemGroup>
5151
<PackageReference Include="CommunityToolkit.HighPerformance" Version="8.4.0" />
52+
<PackageReference Include="DotNext" Version="5.26.0" />
53+
<PackageReference Include="DotNext.IO" Version="5.26.0" />
54+
<PackageReference Include="DotNext.Unsafe" Version="5.26.0" />
5255
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.2" />
5356
</ItemGroup>
5457

0 commit comments

Comments
 (0)