Skip to content

Commit 989ae6d

Browse files
Format constant.go comments for pkg.go.dev (#32)
* Initial plan * Format comments in constant.go to follow pkg.go.dev guidelines Co-authored-by: kwesiRutledge <9002730+kwesiRutledge@users.noreply.github.com> * Move constant comments inside const block per Go conventions Co-authored-by: kwesiRutledge <9002730+kwesiRutledge@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: kwesiRutledge <9002730+kwesiRutledge@users.noreply.github.com>
1 parent 8a5ff46 commit 989ae6d

1 file changed

Lines changed: 21 additions & 46 deletions

File tree

optim/constant.go

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,53 +6,47 @@ import (
66
"gonum.org/v1/gonum/mat"
77
)
88

9-
// Integer constants represnting commonly used numbers. Makes for better
10-
// readability
119
const (
10+
// Zero is a constant expression representing the value 0.
1211
Zero = K(0)
13-
One = K(1)
12+
// One is a constant expression representing the value 1.
13+
One = K(1)
1414
)
1515

16-
// K is a constant expression type for an MIP. K for short ¯\_(ツ)_/¯
16+
// K is a constant expression type for an MIP (Mixed Integer Program).
1717
type K float64
1818

19-
/*
20-
Variables
21-
Description:
22-
23-
Shares all variables included in the expression that is K.
24-
It is a constant, so there are none.
25-
*/
19+
// Variables returns all variables included in the expression.
20+
// For constant K, there are no variables, so it returns an empty slice.
2621
func (c K) Variables() []Variable {
2722
return []Variable{}
2823
}
2924

30-
// NumVars returns the number of variables in the expression. For constants,
31-
// this is always 0
25+
// NumVars returns the number of variables in the expression.
26+
// For constant K, this is always 0.
3227
func (c K) NumVars() int {
3328
return 0
3429
}
3530

36-
// Vars returns a slice of the Var ids in the expression. For constants,
37-
// this is always nil
31+
// IDs returns a slice of the variable IDs in the expression.
32+
// For constant K, this is always nil.
3833
func (c K) IDs() []uint64 {
3934
return nil
4035
}
4136

42-
// Coeffs returns a slice of the coefficients in the expression. For constants,
43-
// this is always nil
37+
// Coeffs returns a slice of the coefficients in the expression.
38+
// For constant K, this is always nil.
4439
func (c K) Coeffs() []float64 {
4540
return nil
4641
}
4742

48-
// Constant returns the constant additive value in the expression. For
49-
// constants, this is just the constants value
43+
// Constant returns the constant additive value in the expression.
44+
// For constant K, this is just the constant's value.
5045
func (c K) Constant() float64 {
5146
return float64(c)
5247
}
5348

54-
// Plus adds the current expression to another and returns the resulting
55-
// expression
49+
// Plus adds the current expression to another and returns the resulting expression.
5650
func (c K) Plus(rightIn interface{}, errors ...error) (Expression, error) {
5751
// Input Processing
5852
err := CheckErrors(errors)
@@ -83,30 +77,22 @@ func (c K) Plus(rightIn interface{}, errors ...error) (Expression, error) {
8377
}
8478
}
8579

86-
// LessEq returns a less than or equal to (<=) constraint between the
87-
// current expression and another
80+
// LessEq returns a less than or equal to (<=) constraint between the current expression and another.
8881
func (c K) LessEq(rightIn interface{}, errors ...error) (Constraint, error) {
8982
return c.Comparison(rightIn, SenseLessThanEqual, errors...)
9083
}
9184

92-
// GreaterEq returns a greater than or equal to (>=) constraint between the
93-
// current expression and another
85+
// GreaterEq returns a greater than or equal to (>=) constraint between the current expression and another.
9486
func (c K) GreaterEq(rightIn interface{}, errors ...error) (Constraint, error) {
9587
return c.Comparison(rightIn, SenseGreaterThanEqual, errors...)
9688
}
9789

98-
// Eq returns an equality (==) constraint between the current expression
99-
// and another
90+
// Eq returns an equality (==) constraint between the current expression and another.
10091
func (c K) Eq(rightIn interface{}, errors ...error) (Constraint, error) {
10192
return c.Comparison(rightIn, SenseEqual, errors...)
10293
}
10394

104-
/*
105-
Comparison
106-
Description:
107-
108-
This method compares the receiver with expression rhs in the sense provided by sense.
109-
*/
95+
// Comparison compares the receiver with expression rhs in the sense provided by sense.
11096
func (c K) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Constraint, error) {
11197
// InputProcessing
11298
err := CheckErrors(errors)
@@ -125,12 +111,7 @@ func (c K) Comparison(rhsIn interface{}, sense ConstrSense, errors ...error) (Co
125111
return ScalarConstraint{c, rhs, sense}, nil
126112
}
127113

128-
/*
129-
Multiply
130-
Description:
131-
132-
This method multiplies the input constant by another expression.
133-
*/
114+
// Multiply multiplies the input constant by another expression.
134115
func (c K) Multiply(term1 interface{}, errors ...error) (Expression, error) {
135116
// Constants
136117

@@ -248,13 +229,7 @@ func (c K) Transpose() Expression {
248229
return c
249230
}
250231

251-
/*
252-
ToSymbolic
253-
Description:
254-
255-
Converts the constant to a symbolic expression (i.e., one that uses the
256-
symbolic math toolbox).
257-
*/
232+
// ToSymbolic converts the constant to a symbolic expression (i.e., one that uses the symbolic math toolbox).
258233
func (c K) ToSymbolic() (symbolic.Expression, error) {
259234
return symbolic.K(c), nil
260235
}

0 commit comments

Comments
 (0)