# Vartype¶

Enumeration of valid variable types for binary quadratic models.

Examples

`Vartype` is an `Enum`. Each vartype has a value and a name.

```>>> vartype = dimod.SPIN
>>> vartype.name
'SPIN'
>>> vartype.value == {-1, +1}
True
```
```>>> vartype = dimod.BINARY
>>> vartype.name
'BINARY'
>>> vartype.value == {0, 1}
True
```

The `as_vartype()` function allows the user to provide several convenient forms.

```>>> from dimod import as_vartype
```
```>>> as_vartype(dimod.SPIN) is dimod.SPIN
True
>>> as_vartype('SPIN') is dimod.SPIN
True
>>> as_vartype({-1, 1}) is dimod.SPIN
True
```
```>>> as_vartype(dimod.BINARY) is dimod.BINARY
True
>>> as_vartype('BINARY') is dimod.BINARY
True
>>> as_vartype({0, 1}) is dimod.BINARY
True
```
class Vartype(value)[source]

An `Enum` over the types of variables for quadratic models.

SPIN[source]

Vartype for spin-valued binary quadratic models and variables of quadratic models that have values that are either -1 or 1.

BINARY[source]

Vartype for binary quadratic models and variables of quadratic models that have values that are either 0 or 1.

INTEGER[source]

Vartype for variables in quadratic models that have values of type int.

REAL[source]

Vartype for variables in quadratic models that have values of type float.

as_vartype(vartype: , extended: bool = False) [source]

Cast various inputs to a valid vartype object.

Parameters
Returns

Either `SPIN` or `BINARY`. If extended is True, can also be `INTEGER` or `REAL`

Return type

`Vartype`

## Bound Information¶

vartype_info()[source]

Information about the variable bounds by variable type.

Parameters
Returns

A named tuple with `default_min`, `default_max`, `min`, and `max` fields. These specify the default and largest bounds for the given variable type.