Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
MatrixTestCase.testScaleNonArray | (self) | Test scale function with non-array | Test scale function with non-array | def testScaleNonArray(self):
"Test scale function with non-array"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
scale = Matrix.__dict__[self.typeStr + "Scale"]
matrix = [[1, 2, 3], [2, 1, 2], [3, 2, 1]]
self.assertRaises(TypeError, scale, matrix) | [
"def",
"testScaleNonArray",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"scale",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
159,
4
] | [
164,
51
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testFloor | (self) | Test floor function | Test floor function | def testFloor(self):
"Test floor function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Matrix.__dict__[self.typeStr + "Floor"]
matrix = np.array([[6, 7], [8, 9]], self.typeCode)
floor(matrix, 7)
np.testing.assert_array_equal(matrix, np.array([[7, 7], [8,... | [
"def",
"testFloor",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Flo... | [
167,
4
] | [
173,
73
] | python | nl | ['nl', 'nl', 'en'] | True |
MatrixTestCase.testFloorWrongDim | (self) | Test floor function with wrong dimensions | Test floor function with wrong dimensions | def testFloorWrongDim(self):
"Test floor function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Matrix.__dict__[self.typeStr + "Floor"]
matrix = np.array([6, 7, 8, 9], self.typeCode)
self.assertRaises(TypeError, floor, matrix) | [
"def",
"testFloorWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
176,
4
] | [
181,
51
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testFloorWrongType | (self) | Test floor function with wrong type | Test floor function with wrong type | def testFloorWrongType(self):
"Test floor function with wrong type"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Matrix.__dict__[self.typeStr + "Floor"]
matrix = np.array([[6, 7], [8, 9]], 'c')
self.assertRaises(TypeError, floor, matrix) | [
"def",
"testFloorWrongType",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",... | [
184,
4
] | [
189,
51
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testFloorNonArray | (self) | Test floor function with non-array | Test floor function with non-array | def testFloorNonArray(self):
"Test floor function with non-array"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
floor = Matrix.__dict__[self.typeStr + "Floor"]
matrix = [[6, 7], [8, 9]]
self.assertRaises(TypeError, floor, matrix) | [
"def",
"testFloorNonArray",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"floor",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
192,
4
] | [
197,
51
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testCeil | (self) | Test ceil function | Test ceil function | def testCeil(self):
"Test ceil function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
ceil = Matrix.__dict__[self.typeStr + "Ceil"]
matrix = np.array([[1, 2], [3, 4]], self.typeCode)
ceil(matrix, 3)
np.testing.assert_array_equal(matrix, np.array([[1, 2], [3, 3]])... | [
"def",
"testCeil",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"ceil",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\"Ceil\... | [
200,
4
] | [
206,
73
] | python | en | ['nb', 'fr', 'en'] | False |
MatrixTestCase.testCeilWrongDim | (self) | Test ceil function with wrong dimensions | Test ceil function with wrong dimensions | def testCeilWrongDim(self):
"Test ceil function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
ceil = Matrix.__dict__[self.typeStr + "Ceil"]
matrix = np.array([1, 2, 3, 4], self.typeCode)
self.assertRaises(TypeError, ceil, matrix) | [
"def",
"testCeilWrongDim",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"ceil",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
209,
4
] | [
214,
50
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testCeilWrongType | (self) | Test ceil function with wrong dimensions | Test ceil function with wrong dimensions | def testCeilWrongType(self):
"Test ceil function with wrong dimensions"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
ceil = Matrix.__dict__[self.typeStr + "Ceil"]
matrix = np.array([[1, 2], [3, 4]], 'c')
self.assertRaises(TypeError, ceil, matrix) | [
"def",
"testCeilWrongType",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"ceil",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
217,
4
] | [
222,
50
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testCeilNonArray | (self) | Test ceil function with non-array | Test ceil function with non-array | def testCeilNonArray(self):
"Test ceil function with non-array"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
ceil = Matrix.__dict__[self.typeStr + "Ceil"]
matrix = [[1, 2], [3, 4]]
self.assertRaises(TypeError, ceil, matrix) | [
"def",
"testCeilNonArray",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"ceil",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
... | [
225,
4
] | [
230,
50
] | python | en | ['en', 'en', 'en'] | True |
MatrixTestCase.testLUSplit | (self) | Test luSplit function | Test luSplit function | def testLUSplit(self):
"Test luSplit function"
print(self.typeStr, "... ", end=' ', file=sys.stderr)
luSplit = Matrix.__dict__[self.typeStr + "LUSplit"]
lower, upper = luSplit([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
self.assertEqual((lower == [[1, 0, 0], [4, 5, 0], [7, 8, 9]]).all(), ... | [
"def",
"testLUSplit",
"(",
"self",
")",
":",
"print",
"(",
"self",
".",
"typeStr",
",",
"\"... \"",
",",
"end",
"=",
"' '",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"luSplit",
"=",
"Matrix",
".",
"__dict__",
"[",
"self",
".",
"typeStr",
"+",
"\... | [
233,
4
] | [
239,
82
] | python | en | ['en', 'no', 'en'] | True |
TrainerDataLoadingMixin.reset_train_dataloader | (self, model: LightningModule) | Resets the train dataloader and initialises required variables
(number of batches, when to validate, etc.).
Args:
model: The current `LightningModule`
| Resets the train dataloader and initialises required variables
(number of batches, when to validate, etc.). | def reset_train_dataloader(self, model: LightningModule) -> None:
"""Resets the train dataloader and initialises required variables
(number of batches, when to validate, etc.).
Args:
model: The current `LightningModule`
"""
self.train_dataloader = self.request_datalo... | [
"def",
"reset_train_dataloader",
"(",
"self",
",",
"model",
":",
"LightningModule",
")",
"->",
"None",
":",
"self",
".",
"train_dataloader",
"=",
"self",
".",
"request_dataloader",
"(",
"model",
".",
"train_dataloader",
")",
"if",
"self",
".",
"overfit_batches",... | [
190,
4
] | [
259,
67
] | python | en | ['en', 'en', 'en'] | True |
TrainerDataLoadingMixin._reset_eval_dataloader | (
self,
model: LightningModule,
mode: str,
) | Generic method to reset a dataloader for evaluation.
Args:
model: The current `LightningModule`
mode: Either `'val'` or `'test'`
Returns:
Tuple (num_batches, dataloaders)
| Generic method to reset a dataloader for evaluation. | def _reset_eval_dataloader(
self,
model: LightningModule,
mode: str,
) -> Tuple[List[Union[int, float]], List[DataLoader]]:
"""Generic method to reset a dataloader for evaluation.
Args:
model: The current `LightningModule`
mode: Either `'val'` or `'te... | [
"def",
"_reset_eval_dataloader",
"(",
"self",
",",
"model",
":",
"LightningModule",
",",
"mode",
":",
"str",
",",
")",
"->",
"Tuple",
"[",
"List",
"[",
"Union",
"[",
"int",
",",
"float",
"]",
"]",
",",
"List",
"[",
"DataLoader",
"]",
"]",
":",
"# alw... | [
261,
4
] | [
352,
46
] | python | en | ['en', 'en', 'en'] | True |
TrainerDataLoadingMixin.reset_val_dataloader | (self, model: LightningModule) | Resets the validation dataloader and determines the number of batches.
Args:
model: The current `LightningModule`
| Resets the validation dataloader and determines the number of batches. | def reset_val_dataloader(self, model: LightningModule) -> None:
"""Resets the validation dataloader and determines the number of batches.
Args:
model: The current `LightningModule`
"""
has_loader = is_overridden('val_dataloader', model)
has_step = is_overridden('vali... | [
"def",
"reset_val_dataloader",
"(",
"self",
",",
"model",
":",
"LightningModule",
")",
"->",
"None",
":",
"has_loader",
"=",
"is_overridden",
"(",
"'val_dataloader'",
",",
"model",
")",
"has_step",
"=",
"is_overridden",
"(",
"'validation_step'",
",",
"model",
")... | [
354,
4
] | [
363,
98
] | python | en | ['en', 'en', 'en'] | True |
TrainerDataLoadingMixin.reset_test_dataloader | (self, model) | Resets the test dataloader and determines the number of batches.
Args:
model: The current `LightningModule`
| Resets the test dataloader and determines the number of batches. | def reset_test_dataloader(self, model) -> None:
"""Resets the test dataloader and determines the number of batches.
Args:
model: The current `LightningModule`
"""
has_loader = is_overridden('test_dataloader', model)
has_step = is_overridden('test_step', model)
... | [
"def",
"reset_test_dataloader",
"(",
"self",
",",
"model",
")",
"->",
"None",
":",
"has_loader",
"=",
"is_overridden",
"(",
"'test_dataloader'",
",",
"model",
")",
"has_step",
"=",
"is_overridden",
"(",
"'test_step'",
",",
"model",
")",
"if",
"has_loader",
"an... | [
365,
4
] | [
375,
58
] | python | en | ['en', 'en', 'en'] | True |
TrainerDataLoadingMixin.reset_predict_dataloader | (self, model) | Resets the predict dataloader and determines the number of batches.
Args:
model: The current `LightningModule`
| Resets the predict dataloader and determines the number of batches. | def reset_predict_dataloader(self, model) -> None:
"""Resets the predict dataloader and determines the number of batches.
Args:
model: The current `LightningModule`
"""
has_loader = is_overridden('predict_dataloader', model)
if has_loader:
self.num_predic... | [
"def",
"reset_predict_dataloader",
"(",
"self",
",",
"model",
")",
"->",
"None",
":",
"has_loader",
"=",
"is_overridden",
"(",
"'predict_dataloader'",
",",
"model",
")",
"if",
"has_loader",
":",
"self",
".",
"num_predict_batches",
",",
"self",
".",
"predict_data... | [
377,
4
] | [
386,
61
] | python | en | ['en', 'en', 'en'] | True |
TrainerDataLoadingMixin.request_dataloader | (self, dataloader_fx: Callable) | Handles downloading data in the GPU or TPU case.
Args:
dataloader_fx: The bound dataloader getter
Returns:
The dataloader
| Handles downloading data in the GPU or TPU case. | def request_dataloader(self, dataloader_fx: Callable) -> DataLoader:
"""Handles downloading data in the GPU or TPU case.
Args:
dataloader_fx: The bound dataloader getter
Returns:
The dataloader
"""
dataloader = dataloader_fx()
dataloader = self._... | [
"def",
"request_dataloader",
"(",
"self",
",",
"dataloader_fx",
":",
"Callable",
")",
"->",
"DataLoader",
":",
"dataloader",
"=",
"dataloader_fx",
"(",
")",
"dataloader",
"=",
"self",
".",
"_flatten_dl_only",
"(",
"dataloader",
")",
"self",
".",
"accelerator",
... | [
388,
4
] | [
401,
25
] | python | en | ['en', 'en', 'en'] | True |
PasswdFilter.filter | (self, record) | Modify record in-place | Modify record in-place | def filter(self, record):
""" Modify record in-place """
if isinstance(record.args, tuple):
record.args = tuple(self._masquerade(arg) for arg in record.args)
else:
record.args = self._masquerade(record.args)
return True | [
"def",
"filter",
"(",
"self",
",",
"record",
")",
":",
"if",
"isinstance",
"(",
"record",
".",
"args",
",",
"tuple",
")",
":",
"record",
".",
"args",
"=",
"tuple",
"(",
"self",
".",
"_masquerade",
"(",
"arg",
")",
"for",
"arg",
"in",
"record",
".",... | [
40,
4
] | [
46,
19
] | python | en | ['en', 'it', 'en'] | True |
PasswdFilter._masquerade | (arg) | Replace password by stars | Replace password by stars | def _masquerade(arg):
""" Replace password by stars """
if isinstance(arg, dict):
for key in ('credential', 'password'):
if key in arg:
arg = arg.copy()
arg[key] = '*' * len(arg[key])
return arg | [
"def",
"_masquerade",
"(",
"arg",
")",
":",
"if",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"for",
"key",
"in",
"(",
"'credential'",
",",
"'password'",
")",
":",
"if",
"key",
"in",
"arg",
":",
"arg",
"=",
"arg",
".",
"copy",
"(",
")",
"arg... | [
49,
4
] | [
56,
18
] | python | en | ['en', 'en', 'en'] | True |
Tesla.request | (self, method, uri, data=None, **kwargs) | Extends base class method to support bearer token insertion. Raises
HTTPError when an error occurs.
:rtype: JsonDict
| Extends base class method to support bearer token insertion. Raises
HTTPError when an error occurs.
:rtype: JsonDict
| def request(self, method, uri, data=None, **kwargs):
""" Extends base class method to support bearer token insertion. Raises
HTTPError when an error occurs.
:rtype: JsonDict
"""
# Auto refresh token and insert access token into headers
if self.authorized:
... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"uri",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Auto refresh token and insert access token into headers\r",
"if",
"self",
".",
"authorized",
":",
"if",
"0",
"<",
"self",
".",
"expires_... | [
109,
4
] | [
136,
50
] | python | en | ['en', 'lb', 'en'] | True |
Tesla.fetch_token | (self) | Sign in using Tesla's SSO service to request a JWT bearer. Raises
HTTPError, CustomOAuth2Error or ValueError. | Sign in using Tesla's SSO service to request a JWT bearer. Raises
HTTPError, CustomOAuth2Error or ValueError. | def fetch_token(self):
""" Sign in using Tesla's SSO service to request a JWT bearer. Raises
HTTPError, CustomOAuth2Error or ValueError. """
if self.authorized:
return
if not self.password:
raise ValueError('`password` is not set')
# Generate code v... | [
"def",
"fetch_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"authorized",
":",
"return",
"if",
"not",
"self",
".",
"password",
":",
"raise",
"ValueError",
"(",
"'`password` is not set'",
")",
"# Generate code verifier and challenge for PKCE (RFC 7636)\r",
"code_ve... | [
138,
4
] | [
186,
30
] | python | en | ['en', 'en', 'en'] | True |
Tesla._check_mfa | (self, oauth, transaction_id) | Handle multi-factor authentication and return submitted response | Handle multi-factor authentication and return submitted response | def _check_mfa(self, oauth, transaction_id):
""" Handle multi-factor authentication and return submitted response """
# Check for MFA factors
url = self.sso_base + 'oauth2/v3/authorize/mfa/factors'
response = oauth.get(url, params={'transaction_id': transaction_id})
response... | [
"def",
"_check_mfa",
"(",
"self",
",",
"oauth",
",",
"transaction_id",
")",
":",
"# Check for MFA factors\r",
"url",
"=",
"self",
".",
"sso_base",
"+",
"'oauth2/v3/authorize/mfa/factors'",
"response",
"=",
"oauth",
".",
"get",
"(",
"url",
",",
"params",
"=",
"... | [
188,
4
] | [
240,
48
] | python | en | ['en', 'en', 'en'] | True |
Tesla._fetch_jwt | (self, oauth) | Perform RFC 7523 JSON web token exchange for Owner API access | Perform RFC 7523 JSON web token exchange for Owner API access | def _fetch_jwt(self, oauth):
""" Perform RFC 7523 JSON web token exchange for Owner API access """
data = {'grant_type': 'urn:ietf:params:oauth:grant-type:jwt-bearer',
'client_id': CLIENT_ID}
response = oauth.post(BASE_URL + 'oauth/token', data=data)
response.raise_f... | [
"def",
"_fetch_jwt",
"(",
"self",
",",
"oauth",
")",
":",
"data",
"=",
"{",
"'grant_type'",
":",
"'urn:ietf:params:oauth:grant-type:jwt-bearer'",
",",
"'client_id'",
":",
"CLIENT_ID",
"}",
"response",
"=",
"oauth",
".",
"post",
"(",
"BASE_URL",
"+",
"'oauth/toke... | [
242,
4
] | [
253,
29
] | python | da | ['no', 'da', 'en'] | False |
Tesla._token_updater | (self) | Handles token persistency | Handles token persistency | def _token_updater(self):
""" Handles token persistency """
# Open cache file
try:
with open('cache.json') as infile:
cache = json.load(infile)
except (IOError, ValueError):
cache = {}
# Write token to cache file
if self.au... | [
"def",
"_token_updater",
"(",
"self",
")",
":",
"# Open cache file\r",
"try",
":",
"with",
"open",
"(",
"'cache.json'",
")",
"as",
"infile",
":",
"cache",
"=",
"json",
".",
"load",
"(",
"infile",
")",
"except",
"(",
"IOError",
",",
"ValueError",
")",
":"... | [
255,
4
] | [
289,
57
] | python | nl | ['nl', 'nl', 'en'] | True |
Tesla.refresh_token | (self) | Refreshes the SSO token and requests a new JWT bearer | Refreshes the SSO token and requests a new JWT bearer | def refresh_token(self):
""" Refreshes the SSO token and requests a new JWT bearer """
if not self.sso_token:
return
# Prepare session for token refresh
oauth = OAuth2Session(client_id=SSO_CLIENT_ID, token=self.sso_token,
scope=('openid', '... | [
"def",
"refresh_token",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"sso_token",
":",
"return",
"# Prepare session for token refresh\r",
"oauth",
"=",
"OAuth2Session",
"(",
"client_id",
"=",
"SSO_CLIENT_ID",
",",
"token",
"=",
"self",
".",
"sso_token",
",",... | [
291,
4
] | [
305,
30
] | python | en | ['en', 'en', 'en'] | True |
Tesla.api | (self, name, path_vars=None, **kwargs) | Convenience method to perform API request for given endpoint name,
with keyword arguments as parameters. Substitutes path variables in URI
using path_vars. Raises ValueError if endpoint name is not found.
:rtype: JsonDict
| Convenience method to perform API request for given endpoint name,
with keyword arguments as parameters. Substitutes path variables in URI
using path_vars. Raises ValueError if endpoint name is not found.
:rtype: JsonDict
| def api(self, name, path_vars=None, **kwargs):
""" Convenience method to perform API request for given endpoint name,
with keyword arguments as parameters. Substitutes path variables in URI
using path_vars. Raises ValueError if endpoint name is not found.
:rtype: JsonDict
... | [
"def",
"api",
"(",
"self",
",",
"name",
",",
"path_vars",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"path_vars",
"=",
"path_vars",
"or",
"{",
"}",
"# Load API endpoints once\r",
"if",
"not",
"self",
".",
"endpoints",
":",
"try",
":",
"data",
"=",... | [
307,
4
] | [
341,
63
] | python | en | ['en', 'en', 'en'] | True |
Tesla.vehicle_list | (self) | Returns a list of :class: Vehicle <Vehicle> objects | Returns a list of :class: Vehicle <Vehicle> objects | def vehicle_list(self):
""" Returns a list of :class: Vehicle <Vehicle> objects """
return [Vehicle(v, self) for v in self.api('VEHICLE_LIST')['response']] | [
"def",
"vehicle_list",
"(",
"self",
")",
":",
"return",
"[",
"Vehicle",
"(",
"v",
",",
"self",
")",
"for",
"v",
"in",
"self",
".",
"api",
"(",
"'VEHICLE_LIST'",
")",
"[",
"'response'",
"]",
"]"
] | [
343,
4
] | [
345,
79
] | python | en | ['en', 'en', 'en'] | True |
Tesla.battery_list | (self) | Returns a list of :class: Battery <Battery> objects | Returns a list of :class: Battery <Battery> objects | def battery_list(self):
""" Returns a list of :class: Battery <Battery> objects """
return [Battery(p, self) for p in self.api('PRODUCT_LIST')['response']
if p.get('resource_type') == 'battery'] | [
"def",
"battery_list",
"(",
"self",
")",
":",
"return",
"[",
"Battery",
"(",
"p",
",",
"self",
")",
"for",
"p",
"in",
"self",
".",
"api",
"(",
"'PRODUCT_LIST'",
")",
"[",
"'response'",
"]",
"if",
"p",
".",
"get",
"(",
"'resource_type'",
")",
"==",
... | [
347,
4
] | [
350,
55
] | python | en | ['en', 'lb', 'en'] | True |
HTMLForm.handle_starttag | (self, tag, attrs) | Make dictionary of name and value attributes of input tags | Make dictionary of name and value attributes of input tags | def handle_starttag(self, tag, attrs):
""" Make dictionary of name and value attributes of input tags """
if tag == 'input':
self[dict(attrs)['name']] = dict(attrs).get('value', '') | [
"def",
"handle_starttag",
"(",
"self",
",",
"tag",
",",
"attrs",
")",
":",
"if",
"tag",
"==",
"'input'",
":",
"self",
"[",
"dict",
"(",
"attrs",
")",
"[",
"'name'",
"]",
"]",
"=",
"dict",
"(",
"attrs",
")",
".",
"get",
"(",
"'value'",
",",
"''",
... | [
360,
4
] | [
363,
68
] | python | en | ['en', 'en', 'en'] | True |
JsonDict.__str__ | (self) | Serialize dict to JSON formatted string with indents | Serialize dict to JSON formatted string with indents | def __str__(self):
""" Serialize dict to JSON formatted string with indents """
return json.dumps(self, indent=4) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"self",
",",
"indent",
"=",
"4",
")"
] | [
374,
4
] | [
376,
41
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.api | (self, name, **kwargs) | Endpoint request with vehicle_id path variable | Endpoint request with vehicle_id path variable | def api(self, name, **kwargs):
""" Endpoint request with vehicle_id path variable """
return self.tesla.api(name, {'vehicle_id': self['id_s']}, **kwargs) | [
"def",
"api",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"tesla",
".",
"api",
"(",
"name",
",",
"{",
"'vehicle_id'",
":",
"self",
"[",
"'id_s'",
"]",
"}",
",",
"*",
"*",
"kwargs",
")"
] | [
388,
4
] | [
390,
75
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.get_vehicle_summary | (self) | Determine the state of the vehicle's various sub-systems | Determine the state of the vehicle's various sub-systems | def get_vehicle_summary(self):
""" Determine the state of the vehicle's various sub-systems """
self.update(self.api('VEHICLE_SUMMARY')['response'])
return self | [
"def",
"get_vehicle_summary",
"(",
"self",
")",
":",
"self",
".",
"update",
"(",
"self",
".",
"api",
"(",
"'VEHICLE_SUMMARY'",
")",
"[",
"'response'",
"]",
")",
"return",
"self"
] | [
392,
4
] | [
395,
19
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.sync_wake_up | (self, timeout=60, interval=2, backoff=1.15) | Wakes up vehicle if needed and waits for it to come online | Wakes up vehicle if needed and waits for it to come online | def sync_wake_up(self, timeout=60, interval=2, backoff=1.15):
""" Wakes up vehicle if needed and waits for it to come online """
logger.info('%s is %s', self['display_name'], self['state'])
if self['state'] != 'online':
self.api('WAKE_UP') # Send wake up command
sta... | [
"def",
"sync_wake_up",
"(",
"self",
",",
"timeout",
"=",
"60",
",",
"interval",
"=",
"2",
",",
"backoff",
"=",
"1.15",
")",
":",
"logger",
".",
"info",
"(",
"'%s is %s'",
",",
"self",
"[",
"'display_name'",
"]",
",",
"self",
"[",
"'state'",
"]",
")",... | [
397,
4
] | [
413,
72
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.option_code_list | (self) | Returns a list of known option code titles | Returns a list of known option code titles | def option_code_list(self):
""" Returns a list of known option code titles """
# Load option codes once
if Vehicle.codes is None:
try:
data = pkgutil.get_data(__name__, 'option_codes.json')
Vehicle.codes = json.loads(data.decode())
... | [
"def",
"option_code_list",
"(",
"self",
")",
":",
"# Load option codes once\r",
"if",
"Vehicle",
".",
"codes",
"is",
"None",
":",
"try",
":",
"data",
"=",
"pkgutil",
".",
"get_data",
"(",
"__name__",
",",
"'option_codes.json'",
")",
"Vehicle",
".",
"codes",
... | [
415,
4
] | [
428,
49
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.get_vehicle_data | (self) | A rollup of all the data request endpoints plus vehicle config | A rollup of all the data request endpoints plus vehicle config | def get_vehicle_data(self):
""" A rollup of all the data request endpoints plus vehicle config """
self.update(self.api('VEHICLE_DATA')['response'])
return self | [
"def",
"get_vehicle_data",
"(",
"self",
")",
":",
"self",
".",
"update",
"(",
"self",
".",
"api",
"(",
"'VEHICLE_DATA'",
")",
"[",
"'response'",
"]",
")",
"return",
"self"
] | [
430,
4
] | [
433,
19
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.get_nearby_charging_sites | (self) | Lists nearby Tesla-operated charging stations | Lists nearby Tesla-operated charging stations | def get_nearby_charging_sites(self):
""" Lists nearby Tesla-operated charging stations """
return self.api('NEARBY_CHARGING_SITES')['response'] | [
"def",
"get_nearby_charging_sites",
"(",
"self",
")",
":",
"return",
"self",
".",
"api",
"(",
"'NEARBY_CHARGING_SITES'",
")",
"[",
"'response'",
"]"
] | [
435,
4
] | [
437,
60
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.mobile_enabled | (self) | Checks if the Mobile Access setting is enabled in the car | Checks if the Mobile Access setting is enabled in the car | def mobile_enabled(self):
""" Checks if the Mobile Access setting is enabled in the car """
# Construct URL and send request
uri = 'api/1/vehicles/%s/mobile_enabled' % self['id_s']
return self.tesla.get(uri)['response'] | [
"def",
"mobile_enabled",
"(",
"self",
")",
":",
"# Construct URL and send request\r",
"uri",
"=",
"'api/1/vehicles/%s/mobile_enabled'",
"%",
"self",
"[",
"'id_s'",
"]",
"return",
"self",
".",
"tesla",
".",
"get",
"(",
"uri",
")",
"[",
"'response'",
"]"
] | [
439,
4
] | [
443,
46
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.compose_image | (self, view='STUD_3QTR', size=640, options=None) | Returns a PNG formatted composed vehicle image. Valid views are:
STUD_3QTR, STUD_SEAT, STUD_SIDE, STUD_REAR and STUD_WHEEL | Returns a PNG formatted composed vehicle image. Valid views are:
STUD_3QTR, STUD_SEAT, STUD_SIDE, STUD_REAR and STUD_WHEEL | def compose_image(self, view='STUD_3QTR', size=640, options=None):
""" Returns a PNG formatted composed vehicle image. Valid views are:
STUD_3QTR, STUD_SEAT, STUD_SIDE, STUD_REAR and STUD_WHEEL """
if options is None:
msg = 'compose_image requires options for the image to be accu... | [
"def",
"compose_image",
"(",
"self",
",",
"view",
"=",
"'STUD_3QTR'",
",",
"size",
"=",
"640",
",",
"options",
"=",
"None",
")",
":",
"if",
"options",
"is",
"None",
":",
"msg",
"=",
"'compose_image requires options for the image to be accurate'",
"logger",
".",
... | [
445,
4
] | [
460,
31
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.dist_units | (self, miles, speed=False) | Format and convert distance or speed to GUI setting units | Format and convert distance or speed to GUI setting units | def dist_units(self, miles, speed=False):
""" Format and convert distance or speed to GUI setting units """
if miles is None:
return None
if 'gui_settings' not in self:
self.get_vehicle_data()
# Lookup GUI settings of the vehicle
if 'km' in self['gu... | [
"def",
"dist_units",
"(",
"self",
",",
"miles",
",",
"speed",
"=",
"False",
")",
":",
"if",
"miles",
"is",
"None",
":",
"return",
"None",
"if",
"'gui_settings'",
"not",
"in",
"self",
":",
"self",
".",
"get_vehicle_data",
"(",
")",
"# Lookup GUI settings of... | [
462,
4
] | [
471,
60
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.temp_units | (self, celcius) | Format and convert temperature to GUI setting units | Format and convert temperature to GUI setting units | def temp_units(self, celcius):
""" Format and convert temperature to GUI setting units """
if celcius is None:
return None
if 'gui_settings' not in self:
self.get_vehicle_data()
# Lookup GUI settings of the vehicle
if 'F' in self['gui_settings']['gu... | [
"def",
"temp_units",
"(",
"self",
",",
"celcius",
")",
":",
"if",
"celcius",
"is",
"None",
":",
"return",
"None",
"if",
"'gui_settings'",
"not",
"in",
"self",
":",
"self",
".",
"get_vehicle_data",
"(",
")",
"# Lookup GUI settings of the vehicle\r",
"if",
"'F'"... | [
473,
4
] | [
482,
33
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.decode_vin | (self) | Returns decoded VIN as dict | Returns decoded VIN as dict | def decode_vin(self):
""" Returns decoded VIN as dict """
make = 'Model ' + self['vin'][3]
body = {'A': 'Hatchback 5 Dr / LHD', 'B': 'Hatchback 5 Dr / RHD',
'C': 'MPV / 5 Dr / LHD', 'D': 'MPV / 5 Dr / RHD',
'E': 'Sedan 4 Dr / LHD', 'F': 'Sedan 4 Dr / RHD',
... | [
"def",
"decode_vin",
"(",
"self",
")",
":",
"make",
"=",
"'Model '",
"+",
"self",
"[",
"'vin'",
"]",
"[",
"3",
"]",
"body",
"=",
"{",
"'A'",
":",
"'Hatchback 5 Dr / LHD'",
",",
"'B'",
":",
"'Hatchback 5 Dr / RHD'",
",",
"'C'",
":",
"'MPV / 5 Dr / LHD'",
... | [
484,
4
] | [
504,
75
] | python | en | ['pt', 'en', 'en'] | True |
Vehicle.remote_start_drive | (self) | Enables keyless driving for two minutes | Enables keyless driving for two minutes | def remote_start_drive(self):
""" Enables keyless driving for two minutes """
if not self.tesla.password:
raise ValueError('`password` is not set')
return self.command('REMOTE_START', password=self.tesla.password) | [
"def",
"remote_start_drive",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"tesla",
".",
"password",
":",
"raise",
"ValueError",
"(",
"'`password` is not set'",
")",
"return",
"self",
".",
"command",
"(",
"'REMOTE_START'",
",",
"password",
"=",
"self",
".... | [
506,
4
] | [
510,
73
] | python | en | ['en', 'en', 'en'] | True |
Vehicle.command | (self, name, **kwargs) | Wrapper method for vehicle command response error handling | Wrapper method for vehicle command response error handling | def command(self, name, **kwargs):
""" Wrapper method for vehicle command response error handling """
response = self.api(name, **kwargs)['response']
if not response['result']:
raise VehicleError(response['reason'])
return response['result'] | [
"def",
"command",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"api",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"[",
"'response'",
"]",
"if",
"not",
"response",
"[",
"'result'",
"]",
":",
"raise",
"V... | [
512,
4
] | [
517,
33
] | python | en | ['en', 'no', 'en'] | True |
Battery.api | (self, name, **kwargs) | Endpoint request with battery_id or site_id path variable | Endpoint request with battery_id or site_id path variable | def api(self, name, **kwargs):
""" Endpoint request with battery_id or site_id path variable """
pathvars = {'battery_id': self['id'], 'site_id': self['energy_site_id']}
return self.tesla.api(name, pathvars, **kwargs) | [
"def",
"api",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"pathvars",
"=",
"{",
"'battery_id'",
":",
"self",
"[",
"'id'",
"]",
",",
"'site_id'",
":",
"self",
"[",
"'energy_site_id'",
"]",
"}",
"return",
"self",
".",
"tesla",
".",
"... | [
532,
4
] | [
535,
55
] | python | en | ['en', 'en', 'en'] | True |
Battery.get_battery_data | (self) | Retrieve detailed state and configuration of the battery | Retrieve detailed state and configuration of the battery | def get_battery_data(self):
""" Retrieve detailed state and configuration of the battery """
self.update(self.api('BATTERY_DATA')['response'])
return self | [
"def",
"get_battery_data",
"(",
"self",
")",
":",
"self",
".",
"update",
"(",
"self",
".",
"api",
"(",
"'BATTERY_DATA'",
")",
"[",
"'response'",
"]",
")",
"return",
"self"
] | [
537,
4
] | [
540,
19
] | python | en | ['en', 'en', 'en'] | True |
Battery.command | (self, name, **kwargs) | Wrapper method for battery command response error handling | Wrapper method for battery command response error handling | def command(self, name, **kwargs):
""" Wrapper method for battery command response error handling """
response = self.api(name, **kwargs)['response']
if response['code'] == 201:
return response.get('message')
raise BatteryError(response.get('message')) | [
"def",
"command",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"response",
"=",
"self",
".",
"api",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"[",
"'response'",
"]",
"if",
"response",
"[",
"'code'",
"]",
"==",
"201",
":",
"return... | [
542,
4
] | [
547,
51
] | python | en | ['en', 'no', 'en'] | True |
Battery.set_operation | (self, mode) | Set battery operation to self_consumption, backup or autonomous | Set battery operation to self_consumption, backup or autonomous | def set_operation(self, mode):
""" Set battery operation to self_consumption, backup or autonomous """
return self.command('BATTERY_OPERATION_MODE', default_real_mode=mode) | [
"def",
"set_operation",
"(",
"self",
",",
"mode",
")",
":",
"return",
"self",
".",
"command",
"(",
"'BATTERY_OPERATION_MODE'",
",",
"default_real_mode",
"=",
"mode",
")"
] | [
549,
4
] | [
551,
77
] | python | en | ['en', 'en', 'en'] | True |
Battery.set_backup_reserve_percent | (self, percent) | Set the minimum backup reserve percent for that battery | Set the minimum backup reserve percent for that battery | def set_backup_reserve_percent(self, percent):
""" Set the minimum backup reserve percent for that battery """
return self.command('BACKUP_RESERVE',
backup_reserve_percent=int(percent)) | [
"def",
"set_backup_reserve_percent",
"(",
"self",
",",
"percent",
")",
":",
"return",
"self",
".",
"command",
"(",
"'BACKUP_RESERVE'",
",",
"backup_reserve_percent",
"=",
"int",
"(",
"percent",
")",
")"
] | [
553,
4
] | [
556,
64
] | python | en | ['en', 'en', 'en'] | True |
export_type | (cls) | Decorator to expose the given class to business_rules.export_rule_data. | Decorator to expose the given class to business_rules.export_rule_data. | def export_type(cls):
""" Decorator to expose the given class to business_rules.export_rule_data. """
cls.export_in_rule_data = True
return cls | [
"def",
"export_type",
"(",
"cls",
")",
":",
"cls",
".",
"export_in_rule_data",
"=",
"True",
"return",
"cls"
] | [
28,
0
] | [
31,
14
] | python | en | ['en', 'en', 'en'] | True |
type_operator | (input_type, label=None, assert_type_for_arguments=True) | Decorator to make a function into a type operator.
- assert_type_for_arguments - if True this patches the operator function
so that arguments passed to it will have _assert_valid_value_and_cast
called on them to make type errors explicit.
| Decorator to make a function into a type operator. | def type_operator(input_type, label=None, assert_type_for_arguments=True):
"""Decorator to make a function into a type operator.
- assert_type_for_arguments - if True this patches the operator function
so that arguments passed to it will have _assert_valid_value_and_cast
called on them to make type... | [
"def",
"type_operator",
"(",
"input_type",
",",
"label",
"=",
"None",
",",
"assert_type_for_arguments",
"=",
"True",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"func",
".",
"is_operator",
"=",
"True",
"func",
".",
"label",
"=",
"label",
"or",
"fn... | [
34,
0
] | [
56,
18
] | python | en | ['en', 'en', 'en'] | True |
get_msvcr_replacement | () | Replacement for outdated version of get_msvcr from cygwinccompiler | Replacement for outdated version of get_msvcr from cygwinccompiler | def get_msvcr_replacement():
"""Replacement for outdated version of get_msvcr from cygwinccompiler"""
msvcr = msvc_runtime_library()
return [] if msvcr is None else [msvcr] | [
"def",
"get_msvcr_replacement",
"(",
")",
":",
"msvcr",
"=",
"msvc_runtime_library",
"(",
")",
"return",
"[",
"]",
"if",
"msvcr",
"is",
"None",
"else",
"[",
"msvcr",
"]"
] | [
41,
0
] | [
44,
43
] | python | en | ['en', 'en', 'en'] | True |
generate_def | (dll, dfile) | Given a dll file location, get all its exported symbols and dump them
into the given def file.
The .def file will be overwritten | Given a dll file location, get all its exported symbols and dump them
into the given def file. | def generate_def(dll, dfile):
"""Given a dll file location, get all its exported symbols and dump them
into the given def file.
The .def file will be overwritten"""
dump = dump_table(dll)
for i in range(len(dump)):
if _START.match(dump[i].decode()):
break
else:
rais... | [
"def",
"generate_def",
"(",
"dll",
",",
"dfile",
")",
":",
"dump",
"=",
"dump_table",
"(",
"dll",
")",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"dump",
")",
")",
":",
"if",
"_START",
".",
"match",
"(",
"dump",
"[",
"i",
"]",
".",
"decode",
"... | [
290,
0
] | [
321,
13
] | python | en | ['en', 'en', 'en'] | True |
_check_for_import_lib | () | Check if an import library for the Python runtime already exists. | Check if an import library for the Python runtime already exists. | def _check_for_import_lib():
"""Check if an import library for the Python runtime already exists."""
major_version, minor_version = tuple(sys.version_info[:2])
# patterns for the file name of the library itself
patterns = ['libpython%d%d.a',
'libpython%d%d.dll.a',
'libpy... | [
"def",
"_check_for_import_lib",
"(",
")",
":",
"major_version",
",",
"minor_version",
"=",
"tuple",
"(",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
")",
"# patterns for the file name of the library itself",
"patterns",
"=",
"[",
"'libpython%d%d.a'",
",",
"'libp... | [
420,
0
] | [
454,
33
] | python | en | ['en', 'en', 'en'] | True |
_build_import_library_x86 | () | Build the import libraries for Mingw32-gcc on Windows
| Build the import libraries for Mingw32-gcc on Windows
| def _build_import_library_x86():
""" Build the import libraries for Mingw32-gcc on Windows
"""
out_exists, out_file = _check_for_import_lib()
if out_exists:
log.debug('Skip building import library: "%s" exists', out_file)
return
lib_name = "python%d%d.lib" % tuple(sys.version_info[:... | [
"def",
"_build_import_library_x86",
"(",
")",
":",
"out_exists",
",",
"out_file",
"=",
"_check_for_import_lib",
"(",
")",
"if",
"out_exists",
":",
"log",
".",
"debug",
"(",
"'Skip building import library: \"%s\" exists'",
",",
"out_file",
")",
"return",
"lib_name",
... | [
476,
0
] | [
520,
10
] | python | en | ['en', 'en', 'en'] | True |
msvc_manifest_xml | (maj, min) | Given a major and minor version of the MSVCR, returns the
corresponding XML file. | Given a major and minor version of the MSVCR, returns the
corresponding XML file. | def msvc_manifest_xml(maj, min):
"""Given a major and minor version of the MSVCR, returns the
corresponding XML file."""
try:
fullver = _MSVCRVER_TO_FULLVER[str(maj * 10 + min)]
except KeyError:
raise ValueError("Version %d,%d of MSVCRT not supported yet" %
(maj,... | [
"def",
"msvc_manifest_xml",
"(",
"maj",
",",
"min",
")",
":",
"try",
":",
"fullver",
"=",
"_MSVCRVER_TO_FULLVER",
"[",
"str",
"(",
"maj",
"*",
"10",
"+",
"min",
")",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",
"\"Version %d,%d of MSVCRT not s... | [
560,
0
] | [
590,
66
] | python | en | ['en', 'en', 'en'] | True |
manifest_rc | (name, type='dll') | Return the rc file used to generate the res file which will be embedded
as manifest for given manifest file name, of given type ('dll' or
'exe').
Parameters
----------
name : str
name of the manifest file to embed
type : str {'dll', 'exe'}
type of the binary which will e... | Return the rc file used to generate the res file which will be embedded
as manifest for given manifest file name, of given type ('dll' or
'exe'). | def manifest_rc(name, type='dll'):
"""Return the rc file used to generate the res file which will be embedded
as manifest for given manifest file name, of given type ('dll' or
'exe').
Parameters
----------
name : str
name of the manifest file to embed
type : str {'dll', 'exe'}
... | [
"def",
"manifest_rc",
"(",
"name",
",",
"type",
"=",
"'dll'",
")",
":",
"if",
"type",
"==",
"'dll'",
":",
"rctype",
"=",
"2",
"elif",
"type",
"==",
"'exe'",
":",
"rctype",
"=",
"1",
"else",
":",
"raise",
"ValueError",
"(",
"\"Type %s not supported\"",
... | [
592,
0
] | [
614,
37
] | python | en | ['en', 'en', 'en'] | True |
check_embedded_msvcr_match_linked | (msver) | msver is the ms runtime version used for the MANIFEST. | msver is the ms runtime version used for the MANIFEST. | def check_embedded_msvcr_match_linked(msver):
"""msver is the ms runtime version used for the MANIFEST."""
# check msvcr major version are the same for linking and
# embedding
maj = msvc_runtime_major()
if maj:
if not maj == int(msver):
raise ValueError(
"Discre... | [
"def",
"check_embedded_msvcr_match_linked",
"(",
"msver",
")",
":",
"# check msvcr major version are the same for linking and",
"# embedding",
"maj",
"=",
"msvc_runtime_major",
"(",
")",
"if",
"maj",
":",
"if",
"not",
"maj",
"==",
"int",
"(",
"msver",
")",
":",
"rai... | [
616,
0
] | [
626,
45
] | python | en | ['en', 'en', 'en'] | True |
Test.test_component | (self) |
test for method component
|
test for method component
| def test_component(self):
"""
test for method component
"""
x = Vector([1, 2, 3])
self.assertEqual(x.component(0), 1)
self.assertEqual(x.component(2), 3)
try:
y = Vector()
self.assertTrue(False)
except:
self.assertTr... | [
"def",
"test_component",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"self",
".",
"assertEqual",
"(",
"x",
".",
"component",
"(",
"0",
")",
",",
"1",
")",
"self",
".",
"assertEqual",
"(",
"x",
".",
... | [
17,
4
] | [
28,
33
] | python | en | ['en', 'error', 'th'] | False |
Test.test_str | (self) |
test for toString() method
|
test for toString() method
| def test_str(self):
"""
test for toString() method
"""
x = Vector([0, 0, 0, 0, 0, 1])
self.assertEqual(x.__str__(), "(0,0,0,0,0,1)") | [
"def",
"test_str",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"1",
"]",
")",
"self",
".",
"assertEqual",
"(",
"x",
".",
"__str__",
"(",
")",
",",
"\"(0,0,0,0,0,1)\"",
")"
] | [
30,
4
] | [
35,
54
] | python | en | ['en', 'error', 'th'] | False |
Test.test_size | (self) |
test for size()-method
|
test for size()-method
| def test_size(self):
"""
test for size()-method
"""
x = Vector([1, 2, 3, 4])
self.assertEqual(x.size(), 4) | [
"def",
"test_size",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
"]",
")",
"self",
".",
"assertEqual",
"(",
"x",
".",
"size",
"(",
")",
",",
"4",
")"
] | [
37,
4
] | [
42,
37
] | python | en | ['en', 'error', 'th'] | False |
Test.test_euclidLength | (self) |
test for the eulidean length
|
test for the eulidean length
| def test_euclidLength(self):
"""
test for the eulidean length
"""
x = Vector([1, 2])
self.assertAlmostEqual(x.eulidLength(), 2.236, 3) | [
"def",
"test_euclidLength",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
"]",
")",
"self",
".",
"assertAlmostEqual",
"(",
"x",
".",
"eulidLength",
"(",
")",
",",
"2.236",
",",
"3",
")"
] | [
44,
4
] | [
49,
57
] | python | en | ['en', 'error', 'th'] | False |
Test.test_add | (self) |
test for + operator
|
test for + operator
| def test_add(self):
"""
test for + operator
"""
x = Vector([1, 2, 3])
y = Vector([1, 1, 1])
self.assertEqual((x + y).component(0), 2)
self.assertEqual((x + y).component(1), 3)
self.assertEqual((x + y).component(2), 4) | [
"def",
"test_add",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"y",
"=",
"Vector",
"(",
"[",
"1",
",",
"1",
",",
"1",
"]",
")",
"self",
".",
"assertEqual",
"(",
"(",
"x",
"+",
"y",
")",
".",
"... | [
51,
4
] | [
59,
49
] | python | en | ['en', 'error', 'th'] | False |
Test.test_sub | (self) |
test for - operator
|
test for - operator
| def test_sub(self):
"""
test for - operator
"""
x = Vector([1, 2, 3])
y = Vector([1, 1, 1])
self.assertEqual((x - y).component(0), 0)
self.assertEqual((x - y).component(1), 1)
self.assertEqual((x - y).component(2), 2) | [
"def",
"test_sub",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"y",
"=",
"Vector",
"(",
"[",
"1",
",",
"1",
",",
"1",
"]",
")",
"self",
".",
"assertEqual",
"(",
"(",
"x",
"-",
"y",
")",
".",
"... | [
61,
4
] | [
69,
49
] | python | en | ['en', 'error', 'th'] | False |
Test.test_mul | (self) |
test for * operator
|
test for * operator
| def test_mul(self):
"""
test for * operator
"""
x = Vector([1, 2, 3])
a = Vector([2, -1, 4]) # for test of dot-product
b = Vector([1, -2, -1])
self.assertEqual((x * 3.0).__str__(), "(3.0,6.0,9.0)")
self.assertEqual((a * b), 0) | [
"def",
"test_mul",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"a",
"=",
"Vector",
"(",
"[",
"2",
",",
"-",
"1",
",",
"4",
"]",
")",
"# for test of dot-product",
"b",
"=",
"Vector",
"(",
"[",
"1",
... | [
71,
4
] | [
79,
36
] | python | en | ['en', 'error', 'th'] | False |
Test.test_zeroVector | (self) |
test for the global function zeroVector(...)
|
test for the global function zeroVector(...)
| def test_zeroVector(self):
"""
test for the global function zeroVector(...)
"""
self.assertTrue(zeroVector(10).__str__().count("0") == 10) | [
"def",
"test_zeroVector",
"(",
"self",
")",
":",
"self",
".",
"assertTrue",
"(",
"zeroVector",
"(",
"10",
")",
".",
"__str__",
"(",
")",
".",
"count",
"(",
"\"0\"",
")",
"==",
"10",
")"
] | [
81,
4
] | [
85,
66
] | python | en | ['en', 'error', 'th'] | False |
Test.test_unitBasisVector | (self) |
test for the global function unitBasisVector(...)
|
test for the global function unitBasisVector(...)
| def test_unitBasisVector(self):
"""
test for the global function unitBasisVector(...)
"""
self.assertEqual(unitBasisVector(3, 1).__str__(), "(0,1,0)") | [
"def",
"test_unitBasisVector",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"unitBasisVector",
"(",
"3",
",",
"1",
")",
".",
"__str__",
"(",
")",
",",
"\"(0,1,0)\"",
")"
] | [
87,
4
] | [
91,
68
] | python | en | ['en', 'error', 'th'] | False |
Test.test_axpy | (self) |
test for the global function axpy(...) (operation)
|
test for the global function axpy(...) (operation)
| def test_axpy(self):
"""
test for the global function axpy(...) (operation)
"""
x = Vector([1, 2, 3])
y = Vector([1, 0, 1])
self.assertEqual(axpy(2, x, y).__str__(), "(3,4,7)") | [
"def",
"test_axpy",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"2",
",",
"3",
"]",
")",
"y",
"=",
"Vector",
"(",
"[",
"1",
",",
"0",
",",
"1",
"]",
")",
"self",
".",
"assertEqual",
"(",
"axpy",
"(",
"2",
",",
"x",
",",... | [
93,
4
] | [
99,
60
] | python | en | ['en', 'error', 'th'] | False |
Test.test_copy | (self) |
test for the copy()-method
|
test for the copy()-method
| def test_copy(self):
"""
test for the copy()-method
"""
x = Vector([1, 0, 0, 0, 0, 0])
y = x.copy()
self.assertEqual(x.__str__(), y.__str__()) | [
"def",
"test_copy",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
"]",
")",
"y",
"=",
"x",
".",
"copy",
"(",
")",
"self",
".",
"assertEqual",
"(",
"x",
".",
"__str__",
"(",
")"... | [
101,
4
] | [
107,
50
] | python | en | ['en', 'error', 'th'] | False |
Test.test_changeComponent | (self) |
test for the changeComponent(...)-method
|
test for the changeComponent(...)-method
| def test_changeComponent(self):
"""
test for the changeComponent(...)-method
"""
x = Vector([1, 0, 0])
x.changeComponent(0, 0)
x.changeComponent(1, 1)
self.assertEqual(x.__str__(), "(0,1,0)") | [
"def",
"test_changeComponent",
"(",
"self",
")",
":",
"x",
"=",
"Vector",
"(",
"[",
"1",
",",
"0",
",",
"0",
"]",
")",
"x",
".",
"changeComponent",
"(",
"0",
",",
"0",
")",
"x",
".",
"changeComponent",
"(",
"1",
",",
"1",
")",
"self",
".",
"ass... | [
109,
4
] | [
116,
48
] | python | en | ['en', 'error', 'th'] | False |
SubstitutionCodeBlock.run | (self) |
Replace placeholders with given variables.
|
Replace placeholders with given variables.
| def run(self):
"""
Replace placeholders with given variables.
"""
app = self.state.document.settings.env.app
new_content = []
existing_content = self.content
for item in existing_content:
for pair in app.config.substitutions:
original, replacem... | [
"def",
"run",
"(",
"self",
")",
":",
"app",
"=",
"self",
".",
"state",
".",
"document",
".",
"settings",
".",
"env",
".",
"app",
"new_content",
"=",
"[",
"]",
"existing_content",
"=",
"self",
".",
"content",
"for",
"item",
"in",
"existing_content",
":"... | [
27,
4
] | [
41,
40
] | python | en | ['en', 'error', 'th'] | False |
take | (a, indices, axis=None, out=None, mode='raise') |
Take elements from an array along an axis.
When axis is not None, this function does the same thing as "fancy"
indexing (indexing arrays using arrays); however, it can be easier to use
if you need elements along a given axis. A call such as
``np.take(arr, indices, axis=3)`` is equivalent to
``... |
Take elements from an array along an axis. | def take(a, indices, axis=None, out=None, mode='raise'):
"""
Take elements from an array along an axis.
When axis is not None, this function does the same thing as "fancy"
indexing (indexing arrays using arrays); however, it can be easier to use
if you need elements along a given axis. A call such ... | [
"def",
"take",
"(",
"a",
",",
"indices",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"mode",
"=",
"'raise'",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'take'",
",",
"indices",
",",
"axis",
"=",
"axis",
",",
"out",
"=",
"out",
... | [
97,
0
] | [
193,
71
] | python | en | ['en', 'error', 'th'] | False |
reshape | (a, newshape, order='C') |
Gives a new shape to an array without changing its data.
Parameters
----------
a : array_like
Array to be reshaped.
newshape : int or tuple of ints
The new shape should be compatible with the original shape. If
an integer, then the result will be a 1-D array of that length.... |
Gives a new shape to an array without changing its data. | def reshape(a, newshape, order='C'):
"""
Gives a new shape to an array without changing its data.
Parameters
----------
a : array_like
Array to be reshaped.
newshape : int or tuple of ints
The new shape should be compatible with the original shape. If
an integer, then th... | [
"def",
"reshape",
"(",
"a",
",",
"newshape",
",",
"order",
"=",
"'C'",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'reshape'",
",",
"newshape",
",",
"order",
"=",
"order",
")"
] | [
202,
0
] | [
300,
57
] | python | en | ['en', 'error', 'th'] | False |
choose | (a, choices, out=None, mode='raise') |
Construct an array from an index array and a set of arrays to choose from.
First of all, if confused or uncertain, definitely look at the Examples -
in its full generality, this function is less simple than it might
seem from the following code description (below ndi =
`numpy.lib.index_tricks`):
... |
Construct an array from an index array and a set of arrays to choose from. | def choose(a, choices, out=None, mode='raise'):
"""
Construct an array from an index array and a set of arrays to choose from.
First of all, if confused or uncertain, definitely look at the Examples -
in its full generality, this function is less simple than it might
seem from the following code de... | [
"def",
"choose",
"(",
"a",
",",
"choices",
",",
"out",
"=",
"None",
",",
"mode",
"=",
"'raise'",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'choose'",
",",
"choices",
",",
"out",
"=",
"out",
",",
"mode",
"=",
"mode",
")"
] | [
311,
0
] | [
431,
62
] | python | en | ['en', 'error', 'th'] | False |
repeat | (a, repeats, axis=None) |
Repeat elements of an array.
Parameters
----------
a : array_like
Input array.
repeats : int or array of ints
The number of repetitions for each element. `repeats` is broadcasted
to fit the shape of the given axis.
axis : int, optional
The axis along which to r... |
Repeat elements of an array. | def repeat(a, repeats, axis=None):
"""
Repeat elements of an array.
Parameters
----------
a : array_like
Input array.
repeats : int or array of ints
The number of repetitions for each element. `repeats` is broadcasted
to fit the shape of the given axis.
axis : int, ... | [
"def",
"repeat",
"(",
"a",
",",
"repeats",
",",
"axis",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'repeat'",
",",
"repeats",
",",
"axis",
"=",
"axis",
")"
] | [
439,
0
] | [
480,
53
] | python | en | ['en', 'error', 'th'] | False |
put | (a, ind, v, mode='raise') |
Replaces specified elements of an array with given values.
The indexing works on the flattened target array. `put` is roughly
equivalent to:
::
a.flat[ind] = v
Parameters
----------
a : ndarray
Target array.
ind : array_like
Target indices, interpreted as int... |
Replaces specified elements of an array with given values. | def put(a, ind, v, mode='raise'):
"""
Replaces specified elements of an array with given values.
The indexing works on the flattened target array. `put` is roughly
equivalent to:
::
a.flat[ind] = v
Parameters
----------
a : ndarray
Target array.
ind : array_like
... | [
"def",
"put",
"(",
"a",
",",
"ind",
",",
"v",
",",
"mode",
"=",
"'raise'",
")",
":",
"try",
":",
"put",
"=",
"a",
".",
"put",
"except",
"AttributeError",
":",
"raise",
"TypeError",
"(",
"\"argument 1 must be numpy.ndarray, \"",
"\"not {name}\"",
".",
"form... | [
488,
0
] | [
544,
33
] | python | en | ['en', 'error', 'th'] | False |
swapaxes | (a, axis1, axis2) |
Interchange two axes of an array.
Parameters
----------
a : array_like
Input array.
axis1 : int
First axis.
axis2 : int
Second axis.
Returns
-------
a_swapped : ndarray
For NumPy >= 1.10.0, if `a` is an ndarray, then a view of `a` is
returne... |
Interchange two axes of an array. | def swapaxes(a, axis1, axis2):
"""
Interchange two axes of an array.
Parameters
----------
a : array_like
Input array.
axis1 : int
First axis.
axis2 : int
Second axis.
Returns
-------
a_swapped : ndarray
For NumPy >= 1.10.0, if `a` is an ndarray,... | [
"def",
"swapaxes",
"(",
"a",
",",
"axis1",
",",
"axis2",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'swapaxes'",
",",
"axis1",
",",
"axis2",
")"
] | [
552,
0
] | [
595,
49
] | python | en | ['en', 'error', 'th'] | False |
transpose | (a, axes=None) |
Permute the dimensions of an array.
Parameters
----------
a : array_like
Input array.
axes : list of ints, optional
By default, reverse the dimensions, otherwise permute the axes
according to the values given.
Returns
-------
p : ndarray
`a` with its ax... |
Permute the dimensions of an array. | def transpose(a, axes=None):
"""
Permute the dimensions of an array.
Parameters
----------
a : array_like
Input array.
axes : list of ints, optional
By default, reverse the dimensions, otherwise permute the axes
according to the values given.
Returns
-------
... | [
"def",
"transpose",
"(",
"a",
",",
"axes",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'transpose'",
",",
"axes",
")"
] | [
603,
0
] | [
649,
42
] | python | en | ['en', 'error', 'th'] | False |
partition | (a, kth, axis=-1, kind='introselect', order=None) |
Return a partitioned copy of an array.
Creates a copy of the array with its elements rearranged in such a
way that the value of the element in k-th position is in the
position it would be in a sorted array. All elements smaller than
the k-th element are moved before this element and all equal or
... |
Return a partitioned copy of an array. | def partition(a, kth, axis=-1, kind='introselect', order=None):
"""
Return a partitioned copy of an array.
Creates a copy of the array with its elements rearranged in such a
way that the value of the element in k-th position is in the
position it would be in a sorted array. All elements smaller tha... | [
"def",
"partition",
"(",
"a",
",",
"kth",
",",
"axis",
"=",
"-",
"1",
",",
"kind",
"=",
"'introselect'",
",",
"order",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"# flatten returns (1, N) for np.matrix, so always use the last axis",
"a",
"=",
"a... | [
657,
0
] | [
745,
12
] | python | en | ['en', 'error', 'th'] | False |
argpartition | (a, kth, axis=-1, kind='introselect', order=None) |
Perform an indirect partition along the given axis using the
algorithm specified by the `kind` keyword. It returns an array of
indices of the same shape as `a` that index data along the given
axis in partitioned order.
.. versionadded:: 1.8.0
Parameters
----------
a : array_like
... |
Perform an indirect partition along the given axis using the
algorithm specified by the `kind` keyword. It returns an array of
indices of the same shape as `a` that index data along the given
axis in partitioned order. | def argpartition(a, kth, axis=-1, kind='introselect', order=None):
"""
Perform an indirect partition along the given axis using the
algorithm specified by the `kind` keyword. It returns an array of
indices of the same shape as `a` that index data along the given
axis in partitioned order.
.. ve... | [
"def",
"argpartition",
"(",
"a",
",",
"kth",
",",
"axis",
"=",
"-",
"1",
",",
"kind",
"=",
"'introselect'",
",",
"order",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'argpartition'",
",",
"kth",
",",
"axis",
"=",
"axis",
",",
"kin... | [
753,
0
] | [
818,
79
] | python | en | ['en', 'error', 'th'] | False |
sort | (a, axis=-1, kind=None, order=None) |
Return a sorted copy of an array.
Parameters
----------
a : array_like
Array to be sorted.
axis : int or None, optional
Axis along which to sort. If None, the array is flattened before
sorting. The default is -1, which sorts along the last axis.
kind : {'quicksort', 'me... |
Return a sorted copy of an array. | def sort(a, axis=-1, kind=None, order=None):
"""
Return a sorted copy of an array.
Parameters
----------
a : array_like
Array to be sorted.
axis : int or None, optional
Axis along which to sort. If None, the array is flattened before
sorting. The default is -1, which sor... | [
"def",
"sort",
"(",
"a",
",",
"axis",
"=",
"-",
"1",
",",
"kind",
"=",
"None",
",",
"order",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"# flatten returns (1, N) for np.matrix, so always use the last axis",
"a",
"=",
"asanyarray",
"(",
"a",
")... | [
826,
0
] | [
970,
12
] | python | en | ['en', 'error', 'th'] | False |
argsort | (a, axis=-1, kind=None, order=None) |
Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm specified
by the `kind` keyword. It returns an array of indices of the same shape as
`a` that index data along the given axis in sorted order.
Parameters
----------
a : array_li... |
Returns the indices that would sort an array. | def argsort(a, axis=-1, kind=None, order=None):
"""
Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm specified
by the `kind` keyword. It returns an array of indices of the same shape as
`a` that index data along the given axis in sorted... | [
"def",
"argsort",
"(",
"a",
",",
"axis",
"=",
"-",
"1",
",",
"kind",
"=",
"None",
",",
"order",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'argsort'",
",",
"axis",
"=",
"axis",
",",
"kind",
"=",
"kind",
",",
"order",
"=",
"or... | [
978,
0
] | [
1083,
69
] | python | en | ['en', 'error', 'th'] | False |
argmax | (a, axis=None, out=None) |
Returns the indices of the maximum values along an axis.
Parameters
----------
a : array_like
Input array.
axis : int, optional
By default, the index is into the flattened array, otherwise
along the specified axis.
out : array, optional
If provided, the result w... |
Returns the indices of the maximum values along an axis. | def argmax(a, axis=None, out=None):
"""
Returns the indices of the maximum values along an axis.
Parameters
----------
a : array_like
Input array.
axis : int, optional
By default, the index is into the flattened array, otherwise
along the specified axis.
out : array,... | [
"def",
"argmax",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'argmax'",
",",
"axis",
"=",
"axis",
",",
"out",
"=",
"out",
")"
] | [
1091,
0
] | [
1152,
53
] | python | en | ['en', 'error', 'th'] | False |
argmin | (a, axis=None, out=None) |
Returns the indices of the minimum values along an axis.
Parameters
----------
a : array_like
Input array.
axis : int, optional
By default, the index is into the flattened array, otherwise
along the specified axis.
out : array, optional
If provided, the result w... |
Returns the indices of the minimum values along an axis. | def argmin(a, axis=None, out=None):
"""
Returns the indices of the minimum values along an axis.
Parameters
----------
a : array_like
Input array.
axis : int, optional
By default, the index is into the flattened array, otherwise
along the specified axis.
out : array,... | [
"def",
"argmin",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'argmin'",
",",
"axis",
"=",
"axis",
",",
"out",
"=",
"out",
")"
] | [
1160,
0
] | [
1221,
53
] | python | en | ['en', 'error', 'th'] | False |
searchsorted | (a, v, side='left', sorter=None) |
Find indices where elements should be inserted to maintain order.
Find the indices into a sorted array `a` such that, if the
corresponding elements in `v` were inserted before the indices, the
order of `a` would be preserved.
Assuming that `a` is sorted:
====== ============================
... |
Find indices where elements should be inserted to maintain order. | def searchsorted(a, v, side='left', sorter=None):
"""
Find indices where elements should be inserted to maintain order.
Find the indices into a sorted array `a` such that, if the
corresponding elements in `v` were inserted before the indices, the
order of `a` would be preserved.
Assuming that ... | [
"def",
"searchsorted",
"(",
"a",
",",
"v",
",",
"side",
"=",
"'left'",
",",
"sorter",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'searchsorted'",
",",
"v",
",",
"side",
"=",
"side",
",",
"sorter",
"=",
"sorter",
")"
] | [
1229,
0
] | [
1295,
68
] | python | en | ['en', 'error', 'th'] | False |
resize | (a, new_shape) |
Return a new array with the specified shape.
If the new array is larger than the original array, then the new
array is filled with repeated copies of `a`. Note that this behavior
is different from a.resize(new_shape) which fills with zeros instead
of repeated copies of `a`.
Parameters
--... |
Return a new array with the specified shape. | def resize(a, new_shape):
"""
Return a new array with the specified shape.
If the new array is larger than the original array, then the new
array is filled with repeated copies of `a`. Note that this behavior
is different from a.resize(new_shape) which fills with zeros instead
of repeated copi... | [
"def",
"resize",
"(",
"a",
",",
"new_shape",
")",
":",
"if",
"isinstance",
"(",
"new_shape",
",",
"(",
"int",
",",
"nt",
".",
"integer",
")",
")",
":",
"new_shape",
"=",
"(",
"new_shape",
",",
")",
"a",
"=",
"ravel",
"(",
"a",
")",
"Na",
"=",
"... | [
1303,
0
] | [
1373,
32
] | python | en | ['en', 'error', 'th'] | False |
squeeze | (a, axis=None) |
Remove single-dimensional entries from the shape of an array.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
.. versionadded:: 1.7.0
Selects a subset of the single-dimensional entries in the
shape. If an axis is selec... |
Remove single-dimensional entries from the shape of an array. | def squeeze(a, axis=None):
"""
Remove single-dimensional entries from the shape of an array.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
.. versionadded:: 1.7.0
Selects a subset of the single-dimensional entries in the
... | [
"def",
"squeeze",
"(",
"a",
",",
"axis",
"=",
"None",
")",
":",
"try",
":",
"squeeze",
"=",
"a",
".",
"squeeze",
"except",
"AttributeError",
":",
"return",
"_wrapit",
"(",
"a",
",",
"'squeeze'",
",",
"axis",
"=",
"axis",
")",
"if",
"axis",
"is",
"N... | [
1381,
0
] | [
1437,
33
] | python | en | ['en', 'error', 'th'] | False |
diagonal | (a, offset=0, axis1=0, axis2=1) |
Return specified diagonals.
If `a` is 2-D, returns the diagonal of `a` with the given offset,
i.e., the collection of elements of the form ``a[i, i+offset]``. If
`a` has more than two dimensions, then the axes specified by `axis1`
and `axis2` are used to determine the 2-D sub-array whose diagonal... |
Return specified diagonals. | def diagonal(a, offset=0, axis1=0, axis2=1):
"""
Return specified diagonals.
If `a` is 2-D, returns the diagonal of `a` with the given offset,
i.e., the collection of elements of the form ``a[i, i+offset]``. If
`a` has more than two dimensions, then the axes specified by `axis1`
and `axis2` ar... | [
"def",
"diagonal",
"(",
"a",
",",
"offset",
"=",
"0",
",",
"axis1",
"=",
"0",
",",
"axis2",
"=",
"1",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"np",
".",
"matrix",
")",
":",
"# Make diagonal of matrix 1-D to preserve backward compatibility.",
"return",
... | [
1445,
0
] | [
1571,
78
] | python | en | ['en', 'error', 'th'] | False |
trace | (a, offset=0, axis1=0, axis2=1, dtype=None, out=None) |
Return the sum along diagonals of the array.
If `a` is 2-D, the sum along its diagonal with the given offset
is returned, i.e., the sum of elements ``a[i,i+offset]`` for all i.
If `a` has more than two dimensions, then the axes specified by axis1 and
axis2 are used to determine the 2-D sub-arrays... |
Return the sum along diagonals of the array. | def trace(a, offset=0, axis1=0, axis2=1, dtype=None, out=None):
"""
Return the sum along diagonals of the array.
If `a` is 2-D, the sum along its diagonal with the given offset
is returned, i.e., the sum of elements ``a[i,i+offset]`` for all i.
If `a` has more than two dimensions, then the axes sp... | [
"def",
"trace",
"(",
"a",
",",
"offset",
"=",
"0",
",",
"axis1",
"=",
"0",
",",
"axis2",
"=",
"1",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"np",
".",
"matrix",
")",
":",
"# Get trace of m... | [
1580,
0
] | [
1640,
97
] | python | en | ['en', 'error', 'th'] | False |
ravel | (a, order='C') | Return a contiguous flattened array.
A 1-D array, containing the elements of the input, is returned. A copy is
made only if needed.
As of NumPy 1.10, the returned array will have the same type as the input
array. (for example, a masked array will be returned for a masked array
input)
Paramet... | Return a contiguous flattened array. | def ravel(a, order='C'):
"""Return a contiguous flattened array.
A 1-D array, containing the elements of the input, is returned. A copy is
made only if needed.
As of NumPy 1.10, the returned array will have the same type as the input
array. (for example, a masked array will be returned for a mask... | [
"def",
"ravel",
"(",
"a",
",",
"order",
"=",
"'C'",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"np",
".",
"matrix",
")",
":",
"return",
"asarray",
"(",
"a",
")",
".",
"ravel",
"(",
"order",
"=",
"order",
")",
"else",
":",
"return",
"asanyarray"... | [
1648,
0
] | [
1751,
47
] | python | en | ['en', 'en', 'en'] | True |
nonzero | (a) |
Return the indices of the elements that are non-zero.
Returns a tuple of arrays, one for each dimension of `a`,
containing the indices of the non-zero elements in that
dimension. The values in `a` are always tested and returned in
row-major, C-style order.
To group the indices by element, rat... |
Return the indices of the elements that are non-zero. | def nonzero(a):
"""
Return the indices of the elements that are non-zero.
Returns a tuple of arrays, one for each dimension of `a`,
containing the indices of the non-zero elements in that
dimension. The values in `a` are always tested and returned in
row-major, C-style order.
To group the ... | [
"def",
"nonzero",
"(",
"a",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'nonzero'",
")"
] | [
1759,
0
] | [
1848,
34
] | python | en | ['en', 'error', 'th'] | False |
shape | (a) |
Return the shape of an array.
Parameters
----------
a : array_like
Input array.
Returns
-------
shape : tuple of ints
The elements of the shape tuple give the lengths of the
corresponding array dimensions.
See Also
--------
alen
ndarray.shape : Equ... |
Return the shape of an array. | def shape(a):
"""
Return the shape of an array.
Parameters
----------
a : array_like
Input array.
Returns
-------
shape : tuple of ints
The elements of the shape tuple give the lengths of the
corresponding array dimensions.
See Also
--------
alen
... | [
"def",
"shape",
"(",
"a",
")",
":",
"try",
":",
"result",
"=",
"a",
".",
"shape",
"except",
"AttributeError",
":",
"result",
"=",
"asarray",
"(",
"a",
")",
".",
"shape",
"return",
"result"
] | [
1856,
0
] | [
1898,
17
] | python | en | ['en', 'error', 'th'] | False |
compress | (condition, a, axis=None, out=None) |
Return selected slices of an array along given axis.
When working along a given axis, a slice along that axis is returned in
`output` for each index where `condition` evaluates to True. When
working on a 1-D array, `compress` is equivalent to `extract`.
Parameters
----------
condition : 1... |
Return selected slices of an array along given axis. | def compress(condition, a, axis=None, out=None):
"""
Return selected slices of an array along given axis.
When working along a given axis, a slice along that axis is returned in
`output` for each index where `condition` evaluates to True. When
working on a 1-D array, `compress` is equivalent to `ex... | [
"def",
"compress",
"(",
"condition",
",",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'compress'",
",",
"condition",
",",
"axis",
"=",
"axis",
",",
"out",
"=",
"out",
")"
] | [
1906,
0
] | [
1966,
66
] | python | en | ['en', 'error', 'th'] | False |
clip | (a, a_min, a_max, out=None, **kwargs) |
Clip (limit) the values in an array.
Given an interval, values outside the interval are clipped to
the interval edges. For example, if an interval of ``[0, 1]``
is specified, values smaller than 0 become 0, and values larger
than 1 become 1.
Equivalent to but faster than ``np.maximum(a_min, ... |
Clip (limit) the values in an array. | def clip(a, a_min, a_max, out=None, **kwargs):
"""
Clip (limit) the values in an array.
Given an interval, values outside the interval are clipped to
the interval edges. For example, if an interval of ``[0, 1]``
is specified, values smaller than 0 become 0, and values larger
than 1 become 1.
... | [
"def",
"clip",
"(",
"a",
",",
"a_min",
",",
"a_max",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'clip'",
",",
"a_min",
",",
"a_max",
",",
"out",
"=",
"out",
",",
"*",
"*",
"kwargs",
")"
] | [
1974,
0
] | [
2036,
64
] | python | en | ['en', 'error', 'th'] | False |
sum | (a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue) |
Sum of array elements over a given axis.
Parameters
----------
a : array_like
Elements to sum.
axis : None or int or tuple of ints, optional
Axis or axes along which a sum is performed. The default,
axis=None, will sum all of the elements of the input array. If
ax... |
Sum of array elements over a given axis. | def sum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue):
"""
Sum of array elements over a given axis.
Parameters
----------
a : array_like
Elements to sum.
axis : None or int or tuple of ints, optional
Axis or axes along ... | [
"def",
"sum",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
",",
"initial",
"=",
"np",
".",
"_NoValue",
",",
"where",
"=",
"np",
".",
"_NoValue",
")",
":",
"... | [
2045,
0
] | [
2181,
55
] | python | en | ['en', 'error', 'th'] | False |
any | (a, axis=None, out=None, keepdims=np._NoValue) |
Test whether any array element along a given axis evaluates to True.
Returns single boolean unless `axis` is not ``None``
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : None or int or tuple of ints, optional
Axis or axes al... |
Test whether any array element along a given axis evaluates to True. | def any(a, axis=None, out=None, keepdims=np._NoValue):
"""
Test whether any array element along a given axis evaluates to True.
Returns single boolean unless `axis` is not ``None``
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : ... | [
"def",
"any",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"return",
"_wrapreduction",
"(",
"a",
",",
"np",
".",
"logical_or",
",",
"'any'",
",",
"axis",
",",
"None",
",",
"ou... | [
2189,
0
] | [
2269,
86
] | python | en | ['en', 'error', 'th'] | False |
all | (a, axis=None, out=None, keepdims=np._NoValue) |
Test whether all array elements along a given axis evaluate to True.
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : None or int or tuple of ints, optional
Axis or axes along which a logical AND reduction is performed.
Th... |
Test whether all array elements along a given axis evaluate to True. | def all(a, axis=None, out=None, keepdims=np._NoValue):
"""
Test whether all array elements along a given axis evaluate to True.
Parameters
----------
a : array_like
Input array or object that can be converted to an array.
axis : None or int or tuple of ints, optional
Axis or axe... | [
"def",
"all",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"return",
"_wrapreduction",
"(",
"a",
",",
"np",
".",
"logical_and",
",",
"'all'",
",",
"axis",
",",
"None",
",",
"o... | [
2277,
0
] | [
2350,
87
] | python | en | ['en', 'error', 'th'] | False |
cumsum | (a, axis=None, dtype=None, out=None) |
Return the cumulative sum of the elements along a given axis.
Parameters
----------
a : array_like
Input array.
axis : int, optional
Axis along which the cumulative sum is computed. The default
(None) is to compute the cumsum over the flattened array.
dtype : dtype, opt... |
Return the cumulative sum of the elements along a given axis. | def cumsum(a, axis=None, dtype=None, out=None):
"""
Return the cumulative sum of the elements along a given axis.
Parameters
----------
a : array_like
Input array.
axis : int, optional
Axis along which the cumulative sum is computed. The default
(None) is to compute the ... | [
"def",
"cumsum",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"out",
"=",
"None",
")",
":",
"return",
"_wrapfunc",
"(",
"a",
",",
"'cumsum'",
",",
"axis",
"=",
"axis",
",",
"dtype",
"=",
"dtype",
",",
"out",
"=",
"out",
"... | [
2358,
0
] | [
2422,
66
] | python | en | ['en', 'error', 'th'] | False |
ptp | (a, axis=None, out=None, keepdims=np._NoValue) |
Range of values (maximum - minimum) along an axis.
The name of the function comes from the acronym for 'peak to peak'.
Parameters
----------
a : array_like
Input values.
axis : None or int or tuple of ints, optional
Axis along which to find the peaks. By default, flatten the
... |
Range of values (maximum - minimum) along an axis. | def ptp(a, axis=None, out=None, keepdims=np._NoValue):
"""
Range of values (maximum - minimum) along an axis.
The name of the function comes from the acronym for 'peak to peak'.
Parameters
----------
a : array_like
Input values.
axis : None or int or tuple of ints, optional
... | [
"def",
"ptp",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"keepdims",
"is",
"not",
"np",
".",
"_NoValue",
":",
"kwargs",
"[",
"'keepdims'",
"]"... | [
2430,
0
] | [
2495,
57
] | python | en | ['en', 'error', 'th'] | False |
amax | (a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
where=np._NoValue) |
Return the maximum of an array or maximum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which to operate. By default, flattened input is
used.
.. versionadded:: 1.7.0
If th... |
Return the maximum of an array or maximum along an axis. | def amax(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
where=np._NoValue):
"""
Return the maximum of an array or maximum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along... | [
"def",
"amax",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
",",
"initial",
"=",
"np",
".",
"_NoValue",
",",
"where",
"=",
"np",
".",
"_NoValue",
")",
":",
"return",
"_wrapreduction",
"("... | [
2504,
0
] | [
2620,
74
] | python | en | ['en', 'error', 'th'] | False |
amin | (a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
where=np._NoValue) |
Return the minimum of an array or minimum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along which to operate. By default, flattened input is
used.
.. versionadded:: 1.7.0
If th... |
Return the minimum of an array or minimum along an axis. | def amin(a, axis=None, out=None, keepdims=np._NoValue, initial=np._NoValue,
where=np._NoValue):
"""
Return the minimum of an array or minimum along an axis.
Parameters
----------
a : array_like
Input data.
axis : None or int or tuple of ints, optional
Axis or axes along... | [
"def",
"amin",
"(",
"a",
",",
"axis",
"=",
"None",
",",
"out",
"=",
"None",
",",
"keepdims",
"=",
"np",
".",
"_NoValue",
",",
"initial",
"=",
"np",
".",
"_NoValue",
",",
"where",
"=",
"np",
".",
"_NoValue",
")",
":",
"return",
"_wrapreduction",
"("... | [
2629,
0
] | [
2745,
74
] | python | en | ['en', 'error', 'th'] | False |
alen | (a) |
Return the length of the first dimension of the input array.
Parameters
----------
a : array_like
Input array.
Returns
-------
alen : int
Length of the first dimension of `a`.
See Also
--------
shape, size
Examples
--------
>>> a = np.zeros((7,4,5))... |
Return the length of the first dimension of the input array. | def alen(a):
"""
Return the length of the first dimension of the input array.
Parameters
----------
a : array_like
Input array.
Returns
-------
alen : int
Length of the first dimension of `a`.
See Also
--------
shape, size
Examples
--------
>>> a... | [
"def",
"alen",
"(",
"a",
")",
":",
"try",
":",
"return",
"len",
"(",
"a",
")",
"except",
"TypeError",
":",
"return",
"len",
"(",
"array",
"(",
"a",
",",
"ndmin",
"=",
"1",
")",
")"
] | [
2753,
0
] | [
2783,
37
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.