text stringlengths 0 828 |
|---|
logging.info('Initialized from DFA em_vector table is the following:') |
logging.info(em_vector) |
self._fill_table_entry(self.epsilon, self.epsilon) |
# list(set([])) is used to remove duplicates, [1:0] to remove epsilon |
for row in sorted(list(set(sm_vector + smi_vector)), key=len)[1:]: |
for column in em_vector: |
self._fill_table_entry(str(row), str(column))" |
543,"def learn_sfa(self, mma=None): |
"""""" |
Implements the high level loop of the algorithm for learning a |
Mealy machine. |
Args: |
mma: |
Returns: |
MealyMachine: A model for the Mealy machine to be learned. |
"""""" |
logging.info('Initializing learning procedure.') |
if mma: |
self._init_table_from_dfa(mma) |
else: |
self._init_table() |
logging.info('Generating a closed and consistent observation table.') |
while True: |
closed = False |
# Make sure that the table is closed |
while not closed: |
logging.debug('Checking if table is closed.') |
closed, s = self.observation_table.is_closed() |
if not closed: |
logging.debug('Closing table.') |
self._ot_make_closed(s) |
else: |
logging.debug('Table closed.') |
# Create conjecture |
sfa = self.get_sfa_conjecture() |
logging.info('Generated conjecture machine with %d states.', |
len(list(sfa.states))) |
# _check correctness |
logging.debug('Running equivalence query.') |
found, counter_example = self._equivalence_query(sfa) |
# Are we done? |
if found: |
logging.info('No counterexample found. Hypothesis is correct!') |
break |
# Add the new experiments into the table to reiterate the |
# learning loop |
logging.info( |
'Processing counterexample %s with length %d.', |
counter_example, |
len(counter_example)) |
self._process_counter_example(sfa, counter_example) |
logging.info('Learning complete.') |
return '', sfa" |
544,"def make_log_metric(level=logging.INFO, msg=""%d items in %.2f seconds""): |
""""""Make a new metric function that logs at the given level |
:arg int level: logging level, defaults to ``logging.INFO`` |
:arg string msg: logging message format string, taking ``count`` and ``elapsed`` |
:rtype: function |
"""""" |
def log_metric(name, count, elapsed): |
log_name = 'instrument.{}'.format(name) if name else 'instrument' |
logging.getLogger(log_name).log(level, msg, count, elapsed) |
return log_metric" |
545,"def _auto_init(self, *args, **kwrds): |
""""""Our decorator will add this as __init__ to target classes."""""" |
for fld in getattr(self, '__fields__', []): |
val = kwrds.get(fld.name, _NO_VAL) |
if val is _NO_VAL: |
val = fld.get_default_val() |
setattr(self, fld.name, val) |
if callable(getattr(self, 'setup', None)): |
self.setup(*args, **kwrds)" |
546,"def ctor_overridable(cls): |
""""""Return true if cls has on overridable __init__."""""" |
prev_init = getattr(cls, ""__init__"", None) |
if not callable(prev_init): |
return True |
if prev_init in [object.__init__, _auto_init]: |
return True |
if getattr(prev_init, '_clobber_ok', False): |
return True |
print(cls, prev_init, getattr(prev_init, '_clobber_ok', 'missing')) |
return False" |
547,"def DBObject(table_name, versioning=VersioningTypes.NONE): |
""""""Classes annotated with DBObject gain persistence methods."""""" |
def wrapped(cls): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.