Skip to content

Commit

Permalink
Remove unused type ConflictingEvidenceError (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange-42 authored Jul 8, 2024
1 parent e572068 commit 65ed0d8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 41 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [[unpublished]](https://github.com/mlange-42/bbn/compare/v0.6.0...main)

### Other

* Removes unused type `ConflictingEvidenceError` (#87)

## [[v0.6.0]](https://github.com/mlange-42/bbn/compare/v0.5.0...v0.6.0)

### Features
Expand Down
29 changes: 29 additions & 0 deletions network.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package bbn

import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"

"github.com/mlange-42/bbn/ve"
)
Expand Down Expand Up @@ -102,6 +105,32 @@ func New(name string, info string, variables []Variable, factors []Factor) (*Net
return net, nil
}

// FromFile reads a [Network] from an YAML or XML file.
func FromFile(path string) (*Network, []Variable, error) {
data, err := os.ReadFile(path)
if err != nil {
return nil, nil, err
}
ext := filepath.Ext(path)

switch strings.ToLower(ext) {
case ".yml":
n, err := FromYAML(data)
if err != nil {
return nil, nil, err
}
return n, n.variables, nil
case ".xml", ".bifxml":
n, err := FromBIFXML(data)
if err != nil {
return nil, nil, err
}
return n, n.variables, nil
default:
return nil, nil, fmt.Errorf("unsupported file format '%s'", ext)
}
}

// prepareVariables, called from the constructor.
func (n *Network) prepareVariables() error {
varNames := map[string]*Variable{}
Expand Down
41 changes: 0 additions & 41 deletions util.go

This file was deleted.

0 comments on commit 65ed0d8

Please sign in to comment.