complexity int64 1 139 | fun_name stringlengths 1 80 | code stringlengths 101 62.2k | commit_id stringlengths 40 40 | ast_errors stringlengths 0 3.11k | ast_levels int64 6 36 | file_name stringlengths 5 79 | n_ast_nodes int64 17 19.2k | commit_message stringlengths 3 15.3k | d_id int64 12 121k | n_ast_errors int64 0 9 | n_whitespaces int64 4 10.8k | token_counts int64 5 3.06k | vocab_size int64 4 1.11k | id int64 20 338k | n_words int64 4 4.82k | repo stringlengths 3 22 | n_identifiers int64 2 176 | path stringlengths 7 134 | language stringclasses 1
value | nloc int64 1 413 | documentation dict | url stringlengths 31 59 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | sorted_items | def sorted_items(self) -> List[Tuple[str, "PNGHeaderDict"]]:
items = sorted(self.process_folder(), key=itemgetter(0))
logger.trace(items) # type: ignore
return items
| c79175cbde5600bebd65785f3821fc74b3a80cbe | 11 | media.py | 69 | Alignments Tool updates
- Copy info back to alignments file from faces | 21,162 | 0 | 44 | 41 | 14 | 101,758 | 15 | faceswap | 12 | tools/alignments/media.py | Python | 11 | {
"docstring": " Return the items sorted by the saved file name.\n\n Returns\n --------\n list\n List of `dict` objects for each face found, sorted by the face's current filename\n ",
"language": "en",
"n_whitespaces": 66,
"n_words": 26,
"vocab_size": 22
} | https://github.com/deepfakes/faceswap.git | |
4 | encrypt_file | def encrypt_file(self, file, key=0):
# precondition
assert isinstance(file, str) and isinstance(key, int)
try:
with open(file, "r") as fin:
with open("encrypt.out", "w+") as fout:
# actual encrypt-process
for line in ... | f0af0c43340763724f139fa68aa1e5a9ffe458b4 | 17 | XOR_cipher.py | 125 | refactor: clean code
Signed-off-by: slowy07 <slowy.arfy@gmail.com> | 4,359 | 0 | 177 | 72 | 32 | 22,543 | 37 | Python | 13 | XORcipher/XOR_cipher.py | Python | 10 | {
"docstring": "\n input: filename (str) and a key (int)\n output: returns true if encrypt process was\n successful otherwise false\n if key not passed the method uses the key by the constructor.\n otherwise key = 1\n ",
"language": "en",
"n_whitespaces": 76,
"n_words":... | https://github.com/geekcomputers/Python.git | |
11 | _get_next_prev | def _get_next_prev(generic_view, date, is_previous, period):
date_field = generic_view.get_date_field()
allow_empty = generic_view.get_allow_empty()
allow_future = generic_view.get_allow_future()
get_current = getattr(generic_view, "_get_current_%s" % period)
get_next = getattr(generic_view, "... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 16 | dates.py | 429 | Refs #33476 -- Reformatted code with Black. | 51,762 | 0 | 658 | 247 | 144 | 206,861 | 251 | django | 35 | django/views/generic/dates.py | Python | 39 | {
"docstring": "\n Get the next or the previous valid date. The idea is to allow links on\n month/day views to never be 404s by never providing a date that'll be\n invalid for the given view.\n\n This is a bit complicated since it handles different intervals of time,\n hence the coupling to generic_vie... | https://github.com/django/django.git | |
5 | request_url | def request_url(self, request, proxies):
proxy = select_proxy(request.url, proxies)
scheme = urlparse(request.url).scheme
is_proxied_http_request = proxy and scheme != "https"
using_socks_proxy = False
if proxy:
proxy_scheme = urlparse(proxy).scheme.lower()
... | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | 13 | adapters.py | 140 | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 4,131 | 0 | 138 | 84 | 27 | 22,042 | 42 | pipenv | 16 | pipenv/patched/pip/_vendor/requests/adapters.py | Python | 12 | {
"docstring": "Obtain the url to use when making the final request.\n\n If the message is being sent through a HTTP proxy, the full URL has to\n be used. Otherwise, we should only use the path portion of the URL.\n\n This should not be called from user code, and is only exposed for use\n ... | https://github.com/pypa/pipenv.git | |
2 | cast_to_floatx | def cast_to_floatx(x):
if isinstance(x, (tf.Tensor, tf.Variable, tf.SparseTensor)):
return tf.cast(x, dtype=floatx())
return np.asarray(x, dtype=floatx())
@keras_export("keras.backend.get_uid") | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | @keras_export("keras.backend.get_uid") | 12 | backend.py | 92 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 80,227 | 1 | 29 | 52 | 12 | 269,607 | 14 | keras | 13 | keras/backend.py | Python | 4 | {
"docstring": "Cast a Numpy array to the default Keras float type.\n\n Args:\n x: Numpy array or TensorFlow tensor.\n\n Returns:\n The same array (Numpy array if `x` was a Numpy array, or TensorFlow tensor\n if `x` was a tensor), cast to its new type.\n\n Example:\n\n >>> tf.keras.ba... | https://github.com/keras-team/keras.git |
10 | query | def query(self, table, columns=None, where=None, where_data=None, order_by=None, group_by=None, integration_name=None, integration_type=None):
if table == 'predictors':
return self._select_predictors()
if table == 'datasources':
return self._select_datasources()
... | b9ee4a5930e20a09350a3e0774283ba658a42da7 | 16 | mindsdb_datanode.py | 269 | del code | 25,538 | 0 | 287 | 169 | 59 | 115,746 | 82 | mindsdb | 25 | mindsdb/api/mysql/mysql_proxy/datahub/datanodes/mindsdb_datanode.py | Python | 18 | {
"docstring": " NOTE WHERE statements can be just $eq joined with 'and'\n ",
"language": "en",
"n_whitespaces": 18,
"n_words": 10,
"vocab_size": 10
} | https://github.com/mindsdb/mindsdb.git | |
2 | mock_json_schema | def mock_json_schema(request, monkeypatch, tmp_path):
# Do not patch integration tests
if "integration" in request.keywords:
return
# Mock the subclasses list to make it very small, containing only mock nodes
monkeypatch.setattr(
haystack.nodes._json_schema,
"find_subclasse... | 11cf94a9652a577732941f27ad59eb7c8bc5063e | @pytest.mark.integration
@pytest.mark.elasticsearch | 11 | test_pipeline_yaml.py | 209 | Pipeline's YAML: syntax validation (#2226)
* Add BasePipeline.validate_config, BasePipeline.validate_yaml, and some new custom exception classes
* Make error composition work properly
* Clarify typing
* Help mypy a bit more
* Update Documentation & Code Style
* Enable autogenerated docs for Milvus1 and ... | 74,961 | 1 | 148 | 116 | 68 | 256,915 | 82 | haystack | 30 | test/test_pipeline_yaml.py | Python | 13 | {
"docstring": "\n JSON schema with the unstable version and only mocked nodes.\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 10,
"vocab_size": 10
} | https://github.com/deepset-ai/haystack.git |
4 | _get_object_config | def _get_object_config(obj):
if isinstance(obj, str):
# Use the content of the string as the config for string.
return obj
elif isinstance(obj, types.FunctionType):
# Keep track of the function's module and name in a dict as the config.
return {
'module': obj.__module__,
'function... | e70d21c144503f560d8659fec0e08267e686a431 | 11 | saving_lib.py | 110 | Keras saving: A prototype of config-based (idempotent) saving and loading. This shows an example of custom Model, Layer, Optimizer, and Loss, and adds test to confirm that the basic aforementioned elements work across this new saving and loading scheme.
PiperOrigin-RevId: 447193044 | 79,990 | 0 | 95 | 62 | 44 | 269,264 | 58 | keras | 11 | keras/saving/experimental/saving_lib.py | Python | 11 | {
"docstring": "Return the object's config depending on string, function, or others.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/keras-team/keras.git | |
1 | _get | def _get(self, serialized_key):
cur = self.connection.cursor()
# should always be a single match, hence the [0]
return list(cur.execute(f))[0][0]
| 0fd3b436c38f38bcae6fed9e14dc4d2a12e90793 | 13 | storage_handler.py | 57 | fix tests and reformat | 25,171 | 0 | 38 | 33 | 18 | 114,374 | 18 | mindsdb | 8 | mindsdb/integrations/libs/storage_handler.py | Python | 3 | {
"docstring": "select value from store where key='{serialized_key}'",
"language": "en",
"n_whitespaces": 5,
"n_words": 6,
"vocab_size": 6
} | https://github.com/mindsdb/mindsdb.git | |
6 | deal_duplicate_bb | def deal_duplicate_bb(thead_part):
# 1. find out <td></td> in <thead></thead>.
td_pattern = "<td rowspan=\"(\d)+\" colspan=\"(\d)+\">(.+?)</td>|" \
"<td colspan=\"(\d)+\" rowspan=\"(\d)+\">(.+?)</td>|" \
"<td rowspan=\"(\d)+\">(.+?)</td>|" \
"<td colspan=\... | ddaa2c2552e19635cd6cdf38619f1f176c358f89 | 15 | table_master_match.py | 259 | add SLANet | 4,744 | 0 | 371 | 140 | 71 | 24,496 | 112 | PaddleOCR | 16 | ppstructure/table/table_master_match.py | Python | 20 | {
"docstring": "\n Deal duplicate <b> or </b> after replace.\n Keep one <b></b> in a <td></td> token.\n :param thead_part:\n :return:\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 17,
"vocab_size": 17
} | https://github.com/PaddlePaddle/PaddleOCR.git | |
1 | test_readback_tfrecords | def test_readback_tfrecords(ray_start_regular_shared, tmp_path):
# The dataset we will write to a .tfrecords file.
ds = ray.data.from_items(
[
# Row one.
{
"int_item": 1,
"int_list": [2, 2, 3],
"float_item": 1.0,
... | 9fab504fe776f96fecf85e12ea006264cbe92f4a | 13 | test_dataset_tfrecords.py | 226 | [Datasets] Add writer for TFRecords. (#29448)
This PR enables users to write TFRecords from datasets.
In particular, the master branch already includes an API for reading TFRecords from datasets. Users have requested the ability to write these datasets back to TFRecords. | 30,664 | 0 | 366 | 155 | 59 | 135,585 | 79 | ray | 11 | python/ray/data/tests/test_dataset_tfrecords.py | Python | 24 | {
"docstring": "\n Test reading back TFRecords written using datasets.\n The dataset we read back should be the same that we wrote.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 19,
"vocab_size": 17
} | https://github.com/ray-project/ray.git | |
1 | test_uninstall_from_sentry | def test_uninstall_from_sentry(self):
self.login_as(self.user)
with self.tasks():
config_id = "my_config_id"
responses.add(
responses.DELETE,
f"{VercelClient.base_url}{VercelClient.UNINSTALL % config_id}",
json={},
... | 8201e74ec3d81e89354905c946e62436f0247602 | 14 | test_uninstall.py | 596 | ref(integrations): Update Vercel endpoints (#36150)
This PR updates the endpoints we reach to in the Vercel integration. It seems to work just fine without changes as the payloads returned from vercel haven't updated, but we'll need to specify API Scopes so they don't receive 403s.
This also refactored the paginat... | 18,884 | 0 | 949 | 316 | 58 | 92,186 | 128 | sentry | 40 | tests/sentry/integrations/vercel/test_uninstall.py | Python | 71 | {
"docstring": "\n Test flows of uninstalling from sentry first to make sure\n that uninstall webhook is valid even if the OrganizationIntegration\n was deleted prior.\n 1. Uninstall the primary configuration\n 2. Check that integration metadata still updated\n 3. Unins... | https://github.com/getsentry/sentry.git | |
4 | check_connection | def check_connection(self) -> StatusResponse:
response = StatusResponse(False)
try:
session = self.connect()
# TODO: change the healthcheck
session.execute('SELECT release_version FROM system.local').one()
response.success = True
except E... | f1fb699f88f8644d46afa9a2786a934510b05b79 | 14 | scylla_handler.py | 147 | Impl handler | 25,506 | 0 | 168 | 75 | 40 | 115,631 | 49 | mindsdb | 16 | mindsdb/integrations/handlers/scylla_handler/scylla_handler.py | Python | 16 | {
"docstring": "\n Check the connection of the Scylla database\n :return: success status and error message if error occurs\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 16,
"vocab_size": 14
} | https://github.com/mindsdb/mindsdb.git | |
2 | downgrade | def downgrade():
conn = op.get_bind()
if conn.dialect.name == "mysql":
op.alter_column(
table_name=TABLE_NAME, column_name=COLUMN_NAME, type_=mysql.TIMESTAMP(), nullable=False
)
| 69f6f9e01b6df76c3c8fa266d460324163957887 | 12 | a66efa278eea_add_precision_to_execution_date_in_mysql.py | 75 | Autogenerate migration reference doc (#21601)
* document airflow version in each alembic migration module and use this to autogen the doc
* update each migration module to have the same description used in migration ref (so it can be used in autogen) | 8,614 | 0 | 49 | 45 | 15 | 45,487 | 15 | airflow | 15 | airflow/migrations/versions/a66efa278eea_add_precision_to_execution_date_in_mysql.py | Python | 6 | {
"docstring": "Unapply Add Precision to ``execution_date`` in ``RenderedTaskInstanceFields`` table",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/apache/airflow.git | |
1 | setraw | def setraw(fd, when=termios.TCSAFLUSH):
mode = termios.tcgetattr(fd)
mode[tty.IFLAG] = mode[tty.IFLAG] & ~(termios.BRKINT | termios.ICRNL | termios.INPCK | termios.ISTRIP | termios.IXON)
# mode[tty.OFLAG] = mode[tty.OFLAG] & ~(termios.OPOST)
mode[tty.CFLAG] = mode[tty.CFLAG] & ~(termios.CSIZE | ter... | 5797d06aecb1ff620483f6c3ff4bd6d30356332f | 14 | pause.py | 250 | Use customized setraw to prevent output issues (#78060) | 78,971 | 0 | 87 | 165 | 33 | 267,602 | 57 | ansible | 27 | lib/ansible/plugins/action/pause.py | Python | 9 | {
"docstring": "Put terminal into a raw mode.\n\n Copied from ``tty`` from CPython 3.11.0, and modified to not remove OPOST from OFLAG\n\n OPOST is kept to prevent an issue with multi line prompts from being corrupted now that display\n is proxied via the queue from forks. The problem is a race condition, in... | https://github.com/ansible/ansible.git | |
1 | get_student_attendance | def get_student_attendance(student_group, date):
student_attendance = frappe.db.sql(
,
(student_group, date),
as_dict=1,
)
return student_attendance
| 494bd9ef78313436f0424b918f200dab8fc7c20b | 9 | student_batch_wise_attendance.py | 45 | style: format code with black | 14,062 | 0 | 6 | 30 | 12 | 65,941 | 13 | erpnext | 8 | erpnext/education/report/student_batch_wise_attendance/student_batch_wise_attendance.py | Python | 9 | {
"docstring": "select count(*) as count, status from `tabStudent Attendance` where\n\t\t\t\tstudent_group= %s and date= %s and docstatus = 1 and\n\t\t\t\t(course_schedule is Null or course_schedule='') group by status",
"language": "en",
"n_whitespaces": 24,
"n_words": 27,
"vocab_size": 23
} | https://github.com/frappe/erpnext.git | |
3 | test_legend_auto5 | def test_legend_auto5():
fig, axs = plt.subplots(ncols=2, figsize=(9.6, 4.8))
leg_bboxes = []
for ax, loc in zip(axs.flat, ("center", "best")):
# An Ellipse patch at the top, a U-shaped Polygon patch at the
# bottom and a ring-like Wedge patch: the correct placement of
# the le... | d8bb1a52316c38434e526412c27d9c4b01960084 | @image_comparison(['legend_various_labels'], remove_text=True) | 14 | test_legend.py | 390 | ENH: rely on non-rectangular patch paths rather than bboxes for legend auto-placing (fix #9580) (#9598)
* use path rather than bbox for non rectangular patches
* Add tests
* Add a short breadcrumb note in api_changes | 24,225 | 1 | 319 | 300 | 82 | 110,587 | 109 | matplotlib | 39 | lib/matplotlib/tests/test_legend.py | Python | 19 | {
"docstring": "\n Check that the automatic placement handle a rather complex\n case with non rectangular patch. Related to issue #9580.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 18,
"vocab_size": 18
} | https://github.com/matplotlib/matplotlib.git |
1 | sort_accounts | def sort_accounts(accounts, is_root=False, key="name"):
def compare_accounts(a, b):
if re.split(r"\W+", a[key])[0].isdigit():
# if chart of accounts is numbered, then sort by number
return int(a[key] > b[key]) - int(a[key] < b[key])
elif is_root:
if a.report_type != b.report_type and a.report_type == "... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 15 | financial_statements.py | 297 | style: format code with black | 13,828 | 0 | 72 | 29 | 49 | 65,230 | 91 | erpnext | 16 | erpnext/accounts/report/financial_statements.py | Python | 3 | {
"docstring": "Sort root types as Asset, Liability, Equity, Income, Expense",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/frappe/erpnext.git | |
1 | look_at | def look_at(eye, center, world_up):
batch_size = center.shape[0]
vector_degeneracy_cutoff = 1e-6
forward = center - eye
forward_norm = np.linalg.norm(forward, axis=1, keepdims=True)
forward = np.divide(forward, forward_norm)
to_side = np.cross(forward, world_up)
to_side_norm = np.linal... | 7375ee364e0df2a417f92593e09557f1b2a3575a | 13 | ganfit_camera.py | 410 | initialize ostec | 1,638 | 0 | 223 | 287 | 72 | 9,563 | 112 | insightface | 34 | reconstruction/ostec/utils/ganfit_camera.py | Python | 26 | {
"docstring": "Computes camera viewing matrices.\n Functionality mimes gluLookAt (third_party/GL/glu/include/GLU/glu.h).\n Args:\n eye: 2-D float32 tensor with shape [batch_size, 3] containing the XYZ world\n space position of the camera.\n center: 2-D float32 tensor with shape [batch_size, 3] con... | https://github.com/deepinsight/insightface.git | |
1 | on_train_batch_end | def on_train_batch_end(self, batch, logs=None):
# For backwards compatibility.
self.on_batch_end(batch, logs=logs)
| f3cafc77c269f7ecbf80bb4cf4b54e28c153f4e6 | 8 | callbacks.py | 36 | resolve line-too-long in root directory | 82,206 | 0 | 31 | 22 | 10 | 277,786 | 10 | keras | 5 | keras/callbacks.py | Python | 2 | {
"docstring": "Called at the end of a training batch in `fit` methods.\n\n Subclasses should override for any actions to run.\n\n Note that if the `steps_per_execution` argument to `compile` in\n `tf.keras.Model` is set to `N`, this method will only be called every\n `N` batches.\n\n ... | https://github.com/keras-team/keras.git | |
5 | pop_up | def pop_up(self, text='', move=True):
self.edit.setText(text)
self.edit.setSelection(0, len(text))
self.edit.setFocus(Qt.PopupFocusReason)
if move:
cursor_pos = QCursor.pos()
# move OK button below cursor
btn = self.button_box.buttons()[0]
... | 0c377fc2588ad0f57b3060c26f2d4f891c68276f | 15 | labelDialog.py | 515 | move "OK" button below cursor when opening label dialog (#893)
The intent for this change is to allow faster labeling when there
are streaks of the same label occasionally, but not consistently
enough to enable "default label" mode. With this PR the user can
simply click again to confirm the previous selection, wit... | 43,352 | 0 | 327 | 310 | 61 | 181,545 | 79 | labelImg | 38 | libs/labelDialog.py | Python | 23 | {
"docstring": "\n Shows the dialog, setting the current text to `text`, and blocks the caller until the user has made a choice.\n If the user entered a label, that label is returned, otherwise (i.e. if the user cancelled the action)\n `None` is returned.\n ",
"language": "en",
"n_whit... | https://github.com/heartexlabs/labelImg.git | |
5 | create_pseudo_labeled_data | def create_pseudo_labeled_data(args, infer_input, infer_output, eval_result, id2label, next_data_dir):
dataset = datasets.concatenate_datasets([infer_input, infer_output], axis=1)
if args.do_filter_by_confidence:
dataset = dataset.filter(lambda example: example["probability"] > args.confidence_th... | 34ef029dc04bb94b4e280e02ef3e82dacf1b9dfc | 14 | selftraining.py | 332 | Add self training code for text classification (#16738)
* Add self-training code for text-classification
* Add self-training code for text-classification
* Add self-training code for text-classification
* Add self-training code for text-classification
* Add self-training code for text-classification
* D... | 6,736 | 0 | 162 | 203 | 53 | 37,117 | 73 | transformers | 37 | examples/research_projects/self-training-text-classification/selftraining.py | Python | 19 | {
"docstring": "Create pseudeo labeled data for the next self-training iteration.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/huggingface/transformers.git | |
17 | jacobi_symbol | def jacobi_symbol(m, n):
r
m, n = as_int(m), as_int(n)
if n < 0 or not n % 2:
raise ValueError("n should be an odd positive integer")
if m < 0 or m > n:
m %= n
if not m:
return int(n == 1)
if n == 1 or m == 1:
return 1
if igcd(m, n) != 1:
return 0
... | d7614cda8f6b341df8515c65244a415b0bf2fc6f | 13 | residue_ntheory.py | 234 | jacobi_symbol: remove dead code paths
Fixes #23443
The first part of the code was never reached `m %= n`
The later `n != 1` condition never matched either since the gcd calculation prevented that from ever happening.
```python
if igcd(m, n) != 1:
return 0
```
https://en.wikipedia.org/wiki/Jaco... | 48,735 | 0 | 254 | 177 | 52 | 197,883 | 114 | sympy | 8 | sympy/ntheory/residue_ntheory.py | Python | 85 | {
"docstring": "\n Returns the Jacobi symbol `(m / n)`.\n\n For any integer ``m`` and any positive odd integer ``n`` the Jacobi symbol\n is defined as the product of the Legendre symbols corresponding to the\n prime factors of ``n``:\n\n .. math ::\n \\genfrac(){}{}{m}{n} =\n \\genfra... | https://github.com/sympy/sympy.git | |
1 | _topk | def _topk(self, scores):
k = self.max_per_img
shape_fm = paddle.shape(scores)
shape_fm.stop_gradient = True
cat, height, width = shape_fm[1], shape_fm[2], shape_fm[3]
# batch size is 1
scores_r = paddle.reshape(scores, [cat, -1])
topk_scores, topk_inds = ... | 5e02a81af77a9a4ecd1e394430c4396b48bc76fd | 10 | layers.py | 344 | remove one line redundant code (#6424) | 53,025 | 0 | 242 | 238 | 60 | 211,087 | 95 | PaddleDetection | 29 | ppdet/modeling/layers.py | Python | 21 | {
"docstring": "\n Select top k scores and decode to get xy coordinates.\n ",
"language": "en",
"n_whitespaces": 25,
"n_words": 10,
"vocab_size": 10
} | https://github.com/PaddlePaddle/PaddleDetection.git | |
3 | latitude | def latitude(self) -> float | None:
if (
self.extra_state_attributes is not None
and ATTR_LATITUDE in self.extra_state_attributes
):
latitude: float = self.extra_state_attributes[ATTR_LATITUDE]
return latitude
return None
| bcae6d604e2967c7475f0caa4b1b5e4e76ab88bf | 10 | schema_discovery.py | 64 | Improve MQTT type hints part 8 (#81034)
* Improve typing device_tracker discovery
* Improve typing device_tracker yaml
* Add test source_type attribute
* Follow up comment
* Initialize at `__init__` not at class level.
* Use full name for return variable
* Correct import, remove assert
* Use Async... | 89,084 | 0 | 97 | 40 | 21 | 289,958 | 25 | core | 5 | homeassistant/components/mqtt/device_tracker/schema_discovery.py | Python | 9 | {
"docstring": "Return latitude if provided in extra_state_attributes or None.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/home-assistant/core.git | |
1 | test_false_values_displayed | def test_false_values_displayed(self):
response = self.get(4)
self.assertContains(response, "<dd>False</dd>", count=3, html=True)
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 8 | test_page_modeladmin.py | 50 | Reformat with black | 15,994 | 0 | 30 | 30 | 9 | 73,222 | 9 | wagtail | 7 | wagtail/contrib/modeladmin/tests/test_page_modeladmin.py | Python | 3 | {
"docstring": "\n Boolean fields with False values should display False, rather than the\n value of `get_empty_value_display()`. For this page, those should be\n `locked`, `expired` and `has_unpublished_changes`\n ",
"language": "en",
"n_whitespaces": 53,
"n_words": 24,
"vocab_siz... | https://github.com/wagtail/wagtail.git | |
2 | call | def call(self, inputs, **kwargs): # pylint:disable=unused-argument
# Compute the axes along which to reduce the mean / variance
input_shape = K.int_shape(inputs)
layer_size = input_shape[self.axis]
if self.partial in (0.0, 1.0):
mean_square = K.mean(K.square(inputs... | c1512fd41d86ef47a5d1ce618d6d755ef7cbacdf | 13 | normalization_tf.py | 230 | Update code to support Tensorflow versions up to 2.8 (#1213)
* Update maximum tf version in setup + requirements
* - bump max version of tf version in launcher
- standardise tf version check
* update keras get_custom_objects for tf>2.6
* bugfix: force black text in GUI file dialogs (linux)
* dssim loss -... | 19,848 | 0 | 227 | 153 | 53 | 100,359 | 73 | faceswap | 27 | lib/model/normalization/normalization_tf.py | Python | 15 | {
"docstring": " Call Root Mean Square Layer Normalization\n\n Parameters\n ----------\n inputs: tensor\n Input tensor, or list/tuple of input tensors\n\n Returns\n -------\n tensor\n A tensor or list/tuple of tensors\n ",
"language": "en",
"n... | https://github.com/deepfakes/faceswap.git | |
3 | test_to_python | def test_to_python(self):
table = self.block.to_python(self.db_data)
self.assertIsInstance(table, TypedTable)
self.assertEqual(len(table.columns), 2)
self.assertEqual(table.columns[0]["heading"], "Country")
self.assertEqual(table.columns[1]["heading"], "Description")
... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 10 | tests.py | 221 | Reformat with black | 16,073 | 0 | 161 | 137 | 33 | 73,622 | 44 | wagtail | 14 | wagtail/contrib/typed_table_block/tests.py | Python | 15 | {
"docstring": "\n Test that we can turn JSONish data from the database into a TypedTable instance\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 14,
"vocab_size": 14
} | https://github.com/wagtail/wagtail.git | |
2 | _format_maybe_minus_and_locale | def _format_maybe_minus_and_locale(self, fmt, arg):
return self.fix_minus(locale.format_string(fmt, (arg,), True)
if self._useLocale else fmt % arg)
| 88cb4c9d0aa1e790fc4689ca7e68725bf851bf63 | 11 | ticker.py | 55 | Properly capitalize "Unicode".
See e.g. https://en.wikipedia.org/wiki/Unicode,
https://docs.python.org/3/howto/unicode.html.
Also associated minor doc cleanups. | 22,797 | 0 | 57 | 37 | 14 | 107,535 | 14 | matplotlib | 8 | lib/matplotlib/ticker.py | Python | 3 | {
"docstring": "\n Format *arg* with *fmt*, applying Unicode minus and locale if desired.\n ",
"language": "en",
"n_whitespaces": 26,
"n_words": 11,
"vocab_size": 11
} | https://github.com/matplotlib/matplotlib.git | |
1 | create_session | def create_session(self, loop):
session = ClientSession(loop=loop, json_serialize=json_dumps)
# Setting directly on `session` will raise deprecation warning
object.__setattr__(session, "_request", self.match_request)
return session
| da027fa3905d36b91beefd456cb546f891617eab | 9 | aiohttp.py | 56 | JSON serialize NamedTuple subclasses with aiohttp (#74971) | 115,615 | 0 | 56 | 34 | 20 | 317,039 | 21 | core | 10 | tests/test_util/aiohttp.py | Python | 4 | {
"docstring": "Create a ClientSession that is bound to this mocker.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git | |
3 | last | def last(self):
for obj in (self.reverse() if self.ordered else self.order_by("-pk"))[:1]:
return obj
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | query.py | 57 | Refs #33476 -- Reformatted code with Black. | 51,217 | 0 | 37 | 34 | 11 | 205,791 | 12 | django | 6 | django/db/models/query.py | Python | 3 | {
"docstring": "Return the last object of a query or None if no match is found.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 14
} | https://github.com/django/django.git | |
1 | create_view | def create_view(self, request):
kwargs = {"model_admin": self}
view_class = self.create_view_class
return view_class.as_view(**kwargs)(request)
| d10f15e55806c6944827d801cd9c2d53f5da4186 | 9 | options.py | 54 | Reformat with black | 15,968 | 0 | 40 | 31 | 11 | 73,170 | 12 | wagtail | 7 | wagtail/contrib/modeladmin/options.py | Python | 4 | {
"docstring": "\n Instantiates a class-based view to provide 'creation' functionality for\n the assigned model, or redirect to Wagtail's create view if the\n assigned model extends 'Page'. The view class used can be overridden by\n changing the 'create_view_class' attribute.\n ",
... | https://github.com/wagtail/wagtail.git | |
5 | _create_index | def _create_index(instance, table_name, index_name):
table = Table(table_name, Base.metadata)
_LOGGER.debug("Looking up index %s for table %s", index_name, table_name)
# Look up the index object by name from the table is the models
index_list = [idx for idx in table.indexes if idx.name == index_nam... | 41ab12cb88741807a246bb296762d7c683a30b58 | 15 | migration.py | 258 | Don't use shared session during recorder migration (#65672) | 110,990 | 0 | 261 | 153 | 91 | 312,340 | 119 | core | 26 | homeassistant/components/recorder/migration.py | Python | 25 | {
"docstring": "Create an index for the specified table.\n\n The index name should match the name given for the index\n within the table definition described in the models\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 26,
"vocab_size": 18
} | https://github.com/home-assistant/core.git | |
5 | squeeze | def squeeze(self, axis=None):
axis = range(self._AXIS_LEN) if axis is None else (self._get_axis_number(axis),)
return self.iloc[
tuple(
0 if i in axis and len(a) == 1 else slice(None)
for i, a in enumerate(self.axes)
)
]
# ---... | 244f747bb63f45c1c439193f0672c6162853b168 | 13 | generic.py | 108 | make series axis parameter docs consistent (#47109)
* make series docs consistent
add series unused param info to DF docs
* fix trailing whitespace
* fix docs build
* add unused
* add or update docs for all series methods
* small fix
* fix line length
* fix param order
* fix param order
*... | 39,840 | 0 | 123 | 69 | 31 | 166,611 | 37 | pandas | 14 | pandas/core/generic.py | Python | 8 | {
"docstring": "\n Squeeze 1 dimensional axis objects into scalars.\n\n Series or DataFrames with a single element are squeezed to a scalar.\n DataFrames with a single column or a single row are squeezed to a\n Series. Otherwise the object is unchanged.\n\n This method is most usefu... | https://github.com/pandas-dev/pandas.git | |
2 | filename | def filename(self):
if self.buildver:
buildver = '-' + self.buildver
else:
buildver = ''
pyver = '.'.join(self.pyver)
abi = '.'.join(self.abi)
arch = '.'.join(self.arch)
# replace - with _ as a local version separator
version = sel... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 10 | wheel.py | 146 | upd; format | 12,910 | 0 | 170 | 83 | 38 | 62,287 | 45 | transferlearning | 10 | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/wheel.py | Python | 11 | {
"docstring": "\n Build and return a filename from the various components.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | https://github.com/jindongwang/transferlearning.git | |
3 | async_internal_added_to_hass | async def async_internal_added_to_hass(self) -> None:
await super().async_internal_added_to_hass()
state = await self.async_get_last_state()
if state is not None and state.attributes.get(ATTR_SKIPPED_VERSION) is not None:
self.__skipped_version = state.attributes[ATTR_SKIPPE... | 073fb40b79cf8aa06790fdceb23b6857db888c99 | 10 | __init__.py | 88 | Add update entity platform (#68248)
Co-authored-by: Glenn Waters <glenn@watrs.ca> | 93,040 | 0 | 63 | 52 | 18 | 293,995 | 24 | core | 9 | homeassistant/components/update/__init__.py | Python | 9 | {
"docstring": "Call when the update entity is added to hass.\n\n It is used to restore the skipped version, if any.\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 19,
"vocab_size": 16
} | https://github.com/home-assistant/core.git | |
2 | generate_export_pipeline_code | def generate_export_pipeline_code(pipeline_tree, operators):
steps = _process_operator(pipeline_tree, operators)
# number of steps in a pipeline
num_step = len(steps)
if num_step > 1:
pipeline_text = "make_pipeline(\n{STEPS}\n)".format(
STEPS=_indent(",\n".join(steps), 4)
... | 388616b6247ca4ea8de4e2f340d6206aee523541 | 17 | export_utils.py | 128 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,653 | 0 | 97 | 71 | 32 | 181,898 | 41 | tpot | 12 | tpot/export_utils.py | Python | 10 | {
"docstring": "Generate code specific to the construction of the sklearn Pipeline for export_pipeline.\n\n Parameters\n ----------\n pipeline_tree: list\n List of operators in the current optimized pipeline\n\n Returns\n -------\n Source code for the sklearn pipeline\n\n ",
"language": ... | https://github.com/EpistasisLab/tpot.git | |
13 | OutputString | def OutputString(self, attrs=None):
# Build up our result
#
result = []
append = result.append
# First, the key=value pair
append("%s=%s" % (self.key, self.coded_value))
# Now add any defined attributes
if attrs is None:
attrs = self._reserve... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 18 | cookies.py | 420 | add python 3.10.4 for windows | 54,962 | 0 | 510 | 203 | 132 | 217,838 | 218 | XX-Net | 29 | python3.10.4/Lib/http/cookies.py | Python | 24 | {
"docstring": "\n \\s* # Optional whitespace at start of cookie\n (?P<key> # Start of group 'key'\n []+? # Any word of at least one letter\n ) # End of group 'key'\n ( # Optional group: there m... | https://github.com/XX-net/XX-Net.git | |
11 | validate_cycler | def validate_cycler(s):
if isinstance(s, str):
# TODO: We might want to rethink this...
# While I think I have it quite locked down, it is execution of
# arbitrary code without sanitation.
# Combine this with the possibility that rcparams might come from the
# internet (... | 22a44db48c1b7659837092c5b01a59eb1d004fc6 | 15 | rcsetup.py | 423 | Use repr in error messages | 23,050 | 0 | 646 | 228 | 192 | 108,079 | 289 | matplotlib | 31 | lib/matplotlib/rcsetup.py | Python | 32 | {
"docstring": "Return a Cycler object from a string repr or the object itself.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 10
} | https://github.com/matplotlib/matplotlib.git | |
1 | addslashes | def addslashes(value):
return value.replace("\\", "\\\\").replace('"', '\\"').replace("'", "\\'")
@register.filter(is_safe=True)
@stringfilter | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | @register.filter(is_safe=True)
@stringfilter | 12 | defaultfilters.py | 81 | Refs #33476 -- Reformatted code with Black. | 51,427 | 1 | 13 | 29 | 9 | 206,236 | 9 | django | 7 | django/template/defaultfilters.py | Python | 2 | {
"docstring": "\n Add slashes before quotes. Useful for escaping strings in CSV, for\n example. Less useful for escaping JavaScript; use the ``escapejs``\n filter instead.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 22,
"vocab_size": 19
} | https://github.com/django/django.git |
3 | get_data | def get_data(filters):
lead_details = []
lead_filters = get_lead_filters(filters)
for lead in frappe.get_all(
"Lead", fields=["name", "lead_name", "company_name"], filters=lead_filters
):
data = frappe.db.sql(
,
{"lead": lead.name, "limit": filters.get("no_of_interaction")},
)
for lead_info in data:... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 15 | prospects_engaged_but_not_converted.py | 164 | style: format code with black | 14,009 | 0 | 27 | 100 | 35 | 65,767 | 41 | erpnext | 20 | erpnext/crm/report/prospects_engaged_but_not_converted/prospects_engaged_but_not_converted.py | Python | 33 | {
"docstring": "\n\t\t\tselect\n\t\t\t\t`tabCommunication`.reference_doctype, `tabCommunication`.reference_name,\n\t\t\t\t`tabCommunication`.content, `tabCommunication`.communication_date\n\t\t\tfrom\n\t\t\t\t(\n\t\t\t\t\t(select name, party_name as lead from `tabOpportunity` where opportunity_from='Lead' and party_n... | https://github.com/frappe/erpnext.git | |
1 | choose | def choose(self, choices):
from dask.array.routines import choose
return choose(self, choices)
| 2820bae493a49cb1d0a6e376985c5473b8f04fa8 | 7 | core.py | 36 | Don't include docs in ``Array`` methods, just refer to module docs (#9244)
Co-authored-by: James Bourbeau <jrbourbeau@users.noreply.github.com> | 36,737 | 0 | 31 | 23 | 9 | 156,727 | 10 | dask | 6 | dask/array/core.py | Python | 3 | {
"docstring": "Use an index array to construct a new array from a set of choices.\n\n Refer to :func:`dask.array.choose` for full documentation.\n\n See Also\n --------\n dask.array.choose : equivalent function\n ",
"language": "en",
"n_whitespaces": 62,
"n_words": 27,
"voc... | https://github.com/dask/dask.git | |
3 | newer | def newer(self, source, target):
if not os.path.exists(source):
raise DistlibException("file '%r' does not exist" %
os.path.abspath(source))
if not os.path.exists(target):
return True
return os.stat(source).st_mtime > os.stat(t... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 13 | util.py | 108 | upd; format | 12,901 | 0 | 108 | 66 | 20 | 62,218 | 24 | transferlearning | 11 | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/util.py | Python | 7 | {
"docstring": "Tell if the target is newer than the source.\n\n Returns true if 'source' exists and is more recently modified than\n 'target', or if 'source' exists and 'target' doesn't.\n\n Returns false if both exist and 'target' is the same age or younger\n than 'source'. Raise Packagi... | https://github.com/jindongwang/transferlearning.git | |
1 | filldedent | def filldedent(s, w=70, **kwargs):
return '\n' + fill(dedent(str(s)).strip('\n'), width=w, **kwargs)
| 2047f4855577845b1b99e0926b887d313725a6e7 | 14 | misc.py | 66 | Pass keyword arguments to filldedent() through to fill() | 48,569 | 0 | 16 | 38 | 10 | 197,470 | 10 | sympy | 9 | sympy/utilities/misc.py | Python | 2 | {
"docstring": "\n Strips leading and trailing empty lines from a copy of ``s``, then dedents,\n fills and returns it.\n\n Empty line stripping serves to deal with docstrings like this one that\n start with a newline after the initial triple quote, inserting an empty\n line at the beginning of the stri... | https://github.com/sympy/sympy.git | |
1 | test_regex | def test_regex(self) -> None:
# Some of the undocumented endpoints which are very similar to
# some of the documented endpoints.
assert find_openapi_endpoint("/users/me/presence") is None
assert find_openapi_endpoint("/users/me/subscriptions/23") is None
assert find_open... | b0ce4f1bce8031881addecb1e86073483517f392 | 10 | test_openapi.py | 152 | docs: Fix many spelling mistakes.
Signed-off-by: Anders Kaseorg <anders@zulip.com> | 17,641 | 0 | 218 | 75 | 42 | 83,259 | 69 | zulip | 3 | zerver/tests/test_openapi.py | Python | 20 | {
"docstring": "\n Calls a few documented and undocumented endpoints and checks whether they\n find a match or not.\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 16,
"vocab_size": 14
} | https://github.com/zulip/zulip.git | |
27 | compare_total | def compare_total(self, other, context=None):
other = _convert_other(other, raiseit=True)
# if one is negative and the other is positive, it's easy
if self._sign and not other._sign:
return _NegativeOne
if not self._sign and other._sign:
return _One
... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 14 | _pydecimal.py | 391 | add python 3.10.4 for windows | 55,829 | 0 | 999 | 242 | 61 | 219,816 | 183 | XX-Net | 19 | python3.10.4/Lib/_pydecimal.py | Python | 57 | {
"docstring": "Compares self to other using the abstract representations.\n\n This is not like the standard compare, which use their numerical\n value. Note that a total ordering is defined for all possible abstract\n representations.\n ",
"language": "en",
"n_whitespaces": 60,
"n_w... | https://github.com/XX-net/XX-Net.git | |
1 | _override_cmds | def _override_cmds(self) -> None:
self.options.version_cmd[0] = self.options.ctl
self.options.restart_cmd[0] = self.options.ctl
self.options.conftest_cmd[0] = self.options.ctl
self.options.get_modules_cmd[0] = self.options.ctl
self.options.get_includes_cmd[0] = self.opti... | eed1afb8082518a5212a6d8016a4ccf44c5ad99e | 9 | configurator.py | 142 | certbot-apache: use httpd by default for CentOS/RHEL (#9402)
* certbot-apache: use httpd for newer RHEL derived distros
A change in RHEL 9 is causing apachectl to error out when used
with additional arguments, resulting in certbot errors. The CentOS
configurator now uses httpd instead for RHEL 9 (and later) deriv... | 45,657 | 0 | 71 | 92 | 12 | 186,917 | 22 | certbot | 10 | certbot-apache/certbot_apache/_internal/configurator.py | Python | 10 | {
"docstring": "\n Set our various command binaries to whatever the user has overridden for apachectl\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 13
} | https://github.com/certbot/certbot.git | |
5 | _get_files | def _get_files(self, files):
# Older versions of fsspec doesn't support unstrip_protocol(). It
# was only added relatively recently:
# https://github.com/fsspec/filesystem_spec/pull/828 | b240370bf83c88589d293b76b4a2409294e06f90 | 6 | parquet_dispatcher.py | 18 | FEAT-#4733: Support fastparquet as engine for `read_parquet` (#4807)
Signed-off-by: Karthik Velayutham <vkarthik@ponder.io> | 35,881 | 0 | 48 | 81 | 18 | 154,259 | 20 | modin | 3 | modin/core/io/column_stores/parquet_dispatcher.py | Python | 9 | {
"docstring": "\n Retrieve list of formatted file names in dataset path.\n\n Parameters\n ----------\n files : list\n List of files from path.\n\n Returns\n -------\n fs_files : list\n List of files from path with fs-protocol prepended.\n ... | https://github.com/modin-project/modin.git | |
3 | get_wheel_cache_entry | def get_wheel_cache_entry(self, link, name):
# type: (Link, Optional[str]) -> Optional[CacheEntry]
if self._wheel_cache is None or self.preparer.require_hashes:
return None
return self._wheel_cache.get_cache_entry(
link=link,
package_name=name,
... | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | 10 | factory.py | 73 | upd; format | 12,412 | 0 | 103 | 47 | 22 | 61,110 | 24 | transferlearning | 11 | .venv/lib/python3.8/site-packages/pip/_internal/resolution/resolvelib/factory.py | Python | 8 | {
"docstring": "Look up the link in the wheel cache.\n\n If ``preparer.require_hashes`` is True, don't use the wheel cache,\n because cached wheels, always built locally, have different hashes\n than the files downloaded from the index server and thus throw false\n hash mismatches. Further... | https://github.com/jindongwang/transferlearning.git | |
2 | broadcast | async def broadcast(self, data):
for channel in self.channels.values():
await channel.send(data)
| 9f6bba40af1a407f190a89f5c0c8b4e3f528ba46 | 10 | channel.py | 45 | initial concept for replicate, basic leader and follower logic | 34,740 | 0 | 35 | 26 | 10 | 150,418 | 10 | freqtrade | 7 | freqtrade/rpc/replicate/channel.py | Python | 3 | {
"docstring": "\n Broadcast data on all Channels\n\n :param data: The data to send\n ",
"language": "en",
"n_whitespaces": 33,
"n_words": 11,
"vocab_size": 10
} | https://github.com/freqtrade/freqtrade.git | |
4 | _set_concurrent_future_state | def _set_concurrent_future_state(concurrent, source):
assert source.done()
if source.cancelled():
concurrent.cancel()
if not concurrent.set_running_or_notify_cancel():
return
exception = source.exception()
if exception is not None:
concurrent.set_exception(_convert_futur... | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 11 | futures.py | 124 | add python 3.10.4 for windows | 56,029 | 0 | 82 | 72 | 21 | 220,522 | 26 | XX-Net | 12 | python3.10.4/Lib/asyncio/futures.py | Python | 12 | {
"docstring": "Copy state from a future to a concurrent.futures.Future.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 7
} | https://github.com/XX-net/XX-Net.git | |
10 | test_repeated_paginate_relations | def test_repeated_paginate_relations(self):
expected_event_ids = []
for idx in range(10):
channel = self._send_relation(
RelationTypes.ANNOTATION, "m.reaction", chr(ord("a") + idx)
)
self.assertEquals(200, channel.code, channel.json_body)
... | df36945ff0e4a293a9dac0da07e2c94256835b32 | 16 | test_relations.py | 544 | Support pagination tokens from /sync and /messages in the relations API. (#11952) | 71,143 | 0 | 689 | 305 | 66 | 246,308 | 148 | synapse | 33 | tests/rest/client/test_relations.py | Python | 48 | {
"docstring": "Test that if we paginate using a limit and tokens then we get the\n expected events.\n ",
"language": "en",
"n_whitespaces": 30,
"n_words": 16,
"vocab_size": 15
} | https://github.com/matrix-org/synapse.git | |
3 | _delete_composed_index | def _delete_composed_index(self, model, fields, *args):
first_field = model._meta.get_field(fields[0])
if first_field.get_internal_type() == "ForeignKey":
constraint_names = self._constraint_names(
model, [first_field.column], index=True
)
if ... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 15 | schema.py | 145 | Refs #33476 -- Reformatted code with Black. | 50,995 | 0 | 156 | 92 | 26 | 205,011 | 31 | django | 17 | django/db/backends/mysql/schema.py | Python | 11 | {
"docstring": "\n MySQL can remove an implicit FK index on a field when that field is\n covered by another index like a unique_together. \"covered\" here means\n that the more complex index starts like the simpler one.\n https://bugs.mysql.com/bug.php?id=37910 / Django ticket #24757\n ... | https://github.com/django/django.git | |
4 | climate_adc_t3000_missing_fan_mode_states_fixture | def climate_adc_t3000_missing_fan_mode_states_fixture(client, climate_adc_t3000_state):
data = copy.deepcopy(climate_adc_t3000_state)
data["name"] = f"{data['name']} missing fan mode states"
for value in data["values"]:
if (
value["commandClassName"] == "Thermostat Fan Mode"
... | 21aa07e3e58268d6ca1425cd05abcfd847b9872c | @pytest.fixture(name="climate_danfoss_lc_13") | 12 | conftest.py | 165 | Add Z-Wave thermostat fan entity (#65865)
* Add Z-Wave thermostat fan entity
* Fix failing test, increase number of entities to 27
* Add tests to improve coverage
* Take back unrelated changes to climate.py
* Clean up guard clauses, use info.primary_value, and make entity disabled by default
* Fix tests... | 92,724 | 1 | 108 | 80 | 35 | 293,667 | 41 | core | 16 | tests/components/zwave_js/conftest.py | Python | 12 | {
"docstring": "Mock a climate ADC-T3000 node with missing 'states' metadata on Thermostat Fan Mode.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 13
} | https://github.com/home-assistant/core.git |
1 | get_basefile | def get_basefile(self, tex, fontsize, dpi=None):
src = self._get_tex_source(tex, fontsize) + str(dpi)
return os.path.join(
self.texcache, hashlib.md5(src.encode('utf-8')).hexdigest())
| 4ea309aac5b6b638967d19107db297b5c7bde551 | 14 | texmanager.py | 89 | Pick TeX cache name based on entire TeX source.
This allows invalidating the cache when the source generation algorithm
changes. | 23,006 | 0 | 47 | 56 | 15 | 107,997 | 15 | matplotlib | 16 | lib/matplotlib/texmanager.py | Python | 4 | {
"docstring": "\n Return a filename based on a hash of the string, fontsize, and dpi.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 12
} | https://github.com/matplotlib/matplotlib.git | |
2 | get_dict_for_field | def get_dict_for_field(self, field_name):
try:
field = self.model._meta.get_field(field_name)
except FieldDoesNotExist:
field = None
return {
"label": self.get_field_label(field_name, field),
"value": self.get_field_display_value(field_nam... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 12 | views.py | 87 | Reformat with black | 16,009 | 0 | 100 | 53 | 18 | 73,300 | 21 | wagtail | 10 | wagtail/contrib/modeladmin/views.py | Python | 9 | {
"docstring": "\n Return a dictionary containing `label` and `value` values to display\n for a field.\n ",
"language": "en",
"n_whitespaces": 35,
"n_words": 13,
"vocab_size": 12
} | https://github.com/wagtail/wagtail.git | |
6 | _upsample_2d | def _upsample_2d(self, hidden_states, weight=None, kernel=None, factor=2, gain=1):
assert isinstance(factor, int) and factor >= 1
# Setup filter kernel.
if kernel is None:
kernel = [1] * factor
# setup kernel
kernel = torch.tensor(kernel, dtype=torch.float... | a73f8b725105b12a60a9b22918bda68f8b6d26c3 | 18 | resnet.py | 660 | Clean up resnet.py file (#780)
* clean up resnet.py
* make style and quality
* minor formatting | 120,955 | 0 | 759 | 430 | 109 | 337,070 | 220 | diffusers | 39 | src/diffusers/models/resnet.py | Python | 45 | {
"docstring": "Fused `upsample_2d()` followed by `Conv2d()`.\n\n Padding is performed only once at the beginning, not between the operations. The fused op is considerably more\n efficient than performing the same calculation using standard TensorFlow ops. It supports gradients of\n arbitrary ord... | https://github.com/huggingface/diffusers.git | |
6 | _update_lines | def _update_lines(self, lines, new_line):
code_matches = [x for x in re.finditer(_invisible_codes, new_line)]
color_codes = [
code.string[code.span()[0] : code.span()[1]] for code in code_matches
]
# Add color codes from earlier in the unwrapped line, and then track... | adf24bfa9723b0621183bb27f0c889b813c06e8a | 12 | tabulate.py | 186 | [State Observability] Use a table format by default (#26159)
NOTE: tabulate is copied/pasted to the codebase for table formatting.
This PR changes the default layout to be the table format for both summary and list APIs. | 27,807 | 0 | 253 | 115 | 75 | 125,203 | 101 | ray | 18 | python/ray/_private/thirdparty/tabulate/tabulate.py | Python | 14 | {
"docstring": "Adds a new line to the list of lines the text is being wrapped into\n This function will also track any ANSI color codes in this string as well\n as add any colors from previous lines order to preserve the same formatting\n as a single unwrapped string.\n ",
"language": "... | https://github.com/ray-project/ray.git | |
1 | score | def score(self, X, y, **fit_params):
check_is_fitted(self)
return self.estimator_.score(self.transform(X), y, **fit_params)
| 6e5ef2e9b8c64e6788428610ae884b9bf3d298a2 | 9 | _rfe.py | 56 | MAINT solve long line reported by flake8 (#24065) | 76,391 | 0 | 31 | 36 | 9 | 260,641 | 10 | scikit-learn | 8 | sklearn/feature_selection/_rfe.py | Python | 3 | {
"docstring": "Reduce X to the selected features and return the score of the estimator.\n\n Parameters\n ----------\n X : array of shape [n_samples, n_features]\n The input samples.\n\n y : array of shape [n_samples]\n The target values.\n\n **fit_params : dic... | https://github.com/scikit-learn/scikit-learn.git | |
1 | allowlist_svg | def allowlist_svg(dirty_xml):
from lxml.html import clean
allow_tags = [
'xml',
'svg',
'circle',
'ellipse',
'line',
'path',
'polygon',
'polyline',
'rect'
]
cleaner = clean.Cleaner(
... | 53f6308186aa131946e196b0409f3d732ec9e007 | 9 | uploader.py | 126 | fix: DEV-2236: Stored XSS via SVG file (#2273)
* user uploaded content rendered as plain text or known image only
* allow list for svg in progress
* allow list for svg basic pass
* add error handling
* add to file processing re: code review
* rm uneeded code
* add env var to disable svg cleaning
*... | 42,555 | 0 | 231 | 77 | 31 | 177,986 | 34 | label-studio | 16 | label_studio/data_import/uploader.py | Python | 23 | {
"docstring": "Filter out malicious/harmful content from SVG files\n by defining allowed tags\n ",
"language": "en",
"n_whitespaces": 17,
"n_words": 11,
"vocab_size": 11
} | https://github.com/heartexlabs/label-studio.git | |
1 | test_save_periodic_pipeline | def test_save_periodic_pipeline():
tpot_obj = TPOTClassifier(
random_state=42,
population_size=1,
offspring_size=2,
generations=1,
verbosity=0,
config_dict='TPOT light'
)
tpot_obj.fit(training_features, training_target)
with closing(StringIO()) as our... | 388616b6247ca4ea8de4e2f340d6206aee523541 | 12 | tpot_tests.py | 207 | Revert "Deployed 7ccda9a with MkDocs version: 1.3.0"
This reverts commit bd9629c40e01241766197119b581a99409b07068. | 43,518 | 0 | 215 | 126 | 52 | 181,731 | 60 | tpot | 30 | tests/tpot_tests.py | Python | 23 | {
"docstring": "Assert that the _save_periodic_pipeline does not export periodic pipeline if exception happened",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | https://github.com/EpistasisLab/tpot.git | |
2 | tzname | def tzname(self):
if self._tzinfo is None:
return None
name = self._tzinfo.tzname(None)
_check_tzname(name)
return name
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 9 | datetime.py | 53 | add python 3.10.4 for windows | 56,547 | 0 | 60 | 31 | 12 | 222,361 | 14 | XX-Net | 5 | python3.10.4/Lib/datetime.py | Python | 6 | {
"docstring": "Return the timezone name.\n\n Note that the name is 100% informational -- there's no requirement that\n it mean anything in particular. For example, \"GMT\", \"UTC\", \"-500\",\n \"-5:00\", \"EDT\", \"US/Eastern\", \"America/New York\" are all valid replies.\n ",
"languag... | https://github.com/XX-net/XX-Net.git | |
1 | gcn_loss | def gcn_loss(self, gcn_data):
gcn_pred, gt_labels = gcn_data
gt_labels = gt_labels.reshape([-1])
loss = F.cross_entropy(gcn_pred, gt_labels)
return loss
| 1f9400dd7374ce9cc47981372e324ff412e53ba3 | 10 | det_drrg_loss.py | 59 | add drrg | 4,861 | 0 | 51 | 36 | 12 | 25,192 | 16 | PaddleOCR | 9 | ppocr/losses/det_drrg_loss.py | Python | 5 | {
"docstring": "CrossEntropy Loss from gcn module.\n\n Args:\n gcn_data (tuple(Tensor, Tensor)): The first is the\n prediction with shape :math:`(N, 2)` and the\n second is the gt label with shape :math:`(m, n)`\n where :math:`m * n = N`.\n\n Retur... | https://github.com/PaddlePaddle/PaddleOCR.git | |
1 | add_never_cache_headers | def add_never_cache_headers(response):
patch_response_headers(response, cache_timeout=-1)
patch_cache_control(
response, no_cache=True, no_store=True, must_revalidate=True, private=True
)
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 9 | cache.py | 54 | Refs #33476 -- Reformatted code with Black. | 51,571 | 0 | 30 | 35 | 11 | 206,572 | 11 | django | 9 | django/utils/cache.py | Python | 5 | {
"docstring": "\n Add headers to a response to indicate that a page should never be cached.\n ",
"language": "en",
"n_whitespaces": 21,
"n_words": 14,
"vocab_size": 12
} | https://github.com/django/django.git | |
1 | test_n_step_very_short_trajectory | def test_n_step_very_short_trajectory(self):
gamma = 1.0
obs = np.arange(0, 2)
actions = np.random.randint(-100, 300, size=(2,))
check_actions = actions.copy()
rewards = [10.0, 100.0]
next_obs = np.arange(1, 3)
batch = SampleBatch(
{
... | 8e680c483ce326cefc62e44f68ab1a6948b1c3d2 | 11 | test_postprocessing.py | 307 | [RLlib] gymnasium support (new `Env.reset()/step()/seed()/render()` APIs). (#28369) | 31,248 | 0 | 293 | 224 | 57 | 137,797 | 69 | ray | 24 | rllib/evaluation/tests/test_postprocessing.py | Python | 24 | {
"docstring": "Tests, whether n-step also works for very small trajectories.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/ray-project/ray.git | |
6 | _create_index_name | def _create_index_name(self, table_name, column_names, suffix=""):
_, table_name = split_identifier(table_name)
hash_suffix_part = "%s%s" % (
names_digest(table_name, *column_names, length=8),
suffix,
)
max_length = self.connection.ops.max_name_length() o... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 12 | schema.py | 276 | Refs #33476 -- Reformatted code with Black. | 50,980 | 0 | 323 | 163 | 84 | 204,926 | 116 | django | 19 | django/db/backends/base/schema.py | Python | 21 | {
"docstring": "\n Generate a unique name for an index/unique constraint.\n\n The name is divided into 3 parts: the table name, the column names,\n and a unique digest and suffix.\n ",
"language": "en",
"n_whitespaces": 56,
"n_words": 27,
"vocab_size": 22
} | https://github.com/django/django.git | |
3 | approve | def approve(self, user=None, update=True, comment=""):
if self.status != self.STATUS_IN_PROGRESS:
raise PermissionDenied
self.status = self.STATUS_APPROVED
self.finished_at = timezone.now()
self.finished_by = user
self.comment = comment
self.save()
... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 10 | __init__.py | 168 | Reformat with black | 16,117 | 0 | 153 | 105 | 31 | 73,800 | 36 | wagtail | 22 | wagtail/core/models/__init__.py | Python | 15 | {
"docstring": "Approve the task state and update the workflow state",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 7
} | https://github.com/wagtail/wagtail.git | |
1 | minimize | def minimize(self, loss, var_list, grad_loss=None, name=None, tape=None):
grads_and_vars = self._compute_gradients(
loss, var_list=var_list, grad_loss=grad_loss, tape=tape
)
return self.apply_gradients(grads_and_vars, name=name)
| 84afc5193d38057e2e2badf9c889ea87d80d8fbf | 9 | optimizer_v2.py | 76 | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81,417 | 0 | 57 | 53 | 17 | 275,527 | 18 | keras | 10 | keras/optimizers/optimizer_v2/optimizer_v2.py | Python | 5 | {
"docstring": "Minimize `loss` by updating `var_list`.\n\n This method simply computes gradient using `tf.GradientTape` and calls\n `apply_gradients()`. If you want to process the gradient before applying\n then call `tf.GradientTape` and `apply_gradients()` explicitly instead\n of using ... | https://github.com/keras-team/keras.git | |
1 | test_render_config | def test_render_config(tmpdir):
user_config_path = os.path.join(tmpdir, "config.yaml")
input_features = [
number_feature(),
number_feature(),
category_feature(encoder={"vocab_size": 3}),
category_feature(encoder={"vocab_size": 3}),
]
output_features = [category_featu... | 5a25d1f2a914c849cf978573c5993411151bc447 | 13 | test_cli.py | 276 | Added tests for init_config and render_config CLI commands (#2551) | 1,363 | 0 | 162 | 170 | 46 | 8,165 | 65 | ludwig | 29 | tests/integration_tests/test_cli.py | Python | 23 | {
"docstring": "Test rendering a full config from a partial user config.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | https://github.com/ludwig-ai/ludwig.git | |
8 | update_info | def update_info(self, info) -> None:
for key in self._info_fields:
value = getattr(self, key, None)
idx = info.setdefault(self.name, {})
existing_value = idx.get(key)
if key in idx and value is not None and existing_value != value:
# fre... | 7d2f9b8d59908fbf57c6453bc41891efbfe981a6 | 18 | pytables.py | 240 | TYP: some return annotations in pytables.py (#47512) | 39,980 | 0 | 488 | 141 | 61 | 167,373 | 96 | pandas | 21 | pandas/io/pytables.py | Python | 26 | {
"docstring": "\n set/update the info for this indexable with the key/value\n if there is a conflict raise/warn as needed\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 16
} | https://github.com/pandas-dev/pandas.git | |
8 | split_dataset | def split_dataset(items, eval_split_max_size=None, eval_split_size=0.01):
speakers = [item["speaker_name"] for item in items]
is_multi_speaker = len(set(speakers)) > 1
if eval_split_size > 1:
eval_split_size = int(eval_split_size)
else:
if eval_split_max_size:
eval_split... | 1425a023fe4bc6bda8578295aeeeb02af78cc082 | 18 | __init__.py | 347 | Make style and lint | 77,180 | 0 | 324 | 219 | 82 | 262,317 | 118 | TTS | 23 | TTS/tts/datasets/__init__.py | Python | 30 | {
"docstring": "Split a dataset into train and eval. Consider speaker distribution in multi-speaker training.\n\n Args:\n <<<<<<< HEAD\n items (List[List]):\n A list of samples. Each sample is a list of `[audio_path, text, speaker_id]`.\n\n eval_split_max_size (int):\n ... | https://github.com/coqui-ai/TTS.git | |
7 | center | def center(G, e=None, usebounds=False, weight=None):
if usebounds is True and e is None and not G.is_directed():
return _extrema_bounding(G, compute="center", weight=weight)
if e is None:
e = eccentricity(G, weight=weight)
radius = min(e.values())
p = [v for v in e if e[v] == radius... | 28f78cfa9a386620ee1179582fda1db5ffc59f84 | 11 | distance_measures.py | 140 | Add weight distance metrics (#5305)
Adds the weight keyword argument to allow users to compute weighted distance metrics
e.g. diameter, eccentricity, periphery, etc. The kwarg works in the same fashion as the
weight param for shortest paths - i.e. if a string, look up with edge attr by key, if callable,
compute the... | 42,268 | 0 | 76 | 90 | 31 | 177,081 | 44 | networkx | 14 | networkx/algorithms/distance_measures.py | Python | 8 | {
"docstring": "Returns the center of the graph G.\n\n The center is the set of nodes with eccentricity equal to radius.\n\n Parameters\n ----------\n G : NetworkX graph\n A graph\n\n e : eccentricity dictionary, optional\n A precomputed dictionary of eccentricities.\n\n weight : string, ... | https://github.com/networkx/networkx.git | |
37 | infer_concrete_type_builder | def infer_concrete_type_builder(nn_module, share_types=True):
concrete_type_builder = torch._C.ConcreteModuleTypeBuilder(type(nn_module))
if isinstance(nn_module, (torch.nn.ModuleDict)):
concrete_type_builder.set_module_dict()
if isinstance(nn_module, (torch.nn.ModuleList, torch.nn.Sequential))... | 8e6d1738a41cb28c36db3dc5e10fd812417673de | 11 | _recursive.py | 198 | Per-overload torch.ops API (#67254)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/67254
Fixes https://github.com/pytorch/pytorch/issues/65997
TODO: disallow `default` as an overload name for aten operators.
BC breaking:
`output = torch.ops._test.leaky_relu(self=torch.tensor(-1.0))` now fai... | 21,503 | 0 | 108 | 846 | 40 | 102,252 | 54 | pytorch | 25 | torch/jit/_recursive.py | Python | 120 | {
"docstring": "\n Build a ConcreteModuleTypeBuilder from an nn.Module. This\n ConcreteModuleType doesn't have a JIT type associated with it yet, it\n must be filled in by the caller.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 23
} | https://github.com/pytorch/pytorch.git | |
6 | to_undirected | def to_undirected(self, as_view=False):
graph_class = self.to_undirected_class()
if as_view is True:
return nx.graphviews.generic_graph_view(self, graph_class)
# deepcopy when not a view
G = graph_class()
G.graph.update(deepcopy(self.graph))
G.add_nod... | 8f4c99debc9440728c5e85f8bffa5d26b232eb6f | 11 | multigraph.py | 198 | Multigraph docs update (#5389)
* Updated MultiDiGraph documentation to include more examples of actually
using parallel edges, and fixed references to things like G[u, v] where
G[u, v, k] is required for a MultiDigraph. Have not made parallel
changes in MultiGraph which should maybe also be made?
Docs tests pass... | 41,880 | 0 | 178 | 127 | 42 | 176,415 | 53 | networkx | 25 | networkx/classes/multigraph.py | Python | 14 | {
"docstring": "Returns an undirected copy of the graph.\n\n Returns\n -------\n G : Graph/MultiGraph\n A deepcopy of the graph.\n\n See Also\n --------\n copy, add_edge, add_edges_from\n\n Notes\n -----\n This returns a \"deepcopy\" of the edg... | https://github.com/networkx/networkx.git | |
2 | rgb_to_hsv | def rgb_to_hsv(arr):
arr = np.asarray(arr)
# check length of the last dimension, should be _some_ sort of rgb
if arr.shape[-1] != 3:
raise ValueError("Last dimension of input array must be 3; "
"shape {} was found.".format(arr.shape))
in_shape = arr.shape
arr ... | 9b6abd0b4933811e0a45c2535ab8fd107db65dd9 | 13 | colors.py | 452 | DOC: improve grammar and consistency | 24,007 | 0 | 310 | 308 | 95 | 110,265 | 175 | matplotlib | 24 | lib/matplotlib/colors.py | Python | 28 | {
"docstring": "\n Convert float RGB values (in the range [0, 1]), in a numpy array to HSV\n values.\n\n Parameters\n ----------\n arr : (..., 3) array-like\n All values must be in the range [0, 1]\n\n Returns\n -------\n (..., 3) ndarray\n Colors converted to HSV values in range [... | https://github.com/matplotlib/matplotlib.git | |
4 | __len__ | def __len__(self) -> int:
# do a DFS to count the number of leaf nodes
count = 0
stack = [self._data]
while stack:
node = stack.pop()
if isinstance(node, NestedDict):
node = node._data
if isinstance(node, Mapping):
... | c8dbbf374661d89e620b472a8c62aa3ce3c6ce98 | 13 | nested_dict.py | 111 | [RLlib] Introduction of Nested dict for RLModule construction (#29027)
Signed-off-by: Kourosh Hakhamaneshi <kourosh@anyscale.com> | 28,718 | 0 | 173 | 66 | 33 | 128,493 | 42 | ray | 13 | rllib/utils/nested_dict.py | Python | 15 | {
"docstring": "Returns the number of leaf nodes in the `NestedDict` that\n are not of type Mappings.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 15,
"vocab_size": 13
} | https://github.com/ray-project/ray.git | |
2 | generate_mask | def generate_mask(self, h, w, p, shift):
# supporting sqaure.
attn_mask = torch.zeros(h, w, p, p, p, p, dtype=torch.bool, device=self.relative_position_params.device)
if self.type == 'W':
return attn_mask
s = p - shift
attn_mask[-1, :, :s, :, s:, :] = True
... | 8deae077004f0332ca607fc3a5d568b1a4705bec | 11 | scunet_model_arch.py | 217 | Add ScuNET DeNoiser/Upscaler
Q&D Implementation of ScuNET, thanks to our handy model loader. :P
https://github.com/cszn/SCUNet | 35,189 | 0 | 170 | 146 | 48 | 152,620 | 82 | stable-diffusion-webui | 16 | modules/scunet_model_arch.py | Python | 11 | {
"docstring": " generating the mask of SW-MSA\n Args:\n shift: shift parameters in CyclicShift.\n Returns:\n attn_mask: should be (1 1 w p p),\n ",
"language": "en",
"n_whitespaces": 64,
"n_words": 20,
"vocab_size": 20
} | https://github.com/AUTOMATIC1111/stable-diffusion-webui.git | |
2 | setup_tpu | def setup_tpu(tpu_driver_version='tpu_driver-0.2'):
global TPU_DRIVER_MODE
if not TPU_DRIVER_MODE:
colab_tpu_addr = os.environ['COLAB_TPU_ADDR'].split(':')[0]
url = f'http://{colab_tpu_addr}:8475/requestversion/{tpu_driver_version}'
requests.post(url)
TPU_DRIVER_MODE = 1
# The following is re... | 0cc4066bb7bf758a5ba8c5def9c2c32a1c98fb89 | 13 | colab_tpu.py | 125 | Pin default jax.tools.colab_tpu.setup_tpu driver version.
Prior to this change, we were defaulting to the TPU nightly driver
version. We should instead pin to the version associated with the
default jaxlib version that Colab uses. | 27,112 | 0 | 55 | 64 | 32 | 122,164 | 37 | jax | 14 | jax/tools/colab_tpu.py | Python | 9 | {
"docstring": "Sets up Colab to run on TPU.\n\n Note: make sure the Colab Runtime is set to Accelerator: TPU.\n\n Args\n ----\n tpu_driver_version : (str) specify the version identifier for the tpu driver.\n Defaults to \"tpu_driver-0.2\", which can be used with jaxlib 0.3.20. Set to\n \"tpu_driver_nightly... | https://github.com/google/jax.git | |
3 | check_connection | def check_connection(self, logger, config) -> Tuple[bool, any]:
try:
req = requests.get(RkiCovidStream.url_base + "germany")
if req.status_code == 200:
return True, None
return False, req.reason
except Exception:
return False, "The... | d6d52c5d99dd7ebbd966da79c1d890699a947f39 | 12 | source.py | 90 | :tada: New Source: RKI (Robert Koch-Institut) Covid Public API (#11732)
* Added source for RKI-covid-germany, updated spec.json, implemented source with check and discover method added germany.json.
* implemented incremental method for germany history cases with date as parameters, updated streams, added cursor fi... | 770 | 0 | 115 | 55 | 32 | 5,421 | 35 | airbyte | 15 | airbyte-integrations/connectors/source-rki-covid/source_rki_covid/source.py | Python | 15 | {
"docstring": "\n Testing connection availability for the connector.\n\n :param config: the user-input config object conforming to the connector's spec.json\n :param logger: logger object\n :return Tuple[bool, any]: (True, None) if the input config can be used to connect to the API succ... | https://github.com/airbytehq/airbyte.git | |
2 | get_heading | def get_heading(self, queryset, field):
heading_override = self.export_headings.get(field)
if heading_override:
return force_str(heading_override)
return force_str(
label_for_field(
field, model=self.model, model_admin=self.model_admin
... | d10f15e55806c6944827d801cd9c2d53f5da4186 | 13 | views.py | 82 | Reformat with black | 16,007 | 0 | 102 | 52 | 18 | 73,294 | 19 | wagtail | 12 | wagtail/contrib/modeladmin/views.py | Python | 9 | {
"docstring": "Get headings for exported spreadsheet column for the relevant field",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | https://github.com/wagtail/wagtail.git | |
2 | _nannumel_sparse | def _nannumel_sparse(x, **kwargs):
n = _nannumel(x, **kwargs)
# If all dimensions are contracted, this will just be a number, otherwise we
# want to densify it.
return n.todense() if hasattr(n, "todense") else n
| 8b95f983c232c1bd628e9cba0695d3ef229d290b | 9 | backends.py | 57 | Sparse array reductions (#9342) | 36,793 | 0 | 48 | 33 | 31 | 156,874 | 33 | dask | 7 | dask/array/backends.py | Python | 3 | {
"docstring": "\n A reduction to count the number of elements in a sparse array, excluding nans.\n This will in general result in a dense matrix with an unpredictable fill value.\n So make it official and convert it to dense.\n\n https://github.com/dask/dask/issues/7169\n ",
"language": "en",
"n_w... | https://github.com/dask/dask.git | |
1 | _new_step | def _new_step(self):
self.should_save = False
self.should_evaluate = False
self.should_log = False
| 44a290e94d1becd1f09fddc3d873f9e19c9d6919 | 7 | trainer_callback.py | 37 | [Trainer] Add init version of paddlenlp trainer and apply finetune for ernie-1.0 pretraining. (#1761)
* add some datasets for finetune.
* support fine tune for all tastks.
* add trainer prototype.
* init verison for paddlenlp trainer.
* refine trainer.
* update for some details.
* support multi-card... | 118,389 | 0 | 39 | 21 | 7 | 323,153 | 11 | PaddleNLP | 5 | paddlenlp/trainer/trainer_callback.py | Python | 4 | {
"docstring": "Internal method that resets the variable for a new step.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/PaddlePaddle/PaddleNLP.git | |
7 | shuffle_group | def shuffle_group(df, cols, stage, k, npartitions, ignore_index, nfinal):
if isinstance(cols, str):
cols = [cols]
if cols and cols[0] == "_partitions":
ind = df[cols[0]]
else:
ind = hash_object_dispatch(df[cols] if cols else df, index=False)
if nfinal and nfinal != npar... | 510bbc380531cbf56a409f1ae68e6fd84a9599e6 | @contextlib.contextmanager | 14 | shuffle.py | 240 | Update `pre-commit` version (#8691) | 36,457 | 1 | 136 | 157 | 47 | 155,752 | 68 | dask | 27 | dask/dataframe/shuffle.py | Python | 15 | {
"docstring": "Splits dataframe into groups\n\n The group is determined by their final partition, and which stage we are in\n in the shuffle\n\n Parameters\n ----------\n df: DataFrame\n cols: str or list\n Column name(s) on which to split the dataframe. If ``cols`` is not\n \"_partit... | https://github.com/dask/dask.git |
8 | unifi_dict | def unifi_dict(self) -> dict[str, Any]:
return {
"nvr": self.nvr.unifi_dict(),
"cameras": [c.unifi_dict() for c in self.cameras.values()],
"lights": [c.unifi_dict() for c in self.lights.values()],
"sensors": [c.unifi_dict() for c in self.sensors.values()]... | 654c59c19414c52f95f56603c460f63edeb60959 | @dataclass | 12 | conftest.py | 272 | Add diagnostics for UniFi Protect (#72280) | 99,995 | 1 | 161 | 166 | 29 | 301,147 | 53 | core | 16 | tests/components/unifiprotect/conftest.py | Python | 12 | {
"docstring": "Return UniFi formatted dict representation of the NVR.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | https://github.com/home-assistant/core.git |
4 | get_attendance_list | def get_attendance_list(from_date, to_date, student_group, students_list):
attendance_list = frappe.db.sql(
,
(student_group, from_date, to_date),
as_dict=1,
)
att_map = {}
students_with_leave_application = get_students_with_leave_application(
from_date, to_date, students_list
)
for d in attendance_list:... | 494bd9ef78313436f0424b918f200dab8fc7c20b | 14 | student_monthly_attendance_sheet.py | 215 | style: format code with black | 14,067 | 0 | 34 | 143 | 39 | 65,948 | 54 | erpnext | 21 | erpnext/education/report/student_monthly_attendance_sheet/student_monthly_attendance_sheet.py | Python | 24 | {
"docstring": "select student, date, status\n\t\tfrom `tabStudent Attendance` where student_group = %s\n\t\tand docstatus = 1\n\t\tand date between %s and %s\n\t\torder by student, date",
"language": "en",
"n_whitespaces": 20,
"n_words": 25,
"vocab_size": 18
} | https://github.com/frappe/erpnext.git | |
5 | update_static | def update_static():
config = Config()
logger = get_log('http')
static_path = Path(config['paths']['static'])
last_gui_version_lv = get_last_compatible_gui_version()
current_gui_version_lv = get_current_gui_version()
if last_gui_version_lv is False:
return False
if current_gu... | 9ce5a21dd6359fd7e8ebf78051ce9e97bd195ec9 | 11 | initialize.py | 286 | ML handler supbrocess (#3377)
* log -> logger
dividing components:
app initialize
parse args
set env.MINDSDB_CONFIG_PATH
config
requiers env.MINDSDB_CONFIG_PATH
sets
env.MINDSDB_DB_CON
Config() - makes initialization
log
uses config
initialize_log - makes initial... | 25,952 | 0 | 171 | 160 | 47 | 117,309 | 72 | mindsdb | 24 | mindsdb/api/http/initialize.py | Python | 25 | {
"docstring": " Update Scout files basing on compatible-config.json content.\n Files will be downloaded and updated if new version of GUI > current.\n Current GUI version stored in static/version.txt.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 26,
"vocab_size": 24
} | https://github.com/mindsdb/mindsdb.git | |
1 | test_stream_admin_remove_others_from_public_stream | def test_stream_admin_remove_others_from_public_stream(self) -> None:
result = self.attempt_unsubscribe_of_principal(
query_count=15,
target_users=[self.example_user("cordelia")],
is_realm_admin=False,
is_stream_admin=True,
is_subbed=True,
... | 803982e87254e3b1ebcb16ed795e224afceea3a3 | 13 | test_subs.py | 125 | message_flags: Short-circuit if no messages changed.
Omit sending an event, and updating the database, if there are no
matching messages. | 17,733 | 0 | 141 | 80 | 21 | 83,840 | 22 | zulip | 15 | zerver/tests/test_subs.py | Python | 16 | {
"docstring": "\n You can remove others from public streams you're a stream administrator of.\n ",
"language": "en",
"n_whitespaces": 27,
"n_words": 12,
"vocab_size": 12
} | https://github.com/zulip/zulip.git | |
2 | test_conversation_part_has_conversation_id | def test_conversation_part_has_conversation_id(requests_mock):
response_body = {
"type": "conversation",
"id": "151272900024304",
"created_at": 1647365706,
"updated_at": 1647366443,
"conversation_parts": {
"type": "conversation_part.list",
"conve... | 787daa9961b6b103e8d520c544277fc77c191dfb | 14 | unit_test.py | 233 | 🎉 Source Intercom: Added conversation_id field to conversation_part records (#11206) | 666 | 0 | 217 | 126 | 46 | 4,470 | 60 | airbyte | 17 | airbyte-integrations/connectors/source-intercom/unit_tests/unit_test.py | Python | 23 | {
"docstring": "\n Test shows that conversation_part records include the `conversation_id` field.\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 9,
"vocab_size": 9
} | https://github.com/airbytehq/airbyte.git | |
9 | flatten | def flatten(data, levels=None, preserve_nulls=False, _ids=None):
if _ids is None:
_ids = set()
if id(data) in _ids:
raise RecursionError("Reference cycle detected. Check input list.")
_ids.add(id(data))
ret = []
for element in data:
if not preserve_nulls and element in... | ec41b56baee98ade5e6e21083645da1ec21c4b86 | 22 | data.py | 249 | detect reference cycles in flatten function | 54,379 | 0 | 409 | 154 | 64 | 216,076 | 82 | salt | 15 | salt/utils/data.py | Python | 27 | {
"docstring": "\n .. versionadded:: 3005\n\n Flatten a list.\n\n :param data: A list to flatten\n\n :param levels: The number of levels in sub-lists to descend\n\n :param preserve_nulls: Preserve nulls in a list, by default flatten removes\n them\n\n :param _ids: Parameter... | https://github.com/saltstack/salt.git | |
9 | training_iteration | def training_iteration(self) -> ResultDict:
# Some shortcuts.
batch_size = self.config["train_batch_size"]
# Collects SampleBatches in parallel and synchronously
# from the Trainer's RolloutWorkers until we hit the
# configured `train_batch_size`.
sample_batches... | 853d10871c55cb741cb15212ef4ab42f158f968c | 13 | trainer.py | 261 | [RLlib] Issue 18499: PGTrainer with training_iteration fn does not support multi-GPU. (#21376) | 28,878 | 0 | 399 | 158 | 97 | 129,027 | 140 | ray | 28 | rllib/agents/trainer.py | Python | 35 | {
"docstring": "Default single iteration logic of an algorithm.\n\n - Collect on-policy samples (SampleBatches) in parallel using the\n Trainer's RolloutWorkers (@ray.remote).\n - Concatenate collected SampleBatches into one train batch.\n - Note that we may have more than one policy in ... | https://github.com/ray-project/ray.git | |
5 | get_model | def get_model(self, app_label, model_name=None, require_ready=True):
if require_ready:
self.check_models_ready()
else:
self.check_apps_ready()
if model_name is None:
app_label, model_name = app_label.split(".")
app_config = self.get_app_conf... | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 11 | registry.py | 132 | Refs #33476 -- Reformatted code with Black. | 50,292 | 0 | 125 | 80 | 25 | 203,306 | 32 | django | 12 | django/apps/registry.py | Python | 11 | {
"docstring": "\n Return the model matching the given app_label and model_name.\n\n As a shortcut, app_label may be in the form <app_label>.<model_name>.\n\n model_name is case-insensitive.\n\n Raise LookupError if no application exists with this label, or no\n model exists with th... | https://github.com/django/django.git | |
20 | handle_groupme | def handle_groupme(request) -> bool:
req = json.loads(request.decode("utf-8"))
text = req.get("text").strip().lower()
group_id = req.get("group_id").strip()
if text[0] == "!":
cmd = text[1:]
full_cmd = cmd.split("/")
group = full_cmd[0].split("-")[0]
parents = {x.s... | b8b3b49896b7553c8ad57e0f3fbb4464ecf24179 | 22 | run_groupme.py | 703 | Groupme Bot (#1418)
* Added groupme helpers
* Began handling of user input
* Expanded commands, improved bot
* Completed dictionary
* Eliminated redundancies
* Added more
* Added debuggers for server
* Fixed bugs
* Improved input handling and image sending
* Fixed dd-est
* Fixed dd comman... | 84,275 | 0 | 941 | 428 | 108 | 282,723 | 187 | OpenBBTerminal | 46 | bots/groupme/run_groupme.py | Python | 62 | {
"docstring": "Handles groupme bot inputs\n\n Parameters\n ----------\n request : Request\n The request object provided by FASTAPI\n\n Returns\n ----------\n success : bool\n Whether the response was sent successfully\n ",
"language": "en",
"n_whitespaces": 61,
"n_words": 26,... | https://github.com/OpenBB-finance/OpenBBTerminal.git | |
3 | _fill | def _fill(strings, linelen=75):
currpos = 0
lasti = 0
result = []
for i, s in enumerate(strings):
length = len(s)
if currpos + length < linelen:
currpos += length + 1
else:
result.append(b' '.join(strings[lasti:i]))
lasti = i
c... | ec410abbb3a721e31f3aaa61e9e4f941467e35e1 | 16 | backend_pdf.py | 181 | Deprecate functions in backends | 23,073 | 0 | 189 | 97 | 80 | 108,136 | 110 | matplotlib | 16 | lib/matplotlib/backends/backend_pdf.py | Python | 14 | {
"docstring": "\n Make one string from sequence of strings, with whitespace in between.\n\n The whitespace is chosen to form lines of at most *linelen* characters,\n if possible.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 25,
"vocab_size": 23
} | https://github.com/matplotlib/matplotlib.git | |
1 | plextv_resources_fixture | def plextv_resources_fixture():
return load_fixture("plex/plextv_resources_one_server.xml")
@pytest.fixture(name="plextv_resources_two_servers", scope="session") | 10195dc700770cdfdeaff79c53cf5d1d763f20c6 | @pytest.fixture(name="plextv_resources_two_servers", scope="session") | 8 | conftest.py | 46 | Improve server selection for Plex config flows (#63408) | 107,537 | 1 | 11 | 10 | 6 | 308,799 | 6 | core | 6 | tests/components/plex/conftest.py | Python | 2 | {
"docstring": "Load single-server payload for plex.tv resources and return it.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | https://github.com/home-assistant/core.git |
2 | test_timeout_does_not_wait_for_completion_for_sync_flows | def test_timeout_does_not_wait_for_completion_for_sync_flows(self, tmp_path):
if sys.version_info[1] == 11:
pytest.xfail("The engine returns _after_ sleep finishes in Python 3.11")
canary_file = tmp_path / "canary"
| a7bd9cadd5038383449b0e75a87bb23a73b278d8 | 10 | test_flows.py | 52 | Add support for Python 3.11 (#7304)
Co-authored-by: Chris Guidry <chris.g@prefect.io> | 11,913 | 0 | 53 | 96 | 21 | 59,586 | 21 | prefect | 8 | tests/test_flows.py | Python | 14 | {
"docstring": "\n Sync flows are cancelled when they change instructions. The flow will return\n immediately when the timeout is reached, but the thread it executes in will\n continue until the next instruction is reached. `time.sleep` will return then\n the thread will be interrupted.\n ... | https://github.com/PrefectHQ/prefect.git | |
2 | inertia | def inertia(self):
if self.is_rigidbody:
return RigidBody.inertia.fget(self)
return (self.central_inertia, self.masscenter)
| f0ccc88c86f77f1c3e13d590d4506e49c8cb2a12 | 10 | body.py | 49 | Add property docstrings | 49,282 | 0 | 41 | 30 | 8 | 199,560 | 9 | sympy | 7 | sympy/physics/mechanics/body.py | Python | 4 | {
"docstring": "The body's inertia about a point; stored as (Dyadic, Point).",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/sympy/sympy.git | |
1 | test_event_ref | def test_event_ref(self):
# Reset the event cache
self.store._get_event_cache.clear()
with LoggingContext("test") as ctx:
# We keep hold of the event event though we never use it.
event = self.get_success(self.store.get_event(self.event_id)) # noqa: F841
... | fcf951d5dc7ca8c4cb18aa9c1f5ccb005df3610a | 13 | test_events_worker.py | 181 | Track in memory events using weakrefs (#10533) | 72,209 | 0 | 211 | 100 | 40 | 248,311 | 73 | synapse | 14 | tests/storage/databases/main/test_events_worker.py | Python | 9 | {
"docstring": "Test that we reuse events that are still in memory but have fallen\n out of the cache, rather than requesting them from the DB.\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 24,
"vocab_size": 22
} | https://github.com/matrix-org/synapse.git | |
8 | _load_specials | def _load_specials(self, *args, **kwargs):
super(KeyedVectors, self)._load_specials(*args, **kwargs)
if hasattr(self, 'doctags'):
self._upconvert_old_d2vkv()
# fixup rename/consolidation into index_to_key of older index2word, index2entity
if not hasattr(self, 'index_... | 766b9e19585968d011649b53057fba3663eff551 | 13 | keyedvectors.py | 286 | Ensure next_index available when loading old stored KeyedVectors models (#3117)
* fix #3114: ensure next_index available
* rm trailing whitespace | 1,665 | 0 | 299 | 166 | 66 | 9,736 | 106 | gensim | 19 | gensim/models/keyedvectors.py | Python | 17 | {
"docstring": "Handle special requirements of `.load()` protocol, usually up-converting older versions.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | https://github.com/RaRe-Technologies/gensim.git | |
1 | simple_test | def simple_test(self, feats, img_metas, rescale=False):
outs = self.forward(feats)
results_list = self.get_results(
*outs, img_metas=img_metas, rescale=rescale)
return results_list
| 9c5b3331ac8edbfa328922fbab45c382380da540 | 9 | base_dense_head.py | 63 | Simplify api of one-stage detector | 70,350 | 0 | 55 | 41 | 14 | 244,361 | 16 | mmdetection | 9 | mmdet/models/dense_heads/base_dense_head.py | Python | 5 | {
"docstring": "Test function without test-time augmentation.\n\n Args:\n feats (tuple[torch.Tensor]): Multi-level features from the\n upstream network, each is a 4D-tensor.\n img_metas (list[dict]): List of image information.\n rescale (bool, optional): Whether ... | https://github.com/open-mmlab/mmdetection.git | |
3 | test_http_server_aborts | def test_http_server_aborts(tctx, stream):
server = Placeholder(Server)
flow = Placeholder(HTTPFlow)
playbook = Playbook(http.HttpLayer(tctx, HTTPMode.regular))
| 372a632161dee642d81542069507826e34466ba1 | 11 | test_http.py | 58 | reintroduce `Flow.live`
We previously relied on the state of `Flow.reply` to check if a flow can be killed,
but this doesn't work anymore with `Flow.reply` being removed. Instead, we now
reintroduce the `Flow.live` attribute, which signals if we are on a live connection.
Killing still is not ideal (see comment in `Flo... | 73,522 | 0 | 25 | 277 | 11 | 250,618 | 13 | mitmproxy | 14 | test/mitmproxy/proxy/layers/http/test_http.py | Python | 58 | {
"docstring": "Test handling of the case where a server aborts during response transmission.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 12
} | https://github.com/mitmproxy/mitmproxy.git |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.