variables

package
v0.0.0-...-03ea0d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

View Source
const Zero = ID("0")

Zero defines the zero id constant assigned to the ignored variable.

Variables

This section is empty.

Functions

func Set

func Set(d *Variables)

Types

type ID

type ID string

ID defines the id of a variable.

type Type

type Type string

Type defines the variable type.

const (
	// Unknown type
	Unknown Type = ""
	// Boolean type of variable
	Boolean Type = "boolean"
	// Nominal (non-boolean) type of variable
	Nominal Type = "nominal"
	// Ordinal type of variable
	Ordinal Type = "ordinal"
	// Numerical (interval) type of variable
	Numerical Type = "numerical"
)

func ParseType

func ParseType(s string) Type

ParseType converts the string to the variable type.

func (Type) String

func (t Type) String() string

String returns the corresponding string representation of the variable type.

type Types

type Types []Type

Types defines a slice of variable types

func ParseTypes

func ParseTypes(s string) Types

ParseTypes converts the string to the variable types.

func (Types) Set

func (ts Types) Set() map[Type]bool

Set converts the slice of variable types to the set.

func (Types) String

func (ts Types) String() string

String returns the corresponding string representation of the variable types.

type Variable

type Variable struct {
	ID       ID        // variable id
	Kind     Type      // variable type
	Name     string    // variable name
	Display  string    // variable display name
	Range    []string  // value range for nominal and ordinal variables
	NumRange []float64 // value range for numerical variables
	UnitName string    // variable default unit
}

Variable defines the variable schema with the relevant fields.

func NewVariable

func NewVariable(id ID, kind Type, name, display string, bounds []string, numBounds []float64, unitName string) *Variable

New creates a new variable.

func (*Variable) InRange

func (v *Variable) InRange(val float64) bool

InRange return true if val is in the valid range or the range is not specified.

type Variables

type Variables struct {
	// contains filtered or unexported fields
}

Variables defines a collection of variables.

func DefaultCatalog

func DefaultCatalog() *Variables

DefaultCatalog defines the variable names and their aliases for unit testing. The display names are omitted for the convenience.

func Get

func Get() *Variables

func Load

func Load(fname string) (*Variables, error)

Load loads variables from a file.​

func New

func New() *Variables

func (*Variables) Add

func (vs *Variables) Add(id ID, kind Type, name string, display string, aliases []string, bounds []string, unitName string, question string) error

func (*Variables) Get

func (vs *Variables) Get(candidate string) (string, bool)

Match returns corresponding name if the candidate is in the variable catalog.

func (*Variables) ID

func (vs *Variables) ID(name string) (ID, bool)

ID returns the ID of the variable name.

func (*Variables) Match

func (vs *Variables) Match(candidate string) bool

Match returns true if the candidate is in the variable catalog.

func (*Variables) Question

func (vs *Variables) Question(id ID) string

Question returns the question associated with the variable id.

func (*Variables) Size

func (vs *Variables) Size() int

func (*Variables) Variable

func (vs *Variables) Variable(id ID) *Variable

Variable returns the variable associated with the variable id.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL