Skip to content

Commit

Permalink
- bug fix in main.go (called wrong function)
Browse files Browse the repository at this point in the history
- added comments to make_continuous
- bug fix in type_parameter.go (yaml.v1 changed to yamlk.v2"
  • Loading branch information
kzahedi committed Sep 10, 2018
1 parent 55458f9 commit c7c62a8
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 14 deletions.
12 changes: 12 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "create binaries",
"type": "shell",
"command": "sh sh/create_binaries.sh"
}
]
}
Binary file modified bin/linux/gomi
Binary file not shown.
Binary file modified bin/macos/gomi
Binary file not shown.
Binary file modified bin/windows/gomi.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func main() {
p.SetIterations(*iterationsPtr)
}

CheckParameters()
p.CheckParameters()

if p.Verbose == true {
fmt.Println(p)
Expand Down
6 changes: 6 additions & 0 deletions make_continuous.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package main
// W2, W1, S1, A1 continuous
////////////////////////////////////////////////////////////////////////////////

// MakeW2W1S1A1 returns a slice with (w',w,s,a) and list of indices, which
// indicate which columns contain which information
func MakeW2W1S1A1(d Data, p Parameters) ([][]float64, []int, []int, []int, []int) {
checkW(d)
checkA(d)
Expand Down Expand Up @@ -62,6 +64,8 @@ func MakeW2W1S1A1(d Data, p Parameters) ([][]float64, []int, []int, []int, []int
// W2, W1, A1 continuous
////////////////////////////////////////////////////////////////////////////////

// MakeW2W1A1 returns a slice with (w',w,a) and list of indices, which
// indicate which columns contain which information
func MakeW2W1A1(d Data, p Parameters) ([][]float64, []int, []int, []int) {
checkW(d)
checkA(d)
Expand Down Expand Up @@ -108,6 +112,8 @@ func MakeW2W1A1(d Data, p Parameters) ([][]float64, []int, []int, []int) {
// W2, W1, S1 continuous
////////////////////////////////////////////////////////////////////////////////

// MakeW2W1S1 returns a slice with (w',w,s) and list of indices, which
// indicate which columns contain which information
func MakeW2W1S1(d Data, p Parameters) ([][]float64, []int, []int, []int) {
checkW(d)
checkS(d)
Expand Down
46 changes: 33 additions & 13 deletions type_parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"os"

yaml "gopkg.in/yaml.v1"
yaml "gopkg.in/yaml.v2"
)

type Parameters struct {
Expand Down Expand Up @@ -291,24 +291,44 @@ func (p *Parameters) SetConfigFile(file string) {
p.Verbose = true
}

func checkFile(filename string) bool {
if filename == "" {
return true
}
if _, err := os.Stat(filename); os.IsNotExist(err) {
return false
}
return true
}

// CheckParameters checks for the sanity of the command line parameters
func (p *Parameters) CheckParameters() {
errorMsg := ""
hasError := false
if _, err := os.Stat(p.File); os.IsNotExist(err) {
hasError = true
errorMsg = fmt.Sprintf("File %f not found\n", p.File)
var err bool

err = checkFile(p.GlobalFile)
hasError = err || hasError
if err == true {
errorMsg = fmt.Sprintf("Global file %s not found\n", p.GlobalFile)
}
if _, err := os.Stat(p.WFile); os.IsNotExist(err) {
hasError = true
errorMsg = fmt.Sprintf("%sW File %f not found\n", p.WFile)

err = checkFile(p.WFile)
hasError = err || hasError
if err == true {
errorMsg = fmt.Sprintf("%sWorld file %s not found\n", errorMsg, p.WFile)
}
if _, err := os.Stat(p.SFile); os.IsNotExist(err) {
hasError = true
errorMsg = fmt.Sprintf("%sS File %f not found\n", p.SFile)

err = checkFile(p.SFile)
hasError = err || hasError
if err == true {
errorMsg = fmt.Sprintf("%sSensor file %s not found\n", errorMsg, p.SFile)
}
if _, err := os.Stat(p.AFile); os.IsNotExist(err) {
hasError = true
errorMsg = fmt.Sprintf("%sA File %f not found\n", p.AFile)

err = checkFile(p.AFile)
hasError = err || hasError
if err == true {
errorMsg = fmt.Sprintf("%sActuator file %s not found\n", errorMsg, p.AFile)
}

if hasError == true {
Expand Down

0 comments on commit c7c62a8

Please sign in to comment.