# Path: epistasis/matrix.py
# def get_model_matrix(binary_genotypes, sites, model_type='global'):
#     """Get a model matrix for a given set of genotypes and coefficients.
# 
#     Parameters
#     ----------
#     binary_genotypes : list or array
#         List of genotypes in their binary representation (see
#         gpmap.utils.genotypes_to_binary)
# 
#     sites : list
#         List of epistatic interaction sites.
# 
#     model_type : string
#         Type of epistasis model (global/Hadamard, local/Biochemical).
#     """
#     # Convert sites to array of arrays
#     sites = np.array([np.array(s) for s in sites],dtype=object)
#     
#     # Encode genotypes
#     encoded_vector = encode_vectors(binary_genotypes, model_type=model_type)
# 
#     # Build matrix.
#     X = build_model_matrix(encoded_vector, sites)
#     return X
# 
# Path: epistasis/models/utils.py
# class XMatrixException(Exception):
#     """Exception Subclass for X matrix errors."""


import numpy as np
from gpmap.gpm import GenotypePhenotypeMap
from gpmap import utils
from epistasis.mapping import (encoding_to_sites, assert_epistasis)
from .mapping import SimulatedEpistasisMap
from epistasis.matrix import get_model_matrix
from epistasis.utils import extract_mutations_from_genotypes
from epistasis.models.utils import XMatrixException
        if type(X) is str and X in ['obs', 'complete']:

            # Create a list of epistatic interaction for this model.
            if hasattr(self, "epistasis"):
                columns = self.epistasis.sites
            else:
                self.add_epistasis()
                columns = self.epistasis.sites

            # Use desired set of genotypes for rows in X matrix.
            index = self.binary

            # Build numpy array
            x = get_model_matrix(index, columns, model_type=self.model_type)

            # Set matrix with given key.
            if key is None:
                key = X

            self.Xbuilt[key] = x

        elif type(X) == np.ndarray or type(X) == pd.DataFrame:
            # Set key
            if key is None:
                raise Exception("A key must be given to store.")

            # Store Xmatrix.
            self.Xbuilt[key] = X

        else:

# Path: epistasis/matrix.py
# def get_model_matrix(binary_genotypes, sites, model_type='global'):
#     """Get a model matrix for a given set of genotypes and coefficients.
# 
#     Parameters
#     ----------
#     binary_genotypes : list or array
#         List of genotypes in their binary representation (see
#         gpmap.utils.genotypes_to_binary)
# 
#     sites : list
#         List of epistatic interaction sites.
# 
#     model_type : string
#         Type of epistasis model (global/Hadamard, local/Biochemical).
#     """
#     # Convert sites to array of arrays
#     sites = np.array([np.array(s) for s in sites],dtype=object)
#     
#     # Encode genotypes
#     encoded_vector = encode_vectors(binary_genotypes, model_type=model_type)
# 
#     # Build matrix.
#     X = build_model_matrix(encoded_vector, sites)
#     return X
# 
# Path: epistasis/models/utils.py
# class XMatrixException(Exception):
#     """Exception Subclass for X matrix errors."""


# Path: epistasis/simulate/base.py
import numpy as np
from gpmap.gpm import GenotypePhenotypeMap
from gpmap import utils
from epistasis.mapping import (encoding_to_sites, assert_epistasis)
from .mapping import SimulatedEpistasisMap
from epistasis.matrix import get_model_matrix
from epistasis.utils import extract_mutations_from_genotypes
from epistasis.models.utils import XMatrixException

        if type(X) is str and X in ['obs', 'complete']:

            # Create a list of epistatic interaction for this model.
            if hasattr(self, "epistasis"):
                columns = self.epistasis.sites
            else:
                self.add_epistasis()
                columns = self.epistasis.sites

            # Use desired set of genotypes for rows in X matrix.
            index = self.binary

            # Build numpy array
            x = get_model_matrix(index, columns, model_type=self.model_type)

            # Set matrix with given key.
            if key is None:
                key = X

            self.Xbuilt[key] = x

        elif type(X) == np.ndarray or type(X) == pd.DataFrame:
            # Set key
            if key is None:
                raise Exception("A key must be given to store.")

            # Store Xmatrix.
            self.Xbuilt[key] = X

        else:

            raise XMatrixException("X must be one of the following: 'obs',"