From a36c63a1b3b0e492f393adb24160b65b69204e2c Mon Sep 17 00:00:00 2001 From: douira Date: Fri, 21 Feb 2025 20:16:38 +0100 Subject: [PATCH] replace single-letter type variable names with more descriptive ones --- .../estimation/Average1DEstimator.java | 8 ++-- .../chunk/compile/estimation/Estimator.java | 42 +++++++++---------- .../compile/estimation/Linear2DEstimator.java | 6 +-- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Average1DEstimator.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Average1DEstimator.java index 02c3a71eb8..a04b8ac632 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Average1DEstimator.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Average1DEstimator.java @@ -4,7 +4,7 @@ import java.util.Locale; -public abstract class Average1DEstimator extends Estimator, Average1DEstimator.ValueBatch, Void, Long, Average1DEstimator.Average> { +public abstract class Average1DEstimator extends Estimator, Average1DEstimator.ValueBatch, Void, Long, Average1DEstimator.Average> { private final float newDataRatio; private final long initialEstimate; @@ -39,7 +39,7 @@ public float getAverage() { } @Override - protected ValueBatch createNewDataBatch() { + protected ValueBatch createNewDataBatch() { return new ValueBatch<>(); } @@ -79,11 +79,11 @@ public String toString() { } @Override - protected Average createNewModel() { + protected Average createNewModel() { return new Average<>(this.newDataRatio, this.initialEstimate); } - public Long predict(C category) { + public Long predict(Category category) { return super.predict(category, null); } } diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Estimator.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Estimator.java index c9abad07a8..fd187d7957 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Estimator.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Estimator.java @@ -5,22 +5,22 @@ /** * This generic model learning class that can be used to estimate values based on a set of data points. It performs batch-wise model updates. The actual data aggregation and model updates are delegated to the implementing classes. The estimator stores multiple models in a map, one for each category. * - * @param The type of the category key - * @param A data point contains a category and one piece of data - * @param A data batch contains multiple data points - * @param The input to the model - * @param The output of the model - * @param The model that is used to predict values + * @param The type of the category key + * @param A data point contains a category and one piece of data + * @param A data batch contains multiple data points + * @param The input to the model + * @param The output of the model + * @param The model that is used to predict values */ public abstract class Estimator< - C, - D extends Estimator.DataPoint, - B extends Estimator.DataBatch, - I, - O, - M extends Estimator.Model> { - protected final Map models = createMap(); - protected final Map batches = createMap(); + Category, + Point extends Estimator.DataPoint, + Batch extends Estimator.DataBatch, + Input, + Output, + Model extends Estimator.Model> { + protected final Map models = createMap(); + protected final Map batches = createMap(); protected interface DataBatch { void addDataPoint(D input); @@ -38,13 +38,13 @@ protected interface Model> { O predict(I input); } - protected abstract B createNewDataBatch(); + protected abstract Batch createNewDataBatch(); - protected abstract M createNewModel(); + protected abstract Model createNewModel(); - protected abstract Map createMap(); + protected abstract Map createMap(); - public void addData(D data) { + public void addData(Point data) { var category = data.category(); var batch = this.batches.get(category); if (batch == null) { @@ -54,7 +54,7 @@ public void addData(D data) { batch.addDataPoint(data); } - private M ensureModel(C category) { + private Model ensureModel(Category category) { var model = this.models.get(category); if (model == null) { model = this.createNewModel(); @@ -77,11 +77,11 @@ public void updateModels() { }); } - public O predict(C category, I input) { + public Output predict(Category category, Input input) { return this.ensureModel(category).predict(input); } - public String toString(C category) { + public String toString(Category category) { var model = this.models.get(category); if (model == null) { return "-"; diff --git a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Linear2DEstimator.java b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Linear2DEstimator.java index 159d08f067..de9d68a989 100644 --- a/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Linear2DEstimator.java +++ b/common/src/main/java/net/caffeinemc/mods/sodium/client/render/chunk/compile/estimation/Linear2DEstimator.java @@ -4,7 +4,7 @@ import java.util.Locale; -public abstract class Linear2DEstimator extends Estimator, Linear2DEstimator.LinearRegressionBatch, Long, Long, Linear2DEstimator.LinearFunction> { +public abstract class Linear2DEstimator extends Estimator, Linear2DEstimator.LinearRegressionBatch, Long, Long, Linear2DEstimator.LinearFunction> { private final float newDataRatio; private final int initialSampleTarget; private final long initialOutput; @@ -34,7 +34,7 @@ public void reset() { } @Override - protected LinearRegressionBatch createNewDataBatch() { + protected LinearRegressionBatch createNewDataBatch() { return new LinearRegressionBatch<>(); } @@ -137,7 +137,7 @@ public String toString() { } @Override - protected LinearFunction createNewModel() { + protected LinearFunction createNewModel() { return new LinearFunction<>(this.newDataRatio, this.initialSampleTarget, this.initialOutput); } }