query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Sets the id of this SiteResultResponseSites. | def id(self, id):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def site_id(self, site_id):\n\n self._site_id = site_id",
"def site_id(self, site_id):\n\n self._site_id = site_id",
"def SetId(self, id):\n self.id = int(id)",
"def set_id(self, id):\n self.data['id'] = id",
"def set_id(self, id_):\n\n self.id_ = id_",
"def set_site_id... | [
"0.5972183",
"0.5972183",
"0.58587265",
"0.5852302",
"0.57827604",
"0.576646",
"0.57471114",
"0.5613573",
"0.56133527",
"0.56100255",
"0.55624807",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682",
"0.5457682"... | 0.5281101 | 92 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, SiteResultResponseSites):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.80886984",
"0.80886984",
"0.8055307",
"0.7983415",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
"0.79673034",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Reset all key metrics. | def stats_reset(self):
self.stats.reset() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_all(self) -> None:\n for metric in self:\n metric.reset()",
"def reset_metric_stats(self):\n\n self.__stats_table = {}",
"def reset_metric_stats(self):\n self.__stats_table = {}",
"def reset_metrics(self):\n self.metrics['loss'] = 0.0\n self.metrics['nu... | [
"0.7870859",
"0.74083424",
"0.73499054",
"0.73214763",
"0.7318451",
"0.72477305",
"0.7237046",
"0.6887533",
"0.6830536",
"0.68184996",
"0.67728966",
"0.67589486",
"0.6724742",
"0.6717452",
"0.670672",
"0.66931087",
"0.6689274",
"0.66353744",
"0.65997446",
"0.65804696",
"0.657... | 0.6442427 | 33 |
Sets necessary initial values, and equation for simulation. | def set_parameters(pars):
y0=[]
fun=None
state_evol=None
if pars["state_law"]==0:
state_evol=state_evol_d
elif pars["state_law"]==1:
state_evol=state_evol_r
elif pars["state_law"]==2:
state_evol=state_evol_p
elif pars["state_law"]==3:
state_evol=state_evol_n
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_initial_value(self, t, x):\n\n self.integrator.set_initial_value(x, t).set_f_params(self._params[\"args\"])\n try:\n testoutput = self.rhs(t, x, self.args)\n except:\n print(\"ODE function not callable\")\n raise\n\n super().set_initial_value(t, ... | [
"0.6883309",
"0.67583114",
"0.66968375",
"0.6500244",
"0.64864296",
"0.64631116",
"0.64126635",
"0.63703257",
"0.6284785",
"0.6249545",
"0.6194924",
"0.61740756",
"0.615462",
"0.6152462",
"0.6147597",
"0.61428523",
"0.61418265",
"0.6128848",
"0.6103001",
"0.6077734",
"0.60777... | 0.0 | -1 |
Determines whether or not the given table exists in the database. | def _table_exists(conn, table_name):
# Query for the table.
with conn:
cur = conn.cursor()
cur.execute(('SELECT name FROM sqlite_master'
' WHERE type="table" AND name="%s"') % table_name)
return len(cur.fetchall()) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_exists(self, table_name):\n table_exists = self.query(\n sql.table_existence,\n (\n table_name,\n self._current_db,\n ),\n )\n return bool(table_exists)",
"def db_table_exists(table_name):\n return table_name in conn... | [
"0.8548726",
"0.85091746",
"0.84993964",
"0.8402604",
"0.8362737",
"0.83571243",
"0.83302623",
"0.831709",
"0.8275886",
"0.82709855",
"0.8261206",
"0.8260306",
"0.8253387",
"0.82527876",
"0.8179717",
"0.81409127",
"0.80135703",
"0.79881203",
"0.7987735",
"0.7977754",
"0.79777... | 0.8395945 | 4 |
Opens a top level window that allows user to pick a color to draw with. | def __init__(self, last_color):
self._color = last_color
self._window = tk.Toplevel(width = 200, height = 132)
self._window.title("Color")
self._initialize() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_win(e) -> None:\n widget_sfx()\n r, g, b = parse_color(var.get())\n new_color, tk_color = askcolor(\n color=f\"#{r:02x}{g:02x}{b:02x}\",\n parent=parent.winfo_toplevel(),\n title=str(TRANS_SELECT_TITLE),\n )\n if new_color is not None:\n ... | [
"0.78519",
"0.7814317",
"0.6693709",
"0.65407825",
"0.6462546",
"0.6143019",
"0.61292297",
"0.6012014",
"0.5964553",
"0.5934409",
"0.593141",
"0.59168404",
"0.5864574",
"0.5836036",
"0.57578963",
"0.57451797",
"0.5741491",
"0.571649",
"0.5708141",
"0.57004005",
"0.569675",
... | 0.61051977 | 7 |
Return the unit of measurement parsed from the device's status. | def unit_of_measurement(self):
unit = get_uom_from_status(self._device.status)
if unit == HS_UNIT_LUX:
return LIGHT_LUX
elif unit == HS_UNIT_CELSIUS:
return TEMP_CELSIUS
elif unit == HS_UNIT_FAHRENHEIT:
return TEMP_FAHRENHEIT
elif unit == HS_UN... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_of_measurement(self):\n return self.sensor_type[\"unit\"]",
"def unit_of_measurement(self):\n return SENSOR_TYPES[self.sensor][1]",
"def unit_of_measurement(self):\n if self.api_unit in TEMPERATURE_UNITS:\n return self.hass.config.units.temperature_unit\n\n if se... | [
"0.76437825",
"0.746998",
"0.74218506",
"0.74157023",
"0.740581",
"0.7388591",
"0.7377171",
"0.7353208",
"0.7341531",
"0.7341531",
"0.7332249",
"0.73284346",
"0.73284346",
"0.73133624",
"0.7282512",
"0.7269954",
"0.7269954",
"0.72663075",
"0.7254831",
"0.7254831",
"0.7218295"... | 0.74856573 | 1 |
Return the device class of the device based on the device's unit of measure. | def device_class(self):
unit = get_uom_from_status(self._device.status)
if unit == HS_UNIT_LUX:
return DEVICE_CLASS_ILLUMINANCE
elif unit == HS_UNIT_CELSIUS or unit == HS_UNIT_FAHRENHEIT:
return DEVICE_CLASS_TEMPERATURE
elif unit == HS_UNIT_A or unit == HS_UNIT_AM... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return self.sensor_type[\"class\"]",
"def device_class(self):\n return SENSOR_TYPES[self.sensor][3].get(\"device_class\")",
"def device_class(self):\n return DEVICE_CLASSES.get(self.sensor_data[\"model\"])",
"def device_class(self):\n return self._device_... | [
"0.8136462",
"0.8074018",
"0.80291504",
"0.8021291",
"0.7964804",
"0.7964804",
"0.7964804",
"0.79148877",
"0.78717184",
"0.7852789",
"0.7852789",
"0.7852789",
"0.7852789",
"0.7852789",
"0.7843691",
"0.7797977",
"0.7797977",
"0.7780279",
"0.77343714",
"0.77221465",
"0.77136075... | 0.7694324 | 21 |
Return the proper sensor object based on device type. | def get_sensor_entity(device, connection):
if device.device_type_string == DEVICE_ZWAVE_BATTERY:
return HomeSeerBatterySensor(device, connection)
elif device.device_type_string == DEVICE_ZWAVE_RELATIVE_HUMIDITY:
return HomeSeerHumiditySensor(device, connection)
elif device.device_type_string... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_class(self):\n return SENSOR_TYPES[self._type][3] if self._type in SENSOR_TYPES else None",
"def device_class(self):\n return self._sensor_type",
"def device_class(self):\n return SENSOR_TYPES[self._type][1]",
"def device_class(self):\n return SENSOR_TYPES[self._type][1... | [
"0.75538343",
"0.7514771",
"0.7448284",
"0.7448284",
"0.73344034",
"0.7313101",
"0.7146185",
"0.7146185",
"0.7034229",
"0.70098543",
"0.69747657",
"0.69605017",
"0.6958129",
"0.6941414",
"0.6871068",
"0.6817007",
"0.6776309",
"0.66841775",
"0.66308254",
"0.66180444",
"0.66003... | 0.6693964 | 17 |
Remove database after tests. | def test_d_remove_database(self):
if os.path.isfile(location):
os.remove(location)
assert(True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n with app.app_context():\n db = app.db.get_db()\n cur = db.cursor()\n with app.open_resource('sql/drop_tests.sql', mode='r') as f:\n cur.execute(f.read())\n db.commit()\n cur.close()\n db.close()",
"def t... | [
"0.8471298",
"0.8440213",
"0.8344882",
"0.82627845",
"0.8261374",
"0.82357323",
"0.82357323",
"0.8201057",
"0.8128077",
"0.812539",
"0.81021607",
"0.80223924",
"0.7978612",
"0.79327077",
"0.79327077",
"0.79316825",
"0.79015857",
"0.78822815",
"0.7879419",
"0.7879419",
"0.7879... | 0.0 | -1 |
Create diagonal matrices from rows of a matrix. | def from_vector_to_diagonal_matrix(vector):
num_columns = gs.shape(vector)[-1]
identity = gs.eye(num_columns)
identity = gs.cast(identity, vector.dtype)
diagonals = gs.einsum('...i,ij->...ij', vector, identity)
return diagonals | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diagM(l):\r\n dim = len(l)\r\n M = np.zeros((dim, dim))\r\n np.fill_diagonal(M, l)\r\n return matrix(M)",
"def row_diag(self):\n rows = self._row_type_2d()\n for i, m in iter_items(self.row_totals):\n rows[i][i] = m\n return self.__class__(rows=rows)",
"def diago... | [
"0.7308241",
"0.7270162",
"0.7073832",
"0.69338995",
"0.6823909",
"0.6801987",
"0.66896343",
"0.66075283",
"0.6604143",
"0.65966094",
"0.652844",
"0.6451578",
"0.6451345",
"0.6391153",
"0.627982",
"0.6244389",
"0.6242408",
"0.6240625",
"0.62153167",
"0.61619514",
"0.61611974"... | 0.5939148 | 40 |
Build the mapping from a initializer's output name to this initializer. | def map_name_and_initializer(cls,
onnx_model: onnx.ModelProto,
allow_redundant=True):
initializers = dict()
for idx, init in enumerate(onnx_model.graph.initializer):
initializers[init.name] = (init, idx)
return init... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_output_table(cls, name='inputTableName', output_name='output'):\n obj = cls(name)\n obj.exporter = 'get_output_table_name'\n obj.output_name = output_name\n return obj",
"def get_dict_of_sequential_param__output(dev_cfg, name, output_name):\n one = get_sequential_params(d... | [
"0.6447417",
"0.61118364",
"0.6078771",
"0.6009913",
"0.58038884",
"0.5754742",
"0.5750578",
"0.570118",
"0.55992615",
"0.55883414",
"0.5571378",
"0.54526895",
"0.54314226",
"0.5389423",
"0.53645575",
"0.53520435",
"0.5318265",
"0.53017825",
"0.5291689",
"0.5280601",
"0.52799... | 0.48844835 | 66 |
Creates a dictionary with some base meta attributes about this monitor. Sub classes should invoke this method when serialising to json and then add any additional parameters as necessary to the result of this methods invoke. | def to_json(self):
return {
"active": self.active,
"started": self.started,
"finished": self.finished,
"id": self.monitor_id,
"waitTime": self.wait_time,
"runInterval": self.run_interval,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_meta(self):\n self.meta = {}\n # Required (core)\n self.meta['ra'] = dict(ext=0, card='RA')\n self.meta['dec'] = dict(ext=0, card='DEC')\n self.meta['target'] = dict(ext=0, card='OBJECT')\n self.meta['decker'] = dict(ext=0, card=None, default='default')\n s... | [
"0.65982944",
"0.6523396",
"0.64963174",
"0.6460221",
"0.6447643",
"0.63927895",
"0.6343281",
"0.63377464",
"0.6313878",
"0.6303408",
"0.6300032",
"0.6289292",
"0.6265826",
"0.61442363",
"0.6137702",
"0.61314744",
"0.6130445",
"0.61262673",
"0.6109824",
"0.61013216",
"0.60618... | 0.56617063 | 92 |
Generate a timestamp for the current time using FORMAT | def main(format):
print(pendulum.now().format(format)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_timestamp():\n\t\treturn strftime(\"%Y%m%dT%H%M%S\")",
"def get_timestamp():\n return datetime.now().strftime(TIMESTAMP_FORMAT)",
"def get_timestamp():\n now, s=get_date()\n return (now, \"%s%s%s%s\" % (s, str(now.hour).zfill(2), str(now.minute).zfill(2), str(now.second).zfill(2)))",
"... | [
"0.7961752",
"0.7802339",
"0.7759335",
"0.76932794",
"0.7642791",
"0.76282215",
"0.76067406",
"0.76055425",
"0.75897336",
"0.75572807",
"0.751964",
"0.7493992",
"0.74717885",
"0.74715686",
"0.7470597",
"0.7438586",
"0.7435322",
"0.7416399",
"0.7408493",
"0.7377975",
"0.735923... | 0.0 | -1 |
Returns a boolean value indicating if `IPMI_DEV` is loaded. | def is_loaded(self):
return os.path.exists(IPMIService.IPMI_DEV) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __virtual__():\n if salt.utils.path.which(\"apf\") is None:\n return (False, \"The apf execution module cannot be loaded: apf unavailable.\")\n elif not IPTC_IMPORTED:\n return (\n False,\n \"The apf execution module cannot be loaded: python-iptables is missing.\",\n ... | [
"0.6116172",
"0.59552795",
"0.585915",
"0.5810406",
"0.57490444",
"0.5721264",
"0.57166934",
"0.5696916",
"0.5675338",
"0.56715816",
"0.56705964",
"0.5584879",
"0.555731",
"0.55389214",
"0.55229425",
"0.5516023",
"0.5498899",
"0.5487562",
"0.5458306",
"0.545599",
"0.5451562",... | 0.82472116 | 0 |
String for representing the Model object. | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return self.game_title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Create a composite solid with the specified parameters from the decorated composition function. Using this decorator allows you to build up the dependency graph of the composite by writing a function that invokes solids and passes the output to other solids. This is similar to the use | def composite_solid(
name: Union[Optional[str], Callable[..., Any]] = None,
input_defs: Optional[List[InputDefinition]] = None,
output_defs: Optional[List[OutputDefinition]] = None,
description: Optional[str] = None,
config_schema: Optional[Dict[str, Any]] = None,
config_fn: Optional[Callable[[d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def composition(func: Callable, *args, **kwargs):\n\n def decorator(decorated: Callable):\n @wraps(decorated)\n def wrapper(*args_, **kwargs_):\n return func(decorated(*args_, **kwargs_), *args, **kwargs)\n\n return wrapper\n\n return decorator",
"def compose(f,g):\n def ... | [
"0.60128206",
"0.5792588",
"0.56960016",
"0.54609394",
"0.5410444",
"0.54075134",
"0.5402522",
"0.5378935",
"0.5368843",
"0.5359969",
"0.52744067",
"0.5230593",
"0.5200594",
"0.51932013",
"0.5162181",
"0.5139571",
"0.51072794",
"0.51007694",
"0.50816023",
"0.507038",
"0.50273... | 0.6964584 | 0 |
Returns the difference between the total number of occurrences of G and the total number of occurrences of C in the first i elements of the sequence. | def get_sequence_skew(sequence):
skew = [0]
for idx, element in enumerate(sequence):
if sequence[idx] == 'G':
skew.append(skew[idx] + 1)
elif sequence[idx] == 'C':
skew.append(skew[idx] - 1)
else:
skew.append(skew[idx])
return skew | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gc(sequence):\n sequence = sequence.upper()\n return (sequence.count('G') + sequence.count('C')) / float(len(sequence))",
"def compute_gc(seq): # seq should be a string\n num_GC = list(seq).count('g')+list(seq).count('c')+list(seq).count('G')+list(seq).count('C')\n amount_GC = num_GC/len(seq)\n ... | [
"0.6847958",
"0.6801968",
"0.6610946",
"0.65225357",
"0.6500474",
"0.6103371",
"0.6056977",
"0.5931549",
"0.5915073",
"0.590089",
"0.5897437",
"0.58609736",
"0.5830444",
"0.5803718",
"0.57924414",
"0.5787228",
"0.56482506",
"0.55885917",
"0.55786735",
"0.5552352",
"0.5531351"... | 0.5125472 | 71 |
Returns a batch of size B (number of "rows"), where each row has length T. Each row contains consecutive timesteps from an episode, but might not start at the beginning of that episode. Should an episode end within such a row (trajectory), a random next episode (starting from its t0) will be concatenated to that row. F... | def sample(
self,
num_items: Optional[int] = None,
*,
batch_size_B: Optional[int] = None,
batch_length_T: Optional[int] = None,
) -> SampleBatchType:
if num_items is not None:
assert batch_size_B is None, (
"Cannot call `sample()` with both... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(\n self,\n capacity: int = 10000,\n *,\n batch_size_B: int = 16,\n batch_length_T: int = 64,\n ):\n self.capacity = capacity\n self.batch_size_B = batch_size_B\n self.batch_length_T = batch_length_T\n\n # The actual episode buffer. We a... | [
"0.63050056",
"0.59570664",
"0.56157994",
"0.55724305",
"0.5569702",
"0.55141264",
"0.54776406",
"0.54565257",
"0.5455103",
"0.5444364",
"0.5413294",
"0.5372205",
"0.5348346",
"0.5336985",
"0.533116",
"0.5315568",
"0.5297452",
"0.52896684",
"0.5269411",
"0.5206413",
"0.520610... | 0.62020963 | 1 |
Adds the given `episode_chunk` to the right side of self. | def concat_episode(self, episode_chunk: "_Episode"):
assert episode_chunk.id_ == self.id_
assert not self.is_done
# Make sure the timesteps match.
assert self.t == episode_chunk.t_started
episode_chunk.validate()
# Make sure, end matches other episode chunk's beginning.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_right(self, p, e):\n node = self._validate_position(p)\n if node.right is not None:\n raise ValueError(\"right child exists\")\n self._size += 1\n node.right = self._Node(e, parent=node)\n return self._make_position(node.right)",
"def add_chunk(self, chunk):... | [
"0.5450189",
"0.5411784",
"0.53774846",
"0.5348699",
"0.52142656",
"0.5170512",
"0.5005324",
"0.4903867",
"0.48993525",
"0.48581204",
"0.48408258",
"0.47391567",
"0.47230396",
"0.46925083",
"0.4686515",
"0.4668182",
"0.46456707",
"0.46340117",
"0.45939565",
"0.45842728",
"0.4... | 0.67538285 | 0 |
Return the queryset against which an 'entities' query should be executed. | def resolve_entities(root, info, ids: list[int], **kwargs):
return Entity.objects.filter(id__in=ids) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return self._queryset_class(\n model=self.model,\n using=self._db,\n hints=self._hints,\n query=CustomQuery(self.model)\n )",
"def queryset(cls):\n return cls.model._default_manager.all()",
"def get_queryset(self) -> Que... | [
"0.66145337",
"0.65898806",
"0.6482328",
"0.6479951",
"0.6357203",
"0.6357203",
"0.6330338",
"0.6323929",
"0.6317595",
"0.631576",
"0.6288385",
"0.6272994",
"0.6222982",
"0.6202299",
"0.6134868",
"0.6125106",
"0.6037924",
"0.6027974",
"0.60120374",
"0.601134",
"0.5969075",
... | 0.0 | -1 |
Returns the length of the queue. | def __len__(self):
return len(self.contents) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qsize(self):\r\n return len(self._queue)",
"def queue_size(self) -> int:\n return self._queue.qsize()",
"def size(self):\n return len(self.__queue)",
"def size(self):\n return len(self.queue)",
"def size(self):\n return len(self.queue)",
"def size(self):\n re... | [
"0.8463733",
"0.8462693",
"0.84618497",
"0.8440461",
"0.8440461",
"0.8440461",
"0.8440461",
"0.84098727",
"0.84098727",
"0.8337942",
"0.8336949",
"0.8293008",
"0.8291974",
"0.8220578",
"0.82007056",
"0.81837326",
"0.81752855",
"0.8151759",
"0.8039402",
"0.787705",
"0.7841482"... | 0.0 | -1 |
Read the manipulations.json file and return it as an object | async def get_result_data(
work_dir,
extra_adjust_parameters,
results_file=None,
group_id=None,
artifact_id=None,
):
manipulation_file_path = os.path.join(work_dir, SMEG_MANIPULATION_FILE_NAME)
if os.path.isfile(manipulation_file_path):
file_path ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_data(self):\n return read_json(self.file_path)",
"def read_json_file(self, fname):\n return {}",
"def parse():\n with open('src/wator/Properties.json') as data_file:\n data = json.load(data_file)\n return data",
"def extract_model_output_from_json(json_file_path: str)... | [
"0.6484432",
"0.6449324",
"0.64144456",
"0.62946147",
"0.6294274",
"0.62579423",
"0.6197317",
"0.6192753",
"0.6192753",
"0.6099266",
"0.602668",
"0.602668",
"0.60177",
"0.5992119",
"0.5986138",
"0.597447",
"0.5972819",
"0.5952447",
"0.5948568",
"0.59288895",
"0.5919142",
"0... | 0.0 | -1 |
Initialize a `BaseProfile` object from an ``xarray Dataset`` Notes `` xarray.Dataset`` objects are mutable; hence, functions and methods that act on them usually change the object in place. | def _create_profile_from_xarray(self, time=None):
# Select one time from the larger dataset
if not isinstance(time, type(None)):
# User specified the time to use
if 'time' in self.data.dims:
# Check if time exists in dataset
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, dataset: Dataset):\n self.dataset = dataset",
"def __init__(self, data, samples_per_update=None, min_true_samples=0,\n options=None):\n if not options:\n options = UnstructuredOptions()\n elif isinstance(options, ProfilerOptions):\n op... | [
"0.5954783",
"0.59512436",
"0.5935184",
"0.58613014",
"0.572895",
"0.5720863",
"0.56118596",
"0.56041884",
"0.5539014",
"0.55338246",
"0.55257845",
"0.55052245",
"0.5495312",
"0.5495042",
"0.5489259",
"0.54807556",
"0.5473731",
"0.547131",
"0.5463395",
"0.5456604",
"0.5456604... | 0.554165 | 8 |
Add data to the ``xarray.Dataset`` and ``Profile`` object This method operates only on the `xarray` data variables in the ``Profile`` object. Since the use may also need to append data to a ``netCDF4`` dataset, the ``Profile`` class extends this method. See the ``Profile.append()`` method for details. | def append(self, data, data_names, data_units, comments=None, z_col=0):
# Make sure the strings are in lists
if isinstance(data_names, str) or isinstance(data_names, unicode):
data_names = [data_names]
if isinstance(data_units, str) or isinstance(data_units, unicode):
dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(self, data, var_symbols, var_units, comments=None, z_col=0):\n if self.nc_open:\n # Make sure the parameter names are in a list\n if isinstance(var_symbols, str) or \\\n isinstance(var_symbols, unicode):\n var_symbols = [var_symbols]\n ... | [
"0.6235448",
"0.6062287",
"0.60007614",
"0.59489816",
"0.59289205",
"0.5888327",
"0.58644706",
"0.58259094",
"0.57889575",
"0.57727253",
"0.57322305",
"0.5715672",
"0.56926054",
"0.5688016",
"0.5662735",
"0.5646588",
"0.5630583",
"0.562672",
"0.5536111",
"0.5523085",
"0.55119... | 0.0 | -1 |
Compute the density and add it to the profile database This method computes the seawater density at each depth in the profile database and adds the computed value to the database with the parameter name 'density' and units of kg/m^3. This method has the optional parameter ``P0``. If this parameter is not used, the loca... | def insert_density(self, P0=None):
# Extract the z-coordinate
zs = self.interp_ds.coords[self.ztsp[0]].values
# Commpute the density at each depth
density = np.zeros(len(zs))
Ts, Ss, Ps = self.get_values(zs, ['temperature', 'salinity',
'pressure']).transpose... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _density(self):\n fraction = np.array([0.]+[m.value for m in self.fraction])\n # TODO: handle invalid fractions using penalty functions\n # S = sum(fraction)\n # scale = S/100 if S > 100 else 1\n # fraction[0] = 100 - S/scale\n # penalty = scale - 1\n fraction[0... | [
"0.6857234",
"0.59307885",
"0.5906926",
"0.57963514",
"0.5779244",
"0.5736262",
"0.56825846",
"0.5681744",
"0.5671112",
"0.56635964",
"0.56551003",
"0.5637884",
"0.5637884",
"0.5637884",
"0.56152254",
"0.5549733",
"0.54431784",
"0.54358536",
"0.5410945",
"0.540377",
"0.538567... | 0.7429463 | 0 |
Append current data passed to the ``__init__()`` method through the array ``current`` and list ``current_units``. | def _append_current(self, current, current_names, current_units):
# Make sure the units list is complete
if isinstance(current_units, str) or \
isinstance(current_units, unicode):
# Assume all components have the same units
current_units = [current_units] * 3
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n this = _libsbml.new_ListOfUnits(*args)\n try: self.this.append(this)\n except: self.this = this",
"def updateCurrentUnit(self):\n self.unitGroup.updateCurrentUnit(unicode(self.text()),\n self.cursorPosition())\n ... | [
"0.56790495",
"0.56622213",
"0.56168544",
"0.54229724",
"0.5354467",
"0.5318624",
"0.5318438",
"0.5288918",
"0.5270292",
"0.5261567",
"0.5251163",
"0.5203913",
"0.5196869",
"0.5177407",
"0.51651007",
"0.5098976",
"0.5093061",
"0.5089625",
"0.507312",
"0.50717676",
"0.50464165... | 0.8221003 | 0 |
Close an open `netCDF4.Dataset` object If the raw profile data are stored in a netCDF file, a pipe is open to the file source whenever this attribute of the object is in use. Once the xarray Dataset is built with the complete data needed for a TAMOC simulation (e.g., once calls to `append` or `extend_profile_deeper` ar... | def close_nc(self):
# Close the netCDF file
if self.nc_open == True:
self.nc.close()
# Remove the object attributes from memory and delete the object
self.nc_open = False
self.nc = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_raster_file(self):\n try:\n if self.dataset:\n del self.dataset\n self.dataset = None\n except AttributeError:\n pass",
"def close(self):\n self.data.close()",
"def close_datafile(fs):\r\n fs.close() # fs is the output from i... | [
"0.62085",
"0.59267896",
"0.5679093",
"0.5674404",
"0.5630073",
"0.5575162",
"0.55730355",
"0.54901",
"0.53368396",
"0.52900803",
"0.5212837",
"0.51928467",
"0.5177638",
"0.51758754",
"0.51758754",
"0.51682335",
"0.5159974",
"0.5159974",
"0.5148683",
"0.5104725",
"0.5096156",... | 0.64858794 | 0 |
Convert the values in data to standard units This function accepts a data array with variables arranged in columns, each column given by the sequential unit in units, and converts the values in the array to standard units. The function returns both the transformed data and the new, standardized units. | def convert_units(data, units):
# Build the dictionary of units conversions
convert = {'m' : [1.0, 0., 'm'],
'meter' : [1.0, 0., 'm'],
'deg C' : [1.0, 273.15, 'K'],
'Celsius' : [1.0, 273.15, 'K'],
'K' : [1.0, 0., 'K'],
'db' : [1.e4, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def standardize_data(data):\n return (data - np.mean(data, axis=0)) / (np.std(data, axis=0) + 10 ** -16)",
"def standardize(data):\r\n mean = data.mean(axis=0)\r\n std = data.std(axis=0)\r\n return (data - mean)/std",
"def standardization(input_data):\n\n # Insert debugging assertions\n asse... | [
"0.74902767",
"0.72637117",
"0.7116936",
"0.7051262",
"0.68576515",
"0.68180263",
"0.6690161",
"0.66882026",
"0.6642543",
"0.66255045",
"0.658968",
"0.65551263",
"0.6433823",
"0.64265805",
"0.6378873",
"0.6272524",
"0.62422115",
"0.62290764",
"0.6208078",
"0.6148806",
"0.6148... | 0.5700461 | 55 |
Testing that sum of four empty lists return 0 | def test_that_sum_of_four_function_empty():
K = []
L = []
M = []
N = []
assert check_sum_of_four(K, L, M, N) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_sum_of_four(a: List[int], b: List[int], c: List[int], d: List[int]) -> int:\n return sum(1 for x in itertools.product(a, b, c, d) if sum(x) == 0)",
"def zero_sum(list):\n if not list:\n return 0\n else:\n return sum(list)",
"def test_sum_of_empty_array():\n assert find_maxim... | [
"0.7371535",
"0.72122633",
"0.70495933",
"0.69088566",
"0.68490154",
"0.67267686",
"0.6609886",
"0.65189046",
"0.63222337",
"0.62949353",
"0.62920153",
"0.6197035",
"0.6194355",
"0.61923987",
"0.61558557",
"0.6055683",
"0.6034134",
"0.6016807",
"0.59702396",
"0.5959803",
"0.5... | 0.82745147 | 0 |
Computes area of triangle according to its vertexes | def compute_area(self):
"""Косое произведение векторов
A = (x2-x1; y2-y1; z2-z1)
B = (x3-x1; y3-y1; z3-z1)
S = 0.5*sqrt((Ay*Bz - Az*By)^2 + (Az*Bx - Ax*Bz)^2 + (Ax*By - Ay*Bx)^2 )
"""
a_x = self.x2 - self.x1
a_y = self.y2 - self.y1
a_z = self.z2 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_triangle_area(vertices):\n v01 = vertices[0] - vertices[1]\n v02 = vertices[0] - vertices[2]\n cross_prod = np.cross(v01, v02)\n area = 0.5 * np.linalg.norm(cross_prod)\n return area",
"def area_triangle(triangle):\n return 0.5 * length_vector(normal_triangle(triangle, False))",
"... | [
"0.8689803",
"0.77349013",
"0.7573903",
"0.75571305",
"0.7544694",
"0.7525414",
"0.75251585",
"0.7443184",
"0.7426886",
"0.7409574",
"0.7408834",
"0.7391191",
"0.73180985",
"0.7312892",
"0.7299688",
"0.7250315",
"0.7207274",
"0.7205594",
"0.7142768",
"0.71237755",
"0.7120846"... | 0.6740285 | 35 |
Static method for create a webhooks in to a project. | def create_webhooks():
client = RequestManager()
client.set_method("POST")
client.set_endpoint("/projects/{0}/webhooks".format(STORED_ID['project_id']))
name = "".join(choices(string.ascii_letters, k=6))
body = {"webhook_url": 'https://' + name, "webhook_version": 'v5'}
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_project_hook(self, project_id, url):\n return self._post('/projects/{0}/hooks'.format(project_id), data={'url': url})",
"def create_webhook():\n\n response = requests.put(KAZOO_SERVER + ':8000/v2/accounts/' + ACC_ID + '/webhooks', headers=HEADERS, data=ws.jsonify(CHANNEL_DESTROY_WEBHOOKS))\n... | [
"0.7059825",
"0.67537344",
"0.6328318",
"0.6267944",
"0.6192408",
"0.6124945",
"0.5949776",
"0.588287",
"0.5854365",
"0.58460563",
"0.5791769",
"0.5789866",
"0.57749516",
"0.5733761",
"0.5663985",
"0.56037116",
"0.55662555",
"0.55014014",
"0.54640454",
"0.5460963",
"0.5450598... | 0.8243269 | 0 |
Creates a new KDM instance from a KDM XML document | def __init__(self, kdm_xml):
self.raw = kdm_xml
self._parse(kdm_xml) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateKmlDoc():\n\n kml_doc = xml.dom.minidom.Document()\n kml_element = kml_doc.createElementNS('http://www.opengis.net/kml/2.2', 'kml')\n kml_element.setAttribute('xmlns', 'http://www.opengis.net/kml/2.2')\n kml_element = kml_doc.appendChild(kml_element)\n document = kml_doc.createElement('Document')\n ... | [
"0.6097475",
"0.5996859",
"0.59304464",
"0.5793666",
"0.5762862",
"0.57570994",
"0.57570994",
"0.57570994",
"0.5748048",
"0.5684737",
"0.56713796",
"0.56713796",
"0.56268805",
"0.5623931",
"0.5568415",
"0.5536706",
"0.55348665",
"0.5517966",
"0.55127996",
"0.5511985",
"0.5507... | 0.7195445 | 0 |
Extract scalar reward from trial result. | def extract_scalar_reward(value, scalar_key='default'):
if isinstance(value, (float, int)):
reward = value
elif isinstance(value, dict) and scalar_key in value and isinstance(value[scalar_key], (float, int)):
reward = value[scalar_key]
else:
raise RuntimeError('Incorrect final result... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_reward(self):\n if self.status():\n return self.current_step/self.ep_length # the reward is proportional to the duration \n else:\n return 0",
"def get_reward(self):\n return self.calc_reward(self.sim.pose[:3], self.sim.v)",
"def get_reward(self):\n accuracy = self.state... | [
"0.6515704",
"0.64581895",
"0.6411313",
"0.6406163",
"0.636316",
"0.63602984",
"0.6345448",
"0.6270197",
"0.6210453",
"0.61967736",
"0.6195546",
"0.61867166",
"0.6183912",
"0.6174516",
"0.61544645",
"0.61544645",
"0.61383116",
"0.6125049",
"0.61133814",
"0.60970986",
"0.60960... | 0.7023478 | 0 |
convert dict type to tuple to solve unhashable problem. | def convert_dict2tuple(value):
if isinstance(value, dict):
for _keys in value:
value[_keys] = convert_dict2tuple(value[_keys])
return tuple(sorted(value.items()))
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _tupleize(d):\n return [(key, value) for key, value in d.items()]",
"def get_dict_as_tuple(d):\n for k, v in six.iteritems(d):\n return k, v\n return None",
"def dict2tuple(d):\n items = list(d.items())\n items.sort()\n return tuple(items)",
"def convert_dict_to_tuple(d):\n re... | [
"0.7630687",
"0.7592358",
"0.7583269",
"0.7357076",
"0.70670927",
"0.6956285",
"0.69442326",
"0.6878567",
"0.6878567",
"0.6675761",
"0.65778214",
"0.64994025",
"0.6450421",
"0.63742745",
"0.63609135",
"0.63017726",
"0.6301577",
"0.6252036",
"0.61089087",
"0.6061087",
"0.60541... | 0.7064694 | 5 |
Convert a diff id to a string with leading "D". | def diff_to_str(diff: int) -> str:
return 'D{}'.format(diff) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_id_to_group(d_id: str) -> str:\n return chr(ord('a') + (int(d_id[2]) % 5))",
"def str_id(self, id):\n\t\ts = bin(id)\n\t\ts = '0'*64 + s[2:]\n\t\tidbits = 64 - (2*self.xybits+self.tbits)\n\t\tret = []\n\t\tnover = self.xybits - self.level\n\t\tfor l, k in [(0, idbits), (0, self.tbits), (nover, sel... | [
"0.6704083",
"0.64353675",
"0.6426906",
"0.61305445",
"0.6101405",
"0.60886675",
"0.6088349",
"0.6060004",
"0.6036831",
"0.60280377",
"0.60235846",
"0.5990331",
"0.5962203",
"0.5962171",
"0.59552735",
"0.5842128",
"0.58302784",
"0.58182293",
"0.58047",
"0.5779413",
"0.5778984... | 0.81684464 | 0 |
Normalizes the absolute value of z_where to the range that is appropriate for the network. | def _normalize_location(T: int, pis: Tensor, sis: Tensor) -> Tensor:
x = pis.clone()
x += sis / 2
x -= T / 2
x /= -(sis / 2)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalise(self):\n for at in self.atoms:\n if at.x < 0. :\n at.x = self.coordx + at.x\n if at.y < 0. :\n at.y = self.coordy + at.y\n if at.z < 0. :\n at.z = self.coordz + at.z",
"def normalize(x: float, y: float, z: float) -... | [
"0.590805",
"0.5795389",
"0.57775766",
"0.5757381",
"0.57563263",
"0.5741311",
"0.5574767",
"0.55609614",
"0.5502854",
"0.5428551",
"0.5414894",
"0.54088646",
"0.53742325",
"0.53569907",
"0.5342718",
"0.5341974",
"0.53404593",
"0.5298294",
"0.528077",
"0.5277419",
"0.5259355"... | 0.0 | -1 |
Gets container name from config | def get_container(self, profile, exec_cmd):
container = None
if self._value.has_option(profile, 'container'):
container = self._value.get(profile, 'container')
elif exec_cmd is not None:
self.logger.error(
"No container parameter found"
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_container_name(self) -> str:\n dirname = os.path.basename(os.getcwd())\n default_container_name = f\"{dirname}_{self.config_name}\"\n container_name = self.config_options.get(\"container_name\", default_container_name)\n return container_name",
"def container_name(self):\n ... | [
"0.848083",
"0.7720753",
"0.74719864",
"0.7436711",
"0.71182317",
"0.69952506",
"0.69952506",
"0.6851204",
"0.6824859",
"0.68244964",
"0.68061346",
"0.67486334",
"0.67483985",
"0.6723277",
"0.66266924",
"0.6604209",
"0.65961",
"0.65818775",
"0.64978147",
"0.64693797",
"0.6468... | 0.5624748 | 79 |
Retrieves the id of the comment. | def number(self) -> int:
return self._id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comment_id(self):\n return int(self.request.get('cid'))",
"def get_id_from_comments(raw_action):\n act_id_re = re.compile(r\"/\\*[ ]*id:(?P<id>[\\w-]+)\")\n act_id_m = act_id_re.search(raw_action)\n if act_id_m:\n return act_id_m.group(1)\n else:\n logger.error(\"Cannot f... | [
"0.8240708",
"0.6875191",
"0.6868295",
"0.6743244",
"0.6741388",
"0.6741388",
"0.6741388",
"0.6741388",
"0.6741388",
"0.6741388",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"0.6730074",
"... | 0.0 | -1 |
r""" Retrieves the content of the comment. >>> from os import environ >>> note = GitLabComment(GitLabOAuthToken(environ['GITLAB_TEST_TOKEN']), ... 'gitmatetestuser/test', 1, ... CommentType.ISSUE, 31500135) >>> note.body 'Lemme comment on you.\r\n' | def body(self) -> str:
return self.data['body'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_issue_get_comment(self):\n pass",
"async def fetch_comment_body(self, community_id, comment_id) -> str:\n comment_url = f\"{self._api_communities_url}{str(community_id)}/comments/{comment_id}/\"\n async with self.web_session.get(comment_url, headers=self._headers) as resp:\n ... | [
"0.6881756",
"0.65997547",
"0.65781164",
"0.6407747",
"0.63365275",
"0.62870747",
"0.6282959",
"0.62537706",
"0.6234587",
"0.6227583",
"0.6215499",
"0.62143075",
"0.61864215",
"0.6151093",
"0.6150658",
"0.61204064",
"0.6104573",
"0.6072021",
"0.6069789",
"0.6050622",
"0.60506... | 0.0 | -1 |
Fits the distribution and returns the parameters. | def _fit_distribution(sample, name):
if name == WEIBULL_2P_KEYWORD:
# Do not fit the location parameter because it is 0 for a 2-p. dist.
params = sts.weibull_min.fit(sample, floc=0)
elif name == WEIBULL_3P_KEYWORD or \
name == WEIBULL_3P_KEYWORD_ALTERNATIV... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_distribution_samples(self, set_count, parameter_count):\n self._samples = numpy.zeros((set_count, parameter_count))\n for i, distribution in enumerate(self.parameter_distributions.values()):\n self._samples[:, i] = distribution.ppf(self._quantiles[:, i])",
"def initializeDi... | [
"0.6415332",
"0.6410556",
"0.63539106",
"0.6326551",
"0.6314661",
"0.61765975",
"0.60896796",
"0.6074439",
"0.60251886",
"0.5981198",
"0.5981165",
"0.5974641",
"0.5943693",
"0.59214693",
"0.59184223",
"0.5915257",
"0.5894126",
"0.5885357",
"0.58645386",
"0.5860529",
"0.585798... | 0.6134794 | 6 |
Return an iterator over the values of a dictionary. | def itervalues(d):
return iter(getattr(d, _itervalues)()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def itervalues(d):\n return iter(getattr(d, _itervalues)())",
"def itervalues(self):\n return DictValuesIterator(self)",
"def itervalues(self):\n return iter(kvp.value for kvp in self.keyvaluepair_set.all())",
"def itervalues(self):\n for key in self:\n yield self[key]",
... | [
"0.7602316",
"0.7579183",
"0.74967605",
"0.7470779",
"0.74170566",
"0.7331451",
"0.7330688",
"0.7330688",
"0.7212818",
"0.7150901",
"0.71241814",
"0.706779",
"0.70010054",
"0.6997674",
"0.69058275",
"0.68918097",
"0.68831944",
"0.68815",
"0.68725574",
"0.6853274",
"0.6829952"... | 0.7592978 | 1 |
Return an iterator over the (key, value) pairs of a dictionary. | def iteritems(d):
return iter(getattr(d, _iteritems)()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self) -> iter:\n return iter(self._dict)",
"def iteritems(self):\n return iter((kvp.key, kvp.value) for kvp in self.keyvaluepair_set.all())",
"def iter_over_pairs(pairs):\r\n if isinstance(pairs, dict):\r\n return pairs.iteritems()\r\n else:\r\n return pairs",
"... | [
"0.69681364",
"0.6962657",
"0.68685055",
"0.6746838",
"0.67312443",
"0.67283183",
"0.672741",
"0.6719771",
"0.670634",
"0.6694921",
"0.6673996",
"0.66608566",
"0.66370773",
"0.65998065",
"0.659718",
"0.6581123",
"0.65757334",
"0.6571146",
"0.65570706",
"0.65514755",
"0.655086... | 0.6518555 | 21 |
Returns True if the node in question is the a final output of the graph | def _is_function_output(node):
return node.clients == [('output', 1)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsOutputNode(self) -> bool:\n return self._isoutput",
"def is_final_node_reached(self):\n if self.actual_node == self.final_node:\n self.final_node_reached = True",
"def is_node_output_tensor(node: pippy.fx.Node) -> bool:\n type_ = node.meta.get(\"type\", None)\n retu... | [
"0.77477425",
"0.74063003",
"0.6975112",
"0.6890987",
"0.6805093",
"0.6588345",
"0.6432544",
"0.6431052",
"0.6399698",
"0.63903904",
"0.6376161",
"0.635022",
"0.62780064",
"0.6251684",
"0.61636066",
"0.61571634",
"0.6119863",
"0.6084669",
"0.6066547",
"0.6052634",
"0.60419613... | 0.6764444 | 5 |
Add a SymbolicInput to this SymbolicInputKit. It will be given the next available index. | def add_input(self, sinput):
self.sinputs.append(sinput)
self.variables.append(sinput.variable) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_symbol(self, symbol):\n self.symbols_list.append(symbol)\n self.symbols_list.sort()",
"def addInput(self, input):\n\t\tself.config._WITH_ACTIONS = True\n\t\tself.config.ACTIONS.append((\"input\", input))",
"def add_symbol(self, symbol: str):\n return self._call_txtrader_api('add_sy... | [
"0.6374103",
"0.60815185",
"0.6043445",
"0.59524095",
"0.57244396",
"0.56974417",
"0.55663705",
"0.5561682",
"0.55237937",
"0.551715",
"0.5495903",
"0.5468849",
"0.5442254",
"0.5409101",
"0.536408",
"0.5363238",
"0.534291",
"0.53173983",
"0.5313006",
"0.52936566",
"0.5248325"... | 0.6293376 | 1 |
Returns True iff x[0] and y[0] are equal (checks the dtype and shape if x and y are numpy.ndarray instances). Used internally. | def check_equal(x, y):
#I put the import here to allow using theano without scipy.
import scipy.sparse as sp
x, y = x[0], y[0]
# TODO: bug in current scipy, two sparse matrices are never equal,
# remove when moving to 0.7
if sp.issparse(x):
x = x.todense()
if sp.issparse(y)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_equal_numpy(x, y):\r\n if isinstance(x, numpy.ndarray) and isinstance(y, numpy.ndarray):\r\n return (x.dtype == y.dtype and x.shape == y.shape and\r\n numpy.any(abs(x - y) < 1e-10))\r\n elif (isinstance(x, numpy.random.RandomState) and\r\n isinstance(y, numpy.random.R... | [
"0.8008812",
"0.74770236",
"0.7457018",
"0.735011",
"0.73161024",
"0.72633797",
"0.7232195",
"0.72056144",
"0.7174843",
"0.7095441",
"0.7047447",
"0.7022002",
"0.7020078",
"0.69643164",
"0.69617593",
"0.69617593",
"0.6960392",
"0.694367",
"0.69084954",
"0.690454",
"0.6892232"... | 0.69050866 | 19 |
Returns a pretty representation of this Component, suitable for reading. | def pretty(self, **kwargs):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pretty(self):\n return self._pretty",
"def __repr__(self):\n return self.pretty_print(self.__dict__)",
"def pretty_string(self):\n return self._tree.toStringPrettyPrint()",
"def pprint(self):\n return pformat(repr(self))",
"def to_str(self):\r\n return pprint.pformat(... | [
"0.72761077",
"0.7178471",
"0.7152357",
"0.70341957",
"0.6964391",
"0.6964391",
"0.69627476",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
"0.69573164",
... | 0.0 | -1 |
Generator that yields each component in a flattened hierarchy of composites and components. If include_self is True, the list will include the Composite instances, else it will only yield the list of leaves. | def flat_components(self, include_self=False):
if include_self:
yield self
for component in self.components():
if isinstance(component, Composite):
for x in component.flat_components(include_self):
yield x
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flat_components_map(self, include_self=False, path=None):\r\n if path is None:\r\n path = []\r\n if include_self:\r\n yield path, self\r\n for name, component in self.components_map():\r\n path2 = path + [name]\r\n if isinstance(component, Compos... | [
"0.6992409",
"0.6084985",
"0.5757968",
"0.5734442",
"0.5720213",
"0.56474704",
"0.5640951",
"0.5568628",
"0.55393916",
"0.55392057",
"0.5514311",
"0.54669154",
"0.5463918",
"0.5455544",
"0.5455544",
"0.5446699",
"0.54455614",
"0.5434089",
"0.54283005",
"0.54162574",
"0.537705... | 0.838234 | 0 |
Get the nonsymbolic value associated with this SharedVariable. | def get_value(self, borrow=False, return_internal_type=False):
if borrow:
return self.container.value
else:
return copy.deepcopy(self.container.value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def silicate(self):\n index = self.var_index(6)\n return self.var_data(index)",
"def get_nonzeros(self):\n return self.tape.get_nonzeros(self.machine.eval_symbol,\n self.machine.eval_state(self.state))",
"def independent_variable(self):\n return self._in... | [
"0.61495614",
"0.58948064",
"0.58204705",
"0.5811126",
"0.5708589",
"0.5692064",
"0.55980664",
"0.5577027",
"0.55735016",
"0.55722296",
"0.5556489",
"0.55536443",
"0.5509104",
"0.54866993",
"0.5485108",
"0.5481467",
"0.54575944",
"0.5393343",
"0.5336514",
"0.5320439",
"0.5311... | 0.0 | -1 |
Test that a module can be pickled | def test_pickle():
M = Module()
M.x = (T.dmatrix())
M.y = (T.dmatrix())
a = T.dmatrix()
M.f = Method([a], a + M.x + M.y)
M.g = Method([a], a * M.x * M.y)
mode = get_mode()
m = M.make(x=numpy.zeros((4,5)), y=numpy.ones((2,3)), mode=mode)
m_dup = cPickle.loads(cPickle.dump... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__pickle_unpickle(self):\n pass",
"def can_be_pickled(x):\n try:\n s = BytesIO() \n pickle.dump(x, s) \n return True\n except:\n return False",
"def test_instmap_picklable(self):\n instmap = FakeAthens().defaults().instruction_schedule_map\n\n se... | [
"0.7558778",
"0.64533925",
"0.64065087",
"0.6353409",
"0.62765557",
"0.62762725",
"0.6252986",
"0.6215321",
"0.61752874",
"0.61294466",
"0.61104",
"0.60432255",
"0.6041333",
"0.6023468",
"0.59874004",
"0.59629446",
"0.59398067",
"0.5928395",
"0.59113646",
"0.5904105",
"0.5861... | 0.59297585 | 17 |
Return True iff both paths can be considered to point to the same module. | def is_same_entry(entry_1, entry_2):
if entry_1 == entry_2:
return True
if os.path.realpath(entry_1) == os.path.realpath(entry_2):
return True
if (os.path.basename(entry_1) == os.path.basename(entry_2) and
(os.path.basename(os.path.dirname(entry_1)) ==
os.path.basenam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def areSamePaths(path1, path2):\n\n path1 = os.path.abspath(os.path.normpath(path1))\n path2 = os.path.abspath(os.path.normpath(path2))\n\n if os.path.exists(path1) and os.path.exists(path2):\n path1 = getExternalUsePath(path1)\n path2 = getExternalUsePath(path2)\n\n path1 = os.path.normc... | [
"0.68801486",
"0.68076736",
"0.6644885",
"0.6581731",
"0.6528018",
"0.64050454",
"0.6393831",
"0.62317806",
"0.6191378",
"0.61807054",
"0.6154301",
"0.6144785",
"0.612932",
"0.60928464",
"0.60600746",
"0.60182685",
"0.59786165",
"0.5886876",
"0.5879789",
"0.5873587",
"0.58333... | 0.5934718 | 17 |
Return path to the module file. | def get_entry(self):
# TODO This method may be removed in the future (e.g. in 0.5) since
# its only purpose is to make sure that old KeyData objects created
# before the 'entry' field was added are properly handled.
if not hasattr(self, 'entry'):
self.entry = module_name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def module_path():\n return os.path.dirname(unicode(__file__, sys.getfilesystemencoding( )))",
"def _get_module_path():\n\n return os.path.dirname(os.path.realpath(__file__))",
"def get_module_path(module):\n return pathlib.Path(os.path.dirname(os.path.abspath(inspect.getfile(module))))",
"def modul... | [
"0.8536127",
"0.8364552",
"0.82391655",
"0.81550163",
"0.81112397",
"0.8007872",
"0.7887397",
"0.77348375",
"0.76793945",
"0.7648227",
"0.7569188",
"0.7533521",
"0.7532497",
"0.7470884",
"0.74592006",
"0.74340403",
"0.7433563",
"0.743165",
"0.74219126",
"0.73809534",
"0.73182... | 0.0 | -1 |
Return location of the user's home directory. | def get_home_dir():
home = os.getenv('HOME')
if home is None:
# This expanduser usually works on Windows (see discussion on
# theano-users, July 13 2010).
home = os.path.expanduser('~')
if home == '~':
# This might happen when expanduser fails. Although the cau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_home_dir(self) -> str:\n ret = os.path.expanduser(\"~\")\n if not os.path.exists(ret):\n raise RuntimeError(\"The home directory does not exist.\")\n return ret",
"def get_user_homedir():\n return os.path.expanduser(\"~\")",
"def homedir():\n return os.path.expandu... | [
"0.8847633",
"0.8795914",
"0.8778984",
"0.8669398",
"0.8519436",
"0.84935045",
"0.8429107",
"0.8429107",
"0.82711875",
"0.81593674",
"0.81309587",
"0.7984031",
"0.78639066",
"0.77803457",
"0.77352375",
"0.7718833",
"0.76106584",
"0.7273814",
"0.7246041",
"0.7237655",
"0.71830... | 0.85374445 | 4 |
Return a list of the parents of this node. Should return a copyi.e., modifying the return value should not modify the graph structure. | def get_parents(self):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parents(self):\n p = self\n result = []\n while p:\n result.append(p)\n p = p.parent\n return result",
"def get_parents(self):\n return NodeList(self._my_map['parentNodes'])",
"def parents(self):\n if self._pedigree is None:\n raise... | [
"0.8513887",
"0.834181",
"0.81859875",
"0.8182216",
"0.8159602",
"0.79699004",
"0.7882261",
"0.7873284",
"0.7825455",
"0.7747307",
"0.75695837",
"0.75200754",
"0.7498095",
"0.74000835",
"0.7391481",
"0.7391481",
"0.7389132",
"0.7348317",
"0.73140126",
"0.7303841",
"0.72947526... | 0.7502715 | 12 |
Return the variables that contribute to those in variable_list (inclusive). | def ancestors(variable_list, blockers=None):
def expand(r):
if r.owner and (not blockers or r not in blockers):
return reversed(r.owner.inputs)
dfs_variables = stack_search(deque(variable_list), expand, 'dfs')
return dfs_variables | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_occuring_variables(formula,variables_to_consider,allowed_variables) :\n variable_set=set(allowed_variables)\n for clause in formula :\n variables_in_clause = {abs(l) for l in clause if abs(l) in variables_to_consider}\n if not variables_in_clause <= variable_set:\n return False, [v for v in ... | [
"0.6693941",
"0.6594262",
"0.6554409",
"0.62701166",
"0.622425",
"0.61425227",
"0.60703",
"0.6052537",
"0.6041542",
"0.5960953",
"0.594741",
"0.59431475",
"0.59401387",
"0.5936862",
"0.5915563",
"0.5867096",
"0.58546484",
"0.5852298",
"0.5807339",
"0.58015394",
"0.58000255",
... | 0.5763826 | 25 |
Return the inputs required to compute the given Variables. | def inputs(variable_list, blockers=None):
vlist = ancestors(variable_list, blockers)
rval = [r for r in vlist if r.owner is None]
return rval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_inputs():\n inputs = tf.placeholder(tf.int32, [None, None], name='input')\n targets = tf.placeholder(tf.int32,[None, None], name='targets')\n learning_rate = tf.placeholder(tf.float32, name='learning_rate')\n\n return inputs, targets, learning_rate",
"def variables(self) -> pulumi.Input[Sequ... | [
"0.6611655",
"0.6557171",
"0.6557171",
"0.6556392",
"0.6501426",
"0.6432337",
"0.6410675",
"0.62868255",
"0.62282425",
"0.6218341",
"0.6177924",
"0.6164701",
"0.6164071",
"0.6146165",
"0.6122791",
"0.6113014",
"0.6113014",
"0.6113014",
"0.61082953",
"0.60911226",
"0.6084602",... | 0.56837964 | 66 |
Return True iff Variables `var1` and `var2` perform the same computation. By 'performing the same computation', we mean that they must share the same graph, so that for instance this function will return False when comparing (x (y z)) with ((x y) z). The current implementation is not efficient since, when possible, it ... | def is_same_graph(var1, var2, givens=None, debug=False):
# Lazy import.
if givens is None:
givens = {}
global equal_computations, is_same_graph_with_merge
if equal_computations is None:
from theano.gof.opt import is_same_graph_with_merge
from theano.scan_module.scan_utils ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_same_graph_with_merge(var1, var2, givens=None):\r\n if givens is None:\r\n givens = {}\r\n # Copy variables since the MergeOptimizer will modify them.\r\n copied = copy.deepcopy([var1, var2, givens])\r\n vars = copied[0:2]\r\n givens = copied[2]\r\n # Create FunctionGraph.\r\n in... | [
"0.6839219",
"0.62304133",
"0.61943305",
"0.6158048",
"0.61495817",
"0.6139312",
"0.6125686",
"0.6122211",
"0.61141986",
"0.60144806",
"0.60063297",
"0.59752274",
"0.59546256",
"0.58842134",
"0.5842495",
"0.5840016",
"0.5838823",
"0.5833646",
"0.5802203",
"0.5784278",
"0.5758... | 0.6730959 | 1 |
A cmp function for nodes in a graph does a depend on b? Returns positive number if a depends on b Returns negative number if b depends on a Returns 0 otherwise | def dependence(a, b):
if depends((a, b)):
return 1
if depends((b, a)):
return -1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dependence_cmp():\r\n\r\n depends = make_depends()\r\n\r\n def dependence(a, b):\r\n \"\"\" A cmp function for nodes in a graph - does a depend on b?\r\n\r\n Returns positive number if a depends on b\r\n Returns negative number if b depends on a\r\n Returns 0 otherwise\r\... | [
"0.7480506",
"0.7094385",
"0.7062442",
"0.6594982",
"0.65599006",
"0.6523148",
"0.647924",
"0.6472027",
"0.6430457",
"0.6337164",
"0.6287762",
"0.6217025",
"0.605961",
"0.60068715",
"0.5983349",
"0.5936095",
"0.59320325",
"0.591268",
"0.59016865",
"0.58851886",
"0.58820677",
... | 0.6830435 | 3 |
Test `is_same_graph` with some trivial graphs (one Variable). | def test_single_var(self):
x, y, z = tensor.vectors('x', 'y', 'z')
self.check([
(x, x, (({}, True), )),
(x, y, (({}, False), ({y: x}, True), )),
(x, tensor.neg(x), (({}, False), )),
(x, tensor.neg(y), (({}, False), )),
]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unique_graph(self):\n g0_graph = tf.Graph()\n with g0_graph.as_default():\n tf.constant(1, name=\"a\")\n tf.constant(2, name=\"b\")\n g1_graph = tf.Graph()\n with g1_graph.as_default():\n tf.constant(1, name=\"a\")\n tf.constant(2, name=\"b\")\n\n g0 = gde.Graph(g0_graph... | [
"0.7752366",
"0.7091291",
"0.6871106",
"0.6626253",
"0.66199636",
"0.65880543",
"0.65497124",
"0.65315586",
"0.6456897",
"0.64434046",
"0.6422406",
"0.6401094",
"0.6376651",
"0.63215494",
"0.63189197",
"0.6304111",
"0.62874687",
"0.62744987",
"0.62579757",
"0.6241734",
"0.615... | 0.0 | -1 |
Return True if a and b can be considered exactly equal. a and b are assumed to be valid values of this Type. | def values_eq(self, a, b):
return a == b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_equal(self, a, b):\n return a is b",
"def is_equal(self, a, b):\n return a == b",
"def _equal_values(self, val1, val2):\n if self.f_supports(val1) != self.f_supports(val2):\n return False\n\n if not self.f_supports(val1) and not self.f_supports(val2):\n ... | [
"0.7593079",
"0.74554974",
"0.7056914",
"0.7051092",
"0.7017823",
"0.6940973",
"0.6938904",
"0.6812031",
"0.66926485",
"0.6656152",
"0.65766394",
"0.6576429",
"0.65478915",
"0.65193045",
"0.6518153",
"0.65016365",
"0.6499767",
"0.6449494",
"0.6446223",
"0.6413474",
"0.6405464... | 0.69134593 | 7 |
Return True if a and b can be considered approximately equal. | def values_eq_approx(self, a, b):
return self.values_eq(a, b)
# def get_shape_info(self, obj):
"""
Optional function. See TensorType().get_shape_info for definition
"""
# def get_size(self, shape_info):
"""
Optional function. See TensorType().get_size fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def almost_equal(a, b, tol=0.0001):\n \n try:\n return a==b or (max(a, b)/min(a, b)) - 1 < tol\n except ZeroDivisionError:\n return False",
"def approx_eq(a, b):\n return abs(a-b) < approx_eq.eps",
"def nearly_equal(a, b, sig_fig=5):\n return a == b or int(a*10**sig_fig) == int(b*1... | [
"0.80643064",
"0.80593413",
"0.8030665",
"0.7976721",
"0.7924514",
"0.78001225",
"0.76892865",
"0.76732624",
"0.7642295",
"0.7630095",
"0.7607067",
"0.75780535",
"0.7509288",
"0.75025356",
"0.7490384",
"0.7445455",
"0.74295497",
"0.742808",
"0.7414975",
"0.7407847",
"0.739863... | 0.0 | -1 |
The unification succeeds iff other_object not in NV.not_options | def unify_walk(nv, o, U):
if o in nv.not_options:
return False
else:
v = BoundVariable("?", o)
return U.merge(v, nv) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other):\n if not isinstance(other, MtreeIntegratedUsage):\n return True\n\n return self.to_dict() != other.to_dict()",
"def __ne__(self, other):\n if not isinstance(other, Options):\n return True\n\n return self.to_dict() != other.to_dict()",
"... | [
"0.64623135",
"0.6445036",
"0.62978894",
"0.62227875",
"0.622242",
"0.6196429",
"0.6166669",
"0.61565065",
"0.6138296",
"0.6135891",
"0.6081893",
"0.6069194",
"0.60682684",
"0.60671914",
"0.60661155",
"0.6051658",
"0.6035081",
"0.6011689",
"0.5999611",
"0.59952617",
"0.599321... | 0.5953622 | 27 |
Tries to unify values of corresponding keys. | def unify_walk(d1, d2, U):
for (k1, v1) in d1.items():
if d2.has_key(k1):
U = unify_walk(v1, d2[k1], U)
if U is False:
return False
return U | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_values(values: dict):\n for (key, value) in values.items():\n if isinstance(value, list):\n values.update({key: value[0]})",
"def clean_dict_values(d: dict, rogue_values: list) -> dict:\n return {key: value for key, value in d.items() if not value in rogue_values}... | [
"0.61672544",
"0.5747395",
"0.5674233",
"0.5648638",
"0.56388474",
"0.5589462",
"0.5551371",
"0.55288845",
"0.55036575",
"0.5488108",
"0.5466464",
"0.54623944",
"0.5459648",
"0.54524153",
"0.54287267",
"0.54234004",
"0.54179513",
"0.5406062",
"0.53863984",
"0.5382555",
"0.537... | 0.52478606 | 31 |
Return absolute and relative error between a and b. The relative error is a small number when a and b are close, relative to how big they are. | def abs_rel_err(a, b):
abs_err = abs(a - b)
rel_err = abs_err / numpy.maximum(abs(a) + abs(b), 1e-8)
# The numpy.asarray are needed as if a or b is a sparse matrix
# this would result in a numpy.matrix and not a numpy.ndarray
# and the behave differently causing problem late... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abs_rel_err(a, b, eps=1.0e-10):\r\n return abs(a - b) / (abs(a) + abs(b) + eps)",
"def abs_rel_err(a, b, eps=1.0e-10):\r\n return abs(a - b) / (abs(a) + abs(b) + eps)",
"def abs_rel_err(a, b):\n abs_err = abs(a - b)\n # 1e-8 is to prevent division by zeros.\n # [] is to m... | [
"0.84385055",
"0.84385055",
"0.8414701",
"0.8018052",
"0.77082133",
"0.7497964",
"0.7468024",
"0.6798173",
"0.66960436",
"0.6536662",
"0.6444666",
"0.63196385",
"0.61937445",
"0.6106722",
"0.6106722",
"0.6089169",
"0.60532755",
"0.60479444",
"0.60158896",
"0.6013913",
"0.6013... | 0.8349792 | 3 |
Find the biggest error between g_pt and self.gf. What is measured is the violation of relative and absolute errors, wrt the provided tolerances (abs_tol, rel_tol). A value > 1 means both tolerances are exceeded. Return the argmax of min(abs_err / abs_tol, rel_err / rel_tol) over g_pt, as well as abs_err and rel_err at ... | def max_err(self, g_pt, abs_tol, rel_tol):
pos = []
errs = []
abs_errs = []
rel_errs = []
abs_rel_errs = self.abs_rel_errors(g_pt)
for abs_err, rel_err in abs_rel_errs:
if not numpy.all(numpy.isfinite(abs_err)):
raise ValueError('abs_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_err(self, g_pt, abs_tol, rel_tol):\n pos = []\n errs = []\n abs_errs = []\n rel_errs = []\n\n abs_rel_errs = self.abs_rel_errors(g_pt)\n for abs_err, rel_err in abs_rel_errs:\n if not np.all(np.isfinite(abs_err)):\n raise ValueError(\"abs_... | [
"0.87032974",
"0.7645797",
"0.76436096",
"0.6662744",
"0.6643494",
"0.6263579",
"0.5839423",
"0.5782929",
"0.57302415",
"0.57302415",
"0.5640657",
"0.56083953",
"0.5585806",
"0.5550195",
"0.55121493",
"0.5490925",
"0.54227644",
"0.5417801",
"0.54095495",
"0.5397066",
"0.53810... | 0.8664696 | 1 |
Returns 'yes', 'no', or 'maybe' indicating whether x is always 0. 'maybe' means that x is an expression that is complicated enough that we can't tell that it simplifies to 0. | def _is_zero(x):
if not hasattr(x, 'type'):
return np.all(x == 0.)
if isinstance(x.type, NullType):
return 'no'
if isinstance(x.type, DisconnectedType):
return 'yes'
no_constant_value = True
try:
constant_value = theano.get_scalar_constant_value(x)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_zero(x):\n if not hasattr(x, \"type\"):\n return np.all(x == 0.0)\n if isinstance(x.type, NullType):\n return \"no\"\n if isinstance(x.type, DisconnectedType):\n return \"yes\"\n\n no_constant_value = True\n try:\n constant_value = aesara.get_scalar_constant_value... | [
"0.7054687",
"0.6683766",
"0.63491225",
"0.6110928",
"0.6048906",
"0.60232204",
"0.5994051",
"0.5977918",
"0.59568125",
"0.59534955",
"0.5932242",
"0.5904407",
"0.577068",
"0.5762852",
"0.57370543",
"0.5716782",
"0.5716782",
"0.5700796",
"0.5674135",
"0.56636804",
"0.5654088"... | 0.7232924 | 0 |
take a gnumpy.garray and make a CudaNdarray that point to its memory | def garray_to_cudandarray(x):
if not isinstance(x, gnumpy.garray):
raise ValueError("We can transfer only gnumpy.garray to CudaNdarray")
# elif x.dtype != "float32":
# raise ValueError("CudaNdarray support only float32")
# We don't need this, because cudamat is alway... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cudandarray_to_garray(x, copyif=False):\r\n if not isinstance(x, cuda.CudaNdarray):\r\n raise ValueError(\"We can transfer only CudaNdarray to cudamat.CUDAMatrix\")\r\n else:\r\n # Check if it is c contiguous\r\n size = 1\r\n c_contiguous = True\r\n ... | [
"0.746835",
"0.65444404",
"0.6414968",
"0.6384258",
"0.62085605",
"0.6202797",
"0.615836",
"0.6153916",
"0.612337",
"0.6120412",
"0.611244",
"0.60924983",
"0.6029814",
"0.6022452",
"0.59826773",
"0.5947319",
"0.593716",
"0.593407",
"0.5905838",
"0.5894318",
"0.5867861",
"0.... | 0.7276369 | 1 |
Convert the input to a Numpy array. This function is almost identical to ``numpy.asarray``, but it should be used instead of its numpy counterpart when a data type is provided in order to perform type conversion if required. The reason is that ``numpy.asarray`` may not actually update the array's data type to the userp... | def _asarray(a, dtype, order=None):
if str(dtype) == 'floatX':
dtype = theano.config.floatX
dtype = numpy.dtype(dtype) # Convert into dtype object.
rval = numpy.asarray(a, dtype=dtype, order=order)
# Note that dtype comparison must be done by comparing their `num`
# attribute. One can... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asarray(input, dtype=None, order='C'):\n\n if (use_origin_backend(input)):\n return numpy.asarray(input, dtype=dtype, order=order)\n\n return array(input, dtype=dtype, order=order)",
"def _asarray(v):\n try:\n return np.asarray(v)\n except ValueError:\n return np.asarray(v, d... | [
"0.72970456",
"0.72445655",
"0.71563846",
"0.71563846",
"0.70818067",
"0.69274795",
"0.69151235",
"0.68004596",
"0.67763275",
"0.6753162",
"0.6605542",
"0.66025704",
"0.6405494",
"0.63770455",
"0.6314394",
"0.62920594",
"0.6246302",
"0.6232909",
"0.62216204",
"0.61999863",
"0... | 0.6668961 | 10 |
Make sure that the gnumpy conversion is exact from garray to CudaNdarray back to garray. | def test(shape=(3, 4, 5)):
gpu = theano.sandbox.cuda.basic_ops.gpu_from_host
U = gpu(theano.tensor.ftensor3('U'))
ii = theano.function([U], gpu(U + 1))
A = gnumpy.rand(*shape)
A_cnd = garray_to_cudandarray(A)
assert A_cnd.shape == A.shape
# dtype always float32
# garray don't h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_conversion(backend):\n\n x = np.random.rand(10, 10)\n x_b = backend.from_numpy(x)\n x_c = backend.to_numpy(x_b)\n\n assert np.all(np.isclose(x, x_c))",
"def test00(self):\n a = np.arange(10)\n ac = bcolz.carray(a, dtype='f4')\n self.assertTrue(ac.dtype == np.dtype('f4'))... | [
"0.6994464",
"0.6608874",
"0.66035527",
"0.6354824",
"0.62173927",
"0.6187351",
"0.6178667",
"0.61777043",
"0.6162876",
"0.6125458",
"0.60293585",
"0.60123116",
"0.58750093",
"0.5864557",
"0.5767077",
"0.5644381",
"0.56272805",
"0.5601141",
"0.55897796",
"0.5559056",
"0.55282... | 0.0 | -1 |
Test with some dimensions being 1. CudaNdarray use 0 for strides for those dimensions. | def test_broadcast_dims():
test((1, 2, 3))
test((2, 1, 3))
test((2, 3, 1))
test2((1, 2, 3))
test2((2, 1, 3))
test2((2, 3, 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is1d(a):\n return np.sum(asarray(asarray(a).shape) > 1) <= 1",
"def really1d(arr):\n if np.ndim(arr) != 1:\n return False\n # Empty list or array\n if len(arr) == 0:\n return True\n if np.any(np.vectorize(np.ndim)(arr)):\n return False\n return True",
"def _is_1d_varray... | [
"0.6508139",
"0.6383367",
"0.630075",
"0.6284688",
"0.5972586",
"0.59132063",
"0.5912012",
"0.5896206",
"0.5870626",
"0.5862447",
"0.5778784",
"0.57560235",
"0.5732134",
"0.5672987",
"0.566625",
"0.56356394",
"0.5615398",
"0.56064045",
"0.56022555",
"0.5594817",
"0.55919117",... | 0.5324396 | 49 |
This return the initial value for myresult. If the scalar op have an identity value, return it. Otherwise, check that the scalar op is maximum or minimum and return first_item. It should be the first element of the reduction. As the maximum and minimum of the same value don't change, this work. | def _assign_init(self, first_item):
if hasattr(self.scalar_op, 'identity'):
return str(self.scalar_op.identity)
else:
assert isinstance(self.scalar_op, (scal.Maximum,
scal.Minimum))
return first_item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_store_min(raw_val):\n\n if isinstance(raw_val, list):\n values = []\n for val in raw_val:\n val = auto_type_convert(val)\n if isinstance(val, (int, float)):\n values.append(val)\n if len(values) != 0:\n return min(values)\n e... | [
"0.56963164",
"0.5639446",
"0.5566354",
"0.550338",
"0.5465667",
"0.5442727",
"0.53944665",
"0.5393128",
"0.5375365",
"0.53678405",
"0.53336596",
"0.5301881",
"0.52633715",
"0.52237964",
"0.52147514",
"0.51961225",
"0.5195964",
"0.5195964",
"0.5162853",
"0.5156137",
"0.515613... | 0.6607779 | 0 |
used to time if the collapse of ccontiguous dims are useful | def speed_elemwise_collapse():
shape = (30, 40, 50, 600)
a = cuda_ndarray.CudaNdarray(theano._asarray(numpy.random.rand(*shape),
dtype='float32'))
a = theano._asarray(numpy.random.rand(*shape), dtype='float32')
a2 = tcn.shared_constructor(a, 'a')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_elemwise_collapse7(atol=1e-6):\r\n\r\n shape = (5, 4, 1)\r\n a = cuda_ndarray.CudaNdarray(theano._asarray(numpy.random.rand(*shape),\r\n dtype='float32'))\r\n a = theano._asarray(numpy.random.rand(*shape), dtype='float32')\r\n a2 = tcn.shared_con... | [
"0.6974547",
"0.68365926",
"0.63880366",
"0.63642",
"0.6356944",
"0.63559383",
"0.63113964",
"0.63037145",
"0.6295899",
"0.5908629",
"0.5833238",
"0.5770219",
"0.57677984",
"0.57145184",
"0.5690363",
"0.5688457",
"0.564179",
"0.56380624",
"0.56280696",
"0.55678844",
"0.556718... | 0.6442772 | 2 |
Test when only one inputs have two broadcastable dimension at each ends | def test_elemwise_collapse3():
shape = (4, 5)
a = cuda_ndarray.CudaNdarray(theano._asarray(numpy.random.rand(*shape),
dtype='float32'))
a = theano._asarray(numpy.random.rand(*shape),
dtype='float32')
a2 = tcn.shared_constru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_broadcast_dims():\r\n test((1, 2, 3))\r\n test((2, 1, 3))\r\n test((2, 3, 1))\r\n test2((1, 2, 3))\r\n test2((2, 1, 3))\r\n test2((2, 3, 1))",
"def can_broadcast(shape1, shape2) -> bool:\n return(\n reduce(\n lambda a, b: a and b,\n starmap(\n ... | [
"0.75529397",
"0.72883916",
"0.70285684",
"0.69619596",
"0.67988664",
"0.6687749",
"0.66589093",
"0.6607058",
"0.6471666",
"0.6449814",
"0.63871133",
"0.63461727",
"0.62258756",
"0.6121402",
"0.6089996",
"0.6059735",
"0.6041826",
"0.60411865",
"0.6005385",
"0.5960568",
"0.595... | 0.5491651 | 55 |
Test when all inputs have two broadcastable dimension at the beginning | def test_elemwise_collapse6():
shape = (4, 5)
a = cuda_ndarray.CudaNdarray(theano._asarray(numpy.random.rand(*shape),
dtype='float32'))
a = theano._asarray(numpy.random.rand(*shape), dtype='float32')
a2 = tcn.shared_constructor(a, 'a')
a3 = a2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_broadcast_dims():\r\n test((1, 2, 3))\r\n test((2, 1, 3))\r\n test((2, 3, 1))\r\n test2((1, 2, 3))\r\n test2((2, 1, 3))\r\n test2((2, 3, 1))",
"def can_broadcast(shape1, shape2) -> bool:\n return(\n reduce(\n lambda a, b: a and b,\n starmap(\n ... | [
"0.7875745",
"0.72969246",
"0.7097894",
"0.695109",
"0.6843395",
"0.6822041",
"0.68009156",
"0.6764441",
"0.67141324",
"0.6600717",
"0.6586656",
"0.6550197",
"0.6390824",
"0.63186455",
"0.62614065",
"0.62592936",
"0.61660224",
"0.6139115",
"0.6126956",
"0.60643524",
"0.604867... | 0.54217535 | 73 |
Return a KouhLayer instance with random parameters The parameters are drawn on a range [typically] suitable for finetuning by gradient descent. | def new_filters_expbounds(cls, rng, input, n_in, n_out, n_terms, dtype=None, eps=1e-1,
exponent_range=(1.0, 3.0), filter_range=1.0):
if input.type.ndim != 2:
raise TypeError('matrix expected for input')
if dtype is None:
dtype = input.dtype
_logger.deb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_parameters(X, Y, nb_units_per_hidden_layer):\n # Your code here\n np.random.seed(1)\n params = {}\n L = len(nb_units_per_hidden_layer)\n params['W' + str(1)] = np.random.randn(nb_units_per_hidden_layer[0],X.shape[0] ) * 0.05\n params['b' + str(1)] = np.zeros((nb_units_per_hidden_la... | [
"0.56659424",
"0.55153936",
"0.5451979",
"0.54040116",
"0.5363682",
"0.5361127",
"0.5301681",
"0.5289917",
"0.525093",
"0.5233192",
"0.522925",
"0.521634",
"0.52039164",
"0.518437",
"0.51726776",
"0.51581526",
"0.515205",
"0.51430297",
"0.51405007",
"0.5127815",
"0.5113524",
... | 0.0 | -1 |
Compare True iff other is the same kind of CudaNdarrayType | def __eq__(self, other):
return (type(self) == type(other) and
other.broadcastable == self.broadcastable) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return self.dtype == other.dtype",
"def __eq__(self, other):\r\n return type(self) == type(other) and other.dtype == self.dtype \\\r\n and other.broadcastable == self.broadcastable",
"def __ne__(self, other):\n return self.dtype != other.dtype",
"def... | [
"0.74683815",
"0.6957558",
"0.69269514",
"0.68303984",
"0.6716315",
"0.6671845",
"0.66556525",
"0.6592239",
"0.6573078",
"0.6564348",
"0.65439713",
"0.6509889",
"0.6500799",
"0.6497271",
"0.64948857",
"0.6492905",
"0.64830595",
"0.6417597",
"0.6399741",
"0.63576615",
"0.63286... | 0.5806459 | 91 |
Return a `TensorVariable` of this type | def make_variable(self, name=None):
return self.Variable(self, name=name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable(value, dtype, name=None, broadcastable=None):\n return tf.Variable(value, dtype=dtype, name=name)",
"def as_tensor_variable(x, name=None, ndim=None):\r\n if hasattr(x, '_as_TensorVariable'):\r\n return x._as_TensorVariable() # TODO: pass name and ndim arguments\r\n\r\n if isinstance... | [
"0.7245973",
"0.7147218",
"0.7117805",
"0.6988221",
"0.68730927",
"0.68377215",
"0.6802997",
"0.6773438",
"0.677283",
"0.6751011",
"0.6723398",
"0.670249",
"0.6698477",
"0.6612007",
"0.65937215",
"0.65904784",
"0.65439755",
"0.65426916",
"0.64908344",
"0.6481408",
"0.6480322"... | 0.67485 | 10 |
memset_0 is only an optimized version. True, it mean the value is always 0, so the c code call memset as it is faster. | def __init__(self, memset_0=False):
self.memset_0 = memset_0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_mat_to_zero(self):\n self.init()\n set_to_zero_by_ref(self.ff64_2)\n assert np.all(self.ff64_2 == 0)\n # Set to ones, then test set_to_zero_by_ptr also works\n self.ff64_2 += 1\n assert np.all(self.ff64_2)\n set_to_zero_by_ptr(self.ff64_2)\n asse... | [
"0.6269091",
"0.6154836",
"0.6085545",
"0.5900251",
"0.5653846",
"0.5619798",
"0.55939865",
"0.5507351",
"0.5358995",
"0.53314006",
"0.5324392",
"0.5324209",
"0.5264462",
"0.51861316",
"0.5155425",
"0.5147923",
"0.512601",
"0.5115177",
"0.5101929",
"0.5101929",
"0.50969404",
... | 0.7229926 | 0 |
This return the initial value for myresult. If the scalar op have an identity value, return it. Otherwise, check that the scalar op is maximum or minimum and return first_item. It should be the first element of the reduction. As the maximum and minimum of the same value don't change, this work. | def _assign_init(self, first_item):
if hasattr(self.scalar_op, 'identity'):
return str(self.scalar_op.identity)
else:
assert isinstance(self.scalar_op, (scal.Maximum,
scal.Minimum))
return first_item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_store_min(raw_val):\n\n if isinstance(raw_val, list):\n values = []\n for val in raw_val:\n val = auto_type_convert(val)\n if isinstance(val, (int, float)):\n values.append(val)\n if len(values) != 0:\n return min(values)\n e... | [
"0.5694842",
"0.563787",
"0.55648816",
"0.5502144",
"0.54654175",
"0.54424334",
"0.53936875",
"0.53929025",
"0.5374715",
"0.5367584",
"0.5332664",
"0.5300864",
"0.5262178",
"0.52220464",
"0.52136755",
"0.51951927",
"0.51944184",
"0.51944184",
"0.51615983",
"0.5155807",
"0.515... | 0.6607988 | 1 |
Sample a tensor of given size whose element from a uniform distribution between low and high. If the size argument is ambiguous on the number of dimensions, ndim may be a plain integer to supplement the missing information. | def uniform(self, size, low=0.0, high=1.0, ndim=None, dtype=None,
nstreams=None):
low = as_tensor_variable(low)
high = as_tensor_variable(high)
if dtype is None:
dtype = scal.upcast(config.floatX, low.dtype, high.dtype)
low = cast(low, dtype=dtype)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, *size):\n if len(size) == 1 and isinstance(size[0], Sequence):\n size = size[0]\n size = list(size) + [self.dim]\n\n sample = torch.randn(size, device=self.mu.device) * self.sigma2.sqrt() + self.mu\n return sample",
"def uniform(self, size=None, low=0.0, hi... | [
"0.69606227",
"0.6928723",
"0.688485",
"0.6874379",
"0.6555901",
"0.6526205",
"0.6476599",
"0.62738085",
"0.62738085",
"0.6272244",
"0.6263985",
"0.6089261",
"0.60325223",
"0.60300195",
"0.5954054",
"0.59291595",
"0.5898744",
"0.58458614",
"0.58458614",
"0.58458614",
"0.58458... | 0.68192196 | 4 |
Converts ``ls`` to list if it is a tuple, or wraps ``ls`` into a list if it is not a list already | def to_list(ls):
if isinstance(ls, (list, tuple)):
return list(ls)
else:
return [ls] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def aslist(something):\n return something if isinstance(something, list) else [something]",
"def as_list(arg):\n if _is_list(arg):\n return arg\n return [arg]",
"def listify(obj):\n return obj if isinstance(obj, (list, tuple, type(None))) else [obj]",
"def list_option(s):\n return _conver... | [
"0.6649146",
"0.6589525",
"0.64599854",
"0.64309746",
"0.63880754",
"0.63082623",
"0.62998784",
"0.6283451",
"0.6260725",
"0.6206974",
"0.6190276",
"0.6179658",
"0.61666834",
"0.6165741",
"0.61615974",
"0.61604184",
"0.61553776",
"0.61389256",
"0.61389256",
"0.61389256",
"0.6... | 0.84737563 | 0 |
Return a small number when a and b are close, relative to how big they are | def abs_rel_err(a, b, eps=1.0e-10):
return abs(a - b) / (abs(a) + abs(b) + eps) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected(A, B):\n return 1 / (1 + 10 ** ((B - A) / 150))",
"def consistancy_test(a, b, aErr, bErr = 0):#TODO: fully test this aproach\n return int(np.ceil(np.abs(b - a) / np.sqrt(bErr**2 + aErr**2)))",
"def _divide_and_round(a, b):\n # Based on the reference implementation for divmod_near\n # i... | [
"0.7172267",
"0.7063415",
"0.70475864",
"0.70414245",
"0.70348746",
"0.6946925",
"0.6923174",
"0.68249786",
"0.6805424",
"0.6760006",
"0.67397815",
"0.6638361",
"0.6628291",
"0.66150033",
"0.6609054",
"0.65909",
"0.6589406",
"0.65887254",
"0.6570174",
"0.653173",
"0.6517996",... | 0.63917494 | 30 |
Return the biggest relative error between g_pt and self.gx | def max_err(self, _g_pt):
g_pt = []
for i in xrange(len(_g_pt)):
if self.ndarray_mask[i]:
g_pt.append(_g_pt[i])
elif isinstance(_g_pt[i], numpy.ndarray):
assert numpy.all(_g_pt[i] == 0)
if len(g_pt) != len(self.gx):
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_err(self, _g_pt):\r\n\r\n g_pt = []\r\n for i in xrange(len(_g_pt)):\r\n if self.ndarray_mask[i]:\r\n g_pt.append(_g_pt[i])\r\n elif isinstance(_g_pt[i], numpy.ndarray):\r\n assert numpy.all(_g_pt[i] == 0)\r\n if len(g_pt) != len(self... | [
"0.75810707",
"0.6728311",
"0.6706104",
"0.6593389",
"0.64850944",
"0.6482201",
"0.6475039",
"0.62704813",
"0.6240463",
"0.6214949",
"0.61370844",
"0.6106558",
"0.6066214",
"0.6050489",
"0.6034139",
"0.6032493",
"0.60204875",
"0.6000332",
"0.5920336",
"0.5889475",
"0.58776236... | 0.75786406 | 1 |
Test that random state can be transferred from one theano graph to another. | def test_random_state_transfer():
class Graph:
def __init__(self, seed=123):
self.rng = MRG_RandomStreams(seed)
self.y = self.rng.uniform(size=(1,))
g1 = Graph(seed=123)
f1 = theano.function([], g1.y)
g2 = Graph(seed=987)
f2 = theano.function([], g2.y)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_random_state_transfer(self):\r\n class Graph:\r\n def __init__(self, seed=123):\r\n self.rng = RandomStreams(seed)\r\n self.y = self.rng.uniform(size=(1,))\r\n g1 = Graph(seed=123)\r\n f1 = function([], g1.y)\r\n g2 = Graph(seed=987)\r\n... | [
"0.7806635",
"0.667129",
"0.65549755",
"0.6376478",
"0.6263402",
"0.6215609",
"0.6182762",
"0.59931374",
"0.59447753",
"0.59427",
"0.58517706",
"0.5824361",
"0.58216846",
"0.5778751",
"0.5765696",
"0.5760656",
"0.5747741",
"0.57295966",
"0.56993616",
"0.56939113",
"0.5671116"... | 0.82961094 | 0 |
Symbolically cast `x` to a Scalar of given `dtype`. | def cast(x, dtype):
if dtype == 'floatX':
dtype = config.floatX
_x = as_scalar(x)
if _x.type.dtype == dtype:
return _x
if _x.type.dtype.startswith('complex') and not dtype.startswith('complex'):
raise TypeError('Casting from complex to real is ambiguous: consider'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast(x, dtype):\r\n if dtype == 'floatX':\r\n dtype = config.floatX\r\n\r\n _x = as_tensor_variable(x)\r\n if _x.type.dtype == dtype:\r\n return _x\r\n if _x.type.dtype.startswith('complex') and not dtype.startswith('complex'):\r\n raise TypeError((\r\n 'Casting from... | [
"0.74585915",
"0.67932993",
"0.67926836",
"0.6497529",
"0.64206344",
"0.6187317",
"0.61673284",
"0.614822",
"0.59687865",
"0.5947312",
"0.5923785",
"0.5920606",
"0.5855891",
"0.5594204",
"0.558748",
"0.5552527",
"0.55161744",
"0.5509941",
"0.5408929",
"0.5407855",
"0.53824663... | 0.7687753 | 0 |
Return the C code for this Composite Op. | def init_c_code(self):
subd = dict(
zip(self.fgraph.inputs,
["%%(i%i)s" % i for i in xrange(len(self.fgraph.inputs))])
+ zip(self.fgraph.outputs,
["%%(o%i)s" % i for i in xrange(len(self.fgraph.outputs))]))
for orphan in sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ccode(self):\n from devito.ir.iet.visitors import CGen\n return CGen().visit(self)",
"def get_C_code(self, C_function_name):\n from cascada.bitvector.printing import BvCCodePrinter\n\n width2type = BvCCodePrinter._width2C_type\n\n # in C, * binds to the declarator, not the ... | [
"0.74382824",
"0.6825815",
"0.6790153",
"0.63693726",
"0.6045204",
"0.6039348",
"0.60272574",
"0.6008835",
"0.5952984",
"0.59243566",
"0.5902734",
"0.5891412",
"0.58567685",
"0.58567685",
"0.58567685",
"0.58567685",
"0.5854359",
"0.58324504",
"0.5821216",
"0.58030146",
"0.573... | 0.63513327 | 4 |
This functions ensures that ``out`` has the same dtype as ``inp`` as well as calling filter_variable to make sure they are both TensorType or CudaNdarrayType. It internally deals with the corner case where inp.ndim + 1 = out.ndim | def format(var, as_var):
if not hasattr(var, 'dtype'):
return var
rval = var
if rval.type.dtype != as_var.type.dtype:
rval = rval.astype(as_var.type.dtype)
if rval.ndim == as_var.ndim:
rval = as_var.type.filter_variab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_type_checking(self, node):\r\n\r\n if not isinstance(node.inputs[0].type, CudaNdarrayType):\r\n raise NotImplementedError()",
"def check_out_dtype(api_fn, in_specs, expect_dtypes, target_index=0, **configs):\n with paddle_static_guard():\n for i, expect_dtype in enumerate(expec... | [
"0.5700036",
"0.5478551",
"0.5444358",
"0.54305047",
"0.53894305",
"0.53726345",
"0.53275836",
"0.530386",
"0.5249604",
"0.52462095",
"0.52267265",
"0.5221992",
"0.51953226",
"0.5177193",
"0.5149556",
"0.5147353",
"0.51221365",
"0.51197225",
"0.511487",
"0.5105944",
"0.510084... | 0.50406295 | 30 |
returns true if l has any duplicates (according to __eq__). | def has_duplicates(l):
return len(set(l)) < len(l) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_duplicates_set(L):\r\n return len(L) != len(set(L))",
"def has_duplicates(L):\r\n unique = []\r\n for e in L:\r\n if e in unique:\r\n return True\r\n unique.append(e)\r\n return False",
"def has_duplicates(lst):\n\n return len(lst) != len(set(lst))",
"def all_d... | [
"0.827208",
"0.82601005",
"0.77031344",
"0.7422962",
"0.7362732",
"0.7362159",
"0.72854084",
"0.7208566",
"0.70778173",
"0.7068668",
"0.6966106",
"0.6904976",
"0.6754918",
"0.67107034",
"0.66911066",
"0.66505605",
"0.6626821",
"0.66199046",
"0.65972435",
"0.6567355",
"0.65267... | 0.8554015 | 0 |
Return a small number when a and b are close, relative to how big they are | def abs_rel_err(a, b, eps=1.0e-10):
return abs(a - b) / (abs(a) + abs(b) + eps) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expected(A, B):\n return 1 / (1 + 10 ** ((B - A) / 150))",
"def consistancy_test(a, b, aErr, bErr = 0):#TODO: fully test this aproach\n return int(np.ceil(np.abs(b - a) / np.sqrt(bErr**2 + aErr**2)))",
"def _divide_and_round(a, b):\n # Based on the reference implementation for divmod_near\n # i... | [
"0.7172267",
"0.7063415",
"0.70475864",
"0.70414245",
"0.70348746",
"0.6946925",
"0.6923174",
"0.68249786",
"0.6805424",
"0.6760006",
"0.67397815",
"0.6638361",
"0.6628291",
"0.66150033",
"0.6609054",
"0.65909",
"0.6589406",
"0.65887254",
"0.6570174",
"0.653173",
"0.6517996",... | 0.63917494 | 31 |
Return the biggest relative error between g_pt and self.gx | def max_err(self, _g_pt):
g_pt = []
for i in xrange(len(_g_pt)):
if self.ndarray_mask[i]:
g_pt.append(_g_pt[i])
elif isinstance(_g_pt[i], numpy.ndarray):
assert numpy.all(_g_pt[i] == 0)
if len(g_pt) != len(self.gx):
ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_err(self, _g_pt):\r\n\r\n g_pt = []\r\n for i in xrange(len(_g_pt)):\r\n if self.ndarray_mask[i]:\r\n g_pt.append(_g_pt[i])\r\n elif isinstance(_g_pt[i], numpy.ndarray):\r\n assert numpy.all(_g_pt[i] == 0)\r\n if len(g_pt) != len(self... | [
"0.75786406",
"0.6728311",
"0.6706104",
"0.6593389",
"0.64850944",
"0.6482201",
"0.6475039",
"0.62704813",
"0.6240463",
"0.6214949",
"0.61370844",
"0.6106558",
"0.6066214",
"0.6050489",
"0.6034139",
"0.6032493",
"0.60204875",
"0.6000332",
"0.5920336",
"0.5889475",
"0.58776236... | 0.75810707 | 0 |
Same as `as_sparse_variable` but If we can't make a sparse variable, we try to make a tensor variable. format. | def as_sparse_or_tensor_variable(x, name=None):
try:
return as_sparse_variable(x, name)
except (ValueError, TypeError):
return theano.tensor.as_tensor_variable(x, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_sparse_variable(x, name=None):\r\n\r\n # TODO\r\n # Verify that sp is sufficiently sparse, and raise a\r\n # warning if it is not\r\n\r\n if isinstance(x, gof.Apply):\r\n if len(x.outputs) != 1:\r\n raise ValueError(\"It is ambiguous which output of a \"\r\n ... | [
"0.78033525",
"0.69434965",
"0.69426894",
"0.67062515",
"0.66421807",
"0.66233003",
"0.6609675",
"0.6587607",
"0.65757",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"0.65701383",
"... | 0.8320486 | 0 |
Construct a sparse matrix of ones with the same sparsity pattern. | def sp_ones_like(x):
# TODO: don't restrict to CSM formats
data, indices, indptr, shape = csm_properties(x)
return CSM(format=x.format)(tensor.ones_like(data), indices, indptr, shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makesparse(matrix):\n n = matrix[0].size\n elements = []\n for i in range(n):\n for j in range(n):\n if matrix[i][j] != 0 :\n temp = MatrixElement(i, j, matrix[i][j])\n elements.append(temp)\n return SparseMatrix(n, elements)",
"def generate_sparse(... | [
"0.73651296",
"0.69551325",
"0.6931981",
"0.6899635",
"0.673322",
"0.6691372",
"0.66438496",
"0.65397567",
"0.65207565",
"0.6475585",
"0.6466727",
"0.64544225",
"0.6454232",
"0.6444037",
"0.6420785",
"0.63349074",
"0.6301656",
"0.62898713",
"0.62797403",
"0.6247648",
"0.62106... | 0.6597544 | 7 |
Construct a sparse matrix of zeros. | def sp_zeros_like(x):
# TODO: don't restrict to CSM formats
_, _, indptr, shape = csm_properties(x)
return CSM(format=x.format)(data=numpy.array([], dtype=x.type.dtype),
indices=numpy.array([], dtype='int32'),
indptr=tensor.zeros_like(in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makesparse(matrix):\n n = matrix[0].size\n elements = []\n for i in range(n):\n for j in range(n):\n if matrix[i][j] != 0 :\n temp = MatrixElement(i, j, matrix[i][j])\n elements.append(temp)\n return SparseMatrix(n, elements)",
"def generate_s_matri... | [
"0.7854581",
"0.725824",
"0.71282923",
"0.7125121",
"0.7095916",
"0.70538086",
"0.699814",
"0.69835925",
"0.6967505",
"0.69490564",
"0.6936071",
"0.69003564",
"0.68625075",
"0.683405",
"0.6825794",
"0.6782413",
"0.6765742",
"0.67656165",
"0.6749142",
"0.6727754",
"0.6722887",... | 0.74044436 | 1 |
return the indptr field of the sparse variable. | def csm_indptr(csm):
return csm_properties(csm)[2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLinIterVarIndx( self, var ):\n \n self.updateAdb( )\n\n if var in self.iterNames:\n return self.iterNames[ var ]\n elif var in self.iterNames.values():\n return var\n else:\n return -1",
"de... | [
"0.6368429",
"0.6021727",
"0.6003801",
"0.58629376",
"0.5741122",
"0.5714157",
"0.5663999",
"0.5647649",
"0.5629932",
"0.55901605",
"0.55812156",
"0.5578166",
"0.5530826",
"0.5499853",
"0.5491709",
"0.548735",
"0.5480442",
"0.5480442",
"0.54627436",
"0.54410255",
"0.54313385"... | 0.72567505 | 0 |
Scale each columns of a sparse matrix by the corresponding element of a dense vector | def col_scale(x, s):
if x.format == 'csc':
return ColScaleCSC()(x, s)
elif x.format == 'csr':
return RowScaleCSC()(x.T, s).T
else:
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_matrix(matrix, k):\n new_matrix = []\n for v in range(NUMBER_VECTORS):\n new_matrix.append(matrix[v].scale(k))\n return new_matrix",
"def apply_scale( vectors, scale ):\n # create a scaling matrix\n matrix = numpy.array([\n [ scale[ 0 ], 0.0, 0.0 ],\n [ 0.0, scale[ 1... | [
"0.7059137",
"0.66901815",
"0.6587453",
"0.64761585",
"0.6454853",
"0.6419277",
"0.64159775",
"0.6389464",
"0.63640267",
"0.63640064",
"0.63577694",
"0.6257491",
"0.62333405",
"0.6229458",
"0.6184725",
"0.6148525",
"0.60534626",
"0.6042722",
"0.6028381",
"0.60094047",
"0.5998... | 0.67728 | 1 |
Scale each row of a sparse matrix by the corresponding element of a dense vector | def row_scale(x, s):
return col_scale(x.T, s).T | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scale_matrix(matrix, k):\n new_matrix = []\n for v in range(NUMBER_VECTORS):\n new_matrix.append(matrix[v].scale(k))\n return new_matrix",
"def scale(self, alpha):\n\t\tc = SparseVector(self.d)\n\t\tfor i in self.st.keys():\n\t\t\tc.put(i, alpha*self.get(i))\n\t\treturn c",
"def apply_scale... | [
"0.70472246",
"0.672525",
"0.6557294",
"0.6499491",
"0.64957833",
"0.64600176",
"0.6442824",
"0.64250773",
"0.6408906",
"0.6355935",
"0.635452",
"0.63498634",
"0.63356835",
"0.62815714",
"0.622665",
"0.6181543",
"0.61597896",
"0.6147584",
"0.6128949",
"0.61090827",
"0.6104064... | 0.6631331 | 2 |
Remove explicit zeros from a sparse matrix, and resort indices. CSR column indices are not necessarily sorted. Likewise for CSC row indices. Use `clean` when sorted indices are required (e.g. when passing data to other libraries) and to ensure there is no zeros in the data. | def clean(x):
return ensure_sorted_indices(remove0(x)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_csm_unsorted(self):\r\n sp_types = {'csc': sp.csc_matrix,\r\n 'csr': sp.csr_matrix}\r\n\r\n for format in ['csr', 'csc', ]:\r\n for dtype in ['float32', 'float64']:\r\n x = tensor.tensor(dtype=dtype, broadcastable=(False,))\r\n y = ... | [
"0.6894709",
"0.61253554",
"0.6090043",
"0.6058734",
"0.5968976",
"0.5950142",
"0.57473177",
"0.5625783",
"0.5438617",
"0.5403211",
"0.5391729",
"0.5385883",
"0.5374858",
"0.5360573",
"0.53557676",
"0.53273404",
"0.53155786",
"0.53014636",
"0.5271759",
"0.52598417",
"0.523991... | 0.65743303 | 1 |
Operation for efficiently calculating the dot product when one or all operands are sparse. Supported formats are CSC and CSR. The output of the operation is sparse. | def true_dot(x, y, grad_preserves_dense=True):
# TODO
# Maybe the triple-transposition formulation
# (when x is dense) is slow. See if there is a
# direct way to do this.
if hasattr(x, 'getnnz'):
x = as_sparse_variable(x)
assert x.format in ["csr", "csc"]
if hasattr(y, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot_sparse(a, b):\n out = a @ b\n\n if isdense(out) and (isinstance(b, qarray) or isinstance(a, qarray)):\n out = qarray(out)\n\n return out",
"def dot(x, y):\r\n\r\n if hasattr(x, 'getnnz'):\r\n x = as_sparse_variable(x)\r\n if hasattr(y, 'getnnz'):\r\n y = as_sparse_vari... | [
"0.7500872",
"0.70212364",
"0.6989696",
"0.6931579",
"0.689175",
"0.6874433",
"0.6826482",
"0.6824428",
"0.67954075",
"0.66793936",
"0.65259653",
"0.6430154",
"0.6345815",
"0.62701505",
"0.60672367",
"0.59521204",
"0.5951297",
"0.59128463",
"0.58662844",
"0.58565414",
"0.5818... | 0.61571884 | 14 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.