n_words
int64 3
1.95k
| n_ast_errors
int64 0
2
| complexity
int64 1
151
| nloc
int64 2
546
| path
stringlengths 8
125
| id
int64 280
339k
| commit_message
stringlengths 3
18.1k
| repo
stringlengths 3
28
| ast_levels
int64 4
28
| language
stringclasses 1
value | vocab_size
int64 3
677
| file_name
stringlengths 5
67
| code
stringlengths 101
24k
| commit_id
stringlengths 40
40
| ast_errors
stringlengths 0
2.76k
| token_counts
int64 7
3.77k
| url
stringlengths 31
61
| n_whitespaces
int64 4
13.9k
| random_cut
stringlengths 21
13.9k
| n_identifiers
int64 1
157
| n_ast_nodes
int64 10
3.6k
| fun_name
stringlengths 3
72
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
13 | 0 | 2 | 5 | mkdocs/config/config_options.py | 224,959 | Add `edit_uri_template` config | mkdocs | 11 | Python | 13 | config_options.py | def run_validation(self, value):
try:
return self.Template(self.Formatter(), value)
except Exception as e:
raise ValidationError(e)
| ad43f1b8b7c5280dd8679af1d9624eed3b1bce1b | 32 | https://github.com/mkdocs/mkdocs.git | 48 | def run_validation(self, value):
try | 8 | 52 | run_validation |
|
15 | 0 | 3 | 7 | test/mitmproxy/proxy/layers/http/test_http3.py | 253,135 | [quic] first test for H3 | mitmproxy | 13 | Python | 15 | test_http3.py | def __rshift__(self, e):
if isinstance(e, collections.abc.Iterable):
for e_i in e:
super().__rshift__(e_i)
else:
super().__rshift__(e)
return self
| a308d3dabcbb938a79902bfd02cf2be0b711c308 | 44 | https://github.com/mitmproxy/mitmproxy.git | 72 | def __rshift__(self, e):
if isinstance(e, collections.abc.Iterable):
for e_i in e:
super().__rshift__(e_i)
else:
| 9 | 71 | __rshift__ |
|
9 | 0 | 1 | 7 | tests/unit/browser/test_qutescheme.py | 321,809 | Add --include-hidden for :config-diff
Needed it for debugging, so why not implement it properly.
TODO: Changelog, pick to master? | qutebrowser | 11 | Python | 9 | test_qutescheme.py | def prepare_config(self, config_stub):
config_stub.set_obj(
"content.javascript.enabled",
True,
pattern=urlmatch.UrlPattern("chrome-devtools://*"),
hide_userconfig=True,
)
| ed19d7f58b2664bb310c7cb6b52c5b9a06ea60b2 | 29 | https://github.com/qutebrowser/qutebrowser.git | 66 | def prepare_config(self, config_stub):
config_stub.set_obj(
"content.javascript.enabled",
True,
pattern=urlmatch.UrlPattern(" | 8 | 46 | prepare_config |
|
26 | 0 | 4 | 8 | tests/unit/test_mongodb_server.py | 116,224 | fix test concurrency: imported executor_commands didn't allow to mock SQLQuery inside MongoServer | mindsdb | 11 | Python | 23 | test_mongodb_server.py | def unload_module(path):
# remove all modules started with path
import sys
to_remove = []
for module_name in sys.modules:
if module_name.startswith(path):
to_remove.append(module_name)
for module_name in to_remove:
sys.modules.pop(module_name)
| d58879d9595ca64a4d9ef22ec81c3d3b9d4de864 | 45 | https://github.com/mindsdb/mindsdb.git | 65 | def unload_module(path):
# remove all modules started with path
import sys
to_remove = []
for module_name in sys.modules:
if module_na | 9 | 74 | unload_module |
|
92 | 0 | 5 | 40 | tests/embedding_test_utils.py | 214,899 | unify embedding tests | flair | 18 | Python | 48 | embedding_test_utils.py | def test_keep_batch_order(self):
embeddings = self.create_embedding_with_args(self.default_args)
embedding_names = embeddings.get_names()
sentences_1 = [Sentence("First sentence"), Sentence("This is second sentence")]
sentences_2 = [Sentence("This is second sentence"), Sentence("First sentence")]
embeddings.embed(sentences_1)
embeddings.embed(sentences_2)
assert sentences_1[0].to_original_text() == "First sentence"
assert sentences_1[1].to_original_text() == "This is second sentence"
if self.is_document_embedding:
assert (
torch.norm(
sentences_1[0].get_embedding(embedding_names) - sentences_2[1].get_embedding(embedding_names)
)
== 0.0
)
assert (
torch.norm(
sentences_1[1].get_embedding(embedding_names) - sentences_2[0].get_embedding(embedding_names)
)
== 0.0
)
if self.is_token_embedding:
for i in range(len(sentences_1[0])):
assert (
torch.norm(
sentences_1[0][i].get_embedding(embedding_names)
- sentences_2[1][i].get_embedding(embedding_names)
)
== 0.0
)
for i in range(len(sentences_1[1])):
assert (
torch.norm(
sentences_1[1][i].get_embedding(embedding_names)
- sentences_2[0][i].get_embedding(embedding_names)
)
== 0.0
)
del embeddings
| 98cbbaffd1bc0c191951e0b09c4f9ff8e083a61c | 258 | https://github.com/flairNLP/flair.git | 628 | def test_keep_batch_order(self):
embeddings | 20 | 396 | test_keep_batch_order |
|
19 | 0 | 3 | 6 | erpnext/loan_management/doctype/loan_balance_adjustment/loan_balance_adjustment.py | 69,025 | feat: add adjustment amount to loan
- fix: bugs in loan balance adjustment | erpnext | 12 | Python | 13 | loan_balance_adjustment.py | def validate(self):
if self.amount == 0:
frappe.throw(_("Amount cannot be zero"))
if self.amount < 0:
frappe.throw(_("Amount cannot be negative"))
self.set_missing_values()
| 5c0a25012c602ed0d47136468e3b0bee11ddf5dd | 42 | https://github.com/frappe/erpnext.git | 61 | def validate(self):
if self.amount == 0:
frappe.throw(_("Amount cannot be zero"))
if self.amount < 0:
frappe.throw(_("Amount cannot be negative"))
self.set_missing_values()
| 7 | 74 | validate |
|
54 | 0 | 7 | 17 | apps/users/serializers/user.py | 188,559 | fix: 修复创建更新用户给定默认权限 | jumpserver | 17 | Python | 39 | user.py | def save_and_set_custom_m2m_fields(self, validated_data, save_handler, created):
m2m_values = {}
for f, default_roles in self.custom_m2m_fields.items():
roles = validated_data.pop(f, None)
if created and not roles:
roles = [
Role.objects.filter(id=role.id).first()
for role in default_roles
]
m2m_values[f] = roles
instance = save_handler(validated_data)
for field_name, value in m2m_values.items():
if value is None:
continue
field = getattr(instance, field_name)
field.set(value)
return instance
| a930f3aab3b7b084a5fb4b60fd1b8722fee890be | 113 | https://github.com/jumpserver/jumpserver.git | 237 | def save_and_set_custom_m2m_fields(self, validated_data, save_handler, created):
m2m_values = {}
for f, default_roles in self.custom_m2m_fields.items():
roles = validated_data.pop(f, None)
if created and not roles:
roles = [
Role.objects.filter(id=role.id).first()
| 24 | 175 | save_and_set_custom_m2m_fields |
|
25 | 0 | 2 | 10 | python/ray/air/checkpoint.py | 137,357 | [AIR] `Checkpoint` improvements (#30948)
Boston dataset (used in tests) is/will be removed from sklearn.
Signed-off-by: Antoni Baum <antoni.baum@protonmail.com>
Co-authored-by: Balaji Veeramani <bveeramani@berkeley.edu> | ray | 9 | Python | 23 | checkpoint.py | def to_bytes(self) -> bytes:
# Todo: Add support for stream in the future (to_bytes(file_like))
data_dict = self.to_dict()
if "bytes_data" in data_dict:
return data_dict["bytes_data"]
return pickle.dumps(data_dict)
| 3a1bee28a19e81416ec2f2112cb6dcbc6e7ab845 | 32 | https://github.com/ray-project/ray.git | 71 | def to_bytes(self) -> bytes:
| 7 | 59 | to_bytes |
|
21 | 1 | 1 | 5 | tests/maskformer/test_feature_extraction_maskformer.py | 35,928 | Tests for MaskFormerFeatureExtractor's post_process*** methods (#15929)
* proper tests for post_process*** methods in feature extractor
* mask th == 0
* Update tests/maskformer/test_feature_extraction_maskformer.py
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
* make style
Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> | transformers | 13 | Python | 20 | test_feature_extraction_maskformer.py | def get_fake_maskformer_outputs(self):
return MaskFormerForInstanceSegmentationOutput(
# +1 for null class
class_queries_logits=torch.randn((self.batch_size, self.num_queries, self.num_classes + 1)),
masks_queries_logits=torch.randn((self.batch_size, self.num_queries, self.height, self.width)),
)
@require_torch
@require_vision | 040c11f6dac72bc3088498aa19184da677563424 | @require_torch
@require_vision | 57 | https://github.com/huggingface/transformers.git | 65 | def get_fake_maskformer_outputs(self):
return MaskFormerForInstanceSegmentationOutput(
# +1 for n | 14 | 90 | get_fake_maskformer_outputs |
38 | 1 | 4 | 11 | jax/_src/numpy/linalg.py | 119,733 | remove `_convert_element_type` from public `jax.lax` module | jax | 10 | Python | 29 | linalg.py | def _promote_arg_dtypes(*args):
dtype, weak_type = dtypes._lattice_result_type(*args)
if not jnp.issubdtype(dtype, jnp.inexact):
dtype, weak_type = jnp.float_, False
dtype = dtypes.canonicalize_dtype(dtype)
args = [lax_internal._convert_element_type(arg, dtype, weak_type)
for arg in args]
if len(args) == 1:
return args[0]
else:
return args
@_wraps(np.linalg.cholesky)
@jit | 8f93629e8780148511ad60d3f7e034ebf4319d9b | @_wraps(np.linalg.cholesky)
@jit | 83 | https://github.com/google/jax.git | 61 | def _promote_arg_dtypes(*args):
dtype, weak_type = dtypes._lattice_result_type(*args)
if not jnp.issubdtype(dtype, jnp.inexact):
dtype, weak_type = jnp.float_, False
dtype = dtypes.canonicalize_dtype(dtype)
args = [lax_internal._convert_element_type(arg, dtype, weak_type)
| 20 | 150 | _promote_arg_dtypes |
55 | 0 | 4 | 21 | bootloader/waflib/Tools/c_config.py | 263,260 | Bootloader: Building: Unpack waf's lib archive.
Doing so makes it easier to modify. This is a temporary measure until the next
waf version is released (although I'm tempted to keep it since it's much more
IDE completion friendly). | pyinstaller | 14 | Python | 36 | c_config.py | def check(self, *k, **kw):
self.validate_c(kw)
self.start_msg(kw['msg'], **kw)
ret = None
try:
ret = self.run_build(*k, **kw)
except self.errors.ConfigurationError:
self.end_msg(kw['errmsg'], 'YELLOW', **kw)
if Logs.verbose > 1:
raise
else:
self.fatal('The configuration failed')
else:
kw['success'] = ret
ret = self.post_check(*k, **kw)
if not ret:
self.end_msg(kw['errmsg'], 'YELLOW', **kw)
self.fatal('The configuration failed %r' % ret)
else:
self.end_msg(self.ret_msg(kw['okmsg'], kw), **kw)
return ret
| 64ccb7aea824fbec57f7ed1bbe483ec486183c13 | 152 | https://github.com/pyinstaller/pyinstaller.git | 162 | def check(self, *k, **kw):
self.validate_c(kw)
self.start_msg(kw['msg'], **kw)
ret = None
try:
ret = self.run_build(*k, **kw)
except self.errors.ConfigurationError:
self.end_msg(kw['errmsg'], 'YELLOW', **kw)
if Logs.verbose > 1:
raise
else:
self.fatal('The configuration failed')
else:
| 16 | 256 | check |
|
8 | 1 | 1 | 2 | tests/openbb_terminal/test_keys_controller.py | 284,196 | openbb_terminal tests: coverage (61% -> 65%) (#1664)
* Attempting more tests
* Began adding tests
* Added keys controller tests
* Added tests for settings and econometrics controller
* Prevented tests from changing .env files
* Fixed issues with tests
* Added econometrics tests
* fixed pylint issues
* Added folder
* Added QA tests
* Fixed qa tests
* Fixed qa tests
* Fixed tests
* Removed skip
* Added mock to tests
* Update helper_funcs.py
Fix any windows path issues
* Update helper_funcs.py
oops forgot import lol
* Skipped display_hist
* expanded tests
* Maybe mocked matplotlib everywhere
Co-authored-by: teh_coderer <me@tehcoderer.com> | OpenBBTerminal | 9 | Python | 8 | test_keys_controller.py | def test_call_bitquery(other):
controller.call_bitquery(other)
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]]) | 8994168e45c91698e4fd20c862e11c9b55e0d03b | @pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]]) | 11 | https://github.com/OpenBB-finance/OpenBBTerminal.git | 9 | def test_call_bitquery(other):
controller.call_bitquery(other)
@pytest.mark.parametr | 7 | 61 | test_call_bitquery |
9 | 0 | 1 | 3 | src/datasets/features/features.py | 106,051 | Clean up remaining Main Classes docstrings (#5349)
clean up docstrings | datasets | 8 | Python | 9 | features.py | def encode_example(self, example):
example = cast_to_python_objects(example)
return encode_nested_example(self, example)
| c78559cacbb0ca6e0bc8bfc313cc0359f8c23ead | 21 | https://github.com/huggingface/datasets.git | 30 | def encode_example(self, example):
example = cast_to_python_objects(example)
return encode_nested_ | 5 | 35 | encode_example |
|
12 | 0 | 1 | 6 | tests/admin_views/tests.py | 207,686 | Refs #33476 -- Reformatted code with Black. | django | 14 | Python | 12 | tests.py | def test_basic_edit_GET(self):
response = self.client.get(
reverse("admin:admin_views_section_change", args=(self.s1.pk,))
)
self.assertIsInstance(response, TemplateResponse)
self.assertEqual(response.status_code, 200)
| 9c19aff7c7561e3a82978a272ecdaad40dda5c00 | 48 | https://github.com/django/django.git | 58 | def test_basic_edit_GET(self):
response = self.client.get(
reverse("admin:admin_views_section_change", args=(self.s1.pk,))
)
self.assertIsInstance(response, TemplateResponse)
self.assertEqual(response | 13 | 78 | test_basic_edit_GET |
|
37 | 0 | 4 | 8 | modules/image/text_to_image/disco_diffusion_cnclip_vitb16/reverse_diffusion/model/transforms.py | 49,857 | add disco_diffusion_cnclip_vitb16 module | PaddleHub | 13 | Python | 33 | transforms.py | def _setup_angle(x, name, req_sizes=(2, )):
if isinstance(x, numbers.Number):
if x < 0:
raise ValueError(f"If {name} is a single number, it must be positive.")
x = [-x, x]
else:
_check_sequence_input(x, name, req_sizes)
return [float(d) for d in x]
| f4d6e64cdc132ae868699a0ba442f4ab1d304a14 | 64 | https://github.com/PaddlePaddle/PaddleHub.git | 77 | def _setup_angle(x, name, req_sizes=(2, )):
if isinstance(x, num | 11 | 100 | _setup_angle |
|
10 | 0 | 1 | 3 | homeassistant/components/yale_smart_alarm/lock.py | 293,194 | Code cleanup yale_smart_alarm (#67701) | core | 9 | Python | 10 | lock.py | async def async_lock(self, **kwargs) -> None:
return await self.async_set_lock("locked", None)
| 1358aed01641292805c94e0d3c50ec097df86746 | 21 | https://github.com/home-assistant/core.git | 24 | async def async_lock(self, **kwargs) -> None:
return await self.as | 4 | 38 | async_lock |
|
25 | 0 | 1 | 13 | tests/acceptance/test_organization_group_index.py | 96,338 | feat(ui): Remove issues from issue stream when action taken (#31701)
* feat(ui): Remove issues from issue stream when action taken
Remove issues from the issue stream when an action like Resolve, Ignore, or Delete is taken on the issue. This will remove the issue from the stream and bring in an issue from the next page (if applicable) and will not refresh the page.
FIXES WOR-1588
* refactor so resolved, ignored, and deleted issues are removed immediately
* refactor marked reviewed group id removal
* add acceptance tests | sentry | 11 | Python | 23 | test_organization_group_index.py | def test_resolve_issues_multi_projects(self, mock_now):
mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
self.create_issues()
group1 = self.event_a.group
with self.feature("organizations:global-views"):
self.page.visit_issue_list(self.org.slug)
self.page.wait_for_stream()
self.page.select_issue(1)
self.page.resolve_issues()
group1.update(status=GroupStatus.RESOLVED)
self.page.wait_for_issue_removal()
groups = self.browser.elements('[data-test-id="event-issue-header"]')
assert len(groups) == 1
| 36196bd7178783a0b78c8bda39b76e4fa6b1a5e6 | 113 | https://github.com/getsentry/sentry.git | 140 | def test_resolve_issues_multi_projects(self, mock_now):
mock_now.return_value = datetime.utcnow().replace(tzinfo=pytz.utc)
self.create_issues()
group1 = self.event_a.group
with self.feature("organizations:global-views"):
self.page.visit_issue_list(self.org.slug)
self.page.wait_for_stream()
self.page.select_issue(1)
self.page.resolve_issues()
group1.update(status=GroupStatus.RESOLVED)
self.page.wait_f | 31 | 190 | test_resolve_issues_multi_projects |
|
35 | 0 | 4 | 15 | gamestonk_terminal/portfolio/portfolio_analysis/yfinance_model.py | 281,382 | Step towards portfolio allocation analysis (#1134)
* Making pa active + pa minor features
Makes pa actice and adds country to the df. The groupby command also gets percents of holding allocation. It also fixes warnings and prepares for a later pr that I'm currently working on.
* Fix linting
* black linter
* Fixes
Should fix everything
* Linting
* Making pa controller to base class standard
* Fix linting
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt> | OpenBBTerminal | 14 | Python | 24 | yfinance_model.py | def get_country(ticker):
country = "NA"
data = yf.utils.get_json(f"https://finance.yahoo.com/quote/{ticker}")
if "summaryProfile" in data:
country = data["summaryProfile"]["country"]
if country not in financedatabase_model.get_countries():
similar_cmd = difflib.get_close_matches(
country,
financedatabase_model.get_countries(),
n=1,
cutoff=0.7,
)
if similar_cmd:
country = similar_cmd[0]
return country
| f77ad02d24c0ecf515a9f42c128d0c3158cc7d27 | 79 | https://github.com/OpenBB-finance/OpenBBTerminal.git | 168 | def get_country(ticker):
country = "NA"
data = yf.utils.get_json(f"https://finance.yahoo.com/quote/{ticker}")
if "summaryProfile" in data:
country = data["summaryProfile"]["country"]
if country not in financedatabase_model.get_countries():
similar_cmd = difflib.get_close_matches(
country,
financedatabase_model.get_cou | 14 | 131 | get_country |
|
69 | 1 | 1 | 12 | tests/test_css_parse.py | 181,987 | Separate parsing of scalar, number, duration | textual | 11 | Python | 44 | test_css_parse.py | def test_parse_offset_composite_rule(offset_x, parsed_x, offset_y, parsed_y):
css = f
stylesheet = Stylesheet()
stylesheet.parse(css)
styles = stylesheet.rules[0].styles
assert len(stylesheet.rules) == 1
assert stylesheet.rules[0].errors == []
assert styles.offset.x == parsed_x
assert styles.offset.y == parsed_y
@pytest.mark.parametrize(
"offset_x, parsed_x, offset_y, parsed_y",
[
[
"-5.5%",
Scalar(-5.5, Unit.PERCENT, Unit.WIDTH),
"-30%",
Scalar(-30, Unit.PERCENT, Unit.HEIGHT),
],
[
"5%",
Scalar(5, Unit.PERCENT, Unit.WIDTH),
"40%",
Scalar(40, Unit.PERCENT, Unit.HEIGHT),
],
[
"10",
Scalar(10, Unit.CELLS, Unit.WIDTH),
"40",
Scalar(40, Unit.CELLS, Unit.HEIGHT),
],
],
) | fd47ef491b7700a4414d85bf573f1e719cfae555 | @pytest.mark.parametrize(
"offset_x, parsed_x, offset_y, parsed_y",
[
[
"-5.5%",
Scalar(-5.5, Unit.PERCENT, Unit.WIDTH),
"-30%",
Scalar(-30, Unit.PERCENT, Unit.HEIGHT),
],
[
"5%",
Scalar(5, Unit.PERCENT, Unit.WIDTH),
"40%",
Scalar(40, Unit.PERCENT, Unit.HEIGHT),
],
[
"10",
Scalar(10, Unit.CELLS, Unit.WIDTH),
"40",
Scalar(40, Unit.CELLS, Unit.HEIGHT),
],
],
) | 73 | https://github.com/Textualize/textual.git | 273 | def test_parse_offset_composite_rule(offset_x, parsed_x, offset_y, parsed_y):
css = f
stylesheet = Stylesheet()
stylesheet.parse(css)
styles = stylesheet.rules[0].styles
assert len(stylesheet.rules) == 1
assert stylesheet.rules[0].errors == []
assert styles.offset.x == parsed_x
assert styles.offset.y == parsed_y
@pytest.mark.parametrize(
"offset_x, parsed_x, offset_y, parsed_y",
[
[
"-5.5%",
Scalar(-5.5, Unit.PERCENT, Unit.WIDTH),
"-30%",
Scalar(-30, Unit.PERCENT, Unit.HEIGHT),
],
[
"5%",
Scalar(5, Unit.PERCENT, Unit.WIDTH),
"40%",
Scalar(40, Unit.PERCENT, Unit.HEIGHT),
],
[
"10",
Scalar(10, Unit.CELLS, Unit.WIDTH),
"40",
Scalar(40, Unit.CELLS, Unit.HEIGHT),
] | 25 | 286 | test_parse_offset_composite_rule |
75 | 0 | 4 | 18 | haystack/modeling/model/adaptive_model.py | 257,083 | Pylint (import related warnings) and REST API improvements (#2326)
* remove duplicate imports
* fix ungrouped-imports
* Fix wrong-import-position
* Fix unused-import
* pyproject.toml
* Working on wrong-import-order
* Solve wrong-import-order
* fix Pool import
* Move open_search_index_to_document_store and elasticsearch_index_to_document_store in elasticsearch.py
* remove Converter from modeling
* Fix mypy issues on adaptive_model.py
* create es_converter.py
* remove converter import
* change import path in tests
* Restructure REST API to not rely on global vars from search.apy and improve tests
* Fix openapi generator
* Move variable initialization
* Change type of FilterRequest.filters
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | haystack | 17 | Python | 65 | adaptive_model.py | def convert_to_transformers(self):
converted_models = []
# convert model for each prediction head
for prediction_head in self.prediction_heads:
if len(prediction_head.layer_dims) != 2:
logger.error(
f"Currently conversion only works for PredictionHeads that are a single layer Feed Forward NN with dimensions [LM_output_dim, number_classes].\n"
f" Your PredictionHead has {str(prediction_head.layer_dims)} dimensions."
)
continue
if prediction_head.model_type == "span_classification":
transformers_model = self._convert_to_transformers_qa(prediction_head)
converted_models.append(transformers_model)
else:
logger.error(
f"Haystack -> Transformers conversion is not supported yet for"
f" prediction heads of type {prediction_head.model_type}"
)
return converted_models
| 96a538b18238ce723208cd18a1c11034ee5a90d1 | 71 | https://github.com/deepset-ai/haystack.git | 335 | def convert_to_transformers(self):
converted_models = []
# convert model for each prediction head
for prediction_head in self.prediction_heads:
if len(prediction_head.layer_dims) != 2:
logger.error(
f"Currently conversion only works for PredictionHeads that are a single layer Feed Forward NN with dimensions [LM_output_dim, number_classes].\n"
f" Your PredictionHead has {str(prediction_head.layer_dims)} dimensions."
)
continue
if prediction_head.model_type == "span_classification":
transformers_model = self._convert_to_transformers_qa(prediction_head)
converted_models.appe | 14 | 144 | convert_to_transformers |
|
12 | 0 | 1 | 2 | sympy/printing/smtlib.py | 199,414 | Implement preliminary Sympy to SMT-Lib printer. | sympy | 11 | Python | 12 | smtlib.py | def emptyPrinter(self, expr):
raise NotImplementedError(f'Cannot convert `{repr(expr)}` of type `{type(expr)}` to SMT.')
| c41964db333afe27571ac399e823df29063d8c83 | 13 | https://github.com/sympy/sympy.git | 18 | def emptyPrinter(self, expr):
raise NotImplementedError(f'Cannot convert `{repr(expr)}` of type `{type | 6 | 39 | emptyPrinter |
|
28 | 0 | 5 | 9 | python3.10.4/Lib/_collections_abc.py | 219,505 | add python 3.10.4 for windows | XX-Net | 9 | Python | 19 | _collections_abc.py | def __le__(self, other):
if not isinstance(other, Set):
return NotImplemented
if len(self) > len(other):
return False
for elem in self:
if elem not in other:
return False
return True
| 8198943edd73a363c266633e1aa5b2a9e9c9f526 | 46 | https://github.com/XX-net/XX-Net.git | 103 | def __le__(self, other):
if not isinstance(other, Set):
return NotImplemented
if len(self) > len(other):
| 8 | 71 | __le__ |
|
84 | 0 | 6 | 37 | src/textual/widget.py | 183,081 | button widget | textual | 14 | Python | 50 | widget.py | def render_styled(self) -> RenderableType:
renderable = self.render()
styles = self.styles
parent_styles = self.parent.styles
parent_text_style = self.parent.rich_text_style
text_style = styles.rich_style
content_align = (styles.content_align_horizontal, styles.content_align_vertical)
if content_align != ("left", "top"):
horizontal, vertical = content_align
renderable = Align(renderable, horizontal, vertical=vertical)
renderable_text_style = parent_text_style + text_style
if renderable_text_style:
renderable = Styled(renderable, renderable_text_style)
renderable = Padding(renderable, styles.padding, style=renderable_text_style)
if styles.border:
renderable = Border(
renderable,
styles.border,
inner_color=styles.background,
outer_color=Color.from_rich_color(parent_text_style.bgcolor),
)
if styles.outline:
renderable = Border(
renderable,
styles.outline,
inner_color=styles.background,
outer_color=parent_styles.background,
outline=True,
)
if styles.opacity != 1.0:
renderable = Opacity(renderable, opacity=styles.opacity)
return renderable
| 44c1f2373aaa61c5262882a61064fa5c084ae21e | 194 | https://github.com/Textualize/textual.git | 412 | def render_styled(self) -> RenderableType:
renderable = self.render()
styles = self.styles
parent_styles = self.parent.styles
pare | 34 | 294 | render_styled |
|
39 | 0 | 1 | 13 | erpnext/patches/v13_0/shopping_cart_to_ecommerce.py | 64,272 | fix: remove stale doctypes and add msg for ecommerce refactor (#27700) | erpnext | 9 | Python | 34 | shopping_cart_to_ecommerce.py | def notify_users():
click.secho(
"Shopping cart and Product settings are merged into E-commerce settings.\n"
"Checkout the documentation to learn more:"
"https://docs.erpnext.com/docs/v13/user/manual/en/e_commerce/set_up_e_commerce",
fg="yellow",
)
note = frappe.new_doc("Note")
note.title = "New E-Commerce Module"
note.public = 1
note.notify_on_login = 1
note.content =
note.save()
| bd3b47fd5081dc592850001ff077bffb0ed3fdb9 | 50 | https://github.com/frappe/erpnext.git | 27 | def notify_users():
click.secho(
"Shopping cart and | 12 | 96 | notify_users |
|
21 | 0 | 3 | 17 | mitmproxy/proxy/mode_servers.py | 252,972 | add transparent server mode based on WireGuard (#5562)
* add mode spec for WireGuard mode
* add WireGuard server implementation
* remove coverage excludes
* simplify wireguard spec
* lint!
* remove superfluous tests
* bump to mitmproxy_wireguard 0.1.1
* proxy/test_mode_specs: remove unused import
* fix wireguard server mode
* WireGuard: move keyfile gen into `.start()`
This way any file format errors result in `.last_exception` being set.
* fixup UDP support
* bump to mitmproxy_wireguard v0.1.2
This release fixes TCP connections which were broken in v0.1.1.
* fix crash handler
* add simple test for WireGuard server instances
* bump to mitmproxy_wireguard v0.1.5 and fix launching wg-test-client
* fixups
- monkeypatch `handle_client` instead of the handlers.
- fix OS detection
- ctx.log -> logging
* nits
* bump to mitmproxy_wireguard 0.1.6 for fixed test client
* move WireGuardDatagramTransport into dedicated module
this allows us to exclude it from individual coverage, which makes no sense.
Also improve type checking to make sure that it's a full replacement.
* cover WireGuardServerInstance.is_running property with tests
* enable specialized server instance creation
* test wireguard conf generation
* deduplicate tcp/udp handlers
* update CHANGELOG
Co-authored-by: Maximilian Hils <git@maximilianhils.com> | mitmproxy | 14 | Python | 19 | mode_servers.py | def client_conf(self) -> str | None:
if not self._server:
return None
host = local_ip.get_local_ip() or local_ip.get_local_ip6()
port = self.mode.listen_port(ctx.options.listen_port)
return textwrap.dedent(f).strip()
| 2d495c093c2e499f2510a3c6d66db7afed7394af | 56 | https://github.com/mitmproxy/mitmproxy.git | 59 | def client_conf(self) -> str | None:
if not self._server:
return None
host = local_ip.get_local_ip() or local_ip.get_local_ip6()
port = self.mode.listen_port(ctx.options.listen_port)
return textwrap.dedent(f).strip()
| 20 | 122 | client_conf |
|
30 | 0 | 1 | 8 | Tests/test_file_gif.py | 242,485 | Convert subsequent frames of L mode GIF to LA if transparency is present | Pillow | 11 | Python | 19 | test_file_gif.py | def test_l_mode_transparency():
with Image.open("Tests/images/no_palette_with_transparency.gif") as im:
assert im.mode == "L"
assert im.load()[0, 0] == 0
assert im.info["transparency"] == 255
im.seek(1)
assert im.mode == "LA"
assert im.load()[0, 0] == (0, 255)
| 5c6212052cc735b5aabc895bb18264143b8408c7 | 71 | https://github.com/python-pillow/Pillow.git | 74 | def test_l_mode_transparency():
with Imag | 8 | 119 | test_l_mode_transparency |
|
42 | 0 | 4 | 10 | torchvision/transforms/transforms.py | 192,097 | Added center arg to F.affine and RandomAffine ops (#5208)
* Added center option to F.affine and RandomAffine ops
* Updates according to the review | vision | 14 | Python | 35 | transforms.py | def forward(self, img):
fill = self.fill
if isinstance(img, Tensor):
if isinstance(fill, (int, float)):
fill = [float(fill)] * F.get_image_num_channels(img)
else:
fill = [float(f) for f in fill]
img_size = F.get_image_size(img)
ret = self.get_params(self.degrees, self.translate, self.scale, self.shear, img_size)
return F.affine(img, *ret, interpolation=self.interpolation, fill=fill, center=self.center)
| 59c723cb45d0f8ab897cc7836d408e9fdde4b552 | 120 | https://github.com/pytorch/vision.git | 136 | def forward(self, img):
fill = self.fill
if isinstance(img, Tensor):
if isinstance(fill, (int, float)):
fill = [float(fill)] * F.get_image_num_channels(img)
else:
fill = [float(f) for f in fill]
img_size = F.get_image_size(img)
ret = self.get_params(self. | 22 | 180 | forward |
|
48 | 0 | 6 | 13 | misc/tools/postprocess-vf.py | 162,910 | UPM 2048 and opsz axis (#462)
- UPM is adjusted to 2048
- Additional opsz VF axis (multi master) added which will eventually replace the separate Display family
- New tooling that uses fontmake instead of Inter's own fontbuild toolchain. (The old toolchain is still supported, i.e. `make -f Makefile_v1.make ...`) | inter | 13 | Python | 33 | postprocess-vf.py | def get_family_name(font):
nameTable = font["name"]
r = None
for plat_id, enc_id, lang_id in (WINDOWS_ENGLISH_IDS, MAC_ROMAN_IDS):
for name_id in (PREFERRED_FAMILY, LEGACY_FAMILY):
r = nameTable.getName(nameID=name_id, platformID=plat_id, platEncID=enc_id, langID=lang_id)
if r is not None:
break
if r is not None:
break
if not r:
raise ValueError("family name not found")
return r.toUnicode()
| 07960766590650e516a75ce6ceba91b68a5fa551 | 87 | https://github.com/rsms/inter.git | 83 | def get_family_name(font):
nameTable = font["name"]
r = None
for plat_id, enc_id, lang_id in (WINDOWS_ENGLISH_IDS | 19 | 134 | get_family_name |
|
43 | 0 | 1 | 5 | awx/main/tests/unit/test_capacity.py | 81,109 | Remove committed_capacity field, delete supporting code (#12086)
* Remove committed_capacity field, delete supporting code
* Track consumed capacity to solve the negatives problem
* Use more verbose name for IG queryset | awx | 11 | Python | 39 | test_capacity.py | def test_RBAC_reduced_filter(sample_cluster, create_ig_manager):
default, ig_large, ig_small = sample_cluster()
tasks = [Job(status='waiting', execution_node='i1'), Job(status='waiting', execution_node='i2'), Job(status='waiting', execution_node='i3')]
instance_groups_mgr = create_ig_manager([default], tasks)
# Cross-links between groups not visible to current user,
# so a naieve accounting of capacities is returned instead
assert instance_groups_mgr.get_consumed_capacity('default') == 43
| cb63d92bbf5d8e10834264f0eb8142c4eb5c9161 | 72 | https://github.com/ansible/awx.git | 64 | def test_RBAC_reduced_filter(sample_cluster, create_ig_manager):
default, ig_large, ig_small = sample_cluster()
tasks = [Job(status='waiting', execution_node='i1'), Job(status='waiting', execution_node='i2'), Job(status='waiting', execution_node='i3')]
instance_groups_mgr = create_ig_manager([default], tasks)
# Cross-links betwee | 12 | 125 | test_RBAC_reduced_filter |
|
29 | 0 | 1 | 5 | flair/embeddings/token.py | 215,027 | finalize token embeddings | flair | 12 | Python | 25 | token.py | def __getstate__(self):
state = self.__dict__.copy()
# save the sentence piece model as binary file (not as path which may change)
state["spm_model_binary"] = open(self.model_file, mode="rb").read()
state["spm"] = None
return state
| 1de7ddaf9cbfc3db7b043c532e6b8ec63807de1c | 41 | https://github.com/flairNLP/flair.git | 63 | def __getstate__(self):
state = self.__dict__.copy()
| 9 | 72 | __getstate__ |
|
13 | 1 | 1 | 3 | tests/openbb_terminal/cryptocurrency/test_cryptocurrency_helpers.py | 284,758 | refactoring load, changed chart to candle (#1838)
* refactoring load, changed chart to candle
* updating load
* refactor done, missing tests
* fixed chart
* refactor
* linting
* tests failing
* fix minh issues
* auto completion for load
* linting
* Tests : cryptocurrency/controller ; remove mocking of functions which are not used anymore
* Cryptocurrency/Controller : call_headlines ; fix bug
* Tests : cryptocurrency/controller ; mock function
* Tests : cryptocurrency/due_diligence ; fix expected output
* cryptocurrency/due_diligence ; mock functions
Co-authored-by: Chavithra <chavithra@gmail.com>
Co-authored-by: minhhoang1023 <40023817+minhhoang1023@users.noreply.github.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com> | OpenBBTerminal | 9 | Python | 12 | test_cryptocurrency_helpers.py | def test_load_none(coin, vs):
df = load(symbol_search=coin, vs=vs)
assert df is not None
@pytest.fixture(name="get_bitcoin") | 0e03b9e9e41aaa61cdec5d674a9f2c64ab8d3394 | @pytest.fixture(name="get_bitcoin") | 24 | https://github.com/OpenBB-finance/OpenBBTerminal.git | 17 | def test_load_none(coin, vs):
df = load(symbol_se | 9 | 53 | test_load_none |