-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7c90981
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package data | ||
|
||
import ( | ||
"bufio" | ||
"math" | ||
"os" | ||
"strconv" | ||
) | ||
|
||
type Zeros map[float64]float64 | ||
|
||
func check(e error) { | ||
if e != nil { | ||
panic(e) | ||
} | ||
} | ||
|
||
func ImportZeros(filename string) Zeros { | ||
f, err := os.Open(filename) | ||
check(err) | ||
|
||
z := make(Zeros) | ||
scanner := bufio.NewScanner(f) | ||
for scanner.Scan() { | ||
text := scanner.Text() | ||
number, parseErr := strconv.ParseFloat(text, 64) | ||
z[number] = number - math.Floor(number) | ||
check(parseErr) | ||
} | ||
check(scanner.Err()) | ||
return z | ||
} | ||
|
||
func ExportData(data) { | ||
} | ||
|
||
func floatsEqual(a float64, b float64) bool { | ||
Epsilon := 0.000001 | ||
if math.Abs(a-b) < Epsilon { | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
// fractional differences | ||
func closestZero(z Zeros, zero float64) float64 { | ||
} | ||
|
||
func fractionalDifferences(z Zeros) (float64, float64) { | ||
} | ||
|
||
// zeros epsilon close to other | ||
func fCloseTo(z Zeros, zero float64, epsilon float64) int { | ||
} | ||
|
||
func zerosFCloseTo(z Zeros, epsilon float64) float64 { | ||
} | ||
|
||
// histogram creating | ||
func createHistogram(z Zeros, epsilon float64) map[int]float64 { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package data | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestFloatsEqual(t *testing.T) { | ||
const inA, inB, out = 1.2, 1.2, true | ||
if x := floatsEqual(inA, inB); x != out { | ||
t.Errorf("floatsEqual(%v, %v) = %v, want %v", inA, inB, x, out) | ||
} | ||
|
||
const inA2, inB2, out2 = 1.2, 1.3, false | ||
if x := floatsEqual(inA2, inB2); x != out2 { | ||
t.Errorf("floatsEqual(%v, %v) = %v, want %v", inA2, inB2, x, out2) | ||
} | ||
} | ||
|
||
func TestImportZeros(t *testing.T) { | ||
const in string = "test.dat" | ||
out := Zeros{3.14: 0.14, 2.71: 0.71} | ||
x := ImportZeros(in) | ||
for k, v := range x { | ||
if !floatsEqual(out[k], v) { | ||
t.Errorf("ImportZeros(%v) = %v, want %v", in, x, out) | ||
} | ||
} | ||
} | ||
|
||
func TestClosestZero(t *testing.T) { | ||
|
||
} | ||
|
||
func TestFractionalDifferences(t *testing.T) { | ||
|
||
} | ||
|
||
func TestFCloseTo(t *testing.T) { | ||
|
||
} | ||
|
||
func TestZerosFCloseTo(t *testing.T) { | ||
|
||
} | ||
|
||
func TestCreateHistogram(t *testing.T) { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
3.14 | ||
2.71 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package main | ||
|
||
func main() { | ||
z := data.ImportZeros("zeros6") | ||
|
||
} |