query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Takes a junitxml filename or path to said file. From this file it extracts the testsuite node and adds it to the junit_docker.xml file, in the process it adds a name to the testsuite (the suite param) and changes the classname from tests. to {suite}. Finaly, it removes the original file. This is because jenkins was not... | def merge_to_junit_xml(filename: str, suite: str) -> None:
junit_docker = Path("junit_docker.xml")
if junit_docker.exists():
tree = ElementTree.parse(junit_docker)
root = tree.getroot()
for testsuite in root:
if testsuite.get("name", None) == suite:
root.remov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_xunit(self, filename):\n suite_node = ElementTree.Element(\"testsuite\")\n suite_node.attrib[\"name\"] = self.testsuite.name\n suite_node.attrib[\"tests\"] = str(self.testsuite.ntests)\n suite_node.attrib[\"failures\"] = str(self.testsuite.nfailed)\n if self.testsuite.pack... | [
"0.67144614",
"0.5849702",
"0.5829017",
"0.57557195",
"0.5434966",
"0.54201025",
"0.5408227",
"0.53354055",
"0.533011",
"0.53068054",
"0.5248331",
"0.52130663",
"0.5207915",
"0.51886815",
"0.5181097",
"0.5173391",
"0.51367235",
"0.5100445",
"0.509859",
"0.50914586",
"0.507439... | 0.8482886 | 0 |
Filter the queryset based on the provided report ID values. As each 'report' instance may optionally define its own filters, the resulting queryset is the 'union' of the two | def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
items = self.get_items()
if len(items) > 0:
"""At this point, we are basically forced to be inefficient:
We need to compare the 'filters' string of each report template,
and ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter(self, *args, **kwargs):\n self._not_support_combined_queries(\"filter\")\n return self._filter_or_exclude(False, args, kwargs)",
"def filter(self, *args, **kwargs):\n self._expand_pk(kwargs)\n return self._filter_or_exclude(False, *args, **kwargs)",
"def apply_filters(sel... | [
"0.5804842",
"0.5686271",
"0.5675178",
"0.56294256",
"0.5462482",
"0.5401659",
"0.5397983",
"0.5386459",
"0.53822505",
"0.5366553",
"0.5341901",
"0.5314391",
"0.52776104",
"0.52713615",
"0.5269606",
"0.52514786",
"0.5210558",
"0.51904607",
"0.5185385",
"0.5180498",
"0.5166344... | 0.6765876 | 0 |
Default implementation of GET for a print endpoint. Note that it expects the class has defined a get_items() method | def get(self, request, *args, **kwargs):
items = self.get_items()
return self.print(request, items) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, *args, **kwargs):\n pass",
"def get(self, *args, **kwargs):\n pass",
"def get(self, request, *args, **kwargs):\n return self.list(request, *args, **kwargs)",
"def get(self, request, *args, **kwargs):\n return self.list(request, *args, **kwargs)",
"def get(self, req... | [
"0.62591857",
"0.62591857",
"0.6256587",
"0.6256587",
"0.6256587",
"0.6256587",
"0.6256587",
"0.6229881",
"0.6121456",
"0.61131376",
"0.6078092",
"0.6053753",
"0.60147244",
"0.60127485",
"0.598551",
"0.5941915",
"0.5938586",
"0.5931523",
"0.5921613",
"0.58128387",
"0.5802244"... | 0.7976665 | 0 |
V.ComputeStructuredCoordinates(vtkAMRBox, (float, float, float), ( float, float, float), (float, float, float), [int, int, int], [float, float, float]) > int | def ComputeStructuredCoordinates(self, vtkAMRBox, , , , p_int=..., p_int=..., p_int=..., *args, **kwargs):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetBoxOrigin(self, vtkAMRBox, , , p_float=..., p_float=..., p_float=...):\n ...",
"def DoesBoxIntersectAlongDimension(self, vtkAMRBox, p_int):\n ...",
"def GetBounds(self, vtkAMRBox, , , p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=...):\n ...",
"def HasPo... | [
"0.6853599",
"0.62397337",
"0.60182947",
"0.5866916",
"0.58467484",
"0.5601747",
"0.558747",
"0.55727845",
"0.5501845",
"0.5414931",
"0.53707856",
"0.53597534",
"0.5356909",
"0.52701604",
"0.52600193",
"0.5217459",
"0.5192331",
"0.5168107",
"0.5134291",
"0.5133645",
"0.512709... | 0.881593 | 0 |
V.DoesBoxIntersectAlongDimension(vtkAMRBox, int) > bool | def DoesBoxIntersectAlongDimension(self, vtkAMRBox, p_int):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_in_image(box, image):\r\n rows = image.shape[0]\r\n cols = image.shape[1]\r\n return box[0] >= 0 and box[1] >= 0 and box[2] <= cols and box[3] <= rows",
"def in_box(coords, box):\n\tif box[0][0] < coords[0] < box[1][0] and box[1][1] < coords[1] < box[0][1]:\n\t\treturn True\n\treturn... | [
"0.6547362",
"0.6476373",
"0.6455584",
"0.6332803",
"0.62612915",
"0.62592554",
"0.6241445",
"0.622248",
"0.62011486",
"0.6175213",
"0.6157521",
"0.61411333",
"0.613348",
"0.6110399",
"0.6102755",
"0.60980844",
"0.6082963",
"0.6069663",
"0.60666573",
"0.60576814",
"0.6042059"... | 0.9140497 | 0 |
V.GetBounds(vtkAMRBox, (float, float, float), (float, float, float), [float, float, float, float, float, float]) | def GetBounds(self, vtkAMRBox, , , p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bounds(self):\n return self._bboxes[0][0] #TODO: merge all coverages",
"def GetBounds(self):\n ...",
"def GetBounds(self):\n ...",
"def GetBounds(self):\n ...",
"def GetBounds(self):\n ...",
"def GetBounds(self):\n ...",
"def GetBounds(self):\n ...",
"d... | [
"0.6927994",
"0.6787887",
"0.6787887",
"0.6787887",
"0.6787887",
"0.6787887",
"0.6787887",
"0.6787887",
"0.6787887",
"0.67129916",
"0.666752",
"0.6603672",
"0.6537393",
"0.65168804",
"0.6401685",
"0.6385878",
"0.6383735",
"0.63759303",
"0.6333268",
"0.6327049",
"0.62563384",
... | 0.8731795 | 0 |
V.GetBoxOrigin(vtkAMRBox, (float, float, float), (float, float, float), [float, float, float]) | def GetBoxOrigin(self, vtkAMRBox, , , p_float=..., p_float=..., p_float=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ComputeStructuredCoordinates(self, vtkAMRBox, , , , p_int=..., p_int=..., p_int=..., *args, **kwargs):\n ...",
"def GetBounds(self, vtkAMRBox, , , p_float=..., p_float=..., p_float=..., p_float=..., p_float=..., p_float=...):\n ...",
"def __init__(self, boxCoord):\n self.boxCoord =boxCoord... | [
"0.6713226",
"0.6548177",
"0.62387615",
"0.6077482",
"0.5997257",
"0.59862036",
"0.5934462",
"0.590664",
"0.58782905",
"0.58346933",
"0.5763362",
"0.5721885",
"0.5704231",
"0.5642697",
"0.5639615",
"0.55798084",
"0.55798084",
"0.55798084",
"0.55797523",
"0.553698",
"0.5505534... | 0.90110934 | 0 |
V.GetCellLinearIndex(vtkAMRBox, int, int, int, [int, int, int]) > int | def GetCellLinearIndex(self, vtkAMRBox, p_int, p_int_1, p_int_2, p_int=..., p_int=..., p_int=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DoesBoxIntersectAlongDimension(self, vtkAMRBox, p_int):\n ...",
"def CellBoundary(self, p_int, , vtkIdList):\n ...",
"def boxscore_index(self):\n return self._boxscore",
"def GetBoxOrigin(self, vtkAMRBox, , , p_float=..., p_float=..., p_float=...):\n ...",
"def get_index(sel... | [
"0.6180141",
"0.59907967",
"0.59018207",
"0.5721436",
"0.56878746",
"0.5674687",
"0.566031",
"0.56476855",
"0.5631614",
"0.5621277",
"0.55624396",
"0.55583566",
"0.55391216",
"0.5539084",
"0.5533785",
"0.5510658",
"0.55105114",
"0.55011135",
"0.5498016",
"0.54950076",
"0.5473... | 0.896459 | 0 |
V.GetGhostVector(int, [int, int, int, int, int, int]) | def GetGhostVector(self, p_int, p_int=..., p_int=..., p_int=..., p_int=..., p_int=..., p_int=...):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, arg0: ngsolve.ngstd.IntRange) -> BaseVector:",
"def AsVector(self) -> ngsolve.la.BaseVector:",
"def __getitem__(self, *args):\n return _ida_hexrays.qvector_lvar_t___getitem__(self, *args)",
"def xvec(self):\n return np.array([self.x, self.y])",
"def generate_vector(self,dim=... | [
"0.6517869",
"0.6359988",
"0.61246526",
"0.6064548",
"0.6045971",
"0.6022795",
"0.6020205",
"0.601929",
"0.5996275",
"0.59916466",
"0.59708065",
"0.5965795",
"0.59203076",
"0.58938336",
"0.5886847",
"0.588524",
"0.5851522",
"0.58494186",
"0.58342505",
"0.5833599",
"0.581636",... | 0.86604995 | 0 |
V.GetHiCorner() > (int, ...) | def GetHiCorner(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetLoCorner(self):\n ...",
"def corners((u,v)):\r\n return ((u+1,v+1), (u+1,v), (u,v), (u,v+1))",
"def footprint_corner_indices():",
"def GetCorners(self):\n ...",
"def upper_covers(self, x):",
"def _cal_meaningful_corners(self):\n corners = np.where(self._free_of_clash)\n ... | [
"0.76464623",
"0.6944285",
"0.65918684",
"0.617755",
"0.6175708",
"0.61426353",
"0.6121388",
"0.60429865",
"0.5924042",
"0.591059",
"0.58895296",
"0.5843339",
"0.57643855",
"0.5724532",
"0.571255",
"0.5692622",
"0.5690439",
"0.5662301",
"0.56549877",
"0.56549877",
"0.5633356"... | 0.8512737 | 0 |
V.GetLoCorner() > (int, ...) | def GetLoCorner(self):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetHiCorner(self):\n ...",
"def corners((u,v)):\r\n return ((u+1,v+1), (u+1,v), (u,v), (u,v+1))",
"def GetCorners(self):\n ...",
"def borders((u,v)):\r\n return ((u,v+1,S), (u+1,v,W), (u,v,S), (u,v,W))",
"def footprint_corner_indices():",
"def right_of(self,v):\n x,y = v[0:2]\n... | [
"0.76609766",
"0.6941712",
"0.6220685",
"0.6114222",
"0.6093272",
"0.5996886",
"0.59884423",
"0.5936555",
"0.5901324",
"0.58546394",
"0.5833557",
"0.5738406",
"0.57167816",
"0.57030666",
"0.5700455",
"0.56675464",
"0.5658317",
"0.5650595",
"0.5638506",
"0.56288946",
"0.562807... | 0.8442552 | 0 |
V.HasPoint(vtkAMRBox, (float, float, float), (float, float, float) , float, float, float) > bool | def HasPoint(self, vtkAMRBox, , , p_float_6, p_float_7, p_float_8):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DoesBoxIntersectAlongDimension(self, vtkAMRBox, p_int):\n ...",
"def __contains__(self, point): \n corners = self.corners\n\n if isinstance(point, tuple):\n from pyresample.spherical_geometry import Coordinate\n retval = planar_point_inside(Coordinate(*point), corne... | [
"0.6841587",
"0.68254536",
"0.65695286",
"0.6554639",
"0.65465",
"0.65465",
"0.64297205",
"0.63890225",
"0.63835347",
"0.636855",
"0.6355215",
"0.6316951",
"0.62981343",
"0.62856036",
"0.6283883",
"0.62801075",
"0.6259954",
"0.6232935",
"0.6190041",
"0.6182691",
"0.61550754",... | 0.88499534 | 0 |
V.SetDimensions(int, int, int, int, int, int, int) | def SetDimensions(self, p_int, p_int_1, p_int_2, p_int_3, p_int_4, p_int_5, p_int_6):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDimensions(self, *args):\n return _libsbml.Layout_setDimensions(self, *args)",
"def setVoxelSize(self, vxs):\n\t\tself.voxelsize = vxs\n\t\ta, b, c = vxs\n\t\tself.spacing = [1, b / a, c / a]",
"def setDims(self, k, name, dims):\n dims = tuple(dims)\n if self.debug:\n pri... | [
"0.7113299",
"0.67363375",
"0.66247135",
"0.6538332",
"0.6510735",
"0.6315262",
"0.6311217",
"0.6262314",
"0.62053883",
"0.6196453",
"0.6153795",
"0.6091557",
"0.6007539",
"0.5975007",
"0.58945024",
"0.58902776",
"0.5812198",
"0.5790954",
"0.57715434",
"0.5759321",
"0.5751996... | 0.7863769 | 0 |
Wrapper for the server_default 'userid' above so it is not called through SERVER_DEFAULTS in our code | def get_userid():
return _userid() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_default(cls):\n return cls.USER",
"def default_user(self) -> str:\n return OS_MAPPING.get(self.os, []).get(\"user\", None)",
"def get_user():\n\treturn '1', 200",
"def __int__(self):\r\n return self.userid",
"def default_server_info():\n # If not set or purposely set = None,... | [
"0.6433542",
"0.6210573",
"0.60074395",
"0.5999773",
"0.5978007",
"0.5956585",
"0.58859277",
"0.58013254",
"0.5787908",
"0.57846475",
"0.5762583",
"0.5752388",
"0.5743204",
"0.5734268",
"0.5707711",
"0.5678209",
"0.5653608",
"0.5631425",
"0.56307405",
"0.5624438",
"0.5616475"... | 0.6384281 | 1 |
Unknown actions aren't a traceback. | def test_unknown_action(self):
exit_string = actions.main(["foo"])
self.assertEqual("Action foo undefined", exit_string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unknown_action(self):\n exit_string = actions.main(['foo'])\n self.assertEqual('Action \"foo\" undefined', exit_string)",
"def traceback(self):",
"def actions() -> None:\n pass",
"def __call__(self,action=None):\n raise NYI",
"def test_unrecognized_actions_rejected(self):\n... | [
"0.7196508",
"0.7029586",
"0.6705374",
"0.6679866",
"0.65183157",
"0.6450634",
"0.64372224",
"0.6418792",
"0.64057785",
"0.6294421",
"0.6267803",
"0.6191011",
"0.61486816",
"0.6099821",
"0.6038406",
"0.60370034",
"0.6010181",
"0.60018474",
"0.5990686",
"0.5988511",
"0.5985331... | 0.7247266 | 0 |
Actions which traceback trigger action_fail() calls. | def test_failing_action(self):
dummy_calls = []
self.action_fail.side_effect = dummy_calls.append
def dummy_action(args):
raise ValueError("uh oh")
with mock.patch.dict(actions.ACTIONS, {"foo": dummy_action}):
actions.main(["foo"])
self.assertEqual(dumm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_failing_action(self):\n dummy_calls = []\n\n self.ch_core.hookenv.action_fail.side_effect = dummy_calls.append\n\n def dummy_action(args):\n raise ValueError('uh oh')\n\n with mock.patch.dict(actions.ACTIONS, {'foo': dummy_action}):\n actions.main(['foo'])... | [
"0.7411279",
"0.64359295",
"0.6383231",
"0.6339706",
"0.63265985",
"0.622575",
"0.62107235",
"0.62066996",
"0.6095239",
"0.60725355",
"0.60586405",
"0.5981069",
"0.5976549",
"0.5956263",
"0.59348005",
"0.5933755",
"0.5911073",
"0.5907096",
"0.58949953",
"0.5894857",
"0.588262... | 0.71720064 | 1 |
Add config for VoVNet. | def add_vovnet_config(cfg):
_C = cfg
_C.MODEL.VOVNET = CN()
_C.MODEL.VOVNET.CONV_BODY = "V-39-eSE"
_C.MODEL.VOVNET.OUT_FEATURES = ["stage2", "stage3", "stage4", "stage5"]
# Options: FrozenBN, GN, "SyncBN", "BN"
_C.MODEL.VOVNET.NORM = "FrozenBN"
_C.MODEL.VOVNET.OUT_CHANNELS = 256
_C.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_config(self, config):\n \n config.setdefaults(\n 'Network', {'IP': '192.168.1.16', 'port': 8000}\n )\n config.setdefaults(\n 'Camera', {'ISO': 100, 'Shutter': 5000, 'Aperture': 4, 'Zoom': 45}\n )\n config.setdefaults(\n 'Admin... | [
"0.6232082",
"0.60484684",
"0.60199356",
"0.59929556",
"0.5975335",
"0.5931359",
"0.59164447",
"0.59083986",
"0.5876919",
"0.5830192",
"0.5786052",
"0.57853055",
"0.56969523",
"0.5644354",
"0.56345737",
"0.56345737",
"0.5609556",
"0.55977726",
"0.5585842",
"0.5571615",
"0.556... | 0.795893 | 0 |
Validate and create a list of twitter authentication elements | def twitter_auth(consumer_key=None, consumer_secret=None, access_key=None, access_secret=None):
if not consumer_key:
consumer_key = os.environ.get('T_CONSUMER_KEY', consumer_key)
if not consumer_secret:
consumer_secret = os.environ.get('T_CONSUMER_SECRET', consumer_secret)
if not access_key... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_all_existing_tokens_authenticated_user(self):\r\n\r\n user = UserFactory.create_batch(2)[1]\r\n user.info = create_tokens_for(user)\r\n del user.info['google_token']\r\n\r\n res = self.app.get('api/token?api_key=' + user.api_key)\r\n data = json.loads(res.data)\r\n\r... | [
"0.5508529",
"0.5407935",
"0.5397758",
"0.5393857",
"0.5376535",
"0.5256781",
"0.523868",
"0.5232314",
"0.5232087",
"0.5217924",
"0.5213543",
"0.5208988",
"0.5189751",
"0.5189009",
"0.51794183",
"0.51718926",
"0.51707536",
"0.5158603",
"0.5157783",
"0.5156875",
"0.5146338",
... | 0.57369494 | 0 |
Validate and create reddit access credentials | def reddit_auth(client_id=None, client_secret=None):
if not client_id:
client_id = os.environ.get('R_CLIENT_ID', client_id)
if not client_secret:
client_secret = os.environ.get('R_CLIENT_SECRET', client_secret)
user_agent = 'smtk:d4d'
# auth = [client_id, client_secret, user_agent]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate(self):\n \n return praw.Reddit(\n client_id = os.environ.get(\n \"CLIENT_ID\"),\n client_secret = os.environ.get(\n \"CLIENT_SECRET\"),\n username = os.environ.get(\n \"USERNAME\"),\n password = os.environ.get(\n ... | [
"0.612015",
"0.6108146",
"0.58253974",
"0.5823662",
"0.58194077",
"0.57738745",
"0.5772843",
"0.5723902",
"0.56990874",
"0.5644359",
"0.5522613",
"0.542311",
"0.53950876",
"0.538076",
"0.5378675",
"0.5364019",
"0.5353602",
"0.53417313",
"0.53414446",
"0.5334806",
"0.53295755"... | 0.67670363 | 0 |
Fetch extended information for the specified users. Users may be specified either as lists of either user_ids, screen_names, or twitter.User objects. The list of users that are queried is the union of all specified parameters. | def UsersLookup_modified(self,
user_id=None,
screen_name=None,
users=None,
include_entities=True,
return_JSON = False):
if not user_id and not screen_name and not users:
raise twitter.TwitterError({'message':... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUsersLookup(self, **kwargs):\n screen_name = handleShouldBeList(kwargs.get('screen_name', None))\n user_id = handleShouldBeList(kwargs.get('user_id', None))\n\n params = {\n 'include_entities': kwargs.get('include_entities', None),\n 'tweet_mode': kwargs.get('tweet... | [
"0.6783255",
"0.65110224",
"0.6474748",
"0.6457495",
"0.6354802",
"0.63074374",
"0.6229125",
"0.6138436",
"0.6106577",
"0.60918707",
"0.6085461",
"0.6061572",
"0.60550267",
"0.604952",
"0.60069096",
"0.5980039",
"0.5968098",
"0.5962766",
"0.5926453",
"0.5910784",
"0.5903772",... | 0.6851053 | 0 |
Split a logfile line into a dict of specific attributes of interest. Initially we just want size and requested file name, so we'll split on spaces and pull the data out. | def split(self, line):
parts = line.split()
return {
'size': 0 if parts[9] == '-' else int(parts[9]),
'file_requested': parts[6]
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_line(self, line):\n fields = line.split('|', 4) # stop splitting after fourth | found\n line_info = {'raw_message': line}\n if len(fields) == 5:\n line_info.update(dict(zip(self._fieldnames, fields)))\n return line_info",
"def _parse_line(self, line):\n m... | [
"0.6926088",
"0.6606197",
"0.62269443",
"0.62132883",
"0.6173081",
"0.6137619",
"0.60874146",
"0.60272986",
"0.60269606",
"0.60140955",
"0.5950168",
"0.59259653",
"0.5875382",
"0.5870191",
"0.5836474",
"0.57917416",
"0.5757606",
"0.57351154",
"0.5705556",
"0.56574345",
"0.565... | 0.7668187 | 0 |
This function is called to generate a random set of data The function gets the values put in by the user scales/sliders | def generate():
global data
data = []
# Generate a random data set
for _ in range(usr_size.get()):
data.append(random.randrange(usr_min.get(), usr_max.get()+1))
display_data(data, ['red' for x in range(len(data))]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute(self):\n # get the parameter values from the widgets\n loc = float(str(self.loctext.text()))\n scale = float(str(self.scaletext.text()))\n # check the values\n # compute\n self.data[2] = self.data[1] + np.random.normal(loc, scale, self.npt)\n self.data[3... | [
"0.6813718",
"0.65909255",
"0.65069234",
"0.64956844",
"0.64515346",
"0.64137477",
"0.63184637",
"0.6254168",
"0.62331945",
"0.6210452",
"0.61599904",
"0.6113222",
"0.60703826",
"0.6063224",
"0.6052808",
"0.6033647",
"0.5970407",
"0.592437",
"0.591089",
"0.5906543",
"0.590047... | 0.72280276 | 0 |
Converts a coordinates string into a dictionary of lats and lons. | def _package_coordinates(self, coords_string):
values = [float(x) for x in coords_string.strip().replace(",", " ").split()]
if len(values) % 2 != 0:
raise Exception("Number of values for coordinates is not even.")
return {"lat": values[0::2], "lon": values[1::2], "type": "polygon"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _lat_lons_from_geojson(s):\n if len(s) >= 2 and isinstance(s[0], _number) and isinstance(s[0], _number):\n lat, lon = s[1], s[0]\n return [(lat, lon)]\n else:\n return [lat_lon for sub in s for lat_lon in _lat_lons_from_geojson(sub)]",
"def string_to_json_position(x):\n\n s = x.... | [
"0.6200124",
"0.6180494",
"0.6039203",
"0.59636515",
"0.5796904",
"0.57461715",
"0.56090033",
"0.5575448",
"0.5531238",
"0.547524",
"0.5460932",
"0.54279685",
"0.53942615",
"0.53920263",
"0.53875566",
"0.5375059",
"0.5364771",
"0.53562665",
"0.53462917",
"0.53424555",
"0.5319... | 0.7149103 | 0 |
Adds extra metadata extracted from the filename. Dictionary `extra_metadata` is changed in place. Returns nothing. | def _add_filename_metadata(self, extra_metadata):
# Make sure product_info section exists
extra_metadata.setdefault('product_info', {})
file_name = os.path.basename(self.fname)
fn_comps = file_name.split("_")
if self.__class__ == SAFESentinel1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_extra_metadata(self, extra_metadata):\n self._add_filename_metadata(extra_metadata)\n self._derive_extra_metadata(extra_metadata)\n \n if type(self) == SAFESentinel3:\n self._extract_metadata_from_zipfile(extra_metadata)",
"def __appendMetaData(self, filename):\... | [
"0.78124166",
"0.70173407",
"0.6769287",
"0.6409602",
"0.637862",
"0.6236373",
"0.59410167",
"0.5940643",
"0.5820693",
"0.5777957",
"0.57753646",
"0.57529926",
"0.5738356",
"0.5732771",
"0.57027894",
"0.57023615",
"0.56945705",
"0.56768316",
"0.5656454",
"0.56031406",
"0.5579... | 0.7716808 | 1 |
Derives extra fields from the existing fields. Dictionary `extra_metadata` is changed in place. Returns nothing. | def _derive_extra_metadata(self, extra_metadata):
extra_metadata['platform']['Family'] = extra_metadata['platform']['Platform Family Name']
# Add platform number if derivable from file
if self.__class__ is not SAFESentinel1:
extra_metadata['platform']['Family'] += "-%s" % extra_meta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_extra(cls, values: Dict[str, Any]) -> Dict[str, Any]:\n all_required_field_names = {field.alias for field in cls.__fields__.values()}\n\n extra = values.get(\"model_kwargs\", {})\n for field_name in list(values):\n if field_name not in all_required_field_names:\n ... | [
"0.6394947",
"0.6265129",
"0.6097499",
"0.60904527",
"0.60773903",
"0.59064895",
"0.58556277",
"0.58184004",
"0.5778241",
"0.5764353",
"0.5725135",
"0.56945044",
"0.5681247",
"0.567161",
"0.56645566",
"0.56113684",
"0.55990225",
"0.55883664",
"0.5582197",
"0.5564177",
"0.5516... | 0.6381761 | 1 |
Set extra metadata extracted from the zip file. Dictionary `extra_metadata` is changed in place. Returns nothing. | def _extract_metadata_from_zipfile(self, extra_metadata):
try:
if type(self) == SAFESentinel2:
zip_metadata = sentinel2.Sentinel2Scan(self.fname).sentinel_metadata
elif type(self) == SAFESentinel3:
zip_metadata = sentinel3.Sentinel3Scan(self.fname).senti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_extra_metadata(self, extra_metadata):\n self._add_filename_metadata(extra_metadata)\n self._derive_extra_metadata(extra_metadata)\n \n if type(self) == SAFESentinel3:\n self._extract_metadata_from_zipfile(extra_metadata)",
"def _add_filename_metadata(self, extra... | [
"0.82966655",
"0.6317464",
"0.6227719",
"0.60372996",
"0.59887105",
"0.586281",
"0.5768411",
"0.56712747",
"0.5647132",
"0.5582265",
"0.55669236",
"0.5524153",
"0.55071056",
"0.5481778",
"0.5435304",
"0.53943723",
"0.53831923",
"0.53691685",
"0.53644294",
"0.5344651",
"0.5342... | 0.7846382 | 1 |
Set extra content from existing content and filename. Dictionary `extra_metadata` is changed in place. Returns nothing. | def _update_extra_metadata(self, extra_metadata):
self._add_filename_metadata(extra_metadata)
self._derive_extra_metadata(extra_metadata)
if type(self) == SAFESentinel3:
self._extract_metadata_from_zipfile(extra_metadata) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_filename_metadata(self, extra_metadata): \n \n # Make sure product_info section exists\n extra_metadata.setdefault('product_info', {})\n \n file_name = os.path.basename(self.fname)\n fn_comps = file_name.split(\"_\")\n \n if self.__class__ == SA... | [
"0.59271455",
"0.5540022",
"0.53696483",
"0.52105075",
"0.51960105",
"0.5182525",
"0.5176605",
"0.51358",
"0.51144683",
"0.51024294",
"0.50993437",
"0.50797385",
"0.5036547",
"0.5032949",
"0.50266296",
"0.50255513",
"0.5004227",
"0.5001558",
"0.49845618",
"0.498424",
"0.49800... | 0.6900195 | 0 |
Takes the dictionary file info `metadata` and does some ESA SAFE specific searching for the '.zip' and '.png' files to report on their existence in the output dictionary by adding to `metadata`. | def _update_filesystem_metadata(self, metadata):
directory, fname = os.path.split(self.fname)
fbase = os.path.splitext(fname)[0]
# Test for presence and size of zip file
zip_file = fbase + '.zip'
zip_path = os.path.join(directory, zip_file)
if os.path.is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_files(metadata_dir, images_dir, image_format, metadata_format):\n all_metadata_files = [x for x in set(os.listdir(metadata_dir)) if x.endswith(metadata_format)]\n all_image_files = [x for x in set(os.listdir(images_dir)) if x.endswith(image_format)]\n images_and_metadata = {}\n for metadata, im... | [
"0.636453",
"0.62716496",
"0.6077342",
"0.6043057",
"0.58981687",
"0.5895847",
"0.5823604",
"0.57824016",
"0.56689334",
"0.5667995",
"0.5650802",
"0.56482416",
"0.56302243",
"0.5626277",
"0.56258726",
"0.56151515",
"0.56082755",
"0.5600401",
"0.5584119",
"0.55749756",
"0.5564... | 0.6572277 | 0 |
The hDQN learning algorithm. All schedules are w.r.t. total number of steps taken in the environment. | def hdqn_learning(
env,
agent,
num_episodes,
exploration_schedule,
gamma=1.0,
):
###############
# RUN ENV #
###############
# Keep track of useful statistics
stats = plotting.EpisodeStats(
episode_lengths=np.zeros(num_episodes),
episode_rewards=np.zeros(n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Q_learning_train(env,alpha,gamma,epsilon,episodes):\n %time\n # For plotting metrics\n all_epochs = []\n all_penalties = []\n rewards = []\n \n #Initialize Q table of 22500 x 8 size (22500 states and 8 actions) with all zeroes\n q_table = np.zeros([env.observation_space.n, env.action_sp... | [
"0.63875365",
"0.63236696",
"0.63088506",
"0.6305369",
"0.6249787",
"0.6219803",
"0.62004256",
"0.6192222",
"0.6188498",
"0.61266965",
"0.6122434",
"0.609209",
"0.60719156",
"0.60613084",
"0.6050038",
"0.60391426",
"0.6034889",
"0.6017718",
"0.60007626",
"0.59964746",
"0.5953... | 0.6834168 | 0 |
Function to apply the Harmonic analysis of time series applied to arrays sample_count = nr. of images (total number of actual samples of the time series) base_period_len = length of the base period, measured in virtual samples (days, dekads, months, etc.) frequencies_considered_count = number of frequencies to be consi... | def HANTS(sample_count, inputs,
frequencies_considered_count=3,
outliers_to_reject='Hi',
low=0., high=255,
fit_error_tolerance=5,
delta=0.1):
# define some parameters
base_period_len = sample_count*2 #
# check which setting to set for outlier filtering
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_harmonic(self,omega,windowlength=3*86400.0,overlap=12*3600.0, plot=True):\r\n \r\n # Make sure that omega is a list\r\n try:\r\n len(omega)\r\n except:\r\n omega=[omega]\r\n \r\n pt1,pt2 = window_index_time(self.t,windowlength,overlap)\r\n... | [
"0.65695894",
"0.6082727",
"0.57877994",
"0.5768405",
"0.57669526",
"0.56731206",
"0.56206816",
"0.55813754",
"0.5539861",
"0.55284065",
"0.5503824",
"0.546635",
"0.5404206",
"0.5376705",
"0.5342813",
"0.5312556",
"0.5302393",
"0.5298924",
"0.52896243",
"0.52830213",
"0.52770... | 0.6632163 | 0 |
Clean an IPv6 address string. Raise ValidationError if the address is invalid. | def clean_ipv6_address(
ip_str, unpack_ipv4=False, error_message=_("This is not a valid IPv6 address.")
):
try:
addr = ipaddress.IPv6Address(int(ipaddress.IPv6Address(ip_str)))
except ValueError:
raise ValidationError(error_message, code="invalid")
if unpack_ipv4 and addr.ipv4_mapped:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_ipv6_address(address, allow_brackets = False):\n\n if allow_brackets:\n if address.startswith('[') and address.endswith(']'):\n address = address[1:-1]\n\n if address.count('.') == 3:\n # Likely an ipv4-mapped portion. Check that its vaild, then replace with a\n # filler.\n\n ipv4_s... | [
"0.65634173",
"0.6422938",
"0.60198426",
"0.5987073",
"0.5893264",
"0.58569044",
"0.58527017",
"0.5852318",
"0.58370996",
"0.58313394",
"0.5744319",
"0.5645577",
"0.56425714",
"0.5566884",
"0.5538559",
"0.55270946",
"0.55110484",
"0.5479389",
"0.5477073",
"0.5451076",
"0.5435... | 0.7801858 | 0 |
Return whether or not the `ip_str` string is a valid IPv6 address. | def is_valid_ipv6_address(ip_str):
try:
ipaddress.IPv6Address(ip_str)
except ValueError:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_ipv6_address(ip_str):\r\n # We need to have at least one ':'.\r\n if ':' not in ip_str:\r\n return False\r\n\r\n # We can only have one '::' shortener.\r\n if ip_str.count('::') > 1:\r\n return False\r\n\r\n # '::' should be encompassed by start, digits or end.\r\n if '... | [
"0.84905803",
"0.81758726",
"0.8022839",
"0.77779543",
"0.77734876",
"0.7747603",
"0.7695875",
"0.7677913",
"0.7669417",
"0.7414498",
"0.7287234",
"0.7211587",
"0.71508443",
"0.7039122",
"0.70264167",
"0.69978344",
"0.6871135",
"0.68205786",
"0.6794286",
"0.6755182",
"0.66914... | 0.9118251 | 0 |
Rewrite `get_bboxes` of `GFLHead` for default backend. Rewrite this function to deploy model, transform network output for a batch into bbox predictions. | def gfl_head__get_bbox(ctx,
self,
cls_scores,
bbox_preds,
score_factors=None,
img_metas=None,
cfg=None,
rescale=False,
with_nms=True,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def im_detect_bbox(model, im, target_scale, target_max_size, boxes=None):\n\n inputs, im_scale = _get_blobs(im, boxes, target_scale, target_max_size)\n\n \n\n if cfg.DEDUP_BOXES > 0:\n v = np.array([1, 1e3, 1e6, 1e9, 1e12])\n hashes = np.round(inputs['rois'] * cfg.DEDUP_BOXES).dot(v)\n ... | [
"0.6367146",
"0.63244224",
"0.63055766",
"0.62705636",
"0.61812466",
"0.61450016",
"0.6081446",
"0.6073175",
"0.60689294",
"0.60434335",
"0.6026332",
"0.6024328",
"0.5992725",
"0.5925751",
"0.5912662",
"0.5903787",
"0.5903787",
"0.5890349",
"0.5886075",
"0.5878742",
"0.584486... | 0.6346811 | 1 |
Analyze, debug and validate your training and development data, get useful stats, and find problems like invalid entity annotations, cyclic dependencies, low data labels and more. | def debug_data(
# fmt: off
lang: ("Model language", "positional", None, str),
train_path: ("Location of JSON-formatted training data", "positional", None, Path),
dev_path: ("Location of JSON-formatted development data", "positional", None, Path),
tag_map_path: ("Location of JSON-formatted tag map", ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n # Read data for train set\n print('loading training data')\n train = read_datafile('../data/tsd_train.csv')\n\n # Read trial data for validation set\n validation = read_datafile('../data/tsd_trial.csv')\n\n # Read data for test set\n print('loading test data')\n test = read_datafile('../data/... | [
"0.6431962",
"0.61798257",
"0.61785036",
"0.61569124",
"0.61369395",
"0.61259204",
"0.6121422",
"0.6117343",
"0.6061163",
"0.6043467",
"0.6029398",
"0.59803045",
"0.5972278",
"0.594772",
"0.59467584",
"0.59008116",
"0.590035",
"0.58814085",
"0.5870088",
"0.5854492",
"0.584985... | 0.6626842 | 0 |
Ensure certificates are valid v1.2 schema | def validate_schema(self):
for _, certificate in self.certificates_to_issue.items():
with open(certificate.signed_cert_file_name) as cert:
cert_json = json.load(cert)
validate_unsigned_v1_2(cert_json) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_certificate_validations():\n course_runs = CourseRunFactory.create_batch(2)\n programs = ProgramFactory.create_batch(2)\n\n course_runs[0].course.page.certificate_page.save_revision()\n course_runs[1].course.page.certificate_page.save_revision()\n\n programs[0].page.certificate_page.save_re... | [
"0.62195843",
"0.60403657",
"0.5973859",
"0.5866873",
"0.5819868",
"0.5807078",
"0.57891136",
"0.57791334",
"0.574835",
"0.57312673",
"0.57312673",
"0.571396",
"0.56870914",
"0.5676448",
"0.5651216",
"0.5631203",
"0.56237787",
"0.5606721",
"0.5570994",
"0.55380255",
"0.552600... | 0.75421417 | 0 |
Hash the JSONLD normalized certificate | def do_hash_certificate(self, certificate):
options = {'algorithm': 'URDNA2015', 'format': 'application/nquads', 'documentLoader': cached_document_loader}
cert_utf8 = certificate.decode('utf-8')
cert_json = json.loads(cert_utf8)
normalized = jsonld.normalize(cert_json, options=options)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hash(self) -> bytes:",
"def internal_hash(self):\r\n return _TripleCanonicalizer(self).to_hash()",
"def do_hash(dat: typing.Any) -> str:\n return hashlib.sha1(json.dumps(dat, sort_keys=True).encode('utf-8')).hexdigest()",
"def hexdigest(jsonable):\n string = json.dumps(jsonable, sort_keys=Tr... | [
"0.64081043",
"0.6407922",
"0.6085655",
"0.60141075",
"0.5990725",
"0.5913254",
"0.59058625",
"0.5895313",
"0.58938307",
"0.58895487",
"0.58408225",
"0.58405244",
"0.58405244",
"0.58138174",
"0.58133066",
"0.57824796",
"0.57690185",
"0.5749606",
"0.57358474",
"0.57310355",
"0... | 0.78307027 | 0 |
Per certificate, we pay 2min_per_output (which is based on dust) + fee. Note assumes 1 input per tx. | def calculate_cost_for_certificate_batch(self):
num_inputs = 1
# output per recipient
num_outputs = len(self.certificates_to_issue)
# plus revocation outputs
num_outputs += sum(1 for c in self.certificates_to_issue.values() if c.revocation_key)
# plus global revocation, c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_fee(inputs: List[UTXO], fee_rate: float, data: Optional[bytes]=None):\n lst_reduce = 0\n if len(inputs) > 0:\n for x in inputs:\n lst_reduce += TX_INPUT_BASE + \\\n (len(x.witness_utxo.script)\n if x.witness_utxo.script else TX_INPUT_PUBKEYHASH)\n\n ... | [
"0.5380131",
"0.53256136",
"0.5247539",
"0.52209157",
"0.5126083",
"0.50726306",
"0.5040589",
"0.5025498",
"0.5017685",
"0.500796",
"0.49776417",
"0.49668923",
"0.49505",
"0.4882323",
"0.48558718",
"0.4836654",
"0.48327735",
"0.48152772",
"0.48044893",
"0.47853735",
"0.477508... | 0.5840483 | 0 |
Should not have threads that are marked invisible. | def test_invisible_thread(self):
thread = self.create_thread(visible=False)
result = Thread.public.by_user(thread.recipients.first())
self.assertNotIn(thread, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invisible_thread(self):\n thread = self.create_thread(visible=False)\n result = Thread.public.by_group(thread.group)\n self.assertNotIn(thread, result)",
"def test_non_active_userthread(self):\n user = self.create_user()\n thread = self.create_thread(recipient=user)\n\... | [
"0.842487",
"0.6570016",
"0.64893293",
"0.6438817",
"0.64271045",
"0.60679334",
"0.60620576",
"0.6002798",
"0.5949417",
"0.58704996",
"0.5864358",
"0.5839722",
"0.5821307",
"0.5807377",
"0.57395947",
"0.5737926",
"0.5713031",
"0.57112116",
"0.57056344",
"0.56932515",
"0.56914... | 0.819304 | 1 |
Userthreads that are not active should not be in the by_user | def test_non_active_userthread(self):
user = self.create_user()
thread = self.create_thread(recipient=user)
UserThread.objects.filter(
thread=thread, user=user).update(status='deleted')
result = Thread.public.by_user(user)
self.assertNotIn(thread, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_by_user_user_is_not_in_group_or_recipient(self):\n thread = self.create_thread()\n user = self.create_user()\n result = Thread.public.by_user(user=user)\n self.assertNotIn(thread, result)",
"def test_invisible_thread(self):\n thread = self.create_thread(visible=False)\... | [
"0.7178074",
"0.67722374",
"0.6556259",
"0.64464927",
"0.5973816",
"0.5969602",
"0.5942077",
"0.5941783",
"0.5904556",
"0.58965063",
"0.58892447",
"0.5802833",
"0.5765719",
"0.57427627",
"0.57249284",
"0.5713149",
"0.56894904",
"0.56878996",
"0.5669149",
"0.566215",
"0.564690... | 0.7816324 | 0 |
The current userthread_status should be selected. | def test_userthread_status(self):
thread = self.create_thread()
thread = Thread.public.by_user(thread.test_shortcuts['recipient'])
self.assertEqual(thread[0].userthread_status, 'active') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_active(self):\n return self.status == ACTIVE_USER",
"def status(self):\n return UserStatuses.Pending.value",
"def get_status(self):\n statuses = dict(ACTIVITY_STATUS_CHOICES)\n return statuses.get(self.status, \"N/A\")",
"def is_active_user(self):\n\n return self.is_... | [
"0.6337266",
"0.6276754",
"0.60865104",
"0.6026635",
"0.5982267",
"0.58548343",
"0.58404535",
"0.58234686",
"0.5804529",
"0.5776344",
"0.5761394",
"0.5733293",
"0.5723153",
"0.5712559",
"0.5712559",
"0.5703948",
"0.5703948",
"0.5703232",
"0.56989425",
"0.5695844",
"0.56577194... | 0.7455018 | 0 |
Should not have threads posted to another group. | def test_by_group_no_messages_for_another_group(self):
thread = self.create_thread()
other_group = mommy.make('groups.Group')
result = Thread.public.by_group(thread.group)
self.assertNotIn(other_group, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invisible_thread(self):\n thread = self.create_thread(visible=False)\n result = Thread.public.by_group(thread.group)\n self.assertNotIn(thread, result)",
"def test_group_is_private(self):\n group = mommy.make('groups.Group', private=True)\n thread = self.create_thread(... | [
"0.7176729",
"0.7124229",
"0.7064972",
"0.69740695",
"0.6888151",
"0.6781709",
"0.6769937",
"0.67116785",
"0.6690149",
"0.6512057",
"0.6498237",
"0.6332847",
"0.62771827",
"0.6211294",
"0.61997145",
"0.6147032",
"0.61397076",
"0.61139333",
"0.60805964",
"0.6050651",
"0.604012... | 0.7741443 | 0 |
Should not have threads that are marked invisible. | def test_invisible_thread(self):
thread = self.create_thread(visible=False)
result = Thread.public.by_group(thread.group)
self.assertNotIn(thread, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invisible_thread(self):\n thread = self.create_thread(visible=False)\n result = Thread.public.by_user(thread.recipients.first())\n self.assertNotIn(thread, result)",
"def test_non_active_userthread(self):\n user = self.create_user()\n thread = self.create_thread(recipi... | [
"0.819304",
"0.6570016",
"0.64893293",
"0.6438817",
"0.64271045",
"0.60679334",
"0.60620576",
"0.6002798",
"0.5949417",
"0.58704996",
"0.5864358",
"0.5839722",
"0.5821307",
"0.5807377",
"0.57395947",
"0.5737926",
"0.5713031",
"0.57112116",
"0.57056344",
"0.56932515",
"0.56914... | 0.842487 | 0 |
Private groups should not have their threads exposed. | def test_group_is_private(self):
group = mommy.make('groups.Group', private=True)
thread = self.create_thread(group=group)
result = Thread.public.by_group(group)
self.assertNotIn(thread, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_group_is_private_user_is_not_member(self):\n thread = self.create_thread()\n thread.group.private = True\n thread.save()\n message = thread.first_message\n user = self.create_user()\n self.assertFalse(message.visible_to_user(user))",
"def test_group_is_not_priva... | [
"0.7350292",
"0.71163964",
"0.69002235",
"0.6769692",
"0.67451155",
"0.67451155",
"0.65284836",
"0.641624",
"0.64148176",
"0.6391246",
"0.63718134",
"0.6197057",
"0.61930597",
"0.61930597",
"0.6173417",
"0.5985812",
"0.58868635",
"0.5883751",
"0.5839615",
"0.58290815",
"0.582... | 0.81521964 | 0 |
Unicode conversion should be Thread and the id of the thread. | def test_unicode(self):
thread = mommy.prepare('connectmessages.Thread')
self.assertEqual(str(thread), "Thread %s" % thread.subject) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _message(message):\n str_thread = \"Thread-%d\" % threading.current_thread().ident\n return \"%s\\t%s\" % (str_thread, message)",
"def get_thread_for_message(id):\n query = 'SELECT thread_id from messages WHERE id like %s'\n return __perform__(query, (id,), method='fetchone')",
"def nam... | [
"0.574927",
"0.55953854",
"0.5547739",
"0.540877",
"0.53879094",
"0.53443795",
"0.5309525",
"0.5309007",
"0.52884513",
"0.522172",
"0.5162996",
"0.51571083",
"0.5149478",
"0.50807196",
"0.50740856",
"0.50612175",
"0.50053614",
"0.49779415",
"0.49702278",
"0.4961908",
"0.49491... | 0.6257277 | 0 |
Test that add_user_to_thread adds the user to the thread. | def test_add_user_to_thread(self):
thread = self.create_thread()
user = self.create_user()
thread.add_user_to_thread(user)
self.assertTrue(
UserThread.objects.filter(thread=thread, user=user).exists()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_user(self):\n pass",
"def test_000_add_user(self):\n # This case is always passed because it's tested in setup_module,\n # If setup module fails, this case will never run\n pass",
"def test_add_user_to_g(self):\r\n\r\n with app.test_request_context():\r\n ... | [
"0.6989746",
"0.6976448",
"0.6827065",
"0.6642321",
"0.66184783",
"0.6556208",
"0.65251815",
"0.6493912",
"0.64689267",
"0.6416938",
"0.6415342",
"0.6378602",
"0.6316247",
"0.6300136",
"0.6296295",
"0.6258321",
"0.6252896",
"0.6245054",
"0.62335354",
"0.6224861",
"0.621713",
... | 0.87322974 | 0 |
Test the get_unsubscribe_url method on the Thread model | def test_get_unsubscribe_url(self):
thread = self.create_thread()
self.assertEqual(
thread.get_unsubscribe_url(),
reverse('thread_unsubscribe', args=[thread.pk])
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unsubscribe_offer(self):\n pass",
"def test_unsubscribe_instructions(self):\n w = watch(save=True)\n template = Template('{% load unsubscribe_instructions %}'\n '{% unsubscribe_instructions watch %}')\n assert w.unsubscribe_url() in template.render(... | [
"0.68589175",
"0.65258676",
"0.6421368",
"0.6250912",
"0.6187368",
"0.61084896",
"0.60762846",
"0.59866345",
"0.5964308",
"0.5964308",
"0.5964308",
"0.5964308",
"0.5964308",
"0.58424234",
"0.5829391",
"0.5737724",
"0.56729025",
"0.56703115",
"0.5631016",
"0.5584726",
"0.55773... | 0.86771256 | 0 |
Test the thread serialization method for a group message | def test_group_serializable(self):
sender = self.create_user()
thread = self.create_thread(sender=sender)
message = thread.first_message
chicago = pytz.timezone('US/Central')
self.assertDictEqual(
thread.serializable(),
{
'id': thread.pk,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_by_group(self):\n thread = self.create_thread()\n result = Thread.public.by_group(thread.group)\n self.assertIn(thread, result)",
"def test_message_group():",
"def test_by_group_no_messages_for_another_group(self):\n thread = self.create_thread()\n other_group = momm... | [
"0.7138616",
"0.68544483",
"0.6407524",
"0.60807014",
"0.59584236",
"0.5934683",
"0.59050465",
"0.5866536",
"0.5790606",
"0.5783281",
"0.57643366",
"0.5758837",
"0.575138",
"0.57375497",
"0.5714414",
"0.5709247",
"0.5693564",
"0.56797636",
"0.5667377",
"0.5659766",
"0.5643305... | 0.83558667 | 0 |
Test the thread serialization method for a direct message | def test_direct_serializable(self):
sender = self.create_user()
recipient = self.create_user()
thread = self.create_thread(
direct=True, sender=sender, recipient=recipient)
message = thread.first_message
chicago = pytz.timezone('US/Central')
self.assertDictIt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_group_serializable(self):\n sender = self.create_user()\n thread = self.create_thread(sender=sender)\n\n message = thread.first_message\n chicago = pytz.timezone('US/Central')\n self.assertDictEqual(\n thread.serializable(),\n {\n 'id... | [
"0.6736856",
"0.6565212",
"0.6389094",
"0.6067452",
"0.59237",
"0.59232396",
"0.5897293",
"0.58617157",
"0.5835917",
"0.5829798",
"0.581644",
"0.5813901",
"0.57823455",
"0.5698229",
"0.5652477",
"0.5639574",
"0.56386197",
"0.5611939",
"0.56023556",
"0.5602286",
"0.559223",
... | 0.7277333 | 0 |
Test the thread serialization method for a system message | def test_systemthread(self):
# The sqlite test runner doesn't run south migrations, so create the
# user here if it doesn't exist
USER_MODEL.objects.get_or_create(
email='systemuser-email@connect.local', defaults={
'username': 'systemuser-email@connect.local',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_serizable_pending(self):\n thread = self.create_thread()\n message = thread.first_message\n\n # Confirm that an 'approved' message is not marked as pending\n self.assertEqual(message.status, 'approved')\n self.assertEqual(message.serializable()['pending'], False)\n\n ... | [
"0.6434637",
"0.6173871",
"0.6111324",
"0.5842612",
"0.5688491",
"0.56690705",
"0.56630594",
"0.56427824",
"0.56289923",
"0.5622637",
"0.5582339",
"0.5469379",
"0.54564416",
"0.5451162",
"0.54270333",
"0.54246694",
"0.5397297",
"0.5397117",
"0.5388497",
"0.537178",
"0.5346730... | 0.6503251 | 0 |
last_read_at should be correctly set. | def test_last_read_at(self):
recipient = self.create_user()
thread = self.create_thread(recipient=recipient)
last_read_at = datetime.datetime(
2014, 3, 17, 19, 42, 37, tzinfo=pytz.timezone('UTC'))
UserThread.objects.filter(
thread=thread, user=recipient).update(la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_recent_read(self):\n self.read_pos = (self.write_pos - 1) % self.log_len\n return",
"def user_last_read_at(self, user):\n user_history = [history_entry for history_entry in self.history if history_entry.user_id == user.id]\n for history_entry in user_history[::-1]:\n if hi... | [
"0.6873836",
"0.6694714",
"0.6255438",
"0.61606884",
"0.59546685",
"0.587834",
"0.5809306",
"0.57667905",
"0.57489073",
"0.5747681",
"0.5714767",
"0.5708482",
"0.5701233",
"0.5660985",
"0.56564283",
"0.56515074",
"0.56465214",
"0.56354296",
"0.5595138",
"0.55945647",
"0.55945... | 0.7515852 | 0 |
If thread has never been opened, count should equal all messages. | def test_unread_message_count_thread_never_opened(self):
recipient = self.create_user()
thread = self.create_thread(recipient=recipient)
mommy.make(Message, thread=thread, sender=self.create_superuser())
result = Thread.public.by_user(
user=recipient,
queryset=Thr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_updates_count(self):\n user = self.create_user()\n thread = self.create_thread(sender=user)\n\n original_count = thread.message_set.count()\n\n for _ in range(0, 5):\n msg = mommy.make(Message, thread=thread, sender=user)\n\n send_message(msg.pk)\n\n # ... | [
"0.71282417",
"0.70151204",
"0.6613124",
"0.65066713",
"0.64776295",
"0.63470167",
"0.6331499",
"0.62142336",
"0.6201822",
"0.61542934",
"0.6137622",
"0.60989445",
"0.60931534",
"0.59873754",
"0.5986775",
"0.59160554",
"0.58659446",
"0.578231",
"0.57664657",
"0.574872",
"0.57... | 0.7718441 | 0 |
get_absolute_url should resolve to threads. | def test_get_absolute_url_resolves_to_threads(self):
thread = self.create_thread()
self.assertEqual(
thread.first_message.get_absolute_url(),
'/messages/id/{pk}/'.format(
pk=thread.pk)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_url(self, absolute):",
"def test_absolute_url_without_request(self):\n context = {}\n\n abs_url = absolute_url(context, \"/ciao/\")\n self.assertEqual(abs_url, \"/ciao/\")\n self.assertNotEqual(abs_url, \"/\")",
"def test_absolute_url(self):\n request_factory = Reque... | [
"0.7434127",
"0.6483516",
"0.6470996",
"0.6316233",
"0.61736745",
"0.61452794",
"0.60758823",
"0.6052836",
"0.6038118",
"0.6005984",
"0.599838",
"0.59757507",
"0.59117925",
"0.5911636",
"0.5900336",
"0.5860799",
"0.58133537",
"0.5794021",
"0.57889223",
"0.57764155",
"0.577446... | 0.71894276 | 1 |
Test the 'pending' logic in message.serlizable | def test_serizable_pending(self):
thread = self.create_thread()
message = thread.first_message
# Confirm that an 'approved' message is not marked as pending
self.assertEqual(message.status, 'approved')
self.assertEqual(message.serializable()['pending'], False)
message.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_pending(self):\n return self._state == \"PENDING\"",
"def is_pending(self):\n return self.type_id == STATE_PENDING",
"def test_pending_job(self):\n\n pending_job = json.loads(TREEHERDER_JOB % (\"unknown\", \"pending\"))\n self.assertEquals(self.query_api.get_job_status(pendin... | [
"0.6372351",
"0.62647235",
"0.6139965",
"0.6124568",
"0.60648656",
"0.60331225",
"0.60225314",
"0.59459144",
"0.5935882",
"0.5892693",
"0.58836454",
"0.5844578",
"0.5798705",
"0.57381856",
"0.5694799",
"0.56841844",
"0.567766",
"0.567352",
"0.5665033",
"0.5630166",
"0.5629019... | 0.80438584 | 0 |
Test that save calls _text_cleaner(). | def test_save_calls_text_cleaner(self):
thread = self.create_thread()
with patch.object(Message, '_text_cleaner') as mock:
mock.return_value = ''
self.assertEqual(mock.call_count, 0)
thread.first_message.save()
self.assertEqual(mock.call_count, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_save(self):",
"def test_save(self):",
"def test_save(self):\n my_model = BaseModel()\n my_model.save()\n self.assertEqual(\"\", \"\")",
"def test_prep_textarea(self):\n pass",
"def test_text(self):\n conn = self.database.connection()\n cursor = conn.cursor... | [
"0.6745654",
"0.6745654",
"0.6584427",
"0.6210587",
"0.61745423",
"0.6054622",
"0.60172105",
"0.5977917",
"0.59758925",
"0.5954136",
"0.58710635",
"0.5822162",
"0.5794779",
"0.57715863",
"0.5727038",
"0.5707453",
"0.5703863",
"0.57035154",
"0.5699245",
"0.5698266",
"0.5697948... | 0.7306864 | 0 |
Long Snippet should return first 140 characters of clean_text. | def test_long_snippet(self):
message = Message(clean_text=''.join('x' for _ in range(0, 200)))
self.assertEqual(
message.long_snippet,
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restrict_text(text):\n\n if len(text) > 400:\n\n return text[:400] + ' ...'\n \n return text",
"def large_text(self):\n pass",
"def remove_longer_words(text):\n return \" \".join([word for word in str(text).split() if len(word) <= 12])",
"def shortened_text(self, max_chars=50):\n ... | [
"0.69354486",
"0.6655568",
"0.66494787",
"0.66479874",
"0.65911067",
"0.6513178",
"0.64595217",
"0.6391068",
"0.6375443",
"0.6368668",
"0.63420016",
"0.63188475",
"0.63168997",
"0.631659",
"0.631659",
"0.6314225",
"0.63132846",
"0.62862605",
"0.6214133",
"0.6177138",
"0.60851... | 0.70666116 | 0 |
Test a long snippet that starts and ends with a nonletter | def test_snippet_beginning_nonletter(self):
message = Message(clean_text=u"!I already know what this will be!!!!!")
self.assertEqual(
message.snippet,
'I already know what...'
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_starts_letter(x):\n return x[0].isalpha()",
"def test_snippet_long_strip_end(self):\n # Without stripping the non-character end this would end with ' --'\n message = Message(clean_text=u\"This was a longer — sentence\")\n self.assertEqual(\n message.snippet,\n ... | [
"0.6380416",
"0.63329107",
"0.6325398",
"0.6297113",
"0.6168859",
"0.6164372",
"0.6160874",
"0.615705",
"0.611136",
"0.6020209",
"0.5970481",
"0.59596306",
"0.59292907",
"0.5922458",
"0.5919931",
"0.5874969",
"0.58698356",
"0.5867936",
"0.58590317",
"0.5843205",
"0.5834966",
... | 0.7553941 | 0 |
Links in a message should be replaced with short code. | def test_links_in_message_are_shortened(self):
sender = self.create_user()
group = self.create_group()
sender.add_to_group(group.pk)
thread = mommy.make(Thread, group=group)
message = Message(
text='This is a <a href="http://www.razzmatazz.local">link</a>',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_links_in_message_are_not_shortened(self):\n sender = self.create_user()\n group = self.create_group()\n sender.add_to_group(group.pk)\n\n thread = mommy.make(Thread, group=group)\n message = Message(\n text='This is a <a href=\"http://www.razzmatazz.local\">li... | [
"0.6935562",
"0.6908946",
"0.6322348",
"0.6177332",
"0.6099006",
"0.6054597",
"0.59039",
"0.5842906",
"0.5831297",
"0.57930523",
"0.5790011",
"0.5773118",
"0.576683",
"0.57603997",
"0.57326275",
"0.5667401",
"0.56313837",
"0.5617337",
"0.56105644",
"0.55780095",
"0.5574015",
... | 0.76363665 | 0 |
If shorten=False, links in message should not be replaced. | def test_links_in_message_are_not_shortened(self):
sender = self.create_user()
group = self.create_group()
sender.add_to_group(group.pk)
thread = mommy.make(Thread, group=group)
message = Message(
text='This is a <a href="http://www.razzmatazz.local">link</a>',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_links_in_message_are_shortened(self):\n sender = self.create_user()\n group = self.create_group()\n sender.add_to_group(group.pk)\n\n thread = mommy.make(Thread, group=group)\n message = Message(\n text='This is a <a href=\"http://www.razzmatazz.local\">link</... | [
"0.75680864",
"0.6855851",
"0.64101446",
"0.63234353",
"0.62372416",
"0.6207822",
"0.61743677",
"0.61155254",
"0.590837",
"0.58996063",
"0.5893649",
"0.5893421",
"0.58750963",
"0.58171886",
"0.580634",
"0.5802176",
"0.57176405",
"0.57138366",
"0.56975865",
"0.5682399",
"0.567... | 0.79565454 | 0 |
Test that a system message is always approved | def test_system_message_approved(self):
system_user, _ = USER_MODEL.objects.get_or_create(
email='systemuser-email@connect.local', defaults={
'username': 'systemuser-email@connect.local',
'is_active': True,
'is_superuser': True
}
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_approve_agreement(self):\n pass",
"def test_user_is_sender_message_is_moderated(self):\n thread = self.create_thread()\n message = thread.first_message\n message.status = 'pending'\n message.save()\n self.assertTrue(message.visible_to_user(message.sender))",
"... | [
"0.676863",
"0.6697957",
"0.6631607",
"0.6546722",
"0.65212",
"0.6509324",
"0.6415082",
"0.6308714",
"0.61621153",
"0.61503994",
"0.61399895",
"0.611757",
"0.61099625",
"0.60696214",
"0.6045466",
"0.602699",
"0.6001933",
"0.59739643",
"0.5964977",
"0.5956104",
"0.5954929",
... | 0.80389374 | 0 |
User should be able to send up to 10 dms before they're pending. | def test_user_can_send_up_to_10_dms(self):
user = self.create_user()
threads = [
self.create_thread(direct=True, sender=user) for _ in range(0, 10)
]
for thread in threads:
self.assertEqual(
thread.first_message.get_initial_status(), 'approved')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reqDeleteAllSent(self):\n while self.status != Modem.Status.IDLE :\n sleep(0.1)\n if self.status != Modem.Status.IDLE:\n raise ValueError(\"Modem deleteAllSent unexpected status: \\\n \" + str(self.status))\n self.status = Modem.Status.BUSY2REQ\n ... | [
"0.632554",
"0.6093344",
"0.59400517",
"0.58852494",
"0.5781926",
"0.57486963",
"0.5725223",
"0.56994617",
"0.56100035",
"0.55830157",
"0.55830157",
"0.55828273",
"0.5565297",
"0.5538157",
"0.55240124",
"0.5522235",
"0.5520115",
"0.5512973",
"0.5507029",
"0.550684",
"0.550650... | 0.7061432 | 0 |
Deleted messages shouldn't be in regular queries. | def test_no_deleted_messages_in_query(self):
thread = self.create_thread()
thread.first_message.delete()
self.assertNotIn(thread.first_message, Message.objects.all()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deleted_messages_in_with_deleted_query(self):\n thread = self.create_thread()\n thread.first_message.delete()\n self.assertTrue(\n Message.objects.with_deleted().filter(\n pk=thread.first_message.pk).exists()\n )",
"def test_delete_message_is_only_me... | [
"0.759864",
"0.71808547",
"0.7013452",
"0.69090825",
"0.6863588",
"0.6863588",
"0.66033405",
"0.65162724",
"0.64656407",
"0.64614314",
"0.6426754",
"0.64262813",
"0.64155954",
"0.6411067",
"0.6402533",
"0.6395916",
"0.6367762",
"0.6352162",
"0.63197875",
"0.63063717",
"0.6287... | 0.769576 | 0 |
Deleted messages should show in with_deleted queries. | def test_deleted_messages_in_with_deleted_query(self):
thread = self.create_thread()
thread.first_message.delete()
self.assertTrue(
Message.objects.with_deleted().filter(
pk=thread.first_message.pk).exists()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_deleted_messages_in_query(self):\n thread = self.create_thread()\n thread.first_message.delete()\n self.assertNotIn(thread.first_message, Message.objects.all())",
"def deleted_messages(self):\n return self._get_messages_from_folder_name('DeletedItems')",
"def get_and_del... | [
"0.6969116",
"0.6873903",
"0.6683903",
"0.6683903",
"0.6500579",
"0.6500142",
"0.6447542",
"0.64318514",
"0.6393938",
"0.6359562",
"0.61886126",
"0.61555475",
"0.6116245",
"0.6095014",
"0.60757685",
"0.60741",
"0.60475",
"0.60475",
"0.6029695",
"0.6024714",
"0.6014551",
"0.... | 0.73684263 | 0 |
Delete should mark a message as deleted and update the thread. | def test_delete(self):
# Create a thread with two messages
thread = self.create_thread()
message = mommy.make(
Message, thread=thread, sender=thread.first_message.sender)
# Delete the second message
message = Message.objects.get(pk=message.pk)
message.delete(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_message_is_only_message_in_thread(self):\n thread = self.create_thread()\n thread.first_message.delete()\n thread = Thread.objects.with_deleted().get(pk=thread.pk)\n self.assertEqual(thread.status, 'deleted')\n self.assertEqual(thread.total_messages, 0)",
"def m... | [
"0.73999614",
"0.72074354",
"0.7093292",
"0.6920951",
"0.6876318",
"0.6835837",
"0.67271906",
"0.6719602",
"0.66689074",
"0.66421676",
"0.66402787",
"0.66284823",
"0.65916914",
"0.64925086",
"0.6401275",
"0.63883716",
"0.63647246",
"0.63568014",
"0.6341362",
"0.63029504",
"0.... | 0.7308605 | 1 |
Delete should update thread.first_message if message was first. | def test_delete_message_is_first_message(self):
# Create a thread with two messages
thread = self.create_thread()
message = mommy.make(
Message, thread=thread, sender=thread.first_message.sender)
# Delete the first message
thread = Thread.objects.get(pk=thread.pk)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_message_is_only_message_in_thread(self):\n thread = self.create_thread()\n thread.first_message.delete()\n thread = Thread.objects.with_deleted().get(pk=thread.pk)\n self.assertEqual(thread.status, 'deleted')\n self.assertEqual(thread.total_messages, 0)",
"def t... | [
"0.77040243",
"0.74047863",
"0.7352191",
"0.7083618",
"0.69684875",
"0.6819017",
"0.6805997",
"0.6620136",
"0.6524674",
"0.6511253",
"0.6486759",
"0.63122684",
"0.62957245",
"0.6266415",
"0.6204599",
"0.6131014",
"0.59867156",
"0.59867114",
"0.5941533",
"0.5940535",
"0.592787... | 0.8024317 | 0 |
Delete should update thread.latest_message if message was last. | def test_delete_message_is_latest_message(self):
# Create a thread with two messages
thread = self.create_thread()
message = mommy.make(
Message, thread=thread, sender=thread.first_message.sender)
# Delete the second message
message = Message.objects.get(pk=message.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_message_is_only_message_in_thread(self):\n thread = self.create_thread()\n thread.first_message.delete()\n thread = Thread.objects.with_deleted().get(pk=thread.pk)\n self.assertEqual(thread.status, 'deleted')\n self.assertEqual(thread.total_messages, 0)",
"def m... | [
"0.7418712",
"0.69314414",
"0.69275993",
"0.68456906",
"0.6706883",
"0.66970724",
"0.66732866",
"0.6595048",
"0.6584641",
"0.6532373",
"0.6488005",
"0.64572746",
"0.6440587",
"0.64126706",
"0.6349081",
"0.6259868",
"0.61821944",
"0.6167975",
"0.6141869",
"0.61404705",
"0.6114... | 0.76555693 | 0 |
Delete should mark a thread as deleted if it was the only message. | def test_delete_message_is_only_message_in_thread(self):
thread = self.create_thread()
thread.first_message.delete()
thread = Thread.objects.with_deleted().get(pk=thread.pk)
self.assertEqual(thread.status, 'deleted')
self.assertEqual(thread.total_messages, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete(self):\n thread = self.create_thread()\n ut = UserThread.objects.get(\n user=thread.recipients.first(), thread=thread)\n ut_id = ut.pk\n ut.delete()\n ut = UserThread.objects.with_deleted().get(pk=ut_id)\n self.assertEqual(ut.status, 'deleted')",... | [
"0.7385993",
"0.7262827",
"0.71498173",
"0.7050442",
"0.7004085",
"0.6997988",
"0.68550617",
"0.6741975",
"0.6699504",
"0.65397376",
"0.6536764",
"0.6532259",
"0.65071875",
"0.6442428",
"0.6327387",
"0.6324189",
"0.63045543",
"0.62430805",
"0.6239857",
"0.61936426",
"0.617815... | 0.78119045 | 0 |
Flagging a message 1 time should mark it as pending. | def test_flag(self):
recipient = self.create_user()
thread = self.create_thread(recipient=recipient)
message = thread.first_message
self.assertEqual(message.status, 'approved')
message.flag(recipient)
self.assertEqual(message.flags.count(), 1)
self.assertEqual(mes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pending(self):\n self.update({self.STATE: self.STATE_PENDING})",
"def is_pending(self):\n return self.type_id == STATE_PENDING",
"def flag(self, reason):\r\n self._flagged = True\r\n self._flagged_reason = reason",
"def pending(self):\n return self._state == PENDING_STA... | [
"0.66700035",
"0.6593479",
"0.65212846",
"0.6459061",
"0.64402586",
"0.64309347",
"0.63792014",
"0.6327654",
"0.62103397",
"0.62025124",
"0.6040014",
"0.5975719",
"0.59606373",
"0.5879657",
"0.5745022",
"0.5701007",
"0.5685793",
"0.5583492",
"0.5519484",
"0.5516737",
"0.53959... | 0.69398886 | 0 |
New message should not be marked as read. | def test_get_message_new(self):
message = mommy.make(
'connectmessages.Message', thread=self.thread, sender=self.sender)
thread = Thread.public.by_user(user=self.user)[0]
messages = thread.messages_for_user(self.user)
self.assertEqual(messages[0], message)
self.assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_message(self, room, mess):\n pass",
"def on_message(self, _, message):\n with self.message_lock:\n self.messages.append(Message.deserialize(message))\n self.new_message_available.set()\n super().on_message(_, message)",
"def receive_message(self, message):\r\n ... | [
"0.6371228",
"0.6363502",
"0.6120947",
"0.6036845",
"0.60229075",
"0.5994648",
"0.59878844",
"0.5986485",
"0.59847265",
"0.5955506",
"0.5932633",
"0.5901218",
"0.58805376",
"0.5863533",
"0.58497316",
"0.5801083",
"0.57967633",
"0.5787752",
"0.57854736",
"0.5781837",
"0.575416... | 0.6441192 | 0 |
A message that has been read should show up as read. | def test_get_message_read(self):
message = mommy.make(
'connectmessages.Message', thread=self.thread, sender=self.sender)
user_thread = UserThread.objects.get(
thread=self.thread, user=self.user)
user_thread.read = True
user_thread.save()
thread = Thread.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def messageWasRead(self, uid, msg):\n if msg.startswith(\"_\"):\n return os.path.exists(os.path.join(self.userMessageBox(uid), msg))\n else:\n return os.path.exists(os.path.join(self.userMessageBox(uid), \"_\" + msg))",
"def read(self):\n if self.status == 'read':\n ... | [
"0.67798173",
"0.66625464",
"0.6581845",
"0.63872105",
"0.63336",
"0.62645847",
"0.6256008",
"0.6255995",
"0.6241815",
"0.619805",
"0.61792505",
"0.614484",
"0.6102536",
"0.60915554",
"0.60557646",
"0.60486007",
"0.60090387",
"0.60069823",
"0.5970234",
"0.59652716",
"0.596336... | 0.7231654 | 0 |
New replies should have just the read messages marked read. | def test_get_message_reply(self):
message1 = mommy.make(
'connectmessages.Message', thread=self.thread, sender=self.sender)
message1.created_at = now() - datetime.timedelta(days=1)
message1.save()
message2 = mommy.make(
'connectmessages.Message', thread=self.threa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_replies(self, new=True):\n url = (\"https://api.imgur.com/3/account/{0}/\"\n \"notifications/replies\".format(self.name))\n return self._imgur._send_request(url, needs_auth=True)",
"def replies(self):\r\n return Replies(self)",
"def read(self, request, *args, **kwargs... | [
"0.65243465",
"0.6419802",
"0.6354777",
"0.6310853",
"0.6183889",
"0.61582726",
"0.61396503",
"0.61124665",
"0.6037831",
"0.60188556",
"0.5922329",
"0.59085685",
"0.5888812",
"0.57145464",
"0.5619408",
"0.5553457",
"0.5501735",
"0.54985017",
"0.5494519",
"0.54899216",
"0.5471... | 0.6433588 | 1 |
User should see approved messages in groups they belong to. | def test_user_is_group_member_status_is_approved(self):
group = mommy.make('groups.Group', moderated=True)
thread = self.create_thread(group=group)
message = thread.first_message
message.status = 'approved'
message.save()
user = self.create_user()
user.add_to_grou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def approve_me_group(message):\n users = hf.get_users()\n sender_id = message._get_user_id()\n\n for user in users:\n if user[\"id\"] == sender_id:\n if (user[\"approval_level\"] == \"unapproved\"):\n message.reply(Strings['APPROVE_ME_REQUEST'])\n else:\n ... | [
"0.73008215",
"0.6954758",
"0.692266",
"0.67957747",
"0.66019076",
"0.6510278",
"0.6432128",
"0.6405132",
"0.6372605",
"0.61512905",
"0.5965712",
"0.5959798",
"0.594747",
"0.5909009",
"0.587584",
"0.58452874",
"0.580294",
"0.57995427",
"0.5781279",
"0.5751287",
"0.57436013",
... | 0.74156636 | 0 |
Nonmembers should not see messages in private groups. | def test_group_is_private_user_is_not_member(self):
thread = self.create_thread()
thread.group.private = True
thread.save()
message = thread.first_message
user = self.create_user()
self.assertFalse(message.visible_to_user(user)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_group_is_not_private_user_is_not_member(self):\n thread = self.create_thread()\n user = self.create_user()\n self.assertTrue(thread.first_message.visible_to_user(user))",
"def test_group_is_private(self):\n group = mommy.make('groups.Group', private=True)\n thread = se... | [
"0.81302375",
"0.72381955",
"0.70782816",
"0.69088227",
"0.6846511",
"0.66533005",
"0.66348624",
"0.66294575",
"0.6608485",
"0.65110636",
"0.6486002",
"0.64359605",
"0.63716865",
"0.636338",
"0.63480633",
"0.6303773",
"0.62828404",
"0.62729204",
"0.6252432",
"0.6213427",
"0.6... | 0.8040601 | 1 |
Test replies sent by banned users are visible only to that user | def test_reply_from_banned_user(self):
# Create 2 users. By default neither is banned, but one will be soon
viewing_user = self.create_user()
banned_user = self.create_user()
# Create a new group and add both our users to it
group = self.create_group()
viewing_user.add_t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_listing_from_wall_when_blocked_some_users(self):",
"def anti_bot(self, message):\n msg_list = self.ts.get_human_readable_message(message).lower().split(' ')\n bot_creation_date = self._get_creation_date(msg_list[1])\n viewers = self.ts.fetch_chatters_from_API()['viewers']\n m... | [
"0.6826658",
"0.63423294",
"0.6313625",
"0.6220517",
"0.6145548",
"0.61343503",
"0.6127449",
"0.6117914",
"0.6036089",
"0.60189503",
"0.6016538",
"0.6009759",
"0.5996712",
"0.5981993",
"0.5976962",
"0.5976602",
"0.59606665",
"0.59525794",
"0.59319",
"0.58801866",
"0.587699",
... | 0.7557479 | 0 |
Group moderators should see any message sent to their group. | def test_user_is_group_moderator(self):
thread = self.create_thread()
user = self.create_user()
thread.group.owners.add(user)
message = thread.first_message
message.status = 'pending'
message.save()
self.assertTrue(message.visible_to_user(user)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def force_accept(self, group):\n self.mod_queue.force_accept(group)\n \n # sponsors become members\n if group.is_accepted():\n self._sponsors_to_members(group)",
"def test_user_is_global_moderator(self):\n thread = self.create_thread()\n user = self.create_use... | [
"0.67371017",
"0.659836",
"0.6573264",
"0.62062967",
"0.61604667",
"0.6114239",
"0.6044625",
"0.603403",
"0.60262585",
"0.5999332",
"0.5991786",
"0.5987665",
"0.59725595",
"0.58769906",
"0.58552104",
"0.5815689",
"0.58130234",
"0.58006585",
"0.57972693",
"0.5795424",
"0.57637... | 0.7330485 | 0 |
The sender of a message should be able to see their own message. | def test_user_is_sender_message_is_moderated(self):
thread = self.create_thread()
message = thread.first_message
message.status = 'pending'
message.save()
self.assertTrue(message.visible_to_user(message.sender)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_is_sender(self):\n sender = self.create_user()\n thread = self.create_thread(sender=sender, status='pending')\n self.assertTrue(thread.first_message.visible_to_user(sender))",
"def publish_message(self, sender, msg: str) -> None:\n for member in self._all_members.values(... | [
"0.7175853",
"0.70278096",
"0.68316144",
"0.66396797",
"0.66046506",
"0.65300834",
"0.6482184",
"0.647706",
"0.6476938",
"0.6476687",
"0.64534324",
"0.64304334",
"0.6418058",
"0.6416962",
"0.63630354",
"0.63623315",
"0.6309421",
"0.62881213",
"0.6282054",
"0.62462664",
"0.623... | 0.7280812 | 0 |
Vetoed messages should not be visible to anyone. | def test_message_is_vetoed(self):
thread = self.create_thread()
message = thread.first_message
message.status = 'vetoed'
message.save()
self.assertFalse(message.visible_to_user(message.sender)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CanVeto(self):\r\n\r\n return self.canveto_flag and self.veto_flag",
"def Veto(self):\r\n\r\n self.notify.Veto()",
"def Veto(self):\r\n\r\n self.notify.Veto()",
"def Veto(self):\r\n\r\n self.notify.Veto()",
"def Veto(self, veto=True):\r\n\r\n self.veto_flag = veto",
... | [
"0.64388263",
"0.6208927",
"0.6208927",
"0.6208927",
"0.6036866",
"0.5830424",
"0.57264316",
"0.55637175",
"0.5543263",
"0.5528869",
"0.5527399",
"0.5524669",
"0.5516222",
"0.54817194",
"0.54788095",
"0.5472597",
"0.5463427",
"0.5456774",
"0.53895456",
"0.53296214",
"0.531691... | 0.634853 | 1 |
Return thread if user is a recipient. | def test_user_is_recipient(self):
UserThread.objects.create(user=self.user, thread=self.thread)
self.assertEqual(
Thread.public.get_by_user(
thread_id=self.thread.pk, user=self.user),
self.thread
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_user_is_recipient(self):\n recipient = self.create_user()\n thread = self.create_thread(recipient=recipient)\n self.assertTrue(thread.first_message.visible_to_user(recipient))",
"def test_user_is_sender(self):\n sender = self.create_user()\n thread = self.create_thread... | [
"0.75965565",
"0.67605346",
"0.63787115",
"0.63627005",
"0.6216186",
"0.6161424",
"0.60673016",
"0.6064786",
"0.59087336",
"0.5839849",
"0.5759381",
"0.568783",
"0.5608954",
"0.55944204",
"0.55939007",
"0.55842644",
"0.5551689",
"0.55199635",
"0.5511284",
"0.5464091",
"0.5454... | 0.7548641 | 1 |
Return thread if user is a group member. | def test_user_is_group_member(self):
self.user.add_to_group(self.thread.group.pk)
self.assertEqual(
Thread.public.get_by_user(
thread_id=self.thread.pk, user=self.user),
self.thread
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_by_user_user_is_in_group(self):\n recipient = self.create_user()\n thread = self.create_thread(recipient=recipient)\n result = Thread.public.by_user(user=recipient)\n self.assertIn(thread, result)",
"def _is_member(groupid):\n timer = Timer()\n try:\n return GWS(... | [
"0.70507634",
"0.6622762",
"0.6547816",
"0.6482142",
"0.6436479",
"0.63451505",
"0.62734544",
"0.6237853",
"0.6192928",
"0.6169322",
"0.61547935",
"0.6143264",
"0.61344093",
"0.61171806",
"0.6104622",
"0.6059706",
"0.60596323",
"0.5992399",
"0.59867233",
"0.5975848",
"0.59716... | 0.7161954 | 0 |
Return thread if user is a group owner. | def test_user_is_group_owner(self):
self.thread.group.owners.add(self.user)
self.assertEqual(
Thread.public.get_by_user(
thread_id=self.thread.pk, user=self.user),
self.thread
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_by_user_user_is_in_group(self):\n recipient = self.create_user()\n thread = self.create_thread(recipient=recipient)\n result = Thread.public.by_user(user=recipient)\n self.assertIn(thread, result)",
"def _is_in_group(user, group_name):\n try:\n return Group.objects.... | [
"0.67267644",
"0.6305702",
"0.627542",
"0.6186394",
"0.615163",
"0.61328244",
"0.6078353",
"0.5948349",
"0.58880657",
"0.5817774",
"0.5807015",
"0.5790116",
"0.5772595",
"0.5754549",
"0.5743287",
"0.5733182",
"0.5724098",
"0.57229835",
"0.5717539",
"0.57133573",
"0.5709131",
... | 0.7242252 | 0 |
Raise ObjectDoesNotExist if user doesn't have access. | def test_user_does_not_have_access(self):
self.assertRaises(
ObjectDoesNotExist,
Thread.public.get_by_user,
**{'thread_id': self.thread.pk, 'user': self.user}
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, user):\n return user == request.user or request.user.is_superuser",
"def test_not_logged_user_cannot_access(self):\n\n utils.test_not_logged_cannot_access(self, self.url)",
"def test_not_logged_user_cannot_access(self):\n\n utils.test_not_logg... | [
"0.64512146",
"0.63119334",
"0.63119334",
"0.63119334",
"0.63119334",
"0.6311788",
"0.62217945",
"0.61707735",
"0.6165318",
"0.6149082",
"0.6141078",
"0.6141058",
"0.6130155",
"0.6103009",
"0.60953027",
"0.6091384",
"0.6080652",
"0.6068873",
"0.6054344",
"0.6051795",
"0.60517... | 0.69305414 | 0 |
Should mark UT as archived. | def test_archive(self):
thread = self.create_thread()
ut = UserThread.objects.get(
user=thread.recipients.first(), thread=thread)
ut_id = ut.pk
ut.archive()
ut = UserThread.objects.get(pk=ut_id)
self.assertEqual(ut.status, 'archived') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_archive_run(self):\n pass",
"def test_unarchive_run(self):\n pass",
"def test_dont_archive_commitlog(self):\n self.run_archive_commitlog(restore_point_in_time=False, restore_archived_commitlog=False)",
"def _archive(self):\n # LOG: change this to something archive specifi... | [
"0.6898809",
"0.6863063",
"0.6369043",
"0.6282837",
"0.6244616",
"0.6176379",
"0.61361325",
"0.5939891",
"0.59228593",
"0.59153026",
"0.5751973",
"0.5703985",
"0.56871235",
"0.5685521",
"0.56480116",
"0.5634897",
"0.5618022",
"0.5608015",
"0.5602448",
"0.5592372",
"0.5483934"... | 0.7368199 | 0 |
Show updatefeedback form and process it. | def update_feedback(feedback_id):
feedback = Feedback.query.get(feedback_id)
if 'username' not in session or feedback.username != session['username']:
flash('Please login first!')
return redirect('/login')
form = FeedbackForm(obj=feedback)
if form.validate_on_submit():
feedba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_feedback(feedback_id: int):\n\n feedback = Feedback.query.get_or_404(feedback_id)\n\n if \"username\" not in session or session[\"username\"] != feedback.from_username:\n raise Unauthorized()\n\n form = FeedbackForm(obj=feedback)\n if form.validate_on_submit():\n feedback.title... | [
"0.66143584",
"0.60384494",
"0.5972837",
"0.59561914",
"0.58804667",
"0.5838432",
"0.58196294",
"0.58097404",
"0.57921964",
"0.57503766",
"0.573909",
"0.5738501",
"0.5720978",
"0.57200134",
"0.569495",
"0.5677665",
"0.5672848",
"0.5663536",
"0.5651938",
"0.56328636",
"0.56177... | 0.6478262 | 1 |
Test the new sneaker creation page. | def test_new(self):
result = self.client.get('/sneakers/new')
self.assertEqual(result.status, '200 OK')
self.assertIn(b'New Sneaker', result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create(self):\n pass",
"def test_create_shelf(self, *_):\n form = forms.ShelfForm()\n form.data[\"user\"] = self.local_user.id\n form.data[\"name\"] = \"new shelf name\"\n form.data[\"description\"] = \"desc\"\n form.data[\"privacy\"] = \"unlisted\"\n req... | [
"0.6698957",
"0.6654224",
"0.657885",
"0.6468629",
"0.6464928",
"0.6462027",
"0.6402381",
"0.6387222",
"0.6387222",
"0.6278436",
"0.62715364",
"0.6262079",
"0.62378675",
"0.62316746",
"0.6199789",
"0.6196729",
"0.6192276",
"0.6192276",
"0.61921525",
"0.61717886",
"0.61551416"... | 0.7892635 | 0 |
Test editing a single sneaker | def test_edit_sneaker(self, mock_find):
mock_find.return_value = sample_sneaker
result = self.client.get(f'/sneakers/{sample_sneaker_id}/edit')
self.assertEqual(result.status, '200 OK')
self.assertIn(b'sneakers', result.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_show_sneaker(self, mock_find):\n mock_find.return_value = sample_sneaker\n\n result = self.client.get(f'/sneakers/{sample_sneaker_id}')\n self.assertEqual(result.status, '200 OK')\n self.assertIn(b'sneakers', result.data)",
"def test_edit_shelf_name(self, *_):\n view =... | [
"0.6761858",
"0.668801",
"0.66555434",
"0.64255506",
"0.61381084",
"0.6120258",
"0.6119082",
"0.6096103",
"0.5955368",
"0.5918134",
"0.5884841",
"0.58441234",
"0.58429253",
"0.5841053",
"0.57969254",
"0.57871133",
"0.57786167",
"0.57699573",
"0.5737636",
"0.57359415",
"0.5721... | 0.8078662 | 0 |
filters a segmented image by getting rid of the components with too few pixels | def filter_by_size(img_segm):
numbers = np.zeros(np.max(img_segm-1))
for i in range(1,np.max(img_segm)):
numbers[i-1] = np.sum(img_segm==i)
indexes = np.arange(1,np.max(img_segm))
#indexes = indexes[numbers>np.mean(numbers)] #Deletes the 1-pixel elements
indexes = indexes[numbe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(img):\n\n label_img = label(img, connectivity=2)\n props = sorted(regionprops(label_img), key=lambda x: x.area)\n clean = morphology.binary_closing(img)\n\n clean = morphology.remove_small_holes(clean)\n return morphology.remove_small_objects(clean,\n ... | [
"0.7125319",
"0.6659455",
"0.6623863",
"0.65784526",
"0.64892656",
"0.6476974",
"0.6443308",
"0.64366084",
"0.6431392",
"0.64009815",
"0.6381148",
"0.6362304",
"0.63297623",
"0.6251212",
"0.6243235",
"0.62267727",
"0.622337",
"0.621946",
"0.6211382",
"0.62091863",
"0.61789745... | 0.7039094 | 1 |
Computes the positions of centroids in a segmented image. Returns the centroids numbers in order | def centroids(img_segm):
m = np.amax(img_segm)
xs = np.zeros(m)
ys = np.zeros(m)
for i in range(0,m):
pos_list = np.where(img_segm==i+1)
xs[i] = np.mean(pos_list[0])
ys[i] = np.mean(pos_list[1])
return xs,ys | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def centroids(img_segm):\n m = int(np.amax(img_segm))\n xs = np.zeros(m)\n ys = np.zeros(m)\n \n for i in range(0,m):\n pos_list = np.where(img_segm==i+1)\n xs[i] = np.mean(pos_list[0])\n ys[i] = np.mean(pos_list[1])\n return xs,ys",
"def centroids(img):\n _, _, _, centr... | [
"0.8074318",
"0.79522794",
"0.75415736",
"0.7367029",
"0.7335259",
"0.72794324",
"0.7116489",
"0.71072453",
"0.7056559",
"0.70126945",
"0.69410944",
"0.69342405",
"0.69011164",
"0.6841275",
"0.68375087",
"0.6791128",
"0.6766953",
"0.6750899",
"0.6718486",
"0.6718486",
"0.6709... | 0.8089151 | 0 |
updates the list of labels based on the correspondance list image is the new image to update | def updateLabels(correspondance_list,labels_list,i,image):
l_prev_index = len(labels_list[(i-1)%2])
l_curr_index = len(labels_list[i%2])
prev_index = labels_list[(i-1)%2]
index_changes = []
ref_image = np.copy(image)
if l_prev_index==l_curr_index: #Same number of cells
for x,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_label_map(path, label_list):\r\n \r\n img = []\r\n for name in path:\r\n now = np.zeros((224,224))\r\n im = cv2.resize(cv2.imread(name), (224,224)).tolist()\r\n for y, i in enumerate(im):\r\n for x, j in enumerate(i):\r\n try:\r\n ... | [
"0.6559158",
"0.6444111",
"0.6378405",
"0.63674814",
"0.62550545",
"0.62397486",
"0.61972344",
"0.61909616",
"0.6172879",
"0.61375517",
"0.61280435",
"0.6098763",
"0.60977834",
"0.60886836",
"0.60382694",
"0.6022372",
"0.60099405",
"0.60021186",
"0.5999822",
"0.599829",
"0.59... | 0.78503317 | 0 |
Computes a cost matrix for the different distances between centroids The rows represent the centroids in the previous frame The columns the centroids in the next frame Returns the cost matrix | def fillCostMatrix(xs0,ys0,xs1,ys1):
M = int ( max(len(xs0),len(xs1)) ) #Number of centroids.
costMatrix = np.zeros((M,M))
x_rows = np.zeros(M)
x_rows[0:len(xs0)] = xs0
y_rows = np.zeros(M)
y_rows[0:len(xs0)] = ys0
x_cols = np.zeros(M)
x_cols[0:len(xs1)] = xs1
y_cols = np.zeros(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fillCostMatrix(xs0,ys0,xs1,ys1):\n M = int ( max(len(xs0),len(xs1)) ) #Number of centroids.\n costMatrix = np.ones((M,M))*-1\n x_rows = np.zeros(M)\n x_rows[0:len(xs0)] = xs0\n y_rows = np.zeros(M)\n y_rows[0:len(xs0)] = ys0\n \n x_cols = np.zeros(M)\n x_cols[0:len(xs1)] = xs1\n y... | [
"0.7236676",
"0.71116245",
"0.6980892",
"0.6211652",
"0.6201551",
"0.61975414",
"0.61440456",
"0.6138001",
"0.6104754",
"0.60291874",
"0.596635",
"0.59564877",
"0.5908374",
"0.5814255",
"0.57994527",
"0.57992846",
"0.57992846",
"0.5795395",
"0.57856137",
"0.57316864",
"0.5696... | 0.7251244 | 0 |
From the list of events and the list of elements destroyed, returns the list of events remaining to be processed. | def get_remaining_events(index_disappeared,to_destroy):
index_cp = index_disappeared[:]
for i,deb,fin in to_destroy:
index_cp = [(x,y,z) for x,y,z in index_cp if (x!=deb and x!=fin)]
return index_cp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup_event_list(self):\n self._event_list, self._event_index_list = \\\n zip(*SimpleDeduplicator.remove_duplicates_from_event_list(\n zip(self._event_list, self._event_index_list)))",
"def remove(self, *args):\n return _libsbml.ListOfEvents_remove(self, *args)",
"... | [
"0.6650749",
"0.5865715",
"0.5838755",
"0.5780777",
"0.5730938",
"0.5675119",
"0.5600364",
"0.5590653",
"0.55873466",
"0.5586479",
"0.557899",
"0.55734974",
"0.5554042",
"0.555168",
"0.55159426",
"0.54889876",
"0.54870254",
"0.548628",
"0.5452252",
"0.54472625",
"0.5435289",
... | 0.6324991 | 1 |
Tests is the triplet event (index,difference,label) is a fusion event | def isFusion(event,buff):
index,diff,label = event
label = label[0]
if diff>0:
return False,[]
img_before = np.copy(buff[:,:,index-1])
img_after = np.copy(buff[:,:,index])
mask_before = (img_before==label).astype(np.uint8)
nb_elts_before = np.amax(img_before)
kernel = np.ones((7,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def analyze(self, event): \n trgObjects = Collection(event,self.trgColl)\n if self.trgMuMinPt!=None and self.trgMuMinPt>0:\n trgObjIdx = [ idx for idx,trg in enumerate(trgObjects) if getattr(trg,\"pt\")>self.trgMuMinPt and getattr(trg,self.trgBranch)==1]\n \n el... | [
"0.5815838",
"0.5663938",
"0.53611773",
"0.5331013",
"0.5326221",
"0.5287455",
"0.5126065",
"0.5097939",
"0.50953466",
"0.5082578",
"0.5075797",
"0.5053954",
"0.5026173",
"0.50153536",
"0.49891096",
"0.49828482",
"0.49418685",
"0.4924229",
"0.49229532",
"0.49065036",
"0.48751... | 0.5712748 | 1 |
Tests is the triplet event (index,difference,label) is a Division event | def isDivision(event,buff):
index,diff,label = event
label = label[0]
if diff<0:
return False,[]
img_before = np.copy(buff[:,:,index-1])
img_after = np.copy(buff[:,:,index])
mask_after = (img_after==label).astype(np.uint8)
nb_elts_after = np.amax(img_after)
kernel = np.ones((7,7)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dividing(self):\n divider = Divider()\n\n for i in range(-10, 10):\n for j in range(-10, 10):\n if j != 0:\n self.assertEqual(i/j, divider.calc(j, i))",
"def test_div():\n assert_equal(Vector(4.0, 1.0) / 2.0, Vector(2.0, 0.5))",
"def test_s... | [
"0.53327847",
"0.5313115",
"0.5300724",
"0.5273938",
"0.5204357",
"0.5184052",
"0.5181586",
"0.5178406",
"0.51758915",
"0.5142592",
"0.5125309",
"0.5066633",
"0.5049268",
"0.50456893",
"0.502341",
"0.5016449",
"0.49821922",
"0.49740198",
"0.49740198",
"0.49713653",
"0.4946493... | 0.592073 | 0 |
copy file from src to dst and minify web files along the way | def minify(src, dst, exclude_files=None, file_processors=None):
LOGGER.info("copying files in <%s> to <%s>", src, dst)
file_processors = DEFAULT_PROCESSORS if file_processors is None else file_processors
prefix = os.path.join(src, "")
for src_path in _walk_files(src, exclude_files):
assert sr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_html_file(src_fname, dst_fname, preprocess_args):\n html_path = src_fname\n # read the html file\n html_data = open(html_path).read() \n # remove all html comments\n html_data = remove_html_comment(html_data)\n # extract all the js data\n js_data = extract_javascript_f... | [
"0.63935184",
"0.63605475",
"0.616257",
"0.6147002",
"0.6136794",
"0.60883707",
"0.6086979",
"0.6039991",
"0.603878",
"0.6025809",
"0.6023852",
"0.6018967",
"0.6018357",
"0.6016775",
"0.5957169",
"0.5946915",
"0.5935241",
"0.5935241",
"0.5935241",
"0.5919326",
"0.5894673",
... | 0.64788646 | 0 |
Display the Fourier spectrum of an image. | def show_spectrum(image: np.ndarray):
assert len(image.shape) == 2, 'image must be 2D'
spectral = np.fft.fft2(image)
spectral[0, 0] = 0 # Kill DC component
spectrum = np.fft.fftshift(spectral) # Shift DC to center
magnitude = np.log(np.abs(spectrum))
plt.imshow(magnitude, cmap='gray')
plt.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fft_viz(image: np.ndarray, shift: bool = True) -> None:\n plt.imshow(img_fft(image, shift=shift), cmap='gray')",
"def plot_fft(self):\r\n\r\n self.ipx = int(self.imageData.shape[1]/2.)\r\n\r\n self.ipy = int(self.imageData.shape[2]/2.)\r\n\r\n nearf = np.absolute(self.DF[0:(self.freqs... | [
"0.73057055",
"0.7221409",
"0.71008265",
"0.68048716",
"0.66177744",
"0.6525481",
"0.6462273",
"0.64391583",
"0.6335996",
"0.625574",
"0.6221019",
"0.61736107",
"0.61712795",
"0.6145641",
"0.6104519",
"0.6071598",
"0.60663205",
"0.6058489",
"0.6057399",
"0.60085714",
"0.59906... | 0.76967245 | 0 |
total pub by each local_authority return local_authority which has minimum value | def least_num_pubBylocal_auth(self):
out=self.df.groupby('local_authority').agg(count('name').alias('lcount')) \
.sort(asc("lcount")).select("local_authority").limit(1)
out.withColumnRenamed('local_authority','local_authority who has the least number of pubs') \
.write.mode("ove... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minInDict(dist):\r\n m = float('inf')\r\n for p in dist:\r\n for q in dist[p]:\r\n if dist[p][q] < m:\r\n m = dist[p][q]\r\n a,b = p,q\r\n return a,b",
"def get_candidate(field_list, group):\n o = min(enumerate(field_list), key=lambda x: get_distance_... | [
"0.52389747",
"0.51440203",
"0.5122334",
"0.5064733",
"0.5064733",
"0.5032393",
"0.49961454",
"0.49773884",
"0.4942817",
"0.4924346",
"0.48977378",
"0.48493078",
"0.4826227",
"0.47944227",
"0.47905",
"0.47809845",
"0.47647154",
"0.4746491",
"0.474605",
"0.4737239",
"0.4729493... | 0.725406 | 0 |
count the words in name column after removing non alphanumeric value sort in decending and limit 5 results. ToDo remove the stop words | def topCommonwords(self,value=5):
out=self.df.withColumn('word', explode(split(col('name'), ' '))) \
.withColumn('norm_word',trim(regexp_replace('word','[^a-zA-Z0-9 ]', ''))) \
.filter(col('norm_word') !='')\
.groupBy('norm_word')\
.count()\
.sort('cou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_words(name):\n row = wiki[wiki['name'] == name]\n word_count_table = row[['word_count']].stack('word_count', new_column_name=['word','count'])\n return word_count_table.sort('count', ascending = False)",
"def index_count(self,wordList,colName):\n\t\twordobj = topicmodels.RawDocs(wordList, \"stop... | [
"0.64729655",
"0.58967775",
"0.5896678",
"0.58741987",
"0.5867055",
"0.5861347",
"0.58365446",
"0.57915187",
"0.5768599",
"0.5751851",
"0.56731445",
"0.56526613",
"0.5636982",
"0.5630961",
"0.5626338",
"0.5612843",
"0.56011504",
"0.55886984",
"0.5588324",
"0.5577244",
"0.5575... | 0.68508554 | 0 |
Registration logic of subgroups, should be overwritten in main CLI | def register_cli(cls):
for cmd in cls.SUB_GROUP_COMMANDS:
getattr(cls, cls.SUB_GROUP_NAME).add_command(getattr(cls, cmd)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrapper(callback):\n if self.subcommand_groups.get(base_names[0]) is None:\n self.subcommand_groups[base_names[0]] = {}\n self.subcommand_groups[base_names[0]][name] = SubSlashCommandGroup(callback, base_names, name, description, options=options, guild_ids=guild_ids, defaul... | [
"0.698378",
"0.65604806",
"0.6237793",
"0.6218014",
"0.618649",
"0.618066",
"0.60943496",
"0.6083362",
"0.60818076",
"0.6078718",
"0.6063804",
"0.60260564",
"0.6023523",
"0.60160524",
"0.5986268",
"0.5959416",
"0.59244037",
"0.5917318",
"0.5917318",
"0.58851683",
"0.58781135"... | 0.65827286 | 1 |
[Int] > tf.Tensor > String > [tf.Variable]? > (TargetNode, LossNode, Optimiser) Create metrics target node, loss node, and optimiser for a regression model. | def regression_metrics(output_node_shape, output_node, name, variables=None):
target_node = placeholder_node(
name + ".target", output_node_shape, dynamic_dimensions=1
)
loss_node = tf.losses.mean_squared_error(target_node, output_node)
optimiser = default_adam_optimiser(loss_node, name, variabl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reconstruction_metrics(input_node, reconstruction_node, name, variables=None):\n loss_node = tf.losses.mean_squared_error(input_node, reconstruction_node)\n optimiser = default_adam_optimiser(loss_node, name, variables=variables)\n return loss_node, optimiser",
"def _create_variables(self):\n\n \... | [
"0.6102364",
"0.5755435",
"0.574669",
"0.5739962",
"0.56981057",
"0.56804514",
"0.5642025",
"0.56373346",
"0.5593237",
"0.555256",
"0.554026",
"0.55188817",
"0.55173427",
"0.5517039",
"0.5429026",
"0.54116523",
"0.540996",
"0.54062945",
"0.54044217",
"0.5369112",
"0.5358145",... | 0.7475532 | 0 |
[Int] > tf.Tensor > String > [tf.Variable]? > (TargetNode, LossNode, Accuracy, Optimiser) Create metrics target node, loss node, accuracy node, and optimiser for a classification model. | def classification_metrics_with_initialiser(
output_node_shape, output_node, name, variables=None, target=None
):
target_node = (
placeholder_node(name + ".target", output_node_shape, dynamic_dimensions=1)
if target is None
else target
)
loss_node = tf.losses.log_loss(target_node... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classification_metrics(\n output_node_shape, output_node, name, variables=None, target=None\n):\n t, l, a, o, _ = classification_metrics_with_initialiser(\n output_node_shape, output_node, name, variables=variables, target=target\n )\n return t, l, a, o",
"def tf_mlp_multiclass_clf(X_train... | [
"0.7134077",
"0.6078243",
"0.6054212",
"0.60016525",
"0.59568673",
"0.59266657",
"0.5871297",
"0.58169127",
"0.5812805",
"0.5790166",
"0.5763362",
"0.5763234",
"0.57521635",
"0.56998026",
"0.5695013",
"0.56910604",
"0.56872755",
"0.56841546",
"0.56796646",
"0.5676946",
"0.567... | 0.69770443 | 1 |
[Int] > tf.Tensor > String > [tf.Variable]? > (TargetNode, LossNode, Accuracy, Optimiser) Create metrics target node, loss node, accuracy node, and optimiser for a classification model. | def classification_metrics(
output_node_shape, output_node, name, variables=None, target=None
):
t, l, a, o, _ = classification_metrics_with_initialiser(
output_node_shape, output_node, name, variables=variables, target=target
)
return t, l, a, o | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def classification_metrics_with_initialiser(\n output_node_shape, output_node, name, variables=None, target=None\n):\n target_node = (\n placeholder_node(name + \".target\", output_node_shape, dynamic_dimensions=1)\n if target is None\n else target\n )\n loss_node = tf.losses.log_l... | [
"0.697698",
"0.6078968",
"0.60548717",
"0.5999791",
"0.5957724",
"0.59262115",
"0.5870743",
"0.5816072",
"0.58087754",
"0.5792562",
"0.5763478",
"0.57633436",
"0.5749403",
"0.57000387",
"0.5693722",
"0.5690244",
"0.5687787",
"0.56866807",
"0.56790656",
"0.5673939",
"0.5672633... | 0.71353245 | 0 |
tf.Tensor > tf.Tensor > String > [tf.Variable]? > (LossNode, Optimiser) Create reconstruction metrics for an autoencoder, which penalises the distance between an input and a reconstructed output in the vector space. | def reconstruction_metrics(input_node, reconstruction_node, name, variables=None):
loss_node = tf.losses.mean_squared_error(input_node, reconstruction_node)
optimiser = default_adam_optimiser(loss_node, name, variables=variables)
return loss_node, optimiser | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def autoencoder(dimensions=[784, 512, 256, 64]):\n # %% input to the network\n x = tf.placeholder(tf.float32, [None, dimensions[0]], name='x')\n current_input = x\n\n # %% Build the encoder\n encoder = []\n for layer_i, n_output in enumerate(dimensions[1:]):\n n_input = int(current_input.g... | [
"0.65111524",
"0.59483415",
"0.5928199",
"0.59144574",
"0.57275474",
"0.5671412",
"0.5649989",
"0.5638825",
"0.5570472",
"0.5562427",
"0.5554723",
"0.5503049",
"0.54874516",
"0.5485655",
"0.546819",
"0.54645383",
"0.54317194",
"0.54237217",
"0.5420391",
"0.54063296",
"0.53980... | 0.64473253 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.