text stringlengths 0 828 |
|---|
return self._parser_func(desired_type, file_path, encoding, logger, **opts) |
else: |
return self._parser_func(desired_type, file_path, encoding, logger, **self.function_args, **opts)" |
1228,"def queryByPortSensor(portiaConfig, edgeId, port, sensor, strategy=SummaryStrategies.PER_HOUR, interval=1, params={ 'from': None, 'to': None, 'order': None, 'precision': 'ms', 'fill':'none', 'min': True, 'max': True, 'sum': True, 'avg': True, 'median': False, 'mode': False, 'stddev': False, 'spread': False }): |
""""""Returns a pandas data frame with the portia select resultset"""""" |
header = {'Accept': 'text/csv'} |
endpoint = '/summary/device/{0}/port/{1}/sensor/{2}/{3}/{4}{5}'.format( edgeId, port, sensor, resolveStrategy(strategy), interval, utils.buildGetParams(params) ) |
response = utils.httpGetRequest(portiaConfig, endpoint, header) |
if response.status_code == 200: |
try: |
dimensionSeries = pandas.read_csv( StringIO(response.text), sep=';' ) |
if portiaConfig['debug']: |
print( '[portia-debug]: {0} rows'.format( len(dimensionSeries.index) ) ) |
return dimensionSeries |
except: |
raise Exception('couldn\'t create pandas data frame') |
else: |
raise Exception('couldn\'t retrieve data')" |
1229,"def _process_counter_example(self, mma, w_string): |
"""""""" |
Process a counterexample in the Rivest-Schapire way. |
Args: |
mma (DFA): The hypothesis automaton |
w_string (str): The examined string to be consumed |
Returns: |
None |
"""""" |
diff = len(w_string) |
same = 0 |
membership_answer = self._membership_query(w_string) |
while True: |
i = (same + diff) / 2 |
access_string = self._run_in_hypothesis(mma, w_string, i) |
if membership_answer != self._membership_query(access_string + w_string[i:]): |
diff = i |
else: |
same = i |
if diff - same == 1: |
break |
exp = w_string[diff:] |
self.observation_table.em_vector.append(exp) |
for row in self.observation_table.sm_vector + self.observation_table.smi_vector: |
self._fill_table_entry(row, exp) |
return 0" |
1230,"def get_dfa_conjecture(self): |
"""""" |
Utilize the observation table to construct a Mealy Machine. |
The library used for representing the Mealy Machine is the python |
bindings of the openFST library (pyFST). |
Args: |
None |
Returns: |
MealyMachine: A mealy machine build based on a closed and consistent |
observation table. |
"""""" |
dfa = DFA(self.alphabet) |
for s in self.observation_table.sm_vector: |
for i in self.alphabet: |
dst = self.observation_table.equiv_classes[s + i] |
# If dst == None then the table is not closed. |
if dst == None: |
logging.debug('Conjecture attempt on non closed table.') |
return None |
obsrv = self.observation_table[s, i] |
src_id = self.observation_table.sm_vector.index(s) |
dst_id = self.observation_table.sm_vector.index(dst) |
dfa.add_arc(src_id, dst_id, i, obsrv) |
# Mark the final states in the hypothesis automaton. |
i = 0 |
for s in self.observation_table.sm_vector: |
dfa[i].final = self.observation_table[s, self.epsilon] |
i += 1 |
return dfa" |
1231,"def _init_table(self): |
"""""" |
Initialize the observation table. |
"""""" |
self.observation_table.sm_vector.append(self.epsilon) |
self.observation_table.smi_vector = list(self.alphabet) |
self.observation_table.em_vector.append(self.epsilon) |
self._fill_table_entry(self.epsilon, self.epsilon) |
for s in self.observation_table.smi_vector: |
self._fill_table_entry(s, self.epsilon)" |
1232,"def learn_dfa(self, mma=None): |
"""""" |
Implements the high level loop of the algorithm for learning a |
Mealy machine. |
Args: |
mma (DFA): The input automaton |
Returns: |
MealyMachine: A string and a model for the Mealy machine to be learned. |
"""""" |
logging.info('Initializing learning procedure.') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.