Skip to content

Commit e8b9662

Browse files
Merge pull request #217 from observerly/refactor/vcurve/Point
refactor: amend Point{} to X, Y in vcurve module in @observerly/iris
2 parents 315eebd + f638f17 commit e8b9662

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

pkg/vcurve/vcurve.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010

1111
// Point is a data point with x and y coordinates.
1212
type Point struct {
13-
x float64
14-
y float64
13+
X float64
14+
Y float64
1515
}
1616

1717
// VCurve is a struct that holds the data points for the V-curve.
@@ -25,8 +25,8 @@ type VCurveParams struct {
2525
B float64
2626
C float64
2727
D float64
28-
x []float64
29-
y []float64
28+
X []float64
29+
Y []float64
3030
}
3131

3232
/*
@@ -43,8 +43,8 @@ func NewHyperbolicVCurve(data VCurve) *VCurveParams {
4343

4444
// A single loop to populate the slices
4545
for _, point := range data.Points {
46-
dataX = append(dataX, point.x)
47-
dataY = append(dataY, point.y)
46+
dataX = append(dataX, point.X)
47+
dataY = append(dataY, point.Y)
4848
}
4949

5050
// Get the initial guess for the parameter, for A, we take the mean value of the yData:
@@ -61,8 +61,8 @@ func NewHyperbolicVCurve(data VCurve) *VCurveParams {
6161
B: B,
6262
C: C,
6363
D: 0,
64-
x: dataX,
65-
y: dataY,
64+
X: dataX,
65+
Y: dataY,
6666
}
6767
}
6868

@@ -108,7 +108,7 @@ LevenbergMarquardtOptimisation optimizes the hyperbolic function using the Leven
108108
func (p *VCurveParams) LevenbergMarquardtOptimisation() (VCurveParams, error) {
109109
// Setting up the optimizer:
110110
problem := optimize.Problem{
111-
Func: objectiveFunc(p.x, p.y),
111+
Func: objectiveFunc(p.X, p.Y),
112112
}
113113

114114
// Create custom settings for the optimization:

pkg/vcurve/vcurve_test.go

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,27 @@ import (
66

77
var (
88
points = []Point{
9-
{x: 29000, y: 40.5},
10-
{x: 29100, y: 36.2},
11-
{x: 29200, y: 31.4},
12-
{x: 29300, y: 28.6},
13-
{x: 29400, y: 23.1},
14-
{x: 29500, y: 21.2},
15-
{x: 29600, y: 16.6},
16-
{x: 29700, y: 13.7},
17-
{x: 29800, y: 6.21},
18-
{x: 29900, y: 4.21},
19-
{x: 30000, y: 3.98},
20-
{x: 30100, y: 4.01},
21-
{x: 30200, y: 4.85},
22-
{x: 30300, y: 11.1},
23-
{x: 30400, y: 15.3},
24-
{x: 30500, y: 22.1},
25-
{x: 30600, y: 21.9},
26-
{x: 30700, y: 27.4},
27-
{x: 30800, y: 32.1},
28-
{x: 30900, y: 36.5},
29-
{x: 31000, y: 39.7},
9+
{X: 29000, Y: 40.5},
10+
{X: 29100, Y: 36.2},
11+
{X: 29200, Y: 31.4},
12+
{X: 29300, Y: 28.6},
13+
{X: 29400, Y: 23.1},
14+
{X: 29500, Y: 21.2},
15+
{X: 29600, Y: 16.6},
16+
{X: 29700, Y: 13.7},
17+
{X: 29800, Y: 6.21},
18+
{X: 29900, Y: 4.21},
19+
{X: 30000, Y: 3.98},
20+
{X: 30100, Y: 4.01},
21+
{X: 30200, Y: 4.85},
22+
{X: 30300, Y: 11.1},
23+
{X: 30400, Y: 15.3},
24+
{X: 30500, Y: 22.1},
25+
{X: 30600, Y: 21.9},
26+
{X: 30700, Y: 27.4},
27+
{X: 30800, Y: 32.1},
28+
{X: 30900, Y: 36.5},
29+
{X: 31000, Y: 39.7},
3030
}
3131
)
3232

0 commit comments

Comments
 (0)