Skip to content

Commit 163a4c9

Browse files
ooplesclaude
andcommitted
style: add readonly modifiers to fields in internal classes
Added readonly modifiers to fields that are only assigned in constructors: - ConvLayer<T>: _kernels, _biases - TransformerBlock<T>: _weights - InformerEncoderBlock<T>: _attentionWeights, _ffnWeights - InformerDecoderBlock<T>: _selfAttentionWeights, _crossAttentionWeights 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent b355fce commit 163a4c9

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/TimeSeries/AnomalyDetection/DeepANT.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,8 @@ internal class ConvLayer<T>
343343
private readonly int _inputChannels;
344344
private readonly int _outputChannels;
345345
private readonly int _kernelSize;
346-
private Matrix<T> _kernels;
347-
private Vector<T> _biases;
346+
private readonly Matrix<T> _kernels;
347+
private readonly Vector<T> _biases;
348348

349349
public int ParameterCount => _kernels.Rows * _kernels.Columns + _biases.Length;
350350

src/TimeSeries/ChronosFoundationModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ public override T PredictSingle(Vector<T> input)
196196
public Dictionary<double, Vector<T>> ForecastWithQuantiles(Vector<T> history, double[] quantiles, int numSamples = 100)
197197
{
198198
var samples = new List<Vector<T>>();
199-
var random = new Random();
200199

201200
for (int s = 0; s < numSamples; s++)
202201
{
@@ -343,7 +342,7 @@ public ChronosOptions(ChronosOptions<T> other)
343342
internal class TransformerBlock<T>
344343
{
345344
private readonly INumericOperations<T> _numOps;
346-
private Matrix<T> _weights;
345+
private readonly Matrix<T> _weights;
347346

348347
public int ParameterCount => _weights.Rows * _weights.Columns;
349348

src/TimeSeries/InformerModel.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ internal class InformerEncoderBlock<T>
241241
{
242242
private readonly INumericOperations<T> _numOps;
243243
private readonly int _embeddingDim;
244-
private Matrix<T> _attentionWeights;
245-
private Matrix<T> _ffnWeights;
244+
private readonly Matrix<T> _attentionWeights;
245+
private readonly Matrix<T> _ffnWeights;
246246

247247
public int ParameterCount => _attentionWeights.Rows * _attentionWeights.Columns +
248248
_ffnWeights.Rows * _ffnWeights.Columns;
@@ -292,8 +292,8 @@ internal class InformerDecoderBlock<T>
292292
{
293293
private readonly INumericOperations<T> _numOps;
294294
private readonly int _embeddingDim;
295-
private Matrix<T> _selfAttentionWeights;
296-
private Matrix<T> _crossAttentionWeights;
295+
private readonly Matrix<T> _selfAttentionWeights;
296+
private readonly Matrix<T> _crossAttentionWeights;
297297

298298
public int ParameterCount => _selfAttentionWeights.Rows * _selfAttentionWeights.Columns +
299299
_crossAttentionWeights.Rows * _crossAttentionWeights.Columns;

0 commit comments

Comments
 (0)