body_hash stringlengths 64 64 | body stringlengths 23 109k | docstring stringlengths 1 57k | path stringlengths 4 198 | name stringlengths 1 115 | repository_name stringlengths 7 111 | repository_stars float64 0 191k | lang stringclasses 1
value | body_without_docstring stringlengths 14 108k | unified stringlengths 45 133k |
|---|---|---|---|---|---|---|---|---|---|
0ee5b6155418c826e06c8e6f57998720d81afb77e686d50abc57e9b7adac33e9 | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_fail(self, mock_request):
'Create package with streaming resource, which failed to create\n resource.'
base_url = 'https://demo.ckan.org/api/3/action/'
package_create_url = '{}package_create'.format(base_url)
resource_c... | Create package with streaming resource, which failed to create
resource. | tests/test_dump_to_ckan.py | test_dump_to_ckan_package_create_streaming_resource_fail | OriHoch/datapackage-pipelines-ckan | 0 | python | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_fail(self, mock_request):
'Create package with streaming resource, which failed to create\n resource.'
base_url = 'https://demo.ckan.org/api/3/action/'
package_create_url = '{}package_create'.format(base_url)
resource_c... | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_fail(self, mock_request):
'Create package with streaming resource, which failed to create\n resource.'
base_url = 'https://demo.ckan.org/api/3/action/'
package_create_url = '{}package_create'.format(base_url)
resource_c... |
12caa0c4be2a07649c7c4d7e2a43b68995f137c8f30292e70aa8e6d70a76250c | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_datastore(self, mock_request):
'Create package with streaming resource, and pushing to datastore.'
package_id = 'ckan-package-id'
base_url = 'https://demo.ckan.org/api/3/action/'
package_create_url = '{}package_create'.format(... | Create package with streaming resource, and pushing to datastore. | tests/test_dump_to_ckan.py | test_dump_to_ckan_package_create_streaming_resource_datastore | OriHoch/datapackage-pipelines-ckan | 0 | python | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_datastore(self, mock_request):
package_id = 'ckan-package-id'
base_url = 'https://demo.ckan.org/api/3/action/'
package_create_url = '{}package_create'.format(base_url)
resource_create_url = '{}resource_create'.format(base... | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_datastore(self, mock_request):
package_id = 'ckan-package-id'
base_url = 'https://demo.ckan.org/api/3/action/'
package_create_url = '{}package_create'.format(base_url)
resource_create_url = '{}resource_create'.format(base... |
411617de1442840d3eeeff65e64d39852e19fa47a2fec0013d97f7cbe2b073a7 | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_datastore_method_invalid(self, mock_request):
'Create package with streaming resource, and pushing to datastore,\n with an invalid method.'
datapackage = {'name': 'my-datapackage', 'project': 'my-project', 'resources': [{'dpp:s... | Create package with streaming resource, and pushing to datastore,
with an invalid method. | tests/test_dump_to_ckan.py | test_dump_to_ckan_package_create_streaming_resource_datastore_method_invalid | OriHoch/datapackage-pipelines-ckan | 0 | python | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_datastore_method_invalid(self, mock_request):
'Create package with streaming resource, and pushing to datastore,\n with an invalid method.'
datapackage = {'name': 'my-datapackage', 'project': 'my-project', 'resources': [{'dpp:s... | @requests_mock.mock()
def test_dump_to_ckan_package_create_streaming_resource_datastore_method_invalid(self, mock_request):
'Create package with streaming resource, and pushing to datastore,\n with an invalid method.'
datapackage = {'name': 'my-datapackage', 'project': 'my-project', 'resources': [{'dpp:s... |
b15de31dc9318c0ab0937da6d46ec0ad77d604df52e3a10394ef679603910114 | def __init__(self, num_features, training_window, training_interval):
'\n num_features: the length of the feature vector\n training_window: the number of previous data points to train on\n training_interval: the number of data points between training periods\n '
self.num_features = n... | num_features: the length of the feature vector
training_window: the number of previous data points to train on
training_interval: the number of data points between training periods | modules/algo.py | __init__ | apadin1/Merit-Smart-Grid-Analytics | 10 | python | def __init__(self, num_features, training_window, training_interval):
'\n num_features: the length of the feature vector\n training_window: the number of previous data points to train on\n training_interval: the number of data points between training periods\n '
self.num_features = n... | def __init__(self, num_features, training_window, training_interval):
'\n num_features: the length of the feature vector\n training_window: the number of previous data points to train on\n training_interval: the number of data points between training periods\n '
self.num_features = n... |
f1ba96c08a9301c3251d4abd63184380b1536e04548485ed80ff6a7ba3c97b0b | def run(self, sample):
'\n Add a single sample to the data pool.\n The sample should be a feature vector: {x_1, x_2, x_3, ..., x_n, y}\n Where x_1->x_n are features and y is the target value\n '
try:
assert (len(sample) == (self.num_features + 1))
except AssertionError:
... | Add a single sample to the data pool.
The sample should be a feature vector: {x_1, x_2, x_3, ..., x_n, y}
Where x_1->x_n are features and y is the target value | modules/algo.py | run | apadin1/Merit-Smart-Grid-Analytics | 10 | python | def run(self, sample):
'\n Add a single sample to the data pool.\n The sample should be a feature vector: {x_1, x_2, x_3, ..., x_n, y}\n Where x_1->x_n are features and y is the target value\n '
try:
assert (len(sample) == (self.num_features + 1))
except AssertionError:
... | def run(self, sample):
'\n Add a single sample to the data pool.\n The sample should be a feature vector: {x_1, x_2, x_3, ..., x_n, y}\n Where x_1->x_n are features and y is the target value\n '
try:
assert (len(sample) == (self.num_features + 1))
except AssertionError:
... |
3b2685ea48265d2b9dea3e77b55f4c0c9a7c37a6ef2a775ac7020d5ab35df883 | def train(self):
'Train the prediction and anomaly detection models'
X = np.matrix(self.samples)
y = np.array(self.targets).flatten()
(w_opt, alpha, beta, S_N) = blr.sklearn_train(X, y)
self.model.fit(X, y)
self.severity.update_params(beta, S_N) | Train the prediction and anomaly detection models | modules/algo.py | train | apadin1/Merit-Smart-Grid-Analytics | 10 | python | def train(self):
X = np.matrix(self.samples)
y = np.array(self.targets).flatten()
(w_opt, alpha, beta, S_N) = blr.sklearn_train(X, y)
self.model.fit(X, y)
self.severity.update_params(beta, S_N) | def train(self):
X = np.matrix(self.samples)
y = np.array(self.targets).flatten()
(w_opt, alpha, beta, S_N) = blr.sklearn_train(X, y)
self.model.fit(X, y)
self.severity.update_params(beta, S_N)<|docstring|>Train the prediction and anomaly detection models<|endoftext|> |
8812e77a7246ac1e7d850c33f04c67b7fc19824d5d94af3ddd53b501acfb40d3 | def set_severity(self, w, L):
'Change the severity parameters'
self.severity.set_wL(w, L) | Change the severity parameters | modules/algo.py | set_severity | apadin1/Merit-Smart-Grid-Analytics | 10 | python | def set_severity(self, w, L):
self.severity.set_wL(w, L) | def set_severity(self, w, L):
self.severity.set_wL(w, L)<|docstring|>Change the severity parameters<|endoftext|> |
becf1fb31f43e6327ae590b8af3952a97b53baca8d1a2f0100b8648b6fde1ba0 | def set_EWMA(self, alpha):
'Change the EWMA (exponential weighted moving average) weight'
self.alpha = alpha | Change the EWMA (exponential weighted moving average) weight | modules/algo.py | set_EWMA | apadin1/Merit-Smart-Grid-Analytics | 10 | python | def set_EWMA(self, alpha):
self.alpha = alpha | def set_EWMA(self, alpha):
self.alpha = alpha<|docstring|>Change the EWMA (exponential weighted moving average) weight<|endoftext|> |
93371873268052aa436a894b3a1e49894373fb1442bedc0b87ead9a14ae6d6be | def main(training_data_file_path, test_data_file_path, grid_results_file_path, image_plot_file_path):
'\n Entry point for script. Takes in training_data_file_path, test_data_file_path\n and image_plot_file_path from commandline, and runs a pre-optimized linear regression\n model. \n\n Arguments:\n --... | Entry point for script. Takes in training_data_file_path, test_data_file_path
and image_plot_file_path from commandline, and runs a pre-optimized linear regression
model.
Arguments:
----------
training_data_file_path
- file path where training data is located. Assumes data is a .csv file in same
format as da... | src/linear_model.py | main | RobBlumberg/DSCI_522_Group_302 | 1 | python | def main(training_data_file_path, test_data_file_path, grid_results_file_path, image_plot_file_path):
'\n Entry point for script. Takes in training_data_file_path, test_data_file_path\n and image_plot_file_path from commandline, and runs a pre-optimized linear regression\n model. \n\n Arguments:\n --... | def main(training_data_file_path, test_data_file_path, grid_results_file_path, image_plot_file_path):
'\n Entry point for script. Takes in training_data_file_path, test_data_file_path\n and image_plot_file_path from commandline, and runs a pre-optimized linear regression\n model. \n\n Arguments:\n --... |
de3dd6c01579a6c3f1234d03ad66123509a4c9921d361de2686952aead6e2346 | def time_parser(input_time):
'\n Function which converts a time string of form mm.ss.SS to seconds\n \n Arguments:\n ----------\n input_time \n (str) - input time as string of form "d.dd.dd" where d is a digit\n\n Returns:\n --------\n float representing input time in seconds\n '
... | Function which converts a time string of form mm.ss.SS to seconds
Arguments:
----------
input_time
(str) - input time as string of form "d.dd.dd" where d is a digit
Returns:
--------
float representing input time in seconds | src/linear_model.py | time_parser | RobBlumberg/DSCI_522_Group_302 | 1 | python | def time_parser(input_time):
'\n Function which converts a time string of form mm.ss.SS to seconds\n \n Arguments:\n ----------\n input_time \n (str) - input time as string of form "d.dd.dd" where d is a digit\n\n Returns:\n --------\n float representing input time in seconds\n '
... | def time_parser(input_time):
'\n Function which converts a time string of form mm.ss.SS to seconds\n \n Arguments:\n ----------\n input_time \n (str) - input time as string of form "d.dd.dd" where d is a digit\n\n Returns:\n --------\n float representing input time in seconds\n '
... |
866c40d27dc9d37d25b8c448cff1fc5af999098417641a213e3c97d5e340af1a | def load_and_parse_data(training_data_file_path, test_data_file_path):
'\n Data loading and cleaning function. Converts finishtime column to seconds\n and drops rows where finishtime is 0. \n\n Arguments:\n ----------\n training_data_file_path \n - file path where training data is located. Ass... | Data loading and cleaning function. Converts finishtime column to seconds
and drops rows where finishtime is 0.
Arguments:
----------
training_data_file_path
- file path where training data is located. Assumes data is a .csv file in same
format as data/data_train.csv (output of download_data.py script)
test_... | src/linear_model.py | load_and_parse_data | RobBlumberg/DSCI_522_Group_302 | 1 | python | def load_and_parse_data(training_data_file_path, test_data_file_path):
'\n Data loading and cleaning function. Converts finishtime column to seconds\n and drops rows where finishtime is 0. \n\n Arguments:\n ----------\n training_data_file_path \n - file path where training data is located. Ass... | def load_and_parse_data(training_data_file_path, test_data_file_path):
'\n Data loading and cleaning function. Converts finishtime column to seconds\n and drops rows where finishtime is 0. \n\n Arguments:\n ----------\n training_data_file_path \n - file path where training data is located. Ass... |
350e8bfb6d7c6d9af2299823f339d1f723cc7a8870ec7567adffece06a4ec2f0 | def data_preprocessing(training_data_file_path, test_data_file_path):
'\n Data preprocessing for linear regression. Applies imputer (mean), \n and polynomial order 5 tranformation to numeric features. Applies \n imputer (fill with "not_specified" constant value) and one-hot encoding\n to categorical fea... | Data preprocessing for linear regression. Applies imputer (mean),
and polynomial order 5 tranformation to numeric features. Applies
imputer (fill with "not_specified" constant value) and one-hot encoding
to categorical features. Uses output of load_and_parse_data() function.
Arguments:
----------
training_data_file_... | src/linear_model.py | data_preprocessing | RobBlumberg/DSCI_522_Group_302 | 1 | python | def data_preprocessing(training_data_file_path, test_data_file_path):
'\n Data preprocessing for linear regression. Applies imputer (mean), \n and polynomial order 5 tranformation to numeric features. Applies \n imputer (fill with "not_specified" constant value) and one-hot encoding\n to categorical fea... | def data_preprocessing(training_data_file_path, test_data_file_path):
'\n Data preprocessing for linear regression. Applies imputer (mean), \n and polynomial order 5 tranformation to numeric features. Applies \n imputer (fill with "not_specified" constant value) and one-hot encoding\n to categorical fea... |
7fd59b2b4b07e653bffe874e597c889982b1fc1a83c5dca3a47f050dbca6a999 | def linear_model_results(training_data_file_path, test_data_file_path, grid_results_file_path):
'\n Fits pre-optimized linear regression model on training data,\n and makes predictions on test data. Uses output of \n data_preprocessing() function.\n\n Arguments:\n ----------\n training_data_file_p... | Fits pre-optimized linear regression model on training data,
and makes predictions on test data. Uses output of
data_preprocessing() function.
Arguments:
----------
training_data_file_path
- file path where training data is located. Assumes data is a .csv file in same
format as data/data_train.csv (output of... | src/linear_model.py | linear_model_results | RobBlumberg/DSCI_522_Group_302 | 1 | python | def linear_model_results(training_data_file_path, test_data_file_path, grid_results_file_path):
'\n Fits pre-optimized linear regression model on training data,\n and makes predictions on test data. Uses output of \n data_preprocessing() function.\n\n Arguments:\n ----------\n training_data_file_p... | def linear_model_results(training_data_file_path, test_data_file_path, grid_results_file_path):
'\n Fits pre-optimized linear regression model on training data,\n and makes predictions on test data. Uses output of \n data_preprocessing() function.\n\n Arguments:\n ----------\n training_data_file_p... |
d13ae664411753906bba0ae3483541e1d2a84c048b80207600fb134cc434b6b8 | def plot_results(training_data_file_path, test_data_file_path, grid_results_file_path, image_plot_file_path):
'\n Plots results from linear regression on test set. Uses output of \n linear_model_results() function. Saves plot to specified file path.\n\n Arguments:\n ----------\n training_data_file_pa... | Plots results from linear regression on test set. Uses output of
linear_model_results() function. Saves plot to specified file path.
Arguments:
----------
training_data_file_path
- file path where training data is located. Assumes data is a .csv file in same
format as data/data_train.csv (output of download_... | src/linear_model.py | plot_results | RobBlumberg/DSCI_522_Group_302 | 1 | python | def plot_results(training_data_file_path, test_data_file_path, grid_results_file_path, image_plot_file_path):
'\n Plots results from linear regression on test set. Uses output of \n linear_model_results() function. Saves plot to specified file path.\n\n Arguments:\n ----------\n training_data_file_pa... | def plot_results(training_data_file_path, test_data_file_path, grid_results_file_path, image_plot_file_path):
'\n Plots results from linear regression on test set. Uses output of \n linear_model_results() function. Saves plot to specified file path.\n\n Arguments:\n ----------\n training_data_file_pa... |
1836b3db7b85cdeaadbbe9acc1b70764bd6d4e777f20ed40bb5fd67570cb1e69 | def setup() -> None:
'Set up loggers.'
logging.TRACE = TRACE_LEVEL
logging.addLevelName(TRACE_LEVEL, 'TRACE')
Logger.trace = _monkeypatch_trace
log_level = (TRACE_LEVEL if constants.DEBUG_MODE else logging.INFO)
format_string = '%(asctime)s | %(name)s | %(levelname)s | %(message)s'
log_forma... | Set up loggers. | griffinbot/logging.py | setup | MrAwesomeRocks/griffinbot | 2 | python | def setup() -> None:
logging.TRACE = TRACE_LEVEL
logging.addLevelName(TRACE_LEVEL, 'TRACE')
Logger.trace = _monkeypatch_trace
log_level = (TRACE_LEVEL if constants.DEBUG_MODE else logging.INFO)
format_string = '%(asctime)s | %(name)s | %(levelname)s | %(message)s'
log_format = logging.Forma... | def setup() -> None:
logging.TRACE = TRACE_LEVEL
logging.addLevelName(TRACE_LEVEL, 'TRACE')
Logger.trace = _monkeypatch_trace
log_level = (TRACE_LEVEL if constants.DEBUG_MODE else logging.INFO)
format_string = '%(asctime)s | %(name)s | %(levelname)s | %(message)s'
log_format = logging.Forma... |
50d8bb4a88ade8b215abb73fe2e1ef22d085dfa6251c059b02e092829a49a54c | def _monkeypatch_trace(self: logging.Logger, msg: str, *args, **kwargs) -> None:
'\n Log \'msg % args\' with severity \'TRACE\'.\n\n To pass exception information, use the keyword argument exc_info with\n a true value, e.g.\n logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)\n ... | Log 'msg % args' with severity 'TRACE'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.trace("Houston, we have an %s", "interesting problem", exc_info=1) | griffinbot/logging.py | _monkeypatch_trace | MrAwesomeRocks/griffinbot | 2 | python | def _monkeypatch_trace(self: logging.Logger, msg: str, *args, **kwargs) -> None:
'\n Log \'msg % args\' with severity \'TRACE\'.\n\n To pass exception information, use the keyword argument exc_info with\n a true value, e.g.\n logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)\n ... | def _monkeypatch_trace(self: logging.Logger, msg: str, *args, **kwargs) -> None:
'\n Log \'msg % args\' with severity \'TRACE\'.\n\n To pass exception information, use the keyword argument exc_info with\n a true value, e.g.\n logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)\n ... |
5ca93845bb0f5878a4477faaa81d753303838d4e425b4d14300f76226936d115 | def box_to_point8(boxes):
'\n Args:\n boxes: nx4\n\n Returns:\n (nx4)x2\n '
b = boxes[(:, [0, 1, 2, 3, 0, 3, 2, 1])]
b = b.reshape(((- 1), 2))
return b | Args:
boxes: nx4
Returns:
(nx4)x2 | official/vision/detection/GSOC 21/Mask RCNN/Experiments/Experiment 01/Custom Code Base/common.py | box_to_point8 | Anustup900/models | 0 | python | def box_to_point8(boxes):
'\n Args:\n boxes: nx4\n\n Returns:\n (nx4)x2\n '
b = boxes[(:, [0, 1, 2, 3, 0, 3, 2, 1])]
b = b.reshape(((- 1), 2))
return b | def box_to_point8(boxes):
'\n Args:\n boxes: nx4\n\n Returns:\n (nx4)x2\n '
b = boxes[(:, [0, 1, 2, 3, 0, 3, 2, 1])]
b = b.reshape(((- 1), 2))
return b<|docstring|>Args:
boxes: nx4
Returns:
(nx4)x2<|endoftext|> |
145b3e556a0d30f6a9f11b19f5a5a241091c9b9bb6f2ab33a1819112669a27f1 | def point8_to_box(points):
'\n Args:\n points: (nx4)x2\n Returns:\n nx4 boxes (x1y1x2y2)\n '
p = points.reshape(((- 1), 4, 2))
minxy = p.min(axis=1)
maxxy = p.max(axis=1)
return np.concatenate((minxy, maxxy), axis=1) | Args:
points: (nx4)x2
Returns:
nx4 boxes (x1y1x2y2) | official/vision/detection/GSOC 21/Mask RCNN/Experiments/Experiment 01/Custom Code Base/common.py | point8_to_box | Anustup900/models | 0 | python | def point8_to_box(points):
'\n Args:\n points: (nx4)x2\n Returns:\n nx4 boxes (x1y1x2y2)\n '
p = points.reshape(((- 1), 4, 2))
minxy = p.min(axis=1)
maxxy = p.max(axis=1)
return np.concatenate((minxy, maxxy), axis=1) | def point8_to_box(points):
'\n Args:\n points: (nx4)x2\n Returns:\n nx4 boxes (x1y1x2y2)\n '
p = points.reshape(((- 1), 4, 2))
minxy = p.min(axis=1)
maxxy = p.max(axis=1)
return np.concatenate((minxy, maxxy), axis=1)<|docstring|>Args:
points: (nx4)x2
Returns:
nx4 boxes... |
630b9dd4851d42e554f68f7ee013c01d756c4a3a1de9c170693e4298be952640 | def segmentation_to_mask(polys, height, width):
'\n Convert polygons to binary masks.\n\n Args:\n polys: a list of nx2 float array. Each array contains many (x, y) coordinates.\n\n Returns:\n a binary matrix of (height, width)\n '
polys = [p.flatten().tolist() for p in polys]
asser... | Convert polygons to binary masks.
Args:
polys: a list of nx2 float array. Each array contains many (x, y) coordinates.
Returns:
a binary matrix of (height, width) | official/vision/detection/GSOC 21/Mask RCNN/Experiments/Experiment 01/Custom Code Base/common.py | segmentation_to_mask | Anustup900/models | 0 | python | def segmentation_to_mask(polys, height, width):
'\n Convert polygons to binary masks.\n\n Args:\n polys: a list of nx2 float array. Each array contains many (x, y) coordinates.\n\n Returns:\n a binary matrix of (height, width)\n '
polys = [p.flatten().tolist() for p in polys]
asser... | def segmentation_to_mask(polys, height, width):
'\n Convert polygons to binary masks.\n\n Args:\n polys: a list of nx2 float array. Each array contains many (x, y) coordinates.\n\n Returns:\n a binary matrix of (height, width)\n '
polys = [p.flatten().tolist() for p in polys]
asser... |
d9d36c0afb29100c1a40af457fc05eec463fd383254775fe9181f2bc08272413 | def clip_boxes(boxes, shape):
'\n Args:\n boxes: (...)x4, float\n shape: h, w\n '
orig_shape = boxes.shape
boxes = boxes.reshape([(- 1), 4])
(h, w) = shape
boxes[(:, [0, 1])] = np.maximum(boxes[(:, [0, 1])], 0)
boxes[(:, 2)] = np.minimum(boxes[(:, 2)], w)
boxes[(:, 3)] = ... | Args:
boxes: (...)x4, float
shape: h, w | official/vision/detection/GSOC 21/Mask RCNN/Experiments/Experiment 01/Custom Code Base/common.py | clip_boxes | Anustup900/models | 0 | python | def clip_boxes(boxes, shape):
'\n Args:\n boxes: (...)x4, float\n shape: h, w\n '
orig_shape = boxes.shape
boxes = boxes.reshape([(- 1), 4])
(h, w) = shape
boxes[(:, [0, 1])] = np.maximum(boxes[(:, [0, 1])], 0)
boxes[(:, 2)] = np.minimum(boxes[(:, 2)], w)
boxes[(:, 3)] = ... | def clip_boxes(boxes, shape):
'\n Args:\n boxes: (...)x4, float\n shape: h, w\n '
orig_shape = boxes.shape
boxes = boxes.reshape([(- 1), 4])
(h, w) = shape
boxes[(:, [0, 1])] = np.maximum(boxes[(:, [0, 1])], 0)
boxes[(:, 2)] = np.minimum(boxes[(:, 2)], w)
boxes[(:, 3)] = ... |
1f0324be435ce4f142789645a5f974b9f26a050363d1b4843a4283c0ff2795f8 | def filter_boxes_inside_shape(boxes, shape):
'\n Args:\n boxes: (nx4), float\n shape: (h, w)\n\n Returns:\n indices: (k, )\n selection: (kx4)\n '
assert (boxes.ndim == 2), boxes.shape
assert (len(shape) == 2), shape
(h, w) = shape
indices = np.where(((((boxes[(:,... | Args:
boxes: (nx4), float
shape: (h, w)
Returns:
indices: (k, )
selection: (kx4) | official/vision/detection/GSOC 21/Mask RCNN/Experiments/Experiment 01/Custom Code Base/common.py | filter_boxes_inside_shape | Anustup900/models | 0 | python | def filter_boxes_inside_shape(boxes, shape):
'\n Args:\n boxes: (nx4), float\n shape: (h, w)\n\n Returns:\n indices: (k, )\n selection: (kx4)\n '
assert (boxes.ndim == 2), boxes.shape
assert (len(shape) == 2), shape
(h, w) = shape
indices = np.where(((((boxes[(:,... | def filter_boxes_inside_shape(boxes, shape):
'\n Args:\n boxes: (nx4), float\n shape: (h, w)\n\n Returns:\n indices: (k, )\n selection: (kx4)\n '
assert (boxes.ndim == 2), boxes.shape
assert (len(shape) == 2), shape
(h, w) = shape
indices = np.where(((((boxes[(:,... |
126d71a0b7dcc437f2bb54725d84e2c48f7205021c26ec9778fd5f6fa97599d9 | def __init__(self, short_edge_length, max_size, interp=cv2.INTER_LINEAR):
'\n Args:\n short_edge_length ([int, int]): a [min, max] interval from which to sample the\n shortest edge length.\n max_size (int): maximum allowed longest edge length.\n '
super(CustomR... | Args:
short_edge_length ([int, int]): a [min, max] interval from which to sample the
shortest edge length.
max_size (int): maximum allowed longest edge length. | official/vision/detection/GSOC 21/Mask RCNN/Experiments/Experiment 01/Custom Code Base/common.py | __init__ | Anustup900/models | 0 | python | def __init__(self, short_edge_length, max_size, interp=cv2.INTER_LINEAR):
'\n Args:\n short_edge_length ([int, int]): a [min, max] interval from which to sample the\n shortest edge length.\n max_size (int): maximum allowed longest edge length.\n '
super(CustomR... | def __init__(self, short_edge_length, max_size, interp=cv2.INTER_LINEAR):
'\n Args:\n short_edge_length ([int, int]): a [min, max] interval from which to sample the\n shortest edge length.\n max_size (int): maximum allowed longest edge length.\n '
super(CustomR... |
37aa7d3b7de8ab9cdad95fe60a5d38c0b413948061bdfde71748a7783c277ade | def __init__(self, filename=None):
'Create a Document instance.'
self.filename = filename
self.filepath = None
self.filedir = None
self.filebase = None
self.fileext = None
if self.filename:
self.filepath = os.path.realpath(self.filename)
(self.filedir, self.filename) = os.pat... | Create a Document instance. | Lib/site-packages/wx-2.8-msw-unicode/wx/py/document.py | __init__ | William22FM/RobotTest | 27 | python | def __init__(self, filename=None):
self.filename = filename
self.filepath = None
self.filedir = None
self.filebase = None
self.fileext = None
if self.filename:
self.filepath = os.path.realpath(self.filename)
(self.filedir, self.filename) = os.path.split(self.filepath)
... | def __init__(self, filename=None):
self.filename = filename
self.filepath = None
self.filedir = None
self.filebase = None
self.fileext = None
if self.filename:
self.filepath = os.path.realpath(self.filename)
(self.filedir, self.filename) = os.path.split(self.filepath)
... |
1c766bba7dc0d9cd00337dead08a8d3bc13721724acb313d30cc19e65a4657ee | def read(self):
'Return contents of file.'
if (self.filepath and os.path.exists(self.filepath)):
f = file(self.filepath, 'rb')
try:
return f.read()
finally:
f.close()
else:
return '' | Return contents of file. | Lib/site-packages/wx-2.8-msw-unicode/wx/py/document.py | read | William22FM/RobotTest | 27 | python | def read(self):
if (self.filepath and os.path.exists(self.filepath)):
f = file(self.filepath, 'rb')
try:
return f.read()
finally:
f.close()
else:
return | def read(self):
if (self.filepath and os.path.exists(self.filepath)):
f = file(self.filepath, 'rb')
try:
return f.read()
finally:
f.close()
else:
return <|docstring|>Return contents of file.<|endoftext|> |
aa7503244b15d4a1395a9d9fa5946d44f5e63a21ca9a6fa61f4ff62baf745c20 | def write(self, text):
'Write text to file.'
try:
f = file(self.filepath, 'wb')
f.write(text)
finally:
if f:
f.close() | Write text to file. | Lib/site-packages/wx-2.8-msw-unicode/wx/py/document.py | write | William22FM/RobotTest | 27 | python | def write(self, text):
try:
f = file(self.filepath, 'wb')
f.write(text)
finally:
if f:
f.close() | def write(self, text):
try:
f = file(self.filepath, 'wb')
f.write(text)
finally:
if f:
f.close()<|docstring|>Write text to file.<|endoftext|> |
93d10f6357bf6a9f343c8a652daa16621f3e7cea10843e6b69450519feb97096 | @quo.group()
def scan():
'Scan an IP/ netblock using Shodan.'
pass | Scan an IP/ netblock using Shodan. | src/expositor/cli/scan.py | scan | secretuminc/expositor | 1 | python | @quo.group()
def scan():
pass | @quo.group()
def scan():
pass<|docstring|>Scan an IP/ netblock using Shodan.<|endoftext|> |
e063526a878eaf774cc423d56ec0d9e4e698cabbffae00b22ffd293cc9625107 | @scan.command(name='list')
def scan_list():
'Show recently launched scans'
key = get_api_key()
api = shodan.Shodan(key)
try:
scans = api.scans()
except shodan.APIError as e:
raise quo.QuoException(e.value)
if (len(scans) > 0):
quo.echo(u'# {} Scans Total - Showing 10 most... | Show recently launched scans | src/expositor/cli/scan.py | scan_list | secretuminc/expositor | 1 | python | @scan.command(name='list')
def scan_list():
key = get_api_key()
api = shodan.Shodan(key)
try:
scans = api.scans()
except shodan.APIError as e:
raise quo.QuoException(e.value)
if (len(scans) > 0):
quo.echo(u'# {} Scans Total - Showing 10 most recent scans:'.format(scans['... | @scan.command(name='list')
def scan_list():
key = get_api_key()
api = shodan.Shodan(key)
try:
scans = api.scans()
except shodan.APIError as e:
raise quo.QuoException(e.value)
if (len(scans) > 0):
quo.echo(u'# {} Scans Total - Showing 10 most recent scans:'.format(scans['... |
3b9ef00015e6ccabb6c1a541fba09ab4b486bfb5cf4901d55bff4459452f98b3 | @scan.command(name='internet')
@quo.option('--quiet', help='Disable the printing of information to the screen.', default=False, is_flag=True)
@quo.argument('port', type=int)
@quo.argument('protocol', type=str)
def scan_internet(quiet, port, protocol):
'Scan the Internet for a specific port and protocol using the Sh... | Scan the Internet for a specific port and protocol using the Shodan infrastructure. | src/expositor/cli/scan.py | scan_internet | secretuminc/expositor | 1 | python | @scan.command(name='internet')
@quo.option('--quiet', help='Disable the printing of information to the screen.', default=False, is_flag=True)
@quo.argument('port', type=int)
@quo.argument('protocol', type=str)
def scan_internet(quiet, port, protocol):
key = get_api_key()
api = shodan.Shodan(key)
try:
... | @scan.command(name='internet')
@quo.option('--quiet', help='Disable the printing of information to the screen.', default=False, is_flag=True)
@quo.argument('port', type=int)
@quo.argument('protocol', type=str)
def scan_internet(quiet, port, protocol):
key = get_api_key()
api = shodan.Shodan(key)
try:
... |
0c389d7e4cb6df782dfb3988dace0fff92abd9ad41a4ebfc7376a6c9c7498054 | @scan.command(name='protocols')
def scan_protocols():
'List the protocols that you can scan with using Shodan.'
key = get_api_key()
api = shodan.Shodan(key)
try:
protocols = api.protocols()
for (name, description) in iter(protocols.items()):
quo.echo((quo.style('{0:<30}'.form... | List the protocols that you can scan with using Shodan. | src/expositor/cli/scan.py | scan_protocols | secretuminc/expositor | 1 | python | @scan.command(name='protocols')
def scan_protocols():
key = get_api_key()
api = shodan.Shodan(key)
try:
protocols = api.protocols()
for (name, description) in iter(protocols.items()):
quo.echo((quo.style('{0:<30}'.format(name), fg='cyan') + description))
except shodan.AP... | @scan.command(name='protocols')
def scan_protocols():
key = get_api_key()
api = shodan.Shodan(key)
try:
protocols = api.protocols()
for (name, description) in iter(protocols.items()):
quo.echo((quo.style('{0:<30}'.format(name), fg='cyan') + description))
except shodan.AP... |
af72eaafcda9a8fba06f7131865920087593d578b0cb6feddaa5641a24b397a4 | @scan.command(name='submit')
@quo.option('--wait', help='How long to wait for results to come back. If this is set to "0" or below return immediately.', default=20, type=int)
@quo.option('--filename', help='Save the results in the given file.', default='', type=str)
@quo.option('--force', default=False, is_flag=True)
@... | Scan an IP/ netblock using Shodan. | src/expositor/cli/scan.py | scan_submit | secretuminc/expositor | 1 | python | @scan.command(name='submit')
@quo.option('--wait', help='How long to wait for results to come back. If this is set to "0" or below return immediately.', default=20, type=int)
@quo.option('--filename', help='Save the results in the given file.', default=, type=str)
@quo.option('--force', default=False, is_flag=True)
@qu... | @scan.command(name='submit')
@quo.option('--wait', help='How long to wait for results to come back. If this is set to "0" or below return immediately.', default=20, type=int)
@quo.option('--filename', help='Save the results in the given file.', default=, type=str)
@quo.option('--force', default=False, is_flag=True)
@qu... |
2ae2f2e49ee4ce90a477cdfabbf51be71a73c358256379e4a991511c14a55d02 | @scan.command(name='status')
@quo.argument('scan_id', type=str)
def scan_status(scan_id):
'Check the status of an on-demand scan.'
key = get_api_key()
api = shodan.Shodan(key)
try:
scan = api.scan_status(scan_id)
quo.echo(scan['status'])
except shodan.APIError as e:
raise quo... | Check the status of an on-demand scan. | src/expositor/cli/scan.py | scan_status | secretuminc/expositor | 1 | python | @scan.command(name='status')
@quo.argument('scan_id', type=str)
def scan_status(scan_id):
key = get_api_key()
api = shodan.Shodan(key)
try:
scan = api.scan_status(scan_id)
quo.echo(scan['status'])
except shodan.APIError as e:
raise quo.QuoException(e.value) | @scan.command(name='status')
@quo.argument('scan_id', type=str)
def scan_status(scan_id):
key = get_api_key()
api = shodan.Shodan(key)
try:
scan = api.scan_status(scan_id)
quo.echo(scan['status'])
except shodan.APIError as e:
raise quo.QuoException(e.value)<|docstring|>Check... |
edbeafc48750dad5450a25cba564d344f2e0bb7f19a27d59ab40b01f4202b6f1 | def spheric_to_cartesian(phi, theta, rho):
' Spheric to cartesian coordinates '
if hasattr(phi, '__iter__'):
n = len(phi)
elif hasattr(theta, '__iter__'):
n = len(theta)
elif hasattr(rho, '__iter__'):
n = len(rho)
P = np.empty((n, 3), dtype=np.float32)
sin_theta = np.sin(... | Spheric to cartesian coordinates | examples/earth.py | spheric_to_cartesian | CodeDoes/glumpy | 1,074 | python | def spheric_to_cartesian(phi, theta, rho):
' '
if hasattr(phi, '__iter__'):
n = len(phi)
elif hasattr(theta, '__iter__'):
n = len(theta)
elif hasattr(rho, '__iter__'):
n = len(rho)
P = np.empty((n, 3), dtype=np.float32)
sin_theta = np.sin(theta)
P[(:, 0)] = ((sin_the... | def spheric_to_cartesian(phi, theta, rho):
' '
if hasattr(phi, '__iter__'):
n = len(phi)
elif hasattr(theta, '__iter__'):
n = len(theta)
elif hasattr(rho, '__iter__'):
n = len(rho)
P = np.empty((n, 3), dtype=np.float32)
sin_theta = np.sin(theta)
P[(:, 0)] = ((sin_the... |
21991ae8a1567b5d1257b269d1f966300b217ba4c4d6b2e64edeafb14d386148 | def get_data_element_impls(reload_modules=False):
'\n Discover and return discovered ``DataElement`` classes. Keys in the\n returned map are the names of the discovered classes, and the paired values\n are the actual class type objects.\n\n We search for implementation classes in:\n - modules nex... | Discover and return discovered ``DataElement`` classes. Keys in the
returned map are the names of the discovered classes, and the paired values
are the actual class type objects.
We search for implementation classes in:
- modules next to this file this function is defined in (ones that begin
with an alphanum... | python/smqtk/representation/data_element/__init__.py | get_data_element_impls | jbeezley/SMQTK | 1 | python | def get_data_element_impls(reload_modules=False):
'\n Discover and return discovered ``DataElement`` classes. Keys in the\n returned map are the names of the discovered classes, and the paired values\n are the actual class type objects.\n\n We search for implementation classes in:\n - modules nex... | def get_data_element_impls(reload_modules=False):
'\n Discover and return discovered ``DataElement`` classes. Keys in the\n returned map are the names of the discovered classes, and the paired values\n are the actual class type objects.\n\n We search for implementation classes in:\n - modules nex... |
e11f072aa5f7bd92fb0ef3d528aab65cb11b397bb794efe3ac897fd74e5fc9ff | def from_uri(uri, impl_generator=get_data_element_impls):
'\n Create a data element instance from available plugin implementations.\n\n The first implementation that can resolve the URI is what is returned. If no\n implementations can resolve the URL, an ``InvalidUriError`` is raised.\n\n :param uri: UR... | Create a data element instance from available plugin implementations.
The first implementation that can resolve the URI is what is returned. If no
implementations can resolve the URL, an ``InvalidUriError`` is raised.
:param uri: URI to try to resolve into a DataElement instance.
:type uri: str
:param impl_generator... | python/smqtk/representation/data_element/__init__.py | from_uri | jbeezley/SMQTK | 1 | python | def from_uri(uri, impl_generator=get_data_element_impls):
'\n Create a data element instance from available plugin implementations.\n\n The first implementation that can resolve the URI is what is returned. If no\n implementations can resolve the URL, an ``InvalidUriError`` is raised.\n\n :param uri: UR... | def from_uri(uri, impl_generator=get_data_element_impls):
'\n Create a data element instance from available plugin implementations.\n\n The first implementation that can resolve the URI is what is returned. If no\n implementations can resolve the URL, an ``InvalidUriError`` is raised.\n\n :param uri: UR... |
e9c93a8e8229862da58e19dce9f0287b4814a06a2cef39b7cf63edf1a4c2a345 | @classmethod
def from_uri(cls, uri):
'\n Construct a new instance based on the given URI.\n\n This function may not be implemented for all DataElement types.\n\n :param uri: URI string to resolve into an element instance\n :type uri: str\n\n :raises NoUriResolutionError: This elem... | Construct a new instance based on the given URI.
This function may not be implemented for all DataElement types.
:param uri: URI string to resolve into an element instance
:type uri: str
:raises NoUriResolutionError: This element type does not implement URI
resolution.
:raises smqtk.exceptions.InvalidUriError: T... | python/smqtk/representation/data_element/__init__.py | from_uri | jbeezley/SMQTK | 1 | python | @classmethod
def from_uri(cls, uri):
'\n Construct a new instance based on the given URI.\n\n This function may not be implemented for all DataElement types.\n\n :param uri: URI string to resolve into an element instance\n :type uri: str\n\n :raises NoUriResolutionError: This elem... | @classmethod
def from_uri(cls, uri):
'\n Construct a new instance based on the given URI.\n\n This function may not be implemented for all DataElement types.\n\n :param uri: URI string to resolve into an element instance\n :type uri: str\n\n :raises NoUriResolutionError: This elem... |
cacee0461d35c9438b13166c00c6dd51df3febdcbc2d6bcecb7645950499666b | def _write_new_temp(self, d):
'\n Actually write our bytes to a new temp file\n Always creates new file.\n\n :param d: directory to write temp file in or None to use system default.\n :returns: path to file written\n\n '
if d:
file_utils.safe_create_dir(d)
ext = MI... | Actually write our bytes to a new temp file
Always creates new file.
:param d: directory to write temp file in or None to use system default.
:returns: path to file written | python/smqtk/representation/data_element/__init__.py | _write_new_temp | jbeezley/SMQTK | 1 | python | def _write_new_temp(self, d):
'\n Actually write our bytes to a new temp file\n Always creates new file.\n\n :param d: directory to write temp file in or None to use system default.\n :returns: path to file written\n\n '
if d:
file_utils.safe_create_dir(d)
ext = MI... | def _write_new_temp(self, d):
'\n Actually write our bytes to a new temp file\n Always creates new file.\n\n :param d: directory to write temp file in or None to use system default.\n :returns: path to file written\n\n '
if d:
file_utils.safe_create_dir(d)
ext = MI... |
38a030a70d121d5d146838d673b636f5996d914fb49227b047f8b49fe2043127 | def _clear_no_exist(self):
"\n Clear paths in temp stack that don't exist on the system.\n "
no_exist_paths = deque()
for fp in self._temp_filepath_stack:
if (not osp.isfile(fp)):
no_exist_paths.append(fp)
for fp in no_exist_paths:
self._temp_filepath_stack.remo... | Clear paths in temp stack that don't exist on the system. | python/smqtk/representation/data_element/__init__.py | _clear_no_exist | jbeezley/SMQTK | 1 | python | def _clear_no_exist(self):
"\n \n "
no_exist_paths = deque()
for fp in self._temp_filepath_stack:
if (not osp.isfile(fp)):
no_exist_paths.append(fp)
for fp in no_exist_paths:
self._temp_filepath_stack.remove(fp) | def _clear_no_exist(self):
"\n \n "
no_exist_paths = deque()
for fp in self._temp_filepath_stack:
if (not osp.isfile(fp)):
no_exist_paths.append(fp)
for fp in no_exist_paths:
self._temp_filepath_stack.remove(fp)<|docstring|>Clear paths in temp stack that don't e... |
7aa6aefa0f2e0074287f0823e9d78631427d587db56440517a936a3a0b2c73ed | def md5(self):
"\n Get the MD5 checksum of this element's binary content.\n\n :return: MD5 hex checksum of the data content.\n :rtype: str\n "
return hashlib.md5(self.get_bytes()).hexdigest() | Get the MD5 checksum of this element's binary content.
:return: MD5 hex checksum of the data content.
:rtype: str | python/smqtk/representation/data_element/__init__.py | md5 | jbeezley/SMQTK | 1 | python | def md5(self):
"\n Get the MD5 checksum of this element's binary content.\n\n :return: MD5 hex checksum of the data content.\n :rtype: str\n "
return hashlib.md5(self.get_bytes()).hexdigest() | def md5(self):
"\n Get the MD5 checksum of this element's binary content.\n\n :return: MD5 hex checksum of the data content.\n :rtype: str\n "
return hashlib.md5(self.get_bytes()).hexdigest()<|docstring|>Get the MD5 checksum of this element's binary content.
:return: MD5 hex checksu... |
2d6aeafeb571856eb701e73bac665227c86f6d48cdc89c2a98eced9307d073de | def sha1(self):
"\n Get the SHA1 checksum of this element's binary content.\n\n :return: SHA1 hex checksum of the data content.\n :rtype: str\n "
return hashlib.sha1(self.get_bytes()).hexdigest() | Get the SHA1 checksum of this element's binary content.
:return: SHA1 hex checksum of the data content.
:rtype: str | python/smqtk/representation/data_element/__init__.py | sha1 | jbeezley/SMQTK | 1 | python | def sha1(self):
"\n Get the SHA1 checksum of this element's binary content.\n\n :return: SHA1 hex checksum of the data content.\n :rtype: str\n "
return hashlib.sha1(self.get_bytes()).hexdigest() | def sha1(self):
"\n Get the SHA1 checksum of this element's binary content.\n\n :return: SHA1 hex checksum of the data content.\n :rtype: str\n "
return hashlib.sha1(self.get_bytes()).hexdigest()<|docstring|>Get the SHA1 checksum of this element's binary content.
:return: SHA1 hex c... |
c134778b9a3c42b1a3327a346d04545fc6f5ff257a47cfe58ebbb2fd4502b416 | def sha512(self):
"\n Get the SHA512 checksum of this element's binary content.\n\n :return: SHA512 hex checksum of the data content.\n :rtype: str\n "
return hashlib.sha512(self.get_bytes()).hexdigest() | Get the SHA512 checksum of this element's binary content.
:return: SHA512 hex checksum of the data content.
:rtype: str | python/smqtk/representation/data_element/__init__.py | sha512 | jbeezley/SMQTK | 1 | python | def sha512(self):
"\n Get the SHA512 checksum of this element's binary content.\n\n :return: SHA512 hex checksum of the data content.\n :rtype: str\n "
return hashlib.sha512(self.get_bytes()).hexdigest() | def sha512(self):
"\n Get the SHA512 checksum of this element's binary content.\n\n :return: SHA512 hex checksum of the data content.\n :rtype: str\n "
return hashlib.sha512(self.get_bytes()).hexdigest()<|docstring|>Get the SHA512 checksum of this element's binary content.
:return: ... |
79a9c3acd440794cdff6c01da2c858ee71cb0645f4a5719b0a1a7da792054710 | def write_temp(self, temp_dir=None):
"\n Write this data's bytes to a temporary file on disk, returning the path\n to the written file, whose extension is guessed based on this data's\n content type.\n\n It is not guaranteed that the returned file path does not point to the\n orig... | Write this data's bytes to a temporary file on disk, returning the path
to the written file, whose extension is guessed based on this data's
content type.
It is not guaranteed that the returned file path does not point to the
original data, i.e. writing to the returned filepath may modify the
original data.
NOTE:
... | python/smqtk/representation/data_element/__init__.py | write_temp | jbeezley/SMQTK | 1 | python | def write_temp(self, temp_dir=None):
"\n Write this data's bytes to a temporary file on disk, returning the path\n to the written file, whose extension is guessed based on this data's\n content type.\n\n It is not guaranteed that the returned file path does not point to the\n orig... | def write_temp(self, temp_dir=None):
"\n Write this data's bytes to a temporary file on disk, returning the path\n to the written file, whose extension is guessed based on this data's\n content type.\n\n It is not guaranteed that the returned file path does not point to the\n orig... |
190e0efc39fb31660e541b3d388131abb92b6fdc0bb8a96e1b6d8cab414810d8 | def clean_temp(self):
'\n Clean any temporary files created by this element. This does nothing if\n no temporary files have been generated for this element yet.\n '
if len(self._temp_filepath_stack):
for fp in self._temp_filepath_stack:
if os.path.isfile(fp):
... | Clean any temporary files created by this element. This does nothing if
no temporary files have been generated for this element yet. | python/smqtk/representation/data_element/__init__.py | clean_temp | jbeezley/SMQTK | 1 | python | def clean_temp(self):
'\n Clean any temporary files created by this element. This does nothing if\n no temporary files have been generated for this element yet.\n '
if len(self._temp_filepath_stack):
for fp in self._temp_filepath_stack:
if os.path.isfile(fp):
... | def clean_temp(self):
'\n Clean any temporary files created by this element. This does nothing if\n no temporary files have been generated for this element yet.\n '
if len(self._temp_filepath_stack):
for fp in self._temp_filepath_stack:
if os.path.isfile(fp):
... |
aa6d757b53d5b6d530f1ab54052e4d65aacb165ce7b6a7403b6e701444462faa | def uuid(self):
"\n UUID for this data element.\n\n This many take different forms from integers to strings to a uuid.UUID\n instance. This must return a hashable data type.\n\n By default, this ends up being the hex stringification of the SHA1 hash\n of this data's bytes. Specifi... | UUID for this data element.
This many take different forms from integers to strings to a uuid.UUID
instance. This must return a hashable data type.
By default, this ends up being the hex stringification of the SHA1 hash
of this data's bytes. Specific implementations may provide other UUIDs,
however.
:return: UUID va... | python/smqtk/representation/data_element/__init__.py | uuid | jbeezley/SMQTK | 1 | python | def uuid(self):
"\n UUID for this data element.\n\n This many take different forms from integers to strings to a uuid.UUID\n instance. This must return a hashable data type.\n\n By default, this ends up being the hex stringification of the SHA1 hash\n of this data's bytes. Specifi... | def uuid(self):
"\n UUID for this data element.\n\n This many take different forms from integers to strings to a uuid.UUID\n instance. This must return a hashable data type.\n\n By default, this ends up being the hex stringification of the SHA1 hash\n of this data's bytes. Specifi... |
c39f3a54199a58a99258644d47ad1fb12381418e79814aafc6f7273912f93977 | def to_buffered_reader(self):
"\n Wrap this element's bytes in a ``io.BufferedReader`` instance for use as\n file-like object for reading.\n\n As we use the ``get_bytes`` function, this element's bytes must safely\n fit in memory for this method to be usable.\n\n :return: New Buff... | Wrap this element's bytes in a ``io.BufferedReader`` instance for use as
file-like object for reading.
As we use the ``get_bytes`` function, this element's bytes must safely
fit in memory for this method to be usable.
:return: New BufferedReader instance
:rtype: io.BufferedReader | python/smqtk/representation/data_element/__init__.py | to_buffered_reader | jbeezley/SMQTK | 1 | python | def to_buffered_reader(self):
"\n Wrap this element's bytes in a ``io.BufferedReader`` instance for use as\n file-like object for reading.\n\n As we use the ``get_bytes`` function, this element's bytes must safely\n fit in memory for this method to be usable.\n\n :return: New Buff... | def to_buffered_reader(self):
"\n Wrap this element's bytes in a ``io.BufferedReader`` instance for use as\n file-like object for reading.\n\n As we use the ``get_bytes`` function, this element's bytes must safely\n fit in memory for this method to be usable.\n\n :return: New Buff... |
92df7dce4909d01fd1a7b5f34359d34f82115992ea9be0719290f77ec043f360 | def is_read_only(self):
'\n :return: If this element can only be read from.\n :rtype: bool\n '
return (not self.writable()) | :return: If this element can only be read from.
:rtype: bool | python/smqtk/representation/data_element/__init__.py | is_read_only | jbeezley/SMQTK | 1 | python | def is_read_only(self):
'\n :return: If this element can only be read from.\n :rtype: bool\n '
return (not self.writable()) | def is_read_only(self):
'\n :return: If this element can only be read from.\n :rtype: bool\n '
return (not self.writable())<|docstring|>:return: If this element can only be read from.
:rtype: bool<|endoftext|> |
29eff2eb1db49def565062c584d5d9f7012df757f65b685546dbecbbd43fd69a | @abc.abstractmethod
def content_type(self):
'\n :return: Standard type/subtype string for this data element, or None if\n the content type is unknown.\n :rtype: str or None\n ' | :return: Standard type/subtype string for this data element, or None if
the content type is unknown.
:rtype: str or None | python/smqtk/representation/data_element/__init__.py | content_type | jbeezley/SMQTK | 1 | python | @abc.abstractmethod
def content_type(self):
'\n :return: Standard type/subtype string for this data element, or None if\n the content type is unknown.\n :rtype: str or None\n ' | @abc.abstractmethod
def content_type(self):
'\n :return: Standard type/subtype string for this data element, or None if\n the content type is unknown.\n :rtype: str or None\n '<|docstring|>:return: Standard type/subtype string for this data element, or None if
the content type is... |
4e5e51cf90d71c8e9d5b6b7a3d7c5bc75ec25547a7faf8c5f5d9049cab8ae76e | @abc.abstractmethod
def is_empty(self):
'\n Check if this element contains no bytes.\n\n The intend of this method is to quickly check if there is any data\n behind this element, ideally without having to read all/any of the\n underlying data.\n\n :return: If this element contains... | Check if this element contains no bytes.
The intend of this method is to quickly check if there is any data
behind this element, ideally without having to read all/any of the
underlying data.
:return: If this element contains 0 bytes.
:rtype: bool | python/smqtk/representation/data_element/__init__.py | is_empty | jbeezley/SMQTK | 1 | python | @abc.abstractmethod
def is_empty(self):
'\n Check if this element contains no bytes.\n\n The intend of this method is to quickly check if there is any data\n behind this element, ideally without having to read all/any of the\n underlying data.\n\n :return: If this element contains... | @abc.abstractmethod
def is_empty(self):
'\n Check if this element contains no bytes.\n\n The intend of this method is to quickly check if there is any data\n behind this element, ideally without having to read all/any of the\n underlying data.\n\n :return: If this element contains... |
1ef59d911695f76ec92d9cffdf152b5e20d604dc7063f42e5d6051ede22189fa | @abc.abstractmethod
def get_bytes(self):
'\n :return: Get the bytes for this data element.\n :rtype: bytes\n ' | :return: Get the bytes for this data element.
:rtype: bytes | python/smqtk/representation/data_element/__init__.py | get_bytes | jbeezley/SMQTK | 1 | python | @abc.abstractmethod
def get_bytes(self):
'\n :return: Get the bytes for this data element.\n :rtype: bytes\n ' | @abc.abstractmethod
def get_bytes(self):
'\n :return: Get the bytes for this data element.\n :rtype: bytes\n '<|docstring|>:return: Get the bytes for this data element.
:rtype: bytes<|endoftext|> |
aa89b96096f48199bb07298eaf33ad177a03b3d41debb62ccbe264fb7b66887e | @abc.abstractmethod
def writable(self):
'\n :return: if this instance supports setting bytes.\n :rtype: bool\n ' | :return: if this instance supports setting bytes.
:rtype: bool | python/smqtk/representation/data_element/__init__.py | writable | jbeezley/SMQTK | 1 | python | @abc.abstractmethod
def writable(self):
'\n :return: if this instance supports setting bytes.\n :rtype: bool\n ' | @abc.abstractmethod
def writable(self):
'\n :return: if this instance supports setting bytes.\n :rtype: bool\n '<|docstring|>:return: if this instance supports setting bytes.
:rtype: bool<|endoftext|> |
467ff0f77f61707f26a31aa124b9b84fb5a915a9e4a14c75f1f09fdd13f130fe | @abc.abstractmethod
def set_bytes(self, b):
'\n Set bytes to this data element.\n\n Not all implementations may support setting bytes (check ``writable``\n method return).\n\n This base abstract method should be called by sub-class implementations\n first. We check for mutability ... | Set bytes to this data element.
Not all implementations may support setting bytes (check ``writable``
method return).
This base abstract method should be called by sub-class implementations
first. We check for mutability based on ``writable()`` method return and
invalidate checksum caches.
:param b: bytes to set.
:t... | python/smqtk/representation/data_element/__init__.py | set_bytes | jbeezley/SMQTK | 1 | python | @abc.abstractmethod
def set_bytes(self, b):
'\n Set bytes to this data element.\n\n Not all implementations may support setting bytes (check ``writable``\n method return).\n\n This base abstract method should be called by sub-class implementations\n first. We check for mutability ... | @abc.abstractmethod
def set_bytes(self, b):
'\n Set bytes to this data element.\n\n Not all implementations may support setting bytes (check ``writable``\n method return).\n\n This base abstract method should be called by sub-class implementations\n first. We check for mutability ... |
64344056a62ba9f59ace1d50b83e6b20c11ee44689ddbfa3874284b7274eb18c | def DB_loss_function(estimator, X, y_true=None):
'\n Computes Davis-Bolding Index for a fitted KMeans\n\n args:\n model: Fitted KMeans object\n x: input data for evaluation \n '
preds = estimator.predict(X)
n_clusters = (int(np.max(preds)) + 1)
db_values = []
for i in range(n_... | Computes Davis-Bolding Index for a fitted KMeans
args:
model: Fitted KMeans object
x: input data for evaluation | HW02/HW02.py | DB_loss_function | iust-projects/Data-Mining-IUST | 0 | python | def DB_loss_function(estimator, X, y_true=None):
'\n Computes Davis-Bolding Index for a fitted KMeans\n\n args:\n model: Fitted KMeans object\n x: input data for evaluation \n '
preds = estimator.predict(X)
n_clusters = (int(np.max(preds)) + 1)
db_values = []
for i in range(n_... | def DB_loss_function(estimator, X, y_true=None):
'\n Computes Davis-Bolding Index for a fitted KMeans\n\n args:\n model: Fitted KMeans object\n x: input data for evaluation \n '
preds = estimator.predict(X)
n_clusters = (int(np.max(preds)) + 1)
db_values = []
for i in range(n_... |
a5e1a3c2192782c301313653808ede9732dec11e9f0737d07a9648ad7a1dca3e | def __init__(self, min_samples, eps):
'\n Constructs DBSCAN given parameters of neighborhood\n\n :param min_samples: Minimum samples within eps radius to be consider as a core point\n :param eps: Radius of core point\n '
self.min_samples = min_samples
self.eps = eps
self.labe... | Constructs DBSCAN given parameters of neighborhood
:param min_samples: Minimum samples within eps radius to be consider as a core point
:param eps: Radius of core point | HW02/HW02.py | __init__ | iust-projects/Data-Mining-IUST | 0 | python | def __init__(self, min_samples, eps):
'\n Constructs DBSCAN given parameters of neighborhood\n\n :param min_samples: Minimum samples within eps radius to be consider as a core point\n :param eps: Radius of core point\n '
self.min_samples = min_samples
self.eps = eps
self.labe... | def __init__(self, min_samples, eps):
'\n Constructs DBSCAN given parameters of neighborhood\n\n :param min_samples: Minimum samples within eps radius to be consider as a core point\n :param eps: Radius of core point\n '
self.min_samples = min_samples
self.eps = eps
self.labe... |
d5888a2012962e1bb80605ec07bf96a4e049987931e3a65f4251848ab50d5969 | def fit_predict(self, x, *args, **kwargs):
'\n Fits the data using DBSCAN and returns labels and core points\n Order of data matter!\n\n Algorithm:\n 1. Consider a list of points that have not been seen yet\n 2. Read an arbitrary point until there is no unseen point left\n... | Fits the data using DBSCAN and returns labels and core points
Order of data matter!
Algorithm:
1. Consider a list of points that have not been seen yet
2. Read an arbitrary point until there is no unseen point left
3. If there are at least ``min_samples`` points within a radius of ``eps``
then all ... | HW02/HW02.py | fit_predict | iust-projects/Data-Mining-IUST | 0 | python | def fit_predict(self, x, *args, **kwargs):
'\n Fits the data using DBSCAN and returns labels and core points\n Order of data matter!\n\n Algorithm:\n 1. Consider a list of points that have not been seen yet\n 2. Read an arbitrary point until there is no unseen point left\n... | def fit_predict(self, x, *args, **kwargs):
'\n Fits the data using DBSCAN and returns labels and core points\n Order of data matter!\n\n Algorithm:\n 1. Consider a list of points that have not been seen yet\n 2. Read an arbitrary point until there is no unseen point left\n... |
d1d1570ca0ae2de329fa09d4df4a21773bfc9a31f9c7383481bf17fcac9b3bf2 | def __nearest_neighbors(self, data, point):
'\n Finds points near to the point ``point`` within the range of ``eps``\n\n :param point: A point\n :param: All points\n\n :return: Indices of nearest neighbor points\n '
distances = euclidean_distances(data, point.reshape(1, (- 1))... | Finds points near to the point ``point`` within the range of ``eps``
:param point: A point
:param: All points
:return: Indices of nearest neighbor points | HW02/HW02.py | __nearest_neighbors | iust-projects/Data-Mining-IUST | 0 | python | def __nearest_neighbors(self, data, point):
'\n Finds points near to the point ``point`` within the range of ``eps``\n\n :param point: A point\n :param: All points\n\n :return: Indices of nearest neighbor points\n '
distances = euclidean_distances(data, point.reshape(1, (- 1))... | def __nearest_neighbors(self, data, point):
'\n Finds points near to the point ``point`` within the range of ``eps``\n\n :param point: A point\n :param: All points\n\n :return: Indices of nearest neighbor points\n '
distances = euclidean_distances(data, point.reshape(1, (- 1))... |
b4b4a98dbab9b3e16c156528af444146dd24a096548fd1c95d70a2bbabb663ec | def __expand(self, data, point_idx, current_cluster):
'\n Expands ``current_cluster`` using given point w.r.t. ``eps`` and ``min_samples``\n Algorithm:\n 1. Get a point as the start point for ``current_cluster``\n 2. Get its neighbors and go through them one by one using queue lo... | Expands ``current_cluster`` using given point w.r.t. ``eps`` and ``min_samples``
Algorithm:
1. Get a point as the start point for ``current_cluster``
2. Get its neighbors and go through them one by one using queue logic
3. If the neighbor is noise, then add it to the current cluster, if it is unseen, get al... | HW02/HW02.py | __expand | iust-projects/Data-Mining-IUST | 0 | python | def __expand(self, data, point_idx, current_cluster):
'\n Expands ``current_cluster`` using given point w.r.t. ``eps`` and ``min_samples``\n Algorithm:\n 1. Get a point as the start point for ``current_cluster``\n 2. Get its neighbors and go through them one by one using queue lo... | def __expand(self, data, point_idx, current_cluster):
'\n Expands ``current_cluster`` using given point w.r.t. ``eps`` and ``min_samples``\n Algorithm:\n 1. Get a point as the start point for ``current_cluster``\n 2. Get its neighbors and go through them one by one using queue lo... |
068d6fd4d4c026d8c6f0544da21de53bcdfe2441989db66cb370ad87e34e63f1 | def __init__(self, amqp_client, zookeeper_client, db_conn, args, dm_logger):
'Initialize ZooKeeper, RabbitMQ, Sandesh, DB conn etc.'
DeviceJobManager._instance = self
self._amqp_client = amqp_client
self._zookeeper_client = zookeeper_client
self._db_conn = db_conn
self._args = args
self._job... | Initialize ZooKeeper, RabbitMQ, Sandesh, DB conn etc. | src/config/device-manager/device_manager/device_job_manager.py | __init__ | pltf/contrail-controller | 0 | python | def __init__(self, amqp_client, zookeeper_client, db_conn, args, dm_logger):
DeviceJobManager._instance = self
self._amqp_client = amqp_client
self._zookeeper_client = zookeeper_client
self._db_conn = db_conn
self._args = args
self._job_mgr_statistics = {'max_job_count': self._args.max_job_... | def __init__(self, amqp_client, zookeeper_client, db_conn, args, dm_logger):
DeviceJobManager._instance = self
self._amqp_client = amqp_client
self._zookeeper_client = zookeeper_client
self._db_conn = db_conn
self._args = args
self._job_mgr_statistics = {'max_job_count': self._args.max_job_... |
d2b1a97b65f14baa4ea5c2d168fe8f94d5d74fef8b81e18004cd705bdc7dca76 | def setup(bot: Bot) -> None:
'Load the Information cog.'
bot.add_cog(Information(bot)) | Load the Information cog. | bot/exts/info/information.py | setup | Zedeldi/bot | 2 | python | def setup(bot: Bot) -> None:
bot.add_cog(Information(bot)) | def setup(bot: Bot) -> None:
bot.add_cog(Information(bot))<|docstring|>Load the Information cog.<|endoftext|> |
87241dad735b33a2ded0a005fb359d96a32c7622b30b5ba3cc00dfa20603a92f | @staticmethod
def get_channel_type_counts(guild: Guild) -> DefaultDict[(str, int)]:
'Return the total amounts of the various types of channels in `guild`.'
channel_counter = defaultdict(int)
for channel in guild.channels:
if is_staff_channel(channel):
channel_counter['staff'] += 1
... | Return the total amounts of the various types of channels in `guild`. | bot/exts/info/information.py | get_channel_type_counts | Zedeldi/bot | 2 | python | @staticmethod
def get_channel_type_counts(guild: Guild) -> DefaultDict[(str, int)]:
channel_counter = defaultdict(int)
for channel in guild.channels:
if is_staff_channel(channel):
channel_counter['staff'] += 1
else:
channel_counter[str(channel.type)] += 1
return ... | @staticmethod
def get_channel_type_counts(guild: Guild) -> DefaultDict[(str, int)]:
channel_counter = defaultdict(int)
for channel in guild.channels:
if is_staff_channel(channel):
channel_counter['staff'] += 1
else:
channel_counter[str(channel.type)] += 1
return ... |
981445dddccced083b4dca643d52a467eb71eac3ee2379571f9fe09e62279b31 | @staticmethod
def get_member_counts(guild: Guild) -> Dict[(str, int)]:
'Return the total number of members for certain roles in `guild`.'
roles = (guild.get_role(role_id) for role_id in (constants.Roles.helpers, constants.Roles.mod_team, constants.Roles.admins, constants.Roles.owners, constants.Roles.contributo... | Return the total number of members for certain roles in `guild`. | bot/exts/info/information.py | get_member_counts | Zedeldi/bot | 2 | python | @staticmethod
def get_member_counts(guild: Guild) -> Dict[(str, int)]:
roles = (guild.get_role(role_id) for role_id in (constants.Roles.helpers, constants.Roles.mod_team, constants.Roles.admins, constants.Roles.owners, constants.Roles.contributors))
return {role.name.title(): len(role.members) for role in ... | @staticmethod
def get_member_counts(guild: Guild) -> Dict[(str, int)]:
roles = (guild.get_role(role_id) for role_id in (constants.Roles.helpers, constants.Roles.mod_team, constants.Roles.admins, constants.Roles.owners, constants.Roles.contributors))
return {role.name.title(): len(role.members) for role in ... |
5dd6300e1f201a410162c2128d9568d1f1adef767467b5af2db4b4a561819ae3 | def get_extended_server_info(self, ctx: Context) -> str:
'Return additional server info only visible in moderation channels.'
talentpool_info = ''
if (cog := self.bot.get_cog('Talentpool')):
talentpool_info = f'''Nominated: {len(cog.watched_users)}
'''
bb_info = ''
if (cog := self.bot.get_co... | Return additional server info only visible in moderation channels. | bot/exts/info/information.py | get_extended_server_info | Zedeldi/bot | 2 | python | def get_extended_server_info(self, ctx: Context) -> str:
talentpool_info =
if (cog := self.bot.get_cog('Talentpool')):
talentpool_info = f'Nominated: {len(cog.watched_users)}
'
bb_info =
if (cog := self.bot.get_cog('Big Brother')):
bb_info = f'BB-watched: {len(cog.watched_users)}
... | def get_extended_server_info(self, ctx: Context) -> str:
talentpool_info =
if (cog := self.bot.get_cog('Talentpool')):
talentpool_info = f'Nominated: {len(cog.watched_users)}
'
bb_info =
if (cog := self.bot.get_cog('Big Brother')):
bb_info = f'BB-watched: {len(cog.watched_users)}
... |
a7944e546f7c38afdc994c95a590e34aea3fdaccf0fc6f17bf6a8a3a88729eaa | @has_any_role(*constants.STAFF_ROLES)
@command(name='roles')
async def roles_info(self, ctx: Context) -> None:
'Returns a list of all roles and their corresponding IDs.'
roles = sorted(ctx.guild.roles[1:], key=(lambda role: role.name))
role_list = []
for role in roles:
role_list.append(f'`{role.... | Returns a list of all roles and their corresponding IDs. | bot/exts/info/information.py | roles_info | Zedeldi/bot | 2 | python | @has_any_role(*constants.STAFF_ROLES)
@command(name='roles')
async def roles_info(self, ctx: Context) -> None:
roles = sorted(ctx.guild.roles[1:], key=(lambda role: role.name))
role_list = []
for role in roles:
role_list.append(f'`{role.id}` - {role.mention}')
embed = Embed(title=f"Role inf... | @has_any_role(*constants.STAFF_ROLES)
@command(name='roles')
async def roles_info(self, ctx: Context) -> None:
roles = sorted(ctx.guild.roles[1:], key=(lambda role: role.name))
role_list = []
for role in roles:
role_list.append(f'`{role.id}` - {role.mention}')
embed = Embed(title=f"Role inf... |
dd85bf178c6fa127ecf91f3c52845bb5fe47b9d9a50dd1662d6ea9706fde4324 | @has_any_role(*constants.STAFF_ROLES)
@command(name='role')
async def role_info(self, ctx: Context, *roles: Union[(Role, str)]) -> None:
'\n Return information on a role or list of roles.\n\n To specify multiple roles just add to the arguments, delimit roles with spaces in them using quotation marks.\... | Return information on a role or list of roles.
To specify multiple roles just add to the arguments, delimit roles with spaces in them using quotation marks. | bot/exts/info/information.py | role_info | Zedeldi/bot | 2 | python | @has_any_role(*constants.STAFF_ROLES)
@command(name='role')
async def role_info(self, ctx: Context, *roles: Union[(Role, str)]) -> None:
'\n Return information on a role or list of roles.\n\n To specify multiple roles just add to the arguments, delimit roles with spaces in them using quotation marks.\... | @has_any_role(*constants.STAFF_ROLES)
@command(name='role')
async def role_info(self, ctx: Context, *roles: Union[(Role, str)]) -> None:
'\n Return information on a role or list of roles.\n\n To specify multiple roles just add to the arguments, delimit roles with spaces in them using quotation marks.\... |
a64bec3ba6c3e30bbaec06b5573408e0c2453acf47d1dae3201ea6b144c63ebb | @command(name='server', aliases=['server_info', 'guild', 'guild_info'])
async def server_info(self, ctx: Context) -> None:
'Returns an embed full of server information.'
embed = Embed(colour=Colour.blurple(), title='Server Information')
created = discord_timestamp(ctx.guild.created_at, TimestampFormats.RELA... | Returns an embed full of server information. | bot/exts/info/information.py | server_info | Zedeldi/bot | 2 | python | @command(name='server', aliases=['server_info', 'guild', 'guild_info'])
async def server_info(self, ctx: Context) -> None:
embed = Embed(colour=Colour.blurple(), title='Server Information')
created = discord_timestamp(ctx.guild.created_at, TimestampFormats.RELATIVE)
region = ctx.guild.region
num_ro... | @command(name='server', aliases=['server_info', 'guild', 'guild_info'])
async def server_info(self, ctx: Context) -> None:
embed = Embed(colour=Colour.blurple(), title='Server Information')
created = discord_timestamp(ctx.guild.created_at, TimestampFormats.RELATIVE)
region = ctx.guild.region
num_ro... |
ede5ddca53d4b7fcba91db9ce73ee8b3f18ca67c47b500fd384393b1c780cc44 | @command(name='user', aliases=['user_info', 'member', 'member_info', 'u'])
async def user_info(self, ctx: Context, user: FetchedMember=None) -> None:
'Returns info about a user.'
if (user is None):
user = ctx.author
elif ((user != ctx.author) and (await has_no_roles_check(ctx, *constants.MODERATION_... | Returns info about a user. | bot/exts/info/information.py | user_info | Zedeldi/bot | 2 | python | @command(name='user', aliases=['user_info', 'member', 'member_info', 'u'])
async def user_info(self, ctx: Context, user: FetchedMember=None) -> None:
if (user is None):
user = ctx.author
elif ((user != ctx.author) and (await has_no_roles_check(ctx, *constants.MODERATION_ROLES))):
(await ctx... | @command(name='user', aliases=['user_info', 'member', 'member_info', 'u'])
async def user_info(self, ctx: Context, user: FetchedMember=None) -> None:
if (user is None):
user = ctx.author
elif ((user != ctx.author) and (await has_no_roles_check(ctx, *constants.MODERATION_ROLES))):
(await ctx... |
2e9bf0c12f6a911be3a80701b87f7bf03e17d7e488406b632900a66b0d5f557c | async def create_user_embed(self, ctx: Context, user: FetchedMember) -> Embed:
'Creates an embed containing information on the `user`.'
on_server = bool(ctx.guild.get_member(user.id))
created = discord_timestamp(user.created_at, TimestampFormats.RELATIVE)
name = str(user)
if (on_server and user.nick... | Creates an embed containing information on the `user`. | bot/exts/info/information.py | create_user_embed | Zedeldi/bot | 2 | python | async def create_user_embed(self, ctx: Context, user: FetchedMember) -> Embed:
on_server = bool(ctx.guild.get_member(user.id))
created = discord_timestamp(user.created_at, TimestampFormats.RELATIVE)
name = str(user)
if (on_server and user.nick):
name = f'{user.nick} ({name})'
if user.pu... | async def create_user_embed(self, ctx: Context, user: FetchedMember) -> Embed:
on_server = bool(ctx.guild.get_member(user.id))
created = discord_timestamp(user.created_at, TimestampFormats.RELATIVE)
name = str(user)
if (on_server and user.nick):
name = f'{user.nick} ({name})'
if user.pu... |
f366387ac891cad88180e9ad0fd2f50f54c6e80366d03436c02c0003b2f68c5b | async def basic_user_infraction_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
'Gets the total and active infraction counts for the given `member`.'
infractions = (await self.bot.api_client.get('bot/infractions', params={'hidden': 'False', 'user__id': str(user.id)}))
total_infractions = len(infract... | Gets the total and active infraction counts for the given `member`. | bot/exts/info/information.py | basic_user_infraction_counts | Zedeldi/bot | 2 | python | async def basic_user_infraction_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
infractions = (await self.bot.api_client.get('bot/infractions', params={'hidden': 'False', 'user__id': str(user.id)}))
total_infractions = len(infractions)
active_infractions = sum((infraction['active'] for infracti... | async def basic_user_infraction_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
infractions = (await self.bot.api_client.get('bot/infractions', params={'hidden': 'False', 'user__id': str(user.id)}))
total_infractions = len(infractions)
active_infractions = sum((infraction['active'] for infracti... |
9411489fe773250c5e72b62b48e62402bb99db363f4a64b791c05fe28862ff79 | async def expanded_user_infraction_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
'\n Gets expanded infraction counts for the given `member`.\n\n The counts will be split by infraction type and the number of active infractions for each type will indicated\n in the output as well.\n ... | Gets expanded infraction counts for the given `member`.
The counts will be split by infraction type and the number of active infractions for each type will indicated
in the output as well. | bot/exts/info/information.py | expanded_user_infraction_counts | Zedeldi/bot | 2 | python | async def expanded_user_infraction_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
'\n Gets expanded infraction counts for the given `member`.\n\n The counts will be split by infraction type and the number of active infractions for each type will indicated\n in the output as well.\n ... | async def expanded_user_infraction_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
'\n Gets expanded infraction counts for the given `member`.\n\n The counts will be split by infraction type and the number of active infractions for each type will indicated\n in the output as well.\n ... |
392e7645a90bb782f57eaaee71e6c121b14adbc15d881672fb2915f6ca5ffe32 | async def user_nomination_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
'Gets the active and historical nomination counts for the given `member`.'
nominations = (await self.bot.api_client.get('bot/nominations', params={'user__id': str(user.id)}))
output = []
if (not nominations):
outpu... | Gets the active and historical nomination counts for the given `member`. | bot/exts/info/information.py | user_nomination_counts | Zedeldi/bot | 2 | python | async def user_nomination_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
nominations = (await self.bot.api_client.get('bot/nominations', params={'user__id': str(user.id)}))
output = []
if (not nominations):
output.append('No nominations')
else:
count = len(nominations)
... | async def user_nomination_counts(self, user: FetchedMember) -> Tuple[(str, str)]:
nominations = (await self.bot.api_client.get('bot/nominations', params={'user__id': str(user.id)}))
output = []
if (not nominations):
output.append('No nominations')
else:
count = len(nominations)
... |
f8720bc1c0a2a4a3c26659cc1b72c17a7a07998416ad41916c8cb8072b32a7b8 | async def user_messages(self, user: FetchedMember) -> Tuple[(Union[(bool, str)], Tuple[(str, str)])]:
"\n Gets the amount of messages for `member`.\n\n Fetches information from the metricity database that's hosted by the site.\n If the database returns a code besides a 404, then many parts of t... | Gets the amount of messages for `member`.
Fetches information from the metricity database that's hosted by the site.
If the database returns a code besides a 404, then many parts of the bot are broken including this one. | bot/exts/info/information.py | user_messages | Zedeldi/bot | 2 | python | async def user_messages(self, user: FetchedMember) -> Tuple[(Union[(bool, str)], Tuple[(str, str)])]:
"\n Gets the amount of messages for `member`.\n\n Fetches information from the metricity database that's hosted by the site.\n If the database returns a code besides a 404, then many parts of t... | async def user_messages(self, user: FetchedMember) -> Tuple[(Union[(bool, str)], Tuple[(str, str)])]:
"\n Gets the amount of messages for `member`.\n\n Fetches information from the metricity database that's hosted by the site.\n If the database returns a code besides a 404, then many parts of t... |
b44d9e5d2dcbd7e742bcc759c71454fc3c91e72b960c835de846998d1d8c22f7 | def format_fields(self, mapping: Mapping[(str, Any)], field_width: Optional[int]=None) -> str:
'Format a mapping to be readable to a human.'
fields = sorted(mapping.items(), key=(lambda item: item[0]))
if (field_width is None):
field_width = len(max(mapping.keys(), key=len))
out = ''
for (ke... | Format a mapping to be readable to a human. | bot/exts/info/information.py | format_fields | Zedeldi/bot | 2 | python | def format_fields(self, mapping: Mapping[(str, Any)], field_width: Optional[int]=None) -> str:
fields = sorted(mapping.items(), key=(lambda item: item[0]))
if (field_width is None):
field_width = len(max(mapping.keys(), key=len))
out =
for (key, val) in fields:
if isinstance(val, d... | def format_fields(self, mapping: Mapping[(str, Any)], field_width: Optional[int]=None) -> str:
fields = sorted(mapping.items(), key=(lambda item: item[0]))
if (field_width is None):
field_width = len(max(mapping.keys(), key=len))
out =
for (key, val) in fields:
if isinstance(val, d... |
a28f585d1f6e82e45c35aaa7f32689f08700ed6b3022077a0f129f4eb798e5aa | @cooldown_with_role_bypass(2, (60 * 3), BucketType.member, bypass_roles=constants.STAFF_ROLES)
@group(invoke_without_command=True)
@in_whitelist(channels=(constants.Channels.bot_commands,), roles=constants.STAFF_ROLES)
async def raw(self, ctx: Context, *, message: Message, json: bool=False) -> None:
'Shows informat... | Shows information about the raw API response. | bot/exts/info/information.py | raw | Zedeldi/bot | 2 | python | @cooldown_with_role_bypass(2, (60 * 3), BucketType.member, bypass_roles=constants.STAFF_ROLES)
@group(invoke_without_command=True)
@in_whitelist(channels=(constants.Channels.bot_commands,), roles=constants.STAFF_ROLES)
async def raw(self, ctx: Context, *, message: Message, json: bool=False) -> None:
if (ctx.au... | @cooldown_with_role_bypass(2, (60 * 3), BucketType.member, bypass_roles=constants.STAFF_ROLES)
@group(invoke_without_command=True)
@in_whitelist(channels=(constants.Channels.bot_commands,), roles=constants.STAFF_ROLES)
async def raw(self, ctx: Context, *, message: Message, json: bool=False) -> None:
if (ctx.au... |
e26eee32d4733b5c94a2b089e982789205674a6fadb5975b4326f6b2a299f99e | @raw.command()
async def json(self, ctx: Context, message: Message) -> None:
'Shows information about the raw API response in a copy-pasteable Python format.'
(await ctx.invoke(self.raw, message=message, json=True)) | Shows information about the raw API response in a copy-pasteable Python format. | bot/exts/info/information.py | json | Zedeldi/bot | 2 | python | @raw.command()
async def json(self, ctx: Context, message: Message) -> None:
(await ctx.invoke(self.raw, message=message, json=True)) | @raw.command()
async def json(self, ctx: Context, message: Message) -> None:
(await ctx.invoke(self.raw, message=message, json=True))<|docstring|>Shows information about the raw API response in a copy-pasteable Python format.<|endoftext|> |
d413feb2da389047bc286243bf152b0e79ffcdc6d61ca450c1668f58e0c91350 | def setUp(self):
'Initialize test values.'
self.type = 'user'
self.name = 'test'
self.principal = 'user:test'
self.repr_type = "<Principal(type='user')>"
self.repr_name = "<Principal(name='test')>"
self.repr_all = "<Principal(type='user', name='test')>" | Initialize test values. | tests/test_principal.py | setUp | BlueDragonX/pyramid_couchauth | 1 | python | def setUp(self):
self.type = 'user'
self.name = 'test'
self.principal = 'user:test'
self.repr_type = "<Principal(type='user')>"
self.repr_name = "<Principal(name='test')>"
self.repr_all = "<Principal(type='user', name='test')>" | def setUp(self):
self.type = 'user'
self.name = 'test'
self.principal = 'user:test'
self.repr_type = "<Principal(type='user')>"
self.repr_name = "<Principal(name='test')>"
self.repr_all = "<Principal(type='user', name='test')>"<|docstring|>Initialize test values.<|endoftext|> |
bba8f4111810ea3c86d4902d053d8c1deba4d15fbfdf6c758c88c7e50c325b31 | def test_init_empty(self):
'Test __init__ method with no params.'
pobj = Principal()
self.assertTrue((pobj.type is None))
self.assertTrue((pobj.name is None)) | Test __init__ method with no params. | tests/test_principal.py | test_init_empty | BlueDragonX/pyramid_couchauth | 1 | python | def test_init_empty(self):
pobj = Principal()
self.assertTrue((pobj.type is None))
self.assertTrue((pobj.name is None)) | def test_init_empty(self):
pobj = Principal()
self.assertTrue((pobj.type is None))
self.assertTrue((pobj.name is None))<|docstring|>Test __init__ method with no params.<|endoftext|> |
b6c0b17c735b8f400c05c6178a7c5af9a6462ae8a465017ad6ff5b64a10d1b37 | def test_init_type_name(self):
'Test __init__ method with type and name params.'
pobj = Principal(type=self.type, name=self.name)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | Test __init__ method with type and name params. | tests/test_principal.py | test_init_type_name | BlueDragonX/pyramid_couchauth | 1 | python | def test_init_type_name(self):
pobj = Principal(type=self.type, name=self.name)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | def test_init_type_name(self):
pobj = Principal(type=self.type, name=self.name)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name)<|docstring|>Test __init__ method with type and name params.<|endoftext|> |
5430a4c7b32f48181596cbdac041c48450a8a765642e43c541c18550658f3adc | def test_init_principal(self):
'Test __init__ method with principal param.'
pobj = Principal(self.principal)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | Test __init__ method with principal param. | tests/test_principal.py | test_init_principal | BlueDragonX/pyramid_couchauth | 1 | python | def test_init_principal(self):
pobj = Principal(self.principal)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | def test_init_principal(self):
pobj = Principal(self.principal)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name)<|docstring|>Test __init__ method with principal param.<|endoftext|> |
9b80a3bdb6a9a3ad78f78bfdd7efb52130fa8c84097519a1e1eda612ba685614 | def test_init_type_principal(self):
'Test __init__ method with type and principal params.'
pobj = Principal(self.name, self.type)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | Test __init__ method with type and principal params. | tests/test_principal.py | test_init_type_principal | BlueDragonX/pyramid_couchauth | 1 | python | def test_init_type_principal(self):
pobj = Principal(self.name, self.type)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | def test_init_type_principal(self):
pobj = Principal(self.name, self.type)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name)<|docstring|>Test __init__ method with type and principal params.<|endoftext|> |
d8f7c9cb7b0ec683bd69ae8bdaabc89e651039017d6bcc0321b90e49bd8b44ef | def test_parse(self):
'Test parse method.'
pobj = Principal()
pobj.parse(self.principal)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | Test parse method. | tests/test_principal.py | test_parse | BlueDragonX/pyramid_couchauth | 1 | python | def test_parse(self):
pobj = Principal()
pobj.parse(self.principal)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name) | def test_parse(self):
pobj = Principal()
pobj.parse(self.principal)
self.assertEqual(pobj.type, self.type)
self.assertEqual(pobj.name, self.name)<|docstring|>Test parse method.<|endoftext|> |
1bf7c05cf3c42703b07ba35c17d30f933d213894e035e92683110cecebe61419 | def test_str(self):
'Test __str__ method.'
pobj = Principal(self.principal)
self.assertEqual(pobj.__str__(), self.principal) | Test __str__ method. | tests/test_principal.py | test_str | BlueDragonX/pyramid_couchauth | 1 | python | def test_str(self):
pobj = Principal(self.principal)
self.assertEqual(pobj.__str__(), self.principal) | def test_str(self):
pobj = Principal(self.principal)
self.assertEqual(pobj.__str__(), self.principal)<|docstring|>Test __str__ method.<|endoftext|> |
4b36e27c7cbff4183dc130df57ee1244fb953d49003f64362b49c62dead766ac | def test_repr_type(self):
'Test __repr__ method when type is set.'
pobj = Principal(type=self.type)
self.assertEqual(pobj.__repr__(), self.repr_type) | Test __repr__ method when type is set. | tests/test_principal.py | test_repr_type | BlueDragonX/pyramid_couchauth | 1 | python | def test_repr_type(self):
pobj = Principal(type=self.type)
self.assertEqual(pobj.__repr__(), self.repr_type) | def test_repr_type(self):
pobj = Principal(type=self.type)
self.assertEqual(pobj.__repr__(), self.repr_type)<|docstring|>Test __repr__ method when type is set.<|endoftext|> |
c8d48cd081992a2f877da40ff9fbbe58ccc240009a6f4284aa44ff3d72f2557a | def test_repr_name(self):
'Test __repr__ method when name is set.'
pobj = Principal(name=self.name)
self.assertEqual(pobj.__repr__(), self.repr_name) | Test __repr__ method when name is set. | tests/test_principal.py | test_repr_name | BlueDragonX/pyramid_couchauth | 1 | python | def test_repr_name(self):
pobj = Principal(name=self.name)
self.assertEqual(pobj.__repr__(), self.repr_name) | def test_repr_name(self):
pobj = Principal(name=self.name)
self.assertEqual(pobj.__repr__(), self.repr_name)<|docstring|>Test __repr__ method when name is set.<|endoftext|> |
e16e932f99b1913bd1e06628ad134e370969c73b31b90c50168bd428ba636877 | def test_repr_all(self):
'Test __repr__ method when principal is set.'
pobj = Principal(self.principal)
self.assertEqual(pobj.__repr__(), self.repr_all) | Test __repr__ method when principal is set. | tests/test_principal.py | test_repr_all | BlueDragonX/pyramid_couchauth | 1 | python | def test_repr_all(self):
pobj = Principal(self.principal)
self.assertEqual(pobj.__repr__(), self.repr_all) | def test_repr_all(self):
pobj = Principal(self.principal)
self.assertEqual(pobj.__repr__(), self.repr_all)<|docstring|>Test __repr__ method when principal is set.<|endoftext|> |
dad3516a1fe334dcf3fbd65dd70e97d25d1cd661383dabb03572a9cbbed278a3 | def session_preparation(self):
'Prepare the session after the connection has been established.'
self.ansi_escape_codes = True
self._test_channel_read()
self.set_base_prompt()
self.disable_paging()
time.sleep((0.3 * self.global_delay_factor))
self.clear_buffer() | Prepare the session after the connection has been established. | netmiko/dlink/dlink_ds.py | session_preparation | benmcbenben/netmiko | 2 | python | def session_preparation(self):
self.ansi_escape_codes = True
self._test_channel_read()
self.set_base_prompt()
self.disable_paging()
time.sleep((0.3 * self.global_delay_factor))
self.clear_buffer() | def session_preparation(self):
self.ansi_escape_codes = True
self._test_channel_read()
self.set_base_prompt()
self.disable_paging()
time.sleep((0.3 * self.global_delay_factor))
self.clear_buffer()<|docstring|>Prepare the session after the connection has been established.<|endoftext|> |
603a8de8b6580a89d9a64ca68b5a9744f7b1d37fbaf11bbc1cfa794c364d4a34 | def enable(self, *args, **kwargs):
'No implemented enable mode on D-Link yet'
return '' | No implemented enable mode on D-Link yet | netmiko/dlink/dlink_ds.py | enable | benmcbenben/netmiko | 2 | python | def enable(self, *args, **kwargs):
return | def enable(self, *args, **kwargs):
return <|docstring|>No implemented enable mode on D-Link yet<|endoftext|> |
7189c7ef3a93d99860dff801bec4c986b909839b52fb63c4f9862841de4b5b70 | def check_enable_mode(self, *args, **kwargs):
'No implemented enable mode on D-Link yet'
return True | No implemented enable mode on D-Link yet | netmiko/dlink/dlink_ds.py | check_enable_mode | benmcbenben/netmiko | 2 | python | def check_enable_mode(self, *args, **kwargs):
return True | def check_enable_mode(self, *args, **kwargs):
return True<|docstring|>No implemented enable mode on D-Link yet<|endoftext|> |
e8004935534715e6a928b176ab23254cc92e6f71af0230d1dc93952425023083 | def exit_enable_mode(self, *args, **kwargs):
'No implemented enable mode on D-Link yet'
return '' | No implemented enable mode on D-Link yet | netmiko/dlink/dlink_ds.py | exit_enable_mode | benmcbenben/netmiko | 2 | python | def exit_enable_mode(self, *args, **kwargs):
return | def exit_enable_mode(self, *args, **kwargs):
return <|docstring|>No implemented enable mode on D-Link yet<|endoftext|> |
b6e4cbe928cb0b2834e25a78207a2debbc44f75f893c3cc2b549a7182dbb86cd | def check_config_mode(self, *args, **kwargs):
'No config mode on D-Link'
return False | No config mode on D-Link | netmiko/dlink/dlink_ds.py | check_config_mode | benmcbenben/netmiko | 2 | python | def check_config_mode(self, *args, **kwargs):
return False | def check_config_mode(self, *args, **kwargs):
return False<|docstring|>No config mode on D-Link<|endoftext|> |
77a4597659ca8963d5a4e49d28da3733366a44daf2c045862f79b24701e7b965 | def config_mode(self, *args, **kwargs):
'No config mode on D-Link'
return '' | No config mode on D-Link | netmiko/dlink/dlink_ds.py | config_mode | benmcbenben/netmiko | 2 | python | def config_mode(self, *args, **kwargs):
return | def config_mode(self, *args, **kwargs):
return <|docstring|>No config mode on D-Link<|endoftext|> |
91f871f2c481b51a097e5a26efdb974dba8ffff89d3a78575b3f3b3dde1ce7de | def exit_config_mode(self, *args, **kwargs):
'No config mode on D-Link'
return '' | No config mode on D-Link | netmiko/dlink/dlink_ds.py | exit_config_mode | benmcbenben/netmiko | 2 | python | def exit_config_mode(self, *args, **kwargs):
return | def exit_config_mode(self, *args, **kwargs):
return <|docstring|>No config mode on D-Link<|endoftext|> |
91bebc59c8d889783919998dde4483ef2ede0cf357ef77006d5d73f6b3b948ae | def save_config(self, cmd='save', confirm=False, confirm_response=''):
'Saves configuration.'
return super().save_config(cmd=cmd, confirm=confirm, confirm_response=confirm_response) | Saves configuration. | netmiko/dlink/dlink_ds.py | save_config | benmcbenben/netmiko | 2 | python | def save_config(self, cmd='save', confirm=False, confirm_response=):
return super().save_config(cmd=cmd, confirm=confirm, confirm_response=confirm_response) | def save_config(self, cmd='save', confirm=False, confirm_response=):
return super().save_config(cmd=cmd, confirm=confirm, confirm_response=confirm_response)<|docstring|>Saves configuration.<|endoftext|> |
70d65a8001f401ba4e27db90670392d7805ad76584d7333369294e916bb90f96 | def cleanup(self):
'Return paging before disconnect'
self.send_command_timing('enable clipaging')
return super().cleanup() | Return paging before disconnect | netmiko/dlink/dlink_ds.py | cleanup | benmcbenben/netmiko | 2 | python | def cleanup(self):
self.send_command_timing('enable clipaging')
return super().cleanup() | def cleanup(self):
self.send_command_timing('enable clipaging')
return super().cleanup()<|docstring|>Return paging before disconnect<|endoftext|> |
1bf1e4a9ae1d2818658fb54d36e0f7f3a8783b5a4adb02af03e2dade16e3ab23 | def neighbors(adata, n_neighbors=15, key_added=None, **kwargs):
'\n Wrapper function for sc.pp.neighbors(), for supporting multiple n_neighbors\n '
if (not isinstance(n_neighbors, (list, tuple))):
sc.pp.neighbors(adata, n_neighbors=n_neighbors, key_added=key_added, **kwargs)
else:
for ... | Wrapper function for sc.pp.neighbors(), for supporting multiple n_neighbors | scanpy_scripts/lib/_neighbors.py | neighbors | ksenia007/scanpy-scripts | 21 | python | def neighbors(adata, n_neighbors=15, key_added=None, **kwargs):
'\n \n '
if (not isinstance(n_neighbors, (list, tuple))):
sc.pp.neighbors(adata, n_neighbors=n_neighbors, key_added=key_added, **kwargs)
else:
for (i, n_nb) in enumerate(n_neighbors):
if (key_added is None):
... | def neighbors(adata, n_neighbors=15, key_added=None, **kwargs):
'\n \n '
if (not isinstance(n_neighbors, (list, tuple))):
sc.pp.neighbors(adata, n_neighbors=n_neighbors, key_added=key_added, **kwargs)
else:
for (i, n_nb) in enumerate(n_neighbors):
if (key_added is None):
... |
0d1f45b02ccd7ebe99d7b0563b1fc5e69312ae3871b3c4c006c5bd3f69b2ee1e | def plot_samples(X_images, img_height, img_width, figsize=(5, 5), transpose=True, shuffle=True):
'\n Args:\n X_images: A 2-D ndarray (matrix) each row of which holds the pixels as features\n of one image. The row number will be the number of all input images.\n img_height: The pixel numb... | Args:
X_images: A 2-D ndarray (matrix) each row of which holds the pixels as features
of one image. The row number will be the number of all input images.
img_height: The pixel numbers of the input image in height.
img_width: The pixel numbers of the input image in width.
figsize: Optional. The ... | misc/imgreader.py | plot_samples | bshao001/DmsMsgRcg | 19 | python | def plot_samples(X_images, img_height, img_width, figsize=(5, 5), transpose=True, shuffle=True):
'\n Args:\n X_images: A 2-D ndarray (matrix) each row of which holds the pixels as features\n of one image. The row number will be the number of all input images.\n img_height: The pixel numb... | def plot_samples(X_images, img_height, img_width, figsize=(5, 5), transpose=True, shuffle=True):
'\n Args:\n X_images: A 2-D ndarray (matrix) each row of which holds the pixels as features\n of one image. The row number will be the number of all input images.\n img_height: The pixel numb... |
66d414c2bdc85ec5e0bb73a42e95985efd726897fef5b2a2a417c1971ae07062 | def get_features_all_images(self, img_dir, ext_filter=['.jpg', '.png'], stride=5, padding=True, data_augm=False):
'\n Output the features extracted from all images in one folder. This method is designed only\n for the trainers.\n Args:\n img_dir: The full path to the images to be... | Output the features extracted from all images in one folder. This method is designed only
for the trainers.
Args:
img_dir: The full path to the images to be feature-extracted.
ext_filter: Optional. File name filter.
stride: Optional. The stride of the sliding.
padding: Optional. Whether to pad the i... | misc/imgreader.py | get_features_all_images | bshao001/DmsMsgRcg | 19 | python | def get_features_all_images(self, img_dir, ext_filter=['.jpg', '.png'], stride=5, padding=True, data_augm=False):
'\n Output the features extracted from all images in one folder. This method is designed only\n for the trainers.\n Args:\n img_dir: The full path to the images to be... | def get_features_all_images(self, img_dir, ext_filter=['.jpg', '.png'], stride=5, padding=True, data_augm=False):
'\n Output the features extracted from all images in one folder. This method is designed only\n for the trainers.\n Args:\n img_dir: The full path to the images to be... |
26008085a73bc8fd3209f5f010686830faf426c68fad7ce3df1f052ad411a825 | def get_image_features(self, img_file, stride=5, padding=True):
'\n Take an image file as input, and output an array of image features whose matrix size is\n based on the image size. When no padding, and the image size is smaller than the required\n feature space size (in x or y direction), the... | Take an image file as input, and output an array of image features whose matrix size is
based on the image size. When no padding, and the image size is smaller than the required
feature space size (in x or y direction), the image is not checked, and this method will
return a tuple of two empty lists; When padding is Tr... | misc/imgreader.py | get_image_features | bshao001/DmsMsgRcg | 19 | python | def get_image_features(self, img_file, stride=5, padding=True):
'\n Take an image file as input, and output an array of image features whose matrix size is\n based on the image size. When no padding, and the image size is smaller than the required\n feature space size (in x or y direction), the... | def get_image_features(self, img_file, stride=5, padding=True):
'\n Take an image file as input, and output an array of image features whose matrix size is\n based on the image size. When no padding, and the image size is smaller than the required\n feature space size (in x or y direction), the... |
3013104b6a5a2bbb44f32070f29af9faf57c4683ff69edd926b471359c7f98c6 | def get_image_array_features(self, img_arr, stride=5, padding=True):
'\n Take an image file as input, and output an array of image features whose matrix size is\n based on the image size. When no padding, and the image size is smaller than the required\n feature space size (in x or y direction)... | Take an image file as input, and output an array of image features whose matrix size is
based on the image size. When no padding, and the image size is smaller than the required
feature space size (in x or y direction), the image is not checked, and this method will
return a tuple of two empty lists; When padding is Tr... | misc/imgreader.py | get_image_array_features | bshao001/DmsMsgRcg | 19 | python | def get_image_array_features(self, img_arr, stride=5, padding=True):
'\n Take an image file as input, and output an array of image features whose matrix size is\n based on the image size. When no padding, and the image size is smaller than the required\n feature space size (in x or y direction)... | def get_image_array_features(self, img_arr, stride=5, padding=True):
'\n Take an image file as input, and output an array of image features whose matrix size is\n based on the image size. When no padding, and the image size is smaller than the required\n feature space size (in x or y direction)... |
24b18eb0b6c624c820d1b3777f2fd9c393bdf870c82a086f517ce793d0bdd357 | def shuffle_data(data, labels):
' Shuffle data and labels.\n Input:\n data: B,N,... numpy array\n label: B,... numpy array\n Return:\n shuffled data, label and shuffle indices\n '
idx = np.arange(len(labels))
np.random.shuffle(idx)
return (data[(idx, ...)], la... | Shuffle data and labels.
Input:
data: B,N,... numpy array
label: B,... numpy array
Return:
shuffled data, label and shuffle indices | torchpcp/datasets/S3DIS/utils/provider.py | shuffle_data | Obarads/torch_point_cloud | 1 | python | def shuffle_data(data, labels):
' Shuffle data and labels.\n Input:\n data: B,N,... numpy array\n label: B,... numpy array\n Return:\n shuffled data, label and shuffle indices\n '
idx = np.arange(len(labels))
np.random.shuffle(idx)
return (data[(idx, ...)], la... | def shuffle_data(data, labels):
' Shuffle data and labels.\n Input:\n data: B,N,... numpy array\n label: B,... numpy array\n Return:\n shuffled data, label and shuffle indices\n '
idx = np.arange(len(labels))
np.random.shuffle(idx)
return (data[(idx, ...)], la... |
cc4e9e89a324ac40add425d25b2b61c623d1408d98a8472d1a32dbdb6966ec46 | def rotate_point_cloud_ndim(batch_xyzc, degree=None):
' Randomly rotate the point clouds to augument the dataset\n rotation is per shape based along up direction\n Input:\n BxNxC array, original batch of point clouds\n Return:\n BxNxC array, rotated batch of point clouds\n ... | Randomly rotate the point clouds to augument the dataset
rotation is per shape based along up direction
Input:
BxNxC array, original batch of point clouds
Return:
BxNxC array, rotated batch of point clouds | torchpcp/datasets/S3DIS/utils/provider.py | rotate_point_cloud_ndim | Obarads/torch_point_cloud | 1 | python | def rotate_point_cloud_ndim(batch_xyzc, degree=None):
' Randomly rotate the point clouds to augument the dataset\n rotation is per shape based along up direction\n Input:\n BxNxC array, original batch of point clouds\n Return:\n BxNxC array, rotated batch of point clouds\n ... | def rotate_point_cloud_ndim(batch_xyzc, degree=None):
' Randomly rotate the point clouds to augument the dataset\n rotation is per shape based along up direction\n Input:\n BxNxC array, original batch of point clouds\n Return:\n BxNxC array, rotated batch of point clouds\n ... |
bc3a9d784919c08a53ebbd0fa3cf512e012cb65e021f05d4c8266f706d0e126e | def rotate_point_cloud(batch_data):
' Randomly rotate the point clouds to augument the dataset\n rotation is per shape based along up direction\n Input:\n BxNx3 array, original batch of point clouds\n Return:\n BxNx3 array, rotated batch of point clouds\n '
rotated_data... | Randomly rotate the point clouds to augument the dataset
rotation is per shape based along up direction
Input:
BxNx3 array, original batch of point clouds
Return:
BxNx3 array, rotated batch of point clouds | torchpcp/datasets/S3DIS/utils/provider.py | rotate_point_cloud | Obarads/torch_point_cloud | 1 | python | def rotate_point_cloud(batch_data):
' Randomly rotate the point clouds to augument the dataset\n rotation is per shape based along up direction\n Input:\n BxNx3 array, original batch of point clouds\n Return:\n BxNx3 array, rotated batch of point clouds\n '
rotated_data... | def rotate_point_cloud(batch_data):
' Randomly rotate the point clouds to augument the dataset\n rotation is per shape based along up direction\n Input:\n BxNx3 array, original batch of point clouds\n Return:\n BxNx3 array, rotated batch of point clouds\n '
rotated_data... |
260a163552aa67b0009b0a0d44379fd73cf6dbee4faef3a6af339fefac03187c | def rotate_point_cloud_by_angle(batch_data, rotation_angle):
' Rotate the point cloud along up direction with certain angle.\n Input:\n BxNx3 array, original batch of point clouds\n Return:\n BxNx3 array, rotated batch of point clouds\n '
rotated_data = np.zeros(batch_data.sha... | Rotate the point cloud along up direction with certain angle.
Input:
BxNx3 array, original batch of point clouds
Return:
BxNx3 array, rotated batch of point clouds | torchpcp/datasets/S3DIS/utils/provider.py | rotate_point_cloud_by_angle | Obarads/torch_point_cloud | 1 | python | def rotate_point_cloud_by_angle(batch_data, rotation_angle):
' Rotate the point cloud along up direction with certain angle.\n Input:\n BxNx3 array, original batch of point clouds\n Return:\n BxNx3 array, rotated batch of point clouds\n '
rotated_data = np.zeros(batch_data.sha... | def rotate_point_cloud_by_angle(batch_data, rotation_angle):
' Rotate the point cloud along up direction with certain angle.\n Input:\n BxNx3 array, original batch of point clouds\n Return:\n BxNx3 array, rotated batch of point clouds\n '
rotated_data = np.zeros(batch_data.sha... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.