Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
lib/operations: Range is int, not int64
Browse files Browse the repository at this point in the history
  • Loading branch information
tharvik committed Feb 25, 2020
1 parent a7377d0 commit e1197b0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/client/survey.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ func surveySetOperation(c *cli.Context) error {
return errors.New("range should be ','-separated")
}

min, err := strconv.ParseInt(splitted[0], 10, 64)
min, err := strconv.ParseInt(splitted[0], 10, 0)
if err != nil {
return err
}

max, err := strconv.ParseInt(splitted[1], 10, 64)
max, err := strconv.ParseInt(splitted[1], 10, 0)
if err != nil {
return err
}

parsedRange = &cmd.Range{Min: min, Max: max}
parsedRange = &cmd.Range{Min: int(min), Max: int(max)}
}

conf, err := readConfigFrom(os.Stdin)
Expand Down
2 changes: 1 addition & 1 deletion cmd/index.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

// Range is a text serialisable width.
type Range struct{ Min, Max int64 }
type Range struct{ Min, Max int }

// Operation is a text serialisable lib.Operation.
type Operation struct {
Expand Down
4 changes: 2 additions & 2 deletions lib/operations/frequency_count.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (FrequencyCount) MarshalID() [8]byte {
}

// NewFrequencyCount creates a new FrequencyCount bound to the given range.
func NewFrequencyCount(min, max int64) (FrequencyCount, error) {
func NewFrequencyCount(min, max int) (FrequencyCount, error) {
if min > max {
return FrequencyCount{}, errors.New("given minimum is greater than maximum")
}
Expand All @@ -33,7 +33,7 @@ func (fc FrequencyCount) ExecuteOnProvider(loaded [][]float64) ([]float64, error
}

converted := floatsToInts(loaded[0])
freqCount := libdrynxencoding.ExecuteFreqCountOnProvider(converted, fc.min, fc.max)
freqCount := libdrynxencoding.ExecuteFreqCountOnProvider(converted, int64(fc.min), int64(fc.max))
ret := make([]float64, len(freqCount))
for i, v := range freqCount {
ret[i] = float64(v)
Expand Down
6 changes: 2 additions & 4 deletions lib/operations/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ func intsToFloats(arr []int64) []float64 {
return ret
}

// Range represents a width between two int64
type Range struct {
min, max int64
}
// Range represents a width between two int
type Range struct{ min, max int }

// MarshalBinary encodes to binary
func (r Range) MarshalBinary() ([]byte, error) {
Expand Down

0 comments on commit e1197b0

Please sign in to comment.