complexity int64 1 56 | n_identifiers int64 1 114 | code stringlengths 19 12.7k | path stringlengths 8 134 | n_ast_nodes int64 12 2.35k | ast_errors stringlengths 0 4.01k | repo stringlengths 3 28 | documentation dict | n_words int64 2 866 | language stringclasses 1
value | vocab_size int64 2 323 | commit_id stringlengths 40 40 | file_name stringlengths 5 79 | id int64 243 338k | nloc int64 1 228 | token_counts int64 5 1.4k | fun_name stringlengths 1 77 | url stringlengths 31 60 | commit_message stringlengths 3 15.3k | n_whitespaces int64 1 3.23k | n_ast_errors int64 0 20 | d_id int64 74 121k | ast_levels int64 4 29 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 20 | def paths(self, request, pk):
obj = get_object_or_404(self.queryset, pk=pk)
cablepaths = CablePath.objects.filter(_nodes__contains=obj).prefetch_related('origin', 'destination')
serializer = serializers.CablePathSerializer(cablepaths, context={'request': request}, many=True)
re... | netbox/dcim/api/views.py | 113 | netbox | {
"docstring": "\n Return all CablePaths which traverse a given pass-through port.\n ",
"language": "en",
"n_whitespaces": 24,
"n_words": 9,
"vocab_size": 9
} | 24 | Python | 20 | 3a461d02793e6f9d41c2b1a92647e691de1abaac | views.py | 264,877 | 5 | 68 | paths | https://github.com/netbox-community/netbox.git | Update Cable instantiations to match new signature | 56 | 0 | 77,892 | 12 | |
1 | 19 | def test_read_only_buffer():
rng = np.random.RandomState(0)
clf = ElasticNet(alpha=0.1, copy_X=True, random_state=rng)
X = np.asfortranarray(rng.uniform(size=(100, 10)))
X.setflags(write=False)
y = rng.rand(100)
clf.fit(X, y)
| sklearn/linear_model/tests/test_coordinate_descent.py | 118 | scikit-learn | {
"docstring": "Test that sparse coordinate descent works for read-only buffers",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 20 | Python | 17 | 3bb4bad1425ee7add6001a32f0d83cb459ffa30c | test_coordinate_descent.py | 260,476 | 7 | 76 | test_read_only_buffer | https://github.com/scikit-learn/scikit-learn.git | MNT Replaced `np.ndarray` with memview where applicable in `linear_model/_cd_fast.pyx` (#23147)
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | 41 | 0 | 76,274 | 12 | |
3 | 20 | def test_cases(self) -> Dict[str, Type[unittest.TestCase]]:
test_cases = {}
for category, items_map in self._filtered_test_items.items():
test_case_name = str('OnnxBackend{}Test').format(category)
test_case = self._get_test_case(test_case_name)
for name, item... | onnx/backend/test/runner/__init__.py | 137 | onnx | {
"docstring": "\n List of test cases to be applied on the parent scope\n Example usage:\n globals().update(BackendTest(backend).test_cases)\n ",
"language": "en",
"n_whitespaces": 47,
"n_words": 14,
"vocab_size": 14
} | 32 | Python | 24 | 83fa57c74edfd13ddac9548b8a12f9e3e2ed05bd | __init__.py | 255,147 | 14 | 86 | test_cases | https://github.com/onnx/onnx.git | Use Python type annotations rather than comments (#3962)
* These have been supported since Python 3.5.
ONNX doesn't support Python < 3.6, so we can use the annotations.
Diffs generated by https://pypi.org/project/com2ann/.
Signed-off-by: Gary Miguel <garymiguel@microsoft.com>
* Remove MYPY conditional logi... | 119 | 0 | 74,735 | 13 | |
1 | 5 | def _may_have_unstable_default(self) -> bool:
return callable(self._default)
| bokeh/core/property/bases.py | 27 | bokeh | {
"docstring": " False if we have a default that is immutable, and will be the\n same every time (some defaults are generated on demand by a function\n to be called).\n\n ",
"language": "en",
"n_whitespaces": 50,
"n_words": 28,
"vocab_size": 26
} | 6 | Python | 6 | 1b3e6acd6eebd352106cc5ecf5e12dbf90e0607c | bases.py | 212,147 | 7 | 15 | _may_have_unstable_default | https://github.com/bokeh/bokeh.git | Add Init signatures to Bokeh models (#12035)
* Add signatures to Bokeh Model initializers
* use explicit type for override default
* move InstanceDefault to bokeh.core.properties
* enable assertions | 20 | 0 | 53,177 | 8 | |
6 | 17 | def __call__(self, bboxes1, bboxes2, mode='iou', is_aligned=False):
bboxes1 = get_box_tensor(bboxes1)
bboxes2 = get_box_tensor(bboxes2)
assert bboxes1.size(-1) in [0, 4, 5]
assert bboxes2.size(-1) in [0, 4, 5]
if bboxes2.size(-1) == 5:
bboxes2 = bboxes2[..., ... | mmdet/models/task_modules/assigners/iou2d_calculator.py | 279 | mmdetection | {
"docstring": "Calculate IoU between 2D bboxes.\n\n Args:\n bboxes1 (Tensor or :obj:`BaseBoxes`): bboxes have shape (m, 4)\n in <x1, y1, x2, y2> format, or shape (m, 5) in <x1, y1, x2,\n y2, score> format.\n bboxes2 (Tensor or :obj:`BaseBoxes`): bboxes have ... | 94 | Python | 54 | d915740fa8228cf57741b27d9e5d66e358456b8e | iou2d_calculator.py | 245,712 | 17 | 183 | __call__ | https://github.com/open-mmlab/mmdetection.git | [Refactor] Refactor anchor head and base head with boxlist (#8625)
* Refactor anchor head
* Update
* Update
* Update
* Add a series of boxes tools
* Fix box type to support n x box_dim boxes
* revert box type changes
* Add docstring
* refactor retina_head
* Update
* Update
* Fix commen... | 275 | 0 | 70,858 | 12 | |
4 | 11 | def to_key_val_list(value):
if value is None:
return None
if isinstance(value, (str, bytes, bool, int)):
raise ValueError("cannot encode objects that are not 2-tuples")
if isinstance(value, Mapping):
value = value.items()
return list(value)
# From mitsuhiko/werkzeug (us... | pipenv/patched/pip/_vendor/requests/utils.py | 88 | pipenv | {
"docstring": "Take an object and test to see if it can be represented as a\n dictionary. If it can be, return a list of tuples, e.g.,\n\n ::\n\n >>> to_key_val_list([('key', 'val')])\n [('key', 'val')]\n >>> to_key_val_list({'key': 'val'})\n [('key', 'val')]\n >>> to_key_val... | 36 | Python | 31 | cd5a9683be69c86c8f3adcd13385a9bc5db198ec | utils.py | 22,153 | 8 | 54 | to_key_val_list | https://github.com/pypa/pipenv.git | Rename notpip to pip. Vendor in pip-22.2.1 and latest requirementslib and vistir. | 71 | 0 | 4,224 | 10 | |
2 | 11 | def _set_gradient_checkpointing(self, module, value=False):
if isinstance(module, ViltEncoder):
module.gradient_checkpointing = value
VILT_START_DOCSTRING = r
VILT_INPUTS_DOCSTRING = r
VILT_IMAGES_AND_TEXT_CLASSIFICATION_INPUTS_DOCSTRING = r
@add_start_docstrings(
"The bare ViLT Model tran... | src/transformers/models/vilt/modeling_vilt.py | 71 | @add_start_docstrings(
"The bare ViLT Model transformer outputting raw hidden-states without any specific head on top.",
VILT_START_DOCSTRING,
) | transformers | {
"docstring": "\n This model is a PyTorch `torch.nn.Module <https://pytorch.org/docs/stable/nn.html#torch.nn.Module>`_ subclass. Use\n it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n behavior.\n\n Parameters:\n config ([`ViltConfi... | 36 | Python | 31 | ac227093e41cecb07c7e0f2fc9a504850907bd06 | modeling_vilt.py | 34,307 | 3 | 24 | _set_gradient_checkpointing | https://github.com/huggingface/transformers.git | Add ViLT (#14895)
* First commit
* Add conversion script
* Make conversion script work for base model
* More improvements
* Update conversion script, works for vqa
* Add indexing argument to meshgrid
* Make conversion script work for ViltForPreTraining
* Add ViltForPreTraining to docs
* Fix dev... | 54 | 1 | 6,254 | 9 |
1 | 7 | def expunge(self):
name = 'EXPUNGE'
typ, dat = self._simple_command(name)
return self._untagged_response(typ, dat, name)
| python3.10.4/Lib/imaplib.py | 51 | XX-Net | {
"docstring": "Permanently remove deleted items from selected mailbox.\n\n Generates 'EXPUNGE' response for each deleted message.\n\n (typ, [data]) = <instance>.expunge()\n\n 'data' is list of 'EXPUNGE'd message numbers in order received.\n ",
"language": "en",
"n_whitespaces": 56,
... | 13 | Python | 12 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | imaplib.py | 217,981 | 4 | 30 | expunge | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 41 | 0 | 55,053 | 8 | |
3 | 15 | def test_next_dagrun_after_auto_align(self):
dag = DAG(
dag_id='test_scheduler_auto_align_1',
start_date=timezone.datetime(2016, 1, 1, 10, 10, 0),
schedule_interval="4 5 * * *",
)
EmptyOperator(task_id='dummy', dag=dag, owner='airflow')
next_... | tests/models/test_dag.py | 235 | airflow | {
"docstring": "\n Test if the schedule_interval will be auto aligned with the start_date\n such that if the start_date coincides with the schedule the first\n execution_date will be start_date, otherwise it will be start_date +\n interval.\n ",
"language": "en",
"n_whitespaces"... | 66 | Python | 32 | 49e336ae0302b386a2f47269a6d13988382d975f | test_dag.py | 47,565 | 17 | 156 | test_next_dagrun_after_auto_align | https://github.com/apache/airflow.git | Replace usage of `DummyOperator` with `EmptyOperator` (#22974)
* Replace usage of `DummyOperator` with `EmptyOperator` | 209 | 0 | 9,160 | 11 | |
1 | 2 | def tickwidth(self):
return self["tickwidth"]
| packages/python/plotly/plotly/graph_objs/_ohlc.py | 22 | plotly.py | {
"docstring": "\n Sets the width of the open/close tick marks relative to the \"x\"\n minimal interval.\n\n The 'tickwidth' property is a number and may be specified as:\n - An int or float in the interval [0, 0.5]\n\n Returns\n -------\n int|float\n ",
"la... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _ohlc.py | 227,484 | 2 | 11 | tickwidth | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 59,157 | 7 | |
1 | 5 | def median_approximate(self, method="default"):
return self.quantile(q=0.5, method=method)
| dask/dataframe/core.py | 39 | dask | {
"docstring": "Return the approximate median of the values over the requested axis.\n\n Parameters\n ----------\n method : {'default', 'tdigest', 'dask'}, optional\n What method to use. By default will use Dask's internal custom\n algorithm (``\"dask\"``). If set to ``\"td... | 6 | Python | 6 | 142de2608df2494bf11e08038aadddb544b4500c | core.py | 156,986 | 2 | 25 | median_approximate | https://github.com/dask/dask.git | Add `DataFrame` and `Series` `median` method (#9483) | 20 | 0 | 36,823 | 8 | |
1 | 15 | def add_metadata_summerizer():
docs = [
Document(
content=,
meta={
"sub_content": "Pegasus Example",
"topic": "California's Electricity",
"context": "Dummy - PG&E stated it scheduled the blackouts in response to forecasts for high winds... | test/nodes/test_summarizer.py | 273 | haystack | {
"docstring": "PG&E stated it scheduled the blackouts in response to forecasts for high winds amid dry conditions. The aim is to reduce the risk of wildfires. Nearly 800 thousand customers were scheduled to be affected by the shutoffs which were expected to last through at least midday tomorrow.The tower is 324 metr... | 122 | Python | 88 | 4d8f40425bc4e7346359b7609720a50ac10b8af9 | test_summarizer.py | 257,543 | 27 | 162 | add_metadata_summerizer | https://github.com/deepset-ai/haystack.git | Passing the meta-data in the summerizer response (#2179)
* Passing the all the meta-data in the summerizer
* Disable metadata forwarding if `generate_single_summary` is `True`
* Update Documentation & Code Style
* simplify tests
* Update Documentation & Code Style
Co-authored-by: github-actions[bot] <41... | 304 | 0 | 75,094 | 13 | |
2 | 14 | def dump_full(self) -> None:
styles = {}
if term.supports_colors(sys.stdout.fileno()):
styles[self] = term.Style16(color='magenta', bold=True)
print(self.root.pdebugformat(styles=styles))
| edb/ir/scopetree.py | 94 | edgedb | {
"docstring": "Do a debug dump of the root but hilight the current node.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | 14 | Python | 13 | e59a77b36afa41b93518b8bc4128e6e90da08fda | scopetree.py | 176,140 | 6 | 56 | dump_full | https://github.com/edgedb/edgedb.git | Add a scopetree method to dump the root but to highlight the current node (#3330) | 53 | 0 | 41,716 | 12 | |
1 | 8 | def local_devices_fixture():
return json.loads(load_fixture("awair/local_devices.json"))
@pytest.fixture(name="gen1_data", scope="session") | tests/components/awair/conftest.py | 54 | @pytest.fixture(name="gen1_data", scope="session") | core | {
"docstring": "Fixture representing devices returned by Awair local API.",
"language": "en",
"n_whitespaces": 7,
"n_words": 8,
"vocab_size": 8
} | 6 | Python | 6 | ebbff7b60e43f17d65ead811d314602b9daddfc4 | conftest.py | 303,763 | 2 | 15 | local_devices_fixture | https://github.com/home-assistant/core.git | Add Awair Local API support (#75535) | 11 | 1 | 102,572 | 10 |
1 | 2 | def root(self):
return self["root"]
| packages/python/plotly/plotly/graph_objs/_icicle.py | 22 | plotly.py | {
"docstring": "\n The 'root' property is an instance of Root\n that may be specified as:\n - An instance of :class:`plotly.graph_objs.icicle.Root`\n - A dict of string/value properties that will be passed\n to the Root constructor\n\n Supported dict properties:\n... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _icicle.py | 227,179 | 2 | 11 | root | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,852 | 7 | |
1 | 31 | def test_stream_slices_no_state_close_to_now(self, api, async_manager_mock, recent_start_date):
start_date = recent_start_date
end_date = pendulum.now()
stream = AdsInsights(api=api, start_date=start_date, end_date=end_date)
async_manager_mock.completed_jobs.return_value = [1, 2... | airbyte-integrations/connectors/source-facebook-marketing/unit_tests/test_base_insight_streams.py | 259 | airbyte | {
"docstring": "Stream will use start_date when there is not state and start_date within 28d from now",
"language": "en",
"n_whitespaces": 14,
"n_words": 15,
"vocab_size": 14
} | 60 | Python | 44 | a3aae8017a0a40ff2006e2567f71dccb04c997a5 | test_base_insight_streams.py | 3,829 | 13 | 165 | test_stream_slices_no_state_close_to_now | https://github.com/airbytehq/airbyte.git | 🎉 🎉 Source FB Marketing: performance and reliability fixes (#9805)
* Facebook Marketing performance improvement
* add comments and little refactoring
* fix integration tests with the new config
* improve job status handling, limit concurrency to 10
* fix campaign jobs, refactor manager
* big refactori... | 151 | 0 | 574 | 12 | |
2 | 19 | def execute():
frappe.reload_doc("stock", "doctype", "purchase_receipt")
frappe.reload_doc("stock", "doctype", "purchase_receipt_item")
frappe.reload_doc("stock", "doctype", "delivery_note")
frappe.reload_doc("stock", "doctype", "delivery_note_item")
frappe.reload_doc("stock", "doctype", "stock_settings")
def up... | erpnext/patches/v13_0/update_returned_qty_in_pr_dn.py | 297 | erpnext | {
"docstring": " update `tabPurchase Receipt Item`\n\t\tset received_stock_qty = received_qty * conversion_factor\n\t\twhere docstatus = 1 ",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 13
} | 81 | Python | 63 | 494bd9ef78313436f0424b918f200dab8fc7c20b | update_returned_qty_in_pr_dn.py | 66,831 | 14 | 77 | execute | https://github.com/frappe/erpnext.git | style: format code with black | 56 | 0 | 14,353 | 15 | |
6 | 32 | def geometric_edges(G, radius, p):
nodes_pos = G.nodes(data="pos")
try:
import scipy as sp
import scipy.spatial # call as sp.spatial
except ImportError:
# no scipy KDTree so compute by for-loop
radius_p = radius**p
edges = [
(u, v)
for (u... | networkx/generators/geometric.py | 252 | @py_random_state(5)
@nodes_or_number(0) | networkx | {
"docstring": "Returns edge list of node pairs within `radius` of each other.\n\n Parameters\n ----------\n G : networkx graph\n The graph from which to generate the edge list. The nodes in `G` should\n have an attribute ``pos`` corresponding to the node position, which is\n used to com... | 94 | Python | 70 | f6755ffa00211b523c6c0bec5398bc6c3c43c8b1 | geometric.py | 176,489 | 18 | 151 | geometric_edges | https://github.com/networkx/networkx.git | Update black (#5438)
* CI: sync up black dev requirements version with precommit
* Run black
Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com> | 206 | 1 | 41,932 | 18 |
4 | 22 | def _proc_function_remote(self, *, fun, low, user, tag, jid, daemonize=True):
if daemonize and not salt.utils.platform.is_windows():
# Shutdown the multiprocessing before daemonizing
salt.log.setup.shutdown_multiprocessing_logging()
salt.utils.process.daemonize()
... | salt/client/mixins.py | 175 | salt | {
"docstring": "\n Run this method in a multiprocess target to execute the function on the\n master and fire the return data on the event bus\n ",
"language": "en",
"n_whitespaces": 45,
"n_words": 23,
"vocab_size": 19
} | 53 | Python | 47 | c78f1ee4f49df35ab04e921a45de0878716d8bf5 | mixins.py | 216,481 | 12 | 105 | _proc_function_remote | https://github.com/saltstack/salt.git | Implement ``__getstate__`` and ``__setstate__`` instead of using ``classmethod``
Signed-off-by: Pedro Algarvio <palgarvio@vmware.com> | 186 | 0 | 54,603 | 11 | |
1 | 14 | def test_text_qtest(self, qtest_key, qtbot, key_tester):
with qtbot.wait_signal(key_tester.got_text):
qtbot.keyPress(key_tester, qtest_key.member)
info = keyutils.KeyInfo(qtest_key.member)
assert info.text() == key_tester.text.lower()
| tests/unit/keyinput/test_keyutils.py | 91 | qutebrowser | {
"docstring": "Make sure KeyInfo.text() lines up with QTest::keyToAscii.\n\n See key_data.py for inputs and expected values.\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 14,
"vocab_size": 14
} | 16 | Python | 16 | 623b06bc3dabfd53f637e611ec8d3e4feb521189 | test_keyutils.py | 321,569 | 5 | 56 | test_text_qtest | https://github.com/qutebrowser/qutebrowser.git | Fix remaining enum/flag issues | 55 | 0 | 117,802 | 10 | |
1 | 11 | def mixin_head_parser(parser):
gp = add_arg_group(parser, title='Head')
gp.add_argument(
'--uses-before-address',
type=str,
help='The address of the uses-before runtime',
)
gp.add_argument(
'--uses-after-address',
type=str,
help='The address of the... | jina/parsers/orchestrate/runtimes/head.py | 137 | jina | {
"docstring": "Mixing in arguments required by head pods and runtimes into the given parser.\n :param parser: the parser instance to which we add arguments\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 23,
"vocab_size": 21
} | 65 | Python | 44 | c7ad27e5614dfb2b1684f4718c5508840cd55de0 | head.py | 11,483 | 23 | 80 | mixin_head_parser | https://github.com/jina-ai/jina.git | refactor: add disable_reduce args (#4424) | 186 | 0 | 2,054 | 10 | |
2 | 20 | def test_run_clm_no_trainer(self):
tmp_dir = self.get_auto_remove_tmp_dir()
testargs = f.split()
if torch.cuda.device_count() > 1:
# Skipping because there are not enough batches to train the model + would need a drop_last to work.
return
run_command(self._launc... | examples/pytorch/test_accelerate_examples.py | 180 | transformers | {
"docstring": "\n {self.examples_dir}/pytorch/language-modeling/run_clm_no_trainer.py\n --model_name_or_path distilgpt2\n --train_file ./tests/fixtures/sample_text.txt\n --validation_file ./tests/fixtures/sample_text.txt\n --block_size 128\n --per_dev... | 44 | Python | 39 | 99eb9b523f9b9ea6096323ce5610ce6633acc88a | test_accelerate_examples.py | 32,329 | 22 | 101 | test_run_clm_no_trainer | https://github.com/huggingface/transformers.git | Fix `no_trainer` CI (#18242)
* Fix all tests | 121 | 0 | 5,903 | 12 | |
2 | 20 | def bokeh_chart(self, figure, use_container_width=False):
import bokeh
if bokeh.__version__ != ST_BOKEH_VERSION:
raise StreamlitAPIException(
f"Streamlit only supports Bokeh version {ST_BOKEH_VERSION}, "
f"but you have version {bokeh.__version__} ins... | lib/streamlit/elements/bokeh_chart.py | 153 | streamlit | {
"docstring": "Display an interactive Bokeh chart.\n\n Bokeh is a charting library for Python. The arguments to this function\n closely follow the ones for Bokeh's `show` function. You can find\n more about Bokeh at https://bokeh.pydata.org.\n\n Parameters\n ----------\n fig... | 63 | Python | 57 | 72703b38029f9358a0ec7ca5ed875a6b438ece19 | bokeh_chart.py | 118,727 | 14 | 84 | bokeh_chart | https://github.com/streamlit/streamlit.git | Replace static apps with live Cloud apps (#4317)
Co-authored-by: kajarenc <kajarenc@gmail.com> | 208 | 0 | 26,384 | 13 | |
3 | 30 | def matthews_corrcoef(y_true, y_pred, *, sample_weight=None):
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
check_consistent_length(y_true, y_pred, sample_weight)
if y_type not in {"binary", "multiclass"}:
raise ValueError("%s is not supported" % y_type)
lb = LabelEncoder()
l... | sklearn/metrics/_classification.py | 336 | scikit-learn | {
"docstring": "Compute the Matthews correlation coefficient (MCC).\n\n The Matthews correlation coefficient is used in machine learning as a\n measure of the quality of binary and multiclass classifications. It takes\n into account true and false positives and negatives and is generally\n regarded as a b... | 93 | Python | 62 | 1fc86b6aacd89da44a3b4e8abf7c3e2ba4336ffe | _classification.py | 258,915 | 21 | 218 | matthews_corrcoef | https://github.com/scikit-learn/scikit-learn.git | MNT Update black to stable version (#22474) | 168 | 0 | 75,481 | 12 | |
2 | 33 | def test_fed_filtering(self):
fed_hostname = self.hs.hostname + "2"
subspace = "#subspace:" + fed_hostname
# Create a few rooms which will have different properties.
public_room = "#public:" + fed_hostname
knock_room = "#knock:" + fed_hostname
not_invited_room =... | tests/handlers/test_room_summary.py | 544 | synapse | {
"docstring": "\n Rooms returned over federation should be properly filtered to only include\n rooms the user has access to.\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 17
} | 218 | Python | 104 | 7754af24ab163a3666bc04c7df409e59ace0d763 | test_room_summary.py | 247,085 | 129 | 484 | test_fed_filtering | https://github.com/matrix-org/synapse.git | Remove the unstable `/spaces` endpoint. (#12073)
...and various code supporting it.
The /spaces endpoint was from an old version of MSC2946 and included
both a Client-Server and Server-Server API. Note that the unstable
/hierarchy endpoint (from the final version of MSC2946) is not yet
removed. | 1,598 | 0 | 71,495 | 14 | |
1 | 25 | def test_tweedie_log_identity_consistency(p):
half_tweedie_log = HalfTweedieLoss(power=p)
half_tweedie_identity = HalfTweedieLossIdentity(power=p)
n_samples = 10
y_true, raw_prediction = random_y_true_raw_prediction(
loss=half_tweedie_log, n_samples=n_samples, seed=42
)
y_pred = hal... | sklearn/_loss/tests/test_loss.py | 255 | scikit-learn | {
"docstring": "Test for identical losses when only the link function is different.",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 174 | Python | 109 | 75a94f518f7bd7d0bf581ffb67d9f961e3c4efbc | test_loss.py | 259,434 | 25 | 155 | test_tweedie_log_identity_consistency | https://github.com/scikit-learn/scikit-learn.git | ENH migrate GLMs / TweedieRegressor to linear loss (#22548)
Co-authored-by: Olivier Grisel <olivier.grisel@ensta.org>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com> | 383 | 0 | 75,768 | 10 | |
1 | 6 | def restart_subscription(name):
subscription = frappe.get_doc("Subscription", name)
subscription.restart_subscription()
@frappe.whitelist() | erpnext/accounts/doctype/subscription/subscription.py | 50 | @frappe.whitelist() | erpnext | {
"docstring": "\n\tRestarts a cancelled `Subscription`. The `Subscription` will 'forget' the history of\n\tall invoices it has generated\n\t",
"language": "en",
"n_whitespaces": 14,
"n_words": 16,
"vocab_size": 16
} | 8 | Python | 8 | 494bd9ef78313436f0424b918f200dab8fc7c20b | subscription.py | 65,075 | 3 | 21 | restart_subscription | https://github.com/frappe/erpnext.git | style: format code with black | 4 | 1 | 13,786 | 9 |
4 | 15 | def set_exception(self, exception):
if self._state != _PENDING:
raise exceptions.InvalidStateError(f'{self._state}: {self!r}')
if isinstance(exception, type):
exception = exception()
if type(exception) is StopIteration:
raise TypeError("StopIteration ... | python3.10.4/Lib/asyncio/futures.py | 132 | XX-Net | {
"docstring": "Mark the future done and set an exception.\n\n If the future is already done when this method is called, raises\n InvalidStateError.\n ",
"language": "en",
"n_whitespaces": 42,
"n_words": 21,
"vocab_size": 17
} | 44 | Python | 36 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | futures.py | 220,514 | 12 | 70 | set_exception | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 160 | 0 | 56,024 | 12 | |
4 | 6 | def _move_into_position(self, width, height):
if self.should_center:
self.center()
if height is not None:
self.height = height
if width is not None:
self.width = width
| manim/mobject/svg/svg_mobject.py | 68 | manim | {
"docstring": "Uses the SVGMobject's config dictionary to set the Mobject's\n width, height, and/or center it. Use ``width``, ``height``, and\n ``should_center`` respectively to modify this.\n ",
"language": "en",
"n_whitespaces": 44,
"n_words": 23,
"vocab_size": 21
} | 23 | Python | 15 | 902e7eb4f0147b5882a613b67467e38a1d47f01e | svg_mobject.py | 189,467 | 7 | 42 | _move_into_position | https://github.com/ManimCommunity/manim.git | Hide more private methods from the docs. (#2468)
* hide privs from text_mobject.py
* hide privs from tex_mobject.py
* hide privs from code_mobject.py
* hide privs from svg_mobject.py
* remove SVGPath and utils from __init__.py
* don't import string_to_numbers
* hide privs from geometry.py
* hide p... | 84 | 0 | 46,075 | 9 | |
1 | 11 | def upgrade():
with op.batch_alter_table("task_instance", schema=None) as batch_op:
batch_op.alter_column("pool_slots", existing_type=sa.Integer, nullable=False, server_default='1')
| airflow/migrations/versions/8646922c8a04_change_default_pool_slots_to_1.py | 70 | airflow | {
"docstring": "Change default pool_slots to 1 and make pool_slots not nullable",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | 11 | Python | 11 | 66c342d033bd3cb959b4dc4e7e4b8aad597aab63 | 8646922c8a04_change_default_pool_slots_to_1.py | 45,007 | 3 | 39 | upgrade | https://github.com/apache/airflow.git | Support generating SQL script for upgrades (#20962)
This PR attempts to add support for generating sql scripts for upgrade.
Example command:
`airflow db upgrade --revision-range e8d98d8ss99:78daisdu38d`
`airflow db upgrade --range 2.0.0:2.2.3` | 24 | 0 | 8,439 | 11 | |
2 | 20 | async def test_setup_temporary_error(hass, aioclient_mock):
fake_async_add_entities = MagicMock()
errors = [HTTPStatus.TOO_MANY_REQUESTS, HTTPStatus.INTERNAL_SERVER_ERROR]
for error in errors:
aioclient_mock.get(re.compile("api.foobot.io/v2/owner/.*"), status=error)
with pytest.raises(... | tests/components/foobot/test_sensor.py | 104 | core | {
"docstring": "Expected failures caused by temporary errors in API response.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 25 | Python | 23 | 8896229ea641a558161d8caed796895e9a78f457 | test_sensor.py | 304,817 | 9 | 63 | test_setup_temporary_error | https://github.com/home-assistant/core.git | Improve type hint in foobot sensor entity (#77164) | 88 | 0 | 103,612 | 12 | |
1 | 17 | def test_constrained_layout22():
fig, ax = plt.subplots(layout="constrained")
fig.draw_without_rendering()
extents0 = np.copy(ax.get_position().extents)
fig.suptitle("Suptitle", y=0.5)
fig.draw_without_rendering()
extents1 = np.copy(ax.get_position().extents)
np.testing.assert_allclo... | lib/matplotlib/tests/test_constrainedlayout.py | 129 | matplotlib | {
"docstring": "#11035: suptitle should not be include in CL if manually positioned",
"language": "en",
"n_whitespaces": 10,
"n_words": 11,
"vocab_size": 11
} | 18 | Python | 14 | ec4dfbc3c83866f487ff0bc9c87b0d43a1c02b22 | test_constrainedlayout.py | 107,161 | 8 | 77 | test_constrained_layout22 | https://github.com/matplotlib/matplotlib.git | ENH: implement and use base layout_engine for more flexible layout. | 42 | 0 | 22,616 | 11 | |
1 | 25 | def test_syntax_highlight_ranges():
syntax = Syntax(
CODE,
lexer="python",
line_numbers=True,
word_wrap=False,
highlight_ranges=[
SyntaxHighlightRange(
# overline the 2nd char of the 1st line:
start=SyntaxPosition(1, 1),
... | tests/test_syntax.py | 728 | rich | {
"docstring": "Iterate and generate a tuple with a flag for first and last value.",
"language": "en",
"n_whitespaces": 12,
"n_words": 13,
"vocab_size": 11
} | 193 | Python | 121 | ebc5d2797e7bfb595183fe61aac50be58c9a5174 | test_syntax.py | 161,775 | 48 | 291 | test_syntax_highlight_ranges | https://github.com/Textualize/rich.git | [syntax] add a `highlight_ranges` optional arg to the Syntax ctor
With this new API we can apply a style from (LINE A, COLUMN A) to (LINE B, COLUMN B) - which is something we will need to be able to add arbitrary ranges to Syntax | 833 | 0 | 39,061 | 18 | |
2 | 18 | def str_presenter(dumper, data):
if len(data.splitlines()) > 1: # check for multiline string
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")
return dumper.represent_scalar("tag:yaml.org,2002:str", data)
yaml.add_representer(str, str_presenter)
yaml.representer.SafeRepres... | src/prefect/cli/deployment.py | 135 | prefect | {
"docstring": "\n configures yaml for dumping multiline strings\n Ref: https://stackoverflow.com/questions/8640959/how-can-i-control-what-scalar-form-pyyaml-uses-for-my-data\n ",
"language": "en",
"n_whitespaces": 18,
"n_words": 8,
"vocab_size": 8
} | 34 | Python | 30 | 36d9870433a22fff3944fa07f8e2feeb1b622bd9 | deployment.py | 57,811 | 4 | 42 | str_presenter | https://github.com/PrefectHQ/prefect.git | Working YAML generation with lots of bells and whistles | 49 | 0 | 11,712 | 11 | |
2 | 27 | def test_lookup_using_custom_divider(self):
jane = Employee.objects.create(name="Jane,Green", department=self.design)
modeladmin = EmployeeCustomDividerFilterAdmin(Employee, site)
employees = [jane, self.jack]
request = self.request_factory.get(
"/", {"name__in": "|... | tests/admin_filters/tests.py | 259 | django | {
"docstring": "\n Filter __in lookups with a custom divider.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 85 | Python | 48 | 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | tests.py | 207,137 | 16 | 156 | test_lookup_using_custom_divider | https://github.com/django/django.git | Refs #33476 -- Reformatted code with Black. | 229 | 0 | 51,875 | 13 | |
1 | 4 | def blend_soft_light(self, rgb, intensity):
return 2 * intensity * rgb + (1 - 2 * intensity) * rgb**2
| lib/matplotlib/colors.py | 44 | matplotlib | {
"docstring": "\n Combine an RGB image with an intensity map using \"soft light\" blending,\n using the \"pegtop\" formula.\n\n Parameters\n ----------\n rgb : ndarray\n An MxNx3 RGB array of floats ranging from 0 to 1 (color image).\n intensity : ndarray\n ... | 18 | Python | 14 | 9b6abd0b4933811e0a45c2535ab8fd107db65dd9 | colors.py | 110,264 | 2 | 28 | blend_soft_light | https://github.com/matplotlib/matplotlib.git | DOC: improve grammar and consistency | 32 | 0 | 24,006 | 10 | |
1 | 3 | def __call__(self):
return list(self)
| lib/matplotlib/cm.py | 21 | matplotlib | {
"docstring": "\n Return a list of the registered colormap names.\n\n This exists only for backward-compatibility in `.pyplot` which had a\n ``plt.colormaps()`` method. The recommended way to get this list is\n now ``list(colormaps)``.\n ",
"language": "en",
"n_whitespaces": 66... | 4 | Python | 4 | 686c9e5a413e31c46bb049407d5eca285bcab76d | cm.py | 108,461 | 2 | 11 | __call__ | https://github.com/matplotlib/matplotlib.git | Fix spelling errors | 18 | 0 | 23,201 | 7 | |
4 | 8 | def get_custom_object_name(obj):
if hasattr(obj, "name"): # Accept `Loss` instance as `Metric`.
return obj.name
elif hasattr(obj, "__name__"): # Function.
return obj.__name__
elif hasattr(obj, "__class__"): # Class instance.
return generic_utils.to_snake_case(obj.__class__.__... | keras/engine/compile_utils.py | 95 | keras | {
"docstring": "Returns the name to use for a custom loss or metric callable.\n\n Args:\n obj: Custom loss of metric callable\n\n Returns:\n Name to use, or `None` if the object was not recognized.\n ",
"language": "en",
"n_whitespaces": 50,
"n_words": 31,
"vocab_size": 26
} | 34 | Python | 25 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | compile_utils.py | 271,050 | 9 | 53 | get_custom_object_name | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 81 | 0 | 80,685 | 12 | |
1 | 14 | def permute_dimensions(x, pattern):
return tf.compat.v1.transpose(x, perm=pattern)
@keras_export("keras.backend.resize_images")
@tf.__internal__.dispatch.add_dispatch_support
@doc_controls.do_not_generate_docs | keras/backend.py | 66 | @keras_export("keras.backend.resize_images")
@tf.__internal__.dispatch.add_dispatch_support
@doc_controls.do_not_generate_docs | keras | {
"docstring": "Permutes axes in a tensor.\n\n Args:\n x: Tensor or variable.\n pattern: A tuple of\n dimension indices, e.g. `(0, 2, 1)`.\n\n Returns:\n A tensor.\n\n Example:\n\n >>> a = tf.constant([[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]])\n >>> a\n <t... | 9 | Python | 9 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | backend.py | 269,576 | 2 | 23 | permute_dimensions | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 12 | 1 | 80,199 | 9 |
1 | 9 | def get_sal_struct(company, currency, salary_slip_based_on_timesheet, condition):
return frappe.db.sql_list(
.format(
condition=condition
),
{
"company": company,
"currency": currency,
"salary_slip_based_on_timesheet": salary_slip_based_on_timesheet,
},
)
| erpnext/payroll/doctype/payroll_entry/payroll_entry.py | 68 | erpnext | {
"docstring": "\n\t\tselect\n\t\t\tname from `tabSalary Structure`\n\t\twhere\n\t\t\tdocstatus = 1 and\n\t\t\tis_active = 'Yes'\n\t\t\tand company = %(company)s\n\t\t\tand currency = %(currency)s and\n\t\t\tifnull(salary_slip_based_on_timesheet,0) = %(salary_slip_based_on_timesheet)s\n\t\t\t{condition}",
"language... | 19 | Python | 17 | 494bd9ef78313436f0424b918f200dab8fc7c20b | payroll_entry.py | 66,913 | 20 | 43 | get_sal_struct | https://github.com/frappe/erpnext.git | style: format code with black | 8 | 0 | 14,378 | 10 | |
1 | 8 | def gelu_new(x):
return 0.5 * x * (1 + paddle.tanh(math.sqrt(2 / math.pi) * (x + 0.044715 * paddle.pow(x, 3))))
| modules/image/text_to_image/disco_diffusion_cnclip_vitb16/cn_clip/clip/modeling_bert.py | 72 | PaddleHub | {
"docstring": " Implementation of the gelu activation function currently in Google Bert repo (identical to OpenAI GPT).\n Also see https://arxiv.org/abs/1606.08415\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 18,
"vocab_size": 18
} | 19 | Python | 15 | f4d6e64cdc132ae868699a0ba442f4ab1d304a14 | modeling_bert.py | 49,732 | 2 | 49 | gelu_new | https://github.com/PaddlePaddle/PaddleHub.git | add disco_diffusion_cnclip_vitb16 module | 25 | 0 | 9,898 | 16 | |
4 | 19 | def clean_stale_components(self):
with self._components_lock:
stale_components = []
stale_component_ids = []
for id, component in self._components.items():
elapsed = time.monotonic() - component.last_reported_time
if elapsed > self._co... | python/ray/_private/metrics_agent.py | 154 | ray | {
"docstring": "Clean up stale components.\n\n Stale means the component is dead or unresponsive.\n\n Stale components won't be reported to Prometheus anymore.\n ",
"language": "en",
"n_whitespaces": 41,
"n_words": 20,
"vocab_size": 19
} | 59 | Python | 52 | 073e7bc04d989607848552537f9f5ac91fa07d85 | metrics_agent.py | 136,720 | 15 | 90 | clean_stale_components | https://github.com/ray-project/ray.git | [Dashboard] Remove opencensus from agent proxy export (#30469)
This PR removes the Opencensus usage on proxy export. Previously, OpenCensus APIs we are using for proxy export deepcopies the whole data {labels -> data} whenever there's a new export which causes O(N^2) write on metrics record. See the below section for ... | 279 | 0 | 30,979 | 17 | |
1 | 20 | def _annotate_pose(cls, image, face):
center = np.array((face.aligned.size / 2,
face.aligned.size / 2)).astype("int32").reshape(1, 2)
center = np.rint(face.aligned.transform_points(center, invert=True)).astype("int32")
points = face.aligned.pose.xyz_2d * face.... | tools/alignments/jobs.py | 291 | faceswap | {
"docstring": " Annotate the pose onto the frame.\n\n Parameters\n ----------\n image: :class:`numpy.ndarray`\n The frame that pose is to be annotated on to\n face: :class:`lib.align.AlignedFace`\n The aligned face loaded for head centering\n ",
"language": ... | 47 | Python | 29 | 5e73437be47f2410439a3c6716de96354e6a0c94 | jobs.py | 101,251 | 9 | 196 | _annotate_pose | https://github.com/deepfakes/faceswap.git | lib.align updates:
- alignments.py
- Add typed dicts for imported alignments
- Explicitly check for presence of thumb value in alignments dict
- linting
- detected_face.py
- Typing
- Linting
- Legacy support for pre-aligned face
- Update dependencies to new property names | 129 | 0 | 20,671 | 16 | |
3 | 7 | def filter_on_submodules(all_modules, submodule):
filtered_modules = [
mod for mod in all_modules if PACKAGE + submodule in mod.__name__
]
return filtered_modules
| keras/tests/keras_doctest.py | 43 | keras | {
"docstring": "Filters all the modules based on the module flag.\n\n The module flag has to be relative to the core package imported.\n For example, if `submodule=keras.layers` then, this function will return\n all the modules in the submodule.\n\n Args:\n all_modules: All the modules in the core package.\n ... | 20 | Python | 17 | a449efe29b092e658a29cd847e0494979a47d252 | keras_doctest.py | 268,868 | 5 | 27 | filter_on_submodules | https://github.com/keras-team/keras.git | Add a keras doctest modeled on tensorflow doctest
PiperOrigin-RevId: 424672415 | 29 | 0 | 79,737 | 10 | |
1 | 15 | def transform(self, X):
check_is_fitted(self)
X = self._validate_data(
X, accept_sparse=("csr", "csc"), dtype=[np.float64, np.float32], reset=False
)
W = self._solve_W(X, self.components_, self._transform_max_iter)
return W
| sklearn/decomposition/_nmf.py | 96 | scikit-learn | {
"docstring": "Transform the data X according to the fitted MiniBatchNMF model.\n\n Parameters\n ----------\n X : {array-like, sparse matrix} of shape (n_samples, n_features)\n Data matrix to be transformed by the model.\n\n Returns\n -------\n W : ndarray of shap... | 21 | Python | 19 | 69132ebbd39f070590ca01813340b5b12c0d02ab | _nmf.py | 259,702 | 7 | 62 | transform | https://github.com/scikit-learn/scikit-learn.git | FEA Online implementation of non-negative matrix factorization (#16948)
Co-authored-by: Tom Dupré la Tour <tom.dupre-la-tour@m4x.org>
Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr>
Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@use... | 74 | 0 | 75,877 | 11 | |
1 | 10 | def kubernetes_manifest():
template = Template(
(prefect.__module_path__ / "cli" / "templates" / "kubernetes.yaml").read_text()
)
manifest = template.substitute(
{
"image_name": get_prefect_image_name(),
}
)
print(manifest)
| src/prefect/cli/orion.py | 83 | prefect | {
"docstring": "\n Generates a kubernetes manifest for to deploy Orion to a cluster.\n\n Example:\n $ prefect orion kubernetes-manifest | kubectl apply -f -\n ",
"language": "en",
"n_whitespaces": 38,
"n_words": 21,
"vocab_size": 19
} | 22 | Python | 18 | 23365cf7727c45f38ad983d610ffec5c15ceca21 | orion.py | 53,269 | 10 | 44 | kubernetes_manifest | https://github.com/PrefectHQ/prefect.git | Add kubernetes manifest commands | 72 | 0 | 10,764 | 15 | |
1 | 10 | def active_count(self):
return self.order_by().exclude(inventory_sources__source='controller').values(name_lower=Lower('name')).distinct().count()
| awx/main/managers.py | 68 | awx | {
"docstring": "Return count of active, unique hosts for licensing.\n Construction of query involves:\n - remove any ordering specified in model's Meta\n - Exclude hosts sourced from another Tower\n - Restrict the query to only return the name column\n - Only consider results th... | 4 | Python | 4 | f52ef6e9677b01c111b012a8725da43a2580d8f1 | managers.py | 80,945 | 2 | 37 | active_count | https://github.com/ansible/awx.git | Fixes case sensitive host count | 18 | 0 | 17,116 | 15 | |
1 | 18 | def test_partial_fit_weight_class_balanced(klass):
# partial_fit with class_weight='balanced' not supported | sklearn/linear_model/tests/test_sgd.py | 121 | @pytest.mark.parametrize("klass", [SGDClassifier, SparseSGDClassifier]) | scikit-learn | {
"docstring": "\n regex = (\n r\"class_weight 'balanced' is not supported for \"\n r\"partial_fit\\. In order to use 'balanced' weights, \"\n r\"use compute_class_weight\\('balanced', classes=classes, y=y\\). \"\n r\"In place of y you can use a large enough sample \"\n r\"of the... | 8 | Python | 8 | 7f0b57e626d36a7c6d8f417261c6bbfe05376a98 | test_sgd.py | 260,298 | 13 | 59 | test_partial_fit_weight_class_balanced | https://github.com/scikit-learn/scikit-learn.git | MAINT parameter validation in SGD*, PassiveAgressive* and Perceptron (#23521)
Co-authored-by: jeremie du boisberranger <jeremiedbb@yahoo.fr>
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: Meekail Zain <34613774+Micky774@users.noreply.github.com> | 10 | 1 | 76,168 | 13 |
1 | 9 | def test_naive_all_pairs_lowest_common_ancestor6(self):
G = self.DG.copy()
G.add_node(-1)
gen = naive_all_pairs_lca(G, [(-1, -1), (-1, 0)])
assert dict(gen) == {(-1, -1): -1}
| networkx/algorithms/tests/test_lowest_common_ancestors.py | 101 | networkx | {
"docstring": "Test that pairs with no LCA specified emits nothing.",
"language": "en",
"n_whitespaces": 8,
"n_words": 9,
"vocab_size": 9
} | 19 | Python | 18 | b2f91c34a23058dd70b41784af0d87890216026a | test_lowest_common_ancestors.py | 177,019 | 5 | 63 | test_naive_all_pairs_lowest_common_ancestor6 | https://github.com/networkx/networkx.git | Naive lowest common ancestor implementation (#5736)
* Add naive lca methods
* Naive algorithm implementation for LCA
* Modify naive lca functions
* Correct parameters of nx.ancestors
* Update lowest_common_ancestors.py
* Parametrize tests
* Apply suggestions from code review
Co-authored-by: Dan Sc... | 54 | 0 | 42,231 | 11 | |
5 | 19 | def get_columns(salary_slips):
columns = [
_("Salary Slip ID") + ":Link/Salary Slip:150",
_("Employee") + ":Link/Employee:120",
_("Employee Name") + "::140",
_("Date of Joining") + "::80",
_("Branch") + ":Link/Branch:-1",
_("Department") + ":Link/Department:-1",
_("Designation") + ":Link/Designation:12... | erpnext/payroll/report/salary_register/salary_register.py | 483 | erpnext | {
"docstring": "\n\tcolumns = [\n\t _(\"Salary Slip ID\") + \":Link/Salary Slip:150\",\n\t _(\"Employee\") + \":Link/Employee:120\",\n\t _(\"Employee Name\") + \"::140\",\n\t _(\"Date of Joining\") + \"::80\",\n\t _(\"Branch\") + \":Link/Branch:120\",\n\t _(\"Department\") + ... | 121 | Python | 79 | 494bd9ef78313436f0424b918f200dab8fc7c20b | salary_register.py | 66,968 | 37 | 267 | get_columns | https://github.com/frappe/erpnext.git | style: format code with black | 87 | 0 | 14,394 | 17 | |
1 | 4 | def serialize(metric):
return serialize_keras_object(metric)
@keras_export("keras.metrics.deserialize") | keras/metrics/__init__.py | 32 | @keras_export("keras.metrics.deserialize") | keras | {
"docstring": "Serializes metric function or `Metric` instance.\n\n Args:\n metric: A Keras `Metric` instance or a metric function.\n\n Returns:\n Metric configuration dictionary.\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 20,
"vocab_size": 17
} | 5 | Python | 5 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | __init__.py | 274,614 | 2 | 11 | serialize | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 10 | 1 | 81,240 | 7 |
4 | 23 | def get_data(filters):
data = []
component_types = frappe.db.sql()
component_types = [comp_type[0] for comp_type in component_types]
if not len(component_types):
return []
conditions = get_conditions(filters)
entry = frappe.db.sql( % (conditions , ", ".join(['%s']*len(component_types))), tuple(component_t... | erpnext/payroll/report/income_tax_deductions/income_tax_deductions.py | 220 | erpnext | {
"docstring": " select name from `tabSalary Component`\n\t\twhere is_income_tax_component = 1 select sal.employee, sal.employee_name, sal.posting_date, ded.salary_component, ded.amount,sal.gross_pay\n\t\tfrom `tabSalary Slip` sal, `tabSalary Detail` ded\n\t\twhere sal.name = ded.parent\n\t\tand ded.parentfield = 'd... | 53 | Python | 43 | 3936d8b70e4847dddd49bf467fcbc6e2fcd106c5 | income_tax_deductions.py | 64,417 | 26 | 133 | get_data | https://github.com/frappe/erpnext.git | refactor: remove India specific code | 35 | 0 | 13,631 | 15 | |
3 | 10 | def generator(self):
K = self.module.number_field
return K.ext.alias if K and K.ext.is_aliased else self.T.gen
| sympy/polys/numberfields/modules.py | 53 | sympy | {
"docstring": "\n Return a :py:class:`~.Symbol` to be used when expressing this element\n as a polynomial.\n\n If we have an associated :py:class:`~.AlgebraicField` whose primitive\n element has an alias symbol, we use that. Otherwise we use the variable\n of the minimal polynomial... | 13 | Python | 12 | d37a3c05b98c8144d401fa264af687a525b5e39c | modules.py | 197,803 | 3 | 33 | generator | https://github.com/sympy/sympy.git | Improve printing for `PrimeIdeal`
* Support latex printing
* Rename `_pretty()` --> `repr()` since this is not 2D printing.
* Provide a `__str__()` method, which prints less info than the `__repr__()` method. | 34 | 0 | 48,701 | 9 | |
1 | 16 | def test_disabling_background_update_sleep(self):
self.get_success(
self.store.db_pool.simple_insert(
"background_updates",
values={"update_name": "test_update", "progress_json": '{"my_key": 1}'},
)
)
self.update_handler.side_eff... | tests/storage/test_background_update.py | 133 | synapse | {
"docstring": "\n Test that disabling sleep in the config results in bg update not sleeping\n ",
"language": "en",
"n_whitespaces": 28,
"n_words": 13,
"vocab_size": 12
} | 33 | Python | 31 | ef3619e61d84493d98470eb2a69131d15eb1166b | test_background_update.py | 247,568 | 12 | 77 | test_disabling_background_update_sleep | https://github.com/matrix-org/synapse.git | Add config settings for background update parameters (#11980) | 155 | 0 | 71,746 | 13 | |
1 | 11 | def test_get_global_no_mutability(self) -> None:
# First add some account data to set up the test.
self.get_success(
self._store.add_account_data_for_user(
self.user_id, "test.data", {"wombat": True}
)
)
# Now request that data and then m... | tests/module_api/test_account_data_manager.py | 114 | synapse | {
"docstring": "\n Tests that modules can't introduce bugs into Synapse by mutating the result\n of `get_global`.\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 14
} | 58 | Python | 51 | 85ca963c1add5ca12f59238a50dfc63df4846bb7 | test_account_data_manager.py | 247,972 | 15 | 64 | test_get_global_no_mutability | https://github.com/matrix-org/synapse.git | Add Module API for reading and writing global account data. (#12391) | 184 | 0 | 72,031 | 12 | |
1 | 5 | def size(self) -> Size:
return Size(self.width, self.height)
| src/textual/geometry.py | 32 | textual | {
"docstring": "Get the size of the region.\n\n Returns:\n Size: Size of the region.\n\n ",
"language": "en",
"n_whitespaces": 37,
"n_words": 12,
"vocab_size": 8
} | 7 | Python | 7 | 6ee4d41bb7a39238a18949f5648773562c6a1c9b | geometry.py | 184,573 | 8 | 19 | size | https://github.com/Textualize/textual.git | docs | 21 | 0 | 44,676 | 8 | |
1 | 4 | async def test_remove_order():
removals: list[str] = []
| tests/test_widget_removing.py | 27 | textual | {
"docstring": "The removal of a top-level widget should cause bottom-first removal.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 10
} | 7 | Python | 7 | 9748850657337ba31f220387e4a7777a87ec019a | test_widget_removing.py | 185,774 | 10 | 87 | test_remove_order | https://github.com/Textualize/textual.git | Add a unit test for removal ordering via Widget.remove | 13 | 0 | 45,174 | 8 | |
4 | 9 | def createPreModuleLoadCode(self, module):
# This is only relevant on standalone mode for Windows
if not isStandaloneMode():
return
full_name = module.getFullName()
if full_name == self.binding_name and isWin32Windows():
code =
yield (
... | nuitka/plugins/standard/PySidePyQtPlugin.py | 78 | Nuitka | {
"docstring": "Method called when a module is being imported.\n\n Notes:\n If full name equals to the binding we insert code to include the dist\n folder in the 'PATH' environment variable (on Windows only).\n\n Args:\n module: the module object\n Returns:\n ... | 44 | Python | 40 | 6b317645a6edf73a8628229c540555142725478d | PySidePyQtPlugin.py | 178,696 | 14 | 43 | createPreModuleLoadCode | https://github.com/Nuitka/Nuitka.git | Plugins: Minor cleanups | 154 | 0 | 42,792 | 10 | |
1 | 10 | def ledoit_wolf(X, *, assume_centered=False, block_size=1000):
estimator = LedoitWolf(
assume_centered=assume_centered,
block_size=block_size,
store_precision=False,
).fit(X)
return estimator.covariance_, estimator.shrinkage_
| sklearn/covariance/_shrunk_covariance.py | 70 | scikit-learn | {
"docstring": "Estimate the shrunk Ledoit-Wolf covariance matrix.\n\n Read more in the :ref:`User Guide <shrunk_covariance>`.\n\n Parameters\n ----------\n X : array-like of shape (n_samples, n_features)\n Data from which to compute the covariance estimate.\n\n assume_centered : bool, default=F... | 15 | Python | 15 | 9a90af51510c0722ab880061107e5cfdcf09192f | _shrunk_covariance.py | 261,798 | 7 | 46 | ledoit_wolf | https://github.com/scikit-learn/scikit-learn.git | MAINT Parameters validation for covariance.ledoit_wolf (#24870)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
Co-authored-by: jeremiedbb <jeremiedbb@yahoo.fr> | 48 | 0 | 77,003 | 11 | |
3 | 15 | def dist_get_direct_url(dist):
# type: (Distribution) -> Optional[DirectUrl]
if not dist.has_metadata(DIRECT_URL_METADATA_NAME):
return None
try:
return DirectUrl.from_json(dist.get_metadata(DIRECT_URL_METADATA_NAME))
except (
DirectUrlValidationError,
json.JSONDecod... | .venv/lib/python3.8/site-packages/pip/_internal/utils/direct_url_helpers.py | 100 | transferlearning | {
"docstring": "Obtain a DirectUrl from a pkg_resource.Distribution.\n\n Returns None if the distribution has no `direct_url.json` metadata,\n or if `direct_url.json` is invalid.\n ",
"language": "en",
"n_whitespaces": 29,
"n_words": 20,
"vocab_size": 17
} | 36 | Python | 32 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | direct_url_helpers.py | 61,169 | 17 | 62 | dist_get_direct_url | https://github.com/jindongwang/transferlearning.git | upd; format | 154 | 0 | 12,422 | 11 | |
1 | 2 | def cmax(self):
return self["cmax"]
| packages/python/plotly/plotly/graph_objs/_cone.py | 22 | plotly.py | {
"docstring": "\n Sets the upper bound of the color domain. Value should have the\n same units as u/v/w norm and if set, `cmin` must be set as\n well.\n\n The 'cmax' property is a number and may be specified as:\n - An int or float\n\n Returns\n -------\n int... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _cone.py | 226,571 | 2 | 11 | cmax | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,244 | 7 | |
4 | 20 | def tcp_pseudoheader(tcp):
# type: (TCP) -> bytes
if isinstance(tcp.underlayer, IP):
plen = len(bytes(tcp))
return in4_pseudoheader(socket.IPPROTO_TCP, tcp.underlayer, plen)
elif conf.ipv6_enabled and _is_ipv6_layer(tcp.underlayer):
plen = len(bytes(tcp))
return raw(scap... | scapy/layers/inet.py | 142 | scapy | {
"docstring": "Pseudoheader of a TCP packet as bytes\n\n Requires underlayer to be either IP or IPv6\n ",
"language": "en",
"n_whitespaces": 21,
"n_words": 15,
"vocab_size": 15
} | 40 | Python | 35 | 20ac1d00389d0735e6d8cd1347f0a53f478144ba | inet.py | 209,126 | 10 | 88 | tcp_pseudoheader | https://github.com/secdev/scapy.git | Support TCP-MD5 and TCP-AO (#3358)
Support TCP-MD5 and TCP-AO | 101 | 0 | 52,615 | 14 | |
2 | 19 | def get_collection_version_metadata(self, namespace, name, version):
api_path = self.available_api_versions.get('v3', self.available_api_versions.get('v2'))
url_paths = [self.api_server, api_path, 'collections', namespace, name, 'versions', version, '/']
n_collection_url = _urljoin(*ur... | lib/ansible/galaxy/api.py | 262 | ansible | {
"docstring": "\n Gets the collection information from the Galaxy server about a specific Collection version.\n\n :param namespace: The collection namespace.\n :param name: The collection name.\n :param version: Version of the collection to get the information for.\n :return: Colle... | 62 | Python | 53 | 43e55db20821a1341d21ffa1e4e7e6185b244105 | api.py | 266,587 | 12 | 163 | get_collection_version_metadata | https://github.com/ansible/ansible.git | ansible-galaxy - add signature verification of the MANIFEST.json (#76681)
* ansible-galaxy collection install|verify:
- Support verifying the origin of the MANIFEST.json when the Galaxy server has provided signatures.
- Allow supplemental signatures to use during verification on the CLI/requirements file.
*... | 232 | 0 | 78,486 | 11 | |
6 | 22 | def get_args(tp):
if isinstance(tp, _AnnotatedAlias):
return (tp.__origin__,) + tp.__metadata__
if isinstance(tp, (typing._GenericAlias, GenericAlias)):
if getattr(tp, "_special", False):
return ()
res = tp.__args__
if get_origin(t... | pipenv/patched/notpip/_vendor/typing_extensions.py | 203 | pipenv | {
"docstring": "Get type arguments with all substitutions performed.\n\n For unions, basic simplifications used by Union constructor are performed.\n Examples::\n get_args(Dict[str, int]) == (str, int)\n get_args(int) == ()\n get_args(Union[int, Union[T, int], str][int])... | 54 | Python | 39 | f3166e673fe8d40277b804d35d77dcdb760fc3b3 | typing_extensions.py | 20,897 | 11 | 101 | get_args | https://github.com/pypa/pipenv.git | check point progress on only bringing in pip==22.0.4 (#4966)
* vendor in pip==22.0.4
* updating vendor packaging version
* update pipdeptree to fix pipenv graph with new version of pip.
* Vendoring of pip-shims 0.7.0
* Vendoring of requirementslib 1.6.3
* Update pip index safety restrictions patch for p... | 166 | 0 | 3,611 | 16 | |
1 | 23 | def test_following_previous_schedule(self):
local_tz = pendulum.timezone('Europe/Zurich')
start = local_tz.convert(datetime.datetime(2018, 10, 28, 2, 55), dst_rule=pendulum.PRE_TRANSITION)
assert start.isoformat() == "2018-10-28T02:55:00+02:00", "Pre-condition: start date is in DST"
... | tests/models/test_dag.py | 284 | airflow | {
"docstring": "\n Make sure DST transitions are properly observed\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 81 | Python | 50 | 2fdc23333909096d427171002582e2906f8bbc0a | test_dag.py | 43,883 | 18 | 167 | test_following_previous_schedule | https://github.com/apache/airflow.git | Fix remaining mypy issues in "core" Airflow (#20795)
Co-authored-by: Josh Fell <josh.d.fell@astronomer.io>
Co-authored-by: Tzu-ping Chung <tp@astronomer.io>
Co-authored-by: Jarek Potiuk <jarek@potiuk.com> | 207 | 0 | 8,084 | 10 | |
3 | 21 | def close(self) -> None:
if not self.has_closed:
# update the run.txt with stopping time
self.run_txt_data["stop_time"] = datetime.datetime.now().isoformat(sep=" ")
with open(os.path.join(self.submit_config.run_dir, "run.txt"), "w") as f:
pprint.pprin... | reconstruction/ostec/external/stylegan2/dnnlib/submission/run_context.py | 163 | insightface | {
"docstring": "Close the context and clean up.\n Should only be called once.",
"language": "en",
"n_whitespaces": 17,
"n_words": 11,
"vocab_size": 11
} | 46 | Python | 37 | 7375ee364e0df2a417f92593e09557f1b2a3575a | run_context.py | 9,376 | 11 | 97 | close | https://github.com/deepinsight/insightface.git | initialize ostec | 167 | 0 | 1,590 | 16 | |
7 | 20 | def wrapCommandForDebuggerForExec(*args):
gdb_path = getExecutablePath("gdb")
# Windows extra ball, attempt the downloaded one.
if isWin32Windows() and gdb_path is None:
from nuitka.Options import assumeYesForDownloads
mingw64_gcc_path = getCachedDownloadedMinGW64(
target... | nuitka/utils/Execution.py | 254 | Nuitka | {
"docstring": "Wrap a command for system debugger to call exec\n\n Args:\n args: (list of str) args for call to be debugged\n Returns:\n args tuple with debugger command inserted\n\n Notes:\n Currently only gdb and lldb are supported, but adding more\n debuggers would be very wel... | 90 | Python | 60 | 98badaaafd4e56529378947358acae489035fa1e | Execution.py | 178,724 | 19 | 142 | wrapCommandForDebuggerForExec | https://github.com/Nuitka/Nuitka.git | Windows: Make running in debugger work with cmd files as well | 214 | 0 | 42,804 | 14 | |
9 | 29 | def sort_bbox(end2end_xywh_bboxes, no_match_end2end_indexes):
groups = []
bbox_groups = []
for index, end2end_xywh_bbox in zip(no_match_end2end_indexes,
end2end_xywh_bboxes):
this_bbox = end2end_xywh_bbox
if len(groups) == 0:
groups.ap... | ppstructure/table/table_master_match.py | 411 | PaddleOCR | {
"docstring": "\n This function will group the render end2end bboxes in row.\n :param end2end_xywh_bboxes:\n :param no_match_end2end_indexes:\n :return:\n ",
"language": "en",
"n_whitespaces": 31,
"n_words": 15,
"vocab_size": 14
} | 162 | Python | 98 | ddaa2c2552e19635cd6cdf38619f1f176c358f89 | table_master_match.py | 24,501 | 36 | 260 | sort_bbox | https://github.com/PaddlePaddle/PaddleOCR.git | add SLANet | 534 | 0 | 4,748 | 16 | |
20 | 17 | def process_directive(self, directive):
# Parse the line: split it up, make sure the right number of words
# is there, and return the relevant words. 'action' is always
# defined: it's the first word of the line. Which of the other
# three are defined depends on the action; it... | .venv/lib/python3.8/site-packages/pip/_vendor/distlib/manifest.py | 437 | transferlearning | {
"docstring": "\n Process a directive which either adds some files from ``allfiles`` to\n ``files``, or removes some files from ``files``.\n\n :param directive: The directive to process. This should be in a format\n compatible with distutils ``MANIFEST.in`` files:\n\n ... | 307 | Python | 136 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | manifest.py | 62,044 | 36 | 247 | process_directive | https://github.com/jindongwang/transferlearning.git | upd; format | 1,158 | 0 | 12,851 | 16 | |
1 | 8 | def hex6(self) -> str:
r, g, b, a = self.clamped
return f"#{r:02X}{g:02X}{b:02X}"
| src/textual/color.py | 54 | textual | {
"docstring": "The color in CSS hex form, with 6 digits for RGB. Alpha is ignored.\n\n Returns:\n str: A CSS hex-style color, e.g. \"#46b3de\"\n\n ",
"language": "en",
"n_whitespaces": 47,
"n_words": 22,
"vocab_size": 21
} | 12 | Python | 12 | 6f7d3b5ad711aa7df62ca6b3fca5cd638dcec665 | color.py | 184,969 | 9 | 22 | hex6 | https://github.com/Textualize/textual.git | text color | 33 | 0 | 44,871 | 8 | |
10 | 16 | def is_matching(G, matching):
if isinstance(matching, dict):
matching = matching_dict_to_set(matching)
nodes = set()
for edge in matching:
if len(edge) != 2:
raise nx.NetworkXError(f"matching has non-2-tuple edge {edge}")
u, v = edge
if u not in G or v not i... | networkx/algorithms/matching.py | 185 | networkx | {
"docstring": "Return True if ``matching`` is a valid matching of ``G``\n\n A *matching* in a graph is a set of edges in which no two distinct\n edges share a common endpoint. Each node is incident to at most one\n edge in the matching. The edges are said to be independent.\n\n Parameters\n ----------... | 75 | Python | 44 | 28b3014d68d2b4e40d3e02219770296a827bd55c | matching.py | 176,367 | 18 | 111 | is_matching | https://github.com/networkx/networkx.git | Update matching functions for error validation and speed (#4897)
* First steps to update matching functions for #4644
Expand tests
Change API to raise NetworkXError when matching involves nodes not in G
Update is_*_matching to 100+ times faster.
* improve matching_dict_to_set and docs for min_weight_matching
... | 201 | 0 | 41,853 | 13 | |
2 | 14 | def test_google_type_conversion(mock_fields_meta_data):
desired_mapping = {
"accessible_bidding_strategy.target_impression_share.location": "string", # "ENUM"
"campaign.name": ["string", "null"], # STRING
"campaign.end_date": ["string", "null"], # DATE
"campaign.optimization_... | airbyte-integrations/connectors/source-google-ads/unit_tests/test_source.py | 285 | airbyte | {
"docstring": "\n query may be invalid (fields incompatibility did not checked).\n But we are just testing types, without submitting the query and further steps.\n Doing that with all possible types.\n \n SELECT\n accessible_bidding_strategy.target_impression_share.location,\n ... | 91 | Python | 60 | d4f8b25b8e3e109db866352cf1dcec0d73c92cbd | test_source.py | 5,061 | 31 | 142 | test_google_type_conversion | https://github.com/airbytehq/airbyte.git | Source Google Ads: Improve unit and integration tests (#12651)
* #12650 source Googel ads: tests
* #12650 source google ads: add changelog item
* #12650 source google ads: add comments to tests
* auto-bump connector version
Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.gith... | 206 | 0 | 714 | 11 | |
1 | 5 | def has_refs(self) -> bool:
return len(self._session_report_run_counts) > 0
| lib/streamlit/forward_msg_cache.py | 30 | streamlit | {
"docstring": "True if this Entry has references from any AppSession.\n\n If not, it can be removed from the cache.\n ",
"language": "en",
"n_whitespaces": 40,
"n_words": 18,
"vocab_size": 17
} | 8 | Python | 8 | 704eab3478cf69847825b23dabf15813a8ac9fa2 | forward_msg_cache.py | 118,557 | 6 | 17 | has_refs | https://github.com/streamlit/streamlit.git | Rename and refactor `Report` machinery (#4141)
This refactor renames (almost) everything related to the outdated "report" concept with more precise concepts that we use throughout our code, primarily "script run", "session", and "app". | 30 | 0 | 26,290 | 9 | |
1 | 10 | def test_multi_part_language_bad_format(self, m):
m.return_value = ["chi_sim", "eng"]
msgs = check_default_language_available(None)
self.assertEqual(len(msgs), 1)
self.assertEqual(msgs[0].level, ERROR)
| src/paperless_tesseract/tests/test_checks.py | 78 | paperless-ngx | {
"docstring": "\n GIVEN:\n - An OCR language which is multi part (ie chi-sim)\n - The language is correctly NOT formatted\n WHEN:\n - Installed packages are checked\n THEN:\n - No errors are reported\n ",
"language": "en",
"n_whitespaces": 1... | 14 | Python | 13 | 55ef0d4a1b62c3abe8500cad97ddeecf9f746b84 | test_checks.py | 320,360 | 5 | 47 | test_multi_part_language_bad_format | https://github.com/paperless-ngx/paperless-ngx.git | Fixes language code checks around two part languages | 49 | 0 | 117,148 | 9 | |
1 | 15 | def simple_test(self, feats, img_metas, **kwargs):
all_cls_scores, all_mask_preds = self(feats, img_metas)
mask_cls_results = all_cls_scores[-1]
mask_pred_results = all_mask_preds[-1]
# upsample masks
img_shape = img_metas[0]['batch_input_shape']
mask_pred_resul... | mmdet/models/dense_heads/maskformer_head.py | 125 | mmdetection | {
"docstring": "Test without augmentaton.\n\n Args:\n feats (list[Tensor]): Multi-level features from the\n upstream network, each is a 4D-tensor.\n img_metas (list[dict]): List of image information.\n\n Returns:\n tuple: A tuple contains two tensors.\n\n ... | 33 | Python | 27 | 4bb184bae070f37febb10f82bee3a217dc1ad7c5 | maskformer_head.py | 244,108 | 11 | 80 | simple_test | https://github.com/open-mmlab/mmdetection.git | [Enhance] MaskFormer refactor (#7471)
* maskformer refactor
update docstring
update docstring
update unit test
update unit test
update unit test
* remove redundant code
* update unit test | 133 | 0 | 70,242 | 11 | |
1 | 12 | def test_query_by_embedding_excluded_meta_data_return_embedding_true(self, mocked_document_store):
mocked_document_store.return_embedding = True
mocked_document_store.excluded_meta_data = ["foo", "embedding"]
mocked_document_store.query_by_embedding(self.query_emb)
_, kwargs = m... | test/document_stores/test_opensearch.py | 102 | haystack | {
"docstring": "\n Test that when `return_embedding==True` the field should NOT be excluded even if it\n was added to `excluded_meta_data`\n ",
"language": "en",
"n_whitespaces": 39,
"n_words": 17,
"vocab_size": 17
} | 30 | Python | 28 | e7627c3f8b241654b61f8523479c81f855102f0a | test_opensearch.py | 257,656 | 6 | 57 | test_query_by_embedding_excluded_meta_data_return_embedding_true | https://github.com/deepset-ai/haystack.git | Use opensearch-py in OpenSearchDocumentStore (#2691)
* add Opensearch extras
* let OpenSearchDocumentStore use opensearch-py
* Update Documentation & Code Style
* fix a bug found after adding tests
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: ... | 79 | 0 | 75,108 | 10 | |
1 | 3 | def id() -> str:
return _distro.id()
| pipenv/patched/notpip/_vendor/distro/distro.py | 25 | pipenv | {
"docstring": "\n Return the distro ID of the current distribution, as a\n machine-readable string.\n\n For a number of OS distributions, the returned distro ID value is\n *reliable*, in the sense that it is documented and that it does not change\n across releases of the distribution.\n\n This pack... | 6 | Python | 6 | c69d55f7c82d5ae2cce542bcfb98d043ca4836a0 | distro.py | 21,509 | 79 | 13 | id | https://github.com/pypa/pipenv.git | Vendor in pip 22.1.2 | 12 | 0 | 3,889 | 7 | |
1 | 33 | def test_execute_task_instances_backfill_tasks_wont_execute(self, dag_maker):
dag_id = 'SchedulerJobTest.test_execute_task_instances_backfill_tasks_wont_execute'
task_id_1 = 'dummy_task'
with dag_maker(dag_id=dag_id):
task1 = EmptyOperator(task_id=task_id_1)
self.s... | tests/jobs/test_scheduler_job.py | 222 | airflow | {
"docstring": "\n Tests that backfill tasks won't get executed.\n ",
"language": "en",
"n_whitespaces": 22,
"n_words": 7,
"vocab_size": 7
} | 43 | Python | 31 | 49e336ae0302b386a2f47269a6d13988382d975f | test_scheduler_job.py | 47,528 | 19 | 131 | test_execute_task_instances_backfill_tasks_wont_execute | https://github.com/apache/airflow.git | Replace usage of `DummyOperator` with `EmptyOperator` (#22974)
* Replace usage of `DummyOperator` with `EmptyOperator` | 180 | 0 | 9,148 | 11 | |
1 | 24 | def rand_series_with_duplicate_datetimeindex() -> Series:
dates = [
datetime(2000, 1, 2),
datetime(2000, 1, 2),
datetime(2000, 1, 2),
datetime(2000, 1, 3),
datetime(2000, 1, 3),
datetime(2000, 1, 3),
datetime(2000, 1, 4),
datetime(2000, 1, 4),
... | pandas/conftest.py | 360 | @pytest.fixture(
params=[
(
Interval(left=0, right=5, inclusive="right"),
IntervalDtype("int64", inclusive="right"),
),
(
Interval(left=0.1, right=0.5, inclusive="right"),
IntervalDtype("float64", inclusive="right"),
),
(Period(... | pandas | {
"docstring": "\n Fixture for Series with a DatetimeIndex that has duplicates.\n ",
"language": "en",
"n_whitespaces": 16,
"n_words": 9,
"vocab_size": 9
} | 78 | Python | 43 | f538568afc2c76c2d738d32e3544cf9fe6742960 | conftest.py | 167,613 | 17 | 120 | rand_series_with_duplicate_datetimeindex | https://github.com/pandas-dev/pandas.git | TYP: misc return type annotations (#47558) | 290 | 1 | 40,065 | 13 |
2 | 5 | def execute():
name = frappe.db.sql(
)
if not name:
frappe.db.sql(
"update `tabProduction Order` pro \
set \
description = (select description from tabItem where name=pro.production_item) \
where \
ifnull(description, '') = ''"
)
| erpnext/patches/v5_7/update_item_description_based_on_item_master.py | 54 | erpnext | {
"docstring": " select name from `tabPatch Log` \\\n\t\twhere \\\n\t\t\tpatch like 'execute:frappe.db.sql(\"update `tabProduction Order` pro set description%' ",
"language": "en",
"n_whitespaces": 15,
"n_words": 16,
"vocab_size": 15
} | 33 | Python | 24 | 494bd9ef78313436f0424b918f200dab8fc7c20b | update_item_description_based_on_item_master.py | 66,864 | 14 | 26 | execute | https://github.com/frappe/erpnext.git | style: format code with black | 22 | 0 | 14,363 | 10 | |
2 | 11 | def iter_mapped_dependencies(self) -> Iterator["Operator"]:
from airflow.models.xcom_arg import XComArg
for ref in XComArg.iter_xcom_args(self._get_expansion_kwargs()):
yield ref.operator
| airflow/models/mappedoperator.py | 62 | airflow | {
"docstring": "Upstream dependencies that provide XComs used by this task for task mapping.",
"language": "en",
"n_whitespaces": 11,
"n_words": 12,
"vocab_size": 11
} | 14 | Python | 14 | 197cff3194e855b9207c3c0da8ae093a0d5dda55 | mappedoperator.py | 47,756 | 5 | 37 | iter_mapped_dependencies | https://github.com/apache/airflow.git | Ensure TaskMap only checks "relevant" dependencies (#23053)
When looking for "mapped dependants" of a task, we only want a task if
it not only is a direct downstream of the task, but also it actually
"uses" the task's pushed XCom for task mapping. So we need to peek into
the mapped downstream task's expansion kwarg... | 46 | 0 | 9,245 | 9 | |
6 | 16 | def get_expiry_date(self, **kwargs):
try:
modification = kwargs['modification']
except KeyError:
modification = timezone.now()
# Same comment as in get_expiry_age
try:
expiry = kwargs['expiry']
except KeyError:
expiry = sel... | django/contrib/sessions/backends/base.py | 152 | django | {
"docstring": "Get session the expiry date (as a datetime object).\n\n Optionally, this function accepts `modification` and `expiry` keyword\n arguments specifying the modification and expiry of the session.\n ",
"language": "en",
"n_whitespaces": 47,
"n_words": 26,
"vocab_size": 22
} | 46 | Python | 30 | 436862787cbdbd68b0ba20ed8c23b295e3679df3 | base.py | 203,048 | 15 | 89 | get_expiry_date | https://github.com/django/django.git | Refs #29708 -- Made SessionBase store expiry as string. | 182 | 0 | 50,223 | 12 | |
2 | 27 | def evaluate(model, criterion, metric, data_loader):
model.eval()
metric.reset()
losses = []
for batch in data_loader:
input_ids, token_type_ids, labels = batch
logits = model(input_ids, token_type_ids)
loss = criterion(logits, labels)
probs = F.sigmoid(logits)
... | examples/text_classification/multi_label/train.py | 187 | PaddleNLP | {
"docstring": "\n Given a dataset, it evals model and computes the metric.\n\n Args:\n model(obj:`paddle.nn.Layer`): A model to classify texts.\n criterion(obj:`paddle.nn.Layer`): It can compute the loss.\n metric(obj:`paddle.metric.Metric`): The evaluation metric.\n data_loader(obj... | 51 | Python | 41 | 621357338437ee420eabbbf5ab19065bc85e73a5 | train.py | 322,167 | 16 | 116 | evaluate | https://github.com/PaddlePaddle/PaddleNLP.git | Update neural search readme and Add Paddle Serving Support (#1558)
* add recall inference similarity
* update examples
* updatea readme
* update dir name
* update neural search readme
* update milvus readme
* update domain adaptive pretraining readme
* fix the mistakes
* update readme
* add ... | 129 | 0 | 118,077 | 11 | |
1 | 2 | def ygap(self):
return self["ygap"]
| packages/python/plotly/plotly/graph_objs/_heatmap.py | 22 | plotly.py | {
"docstring": "\n Sets the vertical gap (in pixels) between bricks.\n\n The 'ygap' property is a number and may be specified as:\n - An int or float in the interval [0, inf]\n\n Returns\n -------\n int|float\n ",
"language": "en",
"n_whitespaces": 84,
"n_words... | 4 | Python | 4 | 43e3a4011080911901176aab919c0ecf5046ddd3 | _heatmap.py | 226,903 | 2 | 11 | ygap | https://github.com/plotly/plotly.py.git | switch to black .22 | 18 | 0 | 58,576 | 7 | |
1 | 3 | def __enter__(self):
raise NotImplementedError()
| python3.10.4/Lib/asyncio/unix_events.py | 20 | XX-Net | {
"docstring": "Enter the watcher's context and allow starting new processes\n\n This function must return self",
"language": "en",
"n_whitespaces": 20,
"n_words": 14,
"vocab_size": 14
} | 4 | Python | 4 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | unix_events.py | 220,938 | 2 | 10 | __enter__ | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 18 | 0 | 56,170 | 7 | |
1 | 2 | def adapt_streams_if_testing(func):
| airbyte-integrations/connectors/source-mixpanel/source_mixpanel/testing.py | 13 | airbyte | {
"docstring": "\n Due to API limitations (60 requests per hour) there is unavailable to make acceptance tests in normal mode,\n so we're reducing amount of requests by, if `is_testing` flag is set in config:\n\n 1. Take time range in only 1 month\n 2. Patch Funnels, so we download data only for one Funne... | 2 | Python | 2 | d79b319819650f99fae2ab8c6c8d3ab25d474cf1 | testing.py | 5,687 | 4 | 15 | adapt_streams_if_testing | https://github.com/airbytehq/airbyte.git | :tada: Source Mixpanel: Beta preparation (#13372)
* Add extra mode to Source, to allow run acceptance tests
* move streams into distinct modules
* Add property name transformation for Export stream for avoiding collisions
* Update doc
* Add `date_window_size` | 5 | 0 | 808 | 6 | |
1 | 6 | def getsource(object):
lines, lnum = getsourcelines(object)
return ''.join(lines)
# --------------------------------------------------- class tree extraction | python3.10.4/Lib/inspect.py | 40 | XX-Net | {
"docstring": "Return the text of the source code for an object.\n\n The argument may be a module, class, method, function, traceback, frame,\n or code object. The source code is returned as a single string. An\n OSError is raised if the source code cannot be retrieved.",
"language": "en",
"n_whitespa... | 13 | Python | 13 | 8198943edd73a363c266633e1aa5b2a9e9c9f526 | inspect.py | 218,386 | 3 | 21 | getsource | https://github.com/XX-net/XX-Net.git | add python 3.10.4 for windows | 21 | 0 | 55,274 | 8 | |
2 | 11 | def set_floatx(value):
global _FLOATX
accepted_dtypes = {"float16", "float32", "float64"}
if value not in accepted_dtypes:
raise ValueError(
f"Unknown `floatx` value: {value}. "
f"Expected one of {accepted_dtypes}"
)
_FLOATX = str(value)
@keras_export("kera... | keras/backend_config.py | 98 | @keras_export("keras.backend.image_data_format")
@tf.__internal__.dispatch.add_dispatch_support | keras | {
"docstring": "Sets the default float type.\n\n Note: It is not recommended to set this to float16 for training, as this\n will likely cause numeric stability issues. Instead, mixed precision, which\n is using a mix of float16 and float32, can be used by calling\n `tf.keras.mixed_precision.set_global_pol... | 31 | Python | 29 | f3cafc77c269f7ecbf80bb4cf4b54e28c153f4e6 | backend_config.py | 277,755 | 9 | 37 | set_floatx | https://github.com/keras-team/keras.git | resolve line-too-long in root directory | 80 | 1 | 82,185 | 12 |
3 | 45 | def test_fetch_final_taken_task(business_client):
config = dict(
title='test_label_races',
is_published=True,
label_config=
)
annotation_result = json.dumps([{
'from_name': 'text_class',
'to_name': 'text',
'type': 'choices',
'value': {'choices': ['clas... | label_studio/tests/test_next_task.py | 662 | @pytest.mark.skipif(not redis_healthcheck(), reason='Multi user locks only supported with redis enabled')
@pytest.mark.django_db | label-studio | {
"docstring": "\n <View>\n <Text name=\"text\" value=\"$text\"></Text>\n <Choices name=\"text_class\" choice=\"single\" toName=\"text\">\n <Choice value=\"class_A\"></Choice>\n <Choice value=\"class_B\"></Choice>\n </Choices>\n ... | 172 | Python | 119 | aaa022d8acbeb002eab2930965da276e9298cd54 | test_next_task.py | 177,569 | 52 | 330 | test_fetch_final_taken_task | https://github.com/heartexlabs/label-studio.git | [ext] Add video interpolation by param (DEV-74) (#1735)
* Add video interpolation by param
* Change label-studio-tools commit
* Fix typo and add some comments
* Fix context field
* Fix label-studio-tools link
* fix link to ext dep
* Update requirements for label_studio_tools
* Change label-studio-... | 363 | 1 | 42,442 | 17 |
2 | 16 | def create_central_storage_strategy():
compute_devices = (
["cpu:0", "gpu:0"]
if (tf.config.list_logical_devices("GPU"))
else ["cpu:0"]
)
return tf.distribute.experimental.CentralStorageStrategy(
compute_devices, parameter_device="cpu:0"
)
TESTCASES = (
{"testc... | keras/mixed_precision/layer_test.py | 156 | @test_combinations.generate(test_combinations.combine(mode=["graph", "eager"])) | keras | {
"docstring": "Create a CentralStorageStrategy, using a GPU if it is available.",
"language": "en",
"n_whitespaces": 9,
"n_words": 10,
"vocab_size": 9
} | 31 | Python | 25 | 84afc5193d38057e2e2badf9c889ea87d80d8fbf | layer_test.py | 274,999 | 9 | 44 | create_central_storage_strategy | https://github.com/keras-team/keras.git | Reformatting the codebase with black.
PiperOrigin-RevId: 450093126 | 77 | 1 | 81,282 | 12 |
1 | 21 | def decode_predictions(preds, top=5):
return imagenet_utils.decode_predictions(preds, top=top)
preprocess_input.__doc__ = imagenet_utils.PREPROCESS_INPUT_DOC.format(
mode='',
ret=imagenet_utils.PREPROCESS_INPUT_RET_DOC_TF,
error=imagenet_utils.PREPROCESS_INPUT_ERROR_DOC)
decode_predictions.__doc__ = imag... | keras/applications/resnet_rs.py | 205 | keras | {
"docstring": "\n\n Reference:\n [Revisiting ResNets: Improved Training and Scaling Strategies](\n https://arxiv.org/pdf/2103.07579.pdf)\n\n For image classification use cases, see\n [this page for detailed examples](\n https://keras.io/api/applications/#usage-examples-for-image-classification-models).\n\n... | 47 | Python | 30 | c223693db91473c9a71c330d4e38a751d149f93c | resnet_rs.py | 268,893 | 2 | 20 | decode_predictions | https://github.com/keras-team/keras.git | KERAS application addition of Resnet-RS model | 48 | 0 | 79,758 | 8 | |
4 | 2 | def all_nodes(self):
| jina/serve/runtimes/gateway/graph/topology_graph.py | 13 | jina | {
"docstring": "\n The set of all the nodes inside this Graph\n\n :return: A list of nodes\n ",
"language": "en",
"n_whitespaces": 36,
"n_words": 14,
"vocab_size": 12
} | 2 | Python | 2 | ef662b529b2a2eecea7bb99759a9f7b9d86d3062 | topology_graph.py | 12,505 | 11 | 69 | all_nodes | https://github.com/jina-ai/jina.git | feat: add grpc health checking (#4779) | 9 | 0 | 2,324 | 6 | |
11 | 60 | def filtered_queryset(self):
qs = self.model.objects.all()
# FIXME: the following fields will be attached to the wrong object
# if they are included in prefetch_related because of
# https://github.com/django-polymorphic/django-polymorphic/issues/68
# 'job_template', 'job... | awx/main/access.py | 665 | awx | {
"docstring": "\n The full set is returned if the user is:\n - System Administrator\n - System Auditor\n These users will be able to see orphaned activity stream items\n (the related resource has been deleted), as well as the other\n obscure cases listed here\n\n Co... | 167 | Python | 99 | e87e041a2a2a6d168a84d3eeea6664985f1c8ab8 | access.py | 82,255 | 53 | 404 | filtered_queryset | https://github.com/ansible/awx.git | Break up and conditionally add the RBAC checks for ActivityStream (#13279)
This should vastly improve the queries executed when accessing any of
the activity stream endpoints as a normal user, in many cases. | 753 | 0 | 17,336 | 21 | |
11 | 35 | def read_packet(self, size=CAN_MTU):
# type: (int) -> Optional[Packet]
line = self.f.readline()
line = line.lstrip()
if len(line) < 16:
raise EOFError
is_log_file_format = orb(line[0]) == orb(b"(")
fd_flags = None
if is_log_file_format:
... | scapy/layers/can.py | 500 | scapy | {
"docstring": "Read a packet from the specified file.\n\n This function will raise EOFError when no more packets are available.\n\n :param size: Not used. Just here to follow the function signature for\n SuperSocket emulation.\n :return: A single packet read from the file or ... | 146 | Python | 77 | ada91610ad55339bce4d84bc7d5e44ee1cab0c6f | can.py | 209,950 | 40 | 312 | read_packet | https://github.com/secdev/scapy.git | Add support of CANFD (#3782)
* Add support of CANFD
Co-authored-by: superuserx
* fix tests
* fix flake
* fix test
* fix test for python2
* fix test for python2
* fix test for python2
Co-authored-by: superuserx <a@b.com>
Co-authored-by: Nils Weiss <nils@dissec.to> | 554 | 0 | 52,837 | 14 | |
3 | 9 | def _set_speaker_encoder_paths_from_tts_config(self):
if hasattr(self.tts_config, "model_args") and hasattr(
self.tts_config.model_args, "speaker_encoder_config_path"
):
self.encoder_checkpoint = self.tts_config.model_args.speaker_encoder_model_path
self.enco... | TTS/utils/synthesizer.py | 82 | TTS | {
"docstring": "Set the encoder paths from the tts model config for models with speaker encoders.",
"language": "en",
"n_whitespaces": 13,
"n_words": 14,
"vocab_size": 13
} | 16 | Python | 15 | 8fd1ee1926a956a146188179baee143ef11a003d | synthesizer.py | 261,841 | 6 | 49 | _set_speaker_encoder_paths_from_tts_config | https://github.com/coqui-ai/TTS.git | Print urls when BadZipError | 70 | 0 | 77,026 | 11 | |
1 | 13 | def alg_field_from_poly(self, poly, alias=None, root_index=-1):
r
from sympy.polys.rootoftools import CRootOf
root = CRootOf(poly, root_index)
alpha = AlgebraicNumber(root, alias=alias)
return self.algebraic_field(alpha, alias=alias)
| sympy/polys/domains/domain.py | 81 | sympy | {
"docstring": "\n Convenience method to construct an algebraic extension on a root of a\n polynomial, chosen by root index.\n\n Parameters\n ==========\n\n poly : :py:class:`~.Poly`\n The polynomial whose root generates the extension.\n alias : str, optional (defa... | 21 | Python | 19 | 1af5040d2466d2e6455eb07454f7da8dd345a9b8 | domain.py | 197,778 | 41 | 55 | alg_field_from_poly | https://github.com/sympy/sympy.git | Support `alias` for prim. elt. of `AlgebraicField` | 55 | 0 | 48,688 | 9 | |
14 | 35 | def _update_defaults(self, defaults):
# type: (Dict[str, Any]) -> Dict[str, Any]
# Accumulate complex default state.
self.values = optparse.Values(self.defaults)
late_eval = set()
# Then set the options with those values
for key, val in self._get_ordered_configu... | .venv/lib/python3.8/site-packages/pip/_internal/cli/parser.py | 518 | transferlearning | {
"docstring": "Updates the given defaults with values from the config files and\n the environ. Does a little special handling for certain types of\n options (lists).",
"language": "en",
"n_whitespaces": 37,
"n_words": 24,
"vocab_size": 22
} | 254 | Python | 148 | f638f5d0e6c8ebed0e69a6584bc7f003ec646580 | parser.py | 60,539 | 47 | 308 | _update_defaults | https://github.com/jindongwang/transferlearning.git | upd; format | 1,029 | 0 | 12,199 | 18 | |
1 | 21 | def test_start_new_processes_with_same_filepath(self):
manager = DagFileProcessorManager(
dag_directory='directory',
max_runs=1,
processor_timeout=timedelta(days=365),
signal_conn=MagicMock(),
dag_ids=[],
pickle_dags=False,
... | tests/dag_processing/test_manager.py | 185 | airflow | {
"docstring": "\n Test that when a processor already exist with a filepath, a new processor won't be created\n with that filepath. The filepath will just be removed from the list.\n ",
"language": "en",
"n_whitespaces": 50,
"n_words": 28,
"vocab_size": 22
} | 105 | Python | 71 | 18da1217d7ae593ff33c681353b027fac9252523 | test_manager.py | 46,452 | 19 | 110 | test_start_new_processes_with_same_filepath | https://github.com/apache/airflow.git | Replace timedelta.max with year long timdelta in test_manager (#22527)
Timedelta.max used in tests is not realistic and in some
circumstances, when it is added to date, it might cause
date OverflowError. Using long (but not 999999999 days long)
timedelta solves the problem. | 315 | 0 | 8,892 | 12 | |
1 | 8 | def search(self, value, user=None, object_types=None, lookup=DEFAULT_LOOKUP_TYPE):
raise NotImplementedError
| netbox/netbox/search/backends.py | 33 | netbox | {
"docstring": "\n Search cached object representations for the given value.\n ",
"language": "en",
"n_whitespaces": 23,
"n_words": 8,
"vocab_size": 8
} | 8 | Python | 8 | 9628dead07ccef9608b32906aa8194bc948e5a09 | backends.py | 265,890 | 2 | 22 | search | https://github.com/netbox-community/netbox.git | Closes #10560: New global search (#10676)
* Initial work on new search backend
* Clean up search backends
* Return only the most relevant result per object
* Clear any pre-existing cached entries on cache()
* #6003: Implement global search functionality for custom field values
* Tweak field weights & do... | 22 | 0 | 78,230 | 6 | |
7 | 59 | def call_load(self, other_args):
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="load",
description=,
)
parser.add_argument(
"-c",
"--coin",
... | openbb_terminal/parent_classes.py | 791 | OpenBBTerminal | {
"docstring": "Process load command.Load crypto currency to perform analysis on.\n Yahoo Finance is used as default source.\n Other sources can be used such as 'ccxt' or 'cg' with --source.\n If you select 'ccxt', you can then select any exchange with --exchange.\n You can... | 198 | Python | 141 | 46141766d7250671b7bc75872e2034afe4938374 | parent_classes.py | 286,499 | 99 | 486 | call_load | https://github.com/OpenBB-finance/OpenBBTerminal.git | Sdk dates (#3354)
* example changes in slopes
* change lettering size and side bar capitalization
* revert back to Fira
* start automatic website generation
* this was autogen
* add examples to slopes model
* generate slopes doc
* change to _index.md
* allow italic formatting
* fix regex
... | 1,328 | 0 | 85,834 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.