input stringlengths 11 7.65k | target stringlengths 22 8.26k |
|---|---|
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _apply_mask(y_true, sample_weight, masked_tokens, dtype):
if sample_weight is None:
sample_weight = tf.ones_like(y_true, dtype)
else:
sample_weight = tf.cast(sample_weight, dtype)
for token in masked_tokens:
mask = tf.cast(tf.not_equal(y_true, token), dtype)
sample_weight = sample_weight * mas... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _copy_vars(v_list):
"""Copy variables in v_list."""
t_list = []
for v in v_list:
t_list.append(tf.identity(v))
return t_list |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, masked_tokens=None, name='num_tokens', dtype=tf.int64):
self._masked_tokens = masked_tokens or []
super().__init__(name, dtype) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _restore_vars(v_list, t_list):
"""Restore variables in v_list from t_list."""
ops = []
for v, t in zip(v_list, t_list):
ops.append(v.assign(t))
return ops |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def update_state(self, y_true, y_pred, sample_weight=None):
sample_weight = _apply_mask(y_true, sample_weight, self._masked_tokens,
self._dtype)
sample_weight = tf.reshape(sample_weight, [-1])
super().update_state(sample_weight) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _scale_vars(s, v_list):
"""Scale all variables in v_list by s."""
return [s * v for v in v_list] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def get_config(self):
config = super().get_config()
config['masked_tokens'] = tuple(self._masked_tokens)
return config |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _acc_grads(g_sum, g_w, g):
"""Accumulate gradients in g, weighted by g_w."""
return [g_sum_i + g_w * g_i for g_sum_i, g_i in zip(g_sum, g)] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, masked_tokens=None, name='accuracy', dtype=None):
self._masked_tokens = masked_tokens or []
super().__init__(name, dtype=dtype) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _compute_reg_grads(gen_grads, disc_vars):
"""Compute gradients norm (this is an upper-bpund of the full-batch norm)."""
gen_norm = tf.accumulate_n([tf.reduce_sum(u * u) for u in gen_grads])
disc_reg_grads = tf.gradients(gen_norm, disc_vars)
return disc_reg_grads |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def update_state(self, y_true, y_pred, sample_weight=None):
sample_weight = _apply_mask(y_true, sample_weight, self._masked_tokens,
self._dtype)
num_classes = tf.shape(y_pred)[-1]
y_true = tf.reshape(y_true, [-1])
y_pred = tf.reshape(y_pred, [-1, num_classes])
sample_... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def run_model(prior, images, model, disc_reg_weight):
"""Run the model with new data and samples.
Args:
prior: the noise source as the generator input.
images: images sampled from dataset.
model: a GAN model defined in gan.py.
disc_reg_weight: regularisation weight for discrmininator gradients.
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def update_model(model, disc_grads, gen_grads, disc_opt, gen_opt,
global_step, update_scale):
"""Update model with gradients."""
disc_vars, gen_vars = model.get_variables()
with tf.control_dependencies(gen_grads + disc_grads):
disc_update_op = disc_opt.apply_gradients(
zip(_scale_va... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def sample_fn(x):
return utils.optimise_and_sample(x, module=model,
data=None, is_training=False)[0] |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def setUp(self):
super().setUp()
self.project1 = self.env["project.project"].create({"name": "Project 1"})
self.task1 = self.env["project.task"].create(
{"name": "name1", "project_id": self.project1.id}
)
self.subtask1 = self.env["project.task"].create(
{... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, item_spacing=ITEM_SPACING, *args, **kwargs):
super().__init__(*args, **kwargs) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, nr, nc):
self.nr = nr
self.nc = nc |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def add_item(self, item):
self._vbox_items.pack_start(item.widget, expand=False, fill=False) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def inc_r(self, ind):
r, c = self.row_col(ind)
r += 1
if r == self.nr:
r = 0
if r == (self.nr - 1) and c == (self.nc - 1):
r = 0
return self.indx(r, c) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def reorder_item(self, item, position):
new_position = min(max(position, 0), len(self._items) - 1) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def dec_r(self, ind):
r, c = self.row_col(ind)
r -= 1
if r < 0:
r = self.nr - 1
if r == (self.nr - 1) and c == (self.nc - 1):
r = self.nr - 2
return self.indx(r, c) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_item(self, item):
item_position = self._get_item_position(item)
if item_position < len(self._items) - 1:
next_item_position = item_position + 1
self._items[next_item_position].item_widget.grab_focus() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def inc_c(self, ind):
r, c = self.row_col(ind)
c += 1
if c == self.nc:
c = 0
if r == (self.nr - 1) and c == (self.nc - 1):
c = 0
return self.indx(r, c) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def clear(self):
for unused_ in range(len(self._items)):
self.remove_item(self._items[0]) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def dec_c(self, ind):
r, c = self.row_col(ind)
c -= 1
if c < 0:
c = self.nc - 1
if r == (self.nr - 1) and c == (self.nc - 1):
c = self.nc - 2
return self.indx(r, c) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _setup_drag(self, item):
self._drag_and_drop_context.setup_drag(
item.item_widget,
self._get_drag_data,
self._on_drag_data_received,
[item],
[item],
self) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def row_col(self, ind):
i = 0
for r in range(self.nr):
for c in range(self.nc):
if i == ind:
return r, c
i += 1 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _get_drag_data(self, dragged_item):
return str(self._items.index(dragged_item)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_drag_data_received(self, dragged_item_index_str, destination_item):
dragged_item = self._items[int(dragged_item_index_str)]
self.reorder_item(dragged_item, self._get_item_position(destination_item)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_item_widget_key_press_event(self, widget, event, item):
if event.state & gtk.gdk.MOD1_MASK: # Alt key
key_name = gtk.gdk.keyval_name(event.keyval)
if key_name in ["Up", "KP_Up"]:
self.reorder_item(
item, self._get_item_position(item) - 1)
elif key_name in ["Down", "KP... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_item_button_remove_clicked(self, button, item):
self.remove_item(item) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _get_item_position(self, item):
return self._items.index(item) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, item_widget):
self._item_widget = item_widget |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def widget(self):
return self._event_box |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def item_widget(self):
return self._item_widget |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def button_remove(self):
return self._button_remove |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_item_widget(self):
self._hbox.remove(self._item_widget) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _setup_item_button(self, item_button, icon, position=None):
item_button.set_relief(gtk.RELIEF_NONE) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_event_box_enter_notify_event(self, event_box, event):
if event.detail != gtk.gdk.NOTIFY_INFERIOR:
self._hbox_buttons.show() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_event_box_leave_notify_event(self, event_box, event):
if event.detail != gtk.gdk.NOTIFY_INFERIOR:
self._hbox_buttons.hide() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_event_box_size_allocate(self, event_box, allocation):
if self._is_event_box_allocated_size:
return |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_event_box_buttons_size_allocate(self, event_box, allocation):
if self._buttons_allocation is not None:
return |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(
self,
new_item_default_value,
min_size=0,
max_size=None,
item_spacing=ItemBox.ITEM_SPACING,
max_width=None,
max_height=None,
*args,
**kwargs):
"""
Parameters: |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _init_gui(self):
self._size_spin_button = gtk.SpinButton(
gtk.Adjustment(
value=0,
lower=self._min_size,
upper=self._max_size,
step_incr=1,
page_incr=10,
),
digits=0) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def add_item(self, item_value=None, index=None):
if item_value is None:
item_value = self._new_item_default_value |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def reorder_item(self, item, new_position):
orig_position = self._get_item_position(item)
processed_new_position = super().reorder_item(item, new_position) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_item(self, item):
if (self._locker.is_unlocked("prevent_removal_below_min_size")
and len(self._items) == self._min_size):
return |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def set_values(self, values):
self._locker.lock("emit_size_spin_button_value_changed")
self._locker.lock("prevent_removal_below_min_size") |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _setup_drag(self, item):
self._drag_and_drop_context.setup_drag(
# Using the entire item allows dragging only by the label rather than the
# widget itself. This avoids problems with widgets such as spin buttons
# that do not behave correctly when reordering and also avoids accidental
# c... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_size_spin_button_value_changed(self, size_spin_button):
if self._locker.is_unlocked("emit_size_spin_button_value_changed"):
self._locker.lock("update_spin_button") |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_item_button_remove_clicked(self, button, item):
self._locker.lock("emit_size_spin_button_value_changed") |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _on_item_widget_size_allocate(self, item_widget, allocation, item):
if item in self._items_allocations:
self._update_width(allocation.width - self._items_allocations[item].width)
self._update_height(allocation.height - self._items_allocations[item].height)
else:
self._update_width(allocati... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _update_width(self, width_diff):
if self._items_total_width is None:
self._items_total_width = self.get_allocation().width |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _update_height(self, height_diff):
if self._items_total_height is None:
self._items_total_height = self.get_allocation().height |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _update_dimension(
self,
size_diff,
total_size,
max_visible_size,
dimension_request_property):
if max_visible_size is None:
is_max_visible_size_unlimited = True
else:
is_max_visible_size_unlimited = max_visible_size <= 0 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _rename_item_names(self, start_index):
for index, item in enumerate(self._items[start_index:]):
item.label.set_label(self._get_item_name(index + 1 + start_index)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _get_item_name(index):
return _("Element") + " " + str(index) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, item_widget):
super().__init__(item_widget) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def label(self):
return self._label |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self):
self._tokens = collections.defaultdict(int) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def lock_temp(self, key):
self.lock(key)
try:
yield
finally:
self.unlock(key) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def lock(self, key):
self._tokens[key] += 1 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def unlock(self, key):
if self._tokens[key] > 0:
self._tokens[key] -= 1 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def is_locked(self, key):
return self._tokens[key] > 0 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def is_unlocked(self, key):
return self._tokens[key] == 0 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, backendsdialog):
"""
Constructor, just initializes the gtk widgets
@param backends: a reference to the dialog in which this is
loaded
"""
super().__init__()
self.dialog = backendsdialog
self.req = backendsdialog.get_requester()
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def refresh(self):
"""refreshes the Gtk.Liststore"""
self.backendid_to_iter = {}
self.liststore.clear()
# Sort backends
# 1, put default backend on top
# 2, sort backends by human name
backends = list(self.req.get_all_backends(disabled=True))
backends = s... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def drawMe(self, g, r):
self.g = g
self.r = r
self.g.save()
self.g.moveTo(self.x,self.y)
self.g.beginPath()
# 根據 r 半徑繪製一個圓代表點的所在位置
self.g.arc(self.x, self.y, self.r, 0, 2*math.pi, true)
self.g.moveTo(self.x,self.y)
self.g.lineTo(self.x+self.r, self... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def on_backend_added(self, sender, backend_id):
"""
Signal callback executed when a new backend is loaded
@param sender: not used, only here to let this function be used as a
callback
@param backend_id: the id of the backend to add
"""
# Add
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def Eq(self, pt):
self.x = pt.x
self.y = pt.y |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def add_backend(self, backend):
"""
Adds a new backend to the list
@param backend_id: the id of the backend to add
"""
if backend:
backend_iter = self.liststore.append([
backend.get_id(),
self.dialog.get_pixbuf_from_icon_name(backend.g... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def setPoint(self, px, py):
self.x = px
self.y = py |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def on_backend_state_changed(self, sender, backend_id):
"""
Signal callback executed when a backend is enabled/disabled.
@param sender: not used, only here to let this function be used as a
callback
@param backend_id: the id of the backend to add
"""
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def distance(self, pt):
self.pt = pt
x = self.x - self.pt.x
y = self.y - self.pt.y
return math.sqrt(x * x + y * y) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _get_markup_for_tags(self, tag_names):
"""Given a list of tags names, generates the pango markup to render
that list with the tag colors used in GTG
@param tag_names: the list of the tags (strings)
@return str: the pango markup string
"""
if ALLTASKS_TAG in tag_name... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def tag(self, g):
self.g = g
self.g.beginPath()
self.g.fillText("%d, %d"%(self.x, self.y),self.x, self.y)
self.g.stroke() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def remove_backend(self, backend_id):
""" Removes a backend from the treeview, and selects the first (to show
something in the configuration panel
@param backend_id: the id of the backend to remove
"""
if backend_id in self.backendid_to_iter:
self.liststore.remove(se... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
# 直線的第一點, 設為線尾
self.Tail = self.p1
# 直線組成的第二點, 設為線頭
self.Head = self.p2
# 直線的長度屬性
self.length = math.sqrt(math.pow(self.p2.x-self.p1.x, 2)+math.pow(self.p2.y-self.p1.y,2)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _init_liststore(self):
"""Creates the liststore"""
self.liststore = Gtk.ListStore(object, GdkPixbuf.Pixbuf, str, str)
self.set_model(self.liststore) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def setPP(self, p1, p2):
self.p1 = p1
self.p2 = p2
self.Tail = self.p1
self.Head = self.p2
self.length = math.sqrt(math.pow(self.p2.x-self.p1.x, 2)+math.pow(self.p2.y-self.p1.y,2)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _init_renderers(self):
"""Initializes the cell renderers"""
# We hide the columns headers
self.set_headers_visible(False)
# For the backend icon
pixbuf_cell = Gtk.CellRendererPixbuf()
tvcolumn_pixbuf = Gtk.TreeViewColumn('Icon', pixbuf_cell)
tvcolumn_pixbuf.ad... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def setRT(self, r, t):
self.r = r
self.t = t
x = self.r * math.cos(self.t)
y = self.r * math.sin(self.t)
self.Tail.Eq(self.p1)
self.Head.setPoint(self.Tail.x + x,self.Tail.y + y) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def cell_edited_callback(self, text_cell, path, new_text):
"""If a backend name is changed, it saves the changes in the Backend
@param text_cell: not used. The Gtk.CellRendererText that emitted the
signal. Only here because it's passed by the signal
@param path: the Gt... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getR(self):
# x 分量與 y 分量
x = self.p1.x - self.p2.x
y = self.p1.y - self.p2.y
return math.sqrt(x * x + y * y) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _init_signals(self):
"""Initializes the backends and gtk signals """
self.connect("cursor-changed", self.on_select_row)
_signals = BackendSignals()
_signals.connect(_signals.BACKEND_ADDED, self.on_backend_added)
_signals.connect(_signals.BACKEND_STATE_TOGGLED,
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getT(self):
x = self.p2.x - self.p1.x
y = self.p2.y - self.p1.y
if (math.fabs(x) < math.pow(10,-100)):
if(y < 0.0):
return (-math.pi/2)
else:
return (math.pi/2)
else:
return math.atan2(y, x) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def on_select_row(self, treeview=None):
"""When a row is selected, displays the corresponding editing panel
@var treeview: not used
"""
self.dialog.on_backend_selected(self.get_selected_backend_id()) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def setTail(self, pt):
self.pt = pt
self.Tail.Eq(pt)
self.Head.setPoint(self.pt.x + self.x, self.pt.y + self.y) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def _get_selected_path(self):
"""
Helper function to get the selected path
@return Gtk.TreePath : returns exactly one path for the selected object
or None
"""
selection = self.get_selection()
if selection:
model, selected_paths ... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getHead(self):
return self.Head |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def select_backend(self, backend_id=None):
"""
Selects the backend corresponding to backend_id.
If backend_id is none, refreshes the current configuration panel.
@param backend_id: the id of the backend to select
"""
selection = self.get_selection()
if backend_id... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getTail(self):
return self.Tail |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def drawMe(self, g):
self.g = g
self.g.beginPath()
self.g.moveTo(self.p1.x,self.p1.y)
self.g.lineTo(self.p2.x,self.p2.y)
self.g.stroke() |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def test(self):
return ("this is pure test to Inherit") |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
self.length = math.sqrt(math.pow((self.p2.x - self.p1.x), 2) + math.pow((self.p2.y - self.p1.y), 2)) |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def drawMe(self, g):
self.g = g
hole = 5
radius = 10
length = self.getR()
# alert(length)
# 儲存先前的繪圖狀態
self.g.save()
self.g.translate(self.p1.x,self.p1.y)
#alert(str(self.p1.x)+","+str(self.p1.y))
#self.g.rotate(-((math.pi/2)-self.getT()))
... |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def __init__(self, p1, p2, p3):
self.p1 = p1
self.p2 = p2
self.p3 = p3 |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getLenp3(self):
p1 = self.p1
ret = p1.distance(self.p2)
return ret |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getLenp1(self):
p2 = self.p2
ret = p2.distance(self.p3)
return ret |
def __init__(self, x=0.0, y=0.0):
self.x = x
self.y = y | def getLenp2(self):
p1 = self.p1
ret = p1.distance(self.p3)
return ret |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.