# Path: speriment/utils.py
# class IDGenerator:
#     '''Creates an object to generate unique IDs for experimental components. You
#     should create exactly one per experiment so that all IDs in that experiment
#     will be distinct.
# 
#     Usage:
#     with make_experiment(IDGenerator()):
#         <experiment code>
#     '''
# 
#     def __init__(self, seed = -1):
#         '''seed: optional, an integer to start making IDs at.'''
#         self.current_id = seed
# 
#     def _current(self):
#         return self.current_id
# 
#     def _next_id(self):
#         '''Takes no arguments and returns a string, which is a new unique ID.'''
#         self.current_id += 1
#         return str(self.current_id)
# 
# def at_most_one(obj, attributes):
#     found = [attribute for attribute in attributes if hasattr(obj, attribute)]
#     if len(found) > 1:
#         raise ValueError, '''{} must have at most one of the following attributes:
# 
# {}
# 
# but it has:
# 
# {}.'''.format(obj, attributes, found)


from speriment.utils import IDGenerator, at_most_one
import copy
        the same value.
        '''
        self.bank = bank
        if bank not in SampleFrom._id_generators:
            SampleFrom._id_generators[bank] = IDGenerator()
            SampleFrom._variable_maps[bank] = {}
        if variable != None:
            self.variable = variable
            if not variable in SampleFrom._variable_maps[bank]:
                SampleFrom._variable_maps[bank][variable] = SampleFrom._id_generators[bank]._next_id()
        if not_variable != None:
            self.not_variable = not_variable
            if not not_variable in SampleFrom._variable_maps[bank]:
                SampleFrom._variable_maps[bank][not_variable] = SampleFrom._id_generators[bank]._next_id()
        if with_replacement:
            self.with_replacement = with_replacement
        if field != None:
            self.field = field

    def map_variables(self):
        mapping = SampleFrom._variable_maps[self.bank]
        if hasattr(self, 'variable'):
            self.variable = int(mapping[self.variable])
        elif hasattr(self, 'not_variable'):
            self.not_variable = int(mapping[self.not_variable])
        else:
            if not hasattr(self, 'with_replacement'):
                self.variable = int(SampleFrom._compile_time_generators[self.bank]._next_id())

    def _validate(self):

# Path: speriment/utils.py
# class IDGenerator:
#     '''Creates an object to generate unique IDs for experimental components. You
#     should create exactly one per experiment so that all IDs in that experiment
#     will be distinct.
# 
#     Usage:
#     with make_experiment(IDGenerator()):
#         <experiment code>
#     '''
# 
#     def __init__(self, seed = -1):
#         '''seed: optional, an integer to start making IDs at.'''
#         self.current_id = seed
# 
#     def _current(self):
#         return self.current_id
# 
#     def _next_id(self):
#         '''Takes no arguments and returns a string, which is a new unique ID.'''
#         self.current_id += 1
#         return str(self.current_id)
# 
# def at_most_one(obj, attributes):
#     found = [attribute for attribute in attributes if hasattr(obj, attribute)]
#     if len(found) > 1:
#         raise ValueError, '''{} must have at most one of the following attributes:
# 
# {}
# 
# but it has:
# 
# {}.'''.format(obj, attributes, found)


# Path: speriment/components/sample_from.py
from speriment.utils import IDGenerator, at_most_one
import copy

        the same value.
        '''
        self.bank = bank
        if bank not in SampleFrom._id_generators:
            SampleFrom._id_generators[bank] = IDGenerator()
            SampleFrom._variable_maps[bank] = {}
        if variable != None:
            self.variable = variable
            if not variable in SampleFrom._variable_maps[bank]:
                SampleFrom._variable_maps[bank][variable] = SampleFrom._id_generators[bank]._next_id()
        if not_variable != None:
            self.not_variable = not_variable
            if not not_variable in SampleFrom._variable_maps[bank]:
                SampleFrom._variable_maps[bank][not_variable] = SampleFrom._id_generators[bank]._next_id()
        if with_replacement:
            self.with_replacement = with_replacement
        if field != None:
            self.field = field

    def map_variables(self):
        mapping = SampleFrom._variable_maps[self.bank]
        if hasattr(self, 'variable'):
            self.variable = int(mapping[self.variable])
        elif hasattr(self, 'not_variable'):
            self.not_variable = int(mapping[self.not_variable])
        else:
            if not hasattr(self, 'with_replacement'):
                self.variable = int(SampleFrom._compile_time_generators[self.bank]._next_id())

    def _validate(self):

        at_most_one(self, ['variable', 'not_variable', 'with_replacement'])