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 |
|---|---|---|---|---|---|---|
Return the object as an OrderedDict. Return an ordered dictionary that stores the attributes and their values as keyvalue pairs. | def to_ordered_dict(self, skip_none: bool = True) -> OrderedDict:
ordered_dict: OrderedDict = OrderedDict()
for attr, attr_type in self._attributes.items():
value = getattr(self, attr)
if attr in self._list_attributes:
if not value and skip_none:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_OrderedDict(self):\n return collections.OrderedDict(self.items())",
"def serialize(self):\n return OrderedDict([('name', self.name), ('description', self.description), ('attribute summary', self.attributes), ('tech level', self.tech), ('caste hierarchy', self.casteOrder), ('founded to', self... | [
"0.7829801",
"0.7396522",
"0.7336554",
"0.73293525",
"0.7268713",
"0.7158995",
"0.71494925",
"0.7079589",
"0.70017576",
"0.6962848",
"0.69168186",
"0.6906487",
"0.6811778",
"0.6799378",
"0.67921835",
"0.67702794",
"0.67618585",
"0.6760853",
"0.67270666",
"0.6667317",
"0.66460... | 0.73626405 | 2 |
Return the stored data as a string in a beautiful YAMLlike format. Returns str Stored data as a string in pretty YAMLlike format. See Also | def pretty_str(self) -> str:
return _yaml_dump(self.to_ordered_dict()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n if self.data is None:\n return \"\"\n\n return yaml.dump(self.data, default_flow_style=False, indent=2)",
"def yaml(self):\n return str(self.data)",
"def pretty(self):\n return yaml.dump(self.get_data(), encoding='utf-8',\n def... | [
"0.79755634",
"0.79693836",
"0.77918315",
"0.7052091",
"0.6988744",
"0.68882823",
"0.68859863",
"0.6760443",
"0.67591935",
"0.67363006",
"0.6732812",
"0.66045094",
"0.6599246",
"0.64758766",
"0.6437745",
"0.63371015",
"0.63054925",
"0.6271019",
"0.6260792",
"0.6260792",
"0.62... | 0.7404561 | 3 |
Wrap a callable function that takes a tensor as input and returns a tensor as output with the given layer name. | def __init__(self, callable_fn, output_layer):
super(DefenseWrapper, self).__init__()
self.output_layer = output_layer
self.callable_fn = callable_fn
self.rec_model = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nn_layer_fn(in_dim, out_dim, layer_name, fn=tf.nn.relu):\n with tf.name_scope(layer_name + '_vars'):\n weights_shape = [in_dim, out_dim]\n weights_stddev = 1.0 / math.sqrt(float(in_dim)) #Xavier initialization\n biases_shape = [out_dim]\n biases_val = 0.1 #to avoid dead neurons\n... | [
"0.7034324",
"0.66526884",
"0.64262354",
"0.6308341",
"0.6245271",
"0.624204",
"0.62054116",
"0.6174813",
"0.61470926",
"0.611377",
"0.6112782",
"0.6090464",
"0.60661393",
"0.6059537",
"0.60282093",
"0.60232943",
"0.6022271",
"0.5993665",
"0.59410995",
"0.59387076",
"0.591923... | 0.0 | -1 |
Create a mock object suitable for replacing confluent_kafka.Consumer which has a list_topics method which acts as if a predetermined set of topics exist. | def make_mock_listing_consumer(topics=[]):
def get_topics(topic=None, timeout=None):
nonlocal topics
result = {}
if topic is None:
for topic in topics:
result[topic] = MagicMock() # don't care much what value is
result[topic].error = None # but i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_kafka_consumer(\n kafka_fixture_name: str,\n kafka_topics: Optional[List[str]] = None,\n seek_to_beginning: bool = False,\n scope: str = 'function',\n **consumer_kwargs\n) -> Callable[..., KafkaConsumer]:\n if kafka_topics is None:\n kafka_topics = []\n\n @pytest.fixture(scope=... | [
"0.6605228",
"0.6418212",
"0.6234094",
"0.61997974",
"0.61825895",
"0.6142635",
"0.6128908",
"0.61017543",
"0.6045486",
"0.60094476",
"0.6002151",
"0.5979141",
"0.59018415",
"0.58984995",
"0.58328545",
"0.5803527",
"0.5799088",
"0.5792315",
"0.57541776",
"0.57241386",
"0.5716... | 0.85897976 | 0 |
Generates a list of all positions that the Queen can attack. Alternatively it may be good to use the elegant diagonal summation/difference checks. | def generateQueenAttacks(boardsize, pos):
assert isinstance(pos, Position) and validatePosition(boardsize, pos)
attackList = []
startPos = Position(pos.x, pos.y)
def addAttackList(pos):
for attacked in attackList:
if pos.compare(attacked):
return
attackLi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def moves(self):\n move_list = list()\n for i in range(self.n):\n row = self.queens[i][0]\n col = self.queens[i][1]\n for rd in [-1,0,1]:\n for cd in [-1,0,1]:\n if (rd == 0) and (cd == 0):\n continue\n ... | [
"0.75085545",
"0.7238031",
"0.72162753",
"0.69097525",
"0.68830097",
"0.6834835",
"0.6642358",
"0.66276836",
"0.6615933",
"0.6517043",
"0.6509062",
"0.6507567",
"0.6499198",
"0.649662",
"0.64962876",
"0.6493829",
"0.64880407",
"0.6486416",
"0.64808154",
"0.6464777",
"0.640126... | 0.74447596 | 1 |
Checks whether there are active recommendations for each category for the given marketplace, and if there are, returns the time when recommendations were last updated for each category. | def get_last_updated_time_for_recommendations(self, marketplace_id):
return self.make_request(
"GetLastUpdatedTimeForRecommendations",
{"MarketplaceId": marketplace_id},
method="POST",
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_if_ok_to_update(self):\n current_time = int(time.time())\n last_refresh = self.last_refresh\n if last_refresh is None:\n last_refresh = 0\n if current_time >= (last_refresh + self.refresh_rate):\n return True\n return False",
"def list_recommenda... | [
"0.48689032",
"0.4762724",
"0.47439244",
"0.47338334",
"0.4668525",
"0.46228564",
"0.4600863",
"0.45566443",
"0.45439604",
"0.45418546",
"0.45240474",
"0.4514353",
"0.45044154",
"0.45044154",
"0.45044154",
"0.45044154",
"0.45044154",
"0.45044154",
"0.45044154",
"0.45004466",
... | 0.600832 | 0 |
Create and configure a new app instance for each test. | def app():
print('creating app with test vars')
app = create_app('test')
app.testing = True
ctx = app.app_context()
ctx.push()
yield app
ctx.pop() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_app():\n param = {\n 'DEBUG': True,\n 'TESTING': True\n }\n _app = create_app(settings_override=param)\n\n ctx = _app.app_context()\n ctx.push()\n yield _app\n ctx.pop()",
"def create_app(self):\n app.config.from_object('config.TestingConfig')\n return ap... | [
"0.7984731",
"0.7973278",
"0.7952626",
"0.7610121",
"0.75586873",
"0.7514867",
"0.748489",
"0.7457632",
"0.7457632",
"0.7457632",
"0.7423435",
"0.74221593",
"0.7392862",
"0.7378533",
"0.73515075",
"0.7331986",
"0.7303747",
"0.7297693",
"0.7282327",
"0.7275915",
"0.7273931",
... | 0.7774617 | 3 |
r""" Define linear function for feedback model. \dot{\phi_i} = \omega + f_i(F) \cos \phi_i \alpha \frac{\partial I}{\partial \phi_i} \frac{\partial I}{\partial} = \alpha k \bar{L} A T \sin \phi_i | def _build_network(self):
self.new_trainable_variable("w0_sin", np.zeros(
(config.somites * 2 - 2, HIDDEN_LAYER_UNITS), dtype=np.float64))
self.new_trainable_variable("b0_sin", np.zeros(HIDDEN_LAYER_UNITS, dtype=np.float64))
self.new_trainable_variable("w1_sin", np.zeros(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fLinear(Vc1,Vc2,Vc3,Vk,Vw,Va,Vf,Pc1,Pc2,Pc3,Pk,Pw,Pa,Pf):\n#\n# 1. Normalise volumetric components:\n#\t-----------------------------------\n\tSum=abs(Vc1)+abs(Vc2)+abs(Vc3)+abs(Vk)+abs(Vw)+abs(Va)+abs(Vf)\n\tVc1=abs(Vc1)/Sum\n\tVc2=abs(Vc2)/Sum\n\tVc3=abs(Vc3)/Sum\n\tVk=abs(Vk)/Sum\n\tVw=abs(Vw)/Sum\n\tVa=a... | [
"0.5901483",
"0.5844917",
"0.58126736",
"0.56765157",
"0.55821604",
"0.556544",
"0.54930675",
"0.5452575",
"0.5425468",
"0.5413999",
"0.54028267",
"0.5395225",
"0.5383704",
"0.538336",
"0.53509414",
"0.5347786",
"0.5322218",
"0.52908975",
"0.5286443",
"0.52736217",
"0.5240986... | 0.0 | -1 |
Return the _id field of the current class. We cannot use the "_id" property (i.e. trip._id) because valid properties cannot start with an underscore. We can access it using trip["_id"] but that is cumbersome to use and can throw if the _id field does not exist (which may or may not be what we want). Let's abstract it o... | def get_id(self):
return self["_id"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_id(self):\n return self.id",
"def _get_id(self):\n return self.__id",
"def _get_id(self):\n return self.__id",
"def _get_id(self):\n return self.__id",
"def _get_id(self):\n return self.__id",
"def _get_id(self):\n return self.__id",
"def _get_id(self):\n return self._... | [
"0.71313035",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754",
"0.71026754"... | 0.7405886 | 0 |
Assert that the shape of the input tensor is the expected 5D spatiotemporal shape | def _check_shape(input_shape):
msg = ('Input to FlattenAxis must be 5D with dimensions: '
'(n_observations, n_spatial_0, n_spatial_1, n_temporal, '
'n_features), but received shape: {}'.format(input_shape))
assert len(input_shape) == 5, msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(input_shape):\n msg = ('Input to SpatioTemporalExpansion must be 5D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_temporal, '\n 'n_features), but received shape: {}'.format(input_shape))\n assert len(input_shape) == 5, msg",
"def tes... | [
"0.767875",
"0.6563718",
"0.64985377",
"0.6418538",
"0.64130336",
"0.6398726",
"0.63728774",
"0.630607",
"0.6295184",
"0.629249",
"0.6280885",
"0.62366974",
"0.62299126",
"0.61740613",
"0.61740327",
"0.6142785",
"0.6126741",
"0.61242807",
"0.6100432",
"0.60915726",
"0.6084971... | 0.6978557 | 1 |
Assert that the shape of the input tensor is the expected 4D spatiotemporal shape | def _check_shape(input_shape):
msg = ('Input to SpatialExpansion must be 4D with dimensions: '
'(n_observations, n_spatial_0, n_spatial_1, n_features), '
'but received shape: {}'.format(input_shape))
assert len(input_shape) == 4, msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(input_shape):\n msg = ('Input to SpatioTemporalExpansion must be 5D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_temporal, '\n 'n_features), but received shape: {}'.format(input_shape))\n assert len(input_shape) == 5, msg",
"def tes... | [
"0.71911967",
"0.67564714",
"0.670049",
"0.65799737",
"0.6575327",
"0.6517123",
"0.64665014",
"0.64350545",
"0.64287883",
"0.6360004",
"0.6293485",
"0.6286067",
"0.62737346",
"0.62045807",
"0.6179963",
"0.6166289",
"0.6125939",
"0.6125699",
"0.61026037",
"0.6096365",
"0.60823... | 0.68198144 | 1 |
Assert that the shape of the input tensor is the expected 5D spatiotemporal shape | def _check_shape(input_shape):
msg = ('Input to SpatioTemporalExpansion must be 5D with dimensions: '
'(n_observations, n_spatial_0, n_spatial_1, n_temporal, '
'n_features), but received shape: {}'.format(input_shape))
assert len(input_shape) == 5, msg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(input_shape):\n msg = ('Input to FlattenAxis must be 5D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_temporal, '\n 'n_features), but received shape: {}'.format(input_shape))\n assert len(input_shape) == 5, msg",
"def test_shape(self... | [
"0.697913",
"0.65635157",
"0.6497553",
"0.64191765",
"0.6413171",
"0.63976014",
"0.6373584",
"0.6307098",
"0.6297198",
"0.6292825",
"0.62823594",
"0.62372994",
"0.62291473",
"0.61750543",
"0.6174745",
"0.6141534",
"0.61258924",
"0.61253655",
"0.6100978",
"0.6091626",
"0.60870... | 0.7679232 | 0 |
concatenates a hiresolution feature to the input tensor x in the middle of a sup3r resolution network. | def call(self, x, hi_res_feature):
return tf.concat((x, hi_res_feature), axis=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_feature(x, x1):\n if x is None:\n x = x1\n else:\n x = np.concatenate((x, x1), axis=1)\n return x",
"def forward(self, x_conv_out: torch.Tensor) -> torch.Tensor:\n x_proj = F.relu(self.proj(x_conv_out))\n x_gate = torch.sigmoid(self.gate(x_conv_out))\n x_highwa... | [
"0.6034361",
"0.5986766",
"0.5870083",
"0.58451366",
"0.577961",
"0.5670602",
"0.56492305",
"0.5633024",
"0.53897166",
"0.5371125",
"0.53708494",
"0.5368953",
"0.5363347",
"0.53163177",
"0.5294121",
"0.5290483",
"0.5279402",
"0.5279402",
"0.5259506",
"0.525445",
"0.5245808",
... | 0.7315015 | 0 |
Excludes any questions that aren't published yet. | def get_queryset(self):
return Question.objects.filter(pub_date__lte=timezone.now()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n # the filter says that it only returns those w/ the pub_date\n # less or equal to timezone.now() (earlier or now)\n questions = Question.objects.filter(\n pub_date__lte=timezone.now()\n ).order_by('-pub_date')\n\n excludes = []\n for qu... | [
"0.66057587",
"0.6447535",
"0.6222388",
"0.6170101",
"0.6170101",
"0.6101224",
"0.6100283",
"0.6083196",
"0.6055842",
"0.60525465",
"0.5971601",
"0.5893893",
"0.5893893",
"0.5890032",
"0.5882812",
"0.58696455",
"0.58696455",
"0.58696455",
"0.58696455",
"0.58689994",
"0.585721... | 0.62109476 | 9 |
Strategy Uses the simple nonnormalized ratio between the player's open moves as the evaluation function. No additional features or weights applied. | def custom_score_3(game, player):
if game.is_loser(player):
return float("-inf")
if game.is_winner(player):
return float("inf")
own_moves = number_moves(game, player)
if own_moves == 0:
return float("-inf")
opp_moves = number_moves(game, game.get_opponent(player))
if o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_func(self, game, player):\n if game.is_loser(player):\n return float(\"-inf\")\n \n if game.is_winner(player):\n return float(\"inf\")\n \n own_moves = len(game.get_legal_moves(player))\n opp_moves = len(game.get_legal_moves(game.get_opponent(player)... | [
"0.6862167",
"0.64080334",
"0.6334316",
"0.63151526",
"0.62976205",
"0.62920845",
"0.62802595",
"0.6241796",
"0.6215971",
"0.62003195",
"0.61731195",
"0.61669105",
"0.6163549",
"0.6156453",
"0.6133787",
"0.6128629",
"0.612595",
"0.6125658",
"0.61221373",
"0.60900956",
"0.6078... | 0.0 | -1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, OrderbookUnit):
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.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 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 |
Returns if the user being serialized is the authenticated user | def get_is_self(self, obj: Profile) -> bool:
request: HttpRequest = self.context.get('request')
if request:
if request.user.is_authenticated:
return obj == request.user.profile
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_authenticated(self) -> bool:\n return self.requester.uuid is not None",
"def logged_in(self):\n return self.auth.get_user_by_session() is not None",
"def is_authenticated(self):\r\n return self.authenticated",
"def is_authenticated(self):\n return self.authenticated",
"def is... | [
"0.7471455",
"0.74387443",
"0.7427041",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74122584",
"0.74033606",
"0.737895",
"0.73223656",
"0.7320313",
"... | 0.6572767 | 59 |
Collection of PivotTables that are part of the worksheet. | def pivot_tables(self):
return self.properties.get('pivotTables',
EntityCollection(self.context, WorkbookPivotTable,
ResourcePath("pivotTables", self.resource_path))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tables(self):\n return self.properties.get('tables',\n WorkbookTableCollection(self.context, ResourcePath(\"tables\", self.resource_path)))",
"def make_tables(self):\n return [XLSRowSet(name, self.workbook.sheet_by_name(name), self.window)\n for ... | [
"0.6552649",
"0.65002507",
"0.5966005",
"0.5962965",
"0.5830784",
"0.5787573",
"0.56597066",
"0.56334597",
"0.5631033",
"0.5583295",
"0.5544617",
"0.5506703",
"0.54890263",
"0.5459125",
"0.5382791",
"0.5318419",
"0.52870756",
"0.5273004",
"0.5272081",
"0.5182937",
"0.516016",... | 0.788829 | 0 |
Plot a confusion matrix. | def plot_cm(
cm: np.ndarray,
zero_diagonal: bool,
labels: [List[str]],
save_cm_plot: bool
) -> None:
# for dark places in visualize plot
cm = [[0.001 if y==0 else y for y in x] for x in cm]
n = len(cm)
if zero_diagonal:
for i in range(n):
cm[i][i] = 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def plot_confusion_matrix(cm, classes=None, title='Confusion matrix'):\n if classes is not None:\n sns.heatmap(cm, cmap=\"YlGnBu\", xticklabels=classes... | [
"0.8346288",
"0.8009091",
"0.8008569",
"0.7926985",
"0.78939724",
"0.7892289",
"0.78611463",
"0.7857628",
"0.785709",
"0.7848136",
"0.7828893",
"0.7809595",
"0.7807486",
"0.7799956",
"0.77992225",
"0.77787936",
"0.7776414",
"0.7775345",
"0.77748877",
"0.77725124",
"0.7753516"... | 0.0 | -1 |
initialize a CorpusReader object, stores the path to the corpus directory | def __init__(self, path):
self.path = path
# Raises an Error if the path doesn't exist
if not os.path.isdir(self.path):
raise ValueError(path + " isn't a directory, or doesn't exist at all") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, root, fileids=DOC_PATTERN, encoding='utf8'):\n\n # Initialize the NLTK corpus reader objects\n CorpusReader.__init__(self, root, fileids, encoding)",
"def __init__(self, corpus):\n if isinstance(corpus, str):\n # Convert directory to Plaintext Corpus.\n ... | [
"0.68194145",
"0.66482127",
"0.62276506",
"0.61951435",
"0.61784625",
"0.61702704",
"0.5980938",
"0.59273446",
"0.58861285",
"0.5752801",
"0.5742754",
"0.5718635",
"0.57126755",
"0.56926036",
"0.56904525",
"0.5671756",
"0.5669341",
"0.56677985",
"0.5634761",
"0.56156135",
"0.... | 0.0 | -1 |
Reads the text of the corpus and return it as a list of tokenized words. | def sents(self):
text = str()
for file in os.listdir(self.path):
# checks if the given path contains a text file and opens it
if file.endswith(".txt"):
with open(self.path + "/" + file) as connection:
text += connection.read()
# token... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def txt_to_word_list(text):\r\n return [w for w in text.split()]",
"def tokenize(text: str):\n # Create list of word tokens\n token_list = []\n # nlp = init_nlp(TaggingMethod.SPACY, Lang.ES, size=DictionarySize.MEDIUM)\n doc = nlp(text)\n token_list = [token.text for token in doc]\n # for to... | [
"0.7821308",
"0.7660063",
"0.7593958",
"0.758809",
"0.7582031",
"0.7464526",
"0.7414278",
"0.72528684",
"0.7246802",
"0.72197306",
"0.7188911",
"0.71005005",
"0.71000504",
"0.7098258",
"0.7083584",
"0.70579046",
"0.70402586",
"0.7032094",
"0.70273083",
"0.7026697",
"0.7009831... | 0.70017755 | 21 |
function to get the similarity matrix specific for the test case. The instances that we map the distance to are the provided train instances. | def getSimilarityMatrixTest(testBags, trainInstances, labels):
similarityMatrix = np.zeros([testBags.shape[0], trainInstances.shape[0]])
#print(similarityMatrix.shape)
for bagInd in range(0, testBags.shape[0]):
#print(labels[bagInd])
#get the average of all instances in this test patient bag
testInstances =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDistanceM(self, test, train):\n p = 2 # TUNE currently euclidian distance\n distanceM = pd.DataFrame(index=test.index.values, columns=train.index.values)\n for testrow, testing in test.iterrows():\n for trainrow, training in train.iterrows():\n tot = 0\n ... | [
"0.6784363",
"0.6022616",
"0.5967267",
"0.59669846",
"0.58467686",
"0.58432096",
"0.581799",
"0.58019656",
"0.57023007",
"0.5694741",
"0.56717575",
"0.5650801",
"0.5608074",
"0.55852276",
"0.55694515",
"0.5533678",
"0.5530354",
"0.55099696",
"0.54819864",
"0.5478882",
"0.5475... | 0.73847157 | 0 |
The name of the connector. | def connector_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "connector_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connector_mapping_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"connector_mapping_name\")",
"def connection_name(self) -> str:\n return pulumi.get(self, \"connection_name\")",
"def getConnectionName(self):\n return self.system",
"def connection_name(self) -> pulumi.Ou... | [
"0.7337074",
"0.732946",
"0.73207146",
"0.7130238",
"0.70410424",
"0.70390975",
"0.70390975",
"0.703408",
"0.69587594",
"0.69246274",
"0.6804043",
"0.6703014",
"0.6703014",
"0.6581841",
"0.6571527",
"0.6548757",
"0.6536891",
"0.6471821",
"0.644584",
"0.64090055",
"0.64068276"... | 0.86829066 | 0 |
The name of the hub. | def hub_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "hub_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hub_name(self):\n return self._props[\"persistent_identifiers\"].get(self._hub_name_prop)",
"def hub(self) -> str:\n return self._db_data.hub",
"def name(self):\n return f'{self._vehicle.name} {self.wan_name} Signal'",
"def name(self):\n return \"{} {}\".format(self._clientname, s... | [
"0.86040986",
"0.7757109",
"0.7266456",
"0.7262012",
"0.72566485",
"0.7248894",
"0.7248894",
"0.7248894",
"0.72286797",
"0.72268325",
"0.7159816",
"0.71467173",
"0.7144651",
"0.7131295",
"0.7124113",
"0.7124113",
"0.7124113",
"0.7124113",
"0.7106911",
"0.7100647",
"0.70927584... | 0.8609149 | 0 |
The name of the resource group. | def resource_group_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "resource_group_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_group_name(self) -> str:\n return pulumi.get(self, \"resource_group_name\")",
"def group_name(self) -> str:\n return pulumi.get(self, \"group_name\")",
"def resource_group_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"resource_group_name\")",
"def resource_gr... | [
"0.8794932",
"0.85470533",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.84212106",
"0.837923",
"0.8275838",
"0.8230199",
"0.82145786",
"0.807179",
"0.807179",
"0.80... | 0.81754035 | 40 |
Return all parameters that do not belong to any wavelet based learning | def parameters(self):
return self._default_params | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_non_bias_params(layer):\n all_params = get_all_params(layer)\n all_bias_params = get_all_bias_params(layer)\n return [p for p in all_params if p not in all_bias_params]",
"def nontrainable_weights(self):\n return list(filter(lambda x: not x.requires_grad, self.get_parameters(expand=Tr... | [
"0.757034",
"0.7299862",
"0.6915207",
"0.63612556",
"0.62665135",
"0.61068153",
"0.6098082",
"0.60897845",
"0.607046",
"0.60271055",
"0.60073906",
"0.59950787",
"0.59579605",
"0.59555995",
"0.5952281",
"0.59236145",
"0.5919052",
"0.5902403",
"0.5902082",
"0.58760995",
"0.5869... | 0.0 | -1 |
Applies custom regularization. The default in pytorch is to apply l2 to everything with the same weight decay. We allow for more customizability. | def get_reg(self):
loss = 0
for name, m in self.net.named_children():
if name.startswith('wave'):
loss += m[0].GainLayer.get_reg()
elif name.startswith('conv'):
loss += 0.5 * self.wd * torch.sum(m[0].weight**2)
loss += 0.5 * self.wd * torch... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def l2_regularizer(scale):\n if isinstance(scale, numbers.Integral):\n raise ValueError('scale cannot be an integer: %s' % (scale,))\n if isinstance(scale, numbers.Real):\n if scale < 0.:\n raise ValueError('Setting a scale less than 0 on a regularizer: %g.' %\n ... | [
"0.7050038",
"0.7031902",
"0.68602824",
"0.6843639",
"0.67073375",
"0.6703064",
"0.6629854",
"0.6379957",
"0.6377536",
"0.6226999",
"0.6226778",
"0.6216663",
"0.61688036",
"0.61538917",
"0.61515725",
"0.6126085",
"0.606442",
"0.6050656",
"0.6034684",
"0.6023497",
"0.60212433"... | 0.0 | -1 |
Return whether two numbers are close enough to be considered equal. | def equalEnough(numA, numB, tol=0.000001):
return math.fabs(numA - numB) <= tol | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearly_equal(a, b, sig_fig=5):\n return a == b or int(a*10**sig_fig) == int(b*10**sig_fig)",
"def almost_equal(x, y):\n return abs(x-y) < FP_PREC",
"def arecloseenough(x1, x2):\n\n if abs(x1 - x2) <= VERYSMALL:\n return True\n \n return False",
"def almost_equal_values(x, y, precision):\n ... | [
"0.81707466",
"0.78271025",
"0.7748413",
"0.77380204",
"0.7558063",
"0.7502925",
"0.7426044",
"0.74024117",
"0.73855555",
"0.7371723",
"0.7367104",
"0.73113316",
"0.7279827",
"0.72797513",
"0.7265305",
"0.72634",
"0.72136974",
"0.71816945",
"0.7178266",
"0.71691096",
"0.71350... | 0.7527095 | 5 |
Return a string representation of this object. | def __str__(self):
return self.user.get_full_name() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_string(self):\r\n return self.__str__()",
"def as_string(self):\n return self.__repr__()",
"def serialize(self):\n\n return str(self)",
"def serialize(self):\n\n\t\treturn str(self)",
"def toString(self) -> str:\n raise NotImplementedError",
"def to_str(self):\n ... | [
"0.877532",
"0.87702316",
"0.87467974",
"0.873373",
"0.8631904",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"0.8590569",
"... | 0.0 | -1 |
Create the istance for Flask application | def create_app():
###############################
# Create a FLASK application
app = Flask(__name__)
# Note: since the app is defined inside this file,
# the static dir will be searched inside this subdirectory
###############################
# Apply configuration
app.config.from_objec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app(self):\r\n self.app = Flask(__name__, instance_relative_config=True)\r\n\r\n # Init the secret key of the app -it is a must for flask to run\r\n self.app.config.from_mapping(\r\n SECRET_KEY='!ZNeverSayNever116Z!',\r\n MONGODB_SETTINGS= {'host': 'mongodb://l... | [
"0.776796",
"0.76693135",
"0.7638588",
"0.762213",
"0.75672436",
"0.75161093",
"0.7404375",
"0.740255",
"0.73974323",
"0.7391641",
"0.73877287",
"0.73740786",
"0.7341485",
"0.7334671",
"0.73148906",
"0.7314717",
"0.7268417",
"0.7250942",
"0.7242731",
"0.7215734",
"0.7167959",... | 0.7079237 | 31 |
Test if it is the same edge with the other. While comparing costs, if their difference is under the precision, then they are considered as the same edge. | def same_edge(self, other, precision=0):
return self.id == other.id \
and self.start_node == other.start_node \
and self.end_node == other.end_node \
and abs(self.cost - other.cost) <= precision \
and abs(self.reverse_cost - other.reverse_cost) <= precision \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\r\n return abs(self.x - other.x) + abs(self.y - other.y) < Vertex.epsilon",
"def __eq__(self, other):\n return abs(self - other) < 10e-10",
"def same(self, other, epsilon_=None):\n if epsilon_ is None:\n return self-other < epsilon\n else:\n ... | [
"0.6727692",
"0.6505541",
"0.6498408",
"0.64822954",
"0.6417987",
"0.6393962",
"0.6364372",
"0.62917227",
"0.6288815",
"0.626958",
"0.6238322",
"0.6234916",
"0.62137187",
"0.61908233",
"0.6114228",
"0.61046827",
"0.6092138",
"0.6084756",
"0.6081539",
"0.60792655",
"0.60791814... | 0.8797289 | 0 |
Sets the id of this VirtualService. | def id(self, id):
if id is not None and not re.search(r'^\\d{1,}-virtualservice-[a-z0-9_\\-]{36}$', id): # noqa: E501
raise ValueError(r"Invalid value for `id`, must be a follow pattern or equal to `/^\\d{1,}-virtualservice-[a-z0-9_\\-]{36}$/`") # noqa: E501
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.__id = id",
"def SetId(self, id):\n self.id = int(id)",
"def set_id(self, id_):\n\n self.id_ = id_",
"def set_id(self, id):\n self.data['id'] = id",
"def setID(self, id):\n self._id = id\n return self.callRemote('setID', id)",
"def se... | [
"0.7246792",
"0.71348435",
"0.7120083",
"0.69750094",
"0.6951778",
"0.68095964",
"0.6804247",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.67225677",
"0.6702289",
"0.6702289",
"0.6702289",... | 0.80658674 | 0 |
Sets the site_id of this VirtualService. | def site_id(self, site_id):
self._site_id = site_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_site_id(self):\n self.site_id = entities.sites['next id']\n entities.sites['object list'].append(self)\n entities.sites['next id'] += 1",
"def web_site_id(self, web_site_id):\n\n self._web_site_id = web_site_id",
"def setSiteids(self):\n self.siteids = []\n for... | [
"0.68784183",
"0.6602689",
"0.6414411",
"0.6092146",
"0.6034268",
"0.5990248",
"0.591408",
"0.57976866",
"0.57383054",
"0.5552645",
"0.53509086",
"0.53509086",
"0.53118485",
"0.5262215",
"0.5254939",
"0.5238961",
"0.5229057",
"0.5209056",
"0.5209056",
"0.5199387",
"0.51953393... | 0.80494 | 1 |
Sets the segment_id of this VirtualService. | def segment_id(self, segment_id):
self._segment_id = segment_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vat_id(self, vat_id: str):\n\n self._vat_id = vat_id",
"def vat_id(self, vat_id):\n\n self._vat_id = vat_id",
"def vpd_id(self, vpd_id):\n\n self._vpd_id = vpd_id",
"def update(self,\n segment_id,\n segment,\n ):\n return self._invoke(... | [
"0.5838757",
"0.5825565",
"0.57639927",
"0.5708378",
"0.5702347",
"0.5625416",
"0.5533488",
"0.55170035",
"0.5496307",
"0.5465427",
"0.5459022",
"0.545264",
"0.5423617",
"0.5415335",
"0.53778774",
"0.5375813",
"0.5352305",
"0.532604",
"0.53248763",
"0.53109074",
"0.5306134",
... | 0.8330469 | 0 |
Sets the name of this VirtualService. | def name(self, name):
if name is not None and not re.search(r'^[a-z0-9]{6}-[0-9]{2}\\.iphmx\\.com$', name): # noqa: E501
raise ValueError(r"Invalid value for `name`, must be a follow pattern or equal to `/^[a-z0-9]{6}-[0-9]{2}\\.iphmx\\.com$/`") # noqa: E501
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetName(self, name):\n self.name = name",
"def set_name(self, name):\n self.__name = name",
"def set_name(self, name):\n self.__name = name",
"def set_name(self, name):\r\n self.__name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, name... | [
"0.7563593",
"0.7558146",
"0.7558146",
"0.755707",
"0.753858",
"0.753858",
"0.753858",
"0.753858",
"0.753858",
"0.7528979",
"0.74654454",
"0.7464236",
"0.7430712",
"0.74030507",
"0.7345044",
"0.7283367",
"0.72244525",
"0.72244525",
"0.7223577",
"0.7223577",
"0.72162753",
"0... | 0.0 | -1 |
Sets the server_pool of this VirtualService. | def server_pool(self, server_pool):
self._server_pool = server_pool | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server(self, server):\n\n self._server = server",
"def update_listener_pool(self, service, name, bigips):\n vip = self.service_adapter.get_virtual_name(service)\n if vip:\n vip[\"pool\"] = name\n for bigip in bigips:\n v = bigip.tm.ltm.virtuals.virtua... | [
"0.5971407",
"0.5879605",
"0.5761809",
"0.54552734",
"0.54371893",
"0.54270303",
"0.54200625",
"0.53819776",
"0.5322363",
"0.5322363",
"0.531683",
"0.5273689",
"0.52584356",
"0.52292633",
"0.5185671",
"0.518415",
"0.5183671",
"0.5172391",
"0.51120234",
"0.50874215",
"0.506536... | 0.8254317 | 0 |
Sets the created_at of this VirtualService. | def created_at(self, created_at):
self._created_at = created_at | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def created_at(self, created_at):\n self._created_at = created_at",
"def created_at(self, created_at: \"datetime\"):\n self._attrs[\"createdAt\"] = created_at",
"def created_at(self, created_at: \"datetime\"):\n self._attrs[\"createdAt\"] = created_at",
"def created_at(self, created_at: ... | [
"0.7580301",
"0.7507754",
"0.7507754",
"0.7507754",
"0.7298143",
"0.7264707",
"0.7080131",
"0.7080131",
"0.6500315",
"0.6499938",
"0.64646447",
"0.6356537",
"0.63251674",
"0.629678",
"0.60847926",
"0.60378355",
"0.60249555",
"0.600644",
"0.5994549",
"0.59793323",
"0.5955705",... | 0.75695914 | 8 |
Sets the deployment_status of this VirtualService. | def deployment_status(self, deployment_status):
allowed_values = ["deploy_pending", "deploy_in_progress", "deploy_failed", "deployed", "delete_pending", "delete_in_progress", "delete_failed", "deleted"] # noqa: E501
if deployment_status not in allowed_values:
raise ValueError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_deployment_status():\n reset_query = dep_table.update().values(deployment_status=None)\n db.session.execute(reset_query)\n\n in_progress_condition = exc_table.c.status.in_(\n execution_states[DeploymentState.IN_PROGRESS])\n req_attention_condition = or_(\n dep_table.c.installatio... | [
"0.67861205",
"0.65088254",
"0.6331958",
"0.6331958",
"0.6331958",
"0.62717587",
"0.6136346",
"0.61323804",
"0.61323804",
"0.6127772",
"0.6103353",
"0.6027898",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066"... | 0.72562563 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, VirtualService):
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.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 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 |
Validate a Bech32 string, and determine HRP and data. | def bech32_decode(bech):
if ((any(ord(x) < 33 or ord(x) > 126 for x in bech)) or
(bech.lower() != bech and bech.upper() != bech)):
return (None, None)
bech = bech.lower()
pos = bech.rfind('1')
if pos < 1 or pos + 7 > len(bech): #or len(bech) > 90:
return (None, None)
if n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkDataType(self,str):\n accepted_vals = [\"HEXA\",\"NEHU\",\"NEDS\",\"NEDU\",\"NDHU\",\"NDDU\"]\n assert str in accepted_vals, \"Error: Data Type not accepted: \" + str\n if (str == 'HEXA') | (str[2] == 'H'):\n self.base = 16\n if str[3] == 'S':\n self.signed = True",
"def is_valid_a... | [
"0.632021",
"0.58705276",
"0.58341265",
"0.5811494",
"0.57285565",
"0.57082236",
"0.5613003",
"0.55415183",
"0.5499696",
"0.54304606",
"0.54039085",
"0.53765565",
"0.5374732",
"0.53599584",
"0.5302655",
"0.52568835",
"0.5249464",
"0.524831",
"0.5240656",
"0.52291",
"0.5218948... | 0.62150854 | 1 |
Builds and returns Dataloader. | def get_loader(config, image_path, crop_size, batch_size,sampler, num_workers=2, mode='train', augmentation_prob=0.4):
dataset = ImageFolder(config)
data_loader = data.DataLoader(dataset=dataset, batch_size=batch_size, num_workers=num_workers, sampler=sampler)
return data_loader | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataloader(self):\n\n # load / split data\n train_data = self.data.get_train_data()\n if self.args.use_dev:\n train_data, dev_data = self.data.split_data(train_data)\n test_data = self.data.get_test_data()\n\n #print(train_data[0])\n #print(dev_data[0])\n ... | [
"0.68903595",
"0.68853897",
"0.67474216",
"0.6728897",
"0.6718818",
"0.64955765",
"0.64845544",
"0.6474833",
"0.64435935",
"0.6432843",
"0.63938326",
"0.63880587",
"0.63334274",
"0.6254247",
"0.62065464",
"0.61979914",
"0.6109981",
"0.61029834",
"0.60769254",
"0.60664064",
"0... | 0.53868306 | 82 |
Creates a dataframe of final recommendations filtered with a "mean" song from a playlist. | def filter_with_meansong(mean_song,recommendations_df, n_recommendations = 10):
features = list(mean_song.columns[6:])
features.remove("key")
features.remove("mode")
mean_song_feat = mean_song[features].values
mean_song_scaled = MinMaxScaler().fit_transform(mean_song_feat.reshape(-1,1))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggest_songs(source_song, songs_df, y, model):\n source_song = preprocess(source_song)\n recommendations = model.kneighbors(source_song)[1][0]\n # normalize dataset, our graph likes normalized data\n numeric_cols = songs_df.select_dtypes(include=np.number).columns\n df_num = songs_df.select_dty... | [
"0.5832328",
"0.5796316",
"0.5668893",
"0.565352",
"0.55372804",
"0.5467602",
"0.5454571",
"0.5408461",
"0.5392319",
"0.5323091",
"0.52779627",
"0.5273057",
"0.5253437",
"0.5243496",
"0.51954097",
"0.5133213",
"0.5107601",
"0.51065266",
"0.50642806",
"0.50602126",
"0.5047967"... | 0.6814532 | 0 |
Return +1, 0, or 1 if the unit cube is above, below, or intersecting the plane. | def UnitCubeTest(P):
above = 0
below = 0
for (a,b,c) in [(0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)]:
s = P.test(a, b, c)
if s > 0:
above = 1
elif s < 0:
below = 1
return above - below | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hitTest( a, b ):\n r = a.radius + b.radius\n x = abs( a.x - b.x )\n y = abs( a.y - b.y )\n if x <= r and y <= r and x*x + y*y <= r*r:\n return 1\n return 0",
"def isInPlane(self, p) -> bool:\n # Testing for zero is done with math.isclose, to avoid rounding/floating point errors.\... | [
"0.6006958",
"0.5900927",
"0.5759193",
"0.5713522",
"0.5660144",
"0.56555474",
"0.56256115",
"0.56209445",
"0.5612326",
"0.5611536",
"0.5605023",
"0.55960155",
"0.55666924",
"0.55626243",
"0.5540222",
"0.55394",
"0.55347407",
"0.55283034",
"0.5525503",
"0.55229247",
"0.550887... | 0.6731846 | 0 |
Determine whether elements in a list are monotonic. ie. unique elements are clustered together. ie. [5,5,3,4] is, [5,3,5] is not. | def is_monotonic(items: Sequence) -> bool:
prev_elements = set({items[0]})
prev_item = items[0]
for item in items:
if item != prev_item:
if item in prev_elements:
return False
prev_item = item
prev_elements.add(item)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkmonotonic(iterable, piecewise=False):\n monotonic = [True] + [x < y for x, y in zip(iterable, iterable[1:])]\n if piecewise is True:\n return monotonic\n else:\n return all(monotonic)",
"def is_unique_and_sorted(self):\n return all((self(i) < self(i+1) for i in range(len(se... | [
"0.6754721",
"0.62469804",
"0.6069717",
"0.60431504",
"0.6037963",
"0.601249",
"0.5946327",
"0.5945903",
"0.59423465",
"0.588357",
"0.587069",
"0.58562666",
"0.58260524",
"0.58257693",
"0.57807654",
"0.57767946",
"0.57500005",
"0.57214695",
"0.571543",
"0.57055587",
"0.570405... | 0.7788266 | 0 |
If the first value in this list is a tag, pop and return it. | def pop_tag(data):
if data and is_tag(data[0]):
return data.pop(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):\n while not self.queue[self.tag].empty():\n temp = self.queue[self.tag].get()\n if not self.queue[self.tag].empty():\n self.queue[1 - self.tag].put(temp)\n else:\n self.tag = 1 - self.tag\n return temp",
"def pop(... | [
"0.73780775",
"0.71970713",
"0.700163",
"0.69585055",
"0.69546187",
"0.6942529",
"0.69298804",
"0.6921087",
"0.69165844",
"0.69013816",
"0.6838649",
"0.6807731",
"0.6806792",
"0.67973435",
"0.67922765",
"0.6770666",
"0.67601925",
"0.67588156",
"0.6755501",
"0.6738713",
"0.673... | 0.8173029 | 0 |
Computes the area, perimeter, and center of mass of a polygon. | def polygon_descriptors(corners):
n_points = corners.shape[1]
p, a, cx, cy = 0, 0, 0, 0
for i in xrange(n_points):
j = (i+1) % n_points
dot = corners[0,i]*corners[1,j] - corners[0,j]*corners[1,i]
a += dot
cx += (corners[0,i] + corners[0,j]) * dot
cy += (corners[1,i] +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center_of_mass_polygon(polygon):\n L = 0\n cx = 0\n cy = 0\n cz = 0\n p = len(polygon)\n for i in range(-1, p - 1):\n p1 = polygon[i]\n p2 = polygon[i + 1]\n d = distance_point_point(p1, p2)\n cx += 0.5 * d * (p1[0] + p2[0])\n cy += 0.5 * d * (p1[1] + ... | [
"0.76629454",
"0.71205616",
"0.69890565",
"0.69153076",
"0.6863332",
"0.68538386",
"0.65735215",
"0.6540808",
"0.65279156",
"0.64882034",
"0.64747334",
"0.64249295",
"0.64215606",
"0.63967",
"0.638212",
"0.6325703",
"0.630471",
"0.6294154",
"0.6226559",
"0.62084484",
"0.61735... | 0.0 | -1 |
Test to ensure we can retrieve the users list from users.json | def test_get_users(self):
users = app.get_users()
self.assertEqual(len(users), 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_list(self):\r\n self._add_demo_import()\r\n params = {\r\n 'api_key': self.api_key\r\n }\r\n res = self.testapp.get('/api/v1/a/users/list',\r\n params=params,\r\n status=200)\r\n\r\n # we should ... | [
"0.832546",
"0.8318069",
"0.81496495",
"0.8068396",
"0.8048681",
"0.80051553",
"0.79913485",
"0.79913485",
"0.79293835",
"0.79282576",
"0.790657",
"0.78551716",
"0.7850104",
"0.7834217",
"0.7797354",
"0.7771003",
"0.77237666",
"0.7721693",
"0.768903",
"0.76788247",
"0.7499827... | 0.75696456 | 20 |
Test to ensure we can retrieve the leaders list from leaderboard.json | def test_get_leaders(self):
leaders = app.get_leaders()
self.assertEqual(len(leaders), 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(self, request):\n team_leaders = self.controller.retrieve_all_teams_leaders()\n serializer = data_serializers.TeamLeaderPresenterSerializer(team_leaders, many=True)\n return Response(serializer.data)",
"def test_03_leaderboard(self):\r\n # As Anonymou user\r\n url = \"... | [
"0.6381545",
"0.6360777",
"0.63352084",
"0.6237816",
"0.6234864",
"0.6102163",
"0.6041341",
"0.5974139",
"0.59478533",
"0.5893005",
"0.58824646",
"0.58673745",
"0.58673745",
"0.58460206",
"0.58338076",
"0.58337706",
"0.5821925",
"0.5797607",
"0.579719",
"0.5778626",
"0.575144... | 0.7366307 | 0 |
Initialize the attention layer | def __init__(self, dim_input_hidden, n_class, use_cuda=False):
super(RateDistAttentionGMM, self).__init__()
self.dim_input_hidden = dim_input_hidden
self.use_cuda = use_cuda
self.n_class = n_class
self.ffn1 = embed2Dist(dim_input_hidden, self.n_class)
# self.ffn1 = nn.Lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_layers(self) -> None:\n self.self_attn = MultiheadAttention(**self.self_attn_cfg)\n self.embed_dims = self.self_attn.embed_dims\n self.ffn = FFN(**self.ffn_cfg)\n norms_list = [\n build_norm_layer(self.norm_cfg, self.embed_dims)[1]\n for _ in range(2)\n ... | [
"0.7030999",
"0.6964342",
"0.68000585",
"0.67509365",
"0.66033065",
"0.6520531",
"0.646856",
"0.6467753",
"0.64234626",
"0.64226556",
"0.63733256",
"0.6316904",
"0.62851983",
"0.6277219",
"0.62352204",
"0.6203299",
"0.6192797",
"0.61542326",
"0.6150573",
"0.6105918",
"0.60989... | 0.0 | -1 |
Setting names for instance variables. | def __init__(self):
self.topology = None
self.learningRate = None
self.momentum = None
self.name = None
self.size = None
#self._hiddenActiv_fun_key = None
#self._outActiv_fun_key = None
#self.output_activation = None
#self.hidden_activation = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.__name = 'name'",
"def __set_name__(self, cls, name):\n pass",
"def set_name(self,name):\r\n self._name = __name",
"def name(self, name):\n self.__name = name",
"def _set_instance_name(self, name):\n self.__instance_name = name",
"def set_nam... | [
"0.7266301",
"0.7190779",
"0.6939247",
"0.6837434",
"0.68220156",
"0.66483474",
"0.6632995",
"0.65824",
"0.6579028",
"0.65728694",
"0.65593624",
"0.6542149",
"0.6542149",
"0.6513601",
"0.6511086",
"0.650466",
"0.6476276",
"0.64525884",
"0.6449827",
"0.6433655",
"0.64283115",
... | 0.0 | -1 |
Returns the number of features or synapses (connections) present in the network. | def get_num_connections(self):
synapses = 0
for mat in self.weights:
synapses += mat.size
return synapses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNeuronCount(self):\n\t\treturn self.loader.getNeuronCount()",
"def num_node_features(self):\n return self[0].num_node_features",
"def num_features(self) -> Dict[NodeType, int]:\n return self.num_node_features",
"def get_num_features(self):\r\n \r\n return len(self[0]['x'])"... | [
"0.7547738",
"0.73359764",
"0.7307265",
"0.72956717",
"0.7176172",
"0.712794",
"0.7111971",
"0.71068484",
"0.7103375",
"0.70746815",
"0.7061183",
"0.7060888",
"0.7045565",
"0.7018414",
"0.7011767",
"0.698772",
"0.6983539",
"0.6975411",
"0.6970141",
"0.6951382",
"0.6929856",
... | 0.7790741 | 0 |
Performs the feedforward propagation of the inputs through the layers. | def feedforward(self,inputs,hidden_activation=tanh,output_activation=tanh):
# These two lists will contain the inputs and the outputs for each layer, respectively
self.netIns = []
self.netOuts = []
input_samples=inputs.shape[0]
#Currently, this will cause a crash when the netw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feedForward(self, inputs):\n\n\t\tinputs = np.atleast_1d(inputs)\n\n\t\tif not len(inputs) == self.nInputs:\n\n\t\t\traise ValueError(\"The input vector is the wrong length for this network\")\n\n\t\t#don't forget we have a bias unit in here too\n\t\tfor i in range(1,self.nInputs+1):\n\t\t\tself.inputLayer[i].... | [
"0.8090789",
"0.7943063",
"0.77892226",
"0.7773758",
"0.76488674",
"0.7491926",
"0.74271184",
"0.7415568",
"0.73791575",
"0.7323898",
"0.72948235",
"0.72812986",
"0.72231257",
"0.71988875",
"0.71837115",
"0.71744525",
"0.7057485",
"0.7057485",
"0.7050749",
"0.70428085",
"0.70... | 0.66682535 | 62 |
Uses the gradients computed by the backpropagation method to update network weights. performs stochastic gradient descent and adjusts the weights | def optimize(self,gradients):
for k in range(self.size):
delta_weight = self.learningRate * gradients[k]
full_change = delta_weight + self.momentum*self.last_change[k]
self.weights[k] -= full_change
self.last_change[k] = 1*gradients[k] #copy gradient mat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __update_weights_grad_desc(self, x_train, y_train):\n\n predictions = self.__compute_prediction(x_train)\n weights_delta = np.dot(x_train.T, y_train - predictions)\n\n m = y_train.shape[0]\n self.__weights += self.__learning_rate / float(m) * weights_delta",
"def update_weights(se... | [
"0.7545041",
"0.74381363",
"0.73606795",
"0.72697425",
"0.7257491",
"0.7247975",
"0.72122455",
"0.71736395",
"0.7097959",
"0.7056193",
"0.7043043",
"0.70325506",
"0.70029825",
"0.6960385",
"0.6907079",
"0.69027144",
"0.68989074",
"0.68964994",
"0.68933463",
"0.68902606",
"0.6... | 0.7200139 | 7 |
Compare the current grid with the other grid. | def equal(self , other , include_lgr = True , include_nnc = False , verbose = False):
if not isinstance(other , EclGrid):
raise TypeError("The other argument must be an EclGrid instance")
return self._equal( other , include_lgr , include_nnc , verbose) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return np.all(self.grid == other.grid) and np.all(self.pos == other.pos)",
"def grid_equal (grid1, grid2):\r\n if grid1 == grid2:\r\n return True\r\n else:\r\n return False",
"def __eq__(self, other):\n return (type(self) == type(other) and\n ... | [
"0.7535007",
"0.74029493",
"0.73907125",
"0.73904663",
"0.7383008",
"0.7383008",
"0.7301348",
"0.7264918",
"0.7212092",
"0.7175864",
"0.71670645",
"0.7093468",
"0.70820326",
"0.7075754",
"0.7061016",
"0.704413",
"0.7030228",
"0.6965346",
"0.6919564",
"0.68922496",
"0.68768907... | 0.6915621 | 19 |
Returns the total number of cells in this grid | def getGlobalSize(self):
return self._get_global_size( ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cells_total(self):\n return self._inv.get(\"cells\", len(self))",
"def Ncells(self):\n return len(self.cells)",
"def get_total_cells(self):\n return self._get(\"cells\")",
"def GetNumberOfCells(self):\n return self.GetNumberOfElements(ArrayAssociation.CELL)",
"def num_cells(... | [
"0.84620357",
"0.828228",
"0.82092845",
"0.8198651",
"0.81028914",
"0.8097803",
"0.7860975",
"0.78265333",
"0.77541155",
"0.7748197",
"0.77120006",
"0.7640579",
"0.7533253",
"0.7531595",
"0.75263035",
"0.74932504",
"0.7478347",
"0.74286604",
"0.7416201",
"0.74102867",
"0.7373... | 0.0 | -1 |
The number of active cells in the grid. | def getNumActive(self):
return self._get_active( ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cellcount(self):\n self.cellcount += 1\n return self.cellcount - 1",
"def num_cells_global(self):\n return self.get_dim_attribute('num_cells')",
"def GetNumberOfCells(self):\n return self.GetNumberOfElements(ArrayAssociation.CELL)",
"def ncells(self):\n return self.... | [
"0.78915435",
"0.77319056",
"0.7490065",
"0.74887973",
"0.748598",
"0.74614465",
"0.7446528",
"0.743738",
"0.7415738",
"0.7415738",
"0.7415738",
"0.7415738",
"0.73065495",
"0.71314865",
"0.712694",
"0.71220756",
"0.70028234",
"0.6994694",
"0.69633216",
"0.69607353",
"0.693411... | 0.70822155 | 16 |
The number of active cells in the grid. | def getNumActiveFracture(self):
return self._get_active_fracture( ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cellcount(self):\n self.cellcount += 1\n return self.cellcount - 1",
"def num_cells_global(self):\n return self.get_dim_attribute('num_cells')",
"def GetNumberOfCells(self):\n return self.GetNumberOfElements(ArrayAssociation.CELL)",
"def ncells(self):\n return self.... | [
"0.78915435",
"0.77319056",
"0.7490065",
"0.74887973",
"0.748598",
"0.74614465",
"0.7446528",
"0.743738",
"0.7415738",
"0.7415738",
"0.7415738",
"0.7415738",
"0.73065495",
"0.71314865",
"0.712694",
"0.71220756",
"0.70822155",
"0.70028234",
"0.6994694",
"0.69633216",
"0.696073... | 0.0 | -1 |
Name of the current grid. For the main grid this is the filename given to the constructor when loading the grid; for an LGR this is the name of the LGR. If the grid instance has been created with the create() classmethod this can be None. | def getName(self):
return self._get_name( ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._path or '__main__'",
"def getGridFilenames(self):\n c = list(self.gridVars.keys())\n return self.gridVars[c[0]]",
"def create_savename(self):\n \n savename = self.config.get('grid', 'dir') + self.fname.split('/')[-1]\n newsuffix = '_gridd... | [
"0.6318372",
"0.62872833",
"0.6229362",
"0.622301",
"0.6192236",
"0.6164516",
"0.6164516",
"0.6138963",
"0.6138963",
"0.6138963",
"0.6138963",
"0.6138963",
"0.6117195",
"0.6104805",
"0.6062773",
"0.6059951",
"0.60593957",
"0.60490316",
"0.60490316",
"0.60490316",
"0.60490316"... | 0.0 | -1 |
Lookup cell containg true position (x,y,z). Will locate the cell in the grid which contains the true position (,,), the return value is as a triplet (i,j,k). The underlying C implementation is not veeery efficient, and can potentially take quite long time. If you provide a good intial guess with the parameter (a tuple ... | def find_cell( self , x , y , z , start_ijk = None):
if start_ijk:
start_index = self.__global_index( ijk = start_ijk )
else:
start_index = 0
global_index = self._get_ijk_xyz( x , y , z , start_index)
if global_index >= 0:
i = ctypes.c_int()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findCellXY(self , x, y , k):\n if 0 <= k <= self.getNZ():\n i = ctypes.c_int()\n j = ctypes.c_int()\n ok = self._get_ij_xy( x,y,k , ctypes.byref(i) , ctypes.byref(j))\n if ok:\n return (i.value , j.value)\n else:\n rais... | [
"0.69080573",
"0.6779657",
"0.66930765",
"0.66930765",
"0.66930765",
"0.6678192",
"0.6678192",
"0.6678192",
"0.6678192",
"0.66224736",
"0.6613548",
"0.639877",
"0.6369274",
"0.6351354",
"0.6351354",
"0.6344353",
"0.6325002",
"0.63212687",
"0.63165545",
"0.6294562",
"0.6286179... | 0.7881949 | 0 |
Get EclGrid instance located in cell. Will query the current grid instance if the cell given by , or has been refined with an LGR. Will return None if the cell in question has not been refined, the return value can be used for further queries. See get_xyz() for documentation of the input parameters. | def get_cell_lgr( self, active_index = None , global_index = None , ijk = None):
gi = self.__global_index( ijk = ijk , active_index = active_index , global_index = global_index)
lgr = self._get_cell_lgr( gi )
if lgr:
lgr.setParent( self )
return lgr
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cell(self, cell, dbg=False):\n a = b = 0\n try:\n a, b = self.__ret_cell(cell)\n if dbg:\n return self._grid[a][b], a, b\n else:\n return self._grid[a][b]\n except IndexError as e:\n self.perror(\"Error: '%s'.\" ... | [
"0.6090308",
"0.60243547",
"0.59928375",
"0.59226567",
"0.5912492",
"0.58661693",
"0.58586776",
"0.5803431",
"0.5781136",
"0.57725286",
"0.5739436",
"0.5710825",
"0.56304365",
"0.5583593",
"0.5551934",
"0.5551149",
"0.55327576",
"0.5495326",
"0.54909706",
"0.54815984",
"0.548... | 0.6312405 | 0 |
Creates an EclKW instance based on existing 3D numpy object. The method create3D() does the inverse operation; creating a 3D numpy object from an EclKW instance. If the argument is true the resulting keyword will have length 'nactive', otherwise the element will have length nxnynz. | def createKW( self , array , kw_name , pack):
if array.ndim == 3:
dims = array.shape
if dims[0] == self.getNX() and dims[1] == self.getNY() and dims[2] == self.getNZ():
dtype = array.dtype
if dtype == numpy.int32:
type = EclTypeEnum.ECL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create3D( self , ecl_kw , default = 0):\n if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize():\n array = numpy.ones( [ self.getGlobalSize() ] , dtype = ecl_kw.dtype) * default\n kwa = ecl_kw.array\n if len(ecl_kw) == self.size:\n f... | [
"0.7482991",
"0.59509605",
"0.5510952",
"0.5499722",
"0.54056096",
"0.52415323",
"0.51461595",
"0.51215535",
"0.5113031",
"0.51026446",
"0.50913775",
"0.5080292",
"0.506541",
"0.50582623",
"0.50578034",
"0.503252",
"0.50322217",
"0.50146544",
"0.49972647",
"0.49777192",
"0.49... | 0.6924006 | 1 |
Creates a 3D numpy array object with the data from . Observe that 3D numpy object is a copy of the data in the EclKW instance, i.e. modification to the numpy object will not be reflected in the ECLIPSE keyword. The methods createKW() does the inverse operation; creating an EclKW instance from a 3D numpy object. | def create3D( self , ecl_kw , default = 0):
if len(ecl_kw) == self.getNumActive() or len(ecl_kw) == self.getGlobalSize():
array = numpy.ones( [ self.getGlobalSize() ] , dtype = ecl_kw.dtype) * default
kwa = ecl_kw.array
if len(ecl_kw) == self.size:
for i in ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createKW( self , array , kw_name , pack):\n if array.ndim == 3:\n dims = array.shape\n if dims[0] == self.getNX() and dims[1] == self.getNY() and dims[2] == self.getNZ():\n dtype = array.dtype\n if dtype == numpy.int32:\n type = EclT... | [
"0.72853476",
"0.5536447",
"0.548136",
"0.5479699",
"0.54082584",
"0.53730893",
"0.5352577",
"0.5350692",
"0.53032625",
"0.5276474",
"0.52748704",
"0.5271365",
"0.52682966",
"0.5257674",
"0.5239569",
"0.520957",
"0.52051854",
"0.5195257",
"0.51888484",
"0.5175834",
"0.5165416... | 0.7509103 | 0 |
Invalid module names raise Exceptions. | def test_invalid_module_names(self):
self.assertRaises(ValueError, Module, '')
self.assertRaises(ValueError, Module, 'names-with-dashes')
self.assertRaises(ValueError, Module, 'names with spaces')
self.assertRaises(ValueError, Module, 'names.with,punctuations!')
self.assertRaises... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_normal_module_name(assert_errors, filename, default_options):\n visitor = WrongModuleNameVisitor(default_options, filename=filename)\n visitor.run()\n\n assert_errors(visitor, [])",
"def test_broken_error_module(self):\r\n with self.assertRaises(TestException):\r\n module = se... | [
"0.70322967",
"0.68136823",
"0.657802",
"0.6511772",
"0.64713454",
"0.64292055",
"0.6387931",
"0.6375257",
"0.6323564",
"0.6284643",
"0.62667674",
"0.6255107",
"0.61453974",
"0.6095324",
"0.6056169",
"0.6034116",
"0.60115004",
"0.60109293",
"0.598281",
"0.59621185",
"0.594186... | 0.8091457 | 0 |
Install datasets for retriever. | def _install(args, use_cache, debug):
engine = choose_engine(args)
engine.use_cache = use_cache
if args['dataset'].endswith('.zip') or args.get('hash_value'):
path_to_archive = args['dataset']
if args.get('hash_value'):
path_to_archive = os.path.join(
PROVENANCE_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install():\n ArticleDataProvider.register()\n ProductDataProvider.register()",
"def task_installTestData(self):\n if env.get('environment') == 'production':\n abort(\"Don't use installTestData in production.\")\n\n if postgres.tableExists('trac', 'system'):\n abort(\"E... | [
"0.64824706",
"0.62990665",
"0.62516385",
"0.62516385",
"0.62441695",
"0.6194383",
"0.6147018",
"0.6111253",
"0.60733217",
"0.6066709",
"0.6036118",
"0.60200125",
"0.5941362",
"0.5941362",
"0.5929711",
"0.5899112",
"0.5832342",
"0.58091074",
"0.58081496",
"0.58072793",
"0.578... | 0.6306677 | 1 |
WKB hex representation of the geometry | def wkb_hex(self): # -> str:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hex_str (self):\n return \"#%02X%02X%02X\"%(self.r, self.g, self.b)",
"def getquoted(self):\n if self.is_geometry:\n # Psycopg will figure out whether to use E'\\\\000' or '\\000'.\n return b\"%s(%s)\" % (\n b\"ST_GeogFromWKB\" if self.geography else b\"ST_G... | [
"0.65884876",
"0.6582219",
"0.636124",
"0.61333066",
"0.6064004",
"0.5988412",
"0.59239453",
"0.5870547",
"0.58452266",
"0.58219653",
"0.58061785",
"0.5790033",
"0.57587856",
"0.5756235",
"0.5752591",
"0.57401365",
"0.5630617",
"0.557337",
"0.5546199",
"0.55373263",
"0.553564... | 0.7904502 | 0 |
True if the geometry's coordinate sequence(s) have z values (are 3dimensional) | def has_z(self): # -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_z(geometry, **kwargs):\n return lib.has_z(geometry, **kwargs)",
"def is3D(data):\n return data.find(\"x3\") != -1 and data.find(\"y3\") != -1 and data.find(\"z3\") != -1",
"def is3_d(self):\n return self.container['is3_d']",
"def isValidZ(self, z):\n if (z <= self.getZMin()):\... | [
"0.820763",
"0.77022755",
"0.7069247",
"0.6848499",
"0.66709745",
"0.6530925",
"0.63884056",
"0.61417586",
"0.6120292",
"0.60563713",
"0.6027548",
"0.5994436",
"0.5988078",
"0.59433526",
"0.59350085",
"0.5894385",
"0.5884434",
"0.5853135",
"0.58302337",
"0.5801898",
"0.578936... | 0.74940985 | 2 |
Returns True if the geometries cross, else False | def crosses(self, other): # -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross(form1, form2):\n for point in form1.points:\n if point in form2:\n return True\n for point in form2.points:\n if point in form1:\n return True\n return",
"def is_crossed(self):\n left_boundary_clusters = np.extract(self.clu... | [
"0.68447363",
"0.658677",
"0.6522985",
"0.6510757",
"0.64877355",
"0.6486709",
"0.64591855",
"0.6447096",
"0.64428073",
"0.63837385",
"0.6341816",
"0.62899524",
"0.62835294",
"0.62699497",
"0.6249035",
"0.62386805",
"0.6217791",
"0.6207276",
"0.62032044",
"0.6188088",
"0.6161... | 0.6429868 | 9 |
Returns True if geometries are equal, else False Refers to pointset equality (or topological equality), and is equivalent to (self.within(other) & self.contains(other)) | def equals(self, other): # -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return np.all(self.grid == other.grid) and np.all(self.pos == other.pos)",
"def __eq__(self, other):\n return (isinstance(other, type(self)) and (self.get_all_features() == other.get_all_features()))",
"def equals(self,other):\n return self._x == other.get_x() an... | [
"0.71639055",
"0.7139683",
"0.70905894",
"0.70265704",
"0.7015772",
"0.70133144",
"0.70048195",
"0.69152844",
"0.69048464",
"0.68904096",
"0.6877656",
"0.68755615",
"0.68755615",
"0.68579316",
"0.68457043",
"0.6845368",
"0.68398446",
"0.683315",
"0.6822902",
"0.68195224",
"0.... | 0.0 | -1 |
Returns True if geometry is within the other, else False | def within(self, other): # -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def doBoundingBoxesIntersect(self, other):\n if(self.upperLeft.x <= other.lowerRight.x and\n self.lowerRight.x >= other.upperLeft.x and\n self.upperLeft.y >= other.lowerRight.y and\n self.lowerRight.y <= other.upperLeft.y):\n return True\n return False"... | [
"0.75616556",
"0.73984003",
"0.72673327",
"0.72669196",
"0.72505486",
"0.7195229",
"0.7160514",
"0.71394855",
"0.70776564",
"0.7074476",
"0.70040333",
"0.69928163",
"0.696956",
"0.6963409",
"0.69393957",
"0.691195",
"0.68868387",
"0.68739426",
"0.686289",
"0.68532085",
"0.684... | 0.6667447 | 33 |
Returns True if geometries are equal to within a specified tolerance Refers to coordinate equality, which requires coordinates to be equal and in the same order for all components of a geometry | def equals_exact(self, other, tolerance): # -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approx_eq(x, y, tolerance = 0.000001):\n\treturn abs(x - y) < tolerance",
"def compare_geometrycollection(config, geometry_x, geometry_y):\n if config in BLIST:\n # print('arc distance: %s' % str(arc_distance(x, y)))\n return arc_distance(geometry_x, geometry_y) < EPOCH_CURVE_RELATIVE\n ... | [
"0.65638185",
"0.649459",
"0.64573056",
"0.6321705",
"0.622471",
"0.61462414",
"0.613085",
"0.613085",
"0.613085",
"0.6104649",
"0.6088571",
"0.6067109",
"0.60385925",
"0.6033399",
"0.5987341",
"0.5935575",
"0.5908245",
"0.5903495",
"0.5901533",
"0.5879786",
"0.5853027",
"0... | 0.71459395 | 0 |
Returns True if geometries are equal at all coordinates to a specified decimal place Refers to approximate coordinate equality, which requires coordinates be approximately equal and in the same order for all components of a geometry. | def almost_equals(self, other, decimal=...): # -> bool:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_floats(config, geometry_x, geometry_y):\n value_x = float(geometry_x)\n value_y = float(geometry_y)\n if value_x == 0:\n return value_y == 0\n\n if config in ALIST:\n precision_error = EPOCH_CURVE_RELATIVE\n else:\n precision_error = EPOCH\n\n return abs((value_x ... | [
"0.6437861",
"0.6355156",
"0.62697935",
"0.62260604",
"0.62024343",
"0.6195202",
"0.6183995",
"0.6170724",
"0.6150034",
"0.6139426",
"0.6124448",
"0.6123378",
"0.6116012",
"0.60985345",
"0.6068995",
"0.6054512",
"0.60515845",
"0.6048156",
"0.6034621",
"0.6029533",
"0.59962445... | 0.630607 | 2 |
Returns the distance along this geometry to a point nearest the specified point If the normalized arg is True, return the distance normalized to the length of the linear geometry. | def project(self, other, normalized=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance(self, point):\n if not isinstance(point, Point):\n point = Point(*point)\n\n distances = [(point.distance_to_point(p), p) for p in self.points]\n sortpoints = sorted(distances, key=lambda x: x[0])\n closest = sortpoints[0][1]\n\n vc = Vector(*closest)\... | [
"0.71456635",
"0.7035688",
"0.70179987",
"0.68550944",
"0.6722721",
"0.67197704",
"0.6635869",
"0.6616292",
"0.65401244",
"0.6483244",
"0.643588",
"0.64350605",
"0.6415676",
"0.6413308",
"0.6403546",
"0.63864744",
"0.63507634",
"0.6288608",
"0.6256427",
"0.62471986",
"0.61447... | 0.0 | -1 |
Get Resource This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. | def app_resource_get_post(self, request, **kwargs):
kwargs['_return_http_data_only'] = True
if kwargs.get('callback'):
return self.app_resource_get_post_with_http_info(request, **kwargs)
else:
(data) = self.app_resource_get_post_with_http_info(request, **kwargs)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, path, callback):\n self.appstack.append({'callback':callback, 'method': 'GET', 'path': path})\n return self",
"def get(self, api_path, *args, **kwargs):\n\n\t\treturn self._do_operation(u'get', api_path, *args, **kwargs)",
"def get(self, *args, **kwargs):\n return self._reque... | [
"0.6274926",
"0.61253905",
"0.61155295",
"0.60833776",
"0.600879",
"0.59691507",
"0.5942576",
"0.5889696",
"0.5876019",
"0.58388215",
"0.5813588",
"0.58012885",
"0.5800905",
"0.5800905",
"0.578236",
"0.5740904",
"0.57363164",
"0.5733023",
"0.5711154",
"0.5701624",
"0.57008654... | 0.0 | -1 |
Get Resource This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a `callback` function to be invoked when receiving the response. | def app_resource_get_post_with_http_info(self, request, **kwargs):
all_params = ['request']
all_params.append('callback')
all_params.append('_return_http_data_only')
all_params.append('_preload_content')
all_params.append('_request_timeout')
params = locals()
fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, path, callback):\n self.appstack.append({'callback':callback, 'method': 'GET', 'path': path})\n return self",
"def get(self, api_path, *args, **kwargs):\n\n\t\treturn self._do_operation(u'get', api_path, *args, **kwargs)",
"def get(self, *args, **kwargs):\n return self._reque... | [
"0.6273417",
"0.6121571",
"0.61106306",
"0.60798013",
"0.6007256",
"0.5966203",
"0.5938566",
"0.58853513",
"0.5870972",
"0.5835819",
"0.580966",
"0.5799486",
"0.5796729",
"0.5796729",
"0.57783145",
"0.5737376",
"0.57338715",
"0.57292354",
"0.57070035",
"0.5696636",
"0.5696474... | 0.0 | -1 |
Extracts X,Y,Z,dX,dY,dZ and magnitude r from the project state vector U. | def split_state(U):
return U[0], U[1], U[2], U[3], U[4], U[5], r(U) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec(self):\r\n\r\n xv = np.arange(self.dx / 2, self.lx, self.dx)\r\n yv = np.arange(-self.ly / 2 + self.dy / 2, self.ly / 2, self.dy)\r\n zv = np.arange(self.oz, self.lz + self.oz, self.dz)\r\n\r\n if self.ox != 0:\r\n xv = np.arange(self.ox, self.lx + self.ox, self.dx)\r... | [
"0.60033303",
"0.56687164",
"0.5581056",
"0.5566059",
"0.55581605",
"0.5483278",
"0.547167",
"0.54471254",
"0.54269505",
"0.5417094",
"0.54122615",
"0.53975004",
"0.53910923",
"0.5378723",
"0.5373825",
"0.5363088",
"0.53599566",
"0.53538674",
"0.5347581",
"0.5346851",
"0.5337... | 0.0 | -1 |
Opens a new database connection if there is none yet for the current application context. | def get_db():
if not hasattr(g, 'postgres_db'):
g.postgres_db = connect_db()
return g.postgres_db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db",
"def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)",
"def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec... | [
"0.7738785",
"0.7583889",
"0.73186874",
"0.71708626",
"0.70241374",
"0.6968058",
"0.69567364",
"0.69516224",
"0.6898437",
"0.6844457",
"0.6830317",
"0.6819776",
"0.6807468",
"0.6796977",
"0.67702866",
"0.6763331",
"0.6752875",
"0.6748848",
"0.673314",
"0.67014456",
"0.6688856... | 0.0 | -1 |
Parses the 1d data set into three separate data sets for each axis. Each trial's data is split into [0th slice, ..., (dim1)th slice] for each x, y, and z. To get only the Nth slices of an axis across all trials, traverse through data_dim_axis by index [N, N + dim1, N + 2dim1, ...] | def convert_1d_to_3d(data_X, data_Y):
data_X = data_X.tocsr()
data_dim_x = [] # slices along x-axis (has shape of (total_trials * dim_x, dim_z, dim_y))
data_dim_x_label = [] # contains (total_trials * dim_x) labels
data_dim_y = [] # slices along y-axis (has shape of (total_trials * dim_y, dim_z... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_slice_other_dimension(setup_teardown_file):\n f = setup_teardown_file[3]\n\n for i, shape in enumerate([(3, 0), (1, 2, 0), (2, 0, 1)]):\n dset = f.create_dataset('x%d'%i, shape, dtype=np.int32)\n assert dset.shape == shape\n out = dset[:1]\n assert isinstance(out, np.ndar... | [
"0.6175714",
"0.6072633",
"0.58613235",
"0.5805677",
"0.5799606",
"0.5719681",
"0.5651642",
"0.56276065",
"0.54468656",
"0.53935266",
"0.5339818",
"0.5322116",
"0.53019875",
"0.52620435",
"0.5252861",
"0.5247714",
"0.51936585",
"0.5185298",
"0.5181618",
"0.5177174",
"0.516000... | 0.6850255 | 0 |
Return a query filtering a given user for the current problem. | def _get_features(self, session, problem_name="", user_name=""):
#TODO pivot metrics tables
query = session.query(Feature, User.name)
#query = session.query(Feature, User.name, Metric)
if user_name:
query = query.filter(User.name == user_name)
if problem_name:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_for_user(self, user):\n query = Q(visibility=Document.PUBLIC) | \\\n Q(visibility=Document.PRIVATE, created_by=user) | \\\n Q(visibility=Document.ORG_ONLY,\n organization__memberships__user=user)\n\n if not user.external:\n query = query | Q(vi... | [
"0.6752233",
"0.66583574",
"0.65809894",
"0.6521227",
"0.64254826",
"0.641422",
"0.63735694",
"0.63310593",
"0.6292751",
"0.62748617",
"0.623925",
"0.62343127",
"0.6204801",
"0.6204801",
"0.6192706",
"0.6116131",
"0.61041623",
"0.60467815",
"0.60305375",
"0.5996594",
"0.59845... | 0.56740594 | 53 |
Return approximate period of the array y between t0 and tf | def periode(y, t0, tf):
l=len(y)
subd = subdivision(t0, tf, l)
nb_periodes = 0
m = 0
periode_f = 0
i = 1
while (i < l):
while ((i < l) and (y[i-1] > y[i])):
i += 1
while((i < l) and (y[i-1] < y[i])):
i += 1
if (i < l):
if (nb_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ytrue(t):\n return np.array([np.exp(lam*t)])",
"def ret_f(t,y):\n\n f = np.zeros(3)\n f[0] = 77.27*(y(1) - y(0)*y(1)+ y(0)-8.375e-6*y(0)*y(0))\n f[1] = (1.0/77.27)*(-y(1)-y(0)*y(1)+y(2))\n f[2] = 0.161*(y(0)-y(2))\n\n return f",
"def est_am(t,y):\n ch=t>t_eq\n y1=y[ch]\n return y... | [
"0.6703843",
"0.6620351",
"0.65095127",
"0.64868265",
"0.6477156",
"0.63925165",
"0.63925165",
"0.6383116",
"0.63666636",
"0.6344767",
"0.63133085",
"0.6238854",
"0.622496",
"0.61634177",
"0.61481524",
"0.604691",
"0.6021404",
"0.6016633",
"0.5985773",
"0.5962284",
"0.5944604... | 0.54531145 | 54 |
Returns a function that maps each index in 0, 1, ..., n1 to a distinct RGB color; the keyword argument name must be a standard mpl colormap name. | def get_cmap(n, name="hsv"):
return plt.cm.get_cmap(name, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cmap(n, name='jet'):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name='hsv'):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name='hsv'):\n return plt.cm.get_cmap(name, n)",
"def get_cmap(n, name='Paired'):\n return plt.cm.get_cmap(name, n)",
"def palette_from_mpl_name(na... | [
"0.70271176",
"0.69774204",
"0.69774204",
"0.6945939",
"0.67224956",
"0.65793276",
"0.6511907",
"0.64272636",
"0.63593674",
"0.6327584",
"0.62864006",
"0.61817783",
"0.613971",
"0.6112558",
"0.6092781",
"0.60421914",
"0.60195726",
"0.5990796",
"0.5959825",
"0.5958139",
"0.588... | 0.6929345 | 4 |
> (str) full name of the field with the name of the table included. i.e. the field |bar| in a table |foo| returns 'foo.bar' | def name(self):
if self.table:
return "{}.{}".format(self.table, self.field_name)
return self.field_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def namehack(field):\n if field.endswith((\"attribute\", \"views\")):\n return field + \"__name\"\n else:\n return field",
"def get_related_name(self, field=None):\n related_name = self.subrecord.__name__.lower()\n if field:\n related_name = \"{0}__{1}\".format(relate... | [
"0.69205326",
"0.6881168",
"0.6826993",
"0.6584583",
"0.65795636",
"0.65795636",
"0.6551517",
"0.6536231",
"0.65072536",
"0.63897425",
"0.63614273",
"0.6269764",
"0.6268629",
"0.6237498",
"0.62347585",
"0.62013537",
"0.6199085",
"0.6191742",
"0.61680526",
"0.6143412",
"0.6133... | 0.77557653 | 0 |
This function computes the surface area | def compute_surface_area(self):
return np.sum(self._find_triangle_areas()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def surface_area(self) -> float:\n return 4 * np.pi * self.radius**2",
"def surfaceArea(self):\n surfaceArea = self.sideLength**2 * 6\n return surfaceArea",
"def getSurfaceArea(self) -> float:\n return self.area()",
"def surface_area(self):\n return self._surface_area",
"... | [
"0.80011004",
"0.7844058",
"0.76182777",
"0.7455883",
"0.7309027",
"0.7252126",
"0.72476107",
"0.7167929",
"0.7060911",
"0.7034661",
"0.7029887",
"0.69332796",
"0.6921517",
"0.68879753",
"0.688659",
"0.6880711",
"0.6879456",
"0.68330854",
"0.67889273",
"0.6771197",
"0.67643",... | 0.83014 | 0 |
Returns and filters queryset based on context and query params. | def filter_queryset(self, queryset, view=None):
queryset = super().filter_queryset(queryset.only("id", "shared"))
form_pk = self.kwargs.get(self.lookup_field)
if form_pk:
try:
int(form_pk)
except ValueError as e:
if form_pk == self.public_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n # Get tags from the request if it was specified\n tags = self.request.query_params.get('tags')\n # Get authors from the request if it was specified\n authors = self.request.query_params.get('authors')\n # Make copy of queryset as to not modify the origin... | [
"0.7470713",
"0.7349306",
"0.7314266",
"0.7103448",
"0.7064712",
"0.70372987",
"0.7035834",
"0.69974697",
"0.69945574",
"0.69693255",
"0.6939901",
"0.6915013",
"0.6912268",
"0.6900177",
"0.68993694",
"0.68842185",
"0.68661326",
"0.68558514",
"0.6851547",
"0.6843153",
"0.68367... | 0.65753025 | 56 |
Set the submission instances queryset. | def set_object_list(self, query, fields, sort, start, limit, is_public_request):
xform = None
try:
enable_etag = True
if not is_public_request:
xform = self.get_object()
self.data_count = xform.num_of_submissions
enable_etag = sel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_submission_sets(apps, schema_editor):\n SubmissionSet = apps.get_model(\"core\", \"SubmissionSet\")\n\n for submission_set in SubmissionSet.objects.all():\n submission = submission_set.submissions.first()\n if not submission:\n submission_set.delete()\n else:\n ... | [
"0.59151727",
"0.54963905",
"0.54722977",
"0.54565376",
"0.54559654",
"0.54143745",
"0.5337643",
"0.53013283",
"0.52154154",
"0.51629066",
"0.51261985",
"0.5121978",
"0.51152354",
"0.5104146",
"0.510059",
"0.50913805",
"0.50902987",
"0.50897956",
"0.50830567",
"0.50822103",
"... | 0.540449 | 6 |
Returns the ``item`` Instance instance as a JSON string. | def get_json_string(item):
return json.dumps(item.json if isinstance(item, Instance) else item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _serialize_item(self, item_id: str, item: Pipeline) -> dict:\n return item.to_json()",
"def __repr__(self):\n return f\"Item=(id={self.id},item_name={self.item_name},item_slug={self.item_slug})\"",
"def __repr__(self):\n return '<Item {0} : {1}>'.format(self.item_id, self.item_name)",
... | [
"0.7664697",
"0.7162026",
"0.7117946",
"0.6911071",
"0.6823493",
"0.6803025",
"0.6772745",
"0.6762667",
"0.6739272",
"0.6738411",
"0.6654118",
"0.66514206",
"0.65619713",
"0.6546932",
"0.6546932",
"0.65354466",
"0.6527233",
"0.6491184",
"0.6487239",
"0.64639443",
"0.6459266",... | 0.86737585 | 0 |
Simply concatenate the provided tensors on their last dimension which needs to have the same size, along with their elementwise multiplication and difference | def __init__(self):
super(LinearAggregationLayer, self).__init__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concatenate(tensors, axis=0):\n raise NotImplementedError",
"def tensor_outer_product(tensor1, tensor2):\n shape_1 = tensor1.shape\n shape_2 = tensor2.shape\n s1 = len(shape_1)\n s2 = len(shape_2)\n \n shape_1 = shape_1 + (1, )*s2\n shape_2 = (1, )*s1 + shape_2\n return np.resh... | [
"0.7637168",
"0.6714965",
"0.6680546",
"0.66562545",
"0.64836586",
"0.64583445",
"0.6454333",
"0.6450519",
"0.6421476",
"0.6368759",
"0.6327544",
"0.6327544",
"0.63009626",
"0.6207492",
"0.62003607",
"0.6194805",
"0.61942124",
"0.61693233",
"0.61100644",
"0.60294825",
"0.6026... | 0.0 | -1 |
Return the last hidden state of a tensor returned by an RNN | def __init__(self):
super(GatherLastLayer, self).__init__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_last_hidden_state(hidden_state):\n seq_len, hidden_size = hidden_state.size()\n assert hidden_size % 2 == 0\n split_point = hidden_size // 2\n last_hidden_state = torch.cat(\n [hidden_state[-1, :split_point], hidden_state[0, split_point:]], dim=0\n )\n return last_hidden_state"... | [
"0.741594",
"0.7169452",
"0.67038333",
"0.66284984",
"0.63799495",
"0.6368448",
"0.6365789",
"0.62684083",
"0.6196929",
"0.6196715",
"0.61620486",
"0.61620486",
"0.615727",
"0.6151135",
"0.6151135",
"0.6145932",
"0.61277485",
"0.61249506",
"0.6087081",
"0.6070309",
"0.6064316... | 0.0 | -1 |
Turn a tensor image with shape CxHxW to a numpy array image with shape HxWxC | def tensor_img_to_npimg(tensor_img):
if not (torch.is_tensor(tensor_img) and tensor_img.ndimension() == 3):
raise NotImplementedError("Not supported tensor image. Only tensors with dimension CxHxW are supported.")
npimg = np.transpose(tensor_img.numpy(), (1, 2, 0))
npimg = npimg.squeeze()
assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def im_to_numpy(tensor):\n tensor_reshaped = tensor.expand(3, *tensor.shape[1:]).permute(1, 2, 0)\n return tensor_reshaped.detach().cpu().numpy()",
"def convert_chwTensor_to_hwcNumpy(tensor):\n\n if isinstance(tensor, Variable):\n return np.transpose(tensor.data.numpy(), (0,2,3,1))\n elif isin... | [
"0.7168356",
"0.7098812",
"0.7000924",
"0.69760305",
"0.68536866",
"0.68024725",
"0.6645319",
"0.66366255",
"0.65286654",
"0.6483346",
"0.6482863",
"0.64284253",
"0.63756907",
"0.6321261",
"0.62861276",
"0.62657464",
"0.6252519",
"0.6243349",
"0.6240875",
"0.6238048",
"0.6226... | 0.70642257 | 2 |
Check whether this field is nullable, i.e., can be `None`. | def is_nullable(self) -> bool: # pragma: no cover
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_nullable(self) -> bool:\n return self.__nullable",
"def is_nullable(self):\n return self._is_nullable",
"def is_nullable(schema_obj):\n\n if isinstance(schema_obj, schema.Field):\n return schema_obj.is_nullable\n return False",
"def is_null(self):\n return self.value is None... | [
"0.8449764",
"0.83130455",
"0.786248",
"0.7661689",
"0.74965847",
"0.7488365",
"0.7440954",
"0.7377148",
"0.73132867",
"0.71837443",
"0.7122148",
"0.71193844",
"0.71191525",
"0.70252806",
"0.6993334",
"0.6983965",
"0.6930141",
"0.69181836",
"0.68292755",
"0.6795569",
"0.67899... | 0.84807235 | 0 |
Returns the DOT language "HTMLlike" syntax specification of a row detailing this field that is part of a table describing the field's parent data model. It is used as part the `label` attribute of data model's node in the graph's DOT representation. | def dot_row(self) -> str:
return _row_template.format(name=self.name, type_name=self.type_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dot_label(self) -> str:\n rows = \"\\n\".join(field.dot_row() for field in self.fields)\n return _table_template.format(name=self.name, rows=rows).replace(\"\\n\", \"\")",
"def text(self):\n\n # Format is a list with each node and its parent, separated by NaN values\n return self.... | [
"0.6907708",
"0.6246067",
"0.6235558",
"0.59718263",
"0.59438574",
"0.5923333",
"0.5858097",
"0.57672936",
"0.5756135",
"0.56328",
"0.5613502",
"0.5565285",
"0.5556723",
"0.5556723",
"0.5497591",
"0.5491017",
"0.5485919",
"0.5484563",
"0.547055",
"0.5447842",
"0.5420922",
"... | 0.62071306 | 3 |
Check if object is the type of data model class that this model adapter works with. | def is_model_type(obj: Any) -> bool: # pragma: no cover
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isinstance(self, obj, raise_error=True):\n rv = isinstance(obj, self.__model__)\n if not rv and raise_error:\n raise ValueError('%s is not of type %s' % (obj, self.__model__))\n return rv",
"def is_dataclass_instance(obj: Any) -> bool:\n return dataclasses.is_dataclass(obj... | [
"0.79185575",
"0.75479585",
"0.75399536",
"0.7518996",
"0.7395414",
"0.7328052",
"0.71795946",
"0.7038402",
"0.7015072",
"0.68881327",
"0.6878079",
"0.68056995",
"0.67854327",
"0.67750436",
"0.6754461",
"0.6694614",
"0.6690304",
"0.66749346",
"0.66486806",
"0.66303533",
"0.66... | 0.78210646 | 1 |
Name of this data model. | def name(self) -> str: # pragma: no cover
return self.model.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self) -> str:\n return self._name(self.model).decode(\"utf-8\")",
"def name(self) -> str:\n return self._model.name",
"def name(self) -> str:\n return self.data['name']",
"def name(self):\n return self.NAME",
"def name(self):\n return self[\"name\"]",
"def name... | [
"0.84215224",
"0.8369717",
"0.8122773",
"0.80840874",
"0.80085826",
"0.8001325",
"0.79773605",
"0.79704523",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.79572695",
"0.7937095",
"0.7937095",
"... | 0.79749143 | 7 |
Fix the bank balance and return it as a float. | def _fix_balance(self, balance):
return float(balance.replace(',', '.').replace(' ', '')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_balance():\n return float(pareto.rvs(1.161))",
"def balance(self) -> float:\n\t\tbalance = 0\n\t\tfor transaction in self.transactions:\n\t\t\tsign = 1 if transaction.receiving_account == self.__number else -1\n\t\t\tbalance += sign*transaction.usd*transaction.completed\n\t\t# The bank has infinit... | [
"0.72123927",
"0.7061845",
"0.7009867",
"0.6872777",
"0.67247254",
"0.64945155",
"0.64721006",
"0.64484996",
"0.6287387",
"0.6281066",
"0.62781847",
"0.62356645",
"0.6213261",
"0.61990225",
"0.6180062",
"0.6111443",
"0.61091805",
"0.6072259",
"0.6057195",
"0.6021365",
"0.6020... | 0.7926201 | 0 |
Parse and return list of all account transactions. | def _parse_account_transactions(self, body):
transactions = []
soup = BeautifulSoup(body, 'html.parser')
for row in soup.select('.history.data-list-wrapper-inner tr'):
transaction = {
'date': row.select('td')[1].text,
'type': row.select('td')[2].sele... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listtransactions(self, account=None, count=10, from_=0, address=None):\n accounts = [account] if account is not None else list(self.listaccounts(as_dict=True).keys())\n return [TransactionInfo(**tx) for acc in accounts for\n tx in self.proxy.listtransactions(acc, count, from_) if\n... | [
"0.7151018",
"0.7149907",
"0.71008074",
"0.6977178",
"0.68028396",
"0.67775965",
"0.6729908",
"0.66277045",
"0.6610449",
"0.6469714",
"0.64354056",
"0.6426669",
"0.6411786",
"0.6402797",
"0.6374859",
"0.6352835",
"0.631962",
"0.63142496",
"0.6298551",
"0.6292313",
"0.62710595... | 0.7749547 | 0 |
Calculer IoU between 2 BBs hoi bi nguoc han tinh left bottom, right top TODO | def box_IoU(b1, b2):
with tf.name_scope('BB1'):
"""Calculate 2 corners: {left bottom, right top} and area of this box"""
b1 = tf.expand_dims(b1, -2) # shape= (None, 13, 13, 3, 1, 4)
b1_xy = b1[..., :2] # x,y shape=(None, 13, 13, 3, 1, 2)
b1_wh = b1[..., 2:4] # w,h shape=(None, 13,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_iou(bb1, bb2):\n if not is_overlap(bb1, bb2):\n return 0\n\n l1, t1, r1, b1 = bb1['x'], bb1['y'], bb1['x']+bb1['w'], bb1['y']+bb1['h']\n l2, t2, r2, b2 = bb2['x'], bb2['y'], bb2['x']+bb2['w'], bb2['y']+bb2['h']\n\n xa, ya = max(l1, l2), max(t1, t2)\n xb, yb = min(r1, r2), min(b1, b2)\... | [
"0.7558291",
"0.7531967",
"0.7019736",
"0.69820255",
"0.6909419",
"0.68078566",
"0.68008924",
"0.67070293",
"0.66814876",
"0.6641592",
"0.662588",
"0.6507753",
"0.64617664",
"0.6441121",
"0.64156467",
"0.6388921",
"0.63724005",
"0.6328378",
"0.6287686",
"0.6277985",
"0.626782... | 0.67484134 | 7 |
Calculate the time difference between two ticks. | def tickDiff(tStart, tEnd):
tDiff = tEnd - tStart
if tDiff < 0:
tDiff += (1 << 32)
return tDiff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_difference(time1: Time, time2: Time) -> float:\n dsec = time1.sec - time2.sec\n dnanosec = time1.nanosec - time2.nanosec\n dt = dsec + dnanosec/(10**9)\n return dt",
"def duration(self):\r\n return self.t2 - self.t1",
"def time_diff(dt1, dt2):\n return abs(int((dt2 - dt1).total_secon... | [
"0.74971485",
"0.7392402",
"0.7383741",
"0.6985187",
"0.6956584",
"0.681082",
"0.67833775",
"0.6701977",
"0.6572094",
"0.64646256",
"0.6447415",
"0.6424221",
"0.6405698",
"0.6351382",
"0.63408834",
"0.6327494",
"0.6264233",
"0.62584716",
"0.6234139",
"0.6215512",
"0.6212319",... | 0.672626 | 7 |
Set the range of PWM values to be used on the gpio. Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE, or PI_NOT_PERMITTED. | def set_PWM_range(user_gpio, range_):
return _u2i(_pigpio_command(_control, _PI_CMD_PRS, user_gpio, range_)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_PWM_range(user_gpio):\n return _u2i(_pigpio_command(_control, _PI_CMD_PRG, user_gpio, 0))",
"def get_PWM_real_range(user_gpio):\n return _u2i(_pigpio_command(_control, _PI_CMD_PRRG, user_gpio, 0))",
"def _set_pwm(self, raw_values):\n for i in range(len(self._pins)):\n self._pi.set... | [
"0.6903804",
"0.64802706",
"0.60067755",
"0.58858705",
"0.58708185",
"0.58489203",
"0.5753922",
"0.5605951",
"0.55939317",
"0.5473511",
"0.5472374",
"0.54461926",
"0.54359305",
"0.54064345",
"0.5387591",
"0.5380408",
"0.532704",
"0.5324829",
"0.5308869",
"0.5295573",
"0.52633... | 0.7968123 | 0 |
Returns the pigpio software version. | def get_pigpio_version():
return _pigpio_command(_control, _PI_CMD_PIGPV, 0, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_version():\n\n version_string = version_from_versioneer()\n\n if not version_string:\n version_string = version_from_pip()\n\n return version_string",
"def software_version(self) -> str:\n return self.data.get(Attribute.SOFTWARE_VERSION)",
"def get_hardware_revision():\n return... | [
"0.73811704",
"0.72887504",
"0.7246847",
"0.71916705",
"0.71436334",
"0.7046444",
"0.70196176",
"0.69799864",
"0.69646806",
"0.6942776",
"0.6942776",
"0.693798",
"0.69212884",
"0.68783",
"0.68749297",
"0.68749297",
"0.68749297",
"0.68749297",
"0.68749297",
"0.68642515",
"0.68... | 0.8240598 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.