hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | UpdateBucket | null | def UpdateBucket(self, request, context):
"""Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.
| Updates a bucket. Equivalent to JSON API's storage.buckets.patch method. | [
"Updates",
"a",
"bucket",
".",
"Equivalent",
"to",
"JSON",
"API",
"'",
"s",
"storage",
".",
"buckets",
".",
"patch",
"method",
"."
] | def UpdateBucket(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"UpdateBucket",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | Updates a bucket. | [
"Updates",
"a",
"bucket",
"."
] | [
"\"\"\"Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | DeleteNotification | null | def DeleteNotification(self, request, context):
"""Permanently deletes a notification subscription.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Permanently deletes a notification subscription.
| Permanently deletes a notification subscription. | [
"Permanently",
"deletes",
"a",
"notification",
"subscription",
"."
] | def DeleteNotification(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"DeleteNotification",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplemen... | Permanently deletes a notification subscription. | [
"Permanently",
"deletes",
"a",
"notification",
"subscription",
"."
] | [
"\"\"\"Permanently deletes a notification subscription.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | CreateNotification | null | def CreateNotification(self, request, context):
"""Creates a notification subscription for a given bucket.
These notifications, when triggered, publish messages to the specified
Pub/Sub topics.
See https://cloud.google.com/storage/docs/pubsub-notifications.
"""
context.se... | Creates a notification subscription for a given bucket.
These notifications, when triggered, publish messages to the specified
Pub/Sub topics.
See https://cloud.google.com/storage/docs/pubsub-notifications.
| Creates a notification subscription for a given bucket.
These notifications, when triggered, publish messages to the specified
Pub/Sub topics. | [
"Creates",
"a",
"notification",
"subscription",
"for",
"a",
"given",
"bucket",
".",
"These",
"notifications",
"when",
"triggered",
"publish",
"messages",
"to",
"the",
"specified",
"Pub",
"/",
"Sub",
"topics",
"."
] | def CreateNotification(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"CreateNotification",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplemen... | Creates a notification subscription for a given bucket. | [
"Creates",
"a",
"notification",
"subscription",
"for",
"a",
"given",
"bucket",
"."
] | [
"\"\"\"Creates a notification subscription for a given bucket.\n These notifications, when triggered, publish messages to the specified\n Pub/Sub topics.\n See https://cloud.google.com/storage/docs/pubsub-notifications.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | ListNotifications | null | def ListNotifications(self, request, context):
"""Retrieves a list of notification subscriptions for a given bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Retrieves a list of notification subscriptions for a given bucket.
| Retrieves a list of notification subscriptions for a given bucket. | [
"Retrieves",
"a",
"list",
"of",
"notification",
"subscriptions",
"for",
"a",
"given",
"bucket",
"."
] | def ListNotifications(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"ListNotifications",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplement... | Retrieves a list of notification subscriptions for a given bucket. | [
"Retrieves",
"a",
"list",
"of",
"notification",
"subscriptions",
"for",
"a",
"given",
"bucket",
"."
] | [
"\"\"\"Retrieves a list of notification subscriptions for a given bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | ComposeObject | null | def ComposeObject(self, request, context):
"""Concatenates a list of existing objects into a new object in the same
bucket.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented... | Concatenates a list of existing objects into a new object in the same
bucket.
| Concatenates a list of existing objects into a new object in the same
bucket. | [
"Concatenates",
"a",
"list",
"of",
"existing",
"objects",
"into",
"a",
"new",
"object",
"in",
"the",
"same",
"bucket",
"."
] | def ComposeObject(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"ComposeObject",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedEr... | Concatenates a list of existing objects into a new object in the same
bucket. | [
"Concatenates",
"a",
"list",
"of",
"existing",
"objects",
"into",
"a",
"new",
"object",
"in",
"the",
"same",
"bucket",
"."
] | [
"\"\"\"Concatenates a list of existing objects into a new object in the same\n bucket.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | DeleteObject | null | def DeleteObject(self, request, context):
"""Deletes an object and its metadata. Deletions are permanent if versioning
is not enabled for the bucket, or if the `generation` parameter
is used.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method ... | Deletes an object and its metadata. Deletions are permanent if versioning
is not enabled for the bucket, or if the `generation` parameter
is used.
| Deletes an object and its metadata. Deletions are permanent if versioning
is not enabled for the bucket, or if the `generation` parameter
is used. | [
"Deletes",
"an",
"object",
"and",
"its",
"metadata",
".",
"Deletions",
"are",
"permanent",
"if",
"versioning",
"is",
"not",
"enabled",
"for",
"the",
"bucket",
"or",
"if",
"the",
"`",
"generation",
"`",
"parameter",
"is",
"used",
"."
] | def DeleteObject(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"DeleteObject",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | Deletes an object and its metadata. | [
"Deletes",
"an",
"object",
"and",
"its",
"metadata",
"."
] | [
"\"\"\"Deletes an object and its metadata. Deletions are permanent if versioning\n is not enabled for the bucket, or if the `generation` parameter\n is used.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | GetObject | null | def GetObject(self, request, context):
"""Retrieves an object's metadata.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Retrieves an object's metadata.
| Retrieves an object's metadata. | [
"Retrieves",
"an",
"object",
"'",
"s",
"metadata",
"."
] | def GetObject(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"GetObject",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedError"... | Retrieves an object's metadata. | [
"Retrieves",
"an",
"object",
"'",
"s",
"metadata",
"."
] | [
"\"\"\"Retrieves an object's metadata.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | ListObjects | null | def ListObjects(self, request, context):
"""Retrieves a list of objects matching the criteria.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Retrieves a list of objects matching the criteria.
| Retrieves a list of objects matching the criteria. | [
"Retrieves",
"a",
"list",
"of",
"objects",
"matching",
"the",
"criteria",
"."
] | def ListObjects(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"ListObjects",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErro... | Retrieves a list of objects matching the criteria. | [
"Retrieves",
"a",
"list",
"of",
"objects",
"matching",
"the",
"criteria",
"."
] | [
"\"\"\"Retrieves a list of objects matching the criteria.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | RewriteObject | null | def RewriteObject(self, request, context):
"""Rewrites a source object to a destination object. Optionally overrides
metadata.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemen... | Rewrites a source object to a destination object. Optionally overrides
metadata.
| Rewrites a source object to a destination object. Optionally overrides
metadata. | [
"Rewrites",
"a",
"source",
"object",
"to",
"a",
"destination",
"object",
".",
"Optionally",
"overrides",
"metadata",
"."
] | def RewriteObject(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"RewriteObject",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedEr... | Rewrites a source object to a destination object. | [
"Rewrites",
"a",
"source",
"object",
"to",
"a",
"destination",
"object",
"."
] | [
"\"\"\"Rewrites a source object to a destination object. Optionally overrides\n metadata.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | GetServiceAccount | null | def GetServiceAccount(self, request, context):
"""Retrieves the name of a project's Google Cloud Storage service account.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Retrieves the name of a project's Google Cloud Storage service account.
| Retrieves the name of a project's Google Cloud Storage service account. | [
"Retrieves",
"the",
"name",
"of",
"a",
"project",
"'",
"s",
"Google",
"Cloud",
"Storage",
"service",
"account",
"."
] | def GetServiceAccount(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"GetServiceAccount",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplement... | Retrieves the name of a project's Google Cloud Storage service account. | [
"Retrieves",
"the",
"name",
"of",
"a",
"project",
"'",
"s",
"Google",
"Cloud",
"Storage",
"service",
"account",
"."
] | [
"\"\"\"Retrieves the name of a project's Google Cloud Storage service account.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | CreateHmacKey | null | def CreateHmacKey(self, request, context):
"""Creates a new HMAC key for the given service account.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Creates a new HMAC key for the given service account.
| Creates a new HMAC key for the given service account. | [
"Creates",
"a",
"new",
"HMAC",
"key",
"for",
"the",
"given",
"service",
"account",
"."
] | def CreateHmacKey(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"CreateHmacKey",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedEr... | Creates a new HMAC key for the given service account. | [
"Creates",
"a",
"new",
"HMAC",
"key",
"for",
"the",
"given",
"service",
"account",
"."
] | [
"\"\"\"Creates a new HMAC key for the given service account.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | DeleteHmacKey | null | def DeleteHmacKey(self, request, context):
"""Deletes a given HMAC key. Key must be in an INACTIVE state.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Deletes a given HMAC key. Key must be in an INACTIVE state.
| Deletes a given HMAC key. Key must be in an INACTIVE state. | [
"Deletes",
"a",
"given",
"HMAC",
"key",
".",
"Key",
"must",
"be",
"in",
"an",
"INACTIVE",
"state",
"."
] | def DeleteHmacKey(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"DeleteHmacKey",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedEr... | Deletes a given HMAC key. | [
"Deletes",
"a",
"given",
"HMAC",
"key",
"."
] | [
"\"\"\"Deletes a given HMAC key. Key must be in an INACTIVE state.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | GetHmacKey | null | def GetHmacKey(self, request, context):
"""Gets an existing HMAC key metadata for the given id.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Gets an existing HMAC key metadata for the given id.
| Gets an existing HMAC key metadata for the given id. | [
"Gets",
"an",
"existing",
"HMAC",
"key",
"metadata",
"for",
"the",
"given",
"id",
"."
] | def GetHmacKey(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"GetHmacKey",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedError... | Gets an existing HMAC key metadata for the given id. | [
"Gets",
"an",
"existing",
"HMAC",
"key",
"metadata",
"for",
"the",
"given",
"id",
"."
] | [
"\"\"\"Gets an existing HMAC key metadata for the given id.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | ListHmacKeys | null | def ListHmacKeys(self, request, context):
"""Lists HMAC keys under a given project with the additional filters provided.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Lists HMAC keys under a given project with the additional filters provided.
| Lists HMAC keys under a given project with the additional filters provided. | [
"Lists",
"HMAC",
"keys",
"under",
"a",
"given",
"project",
"with",
"the",
"additional",
"filters",
"provided",
"."
] | def ListHmacKeys(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"ListHmacKeys",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedErr... | Lists HMAC keys under a given project with the additional filters provided. | [
"Lists",
"HMAC",
"keys",
"under",
"a",
"given",
"project",
"with",
"the",
"additional",
"filters",
"provided",
"."
] | [
"\"\"\"Lists HMAC keys under a given project with the additional filters provided.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
99d551eaf8c668a7ef6838fe076e4eea0a847335 | noahdietz/storage-testbench | google/storage/v2/storage_pb2_grpc.py | [
"Apache-2.0"
] | Python | UpdateHmacKey | null | def UpdateHmacKey(self, request, context):
"""Updates a given HMAC key state between ACTIVE and INACTIVE.
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | Updates a given HMAC key state between ACTIVE and INACTIVE.
| Updates a given HMAC key state between ACTIVE and INACTIVE. | [
"Updates",
"a",
"given",
"HMAC",
"key",
"state",
"between",
"ACTIVE",
"and",
"INACTIVE",
"."
] | def UpdateHmacKey(self, request, context):
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!') | [
"def",
"UpdateHmacKey",
"(",
"self",
",",
"request",
",",
"context",
")",
":",
"context",
".",
"set_code",
"(",
"grpc",
".",
"StatusCode",
".",
"UNIMPLEMENTED",
")",
"context",
".",
"set_details",
"(",
"'Method not implemented!'",
")",
"raise",
"NotImplementedEr... | Updates a given HMAC key state between ACTIVE and INACTIVE. | [
"Updates",
"a",
"given",
"HMAC",
"key",
"state",
"between",
"ACTIVE",
"and",
"INACTIVE",
"."
] | [
"\"\"\"Updates a given HMAC key state between ACTIVE and INACTIVE.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "context",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
2bfa2db0e3357fe18e0a6f07943747c88fe0ce5d | thlynn/binance-downloader | binance_downloader/manager.py | [
"MIT"
] | Python | write_to_csv | <not_specific> | def write_to_csv(self, output=None):
"""Write k-lines retrieved from Binance into a csv file
:param output: output file path. If none, will be stored in ./downloaded
directory with a timestamped filename based on symbol pair and interval
:return: None
"""
if not self... | Write k-lines retrieved from Binance into a csv file
:param output: output file path. If none, will be stored in ./downloaded
directory with a timestamped filename based on symbol pair and interval
:return: None
| Write k-lines retrieved from Binance into a csv file | [
"Write",
"k",
"-",
"lines",
"retrieved",
"from",
"Binance",
"into",
"a",
"csv",
"file"
] | def write_to_csv(self, output=None):
if not self.download_successful:
log.warn("Not writing to output file since no data was received from API")
return
if self.kline_df is None:
raise ValueError("Must read in data from Binance before writing to disk!")
output ... | [
"def",
"write_to_csv",
"(",
"self",
",",
"output",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"download_successful",
":",
"log",
".",
"warn",
"(",
"\"Not writing to output file since no data was received from API\"",
")",
"return",
"if",
"self",
".",
"kline_... | Write k-lines retrieved from Binance into a csv file | [
"Write",
"k",
"-",
"lines",
"retrieved",
"from",
"Binance",
"into",
"a",
"csv",
"file"
] | [
"\"\"\"Write k-lines retrieved from Binance into a csv file\n\n :param output: output file path. If none, will be stored in ./downloaded\n directory with a timestamped filename based on symbol pair and interval\n :return: None\n \"\"\"",
"# Generate default file name/path if none g... | [
{
"param": "self",
"type": null
},
{
"param": "output",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
2bfa2db0e3357fe18e0a6f07943747c88fe0ce5d | thlynn/binance-downloader | binance_downloader/manager.py | [
"MIT"
] | Python | fetch_all_symbols_by_quote | <not_specific> | def fetch_all_symbols_by_quote(self, quote):
"""Get all symbol pairs which quote equals the value of param quote
:param quote: the quote value
:type quote: str
:returns: a list of symbol pairs
:rtype: list
"""
return self.api.get_all_symbols_by_quote(quote) | Get all symbol pairs which quote equals the value of param quote
:param quote: the quote value
:type quote: str
:returns: a list of symbol pairs
:rtype: list
| Get all symbol pairs which quote equals the value of param quote | [
"Get",
"all",
"symbol",
"pairs",
"which",
"quote",
"equals",
"the",
"value",
"of",
"param",
"quote"
] | def fetch_all_symbols_by_quote(self, quote):
return self.api.get_all_symbols_by_quote(quote) | [
"def",
"fetch_all_symbols_by_quote",
"(",
"self",
",",
"quote",
")",
":",
"return",
"self",
".",
"api",
".",
"get_all_symbols_by_quote",
"(",
"quote",
")"
] | Get all symbol pairs which quote equals the value of param quote | [
"Get",
"all",
"symbol",
"pairs",
"which",
"quote",
"equals",
"the",
"value",
"of",
"param",
"quote"
] | [
"\"\"\"Get all symbol pairs which quote equals the value of param quote\n\n :param quote: the quote value\n :type quote: str\n :returns: a list of symbol pairs\n :rtype: list\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "quote",
"type": null
}
] | {
"returns": [
{
"docstring": "a list of symbol pairs",
"docstring_tokens": [
"a",
"list",
"of",
"symbol",
"pairs"
],
"type": "list"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": nul... |
2bfa2db0e3357fe18e0a6f07943747c88fe0ce5d | thlynn/binance-downloader | binance_downloader/manager.py | [
"MIT"
] | Python | fetch_klines_by_quote | null | def fetch_klines_by_quote(self, quote):
"""Fetch symbol pairs klines which quote equals the value of param quote
:param quote: the quote value
:type quote: str
:returns: None
"""
symbol_list = self.fetch_all_symbols_by_quote(quote)
for symbol in symbol_list:
... | Fetch symbol pairs klines which quote equals the value of param quote
:param quote: the quote value
:type quote: str
:returns: None
| Fetch symbol pairs klines which quote equals the value of param quote | [
"Fetch",
"symbol",
"pairs",
"klines",
"which",
"quote",
"equals",
"the",
"value",
"of",
"param",
"quote"
] | def fetch_klines_by_quote(self, quote):
symbol_list = self.fetch_all_symbols_by_quote(quote)
for symbol in symbol_list:
self.symbol = symbol
output = self.output_file
if os.path.exists(output):
log.warn(f"{symbol}: output file already existed, skipping... | [
"def",
"fetch_klines_by_quote",
"(",
"self",
",",
"quote",
")",
":",
"symbol_list",
"=",
"self",
".",
"fetch_all_symbols_by_quote",
"(",
"quote",
")",
"for",
"symbol",
"in",
"symbol_list",
":",
"self",
".",
"symbol",
"=",
"symbol",
"output",
"=",
"self",
"."... | Fetch symbol pairs klines which quote equals the value of param quote | [
"Fetch",
"symbol",
"pairs",
"klines",
"which",
"quote",
"equals",
"the",
"value",
"of",
"param",
"quote"
] | [
"\"\"\"Fetch symbol pairs klines which quote equals the value of param quote\n\n :param quote: the quote value\n :type quote: str\n :returns: None\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "quote",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
729147721c5a97263dc653504356a3a529a3e570 | mrgfisher/display-stuff-skill | __init__.py | [
"MIT"
] | Python | speak_back | null | def speak_back(self, message):
"""
Repeat the utterance back to the user.
TODO: The method is very english centric and will need
localization.
"""
# Remove the display word, trim and create an array of the words
utterance = message.data.get('utt... |
Repeat the utterance back to the user.
TODO: The method is very english centric and will need
localization.
| Repeat the utterance back to the user.
TODO: The method is very english centric and will need
localization. | [
"Repeat",
"the",
"utterance",
"back",
"to",
"the",
"user",
".",
"TODO",
":",
"The",
"method",
"is",
"very",
"english",
"centric",
"and",
"will",
"need",
"localization",
"."
] | def speak_back(self, message):
utterance = message.data.get('utterance')
words = re.sub('^.*?' + message.data['Display'], '', utterance).strip()
words_array = words.split(' ')
json_command = None
state_model = None
speak_this = "oh dear, I did not recognise that"
... | [
"def",
"speak_back",
"(",
"self",
",",
"message",
")",
":",
"utterance",
"=",
"message",
".",
"data",
".",
"get",
"(",
"'utterance'",
")",
"words",
"=",
"re",
".",
"sub",
"(",
"'^.*?'",
"+",
"message",
".",
"data",
"[",
"'Display'",
"]",
",",
"''",
... | Repeat the utterance back to the user. | [
"Repeat",
"the",
"utterance",
"back",
"to",
"the",
"user",
"."
] | [
"\"\"\"\n Repeat the utterance back to the user.\n\n TODO: The method is very english centric and will need\n localization.\n \"\"\"",
"# Remove the display word, trim and create an array of the words",
"# todo",
"# todo",
"# todo",
"# also todo",
"# more to... | [
{
"param": "self",
"type": null
},
{
"param": "message",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens"... |
5ac14e8c97cc11ffeeb2f064e05fa770ade08063 | mbingenheimer/sutra2DNA | main.py | [
"CC0-1.0"
] | Python | simple_transform | <not_specific> | def simple_transform():
"""
handles the simple transcoding/transform page
"""
input_string = ''
dna_string = ''
output_string = ''
# program may or may not be using the above variables
if request.method == 'POST':
# if server receives a POST http request
if 'enc... |
handles the simple transcoding/transform page
| handles the simple transcoding/transform page | [
"handles",
"the",
"simple",
"transcoding",
"/",
"transform",
"page"
] | def simple_transform():
input_string = ''
dna_string = ''
output_string = ''
if request.method == 'POST':
if 'encode' in request.form:
input_text = request.form['input_text']
range_value = int(request.form['base'])
checked_value = ['', '', '']
chec... | [
"def",
"simple_transform",
"(",
")",
":",
"input_string",
"=",
"''",
"dna_string",
"=",
"''",
"output_string",
"=",
"''",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"if",
"'encode'",
"in",
"request",
".",
"form",
":",
"input_text",
"=",
"request"... | handles the simple transcoding/transform page | [
"handles",
"the",
"simple",
"transcoding",
"/",
"transform",
"page"
] | [
"\"\"\"\r\n handles the simple transcoding/transform page\r\n \"\"\"",
"# program may or may not be using the above variables\r",
"# if server receives a POST http request\r",
"# steps taken when the POST is received from element named encode\r",
"# returns template for simple transform page; variable... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5ac14e8c97cc11ffeeb2f064e05fa770ade08063 | mbingenheimer/sutra2DNA | main.py | [
"CC0-1.0"
] | Python | convert_dna_to_unicode | <not_specific> | def convert_dna_to_unicode(dna_input, base):
"""
converts dna string input into unicode string
:param dna_input: String
:param base: int
:return: String
"""
unicode_string = ''
for dna_strings in dna_input.split(transcoding[base]):
if len(dna_strings) == 0:
... |
converts dna string input into unicode string
:param dna_input: String
:param base: int
:return: String
| converts dna string input into unicode string | [
"converts",
"dna",
"string",
"input",
"into",
"unicode",
"string"
] | def convert_dna_to_unicode(dna_input, base):
unicode_string = ''
for dna_strings in dna_input.split(transcoding[base]):
if len(dna_strings) == 0:
continue
unicode_string += chr(int(''.join([str(transcoding.index(i)) for i in dna_strings]), base))
return unicode_string | [
"def",
"convert_dna_to_unicode",
"(",
"dna_input",
",",
"base",
")",
":",
"unicode_string",
"=",
"''",
"for",
"dna_strings",
"in",
"dna_input",
".",
"split",
"(",
"transcoding",
"[",
"base",
"]",
")",
":",
"if",
"len",
"(",
"dna_strings",
")",
"==",
"0",
... | converts dna string input into unicode string | [
"converts",
"dna",
"string",
"input",
"into",
"unicode",
"string"
] | [
"\"\"\"\r\n converts dna string input into unicode string\r\n\r\n :param dna_input: String\r\n :param base: int\r\n :return: String\r\n \"\"\""
] | [
{
"param": "dna_input",
"type": null
},
{
"param": "base",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dna_input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
5ac14e8c97cc11ffeeb2f064e05fa770ade08063 | mbingenheimer/sutra2DNA | main.py | [
"CC0-1.0"
] | Python | convert_unicode_to_dna_simple | <not_specific> | def convert_unicode_to_dna_simple(text_input):
"""
converts unicode string input to DNA string, only uses base-2
:param text_input: String
:return: String
"""
dna_string = ''
for character in text_input:
binary_value = str(bin(ord(character)))[2:].zfill(20)
print(b... |
converts unicode string input to DNA string, only uses base-2
:param text_input: String
:return: String
| converts unicode string input to DNA string, only uses base-2 | [
"converts",
"unicode",
"string",
"input",
"to",
"DNA",
"string",
"only",
"uses",
"base",
"-",
"2"
] | def convert_unicode_to_dna_simple(text_input):
dna_string = ''
for character in text_input:
binary_value = str(bin(ord(character)))[2:].zfill(20)
print(binary_value)
for c in range(0, len(binary_value), 2):
dna_string += transcoding[int(binary_value[c]) * 2 + int(binary_value... | [
"def",
"convert_unicode_to_dna_simple",
"(",
"text_input",
")",
":",
"dna_string",
"=",
"''",
"for",
"character",
"in",
"text_input",
":",
"binary_value",
"=",
"str",
"(",
"bin",
"(",
"ord",
"(",
"character",
")",
")",
")",
"[",
"2",
":",
"]",
".",
"zfil... | converts unicode string input to DNA string, only uses base-2 | [
"converts",
"unicode",
"string",
"input",
"to",
"DNA",
"string",
"only",
"uses",
"base",
"-",
"2"
] | [
"\"\"\"\r\n converts unicode string input to DNA string, only uses base-2\r\n\r\n :param text_input: String\r\n :return: String\r\n \"\"\""
] | [
{
"param": "text_input",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "text_input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
5ac14e8c97cc11ffeeb2f064e05fa770ade08063 | mbingenheimer/sutra2DNA | main.py | [
"CC0-1.0"
] | Python | convert_dna_to_unicode_simple | <not_specific> | def convert_dna_to_unicode_simple(dna_string):
"""
converts DNA string input to unicode output, only uses base-2
:param dna_string: String
:return: String
"""
return_string = ''
for character in range(0, len(dna_string), 10):
numerical_dna_string = ''
for x in dna_... |
converts DNA string input to unicode output, only uses base-2
:param dna_string: String
:return: String
| converts DNA string input to unicode output, only uses base-2 | [
"converts",
"DNA",
"string",
"input",
"to",
"unicode",
"output",
"only",
"uses",
"base",
"-",
"2"
] | def convert_dna_to_unicode_simple(dna_string):
return_string = ''
for character in range(0, len(dna_string), 10):
numerical_dna_string = ''
for x in dna_string[character:character + 10]:
numerical_dna_string += str(int(transcoding.index(x) / 2))
numerical_dna_string += st... | [
"def",
"convert_dna_to_unicode_simple",
"(",
"dna_string",
")",
":",
"return_string",
"=",
"''",
"for",
"character",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"dna_string",
")",
",",
"10",
")",
":",
"numerical_dna_string",
"=",
"''",
"for",
"x",
"in",
"dna... | converts DNA string input to unicode output, only uses base-2 | [
"converts",
"DNA",
"string",
"input",
"to",
"unicode",
"output",
"only",
"uses",
"base",
"-",
"2"
] | [
"\"\"\"\r\n converts DNA string input to unicode output, only uses base-2\r\n\r\n :param dna_string: String\r\n :return: String\r\n \"\"\""
] | [
{
"param": "dna_string",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dna_string",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
5ac14e8c97cc11ffeeb2f064e05fa770ade08063 | mbingenheimer/sutra2DNA | main.py | [
"CC0-1.0"
] | Python | unicode_to_reed_solomon | <not_specific> | def unicode_to_reed_solomon(message, number_of_errors):
"""
converts unicode to dna using reed solomon algorithm
:param message: String
:param number_of_errors: int
:return: String
"""
encoder = rs.RSCoder(len(message) + (2 * number_of_errors), len(message))
encoded_unicode = e... |
converts unicode to dna using reed solomon algorithm
:param message: String
:param number_of_errors: int
:return: String
| converts unicode to dna using reed solomon algorithm | [
"converts",
"unicode",
"to",
"dna",
"using",
"reed",
"solomon",
"algorithm"
] | def unicode_to_reed_solomon(message, number_of_errors):
encoder = rs.RSCoder(len(message) + (2 * number_of_errors), len(message))
encoded_unicode = encoder.encode(message)
return convert_unicode_to_dna(encoded_unicode, 4) | [
"def",
"unicode_to_reed_solomon",
"(",
"message",
",",
"number_of_errors",
")",
":",
"encoder",
"=",
"rs",
".",
"RSCoder",
"(",
"len",
"(",
"message",
")",
"+",
"(",
"2",
"*",
"number_of_errors",
")",
",",
"len",
"(",
"message",
")",
")",
"encoded_unicode"... | converts unicode to dna using reed solomon algorithm | [
"converts",
"unicode",
"to",
"dna",
"using",
"reed",
"solomon",
"algorithm"
] | [
"\"\"\"\r\n converts unicode to dna using reed solomon algorithm\r\n\r\n :param message: String\r\n :param number_of_errors: int\r\n :return: String\r\n \"\"\""
] | [
{
"param": "message",
"type": null
},
{
"param": "number_of_errors",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
5ac14e8c97cc11ffeeb2f064e05fa770ade08063 | mbingenheimer/sutra2DNA | main.py | [
"CC0-1.0"
] | Python | reed_solomon_to_unicode | <not_specific> | def reed_solomon_to_unicode(dna, message_length, number_of_errors):
"""
converts DNA string, encoded using reed solomon, into unicode string
:param dna: String
:param message_length: int
:param number_of_errors: int
:return: String
"""
decoder = rs.RSCoder(message_length + (2 *... |
converts DNA string, encoded using reed solomon, into unicode string
:param dna: String
:param message_length: int
:param number_of_errors: int
:return: String
| converts DNA string, encoded using reed solomon, into unicode string | [
"converts",
"DNA",
"string",
"encoded",
"using",
"reed",
"solomon",
"into",
"unicode",
"string"
] | def reed_solomon_to_unicode(dna, message_length, number_of_errors):
decoder = rs.RSCoder(message_length + (2 * number_of_errors), message_length)
dna_string = convert_dna_to_unicode(dna, 4)
return decoder.decode(dna_string)[0] | [
"def",
"reed_solomon_to_unicode",
"(",
"dna",
",",
"message_length",
",",
"number_of_errors",
")",
":",
"decoder",
"=",
"rs",
".",
"RSCoder",
"(",
"message_length",
"+",
"(",
"2",
"*",
"number_of_errors",
")",
",",
"message_length",
")",
"dna_string",
"=",
"co... | converts DNA string, encoded using reed solomon, into unicode string | [
"converts",
"DNA",
"string",
"encoded",
"using",
"reed",
"solomon",
"into",
"unicode",
"string"
] | [
"\"\"\"\r\n converts DNA string, encoded using reed solomon, into unicode string\r\n\r\n :param dna: String\r\n :param message_length: int\r\n :param number_of_errors: int\r\n :return: String\r\n \"\"\""
] | [
{
"param": "dna",
"type": null
},
{
"param": "message_length",
"type": null
},
{
"param": "number_of_errors",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dna",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_unicode_to_binary | <not_specific> | def convert_unicode_to_binary(unicode_input):
"""
converts unicode string input into binary integer
:param unicode_input: String
:return: int
"""
binary_output = ''
for character in unicode_input:
binary_output += str(bin(ord(character)))[2:].zfill(18)
return binary_ou... |
converts unicode string input into binary integer
:param unicode_input: String
:return: int
| converts unicode string input into binary integer | [
"converts",
"unicode",
"string",
"input",
"into",
"binary",
"integer"
] | def convert_unicode_to_binary(unicode_input):
binary_output = ''
for character in unicode_input:
binary_output += str(bin(ord(character)))[2:].zfill(18)
return binary_output | [
"def",
"convert_unicode_to_binary",
"(",
"unicode_input",
")",
":",
"binary_output",
"=",
"''",
"for",
"character",
"in",
"unicode_input",
":",
"binary_output",
"+=",
"str",
"(",
"bin",
"(",
"ord",
"(",
"character",
")",
")",
")",
"[",
"2",
":",
"]",
".",
... | converts unicode string input into binary integer | [
"converts",
"unicode",
"string",
"input",
"into",
"binary",
"integer"
] | [
"\"\"\"\r\n converts unicode string input into binary integer\r\n\r\n :param unicode_input: String\r\n :return: int\r\n \"\"\""
] | [
{
"param": "unicode_input",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "unicode_input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": nul... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_binary_to_reed_solomon | <not_specific> | def convert_binary_to_reed_solomon(binary_input, errors):
"""
converts binary string input, using errors, to DNA using reed solomon algorithm
:param binary_input: String
:param errors: int
:return: String
"""
rsc = unireedsolomon.RSCoder(len(binary_input) + (2 * errors), len(binary_... |
converts binary string input, using errors, to DNA using reed solomon algorithm
:param binary_input: String
:param errors: int
:return: String
| converts binary string input, using errors, to DNA using reed solomon algorithm | [
"converts",
"binary",
"string",
"input",
"using",
"errors",
"to",
"DNA",
"using",
"reed",
"solomon",
"algorithm"
] | def convert_binary_to_reed_solomon(binary_input, errors):
rsc = unireedsolomon.RSCoder(len(binary_input) + (2 * errors), len(binary_input))
return rsc.encode(binary_input) | [
"def",
"convert_binary_to_reed_solomon",
"(",
"binary_input",
",",
"errors",
")",
":",
"rsc",
"=",
"unireedsolomon",
".",
"RSCoder",
"(",
"len",
"(",
"binary_input",
")",
"+",
"(",
"2",
"*",
"errors",
")",
",",
"len",
"(",
"binary_input",
")",
")",
"return... | converts binary string input, using errors, to DNA using reed solomon algorithm | [
"converts",
"binary",
"string",
"input",
"using",
"errors",
"to",
"DNA",
"using",
"reed",
"solomon",
"algorithm"
] | [
"\"\"\"\r\n converts binary string input, using errors, to DNA using reed solomon algorithm\r\n\r\n :param binary_input: String\r\n :param errors: int\r\n :return: String\r\n \"\"\""
] | [
{
"param": "binary_input",
"type": null
},
{
"param": "errors",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "binary_input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_reed_solomon_to_binary | <not_specific> | def convert_reed_solomon_to_binary(encoded_input, message_length, errors):
"""
converts encoded string input of specified length with predetermined number of possible errors to unicode
:param encoded_input: String
:param message_length: int
:param errors: int
:return: String
"""
... |
converts encoded string input of specified length with predetermined number of possible errors to unicode
:param encoded_input: String
:param message_length: int
:param errors: int
:return: String
| converts encoded string input of specified length with predetermined number of possible errors to unicode | [
"converts",
"encoded",
"string",
"input",
"of",
"specified",
"length",
"with",
"predetermined",
"number",
"of",
"possible",
"errors",
"to",
"unicode"
] | def convert_reed_solomon_to_binary(encoded_input, message_length, errors):
rsc = unireedsolomon.RSCoder(message_length + (2 * errors), message_length)
return rsc.decode(encoded_input)[0] | [
"def",
"convert_reed_solomon_to_binary",
"(",
"encoded_input",
",",
"message_length",
",",
"errors",
")",
":",
"rsc",
"=",
"unireedsolomon",
".",
"RSCoder",
"(",
"message_length",
"+",
"(",
"2",
"*",
"errors",
")",
",",
"message_length",
")",
"return",
"rsc",
... | converts encoded string input of specified length with predetermined number of possible errors to unicode | [
"converts",
"encoded",
"string",
"input",
"of",
"specified",
"length",
"with",
"predetermined",
"number",
"of",
"possible",
"errors",
"to",
"unicode"
] | [
"\"\"\"\r\n converts encoded string input of specified length with predetermined number of possible errors to unicode\r\n\r\n :param encoded_input: String\r\n :param message_length: int\r\n :param errors: int\r\n :return: String\r\n \"\"\""
] | [
{
"param": "encoded_input",
"type": null
},
{
"param": "message_length",
"type": null
},
{
"param": "errors",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "encoded_input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": nul... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_binary_to_unicode | <not_specific> | def convert_binary_to_unicode(binary_input):
"""
converts binary string of length 18 input to unicode
:param binary_input: String
:return: String
"""
unicode_output = ''
for starting_position in range(0, len(binary_input), 18):
unicode_output += chr(int(binary_input[startin... |
converts binary string of length 18 input to unicode
:param binary_input: String
:return: String
| converts binary string of length 18 input to unicode | [
"converts",
"binary",
"string",
"of",
"length",
"18",
"input",
"to",
"unicode"
] | def convert_binary_to_unicode(binary_input):
unicode_output = ''
for starting_position in range(0, len(binary_input), 18):
unicode_output += chr(int(binary_input[starting_position:starting_position + 18], 2))
return unicode_output | [
"def",
"convert_binary_to_unicode",
"(",
"binary_input",
")",
":",
"unicode_output",
"=",
"''",
"for",
"starting_position",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"binary_input",
")",
",",
"18",
")",
":",
"unicode_output",
"+=",
"chr",
"(",
"int",
"(",
... | converts binary string of length 18 input to unicode | [
"converts",
"binary",
"string",
"of",
"length",
"18",
"input",
"to",
"unicode"
] | [
"\"\"\"\r\n converts binary string of length 18 input to unicode\r\n\r\n :param binary_input: String\r\n :return: String\r\n \"\"\""
] | [
{
"param": "binary_input",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "binary_input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_encoded_to_dna | <not_specific> | def convert_encoded_to_dna(encoded, transcoding):
"""
converts encoded string to DNA string using transcoding list
:param encoded: String
:param transcoding: List[char]
:return: String
"""
dna_binary = ''
for character in encoded:
dna_binary += str(bin(ord(character)))... |
converts encoded string to DNA string using transcoding list
:param encoded: String
:param transcoding: List[char]
:return: String
| converts encoded string to DNA string using transcoding list | [
"converts",
"encoded",
"string",
"to",
"DNA",
"string",
"using",
"transcoding",
"list"
] | def convert_encoded_to_dna(encoded, transcoding):
dna_binary = ''
for character in encoded:
dna_binary += str(bin(ord(character)))[2:].zfill(8)
return ''.join([transcoding[2*int(dna_binary[i]) + int(dna_binary[i+1])] for i in range(0, len(dna_binary) - 2, 2)]) | [
"def",
"convert_encoded_to_dna",
"(",
"encoded",
",",
"transcoding",
")",
":",
"dna_binary",
"=",
"''",
"for",
"character",
"in",
"encoded",
":",
"dna_binary",
"+=",
"str",
"(",
"bin",
"(",
"ord",
"(",
"character",
")",
")",
")",
"[",
"2",
":",
"]",
".... | converts encoded string to DNA string using transcoding list | [
"converts",
"encoded",
"string",
"to",
"DNA",
"string",
"using",
"transcoding",
"list"
] | [
"\"\"\"\r\n converts encoded string to DNA string using transcoding list\r\n\r\n :param encoded: String\r\n :param transcoding: List[char]\r\n :return: String\r\n \"\"\""
] | [
{
"param": "encoded",
"type": null
},
{
"param": "transcoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "encoded",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_dna_to_encoded | <not_specific> | def convert_dna_to_encoded(dna_string, transcoding):
"""
converts DNA string to encoded string using transcoding list and reed solomon algorithm
:param dna_string: String
:param transcoding: List[char]
:return: String
"""
encoded_string = ''
binary_stage = ''
for character... |
converts DNA string to encoded string using transcoding list and reed solomon algorithm
:param dna_string: String
:param transcoding: List[char]
:return: String
| converts DNA string to encoded string using transcoding list and reed solomon algorithm | [
"converts",
"DNA",
"string",
"to",
"encoded",
"string",
"using",
"transcoding",
"list",
"and",
"reed",
"solomon",
"algorithm"
] | def convert_dna_to_encoded(dna_string, transcoding):
encoded_string = ''
binary_stage = ''
for character in dna_string:
binary_stage += str(int(transcoding.index(character) / 2))
binary_stage += str(int(transcoding.index(character) % 2))
for i in range(0, len(binary_stage), 8):
e... | [
"def",
"convert_dna_to_encoded",
"(",
"dna_string",
",",
"transcoding",
")",
":",
"encoded_string",
"=",
"''",
"binary_stage",
"=",
"''",
"for",
"character",
"in",
"dna_string",
":",
"binary_stage",
"+=",
"str",
"(",
"int",
"(",
"transcoding",
".",
"index",
"(... | converts DNA string to encoded string using transcoding list and reed solomon algorithm | [
"converts",
"DNA",
"string",
"to",
"encoded",
"string",
"using",
"transcoding",
"list",
"and",
"reed",
"solomon",
"algorithm"
] | [
"\"\"\"\r\n converts DNA string to encoded string using transcoding list and reed solomon algorithm\r\n\r\n :param dna_string: String\r\n :param transcoding: List[char]\r\n :return: String\r\n \"\"\""
] | [
{
"param": "dna_string",
"type": null
},
{
"param": "transcoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dna_string",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_unicode_to_dna | <not_specific> | def convert_unicode_to_dna(unicode_string, errors, transcoding):
"""
converts unicode string input to dna string output using predetermined number of errors and transcoding list
:param unicode_string: String
:param errors: int
:param transcoding: List[char]
:return: String
"""
... |
converts unicode string input to dna string output using predetermined number of errors and transcoding list
:param unicode_string: String
:param errors: int
:param transcoding: List[char]
:return: String
| converts unicode string input to dna string output using predetermined number of errors and transcoding list | [
"converts",
"unicode",
"string",
"input",
"to",
"dna",
"string",
"output",
"using",
"predetermined",
"number",
"of",
"errors",
"and",
"transcoding",
"list"
] | def convert_unicode_to_dna(unicode_string, errors, transcoding):
return convert_encoded_to_dna(convert_binary_to_reed_solomon(convert_unicode_to_binary(unicode_string), errors),
transcoding) | [
"def",
"convert_unicode_to_dna",
"(",
"unicode_string",
",",
"errors",
",",
"transcoding",
")",
":",
"return",
"convert_encoded_to_dna",
"(",
"convert_binary_to_reed_solomon",
"(",
"convert_unicode_to_binary",
"(",
"unicode_string",
")",
",",
"errors",
")",
",",
"transc... | converts unicode string input to dna string output using predetermined number of errors and transcoding list | [
"converts",
"unicode",
"string",
"input",
"to",
"dna",
"string",
"output",
"using",
"predetermined",
"number",
"of",
"errors",
"and",
"transcoding",
"list"
] | [
"\"\"\"\r\n converts unicode string input to dna string output using predetermined number of errors and transcoding list\r\n\r\n :param unicode_string: String\r\n :param errors: int\r\n :param transcoding: List[char]\r\n :return: String\r\n \"\"\""
] | [
{
"param": "unicode_string",
"type": null
},
{
"param": "errors",
"type": null
},
{
"param": "transcoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "unicode_string",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": nu... |
a5c38330577910be1168cff0470aebeca1451871 | mbingenheimer/sutra2DNA | reed_solomon.py | [
"CC0-1.0"
] | Python | convert_dna_to_unicode | <not_specific> | def convert_dna_to_unicode(dna_string, message_length, errors, transcoding):
"""
converts dna string of set message length, predetermined number of errors, and transcoding list
:param dna_string: String
:param message_length: int
:param errors: int
:param transcoding: List[char]
:re... |
converts dna string of set message length, predetermined number of errors, and transcoding list
:param dna_string: String
:param message_length: int
:param errors: int
:param transcoding: List[char]
:return: String
| converts dna string of set message length, predetermined number of errors, and transcoding list | [
"converts",
"dna",
"string",
"of",
"set",
"message",
"length",
"predetermined",
"number",
"of",
"errors",
"and",
"transcoding",
"list"
] | def convert_dna_to_unicode(dna_string, message_length, errors, transcoding):
return convert_binary_to_unicode(convert_reed_solomon_to_binary(convert_dna_to_encoded(dna_string, transcoding),
message_length, errors)) | [
"def",
"convert_dna_to_unicode",
"(",
"dna_string",
",",
"message_length",
",",
"errors",
",",
"transcoding",
")",
":",
"return",
"convert_binary_to_unicode",
"(",
"convert_reed_solomon_to_binary",
"(",
"convert_dna_to_encoded",
"(",
"dna_string",
",",
"transcoding",
")",... | converts dna string of set message length, predetermined number of errors, and transcoding list | [
"converts",
"dna",
"string",
"of",
"set",
"message",
"length",
"predetermined",
"number",
"of",
"errors",
"and",
"transcoding",
"list"
] | [
"\"\"\"\r\n converts dna string of set message length, predetermined number of errors, and transcoding list\r\n\r\n :param dna_string: String\r\n :param message_length: int\r\n :param errors: int\r\n :param transcoding: List[char]\r\n :return: String\r\n \"\"\""
] | [
{
"param": "dna_string",
"type": null
},
{
"param": "message_length",
"type": null
},
{
"param": "errors",
"type": null
},
{
"param": "transcoding",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dna_string",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | _handle_new_peers | null | def _handle_new_peers(self, names):
"""Set up state for new peers."""
for peer_name in names:
if peer_name in self._states:
continue
self._setup_state_for_peer(peer_name) | Set up state for new peers. | Set up state for new peers. | [
"Set",
"up",
"state",
"for",
"new",
"peers",
"."
] | def _handle_new_peers(self, names):
for peer_name in names:
if peer_name in self._states:
continue
self._setup_state_for_peer(peer_name) | [
"def",
"_handle_new_peers",
"(",
"self",
",",
"names",
")",
":",
"for",
"peer_name",
"in",
"names",
":",
"if",
"peer_name",
"in",
"self",
".",
"_states",
":",
"continue",
"self",
".",
"_setup_state_for_peer",
"(",
"peer_name",
")"
] | Set up state for new peers. | [
"Set",
"up",
"state",
"for",
"new",
"peers",
"."
] | [
"\"\"\"Set up state for new peers.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "names",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "names",
"type": null,
"docstring": null,
"docstring_tokens": ... |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | _determine_endpoint | <not_specific> | def _determine_endpoint(self):
"""Determine the IP address of this peer.
@raises Exception: If it is not impossible to figure out the
address.
@return: a C{ADDRESS:PORT} string.
"""
# Figure our our endpoint:
host = self.transport.getHost()
if not sel... | Determine the IP address of this peer.
@raises Exception: If it is not impossible to figure out the
address.
@return: a C{ADDRESS:PORT} string.
| Determine the IP address of this peer. | [
"Determine",
"the",
"IP",
"address",
"of",
"this",
"peer",
"."
] | def _determine_endpoint(self):
host = self.transport.getHost()
if not self._address:
self._address = host.host
if self._address == '0.0.0.0':
raise Exception("address not specified")
return '%s:%d' % (self._address, host.port) | [
"def",
"_determine_endpoint",
"(",
"self",
")",
":",
"host",
"=",
"self",
".",
"transport",
".",
"getHost",
"(",
")",
"if",
"not",
"self",
".",
"_address",
":",
"self",
".",
"_address",
"=",
"host",
".",
"host",
"if",
"self",
".",
"_address",
"==",
"... | Determine the IP address of this peer. | [
"Determine",
"the",
"IP",
"address",
"of",
"this",
"peer",
"."
] | [
"\"\"\"Determine the IP address of this peer.\n\n @raises Exception: If it is not impossible to figure out the\n address.\n @return: a C{ADDRESS:PORT} string.\n \"\"\"",
"# Figure our our endpoint:"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "a C{ADDRESS:PORT} string.",
"docstring_tokens": [
"a",
"C",
"{",
"ADDRESS",
":",
"PORT",
"}",
"string",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifie... |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | _gossip | null | def _gossip(self):
"""Initiate a round of gossiping."""
live_peers = self.live_peers
dead_peers = self.dead_peers
if live_peers:
self._gossip_with_peer(random.choice(live_peers))
prob = len(dead_peers) / float(len(live_peers) + 1)
if random.random() < prob:
... | Initiate a round of gossiping. | Initiate a round of gossiping. | [
"Initiate",
"a",
"round",
"of",
"gossiping",
"."
] | def _gossip(self):
live_peers = self.live_peers
dead_peers = self.dead_peers
if live_peers:
self._gossip_with_peer(random.choice(live_peers))
prob = len(dead_peers) / float(len(live_peers) + 1)
if random.random() < prob:
self._gossip_with_peer(random.choic... | [
"def",
"_gossip",
"(",
"self",
")",
":",
"live_peers",
"=",
"self",
".",
"live_peers",
"dead_peers",
"=",
"self",
".",
"dead_peers",
"if",
"live_peers",
":",
"self",
".",
"_gossip_with_peer",
"(",
"random",
".",
"choice",
"(",
"live_peers",
")",
")",
"prob... | Initiate a round of gossiping. | [
"Initiate",
"a",
"round",
"of",
"gossiping",
"."
] | [
"\"\"\"Initiate a round of gossiping.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | _handle_request | null | def _handle_request(self, message, address):
"""Handle an incoming gossip request."""
deltas, requests, new_peers = self._scuttle.scuttle(
message['digest'])
self._handle_new_peers(new_peers)
response = json.dumps({
'type': 'first-response', 'digest': requests, 'u... | Handle an incoming gossip request. | Handle an incoming gossip request. | [
"Handle",
"an",
"incoming",
"gossip",
"request",
"."
] | def _handle_request(self, message, address):
deltas, requests, new_peers = self._scuttle.scuttle(
message['digest'])
self._handle_new_peers(new_peers)
response = json.dumps({
'type': 'first-response', 'digest': requests, 'updates': deltas
})
self.trans... | [
"def",
"_handle_request",
"(",
"self",
",",
"message",
",",
"address",
")",
":",
"deltas",
",",
"requests",
",",
"new_peers",
"=",
"self",
".",
"_scuttle",
".",
"scuttle",
"(",
"message",
"[",
"'digest'",
"]",
")",
"self",
".",
"_handle_new_peers",
"(",
... | Handle an incoming gossip request. | [
"Handle",
"an",
"incoming",
"gossip",
"request",
"."
] | [
"\"\"\"Handle an incoming gossip request.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "message",
"type": null
},
{
"param": "address",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens"... |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | _handle_first_response | null | def _handle_first_response(self, message, address):
"""Handle the response to a request."""
self._scuttle.update_known_state(message['updates'])
response = json.dumps({
'type': 'second-response',
'updates': self._scuttle.fetch_deltas(
message['digest']... | Handle the response to a request. | Handle the response to a request. | [
"Handle",
"the",
"response",
"to",
"a",
"request",
"."
] | def _handle_first_response(self, message, address):
self._scuttle.update_known_state(message['updates'])
response = json.dumps({
'type': 'second-response',
'updates': self._scuttle.fetch_deltas(
message['digest'])
})
self.transport.write(re... | [
"def",
"_handle_first_response",
"(",
"self",
",",
"message",
",",
"address",
")",
":",
"self",
".",
"_scuttle",
".",
"update_known_state",
"(",
"message",
"[",
"'updates'",
"]",
")",
"response",
"=",
"json",
".",
"dumps",
"(",
"{",
"'type'",
":",
"'second... | Handle the response to a request. | [
"Handle",
"the",
"response",
"to",
"a",
"request",
"."
] | [
"\"\"\"Handle the response to a request.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "message",
"type": null
},
{
"param": "address",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "message",
"type": null,
"docstring": null,
"docstring_tokens"... |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | live_peers | <not_specific> | def live_peers():
"""Property for all peers that we know is alive.
The property holds a sequence L{PeerState}'s.
"""
def get(self):
return [p for (n, p) in self._states.items()
if p.alive and n != self.name]
return get, | Property for all peers that we know is alive.
The property holds a sequence L{PeerState}'s.
| Property for all peers that we know is alive.
The property holds a sequence L{PeerState}'s. | [
"Property",
"for",
"all",
"peers",
"that",
"we",
"know",
"is",
"alive",
".",
"The",
"property",
"holds",
"a",
"sequence",
"L",
"{",
"PeerState",
"}",
"'",
"s",
"."
] | def live_peers():
def get(self):
return [p for (n, p) in self._states.items()
if p.alive and n != self.name]
return get, | [
"def",
"live_peers",
"(",
")",
":",
"def",
"get",
"(",
"self",
")",
":",
"return",
"[",
"p",
"for",
"(",
"n",
",",
"p",
")",
"in",
"self",
".",
"_states",
".",
"items",
"(",
")",
"if",
"p",
".",
"alive",
"and",
"n",
"!=",
"self",
".",
"name",... | Property for all peers that we know is alive. | [
"Property",
"for",
"all",
"peers",
"that",
"we",
"know",
"is",
"alive",
"."
] | [
"\"\"\"Property for all peers that we know is alive.\n\n The property holds a sequence L{PeerState}'s.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e1afe1f695c7b83d585cd702442896424da928e8 | jrydberg/txgossip | txgossip/gossip.py | [
"MIT"
] | Python | dead_peers | <not_specific> | def dead_peers():
"""Property for all peers that we know is dead.
The property holds a sequence L{PeerState}'s.
"""
def get(self):
return [p for (n, p) in self._states.items()
if not p.alive and n != self.name]
return get, | Property for all peers that we know is dead.
The property holds a sequence L{PeerState}'s.
| Property for all peers that we know is dead.
The property holds a sequence L{PeerState}'s. | [
"Property",
"for",
"all",
"peers",
"that",
"we",
"know",
"is",
"dead",
".",
"The",
"property",
"holds",
"a",
"sequence",
"L",
"{",
"PeerState",
"}",
"'",
"s",
"."
] | def dead_peers():
def get(self):
return [p for (n, p) in self._states.items()
if not p.alive and n != self.name]
return get, | [
"def",
"dead_peers",
"(",
")",
":",
"def",
"get",
"(",
"self",
")",
":",
"return",
"[",
"p",
"for",
"(",
"n",
",",
"p",
")",
"in",
"self",
".",
"_states",
".",
"items",
"(",
")",
"if",
"not",
"p",
".",
"alive",
"and",
"n",
"!=",
"self",
".",
... | Property for all peers that we know is dead. | [
"Property",
"for",
"all",
"peers",
"that",
"we",
"know",
"is",
"dead",
"."
] | [
"\"\"\"Property for all peers that we know is dead.\n\n The property holds a sequence L{PeerState}'s.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4fad8d9b5ebe498a707706221e1e3420e87add24 | jrydberg/txgossip | txgossip/recipies.py | [
"MIT"
] | Python | _check_consensus | <not_specific> | def _check_consensus(self, key):
"""Check if all peers have the same value for C{key}.
Return the value if they all have the same value, otherwise
return C{None}.
"""
correct = self._gossiper.get(key)
for peer in self._gossiper.live_peers:
if not key in peer.... | Check if all peers have the same value for C{key}.
Return the value if they all have the same value, otherwise
return C{None}.
| Check if all peers have the same value for C{key}.
Return the value if they all have the same value, otherwise
return C{None}. | [
"Check",
"if",
"all",
"peers",
"have",
"the",
"same",
"value",
"for",
"C",
"{",
"key",
"}",
".",
"Return",
"the",
"value",
"if",
"they",
"all",
"have",
"the",
"same",
"value",
"otherwise",
"return",
"C",
"{",
"None",
"}",
"."
] | def _check_consensus(self, key):
correct = self._gossiper.get(key)
for peer in self._gossiper.live_peers:
if not key in peer.keys():
return None
value = peer.get(key)
if value != correct:
return None
return correct | [
"def",
"_check_consensus",
"(",
"self",
",",
"key",
")",
":",
"correct",
"=",
"self",
".",
"_gossiper",
".",
"get",
"(",
"key",
")",
"for",
"peer",
"in",
"self",
".",
"_gossiper",
".",
"live_peers",
":",
"if",
"not",
"key",
"in",
"peer",
".",
"keys",... | Check if all peers have the same value for C{key}. | [
"Check",
"if",
"all",
"peers",
"have",
"the",
"same",
"value",
"for",
"C",
"{",
"key",
"}",
"."
] | [
"\"\"\"Check if all peers have the same value for C{key}.\n\n Return the value if they all have the same value, otherwise\n return C{None}.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_tokens": []... |
4fad8d9b5ebe498a707706221e1e3420e87add24 | jrydberg/txgossip | txgossip/recipies.py | [
"MIT"
] | Python | value_changed | <not_specific> | def value_changed(self, peer, key, value):
"""Inform about a change of a key-value pair.
@param peer: The peer that changed a value.
@param key: The key.
@param value: The new value.
@return: C{True} if this method acted on the change, or if it
was unrelated.
... | Inform about a change of a key-value pair.
@param peer: The peer that changed a value.
@param key: The key.
@param value: The new value.
@return: C{True} if this method acted on the change, or if it
was unrelated.
| Inform about a change of a key-value pair. | [
"Inform",
"about",
"a",
"change",
"of",
"a",
"key",
"-",
"value",
"pair",
"."
] | def value_changed(self, peer, key, value):
if key == self.VOTE_KEY:
leader = self._check_consensus(self.VOTE_KEY)
if leader:
self._gossiper.set(self.LEADER_KEY, leader)
elif key == self.LEADER_KEY:
leader = self._check_consensus(self.LEADER_KEY)
... | [
"def",
"value_changed",
"(",
"self",
",",
"peer",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"==",
"self",
".",
"VOTE_KEY",
":",
"leader",
"=",
"self",
".",
"_check_consensus",
"(",
"self",
".",
"VOTE_KEY",
")",
"if",
"leader",
":",
"self",
"."... | Inform about a change of a key-value pair. | [
"Inform",
"about",
"a",
"change",
"of",
"a",
"key",
"-",
"value",
"pair",
"."
] | [
"\"\"\"Inform about a change of a key-value pair.\n\n @param peer: The peer that changed a value.\n @param key: The key.\n @param value: The new value.\n\n @return: C{True} if this method acted on the change, or if it\n was unrelated.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "peer",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [
{
"docstring": "C{True} if this method acted on the change, or if it\nwas unrelated.",
"docstring_tokens": [
"C",
"{",
"True",
"}",
"if",
"this",
"method",
"acted",
"on",
"the",
"change",
"or... |
4fad8d9b5ebe498a707706221e1e3420e87add24 | jrydberg/txgossip | txgossip/recipies.py | [
"MIT"
] | Python | start_election | null | def start_election(self):
"""Start an election.
Elections should be started when the cluster membership view
changes (i.e.g, when a peer joins the cluster, or when a peer
dies).
It is safe to call this while an election is taking place.
"""
if self._election_tim... | Start an election.
Elections should be started when the cluster membership view
changes (i.e.g, when a peer joins the cluster, or when a peer
dies).
It is safe to call this while an election is taking place.
| Start an election.
Elections should be started when the cluster membership view
changes .
It is safe to call this while an election is taking place. | [
"Start",
"an",
"election",
".",
"Elections",
"should",
"be",
"started",
"when",
"the",
"cluster",
"membership",
"view",
"changes",
".",
"It",
"is",
"safe",
"to",
"call",
"this",
"while",
"an",
"election",
"is",
"taking",
"place",
"."
] | def start_election(self):
if self._election_timeout is not None:
self._election_timeout.cancel()
self._election_timeout = self.clock.callLater(self.vote_delay,
self._vote) | [
"def",
"start_election",
"(",
"self",
")",
":",
"if",
"self",
".",
"_election_timeout",
"is",
"not",
"None",
":",
"self",
".",
"_election_timeout",
".",
"cancel",
"(",
")",
"self",
".",
"_election_timeout",
"=",
"self",
".",
"clock",
".",
"callLater",
"(",... | Start an election. | [
"Start",
"an",
"election",
"."
] | [
"\"\"\"Start an election.\n\n Elections should be started when the cluster membership view\n changes (i.e.g, when a peer joins the cluster, or when a peer\n dies).\n\n It is safe to call this while an election is taking place.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4fad8d9b5ebe498a707706221e1e3420e87add24 | jrydberg/txgossip | txgossip/recipies.py | [
"MIT"
] | Python | leader_elected | null | def leader_elected(self, is_leader, leader):
"""Notifcation about leader election result.
@param is_leader: C{True} if this peer is the leader.
@param leader: The address of the peer that is the leader.
"""
self.is_leader = is_leader | Notifcation about leader election result.
@param is_leader: C{True} if this peer is the leader.
@param leader: The address of the peer that is the leader.
| Notifcation about leader election result. | [
"Notifcation",
"about",
"leader",
"election",
"result",
"."
] | def leader_elected(self, is_leader, leader):
self.is_leader = is_leader | [
"def",
"leader_elected",
"(",
"self",
",",
"is_leader",
",",
"leader",
")",
":",
"self",
".",
"is_leader",
"=",
"is_leader"
] | Notifcation about leader election result. | [
"Notifcation",
"about",
"leader",
"election",
"result",
"."
] | [
"\"\"\"Notifcation about leader election result.\n\n @param is_leader: C{True} if this peer is the leader.\n @param leader: The address of the peer that is the leader.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "is_leader",
"type": null
},
{
"param": "leader",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "is_leader",
"type": null,
"docstring": "C{True} if this peer is the... |
4fad8d9b5ebe498a707706221e1e3420e87add24 | jrydberg/txgossip | txgossip/recipies.py | [
"MIT"
] | Python | value_changed | <not_specific> | def value_changed(self, peer, key, timestamp_value):
"""A peer has changed its value."""
if key == '__heartbeat__' or key in self._ignore_keys:
return
if peer.name == self._gossiper.name:
self.persist_key_value(key, timestamp_value)
else:
self.replicat... | A peer has changed its value. | A peer has changed its value. | [
"A",
"peer",
"has",
"changed",
"its",
"value",
"."
] | def value_changed(self, peer, key, timestamp_value):
if key == '__heartbeat__' or key in self._ignore_keys:
return
if peer.name == self._gossiper.name:
self.persist_key_value(key, timestamp_value)
else:
self.replicate_key_value(peer, key, timestamp_value) | [
"def",
"value_changed",
"(",
"self",
",",
"peer",
",",
"key",
",",
"timestamp_value",
")",
":",
"if",
"key",
"==",
"'__heartbeat__'",
"or",
"key",
"in",
"self",
".",
"_ignore_keys",
":",
"return",
"if",
"peer",
".",
"name",
"==",
"self",
".",
"_gossiper"... | A peer has changed its value. | [
"A",
"peer",
"has",
"changed",
"its",
"value",
"."
] | [
"\"\"\"A peer has changed its value.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "peer",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "timestamp_value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "peer",
"type": null,
"docstring": null,
"docstring_tokens": [... |
4fad8d9b5ebe498a707706221e1e3420e87add24 | jrydberg/txgossip | txgossip/recipies.py | [
"MIT"
] | Python | keys | <not_specific> | def keys(self, pattern=None):
"""Return a iterable of all available keys."""
if pattern is None:
return self._gossiper.keys()
else:
keys = self._gossiper.keys()
return [key for key in keys
if fnmatch.fnmatch(key, pattern)] | Return a iterable of all available keys. | Return a iterable of all available keys. | [
"Return",
"a",
"iterable",
"of",
"all",
"available",
"keys",
"."
] | def keys(self, pattern=None):
if pattern is None:
return self._gossiper.keys()
else:
keys = self._gossiper.keys()
return [key for key in keys
if fnmatch.fnmatch(key, pattern)] | [
"def",
"keys",
"(",
"self",
",",
"pattern",
"=",
"None",
")",
":",
"if",
"pattern",
"is",
"None",
":",
"return",
"self",
".",
"_gossiper",
".",
"keys",
"(",
")",
"else",
":",
"keys",
"=",
"self",
".",
"_gossiper",
".",
"keys",
"(",
")",
"return",
... | Return a iterable of all available keys. | [
"Return",
"a",
"iterable",
"of",
"all",
"available",
"keys",
"."
] | [
"\"\"\"Return a iterable of all available keys.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "pattern",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pattern",
"type": null,
"docstring": null,
"docstring_tokens"... |
737434d454b416f96a08bc5650a244c80127c036 | Te-k/webcache | webcache/yandex.py | [
"MIT"
] | Python | search | <not_specific> | def search(req):
'''
Search for a request in Yandex and return results
Does not work all the time, Yandex has a captcha often
'''
r = requests.get('https://yandex.ru/search/?text=%s' %
urllib.parse.quote(req, safe='')
)
if r.status_code != 200:
... |
Search for a request in Yandex and return results
Does not work all the time, Yandex has a captcha often
| Search for a request in Yandex and return results
Does not work all the time, Yandex has a captcha often | [
"Search",
"for",
"a",
"request",
"in",
"Yandex",
"and",
"return",
"results",
"Does",
"not",
"work",
"all",
"the",
"time",
"Yandex",
"has",
"a",
"captcha",
"often"
] | def search(req):
r = requests.get('https://yandex.ru/search/?text=%s' %
urllib.parse.quote(req, safe='')
)
if r.status_code != 200:
return False, []
soup = BeautifulSoup(r.text, 'lxml')
if soup.find('main') is None:
return False, []
... | [
"def",
"search",
"(",
"req",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"'https://yandex.ru/search/?text=%s'",
"%",
"urllib",
".",
"parse",
".",
"quote",
"(",
"req",
",",
"safe",
"=",
"''",
")",
")",
"if",
"r",
".",
"status_code",
"!=",
"200",
... | Search for a request in Yandex and return results
Does not work all the time, Yandex has a captcha often | [
"Search",
"for",
"a",
"request",
"in",
"Yandex",
"and",
"return",
"results",
"Does",
"not",
"work",
"all",
"the",
"time",
"Yandex",
"has",
"a",
"captcha",
"often"
] | [
"'''\n Search for a request in Yandex and return results\n Does not work all the time, Yandex has a captcha often\n '''"
] | [
{
"param": "req",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "req",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
737434d454b416f96a08bc5650a244c80127c036 | Te-k/webcache | webcache/yandex.py | [
"MIT"
] | Python | download_cache | <not_specific> | def download_cache(cache_url):
'''
Extract content from a cached Yandex url
'''
# FIXME: do not get date and url
r = requests.get(cache_url)
if r.status_code == 200:
return {
'success': True,
'data': r.text[:-90],
... |
Extract content from a cached Yandex url
| Extract content from a cached Yandex url | [
"Extract",
"content",
"from",
"a",
"cached",
"Yandex",
"url"
] | def download_cache(cache_url):
r = requests.get(cache_url)
if r.status_code == 200:
return {
'success': True,
'data': r.text[:-90],
'cacheurl': cache_url,
}
else:
return {'success': False} | [
"def",
"download_cache",
"(",
"cache_url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"cache_url",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":",
"return",
"{",
"'success'",
":",
"True",
",",
"'data'",
":",
"r",
".",
"text",
"[",
":",
... | Extract content from a cached Yandex url | [
"Extract",
"content",
"from",
"a",
"cached",
"Yandex",
"url"
] | [
"'''\n Extract content from a cached Yandex url\n '''",
"# FIXME: do not get date and url"
] | [
{
"param": "cache_url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache_url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
737434d454b416f96a08bc5650a244c80127c036 | Te-k/webcache | webcache/yandex.py | [
"MIT"
] | Python | cache | <not_specific> | def cache(url):
"""
Search for a cache url in yandex and if found get its content
"""
# FIXME: miss obvious pages, like www.domain.com instead of domain.com
v, res = Yandex.search(url)
if v:
for i in res:
if i['url'] == url:
... |
Search for a cache url in yandex and if found get its content
| Search for a cache url in yandex and if found get its content | [
"Search",
"for",
"a",
"cache",
"url",
"in",
"yandex",
"and",
"if",
"found",
"get",
"its",
"content"
] | def cache(url):
v, res = Yandex.search(url)
if v:
for i in res:
if i['url'] == url:
if 'cache' in i:
c = Yandex.download_cache(i['cache'])
c['found'] = True
return c
return... | [
"def",
"cache",
"(",
"url",
")",
":",
"v",
",",
"res",
"=",
"Yandex",
".",
"search",
"(",
"url",
")",
"if",
"v",
":",
"for",
"i",
"in",
"res",
":",
"if",
"i",
"[",
"'url'",
"]",
"==",
"url",
":",
"if",
"'cache'",
"in",
"i",
":",
"c",
"=",
... | Search for a cache url in yandex and if found get its content | [
"Search",
"for",
"a",
"cache",
"url",
"in",
"yandex",
"and",
"if",
"found",
"get",
"its",
"content"
] | [
"\"\"\"\n Search for a cache url in yandex and if found get its content\n \"\"\"",
"# FIXME: miss obvious pages, like www.domain.com instead of domain.com"
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
00ead7ca73a56662debfea3d7aebc4bd61c4cb6e | Te-k/webcache | webcache/archiveorg.py | [
"MIT"
] | Python | snapshots | <not_specific> | def snapshots(url):
"""
Return a list of snapshots for a given url
"""
# FIXME: report more snapshot through the Memento API
r = requests.get('http://archive.org/wayback/available?url=%s' %
urllib.parse.quote(url))
data = r.json()
res = []
... |
Return a list of snapshots for a given url
| Return a list of snapshots for a given url | [
"Return",
"a",
"list",
"of",
"snapshots",
"for",
"a",
"given",
"url"
] | def snapshots(url):
r = requests.get('http://archive.org/wayback/available?url=%s' %
urllib.parse.quote(url))
data = r.json()
res = []
if 'archived_snapshots' in data:
for i in data['archived_snapshots']:
res.append({
'url':... | [
"def",
"snapshots",
"(",
"url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"'http://archive.org/wayback/available?url=%s'",
"%",
"urllib",
".",
"parse",
".",
"quote",
"(",
"url",
")",
")",
"data",
"=",
"r",
".",
"json",
"(",
")",
"res",
"=",
"[",... | Return a list of snapshots for a given url | [
"Return",
"a",
"list",
"of",
"snapshots",
"for",
"a",
"given",
"url"
] | [
"\"\"\"\n Return a list of snapshots for a given url\n \"\"\"",
"# FIXME: report more snapshot through the Memento API"
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
00ead7ca73a56662debfea3d7aebc4bd61c4cb6e | Te-k/webcache | webcache/archiveorg.py | [
"MIT"
] | Python | download_cache | <not_specific> | def download_cache(cache_url):
"""
Download cache from a cache url
"""
if cache_url.startswith('https://web.archive.org/web/') or \
cache_url.startswith('http://web.archive.org/web/'):
r = requests.get(cache_url)
data = r.text
t1 = data.fin... |
Download cache from a cache url
| Download cache from a cache url | [
"Download",
"cache",
"from",
"a",
"cache",
"url"
] | def download_cache(cache_url):
if cache_url.startswith('https://web.archive.org/web/') or \
cache_url.startswith('http://web.archive.org/web/'):
r = requests.get(cache_url)
data = r.text
t1 = data.find('<!-- End Wayback Rewrite JS Include -->')
cached_... | [
"def",
"download_cache",
"(",
"cache_url",
")",
":",
"if",
"cache_url",
".",
"startswith",
"(",
"'https://web.archive.org/web/'",
")",
"or",
"cache_url",
".",
"startswith",
"(",
"'http://web.archive.org/web/'",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"c... | Download cache from a cache url | [
"Download",
"cache",
"from",
"a",
"cache",
"url"
] | [
"\"\"\"\n Download cache from a cache url\n \"\"\""
] | [
{
"param": "cache_url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache_url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
00ead7ca73a56662debfea3d7aebc4bd61c4cb6e | Te-k/webcache | webcache/archiveorg.py | [
"MIT"
] | Python | cache | <not_specific> | def cache(url):
"""
Download an url from a cache
"""
snapshots = ArchiveOrg.snapshots(url)
if len(snapshots):
last = sorted(snapshots, key=lambda x: x['date'], reverse=True)[0]
return ArchiveOrg.download_cache(last['archive'])
else:
ret... |
Download an url from a cache
| Download an url from a cache | [
"Download",
"an",
"url",
"from",
"a",
"cache"
] | def cache(url):
snapshots = ArchiveOrg.snapshots(url)
if len(snapshots):
last = sorted(snapshots, key=lambda x: x['date'], reverse=True)[0]
return ArchiveOrg.download_cache(last['archive'])
else:
return {'success': False} | [
"def",
"cache",
"(",
"url",
")",
":",
"snapshots",
"=",
"ArchiveOrg",
".",
"snapshots",
"(",
"url",
")",
"if",
"len",
"(",
"snapshots",
")",
":",
"last",
"=",
"sorted",
"(",
"snapshots",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"'date'",
"]",... | Download an url from a cache | [
"Download",
"an",
"url",
"from",
"a",
"cache"
] | [
"\"\"\"\n Download an url from a cache\n \"\"\""
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4aa15dca447219a5208af771b3e3062223679548 | Te-k/webcache | webcache/archiveis.py | [
"MIT"
] | Python | snapshots | <not_specific> | def snapshots(url):
"""
Return all the screenshot of an url
"""
mc = MementoClient(base_url='http://archive.is/')
return mc.snapshots(url) |
Return all the screenshot of an url
| Return all the screenshot of an url | [
"Return",
"all",
"the",
"screenshot",
"of",
"an",
"url"
] | def snapshots(url):
mc = MementoClient(base_url='http://archive.is/')
return mc.snapshots(url) | [
"def",
"snapshots",
"(",
"url",
")",
":",
"mc",
"=",
"MementoClient",
"(",
"base_url",
"=",
"'http://archive.is/'",
")",
"return",
"mc",
".",
"snapshots",
"(",
"url",
")"
] | Return all the screenshot of an url | [
"Return",
"all",
"the",
"screenshot",
"of",
"an",
"url"
] | [
"\"\"\"\n Return all the screenshot of an url\n \"\"\""
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4aa15dca447219a5208af771b3e3062223679548 | Te-k/webcache | webcache/archiveis.py | [
"MIT"
] | Python | download_cache | <not_specific> | def download_cache(cache_url):
"""
return cache data from an archive.is cached url
"""
r = requests.get(cache_url)
data = r.text
t1 = data.find('\n\n\n\n\n\n')
t2 = data.find('</div></div><!--[if !IE]><!--><div style="position:absolute;right:1028px;top:-14px;botto... |
return cache data from an archive.is cached url
| return cache data from an archive.is cached url | [
"return",
"cache",
"data",
"from",
"an",
"archive",
".",
"is",
"cached",
"url"
] | def download_cache(cache_url):
r = requests.get(cache_url)
data = r.text
t1 = data.find('\n\n\n\n\n\n')
t2 = data.find('</div></div><!--[if !IE]><!--><div style="position:absolute;right:1028px;top:-14px;bottom:-2px">')
t5 = data.find('<meta property="article:modified_time" conten... | [
"def",
"download_cache",
"(",
"cache_url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"cache_url",
")",
"data",
"=",
"r",
".",
"text",
"t1",
"=",
"data",
".",
"find",
"(",
"'\\n\\n\\n\\n\\n\\n'",
")",
"t2",
"=",
"data",
".",
"find",
"(",
"'</di... | return cache data from an archive.is cached url | [
"return",
"cache",
"data",
"from",
"an",
"archive",
".",
"is",
"cached",
"url"
] | [
"\"\"\"\n return cache data from an archive.is cached url\n \"\"\"",
"#t3 = data.find('<input style=\"border:1px solid black;height:20px;margin:0 0 0 0;padding:0;width:500px\" type=\"text\" name=\"q\"')",
"#t4 = data[t3+115:].find('\"')",
"#original_url = data[t3+115:t3+115+t4]"
] | [
{
"param": "cache_url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cache_url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4aa15dca447219a5208af771b3e3062223679548 | Te-k/webcache | webcache/archiveis.py | [
"MIT"
] | Python | cache | <not_specific> | def cache(url):
"""
Get a cache url and download the last one
"""
snapshots = ArchiveIs.snapshots(url)
if len(snapshots) > 0:
last = sorted(snapshots, key=lambda x: x['date'], reverse=True)[0]
return ArchiveIs.download_cache(last['archive'])
else:
... |
Get a cache url and download the last one
| Get a cache url and download the last one | [
"Get",
"a",
"cache",
"url",
"and",
"download",
"the",
"last",
"one"
] | def cache(url):
snapshots = ArchiveIs.snapshots(url)
if len(snapshots) > 0:
last = sorted(snapshots, key=lambda x: x['date'], reverse=True)[0]
return ArchiveIs.download_cache(last['archive'])
else:
return {
'success': False
} | [
"def",
"cache",
"(",
"url",
")",
":",
"snapshots",
"=",
"ArchiveIs",
".",
"snapshots",
"(",
"url",
")",
"if",
"len",
"(",
"snapshots",
")",
">",
"0",
":",
"last",
"=",
"sorted",
"(",
"snapshots",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"'d... | Get a cache url and download the last one | [
"Get",
"a",
"cache",
"url",
"and",
"download",
"the",
"last",
"one"
] | [
"\"\"\"\n Get a cache url and download the last one\n \"\"\""
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4aa15dca447219a5208af771b3e3062223679548 | Te-k/webcache | webcache/archiveis.py | [
"MIT"
] | Python | capture | <not_specific> | def capture(url):
"""
Capture an url in archive.is
"""
# Easiest way to do it for now, archive.is API sucks
# FIXME replace this lib
return archiveis.capture(url) |
Capture an url in archive.is
| Capture an url in archive.is | [
"Capture",
"an",
"url",
"in",
"archive",
".",
"is"
] | def capture(url):
return archiveis.capture(url) | [
"def",
"capture",
"(",
"url",
")",
":",
"return",
"archiveis",
".",
"capture",
"(",
"url",
")"
] | Capture an url in archive.is | [
"Capture",
"an",
"url",
"in",
"archive",
".",
"is"
] | [
"\"\"\"\n Capture an url in archive.is\n \"\"\"",
"# Easiest way to do it for now, archive.is API sucks",
"# FIXME replace this lib"
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b34652e318eee2f384d98b38276baae557a266a6 | Te-k/webcache | webcache/bing.py | [
"MIT"
] | Python | download_cache | <not_specific> | def download_cache(url):
"""
Download cache data from a cached page
"""
r = requests.get(url)
if r.status_code == 200:
if "Could not find the requested document in the cache" in r.text:
# Bing bug
return {"success": False}
e... |
Download cache data from a cached page
| Download cache data from a cached page | [
"Download",
"cache",
"data",
"from",
"a",
"cached",
"page"
] | def download_cache(url):
r = requests.get(url)
if r.status_code == 200:
if "Could not find the requested document in the cache" in r.text:
return {"success": False}
else:
soup = BeautifulSoup(r.text, 'lxml')
content = soup.find('div... | [
"def",
"download_cache",
"(",
"url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":",
"if",
"\"Could not find the requested document in the cache\"",
"in",
"r",
".",
"text",
":",
"return",
"{",
"... | Download cache data from a cached page | [
"Download",
"cache",
"data",
"from",
"a",
"cached",
"page"
] | [
"\"\"\"\n Download cache data from a cached page\n \"\"\"",
"# Bing bug"
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b34652e318eee2f384d98b38276baae557a266a6 | Te-k/webcache | webcache/bing.py | [
"MIT"
] | Python | cache | <not_specific> | def cache(url):
"""
Search for an url in Bing cache
"""
res = Bing.search(url)
for i in res:
if same_url(url, i['url']):
if 'cache' in i:
return Bing.download_cache(i['cache'])
return {'success': False} |
Search for an url in Bing cache
| Search for an url in Bing cache | [
"Search",
"for",
"an",
"url",
"in",
"Bing",
"cache"
] | def cache(url):
res = Bing.search(url)
for i in res:
if same_url(url, i['url']):
if 'cache' in i:
return Bing.download_cache(i['cache'])
return {'success': False} | [
"def",
"cache",
"(",
"url",
")",
":",
"res",
"=",
"Bing",
".",
"search",
"(",
"url",
")",
"for",
"i",
"in",
"res",
":",
"if",
"same_url",
"(",
"url",
",",
"i",
"[",
"'url'",
"]",
")",
":",
"if",
"'cache'",
"in",
"i",
":",
"return",
"Bing",
".... | Search for an url in Bing cache | [
"Search",
"for",
"an",
"url",
"in",
"Bing",
"cache"
] | [
"\"\"\"\n Search for an url in Bing cache\n \"\"\""
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6927fd650c39e930577ddb933298c4da3e3f717f | Te-k/webcache | webcache/utils.py | [
"MIT"
] | Python | same_url | <not_specific> | def same_url(url1, url2):
"""
Check for minor differences between url1 and url2, return True if they are the same
Currently only consider extra www. in domain, https/http and extra fragment
"""
if url1 == url2:
return True
# Dirty hacks
if not url1.startswith('http'):
url1 = ... |
Check for minor differences between url1 and url2, return True if they are the same
Currently only consider extra www. in domain, https/http and extra fragment
| Check for minor differences between url1 and url2, return True if they are the same
Currently only consider extra www. in domain, https/http and extra fragment | [
"Check",
"for",
"minor",
"differences",
"between",
"url1",
"and",
"url2",
"return",
"True",
"if",
"they",
"are",
"the",
"same",
"Currently",
"only",
"consider",
"extra",
"www",
".",
"in",
"domain",
"https",
"/",
"http",
"and",
"extra",
"fragment"
] | def same_url(url1, url2):
if url1 == url2:
return True
if not url1.startswith('http'):
url1 = 'http://' + url1
if not url2.startswith('http'):
url2 = 'http://' + url2
if not url1.endswith('/'):
url1 += '/'
if not url2.endswith('/'):
url2 += '/'
purl2 = url... | [
"def",
"same_url",
"(",
"url1",
",",
"url2",
")",
":",
"if",
"url1",
"==",
"url2",
":",
"return",
"True",
"if",
"not",
"url1",
".",
"startswith",
"(",
"'http'",
")",
":",
"url1",
"=",
"'http://'",
"+",
"url1",
"if",
"not",
"url2",
".",
"startswith",
... | Check for minor differences between url1 and url2, return True if they are the same
Currently only consider extra www. | [
"Check",
"for",
"minor",
"differences",
"between",
"url1",
"and",
"url2",
"return",
"True",
"if",
"they",
"are",
"the",
"same",
"Currently",
"only",
"consider",
"extra",
"www",
"."
] | [
"\"\"\"\n Check for minor differences between url1 and url2, return True if they are the same\n Currently only consider extra www. in domain, https/http and extra fragment\n \"\"\"",
"# Dirty hacks"
] | [
{
"param": "url1",
"type": null
},
{
"param": "url2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url2",
"type": null,
"docstring": null,
"docstring_tokens": [... |
959b072bba9eeeee6dcf2274c096e01a4aadeb42 | Te-k/webcache | webcache/memento.py | [
"MIT"
] | Python | _parselinks | <not_specific> | def _parselinks(self, data):
"""
Parse links from RFC 7089, returns list of links
"""
res = []
for d in data.split('\n'):
if d != "":
regex = self.linkre.match(d)
if regex is not None:
new = {
... |
Parse links from RFC 7089, returns list of links
| Parse links from RFC 7089, returns list of links | [
"Parse",
"links",
"from",
"RFC",
"7089",
"returns",
"list",
"of",
"links"
] | def _parselinks(self, data):
res = []
for d in data.split('\n'):
if d != "":
regex = self.linkre.match(d)
if regex is not None:
new = {
'url': regex.group('url'),
'type': regex.group('type')
... | [
"def",
"_parselinks",
"(",
"self",
",",
"data",
")",
":",
"res",
"=",
"[",
"]",
"for",
"d",
"in",
"data",
".",
"split",
"(",
"'\\n'",
")",
":",
"if",
"d",
"!=",
"\"\"",
":",
"regex",
"=",
"self",
".",
"linkre",
".",
"match",
"(",
"d",
")",
"i... | Parse links from RFC 7089, returns list of links | [
"Parse",
"links",
"from",
"RFC",
"7089",
"returns",
"list",
"of",
"links"
] | [
"\"\"\"\n Parse links from RFC 7089, returns list of links\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
959b072bba9eeeee6dcf2274c096e01a4aadeb42 | Te-k/webcache | webcache/memento.py | [
"MIT"
] | Python | snapshots | <not_specific> | def snapshots(self, url):
"""
Download list of snapshots for an url
"""
r = requests.get(urljoin(self.base_url + 'timemap/', quote(url, safe='')), timeout=3)
if r.status_code != 200:
return []
else:
links = self._parselinks(r.text)
# Ge... |
Download list of snapshots for an url
| Download list of snapshots for an url | [
"Download",
"list",
"of",
"snapshots",
"for",
"an",
"url"
] | def snapshots(self, url):
r = requests.get(urljoin(self.base_url + 'timemap/', quote(url, safe='')), timeout=3)
if r.status_code != 200:
return []
else:
links = self._parselinks(r.text)
originals = list(
filter(
lambda x: x[... | [
"def",
"snapshots",
"(",
"self",
",",
"url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"urljoin",
"(",
"self",
".",
"base_url",
"+",
"'timemap/'",
",",
"quote",
"(",
"url",
",",
"safe",
"=",
"''",
")",
")",
",",
"timeout",
"=",
"3",
")",
... | Download list of snapshots for an url | [
"Download",
"list",
"of",
"snapshots",
"for",
"an",
"url"
] | [
"\"\"\"\n Download list of snapshots for an url\n \"\"\"",
"# Get original url",
"# Sort snapshots"
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
1defbad389ab69546a55fe6eabbadad1d7e70021 | Te-k/webcache | webcache/google.py | [
"MIT"
] | Python | download_cache | <not_specific> | def download_cache(url):
"""
Download cache from a cache url
"""
r = requests.get(url)
if r.status_code == 200:
mark1 = r.text.find("It is a snapshot of the page as it appeared on ")
timestamptext = r.text[mark1+47:mark1+47+24]
timestamp = pars... |
Download cache from a cache url
| Download cache from a cache url | [
"Download",
"cache",
"from",
"a",
"cache",
"url"
] | def download_cache(url):
r = requests.get(url)
if r.status_code == 200:
mark1 = r.text.find("It is a snapshot of the page as it appeared on ")
timestamptext = r.text[mark1+47:mark1+47+24]
timestamp = parse(timestamptext)
return {
"succe... | [
"def",
"download_cache",
"(",
"url",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":",
"mark1",
"=",
"r",
".",
"text",
".",
"find",
"(",
"\"It is a snapshot of the page as it appeared on \"",
")",... | Download cache from a cache url | [
"Download",
"cache",
"from",
"a",
"cache",
"url"
] | [
"\"\"\"\n Download cache from a cache url\n \"\"\""
] | [
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9a6a6089a1401ace23cd5b9666318dd3622f0040 | DemirTonchev/iambandit | environment.py | [
"MIT"
] | Python | generate_context | <not_specific> | def generate_context(self):
"""Generates context vector of indicators and computes current
real reward probability
"""
context = []
context_vector = bernuolli(self.context_options)
if self.add_bias:
context_vector = np.append([1], context_vector)
for i... | Generates context vector of indicators and computes current
real reward probability
| Generates context vector of indicators and computes current
real reward probability | [
"Generates",
"context",
"vector",
"of",
"indicators",
"and",
"computes",
"current",
"real",
"reward",
"probability"
] | def generate_context(self):
context = []
context_vector = bernuolli(self.context_options)
if self.add_bias:
context_vector = np.append([1], context_vector)
for i in range(self.k_arms):
context.append(context_vector)
self.current_rewards = [arm.pull(context... | [
"def",
"generate_context",
"(",
"self",
")",
":",
"context",
"=",
"[",
"]",
"context_vector",
"=",
"bernuolli",
"(",
"self",
".",
"context_options",
")",
"if",
"self",
".",
"add_bias",
":",
"context_vector",
"=",
"np",
".",
"append",
"(",
"[",
"1",
"]",
... | Generates context vector of indicators and computes current
real reward probability | [
"Generates",
"context",
"vector",
"of",
"indicators",
"and",
"computes",
"current",
"real",
"reward",
"probability"
] | [
"\"\"\"Generates context vector of indicators and computes current\n real reward probability\n \"\"\"",
"# pull all arms to generate current mean, rewards and get the optimal one",
"# agent/policy/algorithm knows only the context but means are not revealed"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
087ba04eff1f88e31d15cbe23954023bbe50900d | DemirTonchev/iambandit | policy.py | [
"MIT"
] | Python | safe_min_1d | <not_specific> | def safe_min_1d(array):
"""Useful for taking min arm index for some policies
"""
if len(array) > 0:
return np.min(array)
else:
return None | Useful for taking min arm index for some policies
| Useful for taking min arm index for some policies | [
"Useful",
"for",
"taking",
"min",
"arm",
"index",
"for",
"some",
"policies"
] | def safe_min_1d(array):
if len(array) > 0:
return np.min(array)
else:
return None | [
"def",
"safe_min_1d",
"(",
"array",
")",
":",
"if",
"len",
"(",
"array",
")",
">",
"0",
":",
"return",
"np",
".",
"min",
"(",
"array",
")",
"else",
":",
"return",
"None"
] | Useful for taking min arm index for some policies | [
"Useful",
"for",
"taking",
"min",
"arm",
"index",
"for",
"some",
"policies"
] | [
"\"\"\"Useful for taking min arm index for some policies\n \"\"\""
] | [
{
"param": "array",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "array",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ce22e306f321c2a87ef145037aecd579abb04fe0 | DemirTonchev/iambandit | simulation.py | [
"MIT"
] | Python | _run_simulation | <not_specific> | def _run_simulation(simulation, sid = None, full_results = True):
""" Helper function for Parralel computation of several simulations.
Returns list of dictionaries of results for a particular simulation with id and policy
type added
"""
simulation.run()
if full_results:
result = simulati... | Helper function for Parralel computation of several simulations.
Returns list of dictionaries of results for a particular simulation with id and policy
type added
| Helper function for Parralel computation of several simulations.
Returns list of dictionaries of results for a particular simulation with id and policy
type added | [
"Helper",
"function",
"for",
"Parralel",
"computation",
"of",
"several",
"simulations",
".",
"Returns",
"list",
"of",
"dictionaries",
"of",
"results",
"for",
"a",
"particular",
"simulation",
"with",
"id",
"and",
"policy",
"type",
"added"
] | def _run_simulation(simulation, sid = None, full_results = True):
simulation.run()
if full_results:
result = simulation.results
else:
result = [simulation.results[-1]]
for step_results in result:
step_results.update({'id':sid,
'policyType': simulation.po... | [
"def",
"_run_simulation",
"(",
"simulation",
",",
"sid",
"=",
"None",
",",
"full_results",
"=",
"True",
")",
":",
"simulation",
".",
"run",
"(",
")",
"if",
"full_results",
":",
"result",
"=",
"simulation",
".",
"results",
"else",
":",
"result",
"=",
"[",... | Helper function for Parralel computation of several simulations. | [
"Helper",
"function",
"for",
"Parralel",
"computation",
"of",
"several",
"simulations",
"."
] | [
"\"\"\" Helper function for Parralel computation of several simulations.\n Returns list of dictionaries of results for a particular simulation with id and policy\n type added\n \"\"\"",
"# put simulation identifier"
] | [
{
"param": "simulation",
"type": null
},
{
"param": "sid",
"type": null
},
{
"param": "full_results",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "simulation",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sid",
"type": null,
"docstring": null,
"docstring_token... |
8b9dde11380f246bde31304d4d4dc08213735c02 | DemirTonchev/iambandit | base.py | [
"MIT"
] | Python | random_argmax | <not_specific> | def random_argmax(vector):
"""Helper function to select argmax at random... not just first one."""
try:
index = np.random.choice(np.where(vector == np.max(vector))[0])
except:
index = np.random.choice(np.where(vector == np.nanmax(vector))[0])
return index | Helper function to select argmax at random... not just first one. | Helper function to select argmax at random... not just first one. | [
"Helper",
"function",
"to",
"select",
"argmax",
"at",
"random",
"...",
"not",
"just",
"first",
"one",
"."
] | def random_argmax(vector):
try:
index = np.random.choice(np.where(vector == np.max(vector))[0])
except:
index = np.random.choice(np.where(vector == np.nanmax(vector))[0])
return index | [
"def",
"random_argmax",
"(",
"vector",
")",
":",
"try",
":",
"index",
"=",
"np",
".",
"random",
".",
"choice",
"(",
"np",
".",
"where",
"(",
"vector",
"==",
"np",
".",
"max",
"(",
"vector",
")",
")",
"[",
"0",
"]",
")",
"except",
":",
"index",
... | Helper function to select argmax at random... not just first one. | [
"Helper",
"function",
"to",
"select",
"argmax",
"at",
"random",
"...",
"not",
"just",
"first",
"one",
"."
] | [
"\"\"\"Helper function to select argmax at random... not just first one.\"\"\""
] | [
{
"param": "vector",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "vector",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d0317f8a334bf9631e21891416f757b78b3e499f | DemirTonchev/iambandit | arms.py | [
"MIT"
] | Python | pull | <not_specific> | def pull(self, context_vector):
"""generetate random reward with fixed p
"""
self.reward = bernuolli(self.get_expected_reward)
return self.reward | generetate random reward with fixed p
| generetate random reward with fixed p | [
"generetate",
"random",
"reward",
"with",
"fixed",
"p"
] | def pull(self, context_vector):
self.reward = bernuolli(self.get_expected_reward)
return self.reward | [
"def",
"pull",
"(",
"self",
",",
"context_vector",
")",
":",
"self",
".",
"reward",
"=",
"bernuolli",
"(",
"self",
".",
"get_expected_reward",
")",
"return",
"self",
".",
"reward"
] | generetate random reward with fixed p | [
"generetate",
"random",
"reward",
"with",
"fixed",
"p"
] | [
"\"\"\"generetate random reward with fixed p\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "context_vector",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "context_vector",
"type": null,
"docstring": null,
"docstring_... |
3e720390102348df0c442d1761a2f657ed1bfb27 | kaczmarj/grand-challenge.org | app/grandchallenge/retina_api/mixins.py | [
"Apache-2.0"
] | Python | is_in_retina_graders_group | <not_specific> | def is_in_retina_graders_group(user):
"""
Checks if the user is in the retina graders group
:param user: Django User model
:return: true/false
"""
return user.groups.filter(name=settings.RETINA_GRADERS_GROUP_NAME).exists() |
Checks if the user is in the retina graders group
:param user: Django User model
:return: true/false
| Checks if the user is in the retina graders group | [
"Checks",
"if",
"the",
"user",
"is",
"in",
"the",
"retina",
"graders",
"group"
] | def is_in_retina_graders_group(user):
return user.groups.filter(name=settings.RETINA_GRADERS_GROUP_NAME).exists() | [
"def",
"is_in_retina_graders_group",
"(",
"user",
")",
":",
"return",
"user",
".",
"groups",
".",
"filter",
"(",
"name",
"=",
"settings",
".",
"RETINA_GRADERS_GROUP_NAME",
")",
".",
"exists",
"(",
")"
] | Checks if the user is in the retina graders group | [
"Checks",
"if",
"the",
"user",
"is",
"in",
"the",
"retina",
"graders",
"group"
] | [
"\"\"\"\n Checks if the user is in the retina graders group\n :param user: Django User model\n :return: true/false\n \"\"\""
] | [
{
"param": "user",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "user",
"type": null,
"docstring": "Django User model",
"docstring_tokens": [
"Django",
"User",
... |
3e720390102348df0c442d1761a2f657ed1bfb27 | kaczmarj/grand-challenge.org | app/grandchallenge/retina_api/mixins.py | [
"Apache-2.0"
] | Python | is_in_retina_admins_group | <not_specific> | def is_in_retina_admins_group(user):
"""
Checks if the user is in the retina admins group
:param user: Django User model
:return: true/false
"""
return user.groups.filter(name=settings.RETINA_ADMINS_GROUP_NAME).exists() |
Checks if the user is in the retina admins group
:param user: Django User model
:return: true/false
| Checks if the user is in the retina admins group | [
"Checks",
"if",
"the",
"user",
"is",
"in",
"the",
"retina",
"admins",
"group"
] | def is_in_retina_admins_group(user):
return user.groups.filter(name=settings.RETINA_ADMINS_GROUP_NAME).exists() | [
"def",
"is_in_retina_admins_group",
"(",
"user",
")",
":",
"return",
"user",
".",
"groups",
".",
"filter",
"(",
"name",
"=",
"settings",
".",
"RETINA_ADMINS_GROUP_NAME",
")",
".",
"exists",
"(",
")"
] | Checks if the user is in the retina admins group | [
"Checks",
"if",
"the",
"user",
"is",
"in",
"the",
"retina",
"admins",
"group"
] | [
"\"\"\"\n Checks if the user is in the retina admins group\n :param user: Django User model\n :return: true/false\n \"\"\""
] | [
{
"param": "user",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "user",
"type": null,
"docstring": "Django User model",
"docstring_tokens": [
"Django",
"User",
... |
3e720390102348df0c442d1761a2f657ed1bfb27 | kaczmarj/grand-challenge.org | app/grandchallenge/retina_api/mixins.py | [
"Apache-2.0"
] | Python | is_in_retina_group | <not_specific> | def is_in_retina_group(user):
"""
Checks if the user is in the retina graders or retina admins group
:param user: Django User model
:return: true/false
"""
return is_in_retina_graders_group(user) or is_in_retina_admins_group(user) |
Checks if the user is in the retina graders or retina admins group
:param user: Django User model
:return: true/false
| Checks if the user is in the retina graders or retina admins group | [
"Checks",
"if",
"the",
"user",
"is",
"in",
"the",
"retina",
"graders",
"or",
"retina",
"admins",
"group"
] | def is_in_retina_group(user):
return is_in_retina_graders_group(user) or is_in_retina_admins_group(user) | [
"def",
"is_in_retina_group",
"(",
"user",
")",
":",
"return",
"is_in_retina_graders_group",
"(",
"user",
")",
"or",
"is_in_retina_admins_group",
"(",
"user",
")"
] | Checks if the user is in the retina graders or retina admins group | [
"Checks",
"if",
"the",
"user",
"is",
"in",
"the",
"retina",
"graders",
"or",
"retina",
"admins",
"group"
] | [
"\"\"\"\n Checks if the user is in the retina graders or retina admins group\n :param user: Django User model\n :return: true/false\n \"\"\""
] | [
{
"param": "user",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "user",
"type": null,
"docstring": "Django User model",
"docstring_tokens": [
"Django",
"User",
... |
1e4f81984f180d19525b0104819c91201cefcda8 | kaczmarj/grand-challenge.org | app/grandchallenge/challenges/tasks.py | [
"Apache-2.0"
] | Python | check_external_challenge_urls | null | def check_external_challenge_urls():
"""
Checks that all external challenge urls are reachable.
Emails the managers if any of the challenges are not.
"""
challenges = ExternalChallenge.objects.filter(hidden=False)
errors = []
for challenge in challenges:
try:
url = chal... |
Checks that all external challenge urls are reachable.
Emails the managers if any of the challenges are not.
| Checks that all external challenge urls are reachable.
Emails the managers if any of the challenges are not. | [
"Checks",
"that",
"all",
"external",
"challenge",
"urls",
"are",
"reachable",
".",
"Emails",
"the",
"managers",
"if",
"any",
"of",
"the",
"challenges",
"are",
"not",
"."
] | def check_external_challenge_urls():
challenges = ExternalChallenge.objects.filter(hidden=False)
errors = []
for challenge in challenges:
try:
url = challenge.homepage
if not url.startswith("http"):
url = "http://" + url
r = get(url, timeout=60)
... | [
"def",
"check_external_challenge_urls",
"(",
")",
":",
"challenges",
"=",
"ExternalChallenge",
".",
"objects",
".",
"filter",
"(",
"hidden",
"=",
"False",
")",
"errors",
"=",
"[",
"]",
"for",
"challenge",
"in",
"challenges",
":",
"try",
":",
"url",
"=",
"c... | Checks that all external challenge urls are reachable. | [
"Checks",
"that",
"all",
"external",
"challenge",
"urls",
"are",
"reachable",
"."
] | [
"\"\"\"\n Checks that all external challenge urls are reachable.\n\n Emails the managers if any of the challenges are not.\n \"\"\"",
"# raise an exception when we receive a http error (e.g., 404)"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
b43f3361cea7eb5146d927db4e087470d9fd5054 | kaczmarj/grand-challenge.org | app/tests/utils.py | [
"Apache-2.0"
] | Python | assert_viewname_status | <not_specific> | def assert_viewname_status(*, code: int, **kwargs):
"""
Assert that a viewname for challenge_short_name and pk returns status
code `code` for a particular user.
"""
response = get_view_for_user(**kwargs)
assert response.status_code == code
return response |
Assert that a viewname for challenge_short_name and pk returns status
code `code` for a particular user.
| Assert that a viewname for challenge_short_name and pk returns status
code `code` for a particular user. | [
"Assert",
"that",
"a",
"viewname",
"for",
"challenge_short_name",
"and",
"pk",
"returns",
"status",
"code",
"`",
"code",
"`",
"for",
"a",
"particular",
"user",
"."
] | def assert_viewname_status(*, code: int, **kwargs):
response = get_view_for_user(**kwargs)
assert response.status_code == code
return response | [
"def",
"assert_viewname_status",
"(",
"*",
",",
"code",
":",
"int",
",",
"**",
"kwargs",
")",
":",
"response",
"=",
"get_view_for_user",
"(",
"**",
"kwargs",
")",
"assert",
"response",
".",
"status_code",
"==",
"code",
"return",
"response"
] | Assert that a viewname for challenge_short_name and pk returns status
code `code` for a particular user. | [
"Assert",
"that",
"a",
"viewname",
"for",
"challenge_short_name",
"and",
"pk",
"returns",
"status",
"code",
"`",
"code",
"`",
"for",
"a",
"particular",
"user",
"."
] | [
"\"\"\"\n Assert that a viewname for challenge_short_name and pk returns status\n code `code` for a particular user.\n \"\"\""
] | [
{
"param": "code",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "code",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b43f3361cea7eb5146d927db4e087470d9fd5054 | kaczmarj/grand-challenge.org | app/tests/utils.py | [
"Apache-2.0"
] | Python | validate_admin_only_view | null | def validate_admin_only_view(*, two_challenge_set, client: Client, **kwargs):
"""
Assert that a view is only accessible to administrators for that
particular challenge.
"""
# No user
assert_viewname_redirect(
redirect_url=settings.LOGIN_URL,
challenge=two_challenge_set.challenge... |
Assert that a view is only accessible to administrators for that
particular challenge.
| Assert that a view is only accessible to administrators for that
particular challenge. | [
"Assert",
"that",
"a",
"view",
"is",
"only",
"accessible",
"to",
"administrators",
"for",
"that",
"particular",
"challenge",
"."
] | def validate_admin_only_view(*, two_challenge_set, client: Client, **kwargs):
assert_viewname_redirect(
redirect_url=settings.LOGIN_URL,
challenge=two_challenge_set.challenge_set_1.challenge,
client=client,
**kwargs,
)
tests = [
(403, two_challenge_set.challenge_set_1... | [
"def",
"validate_admin_only_view",
"(",
"*",
",",
"two_challenge_set",
",",
"client",
":",
"Client",
",",
"**",
"kwargs",
")",
":",
"assert_viewname_redirect",
"(",
"redirect_url",
"=",
"settings",
".",
"LOGIN_URL",
",",
"challenge",
"=",
"two_challenge_set",
".",... | Assert that a view is only accessible to administrators for that
particular challenge. | [
"Assert",
"that",
"a",
"view",
"is",
"only",
"accessible",
"to",
"administrators",
"for",
"that",
"particular",
"challenge",
"."
] | [
"\"\"\"\n Assert that a view is only accessible to administrators for that\n particular challenge.\n \"\"\"",
"# No user"
] | [
{
"param": "two_challenge_set",
"type": null
},
{
"param": "client",
"type": "Client"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "two_challenge_set",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "client",
"type": "Client",
"docstring": null,
"d... |
b43f3361cea7eb5146d927db4e087470d9fd5054 | kaczmarj/grand-challenge.org | app/tests/utils.py | [
"Apache-2.0"
] | Python | validate_admin_or_participant_view | null | def validate_admin_or_participant_view(
*, two_challenge_set, client: Client, **kwargs
):
"""
Assert that a view is only accessible to administrators or participants
of that particular challenge.
"""
# No user
assert_viewname_redirect(
redirect_url=settings.LOGIN_URL,
challe... |
Assert that a view is only accessible to administrators or participants
of that particular challenge.
| Assert that a view is only accessible to administrators or participants
of that particular challenge. | [
"Assert",
"that",
"a",
"view",
"is",
"only",
"accessible",
"to",
"administrators",
"or",
"participants",
"of",
"that",
"particular",
"challenge",
"."
] | def validate_admin_or_participant_view(
*, two_challenge_set, client: Client, **kwargs
):
assert_viewname_redirect(
redirect_url=settings.LOGIN_URL,
challenge=two_challenge_set.challenge_set_1.challenge,
client=client,
**kwargs,
)
tests = [
(403, two_challenge_set... | [
"def",
"validate_admin_or_participant_view",
"(",
"*",
",",
"two_challenge_set",
",",
"client",
":",
"Client",
",",
"**",
"kwargs",
")",
":",
"assert_viewname_redirect",
"(",
"redirect_url",
"=",
"settings",
".",
"LOGIN_URL",
",",
"challenge",
"=",
"two_challenge_se... | Assert that a view is only accessible to administrators or participants
of that particular challenge. | [
"Assert",
"that",
"a",
"view",
"is",
"only",
"accessible",
"to",
"administrators",
"or",
"participants",
"of",
"that",
"particular",
"challenge",
"."
] | [
"\"\"\"\n Assert that a view is only accessible to administrators or participants\n of that particular challenge.\n \"\"\"",
"# No user"
] | [
{
"param": "two_challenge_set",
"type": null
},
{
"param": "client",
"type": "Client"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "two_challenge_set",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "client",
"type": "Client",
"docstring": null,
"d... |
0c14ce4f2f8d89972b17a58e890467c9119be30c | kaczmarj/grand-challenge.org | app/grandchallenge/components/validators.py | [
"Apache-2.0"
] | Python | validate_safe_path | null | def validate_safe_path(value):
"""Ensures that the path is safe and normalised."""
base = "/input/"
try:
new_path = safe_join(base, value)
except SuspiciousFileOperation:
raise ValidationError("Relative paths are not allowed.")
valid_path = new_path[len(base) :]
if value != va... | Ensures that the path is safe and normalised. | Ensures that the path is safe and normalised. | [
"Ensures",
"that",
"the",
"path",
"is",
"safe",
"and",
"normalised",
"."
] | def validate_safe_path(value):
base = "/input/"
try:
new_path = safe_join(base, value)
except SuspiciousFileOperation:
raise ValidationError("Relative paths are not allowed.")
valid_path = new_path[len(base) :]
if value != valid_path:
raise ValidationError(f"Invalid file path... | [
"def",
"validate_safe_path",
"(",
"value",
")",
":",
"base",
"=",
"\"/input/\"",
"try",
":",
"new_path",
"=",
"safe_join",
"(",
"base",
",",
"value",
")",
"except",
"SuspiciousFileOperation",
":",
"raise",
"ValidationError",
"(",
"\"Relative paths are not allowed.\"... | Ensures that the path is safe and normalised. | [
"Ensures",
"that",
"the",
"path",
"is",
"safe",
"and",
"normalised",
"."
] | [
"\"\"\"Ensures that the path is safe and normalised.\"\"\""
] | [
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ba37bf81a906dda7f532488469c2c7e76d2cee99 | kaczmarj/grand-challenge.org | app/grandchallenge/reader_studies/signals.py | [
"Apache-2.0"
] | Python | update_image_permissions | <not_specific> | def update_image_permissions(instance, action, reverse, model, pk_set, **_):
"""
Assign or remove view permissions to the readers group when images
are added or remove to/from the reader study images. Handles reverse
relations and clearing.
"""
if action not in ["post_add", "post_remove", "pre_c... |
Assign or remove view permissions to the readers group when images
are added or remove to/from the reader study images. Handles reverse
relations and clearing.
| Assign or remove view permissions to the readers group when images
are added or remove to/from the reader study images. Handles reverse
relations and clearing. | [
"Assign",
"or",
"remove",
"view",
"permissions",
"to",
"the",
"readers",
"group",
"when",
"images",
"are",
"added",
"or",
"remove",
"to",
"/",
"from",
"the",
"reader",
"study",
"images",
".",
"Handles",
"reverse",
"relations",
"and",
"clearing",
"."
] | def update_image_permissions(instance, action, reverse, model, pk_set, **_):
if action not in ["post_add", "post_remove", "pre_clear"]:
return
if reverse:
images = Image.objects.filter(pk=instance.pk)
if pk_set is None:
reader_studies = instance.readerstudies.all()
el... | [
"def",
"update_image_permissions",
"(",
"instance",
",",
"action",
",",
"reverse",
",",
"model",
",",
"pk_set",
",",
"**",
"_",
")",
":",
"if",
"action",
"not",
"in",
"[",
"\"post_add\"",
",",
"\"post_remove\"",
",",
"\"pre_clear\"",
"]",
":",
"return",
"i... | Assign or remove view permissions to the readers group when images
are added or remove to/from the reader study images. | [
"Assign",
"or",
"remove",
"view",
"permissions",
"to",
"the",
"readers",
"group",
"when",
"images",
"are",
"added",
"or",
"remove",
"to",
"/",
"from",
"the",
"reader",
"study",
"images",
"."
] | [
"\"\"\"\n Assign or remove view permissions to the readers group when images\n are added or remove to/from the reader study images. Handles reverse\n relations and clearing.\n \"\"\"",
"# nothing to do for the other actions",
"# When using a _clear action, pk_set is None",
"# https://docs.djangopr... | [
{
"param": "instance",
"type": null
},
{
"param": "action",
"type": null
},
{
"param": "reverse",
"type": null
},
{
"param": "model",
"type": null
},
{
"param": "pk_set",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "instance",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "action",
"type": null,
"docstring": null,
"docstring_toke... |
fd51766fc0270cd5b84d8c8555c26e2a619a10a8 | kaczmarj/grand-challenge.org | app/grandchallenge/core/renderers.py | [
"Apache-2.0"
] | Python | flatten_data | null | def flatten_data(self, data):
"""
Create a dictionary that is 1 level deep, with nested values serialized
as json. This means that the header rows are now consistent.
"""
for row in data:
flat_row = {k: self._flatten_value(v) for k, v in row.items()}
yield... |
Create a dictionary that is 1 level deep, with nested values serialized
as json. This means that the header rows are now consistent.
| Create a dictionary that is 1 level deep, with nested values serialized
as json. This means that the header rows are now consistent. | [
"Create",
"a",
"dictionary",
"that",
"is",
"1",
"level",
"deep",
"with",
"nested",
"values",
"serialized",
"as",
"json",
".",
"This",
"means",
"that",
"the",
"header",
"rows",
"are",
"now",
"consistent",
"."
] | def flatten_data(self, data):
for row in data:
flat_row = {k: self._flatten_value(v) for k, v in row.items()}
yield flat_row | [
"def",
"flatten_data",
"(",
"self",
",",
"data",
")",
":",
"for",
"row",
"in",
"data",
":",
"flat_row",
"=",
"{",
"k",
":",
"self",
".",
"_flatten_value",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"row",
".",
"items",
"(",
")",
"}",
"yield",
"... | Create a dictionary that is 1 level deep, with nested values serialized
as json. | [
"Create",
"a",
"dictionary",
"that",
"is",
"1",
"level",
"deep",
"with",
"nested",
"values",
"serialized",
"as",
"json",
"."
] | [
"\"\"\"\n Create a dictionary that is 1 level deep, with nested values serialized\n as json. This means that the header rows are now consistent.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
c998636a3cb132b6f5c10b85fb840cb6413d5300 | kaczmarj/grand-challenge.org | app/grandchallenge/workspaces/tasks.py | [
"Apache-2.0"
] | Python | wait_for_workspace_to_start | <not_specific> | def wait_for_workspace_to_start(self, *, workspace_pk):
"""Checks if the workspace is up for up to 10 minutes."""
workspace = Workspace.objects.get(pk=workspace_pk)
if workspace.status != WorkspaceStatus.PENDING:
# Nothing to do
return
with requests.Session() as s:
_authorise(c... | Checks if the workspace is up for up to 10 minutes. | Checks if the workspace is up for up to 10 minutes. | [
"Checks",
"if",
"the",
"workspace",
"is",
"up",
"for",
"up",
"to",
"10",
"minutes",
"."
] | def wait_for_workspace_to_start(self, *, workspace_pk):
workspace = Workspace.objects.get(pk=workspace_pk)
if workspace.status != WorkspaceStatus.PENDING:
return
with requests.Session() as s:
_authorise(client=s, auth=workspace.user.workbench_token)
instance = _get_workspace(
... | [
"def",
"wait_for_workspace_to_start",
"(",
"self",
",",
"*",
",",
"workspace_pk",
")",
":",
"workspace",
"=",
"Workspace",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"workspace_pk",
")",
"if",
"workspace",
".",
"status",
"!=",
"WorkspaceStatus",
".",
"PENDI... | Checks if the workspace is up for up to 10 minutes. | [
"Checks",
"if",
"the",
"workspace",
"is",
"up",
"for",
"up",
"to",
"10",
"minutes",
"."
] | [
"\"\"\"Checks if the workspace is up for up to 10 minutes.\"\"\"",
"# Nothing to do",
"# Raises celery.exceptions.Retry",
"# TODO catch MaxRetriesExceeded?"
] | [
{
"param": "self",
"type": null
},
{
"param": "workspace_pk",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "workspace_pk",
"type": null,
"docstring": null,
"docstring_to... |
cc1ba608575aa36c1c5c8d8a229d3f2f032e9e93 | kaczmarj/grand-challenge.org | app/grandchallenge/components/backends/utils.py | [
"Apache-2.0"
] | Python | safe_extract | null | def safe_extract(*, src: File, dest: Path):
"""
Safely extracts a zip file into a directory
Any common prefixes and system files are removed.
"""
if not dest.exists():
raise RuntimeError("The destination must exist")
with src.open("rb") as f:
with zipfile.ZipFile(f) as zf:
... |
Safely extracts a zip file into a directory
Any common prefixes and system files are removed.
| Safely extracts a zip file into a directory
Any common prefixes and system files are removed. | [
"Safely",
"extracts",
"a",
"zip",
"file",
"into",
"a",
"directory",
"Any",
"common",
"prefixes",
"and",
"system",
"files",
"are",
"removed",
"."
] | def safe_extract(*, src: File, dest: Path):
if not dest.exists():
raise RuntimeError("The destination must exist")
with src.open("rb") as f:
with zipfile.ZipFile(f) as zf:
members = _filter_members(zf.infolist())
for member in members:
file_dest = Path(saf... | [
"def",
"safe_extract",
"(",
"*",
",",
"src",
":",
"File",
",",
"dest",
":",
"Path",
")",
":",
"if",
"not",
"dest",
".",
"exists",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"\"The destination must exist\"",
")",
"with",
"src",
".",
"open",
"(",
"\"rb... | Safely extracts a zip file into a directory
Any common prefixes and system files are removed. | [
"Safely",
"extracts",
"a",
"zip",
"file",
"into",
"a",
"directory",
"Any",
"common",
"prefixes",
"and",
"system",
"files",
"are",
"removed",
"."
] | [
"\"\"\"\n Safely extracts a zip file into a directory\n\n Any common prefixes and system files are removed.\n \"\"\"",
"# We know that the dest is within the prefix as",
"# safe_join is used, and the destination is already",
"# created, so ok to create the parents here"
] | [
{
"param": "src",
"type": "File"
},
{
"param": "dest",
"type": "Path"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "src",
"type": "File",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": "Path",
"docstring": null,
"docstring_tokens"... |
cc1ba608575aa36c1c5c8d8a229d3f2f032e9e93 | kaczmarj/grand-challenge.org | app/grandchallenge/components/backends/utils.py | [
"Apache-2.0"
] | Python | _filter_members | <not_specific> | def _filter_members(members: List[zipfile.ZipInfo]):
"""Filter common prefixes and uninteresting files from a zip archive"""
members = [
m.filename
for m in members
if not m.is_dir()
and re.search(r"(__MACOSX|\.DS_Store|desktop.ini)", m.filename) is None
]
# Remove any c... | Filter common prefixes and uninteresting files from a zip archive | Filter common prefixes and uninteresting files from a zip archive | [
"Filter",
"common",
"prefixes",
"and",
"uninteresting",
"files",
"from",
"a",
"zip",
"archive"
] | def _filter_members(members: List[zipfile.ZipInfo]):
members = [
m.filename
for m in members
if not m.is_dir()
and re.search(r"(__MACOSX|\.DS_Store|desktop.ini)", m.filename) is None
]
if len(members) == 1:
path = str(Path(members[0]).parent)
path = "" if path... | [
"def",
"_filter_members",
"(",
"members",
":",
"List",
"[",
"zipfile",
".",
"ZipInfo",
"]",
")",
":",
"members",
"=",
"[",
"m",
".",
"filename",
"for",
"m",
"in",
"members",
"if",
"not",
"m",
".",
"is_dir",
"(",
")",
"and",
"re",
".",
"search",
"("... | Filter common prefixes and uninteresting files from a zip archive | [
"Filter",
"common",
"prefixes",
"and",
"uninteresting",
"files",
"from",
"a",
"zip",
"archive"
] | [
"\"\"\"Filter common prefixes and uninteresting files from a zip archive\"\"\"",
"# Remove any common parent directories"
] | [
{
"param": "members",
"type": "List[zipfile.ZipInfo]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "members",
"type": "List[zipfile.ZipInfo]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d0f58d9fb7d993535e745e09de77fed14d0a0d29 | kaczmarj/grand-challenge.org | app/grandchallenge/subdomains/middleware.py | [
"Apache-2.0"
] | Python | middleware | <not_specific> | def middleware(request):
"""
Adds the challenge to the request based on the subdomain,
raising Http404 if challenge is not valid. Requires the
subdomain to be set on the request (eg, by using subdomain_middleware)
"""
subdomain = request.subdomain
if subdomain in... |
Adds the challenge to the request based on the subdomain,
raising Http404 if challenge is not valid. Requires the
subdomain to be set on the request (eg, by using subdomain_middleware)
| Adds the challenge to the request based on the subdomain,
raising Http404 if challenge is not valid. Requires the
subdomain to be set on the request | [
"Adds",
"the",
"challenge",
"to",
"the",
"request",
"based",
"on",
"the",
"subdomain",
"raising",
"Http404",
"if",
"challenge",
"is",
"not",
"valid",
".",
"Requires",
"the",
"subdomain",
"to",
"be",
"set",
"on",
"the",
"request"
] | def middleware(request):
subdomain = request.subdomain
if subdomain in [*settings.WORKSTATIONS_RENDERING_SUBDOMAINS, None]:
request.challenge = None
else:
request.challenge = get_object_or_404(
Challenge.objects.select_related("forum").prefetch_related(
... | [
"def",
"middleware",
"(",
"request",
")",
":",
"subdomain",
"=",
"request",
".",
"subdomain",
"if",
"subdomain",
"in",
"[",
"*",
"settings",
".",
"WORKSTATIONS_RENDERING_SUBDOMAINS",
",",
"None",
"]",
":",
"request",
".",
"challenge",
"=",
"None",
"else",
":... | Adds the challenge to the request based on the subdomain,
raising Http404 if challenge is not valid. | [
"Adds",
"the",
"challenge",
"to",
"the",
"request",
"based",
"on",
"the",
"subdomain",
"raising",
"Http404",
"if",
"challenge",
"is",
"not",
"valid",
"."
] | [
"\"\"\"\n Adds the challenge to the request based on the subdomain,\n raising Http404 if challenge is not valid. Requires the\n subdomain to be set on the request (eg, by using subdomain_middleware)\n \"\"\""
] | [
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c61f8622a257cd3a292b2795565d82fd0d91adbb | dearden/thesis_language_change | 4.7 - ACE/Analysis/sampling_over_time.py | [
"MIT"
] | Python | calculate_CE_per_group | <not_specific> | def calculate_CE_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
"""
Calculates the Cross-Entropy between each combination of groups.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapsho... |
Calculates the Cross-Entropy between each combination of groups.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapshots.
:param test_toks: tokens of test contributions.
:param group_names: all the names of groups.
:param all_g... | Calculates the Cross-Entropy between each combination of groups. | [
"Calculates",
"the",
"Cross",
"-",
"Entropy",
"between",
"each",
"combination",
"of",
"groups",
"."
] | def calculate_CE_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
all_groups_CE = {gname: {} for gname in group_names}
for i in range(len(group_names)):
snaps = SnapshotModelsPreset(samples[group_names[i]], all_groups_toks[i].apply(lambda x: x[:n_words_per... | [
"def",
"calculate_CE_per_group",
"(",
"samples",
",",
"test_contribs",
",",
"test_toks",
",",
"group_names",
",",
"all_groups_toks",
",",
"n_words_per_contrib",
")",
":",
"all_groups_CE",
"=",
"{",
"gname",
":",
"{",
"}",
"for",
"gname",
"in",
"group_names",
"}"... | Calculates the Cross-Entropy between each combination of groups. | [
"Calculates",
"the",
"Cross",
"-",
"Entropy",
"between",
"each",
"combination",
"of",
"groups",
"."
] | [
"\"\"\"\n Calculates the Cross-Entropy between each combination of groups.\n\n :param samples: contributions for training snapshot models.\n :param test_contribs: contributions for comparing to snapshots.\n :param test_toks: tokens of test contributions.\n :param group_names: all the names of groups.... | [
{
"param": "samples",
"type": null
},
{
"param": "test_contribs",
"type": null
},
{
"param": "test_toks",
"type": null
},
{
"param": "group_names",
"type": null
},
{
"param": "all_groups_toks",
"type": null
},
{
"param": "n_words_per_contrib",
"typ... | {
"returns": [
{
"docstring": "The Cross-Entropies of each group against the snapshot model of each group.",
"docstring_tokens": [
"The",
"Cross",
"-",
"Entropies",
"of",
"each",
"group",
"against",
"the",
"snapshot",
... |
c61f8622a257cd3a292b2795565d82fd0d91adbb | dearden/thesis_language_change | 4.7 - ACE/Analysis/sampling_over_time.py | [
"MIT"
] | Python | calculate_KLD_per_group | <not_specific> | def calculate_KLD_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
"""
Calculates the KL-Divergence between each combination of groups.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapsh... |
Calculates the KL-Divergence between each combination of groups.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapshots.
:param test_toks: tokens of test contributions.
:param group_names: all the names of groups.
:param all_g... | Calculates the KL-Divergence between each combination of groups. | [
"Calculates",
"the",
"KL",
"-",
"Divergence",
"between",
"each",
"combination",
"of",
"groups",
"."
] | def calculate_KLD_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
all_snapshots = {}
for i in range(len(group_names)):
all_snapshots[group_names[i]] = SnapshotModelsPreset(samples[group_names[i]], all_groups_toks[i].apply(lambda x: x[:n_words_per_contrib]... | [
"def",
"calculate_KLD_per_group",
"(",
"samples",
",",
"test_contribs",
",",
"test_toks",
",",
"group_names",
",",
"all_groups_toks",
",",
"n_words_per_contrib",
")",
":",
"all_snapshots",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"group_names",... | Calculates the KL-Divergence between each combination of groups. | [
"Calculates",
"the",
"KL",
"-",
"Divergence",
"between",
"each",
"combination",
"of",
"groups",
"."
] | [
"\"\"\"\n Calculates the KL-Divergence between each combination of groups.\n\n :param samples: contributions for training snapshot models.\n :param test_contribs: contributions for comparing to snapshots.\n :param test_toks: tokens of test contributions.\n :param group_names: all the names of groups.... | [
{
"param": "samples",
"type": null
},
{
"param": "test_contribs",
"type": null
},
{
"param": "test_toks",
"type": null
},
{
"param": "group_names",
"type": null
},
{
"param": "all_groups_toks",
"type": null
},
{
"param": "n_words_per_contrib",
"typ... | {
"returns": [
{
"docstring": "The KL-Divergence of each group against the snapshot model of each group.",
"docstring_tokens": [
"The",
"KL",
"-",
"Divergence",
"of",
"each",
"group",
"against",
"the",
"snapshot",
... |
c61f8622a257cd3a292b2795565d82fd0d91adbb | dearden/thesis_language_change | 4.7 - ACE/Analysis/sampling_over_time.py | [
"MIT"
] | Python | calculate_CE_fluct_per_group | <not_specific> | def calculate_CE_fluct_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
"""
Calculates the Cross-Entropy Fluctuation of each group.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapshots.... |
Calculates the Cross-Entropy Fluctuation of each group.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapshots.
:param test_toks: tokens of test contributions.
:param group_names: all the names of groups.
:param all_groups_tok... | Calculates the Cross-Entropy Fluctuation of each group. | [
"Calculates",
"the",
"Cross",
"-",
"Entropy",
"Fluctuation",
"of",
"each",
"group",
"."
] | def calculate_CE_fluct_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
all_groups_CE = {}
for i in range(len(group_names)):
snaps = SnapshotModelsPreset(samples[group_names[i]], all_groups_toks[i].apply(lambda x: x[:n_words_per_contrib]))
all_grou... | [
"def",
"calculate_CE_fluct_per_group",
"(",
"samples",
",",
"test_contribs",
",",
"test_toks",
",",
"group_names",
",",
"all_groups_toks",
",",
"n_words_per_contrib",
")",
":",
"all_groups_CE",
"=",
"{",
"}",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"group_na... | Calculates the Cross-Entropy Fluctuation of each group. | [
"Calculates",
"the",
"Cross",
"-",
"Entropy",
"Fluctuation",
"of",
"each",
"group",
"."
] | [
"\"\"\"\n Calculates the Cross-Entropy Fluctuation of each group.\n\n :param samples: contributions for training snapshot models.\n :param test_contribs: contributions for comparing to snapshots.\n :param test_toks: tokens of test contributions.\n :param group_names: all the names of groups.\n :pa... | [
{
"param": "samples",
"type": null
},
{
"param": "test_contribs",
"type": null
},
{
"param": "test_toks",
"type": null
},
{
"param": "group_names",
"type": null
},
{
"param": "all_groups_toks",
"type": null
},
{
"param": "n_words_per_contrib",
"typ... | {
"returns": [
{
"docstring": "The Cross-Entropy fluctuation of each group.",
"docstring_tokens": [
"The",
"Cross",
"-",
"Entropy",
"fluctuation",
"of",
"each",
"group",
"."
],
"type": null
}
],
"raises": [],
... |
c61f8622a257cd3a292b2795565d82fd0d91adbb | dearden/thesis_language_change | 4.7 - ACE/Analysis/sampling_over_time.py | [
"MIT"
] | Python | calculate_KLD_fluct_per_group | <not_specific> | def calculate_KLD_fluct_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
"""
Calculates the KL-Divergence Fluctuation of each group.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapshots... |
Calculates the KL-Divergence Fluctuation of each group.
:param samples: contributions for training snapshot models.
:param test_contribs: contributions for comparing to snapshots.
:param test_toks: tokens of test contributions.
:param group_names: all the names of groups.
:param all_groups_tok... | Calculates the KL-Divergence Fluctuation of each group. | [
"Calculates",
"the",
"KL",
"-",
"Divergence",
"Fluctuation",
"of",
"each",
"group",
"."
] | def calculate_KLD_fluct_per_group(samples, test_contribs, test_toks, group_names, all_groups_toks, n_words_per_contrib):
all_groups_KLD = {gname: {} for gname in group_names}
for i in range(len(group_names)):
snap = SnapshotModelsPreset(samples[group_names[i]], all_groups_toks[i].apply(lambda x: x[:n_wo... | [
"def",
"calculate_KLD_fluct_per_group",
"(",
"samples",
",",
"test_contribs",
",",
"test_toks",
",",
"group_names",
",",
"all_groups_toks",
",",
"n_words_per_contrib",
")",
":",
"all_groups_KLD",
"=",
"{",
"gname",
":",
"{",
"}",
"for",
"gname",
"in",
"group_names... | Calculates the KL-Divergence Fluctuation of each group. | [
"Calculates",
"the",
"KL",
"-",
"Divergence",
"Fluctuation",
"of",
"each",
"group",
"."
] | [
"\"\"\"\n Calculates the KL-Divergence Fluctuation of each group.\n\n :param samples: contributions for training snapshot models.\n :param test_contribs: contributions for comparing to snapshots.\n :param test_toks: tokens of test contributions.\n :param group_names: all the names of groups.\n :pa... | [
{
"param": "samples",
"type": null
},
{
"param": "test_contribs",
"type": null
},
{
"param": "test_toks",
"type": null
},
{
"param": "group_names",
"type": null
},
{
"param": "all_groups_toks",
"type": null
},
{
"param": "n_words_per_contrib",
"typ... | {
"returns": [
{
"docstring": "The KL-Divergence fluctuation of each group.",
"docstring_tokens": [
"The",
"KL",
"-",
"Divergence",
"fluctuation",
"of",
"each",
"group",
"."
],
"type": null
}
],
"raises": [],
... |
c61f8622a257cd3a292b2795565d82fd0d91adbb | dearden/thesis_language_change | 4.7 - ACE/Analysis/sampling_over_time.py | [
"MIT"
] | Python | multiple_run_sampling | <not_specific> | def multiple_run_sampling(group_names, all_groups_contribs, all_groups_toks, n_runs=5,
snap_samples_per_user=10, snap_num_users=100,
test_sample_size=1000, replace=False, n_words_per_contrib=60,
win_func=get_time_windows, win_size=360, win_st... | Runs the sampling multiple times and calculates a comparison at each run.
Performs multiple runs of sampling and calculation of comparison metric.
For each run, creates a "snapshot" sample of 1000 contributions to train a snapshot model on.
Also creates a "test" sample of 1000 contributions for which to ca... | Runs the sampling multiple times and calculates a comparison at each run.
Performs multiple runs of sampling and calculation of comparison metric.
For each run, creates a "snapshot" sample of 1000 contributions to train a snapshot model on.
Also creates a "test" sample of 1000 contributions for which to calculate a com... | [
"Runs",
"the",
"sampling",
"multiple",
"times",
"and",
"calculates",
"a",
"comparison",
"at",
"each",
"run",
".",
"Performs",
"multiple",
"runs",
"of",
"sampling",
"and",
"calculation",
"of",
"comparison",
"metric",
".",
"For",
"each",
"run",
"creates",
"a",
... | def multiple_run_sampling(group_names, all_groups_contribs, all_groups_toks, n_runs=5,
snap_samples_per_user=10, snap_num_users=100,
test_sample_size=1000, replace=False, n_words_per_contrib=60,
win_func=get_time_windows, win_size=360, win_st... | [
"def",
"multiple_run_sampling",
"(",
"group_names",
",",
"all_groups_contribs",
",",
"all_groups_toks",
",",
"n_runs",
"=",
"5",
",",
"snap_samples_per_user",
"=",
"10",
",",
"snap_num_users",
"=",
"100",
",",
"test_sample_size",
"=",
"1000",
",",
"replace",
"=",
... | Runs the sampling multiple times and calculates a comparison at each run. | [
"Runs",
"the",
"sampling",
"multiple",
"times",
"and",
"calculates",
"a",
"comparison",
"at",
"each",
"run",
"."
] | [
"\"\"\"Runs the sampling multiple times and calculates a comparison at each run.\n\n Performs multiple runs of sampling and calculation of comparison metric.\n For each run, creates a \"snapshot\" sample of 1000 contributions to train a snapshot model on.\n Also creates a \"test\" sample of 1000 contributi... | [
{
"param": "group_names",
"type": null
},
{
"param": "all_groups_contribs",
"type": null
},
{
"param": "all_groups_toks",
"type": null
},
{
"param": "n_runs",
"type": null
},
{
"param": "snap_samples_per_user",
"type": null
},
{
"param": "snap_num_user... | {
"returns": [
{
"docstring": "a list of dictionaries, one for each run. Each dictionary has another dictionary for each\ngroup which contains cross entropy results dataframes. One can find the information of a\nrun as follows: \"runs[group1][group2]\" would contain a DataFrame with the cross entropies\nof ... |
d1af64742eb9773e57b1c3f115b0362ac2bc2213 | dearden/thesis_language_change | 4.7 - ACE/Analysis/models.py | [
"MIT"
] | Python | calculate_cross_entropies_set_windows | <not_specific> | def calculate_cross_entropies_set_windows(self, contribution_windows, toks, limit=None):
"""
Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
:param contribution_windows: This is a series of dataframes (one for each window). The... |
Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
:param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.
:returns: a dictionary of the cross-entropies f... | Method for calculating the cross entropy of a given set of contributions, which has already been split into windows. | [
"Method",
"for",
"calculating",
"the",
"cross",
"entropy",
"of",
"a",
"given",
"set",
"of",
"contributions",
"which",
"has",
"already",
"been",
"split",
"into",
"windows",
"."
] | def calculate_cross_entropies_set_windows(self, contribution_windows, toks, limit=None):
cross_entropies = dict()
for window, curr_contributions in contribution_windows.items():
curr_toks = toks[curr_contributions.index]
cross_entropies[window] = curr_toks.apply(lambda x: self.sn... | [
"def",
"calculate_cross_entropies_set_windows",
"(",
"self",
",",
"contribution_windows",
",",
"toks",
",",
"limit",
"=",
"None",
")",
":",
"cross_entropies",
"=",
"dict",
"(",
")",
"for",
"window",
",",
"curr_contributions",
"in",
"contribution_windows",
".",
"it... | Method for calculating the cross entropy of a given set of contributions, which has already been split into windows. | [
"Method",
"for",
"calculating",
"the",
"cross",
"entropy",
"of",
"a",
"given",
"set",
"of",
"contributions",
"which",
"has",
"already",
"been",
"split",
"into",
"windows",
"."
] | [
"\"\"\"\n Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.\n :param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.\n :returns: a dictionary of the cro... | [
{
"param": "self",
"type": null
},
{
"param": "contribution_windows",
"type": null
},
{
"param": "toks",
"type": null
},
{
"param": "limit",
"type": null
}
] | {
"returns": [
{
"docstring": "a dictionary of the cross-entropies for each window.",
"docstring_tokens": [
"a",
"dictionary",
"of",
"the",
"cross",
"-",
"entropies",
"for",
"each",
"window",
"."
],
"ty... |
d1af64742eb9773e57b1c3f115b0362ac2bc2213 | dearden/thesis_language_change | 4.7 - ACE/Analysis/models.py | [
"MIT"
] | Python | calculate_ce_fluctuation_set_windows | <not_specific> | def calculate_ce_fluctuation_set_windows(self, contribution_windows, toks, limit=None):
"""
Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
:param contribution_windows: This is a series of dataframes (one for each window). Thes... |
Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.
:param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.
:returns: a dictionary of the cross-entropies f... | Method for calculating the cross entropy of a given set of contributions, which has already been split into windows. | [
"Method",
"for",
"calculating",
"the",
"cross",
"entropy",
"of",
"a",
"given",
"set",
"of",
"contributions",
"which",
"has",
"already",
"been",
"split",
"into",
"windows",
"."
] | def calculate_ce_fluctuation_set_windows(self, contribution_windows, toks, limit=None):
cross_entropies = dict()
all_windows = list(contribution_windows.keys())
for curr_window, next_window in zip(all_windows[:-1], all_windows[1:]):
next_contributions = contribution_windows[next_wind... | [
"def",
"calculate_ce_fluctuation_set_windows",
"(",
"self",
",",
"contribution_windows",
",",
"toks",
",",
"limit",
"=",
"None",
")",
":",
"cross_entropies",
"=",
"dict",
"(",
")",
"all_windows",
"=",
"list",
"(",
"contribution_windows",
".",
"keys",
"(",
")",
... | Method for calculating the cross entropy of a given set of contributions, which has already been split into windows. | [
"Method",
"for",
"calculating",
"the",
"cross",
"entropy",
"of",
"a",
"given",
"set",
"of",
"contributions",
"which",
"has",
"already",
"been",
"split",
"into",
"windows",
"."
] | [
"\"\"\"\n Method for calculating the cross entropy of a given set of contributions, which has already been split into windows.\n :param contribution_windows: This is a series of dataframes (one for each window). These must be the same as the snapshot windows.\n :returns: a dictionary of the cro... | [
{
"param": "self",
"type": null
},
{
"param": "contribution_windows",
"type": null
},
{
"param": "toks",
"type": null
},
{
"param": "limit",
"type": null
}
] | {
"returns": [
{
"docstring": "a dictionary of the cross-entropies for each window.",
"docstring_tokens": [
"a",
"dictionary",
"of",
"the",
"cross",
"-",
"entropies",
"for",
"each",
"window",
"."
],
"ty... |
e97c789dde7ef6db2d626e31d1214488d239a77c | dearden/thesis_language_change | 4.7 - ACE/Analysis/helper_functions.py | [
"MIT"
] | Python | tokenise | <not_specific> | def tokenise(text):
"""
Turns given text into tokens.
"""
cleaned = clean_text(text)
cleaned = re.sub(r"(\p{P})\p{P}*", r"\1 ", cleaned)
tokens = spacy_tokenise(cleaned)
return tokens |
Turns given text into tokens.
| Turns given text into tokens. | [
"Turns",
"given",
"text",
"into",
"tokens",
"."
] | def tokenise(text):
cleaned = clean_text(text)
cleaned = re.sub(r"(\p{P})\p{P}*", r"\1 ", cleaned)
tokens = spacy_tokenise(cleaned)
return tokens | [
"def",
"tokenise",
"(",
"text",
")",
":",
"cleaned",
"=",
"clean_text",
"(",
"text",
")",
"cleaned",
"=",
"re",
".",
"sub",
"(",
"r\"(\\p{P})\\p{P}*\"",
",",
"r\"\\1 \"",
",",
"cleaned",
")",
"tokens",
"=",
"spacy_tokenise",
"(",
"cleaned",
")",
"return",
... | Turns given text into tokens. | [
"Turns",
"given",
"text",
"into",
"tokens",
"."
] | [
"\"\"\"\n Turns given text into tokens.\n \"\"\""
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
e97c789dde7ef6db2d626e31d1214488d239a77c | dearden/thesis_language_change | 4.7 - ACE/Analysis/helper_functions.py | [
"MIT"
] | Python | pos_tokenise | <not_specific> | def pos_tokenise(text):
"""
Turns given text into tokens and PoS tags.
"""
cleaned = clean_text(text)
cleaned = re.sub(r"(\p{P})\p{P}*", r"\1 ", cleaned)
doc = nlp(cleaned)
return [{"tok": tok.text, "lemma":tok.lemma_, "pos": tok.pos_} for tok in doc] |
Turns given text into tokens and PoS tags.
| Turns given text into tokens and PoS tags. | [
"Turns",
"given",
"text",
"into",
"tokens",
"and",
"PoS",
"tags",
"."
] | def pos_tokenise(text):
cleaned = clean_text(text)
cleaned = re.sub(r"(\p{P})\p{P}*", r"\1 ", cleaned)
doc = nlp(cleaned)
return [{"tok": tok.text, "lemma":tok.lemma_, "pos": tok.pos_} for tok in doc] | [
"def",
"pos_tokenise",
"(",
"text",
")",
":",
"cleaned",
"=",
"clean_text",
"(",
"text",
")",
"cleaned",
"=",
"re",
".",
"sub",
"(",
"r\"(\\p{P})\\p{P}*\"",
",",
"r\"\\1 \"",
",",
"cleaned",
")",
"doc",
"=",
"nlp",
"(",
"cleaned",
")",
"return",
"[",
"... | Turns given text into tokens and PoS tags. | [
"Turns",
"given",
"text",
"into",
"tokens",
"and",
"PoS",
"tags",
"."
] | [
"\"\"\"\n Turns given text into tokens and PoS tags.\n \"\"\""
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9e7dcfef0ed4205b592b76bce7e77712c320e010 | HekpoMaH/algorithmic-concepts-reasoning | algos/models/algorithm_base.py | [
"Apache-2.0"
] | Python | calculate_step_acc | <not_specific> | def calculate_step_acc(output, output_real, batch_mask, take_total_for_classes=True):
""" Calculates the accuracy for a givens step """
output = output.squeeze(-1)
correct = 0
tot = 0
correct = output == output_real
if len(correct.shape) == 2 and take_total_for_clas... | Calculates the accuracy for a givens step | Calculates the accuracy for a givens step | [
"Calculates",
"the",
"accuracy",
"for",
"a",
"givens",
"step"
] | def calculate_step_acc(output, output_real, batch_mask, take_total_for_classes=True):
output = output.squeeze(-1)
correct = 0
tot = 0
correct = output == output_real
if len(correct.shape) == 2 and take_total_for_classes:
correct = correct.float().mean(dim=-1)
... | [
"def",
"calculate_step_acc",
"(",
"output",
",",
"output_real",
",",
"batch_mask",
",",
"take_total_for_classes",
"=",
"True",
")",
":",
"output",
"=",
"output",
".",
"squeeze",
"(",
"-",
"1",
")",
"correct",
"=",
"0",
"tot",
"=",
"0",
"correct",
"=",
"o... | Calculates the accuracy for a givens step | [
"Calculates",
"the",
"accuracy",
"for",
"a",
"givens",
"step"
] | [
"\"\"\" Calculates the accuracy for a givens step \"\"\""
] | [
{
"param": "output",
"type": null
},
{
"param": "output_real",
"type": null
},
{
"param": "batch_mask",
"type": null
},
{
"param": "take_total_for_classes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "output",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_real",
"type": null,
"docstring": null,
"docstring_t... |
9e7dcfef0ed4205b592b76bce7e77712c320e010 | HekpoMaH/algorithmic-concepts-reasoning | algos/models/algorithm_base.py | [
"Apache-2.0"
] | Python | process | null | def process(
self,
batch,
EPSILON=0,
enforced_mask=None,
extract_formulas=False,
apply_formulas=False,
fit_decision_tree=False,
apply_decision_tree=False,
compute_losses=True,
hardcode_conce... |
Method that takes a batch, does all iterations of every graph inside it
and accumulates all metrics/losses.
| Method that takes a batch, does all iterations of every graph inside it
and accumulates all metrics/losses. | [
"Method",
"that",
"takes",
"a",
"batch",
"does",
"all",
"iterations",
"of",
"every",
"graph",
"inside",
"it",
"and",
"accumulates",
"all",
"metrics",
"/",
"losses",
"."
] | def process(
self,
batch,
EPSILON=0,
enforced_mask=None,
extract_formulas=False,
apply_formulas=False,
fit_decision_tree=False,
apply_decision_tree=False,
compute_losses=True,
hardcode_concepts=None,
... | [
"def",
"process",
"(",
"self",
",",
"batch",
",",
"EPSILON",
"=",
"0",
",",
"enforced_mask",
"=",
"None",
",",
"extract_formulas",
"=",
"False",
",",
"apply_formulas",
"=",
"False",
",",
"fit_decision_tree",
"=",
"False",
",",
"apply_decision_tree",
"=",
"Fa... | Method that takes a batch, does all iterations of every graph inside it
and accumulates all metrics/losses. | [
"Method",
"that",
"takes",
"a",
"batch",
"does",
"all",
"iterations",
"of",
"every",
"graph",
"inside",
"it",
"and",
"accumulates",
"all",
"metrics",
"/",
"losses",
"."
] | [
"'''\r\n Method that takes a batch, does all iterations of every graph inside it\r\n and accumulates all metrics/losses.\r\n '''",
"# Pytorch Geometric batches along the node dimension, but we execute\r",
"# along the temporal (step) dimension, hence we need to transpose\r",
"# a few tens... | [
{
"param": "self",
"type": null
},
{
"param": "batch",
"type": null
},
{
"param": "EPSILON",
"type": null
},
{
"param": "enforced_mask",
"type": null
},
{
"param": "extract_formulas",
"type": null
},
{
"param": "apply_formulas",
"type": null
},
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "batch",
"type": null,
"docstring": null,
"docstring_tokens": ... |
5e98c987ada926da9986f661d1dc698a9986eacf | HekpoMaH/algorithmic-concepts-reasoning | algos/utils.py | [
"Apache-2.0"
] | Python | fit_decision_trees_to_algorithms | null | def fit_decision_trees_to_algorithms(algorithms):
'''
Given a list of algorithms, fit a decision tree for its
concept -> output or concept -> termination mapping
'''
for name, algorithm in algorithms.items():
algorithm.cto_decision_tree = DecisionTreeClassifier()
# concatena... |
Given a list of algorithms, fit a decision tree for its
concept -> output or concept -> termination mapping
| Given a list of algorithms, fit a decision tree for its
concept -> output or concept -> termination mapping | [
"Given",
"a",
"list",
"of",
"algorithms",
"fit",
"a",
"decision",
"tree",
"for",
"its",
"concept",
"-",
">",
"output",
"or",
"concept",
"-",
">",
"termination",
"mapping"
] | def fit_decision_trees_to_algorithms(algorithms):
for name, algorithm in algorithms.items():
algorithm.cto_decision_tree = DecisionTreeClassifier()
all_concepts = torch.cat(algorithm.actual['concepts'], dim=0)
all_target = torch.cat(algorithm.actual['outputs'], dim=0)
all_termination... | [
"def",
"fit_decision_trees_to_algorithms",
"(",
"algorithms",
")",
":",
"for",
"name",
",",
"algorithm",
"in",
"algorithms",
".",
"items",
"(",
")",
":",
"algorithm",
".",
"cto_decision_tree",
"=",
"DecisionTreeClassifier",
"(",
")",
"all_concepts",
"=",
"torch",
... | Given a list of algorithms, fit a decision tree for its
concept -> output or concept -> termination mapping | [
"Given",
"a",
"list",
"of",
"algorithms",
"fit",
"a",
"decision",
"tree",
"for",
"its",
"concept",
"-",
">",
"output",
"or",
"concept",
"-",
">",
"termination",
"mapping"
] | [
"'''\r\n Given a list of algorithms, fit a decision tree for its\r\n concept -> output or concept -> termination mapping\r\n '''",
"# concatenate concepts/predictions from each batch into one tensor\r"
] | [
{
"param": "algorithms",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "algorithms",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5e98c987ada926da9986f661d1dc698a9986eacf | HekpoMaH/algorithmic-concepts-reasoning | algos/utils.py | [
"Apache-2.0"
] | Python | add_explanations_to_algorithms | <not_specific> | def add_explanations_to_algorithms(algorithms):
'''
Given a list of algorithms, it explains each of the algorithm
outputs and adds explanations to the corresponding algorithm
'''
def check_truth_assignment(truth_assignment, indexes, dataset):
for combinations, termination in dataset:... |
Given a list of algorithms, it explains each of the algorithm
outputs and adds explanations to the corresponding algorithm
| Given a list of algorithms, it explains each of the algorithm
outputs and adds explanations to the corresponding algorithm | [
"Given",
"a",
"list",
"of",
"algorithms",
"it",
"explains",
"each",
"of",
"the",
"algorithm",
"outputs",
"and",
"adds",
"explanations",
"to",
"the",
"corresponding",
"algorithm"
] | def add_explanations_to_algorithms(algorithms):
def check_truth_assignment(truth_assignment, indexes, dataset):
for combinations, termination in dataset:
if not (truth_assignment == combinations[:, indexes]).all(axis=-1).any() == termination[0]:
return False
return True
... | [
"def",
"add_explanations_to_algorithms",
"(",
"algorithms",
")",
":",
"def",
"check_truth_assignment",
"(",
"truth_assignment",
",",
"indexes",
",",
"dataset",
")",
":",
"for",
"combinations",
",",
"termination",
"in",
"dataset",
":",
"if",
"not",
"(",
"truth_assi... | Given a list of algorithms, it explains each of the algorithm
outputs and adds explanations to the corresponding algorithm | [
"Given",
"a",
"list",
"of",
"algorithms",
"it",
"explains",
"each",
"of",
"the",
"algorithm",
"outputs",
"and",
"adds",
"explanations",
"to",
"the",
"corresponding",
"algorithm"
] | [
"'''\r\n Given a list of algorithms, it explains each of the algorithm\r\n outputs and adds explanations to the corresponding algorithm\r\n '''",
"# concatenate concepts/predictions from each batch into one tensor\r",
"# After they are all stacked up\r",
"# explain each class in turn\r",
"# and exp... | [
{
"param": "algorithms",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "algorithms",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fa922fc1eed696e325bb17cf7508b42c48220800 | HekpoMaH/algorithmic-concepts-reasoning | algos/mst/utils.py | [
"Apache-2.0"
] | Python | array_to_bits | <not_specific> | def array_to_bits(matrix: np.array, bits: int, n_ints = None):
"""
Transform an array of numbers from decimal representation to binary.
Reference: Yan, Yujun, et al. "Neural execution engines: Learning to execute subroutines." arXiv preprint arXiv:2006.08084 (2020).
https://arxiv.org/pdf/2006.0808... |
Transform an array of numbers from decimal representation to binary.
Reference: Yan, Yujun, et al. "Neural execution engines: Learning to execute subroutines." arXiv preprint arXiv:2006.08084 (2020).
https://arxiv.org/pdf/2006.08084.pdf
Page 4, Bitwise Embeddings
:param matrix: array of in... | Transform an array of numbers from decimal representation to binary.
Reference: Yan, Yujun, et al. "Neural execution engines: Learning to execute subroutines." arXiv preprint arXiv:2006.08084 (2020). | [
"Transform",
"an",
"array",
"of",
"numbers",
"from",
"decimal",
"representation",
"to",
"binary",
".",
"Reference",
":",
"Yan",
"Yujun",
"et",
"al",
".",
"\"",
"Neural",
"execution",
"engines",
":",
"Learning",
"to",
"execute",
"subroutines",
".",
"\"",
"arX... | def array_to_bits(matrix: np.array, bits: int, n_ints = None):
if n_ints is not None:
matrix = (matrix * n_ints).astype(int)
n_samples, n_features = matrix.shape
get_bin = lambda n, z: np.array(list(format(n, 'b').zfill(z))).astype(int)
x_train_bits = np.stack([get_bin(num, bits) for num_list in... | [
"def",
"array_to_bits",
"(",
"matrix",
":",
"np",
".",
"array",
",",
"bits",
":",
"int",
",",
"n_ints",
"=",
"None",
")",
":",
"if",
"n_ints",
"is",
"not",
"None",
":",
"matrix",
"=",
"(",
"matrix",
"*",
"n_ints",
")",
".",
"astype",
"(",
"int",
... | Transform an array of numbers from decimal representation to binary. | [
"Transform",
"an",
"array",
"of",
"numbers",
"from",
"decimal",
"representation",
"to",
"binary",
"."
] | [
"\"\"\"\r\n Transform an array of numbers from decimal representation to binary.\r\n\r\n Reference: Yan, Yujun, et al. \"Neural execution engines: Learning to execute subroutines.\" arXiv preprint arXiv:2006.08084 (2020).\r\n https://arxiv.org/pdf/2006.08084.pdf\r\n Page 4, Bitwise Embeddings\r\n\r\n ... | [
{
"param": "matrix",
"type": "np.array"
},
{
"param": "bits",
"type": "int"
},
{
"param": "n_ints",
"type": null
}
] | {
"returns": [
{
"docstring": "an tensor of numbers on binary.",
"docstring_tokens": [
"an",
"tensor",
"of",
"numbers",
"on",
"binary",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "matrix",
... |
cd0b074063bff07cbd6312712ef48f17455858bc | HekpoMaH/algorithmic-concepts-reasoning | algos/mst/datasets.py | [
"Apache-2.0"
] | Python | generate_dataset | <not_specific> | def generate_dataset(n_graphs: int = 30, batch_size: int = 10, n_nodes: int = 5, bits: int = 16):
"""
Generate a dataset of random graphs having the same number of nodes.
:param n_graphs: number of graphs to be generated.
:param batch_size: number of graphs per batch.
:param n_nodes: number o... |
Generate a dataset of random graphs having the same number of nodes.
:param n_graphs: number of graphs to be generated.
:param batch_size: number of graphs per batch.
:param n_nodes: number of nodes per graph.
:param bits: number of bits for bitwise encoded features.
:return: a pytorch ... | Generate a dataset of random graphs having the same number of nodes. | [
"Generate",
"a",
"dataset",
"of",
"random",
"graphs",
"having",
"the",
"same",
"number",
"of",
"nodes",
"."
] | def generate_dataset(n_graphs: int = 30, batch_size: int = 10, n_nodes: int = 5, bits: int = 16):
graph_list = []
max_n_edges = 0
for i in range(n_graphs):
db4 = n_graphs // 4
if i < db4:
generator = 'ER'
if i >= db4 and i < 2*db4:
generator = 'ladder'
... | [
"def",
"generate_dataset",
"(",
"n_graphs",
":",
"int",
"=",
"30",
",",
"batch_size",
":",
"int",
"=",
"10",
",",
"n_nodes",
":",
"int",
"=",
"5",
",",
"bits",
":",
"int",
"=",
"16",
")",
":",
"graph_list",
"=",
"[",
"]",
"max_n_edges",
"=",
"0",
... | Generate a dataset of random graphs having the same number of nodes. | [
"Generate",
"a",
"dataset",
"of",
"random",
"graphs",
"having",
"the",
"same",
"number",
"of",
"nodes",
"."
] | [
"\"\"\"\r\n Generate a dataset of random graphs having the same number of nodes.\r\n\r\n :param n_graphs: number of graphs to be generated.\r\n :param batch_size: number of graphs per batch.\r\n :param n_nodes: number of nodes per graph.\r\n :param bits: number of bits for bitwise encoded features.\r... | [
{
"param": "n_graphs",
"type": "int"
},
{
"param": "batch_size",
"type": "int"
},
{
"param": "n_nodes",
"type": "int"
},
{
"param": "bits",
"type": "int"
}
] | {
"returns": [
{
"docstring": "a pytorch data loader.",
"docstring_tokens": [
"a",
"pytorch",
"data",
"loader",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "n_graphs",
"type": "int",
"docstring":... |
e23a554f5e83319778d34517cfa6357b63d29706 | HekpoMaH/algorithmic-concepts-reasoning | algos/deterministic/JP_coloring.py | [
"Apache-2.0"
] | Python | jones_plassmann | <not_specific> | def jones_plassmann(G, num_colors=5):
'''
The below algorithm is based on:
M.T.Jones and, P.E.Plassmann, A Parallel Graph Coloring Heuristic, SIAM, Journal of Scienti c Computing 14 (1993) 654
The algorithm takes a graph (a networkx class), randomly assigns a priority
to each node and colou... |
The below algorithm is based on:
M.T.Jones and, P.E.Plassmann, A Parallel Graph Coloring Heuristic, SIAM, Journal of Scienti c Computing 14 (1993) 654
The algorithm takes a graph (a networkx class), randomly assigns a priority
to each node and colours according to the above paper. In a nutshell... | The below algorithm is based on:
M.T.Jones and, P.E.Plassmann, A Parallel Graph Coloring Heuristic, SIAM, Journal of Scienti c Computing 14 (1993) 654
The algorithm takes a graph (a networkx class), randomly assigns a priority
to each node and colours according to the above paper. In a nutshell:
assume there is a colo... | [
"The",
"below",
"algorithm",
"is",
"based",
"on",
":",
"M",
".",
"T",
".",
"Jones",
"and",
"P",
".",
"E",
".",
"Plassmann",
"A",
"Parallel",
"Graph",
"Coloring",
"Heuristic",
"SIAM",
"Journal",
"of",
"Scienti",
"c",
"Computing",
"14",
"(",
"1993",
")",... | def jones_plassmann(G, num_colors=5):
num_nodes = len(G.nodes)
priority = list({'x': x} for x in torch.randint(0, 255, (num_nodes,)).tolist())
priority = dict(zip(range(num_nodes), priority))
nx.set_node_attributes(G, priority)
G = torch_geometric.utils.from_networkx(G)
colored = torch.zeros(num... | [
"def",
"jones_plassmann",
"(",
"G",
",",
"num_colors",
"=",
"5",
")",
":",
"num_nodes",
"=",
"len",
"(",
"G",
".",
"nodes",
")",
"priority",
"=",
"list",
"(",
"{",
"'x'",
":",
"x",
"}",
"for",
"x",
"in",
"torch",
".",
"randint",
"(",
"0",
",",
... | The below algorithm is based on:
M.T.Jones and, P.E.Plassmann, A Parallel Graph Coloring Heuristic, SIAM, Journal of Scienti c Computing 14 (1993) 654 | [
"The",
"below",
"algorithm",
"is",
"based",
"on",
":",
"M",
".",
"T",
".",
"Jones",
"and",
"P",
".",
"E",
".",
"Plassmann",
"A",
"Parallel",
"Graph",
"Coloring",
"Heuristic",
"SIAM",
"Journal",
"of",
"Scienti",
"c",
"Computing",
"14",
"(",
"1993",
")",... | [
"'''\r\n\r\n The below algorithm is based on:\r\n M.T.Jones and, P.E.Plassmann, A Parallel Graph Coloring Heuristic, SIAM, Journal of Scienti c Computing 14 (1993) 654\r\n\r\n The algorithm takes a graph (a networkx class), randomly assigns a priority\r\n to each node and colours according to the above ... | [
{
"param": "G",
"type": null
},
{
"param": "num_colors",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "G",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "num_colors",
"type": null,
"docstring": null,
"docstring_tokens"... |
41a29363f86e7296eec59235daaba79bf5e4120b | HekpoMaH/algorithmic-concepts-reasoning | algos/mst/deterministic.py | [
"Apache-2.0"
] | Python | to_data | <not_specific> | def to_data(self, max_time=10, bits=16):
"""
Padding arrays and return nice tensors.
For node tensors:
1st dimension: number of nodes
2nd dimension: number of time steps
3rd dimension: others
For edge tensors:
1st dimension: 1 (batc... |
Padding arrays and return nice tensors.
For node tensors:
1st dimension: number of nodes
2nd dimension: number of time steps
3rd dimension: others
For edge tensors:
1st dimension: 1 (batch dimension)
2nd dimension: number of ed... | Padding arrays and return nice tensors. | [
"Padding",
"arrays",
"and",
"return",
"nice",
"tensors",
"."
] | def to_data(self, max_time=10, bits=16):
self.edge_index = self.edge_index.transpose(2, 0, 1)
self.edge_index = pad_time(self.edge_index,
(self.edge_index.shape[0], max_time,
self.edge_index.shape[2]))
def stupid_stupid_pad(p... | [
"def",
"to_data",
"(",
"self",
",",
"max_time",
"=",
"10",
",",
"bits",
"=",
"16",
")",
":",
"self",
".",
"edge_index",
"=",
"self",
".",
"edge_index",
".",
"transpose",
"(",
"2",
",",
"0",
",",
"1",
")",
"self",
".",
"edge_index",
"=",
"pad_time",... | Padding arrays and return nice tensors. | [
"Padding",
"arrays",
"and",
"return",
"nice",
"tensors",
"."
] | [
"\"\"\"\r\n Padding arrays and return nice tensors.\r\n For node tensors:\r\n 1st dimension: number of nodes\r\n 2nd dimension: number of time steps\r\n 3rd dimension: others\r\n For edge tensors:\r\n 1st dimension: 1 (batch dimension)\r\n ... | [
{
"param": "self",
"type": null
},
{
"param": "max_time",
"type": null
},
{
"param": "bits",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
7320d030886eeda7a3cf763d8126e0d1a4c9a866 | HekpoMaH/algorithmic-concepts-reasoning | algos/deterministic/BFS.py | [
"Apache-2.0"
] | Python | do_BFS | <not_specific> | def do_BFS(num_nodes, edge_index, start_node=0):
'''
A method that given a graph of size |num_nodes| and edges as edge_index
generates a datapoint for the BFS algorithm
'''
vis = torch.zeros(num_nodes, dtype=torch.bool)
vis[start_node] = 1
# Concept encoding (a node that is classi... |
A method that given a graph of size |num_nodes| and edges as edge_index
generates a datapoint for the BFS algorithm
| A method that given a graph of size |num_nodes| and edges as edge_index
generates a datapoint for the BFS algorithm | [
"A",
"method",
"that",
"given",
"a",
"graph",
"of",
"size",
"|num_nodes|",
"and",
"edges",
"as",
"edge_index",
"generates",
"a",
"datapoint",
"for",
"the",
"BFS",
"algorithm"
] | def do_BFS(num_nodes, edge_index, start_node=0):
vis = torch.zeros(num_nodes, dtype=torch.bool)
vis[start_node] = 1
concepts = torch.zeros((num_nodes, 2), dtype=torch.int)
all_vis = []
all_target_vis = []
all_target_concepts = []
all_target_concepts_fin = []
all_term = []
ei, _ = tor... | [
"def",
"do_BFS",
"(",
"num_nodes",
",",
"edge_index",
",",
"start_node",
"=",
"0",
")",
":",
"vis",
"=",
"torch",
".",
"zeros",
"(",
"num_nodes",
",",
"dtype",
"=",
"torch",
".",
"bool",
")",
"vis",
"[",
"start_node",
"]",
"=",
"1",
"concepts",
"=",
... | A method that given a graph of size |num_nodes| and edges as edge_index
generates a datapoint for the BFS algorithm | [
"A",
"method",
"that",
"given",
"a",
"graph",
"of",
"size",
"|num_nodes|",
"and",
"edges",
"as",
"edge_index",
"generates",
"a",
"datapoint",
"for",
"the",
"BFS",
"algorithm"
] | [
"'''\r\n A method that given a graph of size |num_nodes| and edges as edge_index\r\n generates a datapoint for the BFS algorithm\r\n '''",
"# Concept encoding (a node that is classified as False = unvisited, True = visited)\r",
"# f0 = node is vis or not\r",
"# f1 = node has vis neighbour\r",
"# Fa... | [
{
"param": "num_nodes",
"type": null
},
{
"param": "edge_index",
"type": null
},
{
"param": "start_node",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "num_nodes",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "edge_index",
"type": null,
"docstring": null,
"docstring... |
efd14bad3862a768cae695ff816e251c13b161c8 | maneeshd/braintree_python | braintree/transparent_redirect_gateway.py | [
"MIT"
] | Python | confirm | <not_specific> | def confirm(self, query_string):
"""
Confirms a transparent redirect request. It expects the query string from the
redirect request. The query string should _not_ include the leading "?" character. ::
result = braintree.TransparentRedirect.confirm("foo=bar&id=12345")
"""
... |
Confirms a transparent redirect request. It expects the query string from the
redirect request. The query string should _not_ include the leading "?" character. ::
result = braintree.TransparentRedirect.confirm("foo=bar&id=12345")
| Confirms a transparent redirect request. It expects the query string from the
redirect request. The query string should _not_ include the leading "?" character.
| [
"Confirms",
"a",
"transparent",
"redirect",
"request",
".",
"It",
"expects",
"the",
"query",
"string",
"from",
"the",
"redirect",
"request",
".",
"The",
"query",
"string",
"should",
"_not_",
"include",
"the",
"leading",
"\"",
"?",
"\"",
"character",
"."
] | def confirm(self, query_string):
parsed_query_string = self._parse_and_validate_query_string(query_string)
confirmation_gateway = {
TransparentRedirect.Kind.CreateCustomer: "customer",
TransparentRedirect.Kind.UpdateCustomer: "customer",
TransparentRedirect.Kind.Creat... | [
"def",
"confirm",
"(",
"self",
",",
"query_string",
")",
":",
"parsed_query_string",
"=",
"self",
".",
"_parse_and_validate_query_string",
"(",
"query_string",
")",
"confirmation_gateway",
"=",
"{",
"TransparentRedirect",
".",
"Kind",
".",
"CreateCustomer",
":",
"\"... | Confirms a transparent redirect request. | [
"Confirms",
"a",
"transparent",
"redirect",
"request",
"."
] | [
"\"\"\"\n Confirms a transparent redirect request. It expects the query string from the\n redirect request. The query string should _not_ include the leading \"?\" character. ::\n\n result = braintree.TransparentRedirect.confirm(\"foo=bar&id=12345\")\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query_string",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query_string",
"type": null,
"docstring": null,
"docstring_to... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.