function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def __init__(self): self.status = c_api.TF_NewStatus()
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def __init__(self): self.graph = c_api.TF_NewGraph() # Note: when we're destructing the global context (i.e when the process is # terminating) we may have already deleted other modules. By capturing the # DeleteGraph function here, we retain the ability to cleanly destroy the # graph at shutdown, wh...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def __init__(self): self.options = c_api.TF_NewImportGraphDefOptions()
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def __init__(self, results): self.results = results
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def __init__(self, func): self.func = func # Note: when we're destructing the global context (i.e when the process is # terminating) we may have already deleted other modules. By capturing the # DeleteFunction function here, we retain the ability to cleanly destroy the # Function at shutdown, which ...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def has_been_garbage_collected(self): return self.func is None
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def __init__(self, buf_string): self.buffer = c_api.TF_NewBufferFromString(compat.as_bytes(buf_string))
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def __init__(self): op_def_proto = op_def_pb2.OpList() buf = c_api.TF_GetAllOpList() try: op_def_proto.ParseFromString(c_api.TF_GetBuffer(buf)) self._api_def_map = c_api.TF_NewApiDefMap(buf) finally: c_api.TF_DeleteBuffer(buf) self._op_per_name = {} for op in op_def_proto.op: ...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def put_api_def(self, text): c_api.TF_ApiDefMapPut(self._api_def_map, text, len(text))
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def get_op_def(self, op_name): if op_name in self._op_per_name: return self._op_per_name[op_name] raise ValueError(f"No op_def found for op name {op_name}.")
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def tf_buffer(data=None): """Context manager that creates and deletes TF_Buffer. Example usage: with tf_buffer() as buf: # get serialized graph def into buf ... proto_data = c_api.TF_GetBuffer(buf) graph_def.ParseFromString(compat.as_bytes(proto_data)) # buf has been deleted wi...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def tf_operations(graph): """Generator that yields every TF_Operation in `graph`. Args: graph: Graph Yields: wrapped TF_Operation """ # pylint: disable=protected-access pos = 0 c_op, pos = c_api.TF_GraphNextOperation(graph._c_graph, pos) while c_op is not None: yield c_op c_op, pos = c...
tensorflow/tensorflow
[ 171949, 87931, 171949, 2300, 1446859160 ]
def setUp(self): self.asn1Spec = rfc2314.CertificationRequest()
catapult-project/catapult
[ 1835, 570, 1835, 1039, 1429033745 ]
def add_arguments(self, parser): """ Add arguments to the command parser. """ parser.add_argument( '--course-id', '--course_id', dest='course_ids', action='append', help=u'Migrates transcripts for the list of courses.' ) par...
Stanford-Online/edx-platform
[ 41, 19, 41, 1, 1374606346 ]
def _get_migration_options(self, options): """ Returns the command arguments configured via django admin. """ force_update = options['force_update'] commit = options['commit'] courses_mode = get_mutually_exclusive_required_option(options, 'course_ids', 'all_courses', 'fro...
Stanford-Online/edx-platform
[ 41, 19, 41, 1, 1374606346 ]
def main(): opts, args = getopt.getopt(sys.argv[1:], 'D:U:') for o, a in opts: if o == '-D': defs.append(a) if o == '-U': undefs.append(a) if not args: args = ['-'] for filename in args: if filename == '-': process(sys.stdin,...
google/google-ctf
[ 3196, 457, 3196, 1, 1524844563 ]
def process(fpi, fpo): keywords = ('if', 'ifdef', 'ifndef', 'else', 'endif') ok = 1 stack = [] while 1: line = fpi.readline() if not line: break while line[-2:] == '\\\n': nextline = fpi.readline() if not nextline: break line = line +...
google/google-ctf
[ 3196, 457, 3196, 1, 1524844563 ]
def uart_tx(): # fmt: off # Block with TX deasserted until data available pull() # Initialise bit counter, assert start bit for 8 cycles set(x, 7) .side(0) [7] # Shift out 8 data bits, 8 execution cycles per bit label("bitloop") out(pins, 1) [6] jmp(x_dec, "bitloo...
pfalcon/micropython
[ 741, 72, 741, 28, 1388317127 ]
def pio_uart_print(sm, s): for c in s: sm.put(ord(c))
pfalcon/micropython
[ 741, 72, 741, 28, 1388317127 ]
def assumed_state(self): """Return True if unable to access real state of entity.""" return self.gateway.optimistic
tchellomello/home-assistant
[ 7, 1, 7, 6, 1467778429 ]
def is_closed(self): """Return True if cover is closed.""" set_req = self.gateway.const.SetReq if set_req.V_DIMMER in self._values: return self._values.get(set_req.V_DIMMER) == 0 return self._values.get(set_req.V_LIGHT) == STATE_OFF
tchellomello/home-assistant
[ 7, 1, 7, 6, 1467778429 ]
def current_cover_position(self): """Return current position of cover. None is unknown, 0 is closed, 100 is fully open. """ set_req = self.gateway.const.SetReq return self._values.get(set_req.V_DIMMER)
tchellomello/home-assistant
[ 7, 1, 7, 6, 1467778429 ]
def __init__(self, **kwargs): super(_Merge, self).__init__(**kwargs) self.supports_masking = True
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _compute_elemwise_op_output_shape(self, shape1, shape2): """Computes the shape of the resultant of an elementwise operation. Arguments: shape1: tuple or None. Shape of the first tensor shape2: tuple or None. Shape of the second tensor Returns: expected output shape when an elem...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def call(self, inputs): if self._reshape_required: reshaped_inputs = [] input_ndims = list(map(K.ndim, inputs)) if None not in input_ndims: # If ranks of all inputs are available, # we simply expand each of them at axis=1 # until all of them have the same rank. max_...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def compute_mask(self, inputs, mask=None): if mask is None: return None if not isinstance(mask, list): raise ValueError('`mask` should be a list.') if not isinstance(inputs, list): raise ValueError('`inputs` should be a list.') if len(mask) != len(inputs): raise ValueError('The l...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _merge_function(self, inputs): output = inputs[0] for i in range(1, len(inputs)): output += inputs[i] return output
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _merge_function(self, inputs): output = inputs[0] for i in range(1, len(inputs)): output *= inputs[i] return output
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _merge_function(self, inputs): output = inputs[0] for i in range(1, len(inputs)): output += inputs[i] return output / len(inputs)
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def _merge_function(self, inputs): output = inputs[0] for i in range(1, len(inputs)): output = K.maximum(output, inputs[i]) return output
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def __init__(self, axis=-1, **kwargs): super(Concatenate, self).__init__(**kwargs) self.axis = axis self.supports_masking = True
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def call(self, inputs): if not isinstance(inputs, list): raise ValueError('A `Concatenate` layer should be called ' 'on a list of inputs.') return K.concatenate(inputs, axis=self.axis)
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def compute_mask(self, inputs, mask=None): if mask is None: return None if not isinstance(mask, list): raise ValueError('`mask` should be a list.') if not isinstance(inputs, list): raise ValueError('`inputs` should be a list.') if len(mask) != len(inputs): raise ValueError('The l...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def __init__(self, axes, normalize=False, **kwargs): super(Dot, self).__init__(**kwargs) if not isinstance(axes, int): if not isinstance(axes, (list, tuple)): raise TypeError('Invalid type for `axes` - ' 'should be a list or an int.') if len(axes) != 2: raise ...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def call(self, inputs): x1 = inputs[0] x2 = inputs[1] if isinstance(self.axes, int): if self.axes < 0: axes = [self.axes % K.ndim(x1), self.axes % K.ndim(x2)] else: axes = [self.axes] * 2 else: axes = [] for i in range(len(self.axes)): if self.axes[i] < 0:...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def compute_mask(self, inputs, mask=None): return None
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def add(inputs, **kwargs): """Functional interface to the `Add` layer. Arguments: inputs: A list of input tensors (at least 2). **kwargs: Standard layer keyword arguments. Returns: A tensor, the sum of the inputs. """ return Add(**kwargs)(inputs)
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def average(inputs, **kwargs): """Functional interface to the `Average` layer. Arguments: inputs: A list of input tensors (at least 2). **kwargs: Standard layer keyword arguments. Returns: A tensor, the average of the inputs. """ return Average(**kwargs)(inputs)
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def concatenate(inputs, axis=-1, **kwargs): """Functional interface to the `Concatenate` layer. Arguments: inputs: A list of input tensors (at least 2). axis: Concatenation axis. **kwargs: Standard layer keyword arguments. Returns: A tensor, the concatenation of the inputs alongside axis...
unnikrishnankgs/va
[ 1, 5, 1, 10, 1496432585 ]
def __init__(self, fp): self.palette = [(i, i, i) for i in range(256)] while True: s = fp.readline() if not s: break if s[0:1] == b"#": continue if len(s) > 100: raise SyntaxError("bad palette file") ...
Microvellum/Fluid-Designer
[ 69, 30, 69, 37, 1461884765 ]
def __init__(self): self._num_rows = 3 self._num_columns = 2 self._data = [["hello" for j in range(self._num_columns)] for i in range(self._num_rows)]
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def get_num_columns(self): return self._num_columns
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def set_data(self, row_index, column_index, value): self._data[row_index][column_index] = value
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def __init__(self, data, parent=None): super().__init__(parent) self._data = data # DON'T CALL THIS ATTRIBUTE "data", A QAbstractItemModel METHOD ALREADY HAVE THIS NAME (model.data(index, role)) !!!
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def columnCount(self, parent): return self._data.get_num_columns()
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def setData(self, index, value, role): if role == Qt.EditRole: try: self._data.set_data(index.row(), index.column(), value) # The following line are necessary e.g. to dynamically update the QSortFilterProxyModel self.dataChanged.emit(index, index, [Q...
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def changedCallback(): print("changed")
jeremiedecock/snippets
[ 20, 6, 20, 1, 1433499549 ]
def _redirect_event_creation(category_id, event_type): anchor = f'create-event:{event_type}:{category_id}' return redirect(url_for('.display', category_id=category_id, _anchor=anchor))
indico/indico
[ 1446, 358, 1446, 649, 1311774990 ]
def _redirect_to_bootstrap(): # No users in Indico yet? Redirect from index page to bootstrap form if (request.endpoint == 'categories.display' and not request.view_args['category_id'] and not User.query.filter_by(is_system=False).has_rows()): return redirect(url_for('bootstrap.index'))
indico/indico
[ 1446, 358, 1446, 649, 1311774990 ]
def __init__(self, x): self.val = x self.left = None self.right = None
jiadaizhao/LeetCode
[ 39, 21, 39, 2, 1502171846 ]
def __init__(self, obj): return obj
thonkify/thonkify
[ 17, 1, 17, 3, 1501859450 ]
def __init__( self, plotly_name="opacitysrc", parent_name="scattercarpet.marker", **kwargs
plotly/python-api
[ 13052, 2308, 13052, 1319, 1385013188 ]
def arrangeWords(self, text: str) -> str: words = text.split() table = collections.defaultdict(list) for word in words: table[len(word)].append(word) result = [] for key in sorted(table): result.extend(table[key]) return ' '.join(result).capitaliz...
jiadaizhao/LeetCode
[ 39, 21, 39, 2, 1502171846 ]
def __init__( self, plotly_name="familysrc", parent_name="funnelarea.hoverlabel.font", **kwargs
plotly/plotly.py
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, log, *args, **kw): dv.DataViewCustomRenderer.__init__(self, *args, **kw) self.log = log self.value = None
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def GetValue(self): #self.log.write('MyCustomRenderer.GetValue\n') return self.value
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def Render(self, rect, dc, state): if state != 0: self.log.write('Render: %s, %d\n' % (rect, state)) if not state & dv.DATAVIEW_CELL_SELECTED: # we'll draw a shaded background to see if the rect correctly # fills the cell dc.SetBrush(wx.Brush('light grey'...
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def HasEditorCtrl(self): self.log.write('HasEditorCtrl') return True
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def GetValueFromEditorCtrl(self, editor): self.log.write('GetValueFromEditorCtrl: %s' % editor) value = editor.GetValue() return True, value
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def LeftClick(self, pos, cellRect, model, item, col): self.log.write('LeftClick') return False
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def __init__(self, parent, log, model=None, data=None): self.log = log wx.Panel.__init__(self, parent, -1) # Create a dataview control self.dvc = dv.DataViewCtrl(self, style=wx.BORDER_THEME | dv.DV_ROW_LINES ...
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def main(): from data import musicdata app = wx.App() frm = wx.Frame(None, title="CustomRenderer sample", size=(700,500)) pnl = TestPanel(frm, sys.stdout, data=musicdata) frm.Show() app.MainLoop()
dnxbjyj/python-basic
[ 1, 4, 1, 11, 1501510345 ]
def __init__(self, client, config, serializer, deserializer) -> None: self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_at_resource_group_level( self, resource_group_name: str, filter: Optional[str] = None, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def prepare_request(next_link=None): if not next_link:
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_at_resource_level( self, resource_group_name: str, resource_provider_namespace: str, parent_resource_path: str, resource_type: str, resource_name: str, filter: Optional[str] = None, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def prepare_request(next_link=None): if not next_link:
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_at_subscription_level( self, filter: Optional[str] = None, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def prepare_request(next_link=None): if not next_link:
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_by_scope( self, scope: str, filter: Optional[str] = None, **kwargs: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def prepare_request(next_link=None): if not next_link:
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__(self): self._state = None
tailhook/tilenol
[ 60, 11, 60, 7, 1333893143 ]
def update(self): nval = self._read() if nval != self._state: self._state = nval return True
tailhook/tilenol
[ 60, 11, 60, 7, 1333893143 ]
def groups(self): return self._state
tailhook/tilenol
[ 60, 11, 60, 7, 1333893143 ]
def __init__(self, *, filled=False, first_letter=False, right=False): super().__init__(right=right) self.filled = filled self.first_letter = first_letter
tailhook/tilenol
[ 60, 11, 60, 7, 1333893143 ]
def check_state(self): if self.state.dirty: self.bar.redraw.emit()
tailhook/tilenol
[ 60, 11, 60, 7, 1333893143 ]
def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def _create_or_update_initial( self, resource_group_name, # type: str ip_groups_name, # type: str parameters, # type: "_models.IpGroup" **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def begin_create_or_update( self, resource_group_name, # type: str ip_groups_name, # type: str parameters, # type: "_models.IpGroup" **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_long_running_output(pipeline_response): deserialized = self._deserialize('IpGroup', pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def update_groups( self, resource_group_name, # type: str ip_groups_name, # type: str parameters, # type: "_models.TagsObject" **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def _delete_initial( self, resource_group_name, # type: str ip_groups_name, # type: str **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def begin_delete( self, resource_group_name, # type: str ip_groups_name, # type: str **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {})
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list_by_resource_group( self, resource_group_name, # type: str **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.list_by_reso...
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: error = self._deserialize....
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def list( self, **kwargs # type: Any
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def prepare_request(next_link=None): # Construct headers header_parameters = {} # type: Dict[str, Any] header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') if not next_link: # Construct URL url = self.list.metadat...
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: error = self._deserialize....
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]
def __init__( self, model, inducing_points, variational_distribution, learn_inducing_locations=True, mean_var_batch_dim=None
jrg365/gpytorch
[ 3035, 485, 3035, 323, 1497019700 ]
def _expand_inputs(self, x, inducing_points): # If we haven't explicitly marked a dimension as batch, add the corresponding batch dimension to the input if self.mean_var_batch_dim is None: x = x.unsqueeze(-3) else: x = x.unsqueeze(self.mean_var_batch_dim - 2) retu...
jrg365/gpytorch
[ 3035, 485, 3035, 323, 1497019700 ]
def is_number(number, topping_list): """Will check that what the user enters is really a number and not a letter, also that it is within our list""" if number in "0123456789": number = int(number) if number <= len(topping_list)-1: return number
frastlin/PyAudioGame
[ 5, 4, 5, 2, 1420973210 ]
def add_topping(key): """Will add a topping to your pizza""" number = is_number(key, storage.toppings) if number or number == 0: storage.your_toppings.append(storage.toppings[number]) spk("You added %s to your pizza. Your pizza currently has %s on top" % (storage.toppings[number], storage.your_toppings))
frastlin/PyAudioGame
[ 5, 4, 5, 2, 1420973210 ]
def logic(actions): """Press a and d to switch from adding and removing toppings, press 0-9 to deal with the toppings and press space to eat the pizza""" key = actions['key'] if key == "d": spk("Press a number to remove a topping from your pizza, press a to add toppings again") storage.screen[0] = "remove" sto...
frastlin/PyAudioGame
[ 5, 4, 5, 2, 1420973210 ]
def prng(): global x x = math.fmod((x + math.pi) ** 2.0, 1.0) return x
ActiveState/code
[ 1884, 686, 1884, 41, 1500923597 ]
def c(n, k): if k == 0: return 1 if n == 0: return 0 return c(n - 1, k - 1) + c(n - 1, k)
ActiveState/code
[ 1884, 686, 1884, 41, 1500923597 ]
def __init__(self, head, codes): self._head = '' if head == '' else head + ' ' self._codes = codes
cupy/cupy
[ 6731, 672, 6731, 478, 1477994085 ]
def __init__( self, plotly_name="showexponent", parent_name="parcats.line.colorbar", **kwargs
plotly/python-api
[ 13052, 2308, 13052, 1319, 1385013188 ]
def __init__(self, client, config, serializer, deserializer) -> None: self._client = client self._serialize = serializer self._deserialize = deserializer self._config = config
Azure/azure-sdk-for-python
[ 3526, 2256, 3526, 986, 1335285972 ]