def __init__(self, core, mu, c, weights):
"""Initializes the concept."""
if (not isinstance(core, cor.Core)) or (not cor.check(core._cuboids, core._domains)):
raise Exception("Invalid core")
if mu > 1.0 or mu <= 0.0:
raise Exception("Invalid mu")
if c <= 0.0:
raise Exception("Invalid c")
if (not isinstance(weights, wghts.Weights)) or (not wghts.check(weights._domain_weights, weights._dimension_weights)):
raise Exception("Invalid weights")
self._core = core
self._mu = mu
self._c = c
self._weights = weights
python类Core()的实例源码
def __init__(self):
self.core = Core()
self.grid = deepcopy(self.core.grid)
self.height, self.width = 400, 400
self.tablesize = 10
self.cellsize = 40
self.colourmap = colourmap_read(0)
self.colour_list = config.colours
self.lock_click = False
self.turn = 0
self.root = tk.Tk()
self.root.title("Gravity Connect")
self.root.protocol("WM_DELETE_WINDOW", self.save)
self.make_canvas()
self.root.mainloop()
def project_onto(self, domains):
"""Computes the projection of this concept onto a subset of domains."""
# no explicit check for domains - Core will take care of this
new_core = self._core.project_onto(domains)
new_weights = self._weights.project_onto(domains)
return Concept(new_core, self._mu, self._c, new_weights)
def init():
"""
Initialization method.
Returns:
object: RLTK object
"""
return core.Core()
def get_position():
"""http://localhost:5000/get_position?filename=test&mic_amount=37 ..."""
filename = request.args.get('filename', '', str)
mic_amount = request.args.get('mic_amount', 0, int)
trials = request.args.get('trials', 0, int)
proc_number = request.args.get('proc_number', 0, int)
core = Core(filename, mic_amount=mic_amount, trials=trials, proc_number=proc_number)
core.generate_source_positions()
core.generate_distances()
core.prepare()
core.generate_signals()
return jsonify(est_x=float(core.Est_position[0][0]), est_y=float(core.Est_position[0][1]),
est_z=float(core.Est_position[0][2]), true_x=float(core.True_position[0][0]),
true_y=float(core.True_position[0][1]), true_z=float(core.True_position[0][2]))
def __init__(self, *args, **kwargs):
"""
Init core
:param args:
:param kwargs:
:return:
"""
Cmd.__init__(self, *args, **kwargs)
self.core = Core()
self.args = None
self.last_result = 0
self.last_n_logs = 5
self.noninteractive = False
self.version = 'trunk'
self.hide_key = True
self.root_required = False
self.t = Terminal()
self.update_intro()
self.server = server.MasterTCPServer(('0.0.0.0', 44333), master=self)
self.client_db = {}
self.running = True
self.pinger_thread = None
self.assoc_thread = None
def new_instance():
newInstance = Core()
instanceList.append(newInstance)
return newInstance