instance_id
stringlengths 12
57
| base_commit
stringlengths 40
40
| created_at
stringdate 2015-01-06 14:05:07
2025-04-29 17:56:51
| environment_setup_commit
stringlengths 40
40
| hints_text
stringlengths 0
158k
| patch
stringlengths 261
20.8k
| problem_statement
stringlengths 11
52.5k
| repo
stringlengths 7
53
| test_patch
stringlengths 280
206k
| meta
dict | version
stringclasses 463
values | install_config
dict | requirements
stringlengths 93
34k
⌀ | environment
stringlengths 772
20k
⌀ | FAIL_TO_PASS
sequencelengths 1
856
| FAIL_TO_FAIL
sequencelengths 0
536
| PASS_TO_PASS
sequencelengths 0
7.87k
| PASS_TO_FAIL
sequencelengths 0
92
| license_name
stringclasses 35
values | __index_level_0__
int64 11
21.4k
| num_tokens_patch
int64 103
4.99k
| before_filepaths
sequencelengths 0
14
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
asottile__setup-cfg-fmt-107 | 1663a68ea45ed764f22ff1415edaea28ccbe118d | 2021-10-30 20:47:26 | 1663a68ea45ed764f22ff1415edaea28ccbe118d | diff --git a/setup_cfg_fmt.py b/setup_cfg_fmt.py
index be8eb0d..a2b637e 100644
--- a/setup_cfg_fmt.py
+++ b/setup_cfg_fmt.py
@@ -259,7 +259,8 @@ def _normalize_lib(lib: str) -> str:
def _req_base(lib: str) -> str:
basem = re.match(BASE_NAME_REGEX, lib)
assert basem
- return basem.group(0)
+ # pip replaces _ with - in package names
+ return basem.group(0).replace('_', '-')
def _py_classifiers(
| normalize requirements names to be dashed-names | asottile/setup-cfg-fmt | diff --git a/tests/setup_cfg_fmt_test.py b/tests/setup_cfg_fmt_test.py
index 05a7b8d..d7e7f36 100644
--- a/tests/setup_cfg_fmt_test.py
+++ b/tests/setup_cfg_fmt_test.py
@@ -72,6 +72,7 @@ def test_noop(tmpdir):
'name = pkg\n'
'[options]\n'
'{} =\n'
+ ' req_req\n'
' req03\n'
' req05 <= 2,!=1\n'
' req06 ;python_version==2.7\n'
@@ -97,6 +98,7 @@ def test_noop(tmpdir):
'[options]\n'
'{} =\n'
' req>=2\n'
+ ' req-req\n'
' req01\n'
' req02\n'
' req03\n'
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 0
},
"num_modified_files": 1
} | 1.18 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | cffi==1.17.1
covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
identify==2.6.9
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pycparser==2.22
pytest==8.3.5
-e git+https://github.com/asottile/setup-cfg-fmt.git@1663a68ea45ed764f22ff1415edaea28ccbe118d#egg=setup_cfg_fmt
tomli==2.2.1
ukkonen==1.0.1
| name: setup-cfg-fmt
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- cffi==1.17.1
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- identify==2.6.9
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pycparser==2.22
- pytest==8.3.5
- tomli==2.2.1
- ukkonen==1.0.1
prefix: /opt/conda/envs/setup-cfg-fmt
| [
"tests/setup_cfg_fmt_test.py::test_rewrite_requires[install_requires-normalizes",
"tests/setup_cfg_fmt_test.py::test_rewrite_requires[setup_requires-normalizes"
] | [] | [
"tests/setup_cfg_fmt_test.py::test_ver_type_ok",
"tests/setup_cfg_fmt_test.py::test_ver_type_error",
"tests/setup_cfg_fmt_test.py::test_ver_type_not_a_version",
"tests/setup_cfg_fmt_test.py::test_case_insensitive_glob[foo-[Ff][Oo][Oo]]",
"tests/setup_cfg_fmt_test.py::test_case_insensitive_glob[FOO-[Ff][Oo][Oo]]",
"tests/setup_cfg_fmt_test.py::test_case_insensitive_glob[licen[sc]e-[Ll][Ii][Cc][Ee][Nn][SsCc][Ee]]",
"tests/setup_cfg_fmt_test.py::test_noop",
"tests/setup_cfg_fmt_test.py::test_rewrite[orders",
"tests/setup_cfg_fmt_test.py::test_rewrite[normalizes",
"tests/setup_cfg_fmt_test.py::test_rewrite[sorts",
"tests/setup_cfg_fmt_test.py::test_rewrite[normalize",
"tests/setup_cfg_fmt_test.py::test_normalize_lib[no",
"tests/setup_cfg_fmt_test.py::test_normalize_lib[whitespace",
"tests/setup_cfg_fmt_test.py::test_normalize_lib[<=",
"tests/setup_cfg_fmt_test.py::test_normalize_lib[>=",
"tests/setup_cfg_fmt_test.py::test_normalize_lib[b/w",
"tests/setup_cfg_fmt_test.py::test_normalize_lib[compatible",
"tests/setup_cfg_fmt_test.py::test_adds_long_description_with_readme[README.rst-text/x-rst]",
"tests/setup_cfg_fmt_test.py::test_adds_long_description_with_readme[README.markdown-text/markdown]",
"tests/setup_cfg_fmt_test.py::test_adds_long_description_with_readme[README.md-text/markdown]",
"tests/setup_cfg_fmt_test.py::test_adds_long_description_with_readme[README-text/plain]",
"tests/setup_cfg_fmt_test.py::test_adds_long_description_with_readme[readme.txt-text/plain]",
"tests/setup_cfg_fmt_test.py::test_readme_discover_prefers_file_over_directory",
"tests/setup_cfg_fmt_test.py::test_sets_license_file_if_license_exists[LICENSE]",
"tests/setup_cfg_fmt_test.py::test_sets_license_file_if_license_exists[LICENCE]",
"tests/setup_cfg_fmt_test.py::test_sets_license_file_if_license_exists[LICENSE.md]",
"tests/setup_cfg_fmt_test.py::test_sets_license_file_if_license_exists[license.txt]",
"tests/setup_cfg_fmt_test.py::test_license_does_not_match_directories",
"tests/setup_cfg_fmt_test.py::test_rewrite_sets_license_type_and_classifier",
"tests/setup_cfg_fmt_test.py::test_rewrite_identifies_license",
"tests/setup_cfg_fmt_test.py::test_python_requires_left_alone[already",
"tests/setup_cfg_fmt_test.py::test_python_requires_left_alone[weird",
"tests/setup_cfg_fmt_test.py::test_python_requires_left_alone[not",
"tests/setup_cfg_fmt_test.py::test_strips_empty_options_and_sections[only",
"tests/setup_cfg_fmt_test.py::test_strips_empty_options_and_sections[entire",
"tests/setup_cfg_fmt_test.py::test_guess_python_requires_python2_tox_ini",
"tests/setup_cfg_fmt_test.py::test_guess_python_requires_tox_ini_dashed_name",
"tests/setup_cfg_fmt_test.py::test_guess_python_requires_ignores_insufficient_version_envs",
"tests/setup_cfg_fmt_test.py::test_guess_python_requires_from_classifiers",
"tests/setup_cfg_fmt_test.py::test_min_py3_version_updates_python_requires",
"tests/setup_cfg_fmt_test.py::test_min_py3_version_greater_than_minimum",
"tests/setup_cfg_fmt_test.py::test_min_version_removes_classifiers",
"tests/setup_cfg_fmt_test.py::test_python_requires_with_patch_version",
"tests/setup_cfg_fmt_test.py::test_classifiers_left_alone_for_odd_python_requires",
"tests/setup_cfg_fmt_test.py::test_min_py3_version_less_than_minimum",
"tests/setup_cfg_fmt_test.py::test_rewrite_extras",
"tests/setup_cfg_fmt_test.py::test_imp_classifiers_from_tox_ini",
"tests/setup_cfg_fmt_test.py::test_imp_classifiers_no_change",
"tests/setup_cfg_fmt_test.py::test_imp_classifiers_pypy_only",
"tests/setup_cfg_fmt_test.py::test_natural_sort"
] | [] | MIT License | 11,517 | 143 | [
"setup_cfg_fmt.py"
] |
|
AzureAD__microsoft-authentication-library-for-python-433 | 23e5341acf2118686fd95c11e81d7ffbbde9f367 | 2021-11-02 19:48:19 | 66a1c5a935e59c66281ccf73a3931681eeedee23 | diff --git a/msal/application.py b/msal/application.py
index 05b77fc..04ad5fd 100644
--- a/msal/application.py
+++ b/msal/application.py
@@ -231,8 +231,23 @@ class ClientApplication(object):
:param str authority:
A URL that identifies a token authority. It should be of the format
- https://login.microsoftonline.com/your_tenant
- By default, we will use https://login.microsoftonline.com/common
+ ``https://login.microsoftonline.com/your_tenant``
+ By default, we will use ``https://login.microsoftonline.com/common``
+
+ *Changed in version 1.17*: you can also use predefined constant
+ and a builder like this::
+
+ from msal.authority import (
+ AuthorityBuilder,
+ AZURE_US_GOVERNMENT, AZURE_CHINA, AZURE_PUBLIC)
+ my_authority = AuthorityBuilder(AZURE_PUBLIC, "contoso.onmicrosoft.com")
+ # Now you get an equivalent of
+ # "https://login.microsoftonline.com/contoso.onmicrosoft.com"
+
+ # You can feed such an authority to msal's ClientApplication
+ from msal import PublicClientApplication
+ app = PublicClientApplication("my_client_id", authority=my_authority, ...)
+
:param bool validate_authority: (optional) Turns authority validation
on or off. This parameter default to true.
:param TokenCache cache:
diff --git a/msal/authority.py b/msal/authority.py
index 0656011..14a6ad1 100644
--- a/msal/authority.py
+++ b/msal/authority.py
@@ -14,12 +14,19 @@ from .exceptions import MsalServiceError
logger = logging.getLogger(__name__)
+
+# Endpoints were copied from here
+# https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-national-cloud#azure-ad-authentication-endpoints
+AZURE_US_GOVERNMENT = "login.microsoftonline.us"
+AZURE_CHINA = "login.chinacloudapi.cn"
+AZURE_PUBLIC = "login.microsoftonline.com"
+
WORLD_WIDE = 'login.microsoftonline.com' # There was an alias login.windows.net
WELL_KNOWN_AUTHORITY_HOSTS = set([
WORLD_WIDE,
- 'login.chinacloudapi.cn',
+ AZURE_CHINA,
'login-us.microsoftonline.com',
- 'login.microsoftonline.us',
+ AZURE_US_GOVERNMENT,
'login.microsoftonline.de',
])
WELL_KNOWN_B2C_HOSTS = [
@@ -30,6 +37,19 @@ WELL_KNOWN_B2C_HOSTS = [
]
+class AuthorityBuilder(object):
+ def __init__(self, instance, tenant):
+ """A helper to save caller from doing string concatenation.
+
+ Usage is documented in :func:`application.ClientApplication.__init__`.
+ """
+ self._instance = instance.rstrip("/")
+ self._tenant = tenant.strip("/")
+
+ def __str__(self):
+ return "https://{}/{}".format(self._instance, self._tenant)
+
+
class Authority(object):
"""This class represents an (already-validated) authority.
@@ -53,6 +73,8 @@ class Authority(object):
performed.
"""
self._http_client = http_client
+ if isinstance(authority_url, AuthorityBuilder):
+ authority_url = str(authority_url)
authority, self.instance, tenant = canonicalize(authority_url)
parts = authority.path.split('/')
is_b2c = any(self.instance.endswith("." + d) for d in WELL_KNOWN_B2C_HOSTS) or (
| Add public convenience string constants for endpoints of each cloud (sovereign and public)
**Context**
Customers have had difficulty finding the right documentation pages:
https://docs.microsoft.com/en-us/azure/azure-government/documentation-government-developer-guide#endpoint-mapping
https://docs.microsoft.com/en-us/azure/china/resources-developer-guide#check-endpoints-in-azure
**See also other libraries exposing these:**
- [obj-c](https://azuread.github.io/microsoft-authentication-library-for-objc/Enums/MSALAzureCloudInstance.html)
- [.net](https://docs.microsoft.com/en-us/dotnet/api/microsoft.identity.client.azurecloudinstance?view=azure-dotnet)
**Reference:**
https://identitydivision.visualstudio.com/Engineering/_workitems/edit/1063014
**Other:**
https://github.com/AzureAD/microsoft-authentication-library-for-java/issues/258 | AzureAD/microsoft-authentication-library-for-python | diff --git a/tests/http_client.py b/tests/http_client.py
index a5587b7..5adbbde 100644
--- a/tests/http_client.py
+++ b/tests/http_client.py
@@ -20,6 +20,9 @@ class MinimalHttpClient:
return MinimalResponse(requests_resp=self.session.get(
url, params=params, headers=headers, timeout=self.timeout))
+ def close(self): # Not required, but we use it to avoid a warning in unit test
+ self.session.close()
+
class MinimalResponse(object): # Not for production use
def __init__(self, requests_resp=None, status_code=None, text=None):
diff --git a/tests/test_authority.py b/tests/test_authority.py
index cd6db78..9fdc83c 100644
--- a/tests/test_authority.py
+++ b/tests/test_authority.py
@@ -8,16 +8,37 @@ from tests.http_client import MinimalHttpClient
@unittest.skipIf(os.getenv("TRAVIS_TAG"), "Skip network io during tagged release")
class TestAuthority(unittest.TestCase):
+ def _test_given_host_and_tenant(self, host, tenant):
+ c = MinimalHttpClient()
+ a = Authority('https://{}/{}'.format(host, tenant), c)
+ self.assertEqual(
+ a.authorization_endpoint,
+ 'https://{}/{}/oauth2/v2.0/authorize'.format(host, tenant))
+ self.assertEqual(
+ a.token_endpoint,
+ 'https://{}/{}/oauth2/v2.0/token'.format(host, tenant))
+ c.close()
+
+ def _test_authority_builder(self, host, tenant):
+ c = MinimalHttpClient()
+ a = Authority(AuthorityBuilder(host, tenant), c)
+ self.assertEqual(
+ a.authorization_endpoint,
+ 'https://{}/{}/oauth2/v2.0/authorize'.format(host, tenant))
+ self.assertEqual(
+ a.token_endpoint,
+ 'https://{}/{}/oauth2/v2.0/token'.format(host, tenant))
+ c.close()
+
def test_wellknown_host_and_tenant(self):
# Assert all well known authority hosts are using their own "common" tenant
for host in WELL_KNOWN_AUTHORITY_HOSTS:
- a = Authority(
- 'https://{}/common'.format(host), MinimalHttpClient())
- self.assertEqual(
- a.authorization_endpoint,
- 'https://%s/common/oauth2/v2.0/authorize' % host)
- self.assertEqual(
- a.token_endpoint, 'https://%s/common/oauth2/v2.0/token' % host)
+ self._test_given_host_and_tenant(host, "common")
+
+ def test_wellknown_host_and_tenant_using_new_authority_builder(self):
+ self._test_authority_builder(AZURE_PUBLIC, "consumers")
+ self._test_authority_builder(AZURE_CHINA, "organizations")
+ self._test_authority_builder(AZURE_US_GOVERNMENT, "common")
@unittest.skip("As of Jan 2017, the server no longer returns V1 endpoint")
def test_lessknown_host_will_return_a_set_of_v1_endpoints(self):
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 1.16 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
cryptography==37.0.4
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
-e git+https://github.com/AzureAD/microsoft-authentication-library-for-python.git@23e5341acf2118686fd95c11e81d7ffbbde9f367#egg=msal
packaging==24.2
pluggy==1.5.0
pycparser==2.22
PyJWT==2.10.1
pytest==8.3.5
python-dotenv==1.1.0
requests==2.32.3
swebench_matterhorn @ file:///swebench_matterhorn
tomli==2.2.1
urllib3==2.3.0
| name: microsoft-authentication-library-for-python
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2025.1.31
- cffi==1.17.1
- charset-normalizer==3.4.1
- cryptography==37.0.4
- exceptiongroup==1.2.2
- idna==3.10
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pycparser==2.22
- pyjwt==2.10.1
- pytest==8.3.5
- python-dotenv==1.1.0
- requests==2.32.3
- swebench-matterhorn==0.0.0
- tomli==2.2.1
- urllib3==2.3.0
prefix: /opt/conda/envs/microsoft-authentication-library-for-python
| [
"tests/test_authority.py::TestAuthority::test_wellknown_host_and_tenant_using_new_authority_builder"
] | [
"tests/test_authority.py::TestAuthority::test_wellknown_host_and_tenant"
] | [
"tests/test_authority.py::TestAuthority::test_invalid_host_skipping_validation_can_be_turned_off",
"tests/test_authority.py::TestAuthority::test_unknown_host_wont_pass_instance_discovery",
"tests/test_authority.py::TestAuthorityInternalHelperCanonicalize::test_canonicalize_rejects_non_https",
"tests/test_authority.py::TestAuthorityInternalHelperCanonicalize::test_canonicalize_rejects_tenantless",
"tests/test_authority.py::TestAuthorityInternalHelperCanonicalize::test_canonicalize_rejects_tenantless_host_with_trailing_slash",
"tests/test_authority.py::TestAuthorityInternalHelperCanonicalize::test_canonicalize_tenant_followed_by_extra_fragment",
"tests/test_authority.py::TestAuthorityInternalHelperCanonicalize::test_canonicalize_tenant_followed_by_extra_paths",
"tests/test_authority.py::TestAuthorityInternalHelperCanonicalize::test_canonicalize_tenant_followed_by_extra_query",
"tests/test_authority.py::TestAuthorityInternalHelperUserRealmDiscovery::test_memorize"
] | [] | MIT License | 11,522 | 846 | [
"msal/application.py",
"msal/authority.py"
] |
|
VirtusLab__git-machete-330 | 18f7e32640cab8483c32a231a478c23c1a50ec67 | 2021-11-03 12:50:09 | cbb53164ec69817bca876579af36d8d2646ed94d | diff --git a/git_machete/cli.py b/git_machete/cli.py
index 19a6a38..8824ec9 100644
--- a/git_machete/cli.py
+++ b/git_machete/cli.py
@@ -358,15 +358,25 @@ def create_cli_parser() -> argparse.ArgumentParser:
def update_cli_opts_using_parsed_args(
cli_opts: git_machete.options.CommandLineOptions,
parsed_args: argparse.Namespace) -> None:
+
+ # Warning: In mypy, Arguments that come from untyped functions/variables are silently treated by mypy as Any.
+ # Since argparse is not typed, everything that comes from argparse.Namespace will be taken as Any :(
+ # Even if we add type=LocalBranchShortName into argument parser for branch,
+ # python debugger will see branch as LocalBranchShortName but mypy always will see it as Any,
+ # until you specifically tell mypy what is the exact type by casting (right now it's done this way below, but casting does not solve all of the problems).
+ #
+ # The reasonable solution here would be to use Typed Argument Parser which is a wrapper over argparse with modernised solution for typing.
+ # But it would add external dependency to git-machete, so let's stick to current casting.
+
for opt, arg in vars(parsed_args).items():
if opt == "branch":
- cli_opts.opt_branch = arg
+ cli_opts.opt_branch = LocalBranchShortName.of(arg)
elif opt == "checked_out_since":
cli_opts.opt_checked_out_since = arg
elif opt == "color":
cli_opts.opt_color = arg
elif opt == "down_fork_point":
- cli_opts.opt_down_fork_point = arg
+ cli_opts.opt_down_fork_point = AnyRevision.of(arg)
elif opt == "debug":
cli_opts.opt_debug = True
elif opt == "draft":
@@ -374,7 +384,7 @@ def update_cli_opts_using_parsed_args(
elif opt == "fetch":
cli_opts.opt_fetch = True
elif opt == "fork_point":
- cli_opts.opt_fork_point = arg
+ cli_opts.opt_fork_point = AnyRevision.of(arg)
elif opt == "inferred":
cli_opts.opt_inferred = True
elif opt == "list_commits_with_hashes":
@@ -397,7 +407,7 @@ def update_cli_opts_using_parsed_args(
elif opt == "no_push_untracked":
cli_opts.opt_push_untracked = False
elif opt == "onto":
- cli_opts.opt_onto = arg
+ cli_opts.opt_onto = LocalBranchShortName.of(arg)
elif opt == "override_to":
cli_opts.opt_override_to = arg
elif opt == "override_to_inferred":
@@ -412,7 +422,7 @@ def update_cli_opts_using_parsed_args(
elif opt == "as_root":
cli_opts.opt_as_root = True
elif opt == "roots":
- cli_opts.opt_roots = arg.split(",")
+ cli_opts.opt_roots = list(map(LocalBranchShortName.of, arg.split(",")))
elif opt == "return_to":
cli_opts.opt_return_to = arg
elif opt == "stat":
| `AttributeError: 'str' object has no attribute 'full_name'` due to (?) mistyped `CommandLineOptions.opt_branch`
For an already existing, but not yet managed branch `foo/bar`:
```
$ git machete add foo/bar
Traceback (most recent call last):
File "/usr/local/bin/git-machete", line 4, in <module>
__import__('pkg_resources').run_script('git-machete==3.5.0', 'git-machete')
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 1469, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/EGG-INFO/scripts/git-machete", line 19, in <module>
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/cli.py", line 803, in main
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/cli.py", line 522, in launch
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/client.py", line 263, in add
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/client.py", line 1502, in __infer_upstream
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/client.py", line 1479, in __match_log_to_filtered_reflogs
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/git_operations.py", line 495, in spoonfeed_log_shas
File "/usr/local/lib/python3.7/site-packages/git_machete-3.5.0-py3.7.egg/git_machete/git_operations.py", line 487, in __get_log_shas
AttributeError: 'str' object has no attribute 'full_name'
```
This is most likely due to assignment `cli_opts.opt_branch = arg`, with `arg` being `str`-typed (?)... not sure why it passed mypy in the first place, pls investigate.
Also, regression test + preferable a systematic solution against this kind of errors would be very useful. | VirtusLab/git-machete | diff --git a/git_machete/tests/functional/test_machete.py b/git_machete/tests/functional/test_machete.py
index e6f934d..36165d7 100644
--- a/git_machete/tests/functional/test_machete.py
+++ b/git_machete/tests/functional/test_machete.py
@@ -2647,3 +2647,31 @@ class MacheteTester(unittest.TestCase):
roots_only_commit_hash, log_content,
msg="Verify that commits from parent branch are not visible when "
"executing `git machete log`.")
+
+ @mock.patch('git_machete.utils.run_cmd', mock_run_cmd) # to hide git outputs in tests
+ def test_add(self) -> None:
+ """
+ Verify behaviour of a 'git machete add' command.
+ """
+ (
+ self.repo_sandbox.new_branch("master")
+ .commit("master commit.")
+ .new_branch("develop")
+ .commit("develop commit.")
+ .new_branch("feature")
+ .commit("feature commit.")
+ .check_out("develop")
+ .commit("New commit on develop")
+ )
+ self.launch_command("discover", "-y")
+ self.repo_sandbox.new_branch("bugfix/feature_fail")
+
+ self.assert_command(['add', '-y', 'bugfix/feature_fail'], 'Adding `bugfix/feature_fail` onto the inferred upstream (parent) branch `develop`\n'
+ 'Added branch `bugfix/feature_fail` onto `develop`\n', strip_indentation=False)
+
+ # test with --onto option
+ self.repo_sandbox.new_branch("chore/remove_indentation")
+
+ self.assert_command(['add', '--onto=feature'],
+ 'Added branch `chore/remove_indentation` onto `feature`\n',
+ strip_indentation=False)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 3.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"tox",
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | cachetools==5.5.2
chardet==5.2.0
colorama==0.4.6
distlib==0.3.9
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
filelock==3.18.0
-e git+https://github.com/VirtusLab/git-machete.git@18f7e32640cab8483c32a231a478c23c1a50ec67#egg=git_machete
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
platformdirs==4.3.7
pluggy @ file:///croot/pluggy_1733169602837/work
pyproject-api==1.9.0
pytest @ file:///croot/pytest_1738938843180/work
tomli==2.2.1
tox==4.25.0
typing_extensions==4.13.0
virtualenv==20.29.3
| name: git-machete
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- cachetools==5.5.2
- chardet==5.2.0
- colorama==0.4.6
- distlib==0.3.9
- filelock==3.18.0
- platformdirs==4.3.7
- pyproject-api==1.9.0
- tomli==2.2.1
- tox==4.25.0
- typing-extensions==4.13.0
- virtualenv==20.29.3
prefix: /opt/conda/envs/git-machete
| [
"git_machete/tests/functional/test_machete.py::MacheteTester::test_add"
] | [] | [
"git_machete/tests/functional/test_machete.py::MacheteTester::test_advance_with_few_possible_downstream_branches_and_yes_option",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_advance_with_no_downstream_branches",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_advance_with_one_downstream_branch",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_anno_prs",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_branch_reappers_in_definition",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_checkout_prs",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_checkout_prs_freshly_cloned",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_checkout_prs_from_fork_with_deleted_repo",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_discover_traverse_squash",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_github_create_pr",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_down",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_first_root_with_downstream",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_first_root_without_downstream",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_last",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_next_successor_exists",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_next_successor_on_another_root_tree",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_prev_successor_exists",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_prev_successor_on_another_root_tree",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_root",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_up",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_help",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_log",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_retarget_pr",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_down",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_first",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_last",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_next",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_prev",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_root",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_up",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out_with_down_fork_point_and_multiple_children_of_last_branch",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out_with_invalid_down_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out_with_valid_down_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_squash_merge",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_squash_with_invalid_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_squash_with_valid_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_traverse_no_push",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_traverse_no_push_override",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_traverse_no_push_untracked",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_update_with_fork_point_not_specified",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_update_with_fork_point_specified",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_update_with_invalid_fork_point"
] | [] | MIT License | 11,523 | 733 | [
"git_machete/cli.py"
] |
|
LSSTDESC__sacc-68 | 90cbb05badb2c4f2f8c041f2b863e53fabd9e9d6 | 2021-11-03 21:33:45 | f14fca7098bcf393586c9e0e464814f41e973453 | diff --git a/sacc/sacc.py b/sacc/sacc.py
index 4c134ee..96bfe48 100644
--- a/sacc/sacc.py
+++ b/sacc/sacc.py
@@ -641,6 +641,33 @@ class Sacc:
indices = self.indices(data_type=data_type)
return unique_list(self.data[i].tracers for i in indices)
+ def rename_tracer(self, name, new_name):
+ """
+ Get the tracer object with the given name
+
+ Parameters
+ -----------
+ name: str
+ A string name of a tracer to be changed the name
+ new_name: str
+ A string with the new name of the tracer
+
+ """
+
+ tr = self.tracers.pop(name)
+ tr.name = new_name
+ self.tracers[new_name] = tr
+
+ for d in self.data:
+ new_trs = []
+ for tri in d.tracers:
+ if tri == name:
+ tri = new_name
+
+ new_trs.append(tri)
+
+ d.tracers = tuple(new_trs)
+
@property
def mean(self):
"""
| Add method to rename tracers
I would find be very convenient to have a method to rename tracers (and the tracer combinations involved). If it exists, I missed it. | LSSTDESC/sacc | diff --git a/test/test_sacc2.py b/test/test_sacc2.py
index 7dff1f6..9cc600e 100644
--- a/test/test_sacc2.py
+++ b/test/test_sacc2.py
@@ -30,6 +30,35 @@ def get_from_wiki(url):
return local_file_name
+def get_filled_sacc():
+ s = sacc.Sacc()
+
+ # Tracer
+ z = np.arange(0., 1.0, 0.01)
+ nz = (z-0.5)**2/0.1**2
+ s.add_tracer('NZ', 'source_0', z, nz)
+ s.add_tracer('NZ', 'source_1', z, nz,
+ quantity='cluster_density')
+
+ for i in range(20):
+ ee = 0.1 * i
+ tracers = ('source_0',)
+ s.add_data_point(sacc.standard_types.count,
+ tracers, ee, ell=10.0*i)
+ for i in range(20):
+ bb = 0.2 * i
+ tracers = ('source_0', 'source_1')
+ s.add_data_point(sacc.standard_types.galaxy_shear_cl_bb,
+ tracers, bb, ell=10.0*i)
+ for i in range(20):
+ ee = 0.3 * i
+ tracers = ('source_1', 'source_1', 'source_0')
+ s.add_data_point(sacc.standard_types.galaxy_shear_cl_ee,
+ tracers, ee, ell=10.0*i)
+
+ return s
+
+
def test_quantity_warning():
s = sacc.Sacc()
with pytest.warns(UserWarning):
@@ -642,6 +671,47 @@ def test_io_maps_bpws():
assert w.weight.shape == (n_ell_large, n_ell)
+def test_rename_tracer():
+ s = get_filled_sacc()
+
+ tracer_comb = s.get_tracer_combinations()
+
+ s.rename_tracer('source_0', 'src_0')
+
+ # Check that the name attribute of the tracer has changed
+ tr = s.get_tracer('src_0')
+ assert tr.name == 'src_0'
+
+ # Check that the data tracer combinations have been updated
+ tracer_comb_new = s.get_tracer_combinations()
+ for trs, trs_new in zip(tracer_comb, tracer_comb_new):
+ trs_n = []
+ for tri in trs:
+ if 'source_0' == tri:
+ tri = 'src_0'
+ trs_n.append(tri)
+
+ assert tuple(trs_n) == trs_new
+
+ # Check it is permanent
+ with tempfile.TemporaryDirectory() as tmpdir:
+ filename = os.path.join(tmpdir, 'test.sacc')
+ s.save_fits(filename)
+ s2 = sacc.Sacc.load_fits(filename)
+
+ assert ('source_0' not in s2.tracers) and ('src_0' in s2.tracers)
+ assert sorted(tracer_comb_new) == sorted(s2.get_tracer_combinations())
+ # Make sure the tracers are ordered the same way when comparing the data
+ # points
+ s.to_canonical_order()
+ s2.to_canonical_order()
+ assert np.all(s.mean == s2.mean)
+ assert np.all(s.indices(tracers=('src_0', 'source_1')) ==
+ s2.indices(tracers=('src_0', 'source_1')))
+ assert np.all(s.indices(tracers=('source_1', 'source_1', 'src_0')) ==
+ s2.indices(tracers=('source_1', 'source_1', 'src_0')))
+
+
@pytest.mark.parametrize("vv,ncl,ntr",
[('0.2.0', 2, 2),
('0.3.0', 3, 2),
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 0.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
astropy==6.0.1
astropy-iers-data==0.2025.3.31.0.36.18
babel==2.17.0
certifi==2025.1.31
charset-normalizer==3.4.1
docutils==0.21.2
exceptiongroup==1.2.2
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
MarkupSafe==3.0.2
numpy==1.26.4
numpydoc==1.8.0
packaging==24.2
pluggy==1.5.0
pyerfa==2.0.1.5
Pygments==2.19.1
pytest==8.3.5
PyYAML==6.0.2
requests==2.32.3
-e git+https://github.com/LSSTDESC/sacc.git@90cbb05badb2c4f2f8c041f2b863e53fabd9e9d6#egg=sacc
scipy==1.13.1
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tabulate==0.9.0
tomli==2.2.1
urllib3==2.3.0
zipp==3.21.0
| name: sacc
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- astropy==6.0.1
- astropy-iers-data==0.2025.3.31.0.36.18
- babel==2.17.0
- certifi==2025.1.31
- charset-normalizer==3.4.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markupsafe==3.0.2
- numpy==1.26.4
- numpydoc==1.8.0
- packaging==24.2
- pluggy==1.5.0
- pyerfa==2.0.1.5
- pygments==2.19.1
- pytest==8.3.5
- pyyaml==6.0.2
- requests==2.32.3
- scipy==1.13.1
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- tabulate==0.9.0
- tomli==2.2.1
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/sacc
| [
"test/test_sacc2.py::test_rename_tracer"
] | [
"test/test_sacc2.py::test_keep_remove"
] | [
"test/test_sacc2.py::test_quantity_warning",
"test/test_sacc2.py::test_data_type_warning",
"test/test_sacc2.py::test_construct",
"test/test_sacc2.py::test_tracers_later",
"test/test_sacc2.py::test_full_cov",
"test/test_sacc2.py::test_block_cov",
"test/test_sacc2.py::test_misc_tracer",
"test/test_sacc2.py::test_numap_tracer",
"test/test_sacc2.py::test_map_tracer",
"test/test_sacc2.py::test_nz_tracer",
"test/test_sacc2.py::test_mixed_tracers",
"test/test_sacc2.py::test_inverses",
"test/test_sacc2.py::test_data_point",
"test/test_sacc2.py::test_cutting_block_cov",
"test/test_sacc2.py::test_cutting_block_cov2",
"test/test_sacc2.py::test_cutting_full_cov",
"test/test_sacc2.py::test_cutting_diag_cov",
"test/test_sacc2.py::test_parse_data_names",
"test/test_sacc2.py::test_bandpower_window",
"test/test_sacc2.py::test_tophat_window",
"test/test_sacc2.py::test_log_window",
"test/test_sacc2.py::test_concatenate_covariance",
"test/test_sacc2.py::test_concatenate_data",
"test/test_sacc2.py::test_io",
"test/test_sacc2.py::test_io_maps_bpws",
"test/test_sacc2.py::test_legacy_format[0.2.0-2-2]",
"test/test_sacc2.py::test_legacy_format[0.3.0-3-2]",
"test/test_sacc2.py::test_legacy_format[0.4.2-6-5]"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,528 | 282 | [
"sacc/sacc.py"
] |
|
albumentations-team__albumentations-1055 | 6741f516672f559eb6a4a9ebe521b43065426341 | 2021-11-05 19:40:25 | 880c1aaed10ab74cfe851496a476c1c34cadcd0f | diff --git a/albumentations/core/composition.py b/albumentations/core/composition.py
index 7a78e43..d9f53c4 100644
--- a/albumentations/core/composition.py
+++ b/albumentations/core/composition.py
@@ -48,6 +48,12 @@ def get_always_apply(transforms: typing.Union["BaseCompose", TransformsSeqType])
class BaseCompose(metaclass=SerializableMeta):
def __init__(self, transforms: TransformsSeqType, p: float):
+ if isinstance(transforms, (BaseCompose, BasicTransform)):
+ warnings.warn(
+ "transforms is single transform, but a sequence is expected! Transform will be wrapped into list."
+ )
+ transforms = [transforms]
+
self.transforms = transforms
self.p = p
@@ -276,7 +282,7 @@ class OneOf(BaseCompose):
def __init__(self, transforms: TransformsSeqType, p: float = 0.5):
super(OneOf, self).__init__(transforms, p)
- transforms_ps = [t.p for t in transforms]
+ transforms_ps = [t.p for t in self.transforms]
s = sum(transforms_ps)
self.transforms_ps = [t / s for t in transforms_ps]
@@ -308,7 +314,7 @@ class SomeOf(BaseCompose):
super(SomeOf, self).__init__(transforms, p)
self.n = n
self.replace = replace
- transforms_ps = [t.p for t in transforms]
+ transforms_ps = [t.p for t in self.transforms]
s = sum(transforms_ps)
self.transforms_ps = [t / s for t in transforms_ps]
@@ -347,9 +353,9 @@ class OneOrOther(BaseCompose):
if first is None or second is None:
raise ValueError("You must set both first and second or set transforms argument.")
transforms = [first, second]
- elif len(transforms) != 2:
- warnings.warn("Length of transforms is not equal to 2.")
super(OneOrOther, self).__init__(transforms, p)
+ if len(self.transforms) != 2:
+ warnings.warn("Length of transforms is not equal to 2.")
def __call__(self, *args, force_apply: bool = False, **data) -> typing.Dict[str, typing.Any]:
if self.replay_mode:
| `A.Compose`, `A.Sequential` components run multiple times inside of `A.OneOf`
## 🐛 Bug
Hi, I used `A.OneOf` method on my `A.Compose` objects,
but when I run entire pipeline, all components of `A.Compose` objects are called altogether.
## To Reproduce
Steps to reproduce the behavior:
1. define augmentation
```python3
class Augmentation():
def __init__(self,
dataset_w:int=None,
dataset_h:int=None,
final_return_w:int=None,
final_return_h:int=None):
self.train_augmentation = self.set_train_augmentation(
dataset_w=dataset_w,
dataset_h=dataset_h,
final_return_w=final_return_w,
final_return_h=final_return_h,
)
def get_train_augmentation(self):
return lambda image, mask: list(self.train_augmentation(image=image, mask=mask).values())
def set_train_augmentation(self, **kwargs):
ret = self.augmentation_method(**kwargs)
return ret
def _slightly_smaller(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
ratio:float=0.5
)->tuple:
assert 0. < ratio and ratio < 1, f'0 < ratio {repr(ratio)} < 1'
dw = int((original_w - target_w) * ratio)
dh = int((original_h - target_h) * ratio)
return (target_h + dh, target_w + dw)
def _get_crop(self,
target_h:int,
target_w:int,
)->list:
tf = []
tf += [A.RandomCrop(target_h, target_w, p=1.0)]
return tf
def _get_resize(self,
target_h:int,
target_w:int
)->list:
tf = []
tf += [A.Resize(target_h, target_w, p=1.0)]
return tf
def _get_pad(self,
target_h:int,
target_w:int
)->list:
longer_side = target_h if target_h > target_w else target_w
tf = []
tf += [A.PadIfNeeded(
min_height=longer_side,
min_width=longer_side,
p=1.0,
border_mode=4)]
return tf
def _get_resize_crop(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
)->list:
tf = []
tf += self._get_resize(*self._slightly_smaller(
target_h, target_w,
original_h, original_w)
)
tf += self._get_crop(target_h, target_w)
return tf
def _get_crop_resize(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
)->list:
tf = []
tf += self._get_crop(*self._slightly_smaller(
target_h, target_w,
original_h, original_w)
)
tf += self._get_resize(target_h, target_w)
return tf
def _get_pad_resize(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
)->list:
tf = []
tf += self._get_pad(original_h, original_w)
tf += self._get_reszie(target_h, target_w)
return tf
def _get_pad_crop(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
)->list:
tf = []
tf += self._get_pad(original_h, original_w)
tf += self._get_crop(target_h, target_w)
return tf
def _get_pad_resize_crop(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
)->list:
tf = []
tf += self._get_pad(original_h, original_w)
tf += self._get_resize(*self._slightly_smaller(
target_h, target_w,
original_h, original_w)
)
tf += self._get_crop(target_h, target_w)
return tf
def _get_pad_crop_resize(self,
target_h:int,
target_w:int,
original_h:int,
original_w:int,
)->list:
tf = []
tf += self._get_pad(original_h, original_w)
tf += self._get_crop(*self._slightly_smaller(
target_h, target_w,
original_h, original_w)
)
tf += self._get_resize(target_h, target_w)
return tf
def augmentation_method(self,
dataset_w=None,
dataset_h=None,
final_return_w=None,
final_return_h=None,
):
kwargs = {'target_h':final_return_h,
'target_w':final_return_w,
'original_h':dataset_h,
'original_w':dataset_w}
print(self._get_resize_crop(**kwargs))
print(self._get_crop_resize(**kwargs))
print(self._get_pad_crop_resize(**kwargs))
print(self._get_pad_resize_crop(**kwargs))
tf = A.OneOf([
#A.Compose(self._get_resize_crop(**kwargs), p=1.0), # <-- this line makes error either.
A.Compose(self._get_crop_resize(**kwargs), p=1.0),
A.Compose(self._get_pad_crop_resize(**kwargs), p=1.0),
A.Compose(self._get_pad_resize_crop(**kwargs), p=1.0),
], p=1.0)
return A.Compose(tf, p=1.0)
```
2. new instance
```python3
aug = Augmentation(DATASET_WIDTH,
DATASET_HEIGHT,
DATASET_TRAINING_TARGET_W,
DATASET_TRAINING_TARGET_H)
aug_fn_for_train = aug.get_train_augmentation()
```
3. run pipeline
```python3
image_train_debug, mask_train_debug = aug_fn_for_train(image, mask)
```
## Expected behavior
Doing augmentation from randomly selected one of the composed pipeline.
```python3
tf = A.OneOf([
A.Compose(self._get_resize_crop(**kwargs), p=1.0), # 25%
A.Compose(self._get_crop_resize(**kwargs), p=1.0), # 25%
A.Compose(self._get_pad_crop_resize(**kwargs), p=1.0), # 25%
A.Compose(self._get_pad_resize_crop(**kwargs), p=1.0), # 25%
], p=1.0)
```
## Environment
- Albumentations version (e.g., 0.1.8): 0.1.12
- Python version (e.g., 3.7): python3.8
- OS (e.g., Linux): Google COLAB COLAB
- How you installed albumentations (`conda`, `pip`, source): colab default installed
- Any other relevant information:
## Additional context

<!-- Add any other context about the problem here. -->
| albumentations-team/albumentations | diff --git a/tests/test_core.py b/tests/test_core.py
index 18e677b..5d69d29 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1,26 +1,43 @@
from __future__ import absolute_import
+import typing
from unittest import mock
-from unittest.mock import Mock, MagicMock, call
+from unittest.mock import MagicMock, Mock, call
import cv2
import numpy as np
import pytest
-from albumentations.core.transforms_interface import to_tuple, ImageOnlyTransform, DualTransform
+from albumentations import (
+ BasicTransform,
+ Blur,
+ Crop,
+ HorizontalFlip,
+ MedianBlur,
+ Normalize,
+ PadIfNeeded,
+ Resize,
+ Rotate,
+)
from albumentations.augmentations.bbox_utils import check_bboxes
from albumentations.core.composition import (
- OneOrOther,
+ BaseCompose,
+ BboxParams,
Compose,
+ KeypointParams,
OneOf,
+ OneOrOther,
SomeOf,
PerChannel,
ReplayCompose,
- KeypointParams,
- BboxParams,
Sequential,
)
-from albumentations import HorizontalFlip, Rotate, Blur, MedianBlur, PadIfNeeded, Crop
+from albumentations.core.transforms_interface import (
+ DualTransform,
+ ImageOnlyTransform,
+ to_tuple,
+)
+from .utils import get_filtered_transforms
def test_one_or_other():
@@ -332,3 +349,24 @@ def test_bbox_params_is_not_set(image, bboxes):
with pytest.raises(ValueError) as exc_info:
t(image=image, bboxes=bboxes)
assert str(exc_info.value) == "bbox_params must be specified for bbox transformations"
+
+
[email protected](
+ "compose_transform", get_filtered_transforms((BaseCompose,), custom_arguments={SomeOf: {"n": 1}})
+)
[email protected](
+ "inner_transform",
+ [(Normalize, {}), (Resize, {"height": 100, "width": 100})]
+ + get_filtered_transforms((BaseCompose,), custom_arguments={SomeOf: {"n": 1}}), # type: ignore
+)
+def test_single_transform_compose(
+ compose_transform: typing.Tuple[typing.Type[BaseCompose], dict],
+ inner_transform: typing.Tuple[typing.Union[typing.Type[BaseCompose], typing.Type[BasicTransform]], dict],
+):
+ compose_cls, compose_kwargs = compose_transform
+ cls, kwargs = inner_transform
+ transform = cls(transforms=[], **kwargs) if issubclass(cls, BaseCompose) else cls(**kwargs)
+
+ with pytest.warns(UserWarning):
+ res_transform = compose_cls(transforms=transform, **compose_kwargs) # type: ignore
+ assert isinstance(res_transform.transforms, list)
diff --git a/tests/utils.py b/tests/utils.py
index b5dea11..13d1fb8 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -1,6 +1,6 @@
+import inspect
import random
import typing
-import inspect
import numpy as np
from io import StringIO
@@ -73,7 +73,9 @@ def get_filtered_transforms(
result = []
for name, cls in inspect.getmembers(albumentations):
- if not inspect.isclass(cls) or not issubclass(cls, albumentations.BasicTransform):
+ if not inspect.isclass(cls) or not issubclass(
+ cls, (albumentations.BasicTransform, albumentations.BaseCompose)
+ ):
continue
if "DeprecationWarning" in inspect.getsource(cls) or "FutureWarning" in inspect.getsource(cls):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 3
},
"num_modified_files": 1
} | 1.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[tests]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"numpy>=1.16.0",
"pandas>=1.0.0",
"pre-commit",
"black",
"flake8",
"isort",
"mypy"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/albumentations-team/albumentations.git@6741f516672f559eb6a4a9ebe521b43065426341#egg=albumentations
black==25.1.0
cfgv==3.4.0
click==8.1.8
distlib==0.3.9
exceptiongroup==1.2.2
filelock==3.18.0
flake8==7.2.0
identify==2.6.9
imageio==2.37.0
iniconfig==2.1.0
isort==6.0.1
joblib==1.4.2
lazy_loader==0.4
mccabe==0.7.0
mypy==1.15.0
mypy-extensions==1.0.0
networkx==3.2.1
nodeenv==1.9.1
numpy==2.0.2
opencv-python-headless==4.11.0.86
packaging==24.2
pandas==2.2.3
pathspec==0.12.1
pillow==11.1.0
platformdirs==4.3.7
pluggy==1.5.0
pre_commit==4.2.0
pycodestyle==2.13.0
pyflakes==3.3.2
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
qudida==0.0.4
scikit-image==0.24.0
scikit-learn==1.6.1
scipy==1.13.1
six==1.17.0
threadpoolctl==3.6.0
tifffile==2024.8.30
tomli==2.2.1
typing_extensions==4.13.0
tzdata==2025.2
virtualenv==20.29.3
| name: albumentations
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- black==25.1.0
- cfgv==3.4.0
- click==8.1.8
- distlib==0.3.9
- exceptiongroup==1.2.2
- filelock==3.18.0
- flake8==7.2.0
- identify==2.6.9
- imageio==2.37.0
- iniconfig==2.1.0
- isort==6.0.1
- joblib==1.4.2
- lazy-loader==0.4
- mccabe==0.7.0
- mypy==1.15.0
- mypy-extensions==1.0.0
- networkx==3.2.1
- nodeenv==1.9.1
- numpy==2.0.2
- opencv-python-headless==4.11.0.86
- packaging==24.2
- pandas==2.2.3
- pathspec==0.12.1
- pillow==11.1.0
- platformdirs==4.3.7
- pluggy==1.5.0
- pre-commit==4.2.0
- pycodestyle==2.13.0
- pyflakes==3.3.2
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pyyaml==6.0.2
- qudida==0.0.4
- scikit-image==0.24.0
- scikit-learn==1.6.1
- scipy==1.13.1
- six==1.17.0
- threadpoolctl==3.6.0
- tifffile==2024.8.30
- tomli==2.2.1
- typing-extensions==4.13.0
- tzdata==2025.2
- virtualenv==20.29.3
prefix: /opt/conda/envs/albumentations
| [
"tests/test_core.py::test_single_transform_compose[inner_transform0-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform0-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform0-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform0-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform0-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform0-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform1-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform1-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform1-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform1-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform1-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform1-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform2-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform2-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform2-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform2-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform2-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform2-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform3-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform3-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform3-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform3-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform3-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform3-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform4-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform4-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform4-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform4-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform4-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform4-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform5-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform5-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform5-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform5-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform5-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform5-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform6-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform6-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform6-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform6-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform6-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform6-compose_transform5]",
"tests/test_core.py::test_single_transform_compose[inner_transform7-compose_transform0]",
"tests/test_core.py::test_single_transform_compose[inner_transform7-compose_transform1]",
"tests/test_core.py::test_single_transform_compose[inner_transform7-compose_transform2]",
"tests/test_core.py::test_single_transform_compose[inner_transform7-compose_transform3]",
"tests/test_core.py::test_single_transform_compose[inner_transform7-compose_transform4]",
"tests/test_core.py::test_single_transform_compose[inner_transform7-compose_transform5]"
] | [] | [
"tests/test_core.py::test_one_or_other",
"tests/test_core.py::test_compose",
"tests/test_core.py::test_always_apply",
"tests/test_core.py::test_one_of",
"tests/test_core.py::test_n_of[True-1]",
"tests/test_core.py::test_n_of[True-2]",
"tests/test_core.py::test_n_of[True-5]",
"tests/test_core.py::test_n_of[True-10]",
"tests/test_core.py::test_n_of[False-1]",
"tests/test_core.py::test_n_of[False-2]",
"tests/test_core.py::test_n_of[False-5]",
"tests/test_core.py::test_n_of[False-10]",
"tests/test_core.py::test_sequential",
"tests/test_core.py::test_to_tuple",
"tests/test_core.py::test_image_only_transform",
"tests/test_core.py::test_dual_transform",
"tests/test_core.py::test_additional_targets",
"tests/test_core.py::test_check_bboxes_with_correct_values",
"tests/test_core.py::test_check_bboxes_with_values_less_than_zero",
"tests/test_core.py::test_check_bboxes_with_values_greater_than_one",
"tests/test_core.py::test_check_bboxes_with_end_greater_that_start",
"tests/test_core.py::test_per_channel_mono",
"tests/test_core.py::test_per_channel_multi",
"tests/test_core.py::test_deterministic_oneof",
"tests/test_core.py::test_deterministic_one_or_other",
"tests/test_core.py::test_deterministic_sequential",
"tests/test_core.py::test_named_args",
"tests/test_core.py::test_targets_type_check[targets0-None-image",
"tests/test_core.py::test_targets_type_check[targets1-None-mask",
"tests/test_core.py::test_targets_type_check[targets2-additional_targets2-image1",
"tests/test_core.py::test_targets_type_check[targets3-additional_targets3-mask1",
"tests/test_core.py::test_check_each_transform[targets0-None-keypoint_params0-expected0]",
"tests/test_core.py::test_check_each_transform[targets1-None-keypoint_params1-expected1]",
"tests/test_core.py::test_check_each_transform[targets2-bbox_params2-None-expected2]",
"tests/test_core.py::test_check_each_transform[targets3-bbox_params3-None-expected3]",
"tests/test_core.py::test_check_each_transform[targets4-bbox_params4-keypoint_params4-expected4]",
"tests/test_core.py::test_check_each_transform[targets5-bbox_params5-keypoint_params5-expected5]",
"tests/test_core.py::test_check_each_transform[targets6-bbox_params6-keypoint_params6-expected6]",
"tests/test_core.py::test_check_each_transform[targets7-bbox_params7-keypoint_params7-expected7]",
"tests/test_core.py::test_bbox_params_is_not_set"
] | [] | MIT License | 11,538 | 557 | [
"albumentations/core/composition.py"
] |
|
geopandas__geopandas-2219 | 9a1509476a8ce2c0092ca8fae3b1c1f5bc741c67 | 2021-11-06 10:20:50 | be647ab7e54880278cba374cc77075afd33b25a5 | martinfleis: Can you update from master to get the dev env running? | diff --git a/geopandas/array.py b/geopandas/array.py
index 0532c08b..fd7b7fc6 100644
--- a/geopandas/array.py
+++ b/geopandas/array.py
@@ -363,10 +363,12 @@ class GeometryArray(ExtensionArray):
# for pandas >= 1.0, validate and convert IntegerArray/BooleanArray
# to numpy array, pass-through non-array-like indexers
idx = pd.api.indexers.check_array_indexer(self, idx)
- if isinstance(idx, (Iterable, slice)):
return GeometryArray(self.data[idx], crs=self.crs)
else:
- raise TypeError("Index type not supported", idx)
+ if isinstance(idx, (Iterable, slice)):
+ return GeometryArray(self.data[idx], crs=self.crs)
+ else:
+ raise TypeError("Index type not supported", idx)
def __setitem__(self, key, value):
if compat.PANDAS_GE_10:
@@ -740,8 +742,9 @@ class GeometryArray(ExtensionArray):
>>> a = a.to_crs(3857)
>>> to_wkt(a)
- array(['POINT (111319 111325)', 'POINT (222639 222684)',
- 'POINT (333958 334111)'], dtype=object)
+ array(['POINT (111319.490793 111325.142866)',
+ 'POINT (222638.981587 222684.208506)',
+ 'POINT (333958.47238 334111.171402)'], dtype=object)
>>> a.crs # doctest: +SKIP
<Projected CRS: EPSG:3857>
Name: WGS 84 / Pseudo-Mercator
| TST: tests with invalid values fail with pandas master
We have some recent failures coming from pandas master -
https://github.com/geopandas/geopandas/runs/4059704198?check_suite_focus=true
All seem to be related to the handling of invalid values but I guess that the fix should happen in pandas? I've got no bandwidth now, so filing it to keep an eye on it. | geopandas/geopandas | diff --git a/geopandas/tests/test_extension_array.py b/geopandas/tests/test_extension_array.py
index 6e1205b2..9582404b 100644
--- a/geopandas/tests/test_extension_array.py
+++ b/geopandas/tests/test_extension_array.py
@@ -231,6 +231,18 @@ def as_array(request):
return request.param
[email protected]
+def invalid_scalar(data):
+ """
+ A scalar that *cannot* be held by this ExtensionArray.
+
+ The default should work for most subclasses, but is not guaranteed.
+
+ If the array can hold any item (i.e. object dtype), then use pytest.skip.
+ """
+ return object.__new__(object)
+
+
# Fixtures defined in pandas/conftest.py that are also needed: defining them
# here instead of importing for compatibility
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 0.10 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": true,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.8",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | affine @ file:///home/conda/feedstock_root/build_artifacts/affine_1674245120525/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1722977137225/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1705564648255/work
branca @ file:///home/conda/feedstock_root/build_artifacts/branca_1714071803448/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work
Cartopy @ file:///home/conda/feedstock_root/build_artifacts/cartopy_1634173731720/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1725278078093/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1636046063618/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1728479282467/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1692311806742/work
click-plugins==1.1.1
cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1633637764473/work
contextily @ file:///home/conda/feedstock_root/build_artifacts/contextily_1725373645143/work
contourpy @ file:///home/conda/feedstock_root/build_artifacts/contourpy_1652954517238/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1696677705766/work
exceptiongroup==1.2.2
Fiona==1.8.20
folium @ file:///home/conda/feedstock_root/build_artifacts/folium_1729664526496/work
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1651017731964/work
GDAL==3.3.2
geographiclib @ file:///home/conda/feedstock_root/build_artifacts/geographiclib_1650904727084/work
-e git+https://github.com/geopandas/geopandas.git@9a1509476a8ce2c0092ca8fae3b1c1f5bc741c67#egg=geopandas
geoplot @ file:///home/conda/feedstock_root/build_artifacts/geoplot_1647638253670/work
geopy @ file:///home/conda/feedstock_root/build_artifacts/geopy_1709140178986/work
h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1634280454336/work
hpack==4.0.0
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1619110129307/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1726459485162/work
importlib_resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1725921340658/work
iniconfig==2.1.0
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1715127149914/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1714665484399/work
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1648854389294/work
libpysal @ file:///home/conda/feedstock_root/build_artifacts/libpysal_1668782270408/work
mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1673861555770/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737563195/work
matplotlib @ file:///croot/matplotlib-suite_1693812469450/work
mercantile @ file:///home/conda/feedstock_root/build_artifacts/mercantile_1619028378680/work
munch @ file:///home/conda/feedstock_root/build_artifacts/munch_1688318326844/work
munkres==1.1.4
networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1680692919326/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1651020413938/work
olefile @ file:///home/conda/feedstock_root/build_artifacts/olefile_1701735466804/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas==1.4.2
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1630696607296/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1726613481435/work
pluggy==1.5.0
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1711811537435/work
pyepsg==0.4.0
pygeos @ file:///home/conda/feedstock_root/build_artifacts/pygeos_1629724768668/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1633060551313/work
PyQt5==5.12.3
PyQt5_sip==4.19.18
PyQtChart==5.12
PyQtWebEngine==5.12.1
pyshp @ file:///home/conda/feedstock_root/build_artifacts/pyshp_1659002966020/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1661604839144/work
pytest==8.3.5
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1709299778482/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1726055524169/work
rasterio @ file:///home/conda/feedstock_root/build_artifacts/rasterio_1634058376711/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1717057054362/work
Rtree @ file:///home/conda/feedstock_root/build_artifacts/rtree_1705697874364/work
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1652976690378/work
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1653073867187/work
seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-split_1714494649443/work
Shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1635194351654/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
snuggs @ file:///home/conda/feedstock_root/build_artifacts/snuggs_1722610615774/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1693929250441/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1714400101435/work
tomli==2.2.1
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1648827257044/work
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1649111919534/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1726496430923/work
xyzservices @ file:///home/conda/feedstock_root/build_artifacts/xyzservices_1737234886776/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1731262100163/work
zstandard @ file:///croot/zstandard_1677013143055/work
| name: geopandas
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- affine=2.4.0=pyhd8ed1ab_0
- alsa-lib=1.2.3.2=h166bdaf_0
- attrs=24.2.0=pyh71513ae_0
- beautifulsoup4=4.12.3=pyha770c72_0
- boost-cpp=1.74.0=h312852a_4
- branca=0.7.2=pyhd8ed1ab_0
- brotli=1.0.9=h166bdaf_7
- brotli-bin=1.0.9=h166bdaf_7
- brotli-python=1.0.9=py38hfa26641_7
- bzip2=1.0.8=h7f98852_4
- c-ares=1.18.1=h7f98852_0
- ca-certificates=2025.2.25=h06a4308_0
- cairo=1.16.0=h6cf1ce9_1008
- cartopy=0.20.1=py38hf9a4893_1
- certifi=2024.8.30=pyhd8ed1ab_0
- cffi=1.15.0=py38h3931269_0
- cfitsio=3.470=hb418390_7
- charset-normalizer=3.4.0=pyhd8ed1ab_0
- click=8.1.7=unix_pyh707e725_0
- click-plugins=1.1.1=py_0
- cligj=0.7.2=pyhd8ed1ab_1
- contextily=1.6.2=pyhd8ed1ab_0
- contourpy=1.0.2=py38h43d8883_2
- curl=7.79.1=h2574ce0_1
- cycler=0.12.1=pyhd8ed1ab_0
- dbus=1.13.6=h48d8840_2
- expat=2.4.8=h27087fc_0
- fiona=1.8.20=py38hbb147eb_2
- folium=0.18.0=pyhd8ed1ab_0
- font-ttf-dejavu-sans-mono=2.37=hab24e00_0
- font-ttf-inconsolata=3.000=h77eed37_0
- font-ttf-source-code-pro=2.038=h77eed37_0
- font-ttf-ubuntu=0.83=h77eed37_3
- fontconfig=2.14.0=h8e229c2_0
- fonts-conda-ecosystem=1=0
- fonts-conda-forge=1=0
- fonttools=4.33.3=py38h0a891b7_0
- freetype=2.10.4=h0708190_1
- freexl=1.0.6=h7f98852_0
- gdal=3.3.2=py38h81a01a0_4
- geographiclib=2.0=pyhd8ed1ab_0
- geoplot=0.5.1=pyhd8ed1ab_0
- geopy=2.4.1=pyhd8ed1ab_1
- geos=3.9.1=h9c3ff4c_2
- geotiff=1.7.0=hcfb7246_3
- gettext=0.19.8.1=h73d1719_1008
- giflib=5.2.1=h36c2ea0_2
- glib=2.68.4=h9c3ff4c_1
- glib-tools=2.68.4=h9c3ff4c_1
- gst-plugins-base=1.18.5=hf529b03_0
- gstreamer=1.18.5=h76c114f_0
- h2=4.1.0=pyhd8ed1ab_0
- hdf4=4.2.15=h10796ff_3
- hdf5=1.12.1=nompi_h2750804_100
- hpack=4.0.0=pyh9f0ad1d_0
- hyperframe=6.0.1=pyhd8ed1ab_0
- icu=68.2=h9c3ff4c_0
- idna=3.10=pyhd8ed1ab_0
- importlib_resources=6.4.5=pyhd8ed1ab_0
- jbig=2.1=h7f98852_2003
- jinja2=3.1.4=pyhd8ed1ab_0
- joblib=1.4.2=pyhd8ed1ab_0
- jpeg=9e=h166bdaf_1
- json-c=0.15=h98cffda_0
- kealib=1.4.14=h87e4c3c_3
- keyutils=1.6.1=h166bdaf_0
- kiwisolver=1.4.2=py38h43d8883_1
- krb5=1.19.3=h3790be6_0
- lcms2=2.12=hddcbb42_0
- ld_impl_linux-64=2.40=h12ee557_0
- lerc=2.2.1=h9c3ff4c_0
- libblas=3.9.0=16_linux64_openblas
- libbrotlicommon=1.0.9=h166bdaf_7
- libbrotlidec=1.0.9=h166bdaf_7
- libbrotlienc=1.0.9=h166bdaf_7
- libcblas=3.9.0=16_linux64_openblas
- libclang=11.1.0=default_ha53f305_1
- libcurl=7.79.1=h2574ce0_1
- libdap4=3.20.6=hd7c4107_2
- libdeflate=1.7=h7f98852_5
- libedit=3.1.20191231=he28a2e2_2
- libev=4.33=h516909a_1
- libevent=2.1.10=h9b69904_4
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgdal=3.3.2=h9c9eb65_4
- libgfortran-ng=13.2.0=h69a702a_0
- libgfortran5=13.2.0=ha4646dd_0
- libglib=2.68.4=h174f98d_1
- libgomp=11.2.0=h1234567_1
- libiconv=1.17=h166bdaf_0
- libkml=1.3.0=h238a007_1014
- liblapack=3.9.0=16_linux64_openblas
- libllvm11=11.1.0=hf817b99_2
- libnetcdf=4.8.1=nompi_hb3fd0d9_101
- libnghttp2=1.43.0=h812cca2_1
- libnsl=2.0.0=h7f98852_0
- libogg=1.3.4=h7f98852_1
- libopenblas=0.3.21=h043d6bf_0
- libopus=1.3.1=h7f98852_1
- libpng=1.6.37=h21135ba_2
- libpq=13.3=hd57d9b9_0
- libpysal=4.7.0=pyhd8ed1ab_0
- librttopo=1.1.0=h1185371_6
- libspatialindex=1.9.3=h9c3ff4c_4
- libspatialite=5.0.1=h8796b1e_9
- libssh2=1.10.0=ha56f1ee_2
- libstdcxx-ng=11.2.0=h1234567_1
- libtiff=4.3.0=hf544144_1
- libuuid=2.32.1=h7f98852_1000
- libvorbis=1.3.7=h9c3ff4c_0
- libwebp-base=1.2.2=h7f98852_1
- libxcb=1.13=h7f98852_1004
- libxkbcommon=1.0.3=he3ba5ed_0
- libxml2=2.9.12=h72842e0_0
- libzip=1.8.0=h4de3113_1
- lz4-c=1.9.3=h9c3ff4c_1
- mapclassify=2.5.0=pyhd8ed1ab_1
- markupsafe=2.1.1=py38h0a891b7_1
- matplotlib=3.7.2=py38h578d9bd_0
- matplotlib-base=3.7.2=py38h1128e8f_0
- mercantile=1.2.1=pyhd8ed1ab_0
- munch=4.0.0=pyhd8ed1ab_0
- munkres=1.1.4=pyh9f0ad1d_0
- mysql-common=8.0.25=ha770c72_2
- mysql-libs=8.0.25=hfa10184_2
- ncurses=6.4=h6a678d5_0
- networkx=3.1=pyhd8ed1ab_0
- nspr=4.32=h9c3ff4c_1
- nss=3.69=hb5efdd6_1
- numpy=1.22.3=py38h99721a1_2
- olefile=0.47=pyhd8ed1ab_0
- openjpeg=2.4.0=hb52868f_1
- openssl=1.1.1o=h166bdaf_0
- packaging=24.2=pyhd8ed1ab_2
- pandas=1.4.2=py38h47df419_1
- pcre=8.45=h9c3ff4c_0
- pillow=8.3.2=py38h8e6f84c_0
- pip=24.2=py38h06a4308_0
- pixman=0.40.0=h36c2ea0_0
- platformdirs=4.3.6=pyhd8ed1ab_0
- poppler=21.09.0=ha39eefc_3
- poppler-data=0.4.12=hd8ed1ab_0
- postgresql=13.3=h2510834_0
- proj=8.1.1=h277dcde_2
- pthread-stubs=0.4=h36c2ea0_1001
- pycparser=2.22=pyhd8ed1ab_0
- pyepsg=0.4.0=py_0
- pygeos=0.10.2=py38hb7fe4a8_0
- pyparsing=3.0.9=pyhd8ed1ab_0
- pyproj=3.2.1=py38h80797bf_2
- pyqt=5.12.3=py38h578d9bd_8
- pyqt-impl=5.12.3=py38h0ffb2e6_8
- pyqt5-sip=4.19.18=py38h709712a_8
- pyqtchart=5.12=py38h7400c14_8
- pyqtwebengine=5.12.1=py38h7400c14_8
- pyshp=2.3.1=pyhd8ed1ab_0
- pysocks=1.7.1=pyha2e5f31_6
- python=3.8.12=hb7a2778_1_cpython
- python-dateutil=2.9.0=pyhd8ed1ab_0
- python_abi=3.8=5_cp38
- pytz=2024.2=pyhd8ed1ab_0
- qt=5.12.9=hda022c4_4
- rasterio=1.2.10=py38hfd64e68_0
- readline=8.2=h5eee18b_0
- requests=2.32.3=pyhd8ed1ab_0
- rtree=1.2.0=py38h02d302b_0
- scikit-learn=1.1.1=py38hf80bbf7_0
- scipy=1.8.1=py38h1ee437e_0
- seaborn-base=0.13.2=pyhd8ed1ab_2
- setuptools=75.1.0=py38h06a4308_0
- shapely=1.8.0=py38hb7fe4a8_0
- six=1.16.0=pyh6c4a22f_0
- snuggs=1.4.7=pyhd8ed1ab_1
- soupsieve=2.5=pyhd8ed1ab_1
- sqlite=3.45.3=h5eee18b_0
- threadpoolctl=3.5.0=pyhc1e730c_0
- tiledb=2.3.4=he87e0bf_0
- tk=8.6.14=h39e8969_0
- tornado=6.1=py38h0a891b7_3
- tzcode=2022a=h166bdaf_0
- tzdata=2025b=h78e105d_0
- unicodedata2=14.0.0=py38h0a891b7_1
- urllib3=2.2.3=pyhd8ed1ab_0
- wheel=0.44.0=py38h06a4308_0
- xerces-c=3.2.3=h9d8b166_3
- xorg-kbproto=1.0.7=h7f98852_1002
- xorg-libice=1.0.10=h7f98852_0
- xorg-libsm=1.2.3=hd9c2040_1000
- xorg-libx11=1.7.2=h7f98852_0
- xorg-libxau=1.0.9=h7f98852_0
- xorg-libxdmcp=1.1.3=h7f98852_0
- xorg-libxext=1.3.4=h7f98852_1
- xorg-libxrender=0.9.10=h7f98852_1003
- xorg-renderproto=0.11.1=h7f98852_1002
- xorg-xextproto=7.3.0=h7f98852_1002
- xorg-xproto=7.0.31=h7f98852_1007
- xyzservices=2025.1.0=pyhd8ed1ab_0
- xz=5.6.4=h5eee18b_1
- zipp=3.21.0=pyhd8ed1ab_0
- zlib=1.2.13=h5eee18b_1
- zstandard=0.19.0=py38h5eee18b_0
- zstd=1.5.0=ha95c52a_0
- pip:
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/geopandas
| [
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_invalid"
] | [] | [
"geopandas/tests/test_extension_array.py::TestDtype::test_name",
"geopandas/tests/test_extension_array.py::TestDtype::test_kind",
"geopandas/tests/test_extension_array.py::TestDtype::test_construct_from_string_own_name",
"geopandas/tests/test_extension_array.py::TestDtype::test_is_dtype_from_name",
"geopandas/tests/test_extension_array.py::TestDtype::test_is_dtype_unboxes_dtype",
"geopandas/tests/test_extension_array.py::TestDtype::test_is_dtype_from_self",
"geopandas/tests/test_extension_array.py::TestDtype::test_is_dtype_other_input",
"geopandas/tests/test_extension_array.py::TestDtype::test_is_not_string_type",
"geopandas/tests/test_extension_array.py::TestDtype::test_is_not_object_type",
"geopandas/tests/test_extension_array.py::TestDtype::test_eq_with_str",
"geopandas/tests/test_extension_array.py::TestDtype::test_eq_with_numpy_object",
"geopandas/tests/test_extension_array.py::TestDtype::test_eq_with_self",
"geopandas/tests/test_extension_array.py::TestDtype::test_array_type",
"geopandas/tests/test_extension_array.py::TestDtype::test_check_dtype",
"geopandas/tests/test_extension_array.py::TestDtype::test_hashable",
"geopandas/tests/test_extension_array.py::TestDtype::test_str",
"geopandas/tests/test_extension_array.py::TestDtype::test_eq",
"geopandas/tests/test_extension_array.py::TestDtype::test_construct_from_string",
"geopandas/tests/test_extension_array.py::TestDtype::test_construct_from_string_another_type_raises",
"geopandas/tests/test_extension_array.py::TestDtype::test_construct_from_string_wrong_type_raises",
"geopandas/tests/test_extension_array.py::TestDtype::test_get_common_dtype",
"geopandas/tests/test_extension_array.py::TestDtype::test_infer_dtype[True]",
"geopandas/tests/test_extension_array.py::TestDtype::test_infer_dtype[False]",
"geopandas/tests/test_extension_array.py::TestDtype::test_array_type_with_arg",
"geopandas/tests/test_extension_array.py::TestDtype::test_registry",
"geopandas/tests/test_extension_array.py::TestInterface::test_len",
"geopandas/tests/test_extension_array.py::TestInterface::test_size",
"geopandas/tests/test_extension_array.py::TestInterface::test_ndim",
"geopandas/tests/test_extension_array.py::TestInterface::test_can_hold_na_valid",
"geopandas/tests/test_extension_array.py::TestInterface::test_memory_usage",
"geopandas/tests/test_extension_array.py::TestInterface::test_is_extension_array_dtype",
"geopandas/tests/test_extension_array.py::TestInterface::test_no_values_attribute",
"geopandas/tests/test_extension_array.py::TestInterface::test_is_numeric_honored",
"geopandas/tests/test_extension_array.py::TestInterface::test_isna_extension_array",
"geopandas/tests/test_extension_array.py::TestInterface::test_copy",
"geopandas/tests/test_extension_array.py::TestInterface::test_view",
"geopandas/tests/test_extension_array.py::TestInterface::test_tolist",
"geopandas/tests/test_extension_array.py::TestInterface::test_array_interface",
"geopandas/tests/test_extension_array.py::TestInterface::test_contains",
"geopandas/tests/test_extension_array.py::TestConstructors::test_from_sequence_from_cls",
"geopandas/tests/test_extension_array.py::TestConstructors::test_array_from_scalars",
"geopandas/tests/test_extension_array.py::TestConstructors::test_series_constructor",
"geopandas/tests/test_extension_array.py::TestConstructors::test_series_constructor_no_data_with_index",
"geopandas/tests/test_extension_array.py::TestConstructors::test_series_constructor_scalar_na_with_index",
"geopandas/tests/test_extension_array.py::TestConstructors::test_series_constructor_scalar_with_index",
"geopandas/tests/test_extension_array.py::TestConstructors::test_dataframe_constructor_from_dict[True]",
"geopandas/tests/test_extension_array.py::TestConstructors::test_dataframe_constructor_from_dict[False]",
"geopandas/tests/test_extension_array.py::TestConstructors::test_dataframe_from_series",
"geopandas/tests/test_extension_array.py::TestConstructors::test_series_given_mismatched_index_raises",
"geopandas/tests/test_extension_array.py::TestConstructors::test_from_dtype",
"geopandas/tests/test_extension_array.py::TestConstructors::test_pandas_array",
"geopandas/tests/test_extension_array.py::TestConstructors::test_pandas_array_dtype",
"geopandas/tests/test_extension_array.py::TestConstructors::test_construct_empty_dataframe",
"geopandas/tests/test_extension_array.py::TestConstructors::test_empty",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat[True]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat[False]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat_all_na_block[True]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat_all_na_block[False]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat_mixed_dtypes",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat_columns",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat_extension_arrays_copy_false",
"geopandas/tests/test_extension_array.py::TestReshaping::test_concat_with_reindex",
"geopandas/tests/test_extension_array.py::TestReshaping::test_align",
"geopandas/tests/test_extension_array.py::TestReshaping::test_align_frame",
"geopandas/tests/test_extension_array.py::TestReshaping::test_align_series_frame",
"geopandas/tests/test_extension_array.py::TestReshaping::test_set_frame_expand_regular_with_extension",
"geopandas/tests/test_extension_array.py::TestReshaping::test_set_frame_expand_extension_with_regular",
"geopandas/tests/test_extension_array.py::TestReshaping::test_set_frame_overwrite_object",
"geopandas/tests/test_extension_array.py::TestReshaping::test_merge",
"geopandas/tests/test_extension_array.py::TestReshaping::test_merge_on_extension_array",
"geopandas/tests/test_extension_array.py::TestReshaping::test_merge_on_extension_array_duplicates",
"geopandas/tests/test_extension_array.py::TestReshaping::test_stack[columns0]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_stack[columns1]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[series-index0]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[series-index1]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[series-index2]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[series-index3]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[frame-index0]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[frame-index1]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[frame-index2]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_unstack[frame-index3]",
"geopandas/tests/test_extension_array.py::TestReshaping::test_ravel",
"geopandas/tests/test_extension_array.py::TestReshaping::test_transpose",
"geopandas/tests/test_extension_array.py::TestReshaping::test_transpose_frame",
"geopandas/tests/test_extension_array.py::TestGetitem::test_iloc_series",
"geopandas/tests/test_extension_array.py::TestGetitem::test_iloc_frame",
"geopandas/tests/test_extension_array.py::TestGetitem::test_iloc_frame_single_block",
"geopandas/tests/test_extension_array.py::TestGetitem::test_loc_series",
"geopandas/tests/test_extension_array.py::TestGetitem::test_loc_frame",
"geopandas/tests/test_extension_array.py::TestGetitem::test_loc_iloc_frame_single_dtype",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_scalar",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_scalar_na",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_empty",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_mask",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_mask_raises",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_boolean_array_mask",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_boolean_na_treated_as_false",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_integer_array[list]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_integer_array[integer-array]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_integer_array[numpy-array]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_integer_with_missing_raises[list]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_integer_with_missing_raises[integer-array]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_slice",
"geopandas/tests/test_extension_array.py::TestGetitem::test_getitem_ellipsis_and_slice",
"geopandas/tests/test_extension_array.py::TestGetitem::test_get",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_sequence",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_empty",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_negative",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_non_na_fill_value",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_pandas_style_negative_raises",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_out_of_bounds_raises[True]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_out_of_bounds_raises[False]",
"geopandas/tests/test_extension_array.py::TestGetitem::test_take_series",
"geopandas/tests/test_extension_array.py::TestGetitem::test_reindex",
"geopandas/tests/test_extension_array.py::TestGetitem::test_reindex_non_na_fill_value",
"geopandas/tests/test_extension_array.py::TestGetitem::test_loc_len1",
"geopandas/tests/test_extension_array.py::TestGetitem::test_item",
"geopandas/tests/test_extension_array.py::TestGetitem::test_ellipsis_index",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_scalar_series[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_scalar_series[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_sequence[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_sequence[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_sequence_mismatched_length_raises[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_sequence_mismatched_length_raises[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_empty_indexer[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_empty_indexer[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_sequence_broadcasts[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_sequence_broadcasts[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_scalar[loc]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_scalar[iloc]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_loc_scalar_mixed",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_loc_scalar_single",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_loc_scalar_multiple_homogoneous",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_iloc_scalar_mixed",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_iloc_scalar_single",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_iloc_scalar_multiple_homogoneous",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask[True-numpy-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask[True-boolean-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask[True-boolean-array-na]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask[False-numpy-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask[False-boolean-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask[False-boolean-array-na]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_raises[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_raises[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_boolean_array_with_na[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_boolean_array_with_na[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_array[True-list]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_array[True-integer-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_array[True-numpy-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_array[False-list]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_array[False-integer-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_array[False-numpy-array]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_with_missing_raises[list-False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_with_missing_raises[integer-array-False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_integer_with_missing_raises[integer-array-True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_aligned[loc-True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_aligned[loc-False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_aligned[None-True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_aligned[None-False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_broadcast[loc]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_mask_broadcast[None]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_expand_columns",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_expand_with_extension",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_frame_invalid_length",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_tuple_index",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_slice[True]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_slice[False]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_loc_iloc_slice",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_slice_mismatch_length_raises",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_slice_array",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_scalar_key_sequence_raise",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_preserves_views",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[index]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[list[index]]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[null_slice]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[full_slice]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[range]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[list(range)]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_with_expansion_dataframe_column[mask]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[index]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[list[index]]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[null_slice]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[full_slice]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[range]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[list(range)]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_series[mask]",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_frame_2d_values",
"geopandas/tests/test_extension_array.py::TestSetitem::test_delitem_series",
"geopandas/tests/test_extension_array.py::TestSetitem::test_setitem_invalid",
"geopandas/tests/test_extension_array.py::TestMissing::test_isna",
"geopandas/tests/test_extension_array.py::TestMissing::test_isna_returns_copy[isna]",
"geopandas/tests/test_extension_array.py::TestMissing::test_isna_returns_copy[notna]",
"geopandas/tests/test_extension_array.py::TestMissing::test_dropna_array",
"geopandas/tests/test_extension_array.py::TestMissing::test_dropna_series",
"geopandas/tests/test_extension_array.py::TestMissing::test_dropna_frame",
"geopandas/tests/test_extension_array.py::TestMissing::test_fillna_scalar",
"geopandas/tests/test_extension_array.py::TestMissing::test_fillna_frame",
"geopandas/tests/test_extension_array.py::TestMissing::test_fillna_fill_other",
"geopandas/tests/test_extension_array.py::TestMissing::test_use_inf_as_na_no_effect",
"geopandas/tests/test_extension_array.py::TestMissing::test_fillna_series",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[sum-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[sum-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[max-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[max-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[min-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[min-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[mean-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[mean-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[prod-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[prod-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[std-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[std-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[var-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[var-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[median-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[median-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[kurt-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[kurt-False]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[skew-True]",
"geopandas/tests/test_extension_array.py::TestReduce::test_reduce_series_numeric[skew-False]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__add__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__radd__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__mul__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__rmul__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__floordiv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__rfloordiv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__truediv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__rtruediv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__pow__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__rpow__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__mod__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_scalar[__rmod__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__add__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__radd__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__mul__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__rmul__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__floordiv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__rfloordiv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__truediv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__rtruediv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__pow__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__rpow__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__mod__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_frame_with_scalar[__rmod__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__add__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__radd__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__mul__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__rmul__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__floordiv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__rfloordiv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__truediv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__rtruediv__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__pow__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__rpow__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__mod__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_arith_series_with_array[__rmod__]",
"geopandas/tests/test_extension_array.py::TestArithmeticOps::test_divmod",
"geopandas/tests/test_extension_array.py::TestComparisonOps::test_direct_arith_with_ndframe_returns_not_implemented[Series]",
"geopandas/tests/test_extension_array.py::TestComparisonOps::test_direct_arith_with_ndframe_returns_not_implemented[DataFrame]",
"geopandas/tests/test_extension_array.py::TestComparisonOps::test_compare_scalar[__eq__]",
"geopandas/tests/test_extension_array.py::TestComparisonOps::test_compare_scalar[__ne__]",
"geopandas/tests/test_extension_array.py::TestComparisonOps::test_compare_array[__eq__]",
"geopandas/tests/test_extension_array.py::TestComparisonOps::test_compare_array[__ne__]",
"geopandas/tests/test_extension_array.py::TestMethods::test_value_counts_default_dropna",
"geopandas/tests/test_extension_array.py::TestMethods::test_count",
"geopandas/tests/test_extension_array.py::TestMethods::test_series_count",
"geopandas/tests/test_extension_array.py::TestMethods::test_apply_simple_series",
"geopandas/tests/test_extension_array.py::TestMethods::test_unique[<lambda>-Series]",
"geopandas/tests/test_extension_array.py::TestMethods::test_unique[<lambda>-<lambda>]",
"geopandas/tests/test_extension_array.py::TestMethods::test_unique[unique-Series]",
"geopandas/tests/test_extension_array.py::TestMethods::test_unique[unique-<lambda>]",
"geopandas/tests/test_extension_array.py::TestMethods::test_factorize[-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_factorize[-2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_factorize_equivalence[-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_factorize_equivalence[-2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_factorize_empty",
"geopandas/tests/test_extension_array.py::TestMethods::test_fillna_copy_frame",
"geopandas/tests/test_extension_array.py::TestMethods::test_fillna_copy_series",
"geopandas/tests/test_extension_array.py::TestMethods::test_combine_first",
"geopandas/tests/test_extension_array.py::TestMethods::test_container_shift[-2-indices0-True]",
"geopandas/tests/test_extension_array.py::TestMethods::test_container_shift[-2-indices0-False]",
"geopandas/tests/test_extension_array.py::TestMethods::test_container_shift[0-indices1-True]",
"geopandas/tests/test_extension_array.py::TestMethods::test_container_shift[0-indices1-False]",
"geopandas/tests/test_extension_array.py::TestMethods::test_container_shift[2-indices2-True]",
"geopandas/tests/test_extension_array.py::TestMethods::test_container_shift[2-indices2-False]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_0_periods",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_non_empty_array[-4-indices0]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_non_empty_array[-1-indices1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_non_empty_array[0-indices2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_non_empty_array[1-indices3]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_non_empty_array[4-indices4]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_empty_array[-4]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_empty_array[-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_empty_array[0]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_empty_array[1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_empty_array[4]",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_zero_copies",
"geopandas/tests/test_extension_array.py::TestMethods::test_shift_fill_value",
"geopandas/tests/test_extension_array.py::TestMethods::test_not_hashable",
"geopandas/tests/test_extension_array.py::TestMethods::test_hash_pandas_object_works[True]",
"geopandas/tests/test_extension_array.py::TestMethods::test_hash_pandas_object_works[False]",
"geopandas/tests/test_extension_array.py::TestMethods::test_where_series[True]",
"geopandas/tests/test_extension_array.py::TestMethods::test_where_series[False]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-True-0]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-True-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-True-2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-True-repeats3]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-False-0]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-False-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-False-2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[True-False-repeats3]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-True-0]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-True-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-True-2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-True-repeats3]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-False-0]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-False-1]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-False-2]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat[False-False-repeats3]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[True-2-kwargs0-ValueError-axis]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[True--1-kwargs1-ValueError-negative]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[True-repeats2-kwargs2-ValueError-shape]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[True-2-kwargs3-TypeError-'foo']",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[False-2-kwargs0-ValueError-axis]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[False--1-kwargs1-ValueError-negative]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[False-repeats2-kwargs2-ValueError-shape]",
"geopandas/tests/test_extension_array.py::TestMethods::test_repeat_raises[False-2-kwargs3-TypeError-'foo']",
"geopandas/tests/test_extension_array.py::TestMethods::test_delete",
"geopandas/tests/test_extension_array.py::TestMethods::test_insert",
"geopandas/tests/test_extension_array.py::TestMethods::test_insert_invalid",
"geopandas/tests/test_extension_array.py::TestMethods::test_insert_invalid_loc",
"geopandas/tests/test_extension_array.py::TestMethods::test_equals[True-array]",
"geopandas/tests/test_extension_array.py::TestMethods::test_equals[True-Series]",
"geopandas/tests/test_extension_array.py::TestMethods::test_equals[True-DataFrame]",
"geopandas/tests/test_extension_array.py::TestMethods::test_equals[False-array]",
"geopandas/tests/test_extension_array.py::TestMethods::test_equals[False-Series]",
"geopandas/tests/test_extension_array.py::TestMethods::test_equals[False-DataFrame]",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_object_series[data]",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_object_series[data_missing]",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_object_frame[data]",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_object_frame[data_missing]",
"geopandas/tests/test_extension_array.py::TestCasting::test_tolist",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_str",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_string[string[python]]",
"geopandas/tests/test_extension_array.py::TestCasting::test_to_numpy",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_empty_dataframe",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_own_type[True]",
"geopandas/tests/test_extension_array.py::TestCasting::test_astype_own_type[False]",
"geopandas/tests/test_extension_array.py::TestGroupby::test_grouping_grouper",
"geopandas/tests/test_extension_array.py::TestGroupby::test_groupby_agg_extension",
"geopandas/tests/test_extension_array.py::TestGroupby::test_groupby_extension_no_sort",
"geopandas/tests/test_extension_array.py::TestGroupby::test_groupby_apply_identity",
"geopandas/tests/test_extension_array.py::TestGroupby::test_in_numeric_groupby",
"geopandas/tests/test_extension_array.py::TestPrinting::test_array_repr[big]",
"geopandas/tests/test_extension_array.py::TestPrinting::test_array_repr[small]",
"geopandas/tests/test_extension_array.py::TestPrinting::test_array_repr_unicode",
"geopandas/tests/test_extension_array.py::TestPrinting::test_series_repr",
"geopandas/tests/test_extension_array.py::TestPrinting::test_dataframe_repr",
"geopandas/tests/test_extension_array.py::TestPrinting::test_dtype_name_in_info"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,540 | 483 | [
"geopandas/array.py"
] |
edgewall__genshi-53 | 4c402aa08c37fe979487abf3ccd866417052f44d | 2021-11-07 14:58:06 | 43496ec3cd21113f5332bb2664d9f9d37c40270b | diff --git a/genshi/template/markup.py b/genshi/template/markup.py
index 22f0602..dd441b9 100644
--- a/genshi/template/markup.py
+++ b/genshi/template/markup.py
@@ -172,11 +172,14 @@ class MarkupTemplate(Template):
]
elif kind is SUB:
- directives, substream = data
- substream = self._extract_directives(substream, namespace,
+ directives, prev_substream = data
+ substream = self._extract_directives(prev_substream, namespace,
factory)
- if len(substream) == 1 and substream[0][0] is SUB:
+ if (len(substream) == 1 and substream[0][0] is SUB
+ # merge only if the direct substream has changed
+ and (prev_substream[0][0] is not SUB
+ or prev_substream[0][1][0] != substream[0][1][0])):
added_directives, substream = substream[0][1]
directives += added_directives
| Translator filter merge sub-directives
I have wrote a test that shows the problem: https://github.com/cedk/genshi/commit/53f60233156b87190f03b7dca3f59cd6acaba56b | edgewall/genshi | diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
deleted file mode 100644
index 936554a..0000000
--- a/.github/workflows/tests.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-name: run
-
-on: [push]
-
-jobs:
- tests:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- python-version: [2.7, 3.6, 3.7, 3.8, 3.9, '3.10-dev', pypy2, pypy3]
-
- steps:
- - uses: actions/checkout@v2
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v2
- with:
- python-version: ${{ matrix.python-version }}
-
- - name: Run test suite
- run: |
- python setup.py test
-
diff --git a/genshi/filters/tests/i18n.py b/genshi/filters/tests/i18n.py
index 80d0924..18548f2 100644
--- a/genshi/filters/tests/i18n.py
+++ b/genshi/filters/tests/i18n.py
@@ -301,6 +301,19 @@ class TranslatorTestCase(unittest.TestCase):
<span title="Voh">...</span>
</html>""", tmpl.generate().render())
+ def test_translate_nested_directives(self):
+ html = """<html xmlns:py="http://genshi.edgewall.org/">
+ <py:with vars="x = 'test'"><py:if test="x">
+ </py:if></py:with>
+ </html>"""
+ tmpl = MarkupTemplate(html)
+ raw = tmpl.generate().render()
+ tmpl = MarkupTemplate(html)
+ translator = Translator(DummyTranslations())
+ translator.setup(tmpl)
+ translated = tmpl.generate().render()
+ self.assertEqual(raw, translated)
+
class MsgDirectiveTestCase(unittest.TestCase):
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 0
},
"num_modified_files": 1
} | 0.7 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "six",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup==1.2.2
-e git+https://github.com/edgewall/genshi.git@4c402aa08c37fe979487abf3ccd866417052f44d#egg=Genshi
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
six @ file:///tmp/build/80754af9/six_1644875935023/work
tomli==2.2.1
| name: genshi
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- six=1.16.0=pyhd3eb1b0_1
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/genshi
| [
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_translate_nested_directives"
] | [] | [
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_attribute_expr",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_funky_plural_form",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_gettext_with_unicode_string",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_included_attribute_text",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_included_attribute_text_with_spaces",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_included_empty_attribute_text",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_non_included_attribute_interpolated",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_plural_form",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_tag_with_variable_xml_lang",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_text_from_sub",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_extract_without_text",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_ignore_attribute_with_expression",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_ignore_tag_with_fixed_xml_lang",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_translate_included_attribute_text",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_translate_included_attribute_text_with_spaces",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_translate_included_empty_attribute_text",
"genshi/filters/tests/i18n.py::TranslatorTestCase::test_translate_with_translations_object",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_as_element_with_attributes",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_elt_nonewline",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_empty",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_label_with_nested_input",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_multiple",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_multiple_empty",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_nested",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_nonewline",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_attr",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_attributes",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_comment",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_directive",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_dynamic_attributes",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_other_directives_nested",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_param",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_py_strip",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_py_strip_and_comment",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_extract_i18n_msg_with_two_params",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_i18n_msg_ticket_251_extract",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_i18n_msg_ticket_251_translate",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_i18n_msg_ticket_300_extract",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_i18n_msg_ticket_300_translate",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_i18n_msg_with_other_nested_directives_with_reordered_content",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_and_comment_with_py_strip_directives",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_and_py_strip_directives",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_as_element_with_attributes",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_elt_nonewline",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_empty",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_label_with_nested_input",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_multiple",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_multiple_empty",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_nested",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_nonewline",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_ticket_404",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_ticket_404_regression",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_attr",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_attribute_param",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_attributes",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_comment",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_directive",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_dynamic_attributes",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_other_directives_nested",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_param",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_param_reordered",
"genshi/filters/tests/i18n.py::MsgDirectiveTestCase::test_translate_i18n_msg_with_two_params",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_attribute",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_attribute_and_py_strip",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_attribute_with_params",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_attribute_with_params_and_comment",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_attribute_with_params_and_domain_as_param",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_directive",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_directive_with_params",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_directive_with_params_and_comment",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_directive_with_params_and_domain_as_directive",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_as_element_with_attributes",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_extract_i18n_choose_with_attributes",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_and_domain_and_py_strip",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_and_plural_with_py_strip",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_and_py_strip",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_and_singular_with_py_strip",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_attribute",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_attribute_with_params",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_attribute_with_params_and_domain_as_param",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_directive",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_directive_singular_and_plural_with_strip",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_directive_with_params",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_directive_with_params_and_domain_as_directive",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_as_element_with_attributes",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_plural_singular_as_directive",
"genshi/filters/tests/i18n.py::ChooseDirectiveTestCase::test_translate_i18n_choose_with_attributes",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_as_directive_not_attribute",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_nested_directives",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_empty_nested_domain_directive",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_inline_directive_on_START_NS",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_inline_directive_on_START_NS_with_py_strip",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_inline_directives",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_msg_directives",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_nested_includes",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_with_nested_includes_with_translatable_attrs",
"genshi/filters/tests/i18n.py::DomainDirectiveTestCase::test_translate_i18n_domain_without_msg_directives",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_extract_py_def_directive_with_py_strip",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_extraction_inside_ignored_tags",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_extraction_inside_ignored_tags_with_directives",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_extraction_with_keyword_arg",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_extraction_with_nonstring_arg",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_extraction_without_text",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_markup_template_extraction",
"genshi/filters/tests/i18n.py::ExtractTestCase::test_text_template_extraction",
"genshi/filters/tests/i18n.py::ContextDirectiveTestCase::test_extract_msgcontext",
"genshi/filters/tests/i18n.py::ContextDirectiveTestCase::test_translate_context_with_msg",
"genshi/filters/tests/i18n.py::ContextDirectiveTestCase::test_translate_msgcontext",
"genshi/filters/tests/i18n.py::ContextDirectiveTestCase::test_translate_msgcontext_with_domain",
"genshi/filters/tests/i18n.py::ContextDirectiveTestCase::test_translate_msgcontext_with_plurals"
] | [] | BSD License | 11,546 | 266 | [
"genshi/template/markup.py"
] |
|
frictionlessdata__frictionless-py-946 | 02e14a06659f0b2c1b5dd48eda3ae3eaf70018e3 | 2021-11-08 12:59:44 | 02e14a06659f0b2c1b5dd48eda3ae3eaf70018e3 | diff --git a/frictionless/package.py b/frictionless/package.py
index f3cdc7f9..2ce2eb13 100644
--- a/frictionless/package.py
+++ b/frictionless/package.py
@@ -712,6 +712,9 @@ class Package(Metadata):
# Resources
for resource in self.resources:
yield from resource.metadata_errors
+ if len(self.resource_names) != len(set(self.resource_names)):
+ note = "names of the resources are not unique"
+ yield errors.PackageError(note=note)
# Created
if self.get("created"):
| Resources with duplicate property "name" in datapackage.json files
# Overview
The `frictionless validate` option doesn't return any error if a datapackage.json contains two resources with the same "name" property.
I believe that it could be validated for two reasons:
Frist: Because as pointed in frictionless [specs](https://specs.frictionlessdata.io/data-resource/#metadata-properties) "if present, the name MUST be unique amongst all resources in this data package".
Second: As I tested, if [package.get_resource function](https://framework.frictionlessdata.io/docs/references/api-reference/#packageget_resource) is needed to extract the resource information, only the first resource listed in my datapackage.json will the returned.
What makes more sense: an error during `frictionless validate` call or return all resources with the same name in package.get_resource function?
---
Please preserve this line to notify @roll (lead of this repository)
| frictionlessdata/frictionless-py | diff --git a/tests/test_package.py b/tests/test_package.py
index c3537d34..0a61a4bf 100644
--- a/tests/test_package.py
+++ b/tests/test_package.py
@@ -1030,3 +1030,15 @@ def test_package_validation_is_not_strict_enough_issue_869():
assert len(errors) == 2
assert errors[0].note == 'property "created" is not valid "datetime"'
assert errors[1].note == 'property "contributors[].email" is not valid "email"'
+
+
+def test_package_validation_duplicate_resource_names_issue_942():
+ package = Package(
+ resources=[
+ Resource(name="name", path="data/table.csv"),
+ Resource(name="name", path="data/table.csv"),
+ ]
+ )
+ errors = package.metadata_errors
+ assert len(errors) == 1
+ assert errors[0].note == "names of the resources are not unique"
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 1
},
"num_modified_files": 1
} | 4.20 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install --upgrade -e .[bigquery,ckan,excel,gsheets,html,json,ods,pandas,s3,server,spss,sql,dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc",
"apt-get install -y postgresql libpq-dev"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | asttokens==3.0.0
attrs==25.3.0
black==23.12.1
blinker==1.9.0
boto3==1.37.23
botocore==1.37.23
cached-property==2.0.1
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
ckanapi==4.8
click==8.1.8
coverage==7.8.0
cryptography==44.0.2
cssselect==1.3.0
databind==4.5.2
databind.core==4.5.2
databind.json==4.5.2
decorator==5.2.1
deepmerge==2.0
Deprecated==1.2.18
docopt==0.6.2
docspec==2.2.1
docspec-python==2.2.1
docstring_parser==0.11
et_xmlfile==2.0.0
exceptiongroup==1.2.2
execnet==2.1.1
executing==2.2.0
ezodf==0.3.2
Flask==3.1.0
-e git+https://github.com/frictionlessdata/frictionless-py.git@02e14a06659f0b2c1b5dd48eda3ae3eaf70018e3#egg=frictionless
gitdb==4.0.12
GitPython==3.1.44
giturlparse==0.12.0
google-api-core==2.24.2
google-api-python-client==2.166.0
google-auth==2.38.0
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.1
googleapis-common-protos==1.69.2
greenlet==3.1.1
gunicorn==23.0.0
httplib2==0.22.0
idna==3.10
ijson==3.3.0
importlib_metadata==8.6.1
iniconfig==2.1.0
ipython==8.18.1
isodate==0.7.2
itsdangerous==2.2.0
jedi==0.19.2
Jinja2==3.1.6
jmespath==1.0.1
jsonlines==4.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
livemark==0.110.8
livereload==2.7.1
lxml==5.3.1
markdown-it-py==3.0.0
marko==1.3.1
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mccabe==0.7.0
mdurl==0.1.2
moto==5.1.2
multidict==6.2.0
mypy==1.15.0
mypy-extensions==1.0.0
nr-date==2.1.0
nr-stream==1.1.5
nr.util==0.8.12
numpy==2.0.2
oauth2client==4.1.3
oauthlib==3.2.2
openpyxl==3.1.5
packaging==24.2
pandas==2.2.3
parso==0.8.4
pathspec==0.12.1
petl==1.7.15
pexpect==4.9.0
platformdirs==4.3.7
pluggy==1.5.0
prompt_toolkit==3.0.50
propcache==0.3.1
proto-plus==1.26.1
protobuf==6.30.2
psycopg2==2.9.10
ptyprocess==0.7.0
pure_eval==0.2.3
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycodestyle==2.13.0
pycparser==2.22
pydoc-markdown==4.8.2
pydocstyle==6.3.0
pyflakes==3.3.2
Pygments==2.19.1
pygsheets==2.0.6
pylama==8.4.1
PyMySQL==1.1.1
pyparsing==3.2.3
pyquery==1.4.3
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-only==2.1.2
pytest-vcr==1.0.2
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-dotenv==1.1.0
python-slugify==8.0.4
pytz==2025.2
PyYAML==6.0.2
referencing==0.36.2
requests==2.32.3
requests-mock==1.12.1
requests-oauthlib==2.0.0
responses==0.25.7
rfc3986==2.0.0
rich==14.0.0
rpds-py==0.24.0
rsa==4.9
s3transfer==0.11.4
savReaderWriter==3.4.2
shellingham==1.5.4
simpleeval==1.0.3
simplejson==3.20.1
six==1.17.0
smmap==5.0.2
snowballstemmer==2.2.0
SQLAlchemy==2.0.40
stack-data==0.6.3
stringcase==1.2.0
text-unidecode==1.3
tomli==2.2.1
tomli_w==1.2.0
tornado==6.4.2
traitlets==5.14.3
typeapi==2.2.4
typer==0.15.2
typing_extensions==4.13.0
tzdata==2025.2
uritemplate==4.1.1
urllib3==1.26.20
validators==0.34.0
vcrpy==7.0.0
watchdog==6.0.0
wcwidth==0.2.13
Werkzeug==3.1.3
wrapt==1.17.2
xlrd==2.0.1
xlwt==1.3.0
xmltodict==0.14.2
yapf==0.43.0
yarl==1.18.3
zipp==3.21.0
| name: frictionless-py
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- asttokens==3.0.0
- attrs==25.3.0
- black==23.12.1
- blinker==1.9.0
- boto3==1.37.23
- botocore==1.37.23
- cached-property==2.0.1
- cachetools==5.5.2
- certifi==2025.1.31
- cffi==1.17.1
- chardet==5.2.0
- charset-normalizer==3.4.1
- ckanapi==4.8
- click==8.1.8
- coverage==7.8.0
- cryptography==44.0.2
- cssselect==1.3.0
- databind==4.5.2
- databind-core==4.5.2
- databind-json==4.5.2
- decorator==5.2.1
- deepmerge==2.0
- deprecated==1.2.18
- docopt==0.6.2
- docspec==2.2.1
- docspec-python==2.2.1
- docstring-parser==0.11
- et-xmlfile==2.0.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- executing==2.2.0
- ezodf==0.3.2
- flask==3.1.0
- frictionless==4.20.1
- gitdb==4.0.12
- gitpython==3.1.44
- giturlparse==0.12.0
- google-api-core==2.24.2
- google-api-python-client==2.166.0
- google-auth==2.38.0
- google-auth-httplib2==0.2.0
- google-auth-oauthlib==1.2.1
- googleapis-common-protos==1.69.2
- greenlet==3.1.1
- gunicorn==23.0.0
- httplib2==0.22.0
- idna==3.10
- ijson==3.3.0
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- ipython==8.18.1
- isodate==0.7.2
- itsdangerous==2.2.0
- jedi==0.19.2
- jinja2==3.1.6
- jmespath==1.0.1
- jsonlines==4.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- livemark==0.110.8
- livereload==2.7.1
- lxml==5.3.1
- markdown-it-py==3.0.0
- marko==1.3.1
- markupsafe==3.0.2
- matplotlib-inline==0.1.7
- mccabe==0.7.0
- mdurl==0.1.2
- moto==5.1.2
- multidict==6.2.0
- mypy==1.15.0
- mypy-extensions==1.0.0
- nr-date==2.1.0
- nr-stream==1.1.5
- nr-util==0.8.12
- numpy==2.0.2
- oauth2client==4.1.3
- oauthlib==3.2.2
- openpyxl==3.1.5
- packaging==24.2
- pandas==2.2.3
- parso==0.8.4
- pathspec==0.12.1
- petl==1.7.15
- pexpect==4.9.0
- platformdirs==4.3.7
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- propcache==0.3.1
- proto-plus==1.26.1
- protobuf==6.30.2
- psycopg2==2.9.10
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pyasn1==0.6.1
- pyasn1-modules==0.4.2
- pycodestyle==2.13.0
- pycparser==2.22
- pydoc-markdown==4.8.2
- pydocstyle==6.3.0
- pyflakes==3.3.2
- pygments==2.19.1
- pygsheets==2.0.6
- pylama==8.4.1
- pymysql==1.1.1
- pyparsing==3.2.3
- pyquery==1.4.3
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-only==2.1.2
- pytest-vcr==1.0.2
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- python-dotenv==1.1.0
- python-slugify==8.0.4
- pytz==2025.2
- pyyaml==6.0.2
- referencing==0.36.2
- requests==2.32.3
- requests-mock==1.12.1
- requests-oauthlib==2.0.0
- responses==0.25.7
- rfc3986==2.0.0
- rich==14.0.0
- rpds-py==0.24.0
- rsa==4.9
- s3transfer==0.11.4
- savreaderwriter==3.4.2
- shellingham==1.5.4
- simpleeval==1.0.3
- simplejson==3.20.1
- six==1.17.0
- smmap==5.0.2
- snowballstemmer==2.2.0
- sqlalchemy==2.0.40
- stack-data==0.6.3
- stringcase==1.2.0
- text-unidecode==1.3
- tomli==2.2.1
- tomli-w==1.2.0
- tornado==6.4.2
- traitlets==5.14.3
- typeapi==2.2.4
- typer==0.15.2
- typing-extensions==4.13.0
- tzdata==2025.2
- uritemplate==4.1.1
- urllib3==1.26.20
- validators==0.34.0
- vcrpy==7.0.0
- watchdog==6.0.0
- wcwidth==0.2.13
- werkzeug==3.1.3
- wrapt==1.17.2
- xlrd==2.0.1
- xlwt==1.3.0
- xmltodict==0.14.2
- yapf==0.43.0
- yarl==1.18.3
- zipp==3.21.0
prefix: /opt/conda/envs/frictionless-py
| [
"tests/test_package.py::test_package_validation_duplicate_resource_names_issue_942"
] | [
"tests/test_package.py::test_package_external_profile_invalid_remote",
"tests/test_package.py::test_package_external_profile_invalid_remote_from_descriptor"
] | [
"tests/test_package.py::test_package",
"tests/test_package.py::test_package_from_dict",
"tests/test_package.py::test_package_from_path",
"tests/test_package.py::test_package_from_pathlib",
"tests/test_package.py::test_package_from_path_error_bad_path",
"tests/test_package.py::test_package_from_path_error_non_json",
"tests/test_package.py::test_package_from_path_error_bad_json",
"tests/test_package.py::test_package_from_path_error_bad_json_not_dict",
"tests/test_package.py::test_package_from_path_remote",
"tests/test_package.py::test_package_from_path_remote_error_not_found",
"tests/test_package.py::test_package_from_path_remote_error_bad_json",
"tests/test_package.py::test_package_from_path_remote_error_bad_json_not_dict",
"tests/test_package.py::test_package_from_invalid_descriptor_type",
"tests/test_package.py::test_package_from_zip",
"tests/test_package.py::test_package_from_zip_remote",
"tests/test_package.py::test_package_from_zip_no_descriptor",
"tests/test_package.py::test_package_from_zip_innerpath",
"tests/test_package.py::test_package_standard_specs_properties[create_descriptor0]",
"tests/test_package.py::test_package_standard_specs_properties[create_descriptor1]",
"tests/test_package.py::test_package_description_html",
"tests/test_package.py::test_package_description_html_multiline",
"tests/test_package.py::test_package_description_text",
"tests/test_package.py::test_package_description_text_plain",
"tests/test_package.py::test_package_resources",
"tests/test_package.py::test_package_resources_inline",
"tests/test_package.py::test_package_resources_empty",
"tests/test_package.py::test_package_add_resource",
"tests/test_package.py::test_package_get_resource",
"tests/test_package.py::test_package_get_resource_error_not_found",
"tests/test_package.py::test_package_remove_resource",
"tests/test_package.py::test_package_remove_resource_error_not_found",
"tests/test_package.py::test_package_update_resource",
"tests/test_package.py::test_package_resources_append_in_place",
"tests/test_package.py::test_package_resources_remove_in_place",
"tests/test_package.py::test_package_resources_respect_layout_set_after_creation_issue_503",
"tests/test_package.py::test_package_compression_implicit_gz",
"tests/test_package.py::test_package_compression_implicit_zip",
"tests/test_package.py::test_package_compression_explicit_gz",
"tests/test_package.py::test_package_compression_explicit_zip",
"tests/test_package.py::test_package_schema_foreign_key",
"tests/test_package.py::test_package_schema_foreign_key_invalid",
"tests/test_package.py::test_package_schema_foreign_key_self_reference",
"tests/test_package.py::test_package_schema_foreign_key_self_reference_invalid",
"tests/test_package.py::test_package_schema_foreign_key_multifield",
"tests/test_package.py::test_package_schema_foreign_key_multifield_invalid",
"tests/test_package.py::test_resource_onerror",
"tests/test_package.py::test_resource_onerror_header_warn",
"tests/test_package.py::test_resource_onerror_header_raise",
"tests/test_package.py::test_resource_onerror_row_warn",
"tests/test_package.py::test_resource_onerror_row_raise",
"tests/test_package.py::test_package_expand",
"tests/test_package.py::test_package_expand_empty",
"tests/test_package.py::test_package_expand_resource_schema",
"tests/test_package.py::test_package_expand_resource_dialect",
"tests/test_package.py::test_package_infer",
"tests/test_package.py::test_package_infer_with_basepath",
"tests/test_package.py::test_package_infer_multiple_paths",
"tests/test_package.py::test_package_infer_non_utf8_file",
"tests/test_package.py::test_package_infer_empty_file",
"tests/test_package.py::test_package_infer_duplicate_resource_names_issue_530",
"tests/test_package.py::test_package_to_copy",
"tests/test_package.py::test_package_to_json",
"tests/test_package.py::test_package_to_yaml",
"tests/test_package.py::test_package_to_zip",
"tests/test_package.py::test_package_to_zip_resource_path",
"tests/test_package.py::test_package_to_zip_resource_remote_path",
"tests/test_package.py::test_package_to_zip_resource_memory_inline",
"tests/test_package.py::test_package_to_zip_resource_memory_function",
"tests/test_package.py::test_package_external_profile",
"tests/test_package.py::test_package_external_profile_invalid_local",
"tests/test_package.py::test_package_external_profile_invalid_local_from_descriptor",
"tests/test_package.py::test_package_external_profile_invalid_local_from_descriptor_unsafe",
"tests/test_package.py::test_package_external_profile_invalid_local_from_descriptor_unsafe_trusted",
"tests/test_package.py::test_package_dialect_no_header_issue_167",
"tests/test_package.py::test_package_validation_is_not_strict_enough_issue_869"
] | [] | MIT License | 11,550 | 141 | [
"frictionless/package.py"
] |
|
infobloxopen__infoblox-client-292 | 2efaf4b92fb077af28a2f5e44b88b6083efaa084 | 2021-11-09 13:42:45 | b6af5306673744ee1de9285ef6b1cd90e0838f6e | diff --git a/infoblox_client/connector.py b/infoblox_client/connector.py
index a2946b6..2e9928b 100644
--- a/infoblox_client/connector.py
+++ b/infoblox_client/connector.py
@@ -44,6 +44,8 @@ CLOUD_WAPI_MAJOR_VERSION = 2
def reraise_neutron_exception(func):
+ """This decorator catches third-party exceptions and replaces them with
+ Infoblox exceptions"""
@functools.wraps(func)
def callee(*args, **kwargs):
try:
@@ -269,7 +271,8 @@ class Connector(object):
Returns:
A list of the Infoblox objects requested
Raises:
- InfobloxObjectNotFound
+ requests.exceptions.HTTPError: If API responded with error HTTP
+ status code.
"""
self._validate_obj_type_or_die(obj_type, obj_type_expected=False)
@@ -287,19 +290,14 @@ class Connector(object):
paging=paging)
# Clear proxy flag if wapi version is too old (non-cloud)
proxy_flag = self.cloud_api_enabled and force_proxy
- ib_object = self._handle_get_object(obj_type, query_params, extattrs,
- proxy_flag)
- if ib_object:
- return ib_object
- # Do second get call with force_proxy if not done yet
- if self.cloud_api_enabled and not force_proxy:
- ib_object = self._handle_get_object(obj_type, query_params,
- extattrs, proxy_flag=True)
- if ib_object:
- return ib_object
-
- return None
+ try:
+ return self._handle_get_object(obj_type, query_params, extattrs,
+ proxy_flag)
+ except req_exc.HTTPError:
+ # Do second get call with force_proxy if not done yet
+ return self._handle_get_object(obj_type, query_params,
+ extattrs, proxy_flag=True)
def _handle_get_object(self, obj_type, query_params, extattrs,
proxy_flag=False):
@@ -347,7 +345,7 @@ class Connector(object):
if r.status_code != requests.codes.ok:
LOG.warning("Failed on object search with url %s: %s",
url, r.content)
- return None
+ r.raise_for_status()
return self._parse_reply(r)
@reraise_neutron_exception
| Unable to capture 500 errors
Hello,
currently, it seems not possible to distinguish 404 errors from 5XX using connector's `_get_object`.
https://github.com/infobloxopen/infoblox-client/blob/d3131bd32efbe101276279ce29cf4d7954e040c7/infoblox_client/connector.py#L341-L344
the connector threat all http error exactly the same. as a result all get_object query are returning `None` object
```python
# Example to reproduce the issue with requests-mock
import pytest
from infoblox_client import connector
def test_infoblox_client_error(requests_mock):
requests_mock.get(
"https://example.com/wapi/v2.10.3/zone_auth?",
text="",
status_code=500
)
conn = connector.Connector(
{
"host": "example.com",
"username": "foo",
"password": "bar",
"wapi_version": "2.10.3"
}
)
error_500 = conn.get_object('zone_auth')
requests_mock.get(
"https://example.com/wapi/v2.10.3/zone_auth?",
text="",
status_code=404
)
conn = connector.Connector(
{
"host": "example.com",
"username": "foo",
"password": "bar",
"wapi_version": "2.10.3"
}
)
error_404 = conn.get_object('zone_auth')
assert error_404 != error_500, "Unable to distinguish 404 from 500 error"
```
Unfortunately, sometimes the infoblox api is returning 5XX error. It would be a good improvement to raise an error for unexpected results.
In worst case scenario the api is called twice. that could affect infoblox api performances.
https://github.com/infobloxopen/infoblox-client/blob/d3131bd32efbe101276279ce29cf4d7954e040c7/infoblox_client/connector.py#L289-L296
also the name "InfobloxObjectNotFound" is visible in get_object's docstring, but never use.
https://github.com/infobloxopen/infoblox-client/blob/d3131bd32efbe101276279ce29cf4d7954e040c7/infoblox_client/connector.py#L263-L266
thank you a lot for your help
| infobloxopen/infoblox-client | diff --git a/tests/test_connector.py b/tests/test_connector.py
index 2410666..e888b7b 100644
--- a/tests/test_connector.py
+++ b/tests/test_connector.py
@@ -356,7 +356,7 @@ class TestInfobloxConnector(unittest.TestCase):
url)
def test_get_object_with_proxy_flag(self):
- self.connector._get_object = mock.MagicMock(return_value=False)
+ self.connector._get_object = mock.MagicMock(return_value=None)
self.connector._construct_url = mock.MagicMock()
self.connector.cloud_api_enabled = True
@@ -371,7 +371,9 @@ class TestInfobloxConnector(unittest.TestCase):
self.connector._construct_url)
def test_get_object_without_proxy_flag(self):
- self.connector._get_object = mock.MagicMock(return_value=False)
+ self.connector._get_object = mock.MagicMock(
+ side_effect=[requests.HTTPError(), None],
+ )
self.connector._construct_url = mock.MagicMock()
self.connector.cloud_api_enabled = True
@@ -382,15 +384,17 @@ class TestInfobloxConnector(unittest.TestCase):
mock.call('network', {}, None, force_proxy=True)]
self.connector._construct_url.assert_has_calls(construct_calls)
- def test__get_object_search_error_return_none(self):
- response = mock.Mock()
- response.status_code = '404'
- response.content = 'Object not found'
+ def test__get_object_raises_search_error(self):
+ url = 'http://some-url/'
+ response = requests.Response()
+ response.status_code = 404
+ response._content = 'Object not found'
+ response.url = url
self.connector.session = mock.Mock()
self.connector.session.get.return_value = response
- url = 'http://some-url/'
- self.assertEqual(None, self.connector._get_object('network', url))
+ with self.assertRaises(requests.HTTPError):
+ self.connector._get_object('network', url)
def test_get_object_with_pagination_with_no_result(self):
self.connector._get_object = mock.MagicMock(return_value=None)
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 3
},
"num_modified_files": 1
} | 0.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"mock",
"netaddr"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi==2025.1.31
charset-normalizer==3.4.1
debtcollector==3.0.0
exceptiongroup==1.2.2
idna==3.10
-e git+https://github.com/infobloxopen/infoblox-client.git@2efaf4b92fb077af28a2f5e44b88b6083efaa084#egg=infoblox_client
iniconfig==2.1.0
iso8601==2.1.0
mock==5.2.0
msgpack==1.1.0
netaddr==1.3.0
oslo.config==9.7.1
oslo.context==5.7.1
oslo.i18n==6.5.1
oslo.log==7.1.0
oslo.serialization==5.7.0
oslo.utils==8.2.0
packaging==24.2
pbr==6.1.1
pluggy==1.5.0
psutil==7.0.0
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
rfc3986==2.0.0
six==1.17.0
stevedore==5.4.1
tomli==2.2.1
tzdata==2025.2
urllib3==2.3.0
wrapt==1.17.2
| name: infoblox-client
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2025.1.31
- charset-normalizer==3.4.1
- debtcollector==3.0.0
- exceptiongroup==1.2.2
- idna==3.10
- iniconfig==2.1.0
- iso8601==2.1.0
- mock==5.2.0
- msgpack==1.1.0
- netaddr==1.3.0
- oslo-config==9.7.1
- oslo-context==5.7.1
- oslo-i18n==6.5.1
- oslo-log==7.1.0
- oslo-serialization==5.7.0
- oslo-utils==8.2.0
- packaging==24.2
- pbr==6.1.1
- pluggy==1.5.0
- psutil==7.0.0
- pyparsing==3.2.3
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pyyaml==6.0.2
- requests==2.32.3
- rfc3986==2.0.0
- six==1.17.0
- stevedore==5.4.1
- tomli==2.2.1
- tzdata==2025.2
- urllib3==2.3.0
- wrapt==1.17.2
prefix: /opt/conda/envs/infoblox-client
| [
"tests/test_connector.py::TestInfobloxConnector::test__get_object_raises_search_error",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_without_proxy_flag"
] | [
"tests/test_connector.py::TestInfobloxConnector::test_get_object_with_proxy_flag"
] | [
"tests/test_connector.py::TestInfobloxConnector::test__check_service_availability",
"tests/test_connector.py::TestInfobloxConnector::test__handle_get_object_with_max_results_negative",
"tests/test_connector.py::TestInfobloxConnector::test__handle_get_object_with_pagination_with_no_record",
"tests/test_connector.py::TestInfobloxConnector::test__handle_get_object_with_pagination_with_record",
"tests/test_connector.py::TestInfobloxConnector::test__handle_get_object_with_record_more_than_max_results_paging",
"tests/test_connector.py::TestInfobloxConnector::test__handle_get_object_without_pagination",
"tests/test_connector.py::TestInfobloxConnector::test__handle_get_object_without_pagination_with_record",
"tests/test_connector.py::TestInfobloxConnector::test_call_download_file",
"tests/test_connector.py::TestInfobloxConnector::test_call_download_file_with_error_403",
"tests/test_connector.py::TestInfobloxConnector::test_call_func",
"tests/test_connector.py::TestInfobloxConnector::test_call_func_with_http_error",
"tests/test_connector.py::TestInfobloxConnector::test_call_func_with_http_error_503",
"tests/test_connector.py::TestInfobloxConnector::test_call_upload_file",
"tests/test_connector.py::TestInfobloxConnector::test_call_upload_file_with_error_403",
"tests/test_connector.py::TestInfobloxConnector::test_construct_url_absolute_path_fails",
"tests/test_connector.py::TestInfobloxConnector::test_construct_url_with_force_proxy",
"tests/test_connector.py::TestInfobloxConnector::test_construct_url_with_query_params_and_extattrs",
"tests/test_connector.py::TestInfobloxConnector::test_construct_url_with_query_params_containing_array",
"tests/test_connector.py::TestInfobloxConnector::test_create_object",
"tests/test_connector.py::TestInfobloxConnector::test_create_object_raises_member_assigned",
"tests/test_connector.py::TestInfobloxConnector::test_create_object_with_extattrs",
"tests/test_connector.py::TestInfobloxConnector::test_delete_object",
"tests/test_connector.py::TestInfobloxConnector::test_delete_object_with_http_error",
"tests/test_connector.py::TestInfobloxConnector::test_delete_object_with_http_error_503",
"tests/test_connector.py::TestInfobloxConnector::test_get_object",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_override_paging",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_with_cookies",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_with_default_and_extattrs",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_with_pagination_with_no_result",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_with_pagination_with_result",
"tests/test_connector.py::TestInfobloxConnector::test_get_object_with_specific_return_fields",
"tests/test_connector.py::TestInfobloxConnector::test_get_objects_with_extattrs",
"tests/test_connector.py::TestInfobloxConnector::test_get_objects_with_max_results",
"tests/test_connector.py::TestInfobloxConnector::test_get_objects_with_max_results_as_connector_opt",
"tests/test_connector.py::TestInfobloxConnector::test_max_results_priority",
"tests/test_connector.py::TestInfobloxConnector::test_update_object",
"tests/test_connector.py::TestInfobloxConnector::test_update_object_with_http_error",
"tests/test_connector.py::TestInfobloxConnector::test_update_object_with_http_error_503",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test__parse_reply",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test__parse_reply_raises_connection_error",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_allow_options_as_dict",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_blank_values_not_allowed",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_cloud_api_detection",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_default_options",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_exception_raised_for_non_authorized",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_incomplete_options_raises_exception",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_is_cloud_wapi_raises_exception",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_neutron_exception_is_raised_on_any_request_error",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_no_exceptions_for_ok_statuses",
"tests/test_connector.py::TestInfobloxConnectorStaticMethods::test_non_cloud_api_detection"
] | [] | Apache License 2.0 | 11,561 | 557 | [
"infoblox_client/connector.py"
] |
|
dcs4cop__xcube-sh-77 | 67f5600947d6c291f2f51b4d96e28ecd47c0c8ba | 2021-11-10 11:53:24 | 0340708b1ccc3fea18eefbf9e279535cc10e1e19 | diff --git a/xcube_sh/chunkstore.py b/xcube_sh/chunkstore.py
index d0f3125..b26c497 100644
--- a/xcube_sh/chunkstore.py
+++ b/xcube_sh/chunkstore.py
@@ -553,12 +553,16 @@ class SentinelHubChunkStore(RemoteStore):
trace_store_calls=False):
self._sentinel_hub = sentinel_hub
if cube_config.band_names is None:
- d = cube_config.to_dict()
- d['band_names'] = sentinel_hub.band_names(
- cube_config.dataset_name
- if cube_config.dataset_name != 'CUSTOM'
- else cube_config.collection_id
+ bands = sentinel_hub.bands(
+ cube_config.dataset_name,
+ collection_id=cube_config.collection_id
)
+ band_names = [b['name'] for b in bands]
+ band_sample_types = [b.get('sampleType') for b in bands]
+ d = cube_config.to_dict()
+ d['band_names'] = band_names
+ if all(band_sample_types):
+ d['band_sample_types'] = band_sample_types
cube_config = CubeConfig.from_dict(d)
super().__init__(cube_config,
observer=observer,
@@ -626,7 +630,7 @@ class SentinelHubChunkStore(RemoteStore):
self.cube_config.dataset_name,
band_name, default='FLOAT32'
)
- elif isinstance(band_sample_types, tuple):
+ elif isinstance(band_sample_types, (tuple, list)):
index = self.cube_config.band_names.index(band_name)
sample_type = band_sample_types[index]
else: # isinstance(band_sample_types, str)
diff --git a/xcube_sh/config.py b/xcube_sh/config.py
index 48c8527..c6e0ea1 100644
--- a/xcube_sh/config.py
+++ b/xcube_sh/config.py
@@ -30,13 +30,13 @@ from xcube.util.assertions import assert_given, assert_true, assert_in
from .constants import CRS_ID_TO_URI
from .constants import CRS_URI_TO_ID
from .constants import DEFAULT_CRS
+from .constants import DEFAULT_MOSAICKING_ORDER
+from .constants import DEFAULT_RESAMPLING
from .constants import DEFAULT_TILE_SIZE
from .constants import DEFAULT_TIME_TOLERANCE
-from .constants import SH_MAX_IMAGE_SIZE
-from .constants import RESAMPLINGS
-from .constants import DEFAULT_RESAMPLING
-from .constants import DEFAULT_MOSAICKING_ORDER
from .constants import MOSAICKING_ORDERS
+from .constants import RESAMPLINGS
+from .constants import SH_MAX_IMAGE_SIZE
def _safe_int_div(x: int, y: int) -> int:
@@ -335,11 +335,11 @@ class CubeConfig:
return self._band_names
@property
- def band_units(self) -> Union[None, str, Tuple[str, ...]]:
+ def band_units(self) -> Union[None, str, Sequence[str]]:
return self._band_units
@property
- def band_sample_types(self) -> Union[None, str, Tuple[str, ...]]:
+ def band_sample_types(self) -> Union[None, str, Sequence[str]]:
return self._band_sample_types
@property
diff --git a/xcube_sh/constants.py b/xcube_sh/constants.py
index b80b878..597d4c6 100644
--- a/xcube_sh/constants.py
+++ b/xcube_sh/constants.py
@@ -26,6 +26,8 @@ DEFAULT_CLIENT_SECRET = os.environ.get('SH_CLIENT_SECRET')
DEFAULT_SH_API_URL = 'https://services.sentinel-hub.com'
DEFAULT_SH_OAUTH2_URL = f'{DEFAULT_SH_API_URL}/oauth'
+DEFAULT_SH_METADATA_API_URL = f'{DEFAULT_SH_API_URL}/configuration/' \
+ f'api/v1/metadata/collection/byoc-%s'
SH_CATALOG_FEATURE_LIMIT = 100 # SH Catalog only allows this number of features to requested.
diff --git a/xcube_sh/main.py b/xcube_sh/main.py
index b932c18..8c89371 100644
--- a/xcube_sh/main.py
+++ b/xcube_sh/main.py
@@ -264,11 +264,21 @@ def info(datasets: List[str] = None):
else:
response = dict()
for dataset_name in datasets:
- band_names = sentinel_hub.band_names(dataset_name)
- bands = dict()
- for band_name in band_names:
- bands[band_name] = sentinel_hub.METADATA.dataset_band(dataset_name, band_name, default={})
- response[dataset_name] = bands
+ bands = sentinel_hub.bands(dataset_name)
+ bands_dict = dict()
+ for band in bands:
+ band_dict = dict(band)
+ band_name = band_dict.pop('name')
+ band_dict.update(
+ sentinel_hub.METADATA.dataset_band(dataset_name,
+ band_name,
+ default={})
+ )
+ band_sample_type = band.pop('sampleType', None)
+ if band_sample_type:
+ band_dict['sample_type'] = band_sample_type
+ bands_dict[band_name] = band_dict
+ response[dataset_name] = bands_dict
print(json.dumps(response, indent=2))
diff --git a/xcube_sh/sentinelhub.py b/xcube_sh/sentinelhub.py
index 89307f2..f4f6bfb 100644
--- a/xcube_sh/sentinelhub.py
+++ b/xcube_sh/sentinelhub.py
@@ -43,6 +43,7 @@ from .constants import DEFAULT_RESAMPLING
from .constants import DEFAULT_RETRY_BACKOFF_BASE
from .constants import DEFAULT_RETRY_BACKOFF_MAX
from .constants import DEFAULT_SH_API_URL
+from .constants import DEFAULT_SH_METADATA_API_URL
from .constants import DEFAULT_SH_OAUTH2_URL
from .constants import SH_CATALOG_FEATURE_LIMIT
from .metadata import SentinelHubMetadata
@@ -170,13 +171,33 @@ class SentinelHub:
SentinelHubError.maybe_raise_for_response(response)
return response.json()
- def band_names(self, dataset_name: str) -> List[str]:
- response = self.session.get(self.api_url
- + f'/api/v1/process/dataset/'
- f'{dataset_name}/bands')
+ def band_names(self, dataset_name: str, collection_id: str = None) -> List[str]:
+ if dataset_name.upper() == 'CUSTOM':
+ url = DEFAULT_SH_METADATA_API_URL % collection_id
+ response = self.session.get(url)
+ SentinelHubError.maybe_raise_for_response(response)
+ bands = response.json().get('bands', [])
+ return [band.get('name') for band in bands]
+
+ url = f'{self.api_url}/api/v1/process/dataset/{dataset_name}/bands'
+ response = self.session.get(url)
SentinelHubError.maybe_raise_for_response(response)
return response.json().get('data', {})
+ def bands(self, dataset_name: str, collection_id: str = None) \
+ -> List[Dict[str, Any]]:
+ if dataset_name.upper() == 'CUSTOM':
+ url = DEFAULT_SH_METADATA_API_URL % collection_id
+ response = self.session.get(url)
+ SentinelHubError.maybe_raise_for_response(response)
+ return response.json().get('bands', [])
+
+ url = f'{self.api_url}/api/v1/process/dataset/{dataset_name}/bands'
+ response = self.session.get(url)
+ SentinelHubError.maybe_raise_for_response(response)
+ band_names = response.json().get('data', [])
+ return [dict(name=band_name) for band_name in band_names]
+
def collections(self) -> List[Dict[str, Any]]:
"""
See https://docs.sentinel-hub.com/api/latest/reference/#operation/getCollections
diff --git a/xcube_sh/store.py b/xcube_sh/store.py
index 1ee0732..35ab388 100644
--- a/xcube_sh/store.py
+++ b/xcube_sh/store.py
@@ -294,25 +294,30 @@ class SentinelHubDataOpener(DataOpener):
def _describe_data(self, data_id: str) -> DatasetDescriptor:
dataset_metadata, collection_metadata = \
self._get_dataset_and_collection_metadata(data_id)
- band_metadatas = dataset_metadata.get('bands', {})
+ bands = dict(dataset_metadata.get('bands', {}))
if self._sentinel_hub is not None and data_id != 'CUSTOM':
# If we are connected to the API, we return band names by API
- band_names = self._sentinel_hub.band_names(data_id)
- else:
- # Otherwise all we know about
- band_names = band_metadatas.keys()
+ remote_bands = self._sentinel_hub.bands(data_id)
+ if remote_bands:
+ for band in remote_bands:
+ band_copy = dict(band)
+ band_name = band_copy.pop('name')
+ if 'sampleType' in band_copy:
+ band_copy['sample_type'] = band_copy.pop('sampleType')
+ if band_name in bands:
+ bands[band_name].update(band_copy)
+ else:
+ bands[band_name] = band_copy
data_vars = {}
- for band_name in band_names:
- band_metadata = band_metadatas.get(band_name,
- dict(sample_type='FLOAT32'))
+ for band_name, band_attrs in bands.items():
data_vars[band_name] = \
VariableDescriptor(
name=band_name,
- dtype=band_metadata.get('sample_type', 'FLOAT32'),
- dims=('time', 'lat', 'lon'),
- attrs=band_metadata.copy()
+ dtype=band_attrs.get('sample_type', 'FLOAT32'),
+ dims=('time', 'y', 'x'),
+ attrs=band_attrs.copy()
)
dataset_attrs = dataset_metadata.copy()
@@ -323,6 +328,11 @@ class SentinelHubDataOpener(DataOpener):
extent = collection_metadata.get('extent')
if extent is not None:
bbox = extent.get("spatial", {}).get('bbox')
+ if isinstance(bbox, list) and len(bbox) > 0:
+ if isinstance(bbox[0], list) and len(bbox[0]) == 4:
+ bbox = tuple(bbox[0])
+ elif len(bbox) == 4:
+ bbox = tuple(bbox)
interval = extent.get("temporal", {}).get('interval')
if isinstance(interval, list) and len(interval) > 0:
if isinstance(interval[0], list) and len(interval[0]) == 2:
@@ -356,11 +366,12 @@ class SentinelHubDataOpener(DataOpener):
def _get_dataset_and_collection_metadata(self, data_id: str) \
-> Tuple[Dict[str, Any], Optional[Dict[str, Any]]]:
- if data_id == 'CUSTOM':
+ if data_id.upper() == 'CUSTOM':
return {}, None
dataset_metadata = SentinelHubMetadata().datasets.get(data_id)
if dataset_metadata is None:
- raise DataStoreError(f'Dataset "{data_id}" not found.')
+ dataset_metadata = {}
+ # raise DataStoreError(f'No metadata for dataset "{data_id}" found.')
if self._sentinel_hub is not None:
# If we are connected to the API,
# we may also have collection metadata
| Cannot omit band names for "CUSTOM" datasets
Currently, when opening a cube given a `CubeConfig` with `dataset_name="CUSTOM"` and given `collection_id`, then users must also pass `band_names` otherwise an error occurs:
SentinelHubError: 500 Server Error: Internal Server Error for url: https://creodias.sentinel-hub.com/api/v1/process/dataset/{collection_id}/bands
This is not user-friendly, because users need to know the available band names (and their native sample types) in advance. | dcs4cop/xcube-sh | diff --git a/test/test_chunkstore.py b/test/test_chunkstore.py
index 15e94b9..9559bfc 100644
--- a/test/test_chunkstore.py
+++ b/test/test_chunkstore.py
@@ -382,9 +382,12 @@ class SentinelHubMock:
self._config = config
self._requests = []
- def band_names(self, dataset_name: str):
+ def band_names(self, dataset_name: str, collection_id=None):
return S2_BAND_NAMES
+ def bands(self, dataset_name: str, collection_id=None):
+ return [dict(name=b) for b in S2_BAND_NAMES]
+
# noinspection PyUnusedLocal
def get_features(self, collection_name, bbox, crs, time_range):
"""Return dummy catalog features"""
diff --git a/test/test_config.py b/test/test_config.py
index e022d92..773d218 100644
--- a/test/test_config.py
+++ b/test/test_config.py
@@ -32,10 +32,10 @@ class CubeConfigTest(unittest.TestCase):
def test_adjust_sizes(self):
spatial_res = 0.00018
common_kwargs = dict(dataset_name='S2L2A',
- band_names=('B01', 'B02', 'B03'),
+ band_names=['B01', 'B02', 'B03'],
spatial_res=spatial_res,
tile_size=(512, 512),
- time_range=('2019-01-01', '2019-01-02'))
+ time_range=['2019-01-01', '2019-01-02'])
# size will be smaller than chunk sizes
config = CubeConfig(bbox=(10.11, 54.17, 10.14, 54.19), **common_kwargs)
@@ -181,14 +181,19 @@ class CubeConfigTest(unittest.TestCase):
self.assertEqual("Found invalid parameters in cube configuration: 'geometrix', 'special_res'",
f'{cm.exception}')
- def test_band_names_may_be_null(self):
- config = CubeConfig(dataset_name='S2L2A',
- band_names=None,
- bbox=(10.11, 54.17, 10.14, 54.19),
- spatial_res=0.00001,
- time_range=('2019-01-01', '2019-01-02'))
+ def test_band_names(self):
+ common_kwargs = dict(dataset_name='S2L2A',
+ bbox=(10.11, 54.17, 10.14, 54.19),
+ spatial_res=0.00001,
+ time_range=('2019-01-01', '2019-01-02'))
+
+ config = CubeConfig(**common_kwargs)
self.assertEqual(None, config.band_names)
+ config = CubeConfig(band_names=["B02", "B03"], **common_kwargs)
+ self.assertIsInstance(config.band_names, tuple)
+ self.assertEqual(("B02", "B03"), config.band_names)
+
def test_deprecated_geometry_still_works(self):
config = CubeConfig(dataset_name='S2L2A',
geometry=(10.11, 54.17, 10.14, 54.19),
diff --git a/test/test_sentinelhub.py b/test/test_sentinelhub.py
index 7c72f8b..1e1eb3f 100644
--- a/test/test_sentinelhub.py
+++ b/test/test_sentinelhub.py
@@ -315,7 +315,7 @@ class SentinelHubCatalogueTest(unittest.TestCase):
self.assertEqual(expected_dataset_names,
sentinel_hub.dataset_names)
- def test_variable_names(self):
+ def test_band_names(self):
expected_band_names = ['B01',
'B02',
'B03',
@@ -343,6 +343,35 @@ class SentinelHubCatalogueTest(unittest.TestCase):
self.assertEqual(expected_band_names, sentinel_hub.band_names('S2L2A'))
sentinel_hub.close()
+ def test_bands(self):
+ expected_band_names = ['B01',
+ 'B02',
+ 'B03',
+ 'B04',
+ 'B05',
+ 'B06',
+ 'B07',
+ 'B08',
+ 'B8A',
+ 'B09',
+ 'B10',
+ 'B11',
+ 'B12',
+ 'viewZenithMean',
+ 'viewAzimuthMean',
+ 'sunZenithAngles',
+ 'sunAzimuthAngles']
+ sentinel_hub = SentinelHub(session=SessionMock({
+ 'get': {
+ 'https://services.sentinel-hub.com/api/v1/process/dataset/S2L2A/bands': {
+ 'data': expected_band_names
+ }
+ }
+ }))
+ self.assertEqual([dict(name=b) for b in expected_band_names],
+ sentinel_hub.bands('S2L2A'))
+ sentinel_hub.close()
+
def test_get_features(self):
properties = [{'datetime': '2019-10-02T10:35:47Z'}, {'datetime': '2019-10-04T10:25:47Z'},
{'datetime': '2019-10-05T10:45:36Z'}, {'datetime': '2019-10-05T10:45:44Z'}]
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 6
} | 0.9 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | affine @ file:///home/conda/feedstock_root/build_artifacts/affine_1733762038348/work
aiobotocore @ file:///home/conda/feedstock_root/build_artifacts/aiobotocore_1741606508148/work
aiohappyeyeballs @ file:///home/conda/feedstock_root/build_artifacts/aiohappyeyeballs_1741775197943/work
aiohttp @ file:///home/conda/feedstock_root/build_artifacts/aiohttp_1742268596946/work
aioitertools @ file:///home/conda/feedstock_root/build_artifacts/aioitertools_1735329051909/work
aiosignal @ file:///home/conda/feedstock_root/build_artifacts/aiosignal_1734342155601/work
asciitree==0.3.3
async-timeout @ file:///home/conda/feedstock_root/build_artifacts/async-timeout_1733235340728/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1741918516150/work
blinker @ file:///home/conda/feedstock_root/build_artifacts/blinker_1731096409132/work
bokeh @ file:///home/conda/feedstock_root/build_artifacts/bokeh_1719324651922/work
botocore @ file:///home/conda/feedstock_root/build_artifacts/botocore_1740533712647/work
branca @ file:///home/conda/feedstock_root/build_artifacts/branca_1734433375112/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1725267488082/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1739515848642/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1725571112467/work
cftime @ file:///home/conda/feedstock_root/build_artifacts/cftime_1725400455427/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1735929714516/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1734858813237/work
click-plugins @ file:///home/conda/feedstock_root/build_artifacts/click-plugins_1733731077999/work
cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1733749956636/work
cloudpickle @ file:///home/conda/feedstock_root/build_artifacts/cloudpickle_1736947526808/work
cmocean @ file:///home/conda/feedstock_root/build_artifacts/cmocean_1734343940570/work
colorspacious @ file:///home/conda/feedstock_root/build_artifacts/colorspacious_1734341944815/work
contourpy @ file:///home/conda/feedstock_root/build_artifacts/contourpy_1727293517607/work
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography-split_1740893557677/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1733332471406/work
cytoolz @ file:///home/conda/feedstock_root/build_artifacts/cytoolz_1734107207199/work
dask @ file:///home/conda/feedstock_root/build_artifacts/dask-core_1722976580461/work
dask-expr @ file:///home/conda/feedstock_root/build_artifacts/dask-expr_1722982607046/work
dask-image @ file:///home/conda/feedstock_root/build_artifacts/dask-image_1716364003245/work
Deprecated @ file:///home/conda/feedstock_root/build_artifacts/deprecated_1737986966356/work
distributed @ file:///home/conda/feedstock_root/build_artifacts/distributed_1722982528621/work
exceptiongroup==1.2.2
fasteners @ file:///home/conda/feedstock_root/build_artifacts/fasteners_1734943108928/work
fiona @ file:///home/conda/feedstock_root/build_artifacts/fiona_1733507410958/work
folium @ file:///home/conda/feedstock_root/build_artifacts/folium_1740766619747/work
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1738940303262/work
frozenlist @ file:///home/conda/feedstock_root/build_artifacts/frozenlist_1737645236190/work
fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1741403990995/work
GDAL @ file:///home/conda/feedstock_root/build_artifacts/libgdal-core_1742974302524/work/build/swig/python
geopandas @ file:///home/conda/feedstock_root/build_artifacts/geopandas_1734346029138/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
imagecodecs @ file:///home/conda/feedstock_root/build_artifacts/imagecodecs_1736603143530/work
imageio @ file:///home/conda/feedstock_root/build_artifacts/imageio_1738273805233/work
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1737420181517/work
importlib_resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1736252299705/work
iniconfig==2.1.0
jdcal==1.4.1
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1741263328855/work
jmespath @ file:///home/conda/feedstock_root/build_artifacts/jmespath_1733229141657/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1733736026804/work
jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema_1733472696581/work
jsonschema-specifications @ file:///tmp/tmpk0f344m9/src
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1725459266648/work
llvmlite==0.43.0
locket @ file:///home/conda/feedstock_root/build_artifacts/locket_1650660393415/work
lz4 @ file:///home/conda/feedstock_root/build_artifacts/lz4_1733474248677/work
mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1733731066416/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1733219680183/work
mashumaro @ file:///home/conda/feedstock_root/build_artifacts/mashumaro_1734307106848/work
matplotlib==3.9.4
msgpack @ file:///home/conda/feedstock_root/build_artifacts/msgpack-python_1725975012026/work
multidict @ file:///home/conda/feedstock_root/build_artifacts/multidict_1742308123521/work
munkres==1.1.4
netCDF4 @ file:///home/conda/feedstock_root/build_artifacts/netcdf4_1733253078561/work
networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1698504735452/work
numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1718888028049/work
numcodecs @ file:///home/conda/feedstock_root/build_artifacts/numcodecs_1715218778254/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1732314280888/work/dist/numpy-2.0.2-cp39-cp39-linux_x86_64.whl#sha256=62d98eb3da9f13e6b227c430d01026b7427f341b3fdcb838430f2a9e520417b1
oauthlib @ file:///home/conda/feedstock_root/build_artifacts/oauthlib_1733752848439/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas @ file:///home/conda/feedstock_root/build_artifacts/pandas_1736810577256/work
partd @ file:///home/conda/feedstock_root/build_artifacts/partd_1715026491486/work
pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1735929703139/work
PIMS @ file:///home/conda/feedstock_root/build_artifacts/pims_1734051112899/work
pkgutil_resolve_name @ file:///home/conda/feedstock_root/build_artifacts/pkgutil-resolve-name_1733344503739/work
pluggy==1.5.0
propcache @ file:///home/conda/feedstock_root/build_artifacts/propcache_1737635528546/work
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1740663125313/work
pyarrow==19.0.1
pyarrow-hotfix @ file:///home/conda/feedstock_root/build_artifacts/pyarrow-hotfix_1734380560621/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
PyJWT @ file:///home/conda/feedstock_root/build_artifacts/pyjwt_1732782409051/work
pyogrio @ file:///home/conda/feedstock_root/build_artifacts/pyogrio_1732013374897/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1743089729650/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1726679693937/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
pytest==8.3.5
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1706886791323/work
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1737454647378/work
rasterio @ file:///home/conda/feedstock_root/build_artifacts/rasterio_1733163417290/work
referencing @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_referencing_1737836872/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
requests-oauthlib @ file:///home/conda/feedstock_root/build_artifacts/requests-oauthlib_1733772243268/work
rfc3339_validator @ file:///home/conda/feedstock_root/build_artifacts/rfc3339-validator_1733599910982/work
rioxarray @ file:///home/conda/feedstock_root/build_artifacts/rioxarray_1692046920781/work
rpds-py @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_rpds-py_1743037693/work
s3fs @ file:///home/conda/feedstock_root/build_artifacts/s3fs_1741440613142/work
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1736496755362/work/dist/scikit_learn-1.6.1-cp39-cp39-linux_x86_64.whl#sha256=e8f978e37bb47e04e1337a63f75697b723d6d25f58e477734555faed033884ba
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy-split_1716470218293/work/dist/scipy-1.13.1-cp39-cp39-linux_x86_64.whl#sha256=e6696cb8683d94467891b7648e068a3970f6bc0a1b3c1aa7f9bc89458eafd2f0
shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1741166945909/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
slicerator @ file:///home/conda/feedstock_root/build_artifacts/slicerator_1734050998983/work
snuggs @ file:///home/conda/feedstock_root/build_artifacts/snuggs_1733818638588/work
sortedcontainers @ file:///home/conda/feedstock_root/build_artifacts/sortedcontainers_1738440353519/work
tblib @ file:///home/conda/feedstock_root/build_artifacts/tblib_1733842374544/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1741878222898/work
tifffile @ file:///home/conda/feedstock_root/build_artifacts/tifffile_1718963615451/work
tomli==2.2.1
toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1733736030883/work
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1732615921868/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_typing_extensions_1743201626/work
tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1742745135198/work
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1736692503055/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1718728347128/work
wrapt @ file:///home/conda/feedstock_root/build_artifacts/wrapt_1736869460534/work
xarray @ file:///home/conda/feedstock_root/build_artifacts/xarray_1722348170975/work
xcube @ file:///home/conda/feedstock_root/build_artifacts/xcube_1729000738130/work
-e git+https://github.com/dcs4cop/xcube-sh.git@67f5600947d6c291f2f51b4d96e28ecd47c0c8ba#egg=xcube_sh
xyzservices @ file:///home/conda/feedstock_root/build_artifacts/xyzservices_1737234886776/work
yarl @ file:///home/conda/feedstock_root/build_artifacts/yarl_1737575777699/work
zarr @ file:///home/conda/feedstock_root/build_artifacts/zarr_1716779724722/work
zict @ file:///home/conda/feedstock_root/build_artifacts/zict_1733261551178/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work
| name: xcube-sh
channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=conda_forge
- _openmp_mutex=4.5=2_gnu
- affine=2.4.0=pyhd8ed1ab_1
- aiobotocore=2.21.1=pyhd8ed1ab_0
- aiohappyeyeballs=2.6.1=pyhd8ed1ab_0
- aiohttp=3.11.14=py39h9399b63_0
- aioitertools=0.12.0=pyhd8ed1ab_1
- aiosignal=1.3.2=pyhd8ed1ab_0
- aom=3.9.1=hac33072_0
- asciitree=0.3.3=py_2
- async-timeout=5.0.1=pyhd8ed1ab_1
- attrs=25.3.0=pyh71513ae_0
- aws-c-auth=0.8.6=hd08a7f5_4
- aws-c-cal=0.8.7=h043a21b_0
- aws-c-common=0.12.0=hb9d3cd8_0
- aws-c-compression=0.3.1=h3870646_2
- aws-c-event-stream=0.5.4=h04a3f94_2
- aws-c-http=0.9.4=hb9b18c6_4
- aws-c-io=0.17.0=h3dad3f2_6
- aws-c-mqtt=0.12.2=h108da3e_2
- aws-c-s3=0.7.13=h822ba82_2
- aws-c-sdkutils=0.2.3=h3870646_2
- aws-checksums=0.2.3=h3870646_2
- aws-crt-cpp=0.31.0=h55f77e1_4
- aws-sdk-cpp=1.11.510=h37a5c72_3
- azure-core-cpp=1.14.0=h5cfcd09_0
- azure-identity-cpp=1.10.0=h113e628_0
- azure-storage-blobs-cpp=12.13.0=h3cf044e_1
- azure-storage-common-cpp=12.8.0=h736e048_1
- azure-storage-files-datalake-cpp=12.12.0=ha633028_1
- blinker=1.9.0=pyhff2d567_0
- blosc=1.21.6=he440d0b_1
- bokeh=3.4.2=pyhd8ed1ab_0
- botocore=1.37.1=pyge38_1234567_0
- branca=0.8.1=pyhd8ed1ab_0
- brotli=1.1.0=hb9d3cd8_2
- brotli-bin=1.1.0=hb9d3cd8_2
- brotli-python=1.1.0=py39hf88036b_2
- brunsli=0.1=h9c3ff4c_0
- bzip2=1.0.8=h4bc722e_7
- c-ares=1.34.4=hb9d3cd8_0
- c-blosc2=2.15.2=h3122c55_1
- ca-certificates=2025.1.31=hbcca054_0
- certifi=2025.1.31=pyhd8ed1ab_0
- cffi=1.17.1=py39h15c3d72_0
- cftime=1.6.4=py39hf3d9206_1
- charls=2.4.2=h59595ed_0
- charset-normalizer=3.4.1=pyhd8ed1ab_0
- click=8.1.8=pyh707e725_0
- click-plugins=1.1.1=pyhd8ed1ab_1
- cligj=0.7.2=pyhd8ed1ab_2
- cloudpickle=3.1.1=pyhd8ed1ab_0
- cmocean=4.0.3=pyhd8ed1ab_1
- colorspacious=1.1.2=pyhecae5ae_1
- contourpy=1.3.0=py39h74842e3_2
- cryptography=44.0.2=py39h7170ec2_0
- cycler=0.12.1=pyhd8ed1ab_1
- cytoolz=1.0.1=py39h8cd3c5a_0
- dask=2024.8.0=pyhd8ed1ab_0
- dask-core=2024.8.0=pyhd8ed1ab_0
- dask-expr=1.1.10=pyhd8ed1ab_0
- dask-image=2024.5.3=pyhd8ed1ab_0
- dav1d=1.2.1=hd590300_0
- deprecated=1.2.18=pyhd8ed1ab_0
- distributed=2024.8.0=pyhd8ed1ab_0
- fasteners=0.19=pyhd8ed1ab_1
- fiona=1.10.1=py39h4bd6204_3
- folium=0.19.5=pyhd8ed1ab_0
- fonttools=4.56.0=py39h9399b63_0
- freetype=2.13.3=h48d6fc4_0
- freexl=2.0.0=h9dce30a_2
- frozenlist=1.5.0=py39h9399b63_1
- fsspec=2025.3.0=pyhd8ed1ab_0
- gdal=3.10.2=py39h20e3955_5
- geopandas=1.0.1=pyhd8ed1ab_3
- geopandas-base=1.0.1=pyha770c72_3
- geos=3.13.1=h97f6797_0
- geotiff=1.7.4=h3551947_0
- gflags=2.2.2=h5888daf_1005
- giflib=5.2.2=hd590300_0
- glog=0.7.1=hbabe93e_0
- hdf4=4.2.15=h2a13503_7
- hdf5=1.14.4=nompi_h2d575fe_105
- icu=75.1=he02047a_0
- idna=3.10=pyhd8ed1ab_1
- imagecodecs=2024.12.30=py39hac51188_0
- imageio=2.37.0=pyhfb79c49_0
- importlib-metadata=8.6.1=pyha770c72_0
- importlib-resources=6.5.2=pyhd8ed1ab_0
- importlib_metadata=8.6.1=hd8ed1ab_0
- importlib_resources=6.5.2=pyhd8ed1ab_0
- jdcal=1.4.1=py_0
- jinja2=3.1.6=pyhd8ed1ab_0
- jmespath=1.0.1=pyhd8ed1ab_1
- joblib=1.4.2=pyhd8ed1ab_1
- json-c=0.18=h6688a6e_0
- jsonschema=4.23.0=pyhd8ed1ab_1
- jsonschema-specifications=2024.10.1=pyhd8ed1ab_1
- jxrlib=1.1=hd590300_3
- keyutils=1.6.1=h166bdaf_0
- kiwisolver=1.4.7=py39h74842e3_0
- krb5=1.21.3=h659f571_0
- lcms2=2.17=h717163a_0
- ld_impl_linux-64=2.43=h712a8e2_4
- lerc=4.0.0=h27087fc_0
- libabseil=20250127.1=cxx17_hbbce691_0
- libaec=1.1.3=h59595ed_0
- libarchive=3.7.7=h4585015_3
- libarrow=19.0.1=h120c447_5_cpu
- libarrow-acero=19.0.1=hcb10f89_5_cpu
- libarrow-dataset=19.0.1=hcb10f89_5_cpu
- libarrow-substrait=19.0.1=h1bed206_5_cpu
- libavif16=1.2.1=hbb36593_2
- libblas=3.9.0=31_h59b9bed_openblas
- libbrotlicommon=1.1.0=hb9d3cd8_2
- libbrotlidec=1.1.0=hb9d3cd8_2
- libbrotlienc=1.1.0=hb9d3cd8_2
- libcblas=3.9.0=31_he106b2a_openblas
- libcrc32c=1.1.2=h9c3ff4c_0
- libcurl=8.12.1=h332b0f4_0
- libde265=1.0.15=h00ab1b0_0
- libdeflate=1.23=h4ddbbb0_0
- libedit=3.1.20250104=pl5321h7949ede_0
- libev=4.33=hd590300_2
- libevent=2.1.12=hf998b51_1
- libexpat=2.6.4=h5888daf_0
- libffi=3.4.6=h2dba641_0
- libgcc=14.2.0=h767d61c_2
- libgcc-ng=14.2.0=h69a702a_2
- libgdal-core=3.10.2=h05269f4_1
- libgfortran=14.2.0=h69a702a_2
- libgfortran-ng=14.2.0=h69a702a_2
- libgfortran5=14.2.0=hf1ad2bd_2
- libgomp=14.2.0=h767d61c_2
- libgoogle-cloud=2.36.0=hc4361e1_1
- libgoogle-cloud-storage=2.36.0=h0121fbd_1
- libgrpc=1.71.0=he753a82_0
- libheif=1.19.7=gpl_hc18d805_100
- libhwy=1.1.0=h00ab1b0_0
- libiconv=1.18=h4ce23a2_1
- libjpeg-turbo=3.0.0=hd590300_1
- libjxl=0.11.1=hdb8da77_0
- libkml=1.3.0=hf539b9f_1021
- liblapack=3.9.0=31_h7ac8fdf_openblas
- libllvm14=14.0.6=hcd5def8_4
- liblzma=5.6.4=hb9d3cd8_0
- libnetcdf=4.9.2=nompi_h5ddbaa4_116
- libnghttp2=1.64.0=h161d5f1_0
- libnsl=2.0.1=hd590300_0
- libopenblas=0.3.29=pthreads_h94d23a6_0
- libopentelemetry-cpp=1.19.0=hd1b1c89_0
- libopentelemetry-cpp-headers=1.19.0=ha770c72_0
- libparquet=19.0.1=h081d1f1_5_cpu
- libpng=1.6.47=h943b412_0
- libprotobuf=5.29.3=h501fc15_0
- libre2-11=2024.07.02=hba17884_3
- librttopo=1.1.0=hd718a1a_18
- libspatialite=5.1.0=h366e088_13
- libsqlite=3.49.1=hee588c1_2
- libssh2=1.11.1=hf672d98_0
- libstdcxx=14.2.0=h8f9b012_2
- libstdcxx-ng=14.2.0=h4852527_2
- libthrift=0.21.0=h0e7cc3e_0
- libtiff=4.7.0=hd9ff511_3
- libutf8proc=2.10.0=h4c51ac1_0
- libuuid=2.38.1=h0b41bf4_0
- libwebp-base=1.5.0=h851e524_0
- libxcb=1.17.0=h8a09558_0
- libxcrypt=4.4.36=hd590300_1
- libxml2=2.13.7=h8d12d68_0
- libzip=1.11.2=h6991a6a_0
- libzlib=1.3.1=hb9d3cd8_2
- libzopfli=1.0.3=h9c3ff4c_0
- llvmlite=0.43.0=py39hf8b6b1a_1
- locket=1.0.0=pyhd8ed1ab_0
- lz4=4.3.3=py39h92207c2_2
- lz4-c=1.10.0=h5888daf_1
- lzo=2.10=hd590300_1001
- mapclassify=2.8.1=pyhd8ed1ab_1
- markupsafe=3.0.2=py39h9399b63_1
- mashumaro=3.15=pyhd8ed1ab_1
- matplotlib-base=3.9.4=py39h16632d1_0
- minizip=4.0.7=h05a5f5f_3
- msgpack-python=1.1.0=py39h74842e3_0
- multidict=6.2.0=py39h9399b63_0
- munkres=1.1.4=pyh9f0ad1d_0
- ncurses=6.5=h2d0b736_3
- netcdf4=1.7.2=nompi_py39h1defa26_101
- networkx=3.2.1=pyhd8ed1ab_0
- nlohmann_json=3.11.3=he02047a_1
- numba=0.60.0=py39h0320e7d_0
- numcodecs=0.12.1=py39h84cc369_1
- numpy=2.0.2=py39h9cb892a_1
- oauthlib=3.2.2=pyhd8ed1ab_1
- openjpeg=2.5.3=h5fbd93e_0
- openssl=3.4.1=h7b32b05_0
- orc=2.1.1=h17f744e_1
- packaging=24.2=pyhd8ed1ab_2
- pandas=2.2.3=py39h3b40f6f_2
- partd=1.4.2=pyhd8ed1ab_0
- pcre2=10.44=hba22ea6_2
- pillow=11.1.0=py39h15c0740_0
- pims=0.7=pyhd8ed1ab_1
- pip=25.0.1=pyh8b19718_0
- pkgutil-resolve-name=1.3.10=pyhd8ed1ab_2
- proj=9.5.1=h0054346_0
- prometheus-cpp=1.3.0=ha5d0236_0
- propcache=0.2.1=py39h9399b63_1
- psutil=7.0.0=py39h8cd3c5a_0
- pthread-stubs=0.4=hb9d3cd8_1002
- pyarrow=19.0.1=py39hf3d152e_0
- pyarrow-core=19.0.1=py39h6117c73_0_cpu
- pyarrow-hotfix=0.6=pyhd8ed1ab_1
- pycparser=2.22=pyh29332c3_1
- pyjwt=2.10.1=pyhd8ed1ab_0
- pyogrio=0.10.0=py39h4bd6204_1
- pyparsing=3.2.3=pyhd8ed1ab_1
- pyproj=3.6.1=py39h306d449_10
- pysocks=1.7.1=pyha55dd90_7
- python=3.9.21=h9c0c6dc_1_cpython
- python-dateutil=2.9.0.post0=pyhff2d567_1
- python-tzdata=2025.2=pyhd8ed1ab_0
- python_abi=3.9=5_cp39
- pytz=2024.1=pyhd8ed1ab_0
- pyyaml=6.0.2=py39h9399b63_2
- qhull=2020.2=h434a139_5
- rasterio=1.4.3=py39h13cc60e_0
- rav1e=0.6.6=he8a937b_2
- re2=2024.07.02=h9925aae_3
- readline=8.2=h8c095d6_2
- referencing=0.36.2=pyh29332c3_0
- requests=2.32.3=pyhd8ed1ab_1
- requests-oauthlib=2.0.0=pyhd8ed1ab_1
- rfc3339-validator=0.1.4=pyhd8ed1ab_1
- rioxarray=0.15.0=pyhd8ed1ab_0
- rpds-py=0.24.0=py39h3506688_0
- s2n=1.5.14=h6c98b2b_0
- s3fs=2025.3.0=pyhd8ed1ab_0
- scikit-learn=1.6.1=py39h4b7350c_0
- scipy=1.13.1=py39haf93ffa_0
- setuptools=75.8.2=pyhff2d567_0
- shapely=2.0.7=py39h322cc2b_1
- six=1.17.0=pyhd8ed1ab_0
- slicerator=1.1.0=pyhd8ed1ab_1
- snappy=1.2.1=h8bd8927_1
- snuggs=1.4.7=pyhd8ed1ab_2
- sortedcontainers=2.4.0=pyhd8ed1ab_1
- sqlite=3.49.1=h9eae976_2
- svt-av1=3.0.2=h5888daf_0
- tblib=3.0.0=pyhd8ed1ab_1
- threadpoolctl=3.6.0=pyhecae5ae_0
- tifffile=2024.6.18=pyhd8ed1ab_0
- tk=8.6.13=noxft_h4845f30_101
- toolz=1.0.0=pyhd8ed1ab_1
- tornado=6.4.2=py39h8cd3c5a_0
- typing-extensions=4.13.0=h9fa5a19_1
- typing_extensions=4.13.0=pyh29332c3_1
- tzdata=2025b=h78e105d_0
- unicodedata2=16.0.0=py39h8cd3c5a_0
- uriparser=0.9.8=hac33072_0
- urllib3=1.26.19=pyhd8ed1ab_0
- wheel=0.45.1=pyhd8ed1ab_1
- wrapt=1.17.2=py39h8cd3c5a_0
- x265=3.5=h924138e_3
- xarray=2024.7.0=pyhd8ed1ab_0
- xcube=1.7.1=pyhd8ed1ab_0
- xerces-c=3.2.5=h988505b_2
- xorg-libxau=1.0.12=hb9d3cd8_0
- xorg-libxdmcp=1.1.5=hb9d3cd8_0
- xyzservices=2025.1.0=pyhd8ed1ab_0
- yaml=0.2.5=h7f98852_2
- yarl=1.18.3=py39h9399b63_1
- zarr=2.18.2=pyhd8ed1ab_0
- zfp=1.0.1=h5888daf_2
- zict=3.0.0=pyhd8ed1ab_1
- zipp=3.21.0=pyhd8ed1ab_1
- zlib=1.3.1=hb9d3cd8_2
- zlib-ng=2.2.4=h7955e40_0
- zstd=1.5.7=hb8e6e7a_2
- pip:
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/xcube-sh
| [
"test/test_sentinelhub.py::SentinelHubCatalogueTest::test_bands"
] | [
"test/test_chunkstore.py::SentinelHubStore3DTestWithAllBands::test_all_bands_available",
"test/test_chunkstore.py::SentinelHubStore3DTestWithTiles::test_cached",
"test/test_chunkstore.py::SentinelHubStore3DTestWithTiles::test_plain",
"test/test_config.py::CubeConfigTest::test_adjust_sizes",
"test/test_config.py::CubeConfigTest::test_band_names",
"test/test_config.py::CubeConfigTest::test_crs",
"test/test_config.py::CubeConfigTest::test_deprecated_geometry_still_works",
"test/test_config.py::CubeConfigTest::test_from_and_to_dict",
"test/test_config.py::CubeConfigTest::test_is_geographic_crs",
"test/test_config.py::CubeConfigTest::test_time_deltas",
"test/test_config.py::CubeConfigTest::test_time_none"
] | [
"test/test_chunkstore.py::SentinelHubStore3DTest::test_basics",
"test/test_chunkstore.py::SentinelHubStore3DTest::test_cached",
"test/test_chunkstore.py::SentinelHubStore3DTest::test_plain",
"test/test_chunkstore.py::SentinelHubStore4DTest::test_cached",
"test/test_chunkstore.py::SentinelHubStore4DTest::test_plain",
"test/test_config.py::CubeConfigTest::test_from_dict_invalids",
"test/test_sentinelhub.py::SentinelHubCatalogFeaturesTest::test_features_to_time_ranges",
"test/test_sentinelhub.py::SentinelHubCatalogueTest::test_band_names",
"test/test_sentinelhub.py::SentinelHubCatalogueTest::test_dataset_names",
"test/test_sentinelhub.py::SentinelHubCatalogueTest::test_get_features",
"test/test_sentinelhub.py::SentinelHubNewRequestTest::test_new_data_request_multi",
"test/test_sentinelhub.py::SentinelHubNewRequestTest::test_new_data_request_multi_byod",
"test/test_sentinelhub.py::SentinelHubNewRequestTest::test_new_data_request_single",
"test/test_sentinelhub.py::SentinelHubNewRequestTest::test_new_data_request_single_byod",
"test/test_sentinelhub.py::SerializableOAuth2SessionTest::test_pickle"
] | [] | MIT License | 11,568 | 2,665 | [
"xcube_sh/chunkstore.py",
"xcube_sh/config.py",
"xcube_sh/constants.py",
"xcube_sh/main.py",
"xcube_sh/sentinelhub.py",
"xcube_sh/store.py"
] |
|
childsish__dynamic-yaml-18 | 73895727841024969b854b1c524ce8aa70527f46 | 2021-11-11 10:49:24 | bed4e61cb46744dc8e486cc83097cef010f94557 | diff --git a/dynamic_yaml/yaml_wrappers.py b/dynamic_yaml/yaml_wrappers.py
index 14c5ecc..1a08d27 100644
--- a/dynamic_yaml/yaml_wrappers.py
+++ b/dynamic_yaml/yaml_wrappers.py
@@ -78,6 +78,10 @@ class YamlList(DynamicYamlObject, MutableSequence):
super().__setattr__('_collection', list(*args, **kwargs))
super().__setattr__('_root', YamlDict([(YamlList.ROOT_NAME, self)]))
+ def __iter__(self):
+ for i in range(len(self)):
+ yield self[i]
+
def insert(self, index: int, object):
super().__getattribute__('_collection').insert(index, object)
| [Enhancement] - Method to resolve the dynamic object
Ran into the issue when trying to pass in a list to a pandas dataframe. I was trying to define some columns, but the list of columns wouldn't resolve. See below example:
```python
import dynamic_yaml
import pandas as pd
yml = '''
names:
n1: "name1"
n2: "name2"
columns:
- "{names.n1}"
- "{names.n2}"
'''
if __name__ == '__main__':
config = dynamic_yaml.load(yml)
df = pd.DataFrame(columns=config.columns)
print(df.columns)
```
Yeilds:
```
Index(['{names.n1}', '{names.n2}'], dtype='object')
```
So either after a fix that resolves the object when passed, or a method I can call on the object such as `config.columns.as_list()` or `config.columns.as_set()` or `config.columns.resolve()`. Not sure what the best approach is.
Current approach is to unpack and store in a variable. Roughly the following:
```python
cols = [config.columns[x] for x in range(len(config.columns))]
``` | childsish/dynamic-yaml | diff --git a/tests/test_dynamic_yaml.py b/tests/test_dynamic_yaml.py
index c666952..3cd4bee 100644
--- a/tests/test_dynamic_yaml.py
+++ b/tests/test_dynamic_yaml.py
@@ -197,6 +197,34 @@ class TestDynamicYaml(TestCase):
res = load(config, recursive=True)
inner_test(**res)
+ def test_list_iteration(self):
+ config = '''
+ targets:
+ v1: value1
+ v2: value2
+ query:
+ - '{targets.v1}'
+ - '{targets.v2}'
+ '''
+
+ res = load(config)
+ self.assertEqual(['value1', 'value2'], list(res.query))
+
+ def test_dict_iteration(self):
+ config = '''
+ targets:
+ v1: value1
+ v2: value2
+ query:
+ v1: '{targets.v1}'
+ v2: '{targets.v2}'
+ '''
+
+ res = load(config)
+ self.assertEqual(['v1', 'v2'], list(res.query))
+ self.assertEqual(['value1', 'value2'], list(res.query.values()))
+ self.assertEqual([('v1', 'value1'), ('v2', 'value2')], list(res.query.items()))
+
if __name__ == '__main__':
import sys
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 1.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | backports.tarfile==1.2.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
cryptography==44.0.2
docutils==0.21.2
-e git+https://github.com/childsish/dynamic-yaml.git@73895727841024969b854b1c524ce8aa70527f46#egg=dynamic_yaml
exceptiongroup==1.2.2
id==1.5.0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
keyring==25.6.0
markdown-it-py==3.0.0
mdurl==0.1.2
more-itertools==10.6.0
nh3==0.2.21
packaging==24.2
pluggy==1.5.0
pycparser==2.22
Pygments==2.19.1
pytest==8.3.5
PyYAML==6.0.2
readme_renderer==44.0
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==14.0.0
SecretStorage==3.3.3
tomli==2.2.1
twine==6.1.0
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0
| name: dynamic-yaml
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- backports-tarfile==1.2.0
- certifi==2025.1.31
- cffi==1.17.1
- charset-normalizer==3.4.1
- cryptography==44.0.2
- docutils==0.21.2
- exceptiongroup==1.2.2
- id==1.5.0
- idna==3.10
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jaraco-classes==3.4.0
- jaraco-context==6.0.1
- jaraco-functools==4.1.0
- jeepney==0.9.0
- keyring==25.6.0
- markdown-it-py==3.0.0
- mdurl==0.1.2
- more-itertools==10.6.0
- nh3==0.2.21
- packaging==24.2
- pluggy==1.5.0
- pycparser==2.22
- pygments==2.19.1
- pytest==8.3.5
- pyyaml==6.0.2
- readme-renderer==44.0
- requests==2.32.3
- requests-toolbelt==1.0.0
- rfc3986==2.0.0
- rich==14.0.0
- secretstorage==3.3.3
- tomli==2.2.1
- twine==6.1.0
- typing-extensions==4.13.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/dynamic-yaml
| [
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_list_iteration"
] | [] | [
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_argparse",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_deeply_nested_dict",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_dict",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_dict_iteration",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_keyword_args",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_list",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_list_resolution",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_nested_dict",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_recursive",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_resolve_deeply_nested",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_resolve_missing",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_resolve_nested",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_resolve_nested_update",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_resolve_simple",
"tests/test_dynamic_yaml.py::TestDynamicYaml::test_resolve_simple_update"
] | [] | MIT License | 11,578 | 181 | [
"dynamic_yaml/yaml_wrappers.py"
] |
|
DiamondLightSource__python-workflows-107 | 8549c1ee333c73635705def66cbea5a0929a0e31 | 2021-11-11 13:47:31 | 2c2944c6b4e64e6eca3ff6f4e344f790e092c54e | codecov[bot]: # [Codecov](https://codecov.io/gh/DiamondLightSource/python-workflows/pull/107?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DiamondLightSource) Report
> Merging [#107](https://codecov.io/gh/DiamondLightSource/python-workflows/pull/107?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DiamondLightSource) (5b7f425) into [main](https://codecov.io/gh/DiamondLightSource/python-workflows/commit/f23f065f2724b9f489d0f915cb55e06e85e46a3e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=DiamondLightSource) (f23f065) will **decrease** coverage by `0.15%`.
> The diff coverage is `72.72%`.
```diff
@@ Coverage Diff @@
## main #107 +/- ##
==========================================
- Coverage 82.06% 81.91% -0.16%
==========================================
Files 22 22
Lines 1979 1979
Branches 343 344 +1
==========================================
- Hits 1624 1621 -3
- Misses 268 269 +1
- Partials 87 89 +2
```
| diff --git a/src/workflows/logging/__init__.py b/src/workflows/logging.py
similarity index 79%
rename from src/workflows/logging/__init__.py
rename to src/workflows/logging.py
index 2d50e99..5b03cf7 100644
--- a/src/workflows/logging/__init__.py
+++ b/src/workflows/logging.py
@@ -64,3 +64,18 @@ class CallbackHandler(logging.Handler):
self._callback(self.prepare(record))
except Exception:
self.handleError(record)
+
+ def handleError(self, record):
+ t, v, _ = sys.exc_info()
+ try:
+ sys.stderr.write(
+ f"--- Logging error --- {t.__name__}: {v}\n"
+ "Could not forward log message from service to frontend process\n"
+ f"Message: {record.msg}\n"
+ f"Level: {record.levelno} - Thread: {record.threadName} - Arguments: {record.args}\n"
+ )
+ except Exception as e:
+ sys.stderr.write(
+ "--- Logging error ---\n"
+ f"Encountered exception {e!r} during exception handling\n"
+ )
diff --git a/src/workflows/services/common_service.py b/src/workflows/services/common_service.py
index 348090f..b8966a6 100644
--- a/src/workflows/services/common_service.py
+++ b/src/workflows/services/common_service.py
@@ -393,20 +393,22 @@ class CommonService:
while not self.__shutdown: # main loop
self.__update_service_status(self.SERVICE_STATUS_IDLE)
- if self._idle_time is None:
- task = self.__queue.get()
- else:
- try:
- task = self.__queue.get(True, self._idle_time)
- run_idle_task = False
- except queue.Empty:
- run_idle_task = True
- if run_idle_task:
+ try:
+ task = self.__queue.get(True, self._idle_time or 2)
+ run_idle_task = False
+ except queue.Empty:
+ run_idle_task = True
+
+ if self.transport and not self.transport.is_connected():
+ raise workflows.Disconnected("Connection lost")
+
+ if run_idle_task:
+ if self._idle_time:
# run this outside the 'except' to avoid exception chaining
self.__update_service_status(self.SERVICE_STATUS_TIMER)
if self._idle_callback:
self._idle_callback()
- continue
+ continue
self.__update_service_status(self.SERVICE_STATUS_PROCESSING)
diff --git a/src/workflows/transport/pika_transport.py b/src/workflows/transport/pika_transport.py
index b073205..0d9aebf 100644
--- a/src/workflows/transport/pika_transport.py
+++ b/src/workflows/transport/pika_transport.py
@@ -13,7 +13,6 @@ from concurrent.futures import Future
from enum import Enum, auto
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
-import pika
import pika.exceptions
from pika.adapters.blocking_connection import BlockingChannel
@@ -395,7 +394,7 @@ class PikaTransport(CommonTransport):
pika.exceptions.AMQPChannelError,
pika.exceptions.AMQPConnectionError,
) as e:
- raise workflows.Disconnected(e)
+ raise workflows.Disconnected(repr(e)) from None
def _subscribe_broadcast(
self,
| PikaTransport `ChannelClose` errors are not propagated | DiamondLightSource/python-workflows | diff --git a/tests/services/test_common_service.py b/tests/services/test_common_service.py
index 4bb2c80..de107bd 100644
--- a/tests/services/test_common_service.py
+++ b/tests/services/test_common_service.py
@@ -220,7 +220,7 @@ def test_observe_shutdown_command():
# Check startup/shutdown sequence
service.initializing.assert_called_once()
service.in_shutdown.assert_called_once()
- main_queue.get.assert_called_once_with()
+ main_queue.get.assert_called_once_with(True, 2)
messages = []
while fe_pipe_out.poll():
message = fe_pipe_out.recv()
diff --git a/tests/transport/test_pika.py b/tests/transport/test_pika.py
index c5cc807..c6fb358 100644
--- a/tests/transport/test_pika.py
+++ b/tests/transport/test_pika.py
@@ -797,9 +797,10 @@ def connection_params():
]
# Try a connection here to make sure this is valid
try:
- pika.BlockingConnection(params)
+ bc = pika.BlockingConnection(params)
except BaseException:
pytest.skip("Failed to create test RabbitMQ connection")
+ bc.close()
return params
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 3
},
"num_modified_files": 3
} | 2.15 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": null,
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements_dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
coverage==7.8.0
docopt==0.6.2
iniconfig==2.1.0
packaging==24.2
pika==1.2.0
pluggy==1.5.0
py==1.11.0
pytest==6.2.5
pytest-cov==3.0.0
pytest-timeout==2.0.1
stomp.py==7.0.0
toml==0.10.2
tomli==2.2.1
-e git+https://github.com/DiamondLightSource/python-workflows.git@8549c1ee333c73635705def66cbea5a0929a0e31#egg=workflows
| name: python-workflows
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- coverage==7.8.0
- docopt==0.6.2
- iniconfig==2.1.0
- packaging==24.2
- pika==1.2.0
- pluggy==1.5.0
- py==1.11.0
- pytest==6.2.5
- pytest-cov==3.0.0
- pytest-timeout==2.0.1
- setuptools==58.5.3
- stomp-py==7.0.0
- toml==0.10.2
- tomli==2.2.1
- workflows==2.15
prefix: /opt/conda/envs/python-workflows
| [
"tests/services/test_common_service.py::test_observe_shutdown_command"
] | [] | [
"tests/services/test_common_service.py::test_instantiate_basic_service",
"tests/services/test_common_service.py::test_logging_to_frontend",
"tests/services/test_common_service.py::test_adding_fieldvalue_pairs_to_log_messages",
"tests/services/test_common_service.py::test_log_message_fieldvalue_pairs_are_removed_outside_their_context",
"tests/services/test_common_service.py::test_log_message_fieldvalue_pairs_are_attached_to_unhandled_exceptions_and_logged_properly",
"tests/services/test_common_service.py::test_receive_frontend_commands",
"tests/services/test_common_service.py::test_idle_timer_is_triggered",
"tests/services/test_common_service.py::test_callbacks_are_routed_correctly",
"tests/services/test_common_service.py::test_log_unknown_band_data",
"tests/services/test_common_service.py::test_service_initialization_crashes_are_handled_correctly",
"tests/services/test_common_service.py::test_service_can_change_name_and_shut_itself_down",
"tests/services/test_common_service.py::test_service_can_mark_itself_as_unstable",
"tests/services/test_common_service.py::test_can_pass_environment_to_service",
"tests/services/test_common_service.py::test_transport_object_can_be_injected",
"tests/services/test_common_service.py::test_transport_object_can_not_be_overwritten",
"tests/services/test_common_service.py::test_transport_connection_is_started_on_initialization",
"tests/services/test_common_service.py::test_main_queue_can_deal_with_being_empty",
"tests/services/test_common_service.py::test_commands_are_processed_from_main_queue_before_transport",
"tests/services/test_common_service.py::test_transport_callbacks_are_processed_from_main_queue",
"tests/transport/test_pika.py::test_lookup_and_initialize_pika_transport_layer",
"tests/transport/test_pika.py::test_add_command_line_help_optparse",
"tests/transport/test_pika.py::test_add_command_line_help_argparse",
"tests/transport/test_pika.py::test_adding_arguments_to_argparser",
"tests/transport/test_pika.py::test_check_config_file_behaviour",
"tests/transport/test_pika.py::test_anonymous_connection",
"tests/transport/test_pika.py::test_instantiate_link_and_connect_to_broker",
"tests/transport/test_pika.py::test_error_handling_when_connecting_to_broker",
"tests/transport/test_pika.py::test_broadcast_status",
"tests/transport/test_pika.py::test_send_message",
"tests/transport/test_pika.py::test_sending_message_with_expiration",
"tests/transport/test_pika.py::test_send_broadcast",
"tests/transport/test_pika.py::test_broadcasting_message_with_expiration",
"tests/transport/test_pika.py::test_messages_are_serialized_for_transport",
"tests/transport/test_pika.py::test_messages_are_not_serialized_for_raw_transport",
"tests/transport/test_pika.py::test_messages_are_deserialized_after_transport",
"tests/transport/test_pika.py::test_subscribe_to_queue",
"tests/transport/test_pika.py::test_subscribe_to_broadcast",
"tests/transport/test_pika.py::test_error_handling_on_subscribing",
"tests/transport/test_pika.py::test_ack_message",
"tests/transport/test_pika.py::test_nack_message"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,579 | 812 | [
"src/workflows/logging/__init__.py",
"src/workflows/services/common_service.py",
"src/workflows/transport/pika_transport.py"
] |
doccano__doccano-1558 | 0d7bf054e619c144ec84fcf18f9457af8822a204 | 2021-11-12 01:01:49 | bfdecb92fe2cfa8060634aab57df2933ab30b599 | diff --git a/backend/api/views/download/writer.py b/backend/api/views/download/writer.py
index 5de1264e..a4d5293a 100644
--- a/backend/api/views/download/writer.py
+++ b/backend/api/views/download/writer.py
@@ -84,7 +84,7 @@ class CsvWriter(BaseWriter):
return {
'id': record.id,
'data': record.data,
- 'label': '#'.join(record.label),
+ 'label': '#'.join(sorted(record.label)),
**record.metadata
}
@@ -144,6 +144,7 @@ class FastTextWriter(LineWriter):
def create_line(self, record):
line = [f'__label__{label}' for label in record.label]
+ line.sort()
line.append(record.data)
line = ' '.join(line)
return line
| Mutli-label text classification export issues: same classes but in different orders
How to reproduce the behaviour
---------
<!-- Before submitting an issue, make sure to check the docs and closed issues and FAQ to see if any of the solutions work for you. https://github.com/doccano/doccano/wiki/Frequently-Asked-Questions -->
We are two annotators on a multi-label classification project. When I export the annotations, for some examples, me and my co-annotator have put the same labels, but on the exported CSV, they do not appear in the same order:
Annotator 1:
| text | labels |
| example 1 | label1#label2#label3 |
Annotator 2:
| text | labels |
| example 1 | label2#label3#label1 |
As I try to use these CSVs for comparing our annotations, this brings more difficulty.
<!-- Include a code example or the steps that led to the problem. Please try to be as specific as possible. -->
Your Environment
---------
<!-- Include details of your environment.-->
* Operating System: Debian
* Python Version Used: Don't know, I pulled the latest version from Docker Hub
* When you install doccano: 3 days ago
* How did you install doccano (Heroku button etc): Docker
| doccano/doccano | diff --git a/backend/api/tests/download/test_writer.py b/backend/api/tests/download/test_writer.py
index 2c48cb92..720244dd 100644
--- a/backend/api/tests/download/test_writer.py
+++ b/backend/api/tests/download/test_writer.py
@@ -32,6 +32,16 @@ class TestCSVWriter(unittest.TestCase):
}
self.assertEqual(line, expected)
+ def test_label_order(self):
+ writer = CsvWriter('.')
+ record1 = Record(id=0, data='', label=['labelA', 'labelB'], user='', metadata={})
+ record2 = Record(id=0, data='', label=['labelB', 'labelA'], user='', metadata={})
+ line1 = writer.create_line(record1)
+ line2 = writer.create_line(record2)
+ expected = 'labelA#labelB'
+ self.assertEqual(line1['label'], expected)
+ self.assertEqual(line2['label'], expected)
+
@patch('os.remove')
@patch('zipfile.ZipFile')
@patch('csv.DictWriter.writerow')
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 1.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | amqp==5.3.1
annotated-types==0.7.0
apache-libcloud==3.8.0
asgiref==3.8.1
auto-labeling-pipeline==0.1.23
billiard==4.2.1
boto3==1.37.23
botocore==1.37.23
celery==5.4.0
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
click-didyoumean==0.3.1
click-plugins==1.1.1
click-repl==0.3.0
colour==0.1.5
conllu==6.0.0
cryptography==44.0.2
defusedxml==0.7.1
dj-database-url==2.3.0
dj-rest-auth==7.0.1
Django==4.2.20
django-celery-results==2.5.1
django-cors-headers==4.7.0
django-drf-filepond==0.5.0
django-filter==25.1
django-polymorphic==3.1.0
django-rest-polymorphic==0.1.10
django-storages==1.14.5
djangorestframework==3.16.0
djangorestframework-csv==3.0.2
djangorestframework-xml==2.0.0
-e git+https://github.com/doccano/doccano.git@0d7bf054e619c144ec84fcf18f9457af8822a204#egg=doccano
drf-yasg==1.21.10
ecdsa==0.19.1
environs==14.1.1
et_xmlfile==2.0.0
exceptiongroup==1.2.2
furl==2.1.4
greenlet==3.1.1
gunicorn==23.0.0
idna==3.10
inflection==0.5.1
iniconfig==2.1.0
Jinja2==3.1.6
jmespath==1.0.1
joblib==1.4.2
kombu==5.5.2
lml==0.2.0
MarkupSafe==3.0.2
marshmallow==3.26.1
numpy==2.0.2
oauthlib==3.2.2
openpyxl==3.1.5
orderedmultidict==1.0.1
packaging==24.2
pluggy==1.5.0
prompt_toolkit==3.0.50
pyasn1==0.4.8
pycparser==2.22
pydantic==2.11.1
pydantic_core==2.33.0
pyexcel==0.7.2
pyexcel-io==0.6.7
pyexcel-xlsx==0.6.1
PyJWT==2.10.1
pytest==8.3.5
python-dateutil==2.9.0.post0
python-dotenv==1.1.0
python-jose==3.4.0
python3-openid==3.2.0
pytz==2025.2
PyYAML==6.0.2
requests==2.32.3
requests-oauthlib==2.0.0
rsa==4.9
s3transfer==0.11.4
scikit-learn==1.6.1
scipy==1.13.1
seqeval==1.2.2
shortuuid==1.0.13
six==1.17.0
social-auth-app-django==5.4.3
social-auth-core==4.5.6
SQLAlchemy==2.0.40
sqlparse==0.5.3
texttable==1.7.0
threadpoolctl==3.6.0
tomli==2.2.1
typing-inspection==0.4.0
typing_extensions==4.12.2
tzdata==2025.2
uritemplate==4.1.1
urllib3==1.26.20
vine==5.1.0
waitress==3.0.2
wcwidth==0.2.13
whitenoise==6.9.0
| name: doccano
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- amqp==5.3.1
- annotated-types==0.7.0
- apache-libcloud==3.8.0
- asgiref==3.8.1
- auto-labeling-pipeline==0.1.23
- billiard==4.2.1
- boto3==1.37.23
- botocore==1.37.23
- celery==5.4.0
- certifi==2025.1.31
- cffi==1.17.1
- chardet==5.2.0
- charset-normalizer==3.4.1
- click==8.1.8
- click-didyoumean==0.3.1
- click-plugins==1.1.1
- click-repl==0.3.0
- colour==0.1.5
- conllu==6.0.0
- cryptography==44.0.2
- defusedxml==0.7.1
- dj-database-url==2.3.0
- dj-rest-auth==7.0.1
- django==4.2.20
- django-celery-results==2.5.1
- django-cors-headers==4.7.0
- django-drf-filepond==0.5.0
- django-filter==25.1
- django-polymorphic==3.1.0
- django-rest-polymorphic==0.1.10
- django-storages==1.14.5
- djangorestframework==3.16.0
- djangorestframework-csv==3.0.2
- djangorestframework-xml==2.0.0
- drf-yasg==1.21.10
- ecdsa==0.19.1
- environs==14.1.1
- et-xmlfile==2.0.0
- exceptiongroup==1.2.2
- furl==2.1.4
- greenlet==3.1.1
- gunicorn==23.0.0
- idna==3.10
- inflection==0.5.1
- iniconfig==2.1.0
- jinja2==3.1.6
- jmespath==1.0.1
- joblib==1.4.2
- kombu==5.5.2
- lml==0.2.0
- markupsafe==3.0.2
- marshmallow==3.26.1
- numpy==2.0.2
- oauthlib==3.2.2
- openpyxl==3.1.5
- orderedmultidict==1.0.1
- packaging==24.2
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- pyasn1==0.4.8
- pycparser==2.22
- pydantic==2.11.1
- pydantic-core==2.33.0
- pyexcel==0.7.2
- pyexcel-io==0.6.7
- pyexcel-xlsx==0.6.1
- pyjwt==2.10.1
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- python-dotenv==1.1.0
- python-jose==3.4.0
- python3-openid==3.2.0
- pytz==2025.2
- pyyaml==6.0.2
- requests==2.32.3
- requests-oauthlib==2.0.0
- rsa==4.9
- s3transfer==0.11.4
- scikit-learn==1.6.1
- scipy==1.13.1
- seqeval==1.2.2
- shortuuid==1.0.13
- six==1.17.0
- social-auth-app-django==5.4.3
- social-auth-core==4.5.6
- sqlalchemy==2.0.40
- sqlparse==0.5.3
- texttable==1.7.0
- threadpoolctl==3.6.0
- tomli==2.2.1
- typing-extensions==4.12.2
- typing-inspection==0.4.0
- tzdata==2025.2
- uritemplate==4.1.1
- urllib3==1.26.20
- vine==5.1.0
- waitress==3.0.2
- wcwidth==0.2.13
- whitenoise==6.9.0
prefix: /opt/conda/envs/doccano
| [
"backend/api/tests/download/test_writer.py::TestCSVWriter::test_label_order"
] | [] | [
"backend/api/tests/download/test_writer.py::TestCSVWriter::test_create_header",
"backend/api/tests/download/test_writer.py::TestCSVWriter::test_create_line",
"backend/api/tests/download/test_writer.py::TestCSVWriter::test_dump"
] | [] | MIT License | 11,585 | 202 | [
"backend/api/views/download/writer.py"
] |
|
abhinavsingh__proxy.py-740 | 8052c907e8ed7bd889a13c8029a657675d6fd13a | 2021-11-15 09:06:59 | 3ff7f211e7dba687c293cc971b3fff2853344771 | codecov[bot]: # [Codecov](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh) Report
> Merging [#740](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh) (8fadf49) into [develop](https://codecov.io/gh/abhinavsingh/proxy.py/commit/7f1470e3a95b7b0a0037f217b64a1cbe2cc315b8?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh) (7f1470e) will **decrease** coverage by `0.15%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh)
```diff
@@ Coverage Diff @@
## develop #740 +/- ##
===========================================
- Coverage 87.78% 87.63% -0.16%
===========================================
Files 122 122
Lines 5363 5370 +7
Branches 431 432 +1
===========================================
- Hits 4708 4706 -2
- Misses 569 572 +3
- Partials 86 92 +6
```
| Flag | Coverage Δ | |
|---|---|---|
| pytest | `87.59% <100.00%> (-0.04%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh) | Coverage Δ | |
|---|---|---|
| [proxy/http/parser/parser.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-cHJveHkvaHR0cC9wYXJzZXIvcGFyc2VyLnB5) | `94.79% <100.00%> (+0.03%)` | :arrow_up: |
| [tests/http/test\_http\_parser.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-dGVzdHMvaHR0cC90ZXN0X2h0dHBfcGFyc2VyLnB5) | `100.00% <100.00%> (ø)` | |
| [proxy/common/types.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-cHJveHkvY29tbW9uL3R5cGVzLnB5) | `86.66% <0.00%> (-13.34%)` | :arrow_down: |
| [tests/test\_set\_open\_file\_limit.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-dGVzdHMvdGVzdF9zZXRfb3Blbl9maWxlX2xpbWl0LnB5) | `96.29% <0.00%> (-3.71%)` | :arrow_down: |
| [proxy/common/constants.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-cHJveHkvY29tbW9uL2NvbnN0YW50cy5weQ==) | `97.75% <0.00%> (-2.25%)` | :arrow_down: |
| [proxy/common/utils.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-cHJveHkvY29tbW9uL3V0aWxzLnB5) | `91.86% <0.00%> (-1.63%)` | :arrow_down: |
| [proxy/common/flag.py](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh#diff-cHJveHkvY29tbW9uL2ZsYWcucHk=) | `90.90% <0.00%> (-1.52%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh). Last update [7f1470e...8fadf49](https://codecov.io/gh/abhinavsingh/proxy.py/pull/740?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Abhinav+Singh).
abhinavsingh: I highly recommend you to setup https://github.com/abhinavsingh/proxy.py#setup-local-environment or at-least run those commands manually before pushing to upstream. To avoid unnecessary to and fro. Example now we ran into this issue:
<img width="711" alt="Screen Shot 2021-11-18 at 6 38 13 AM" src="https://user-images.githubusercontent.com/126065/142332599-1fab1e92-cff4-4c45-b655-7d20bdc95e9d.png">
at-least make sure to run
`make lib-mypy && make lib-flake8` to ensure linting is fine. You may still run into other issues. For total satisfaction, run `make` to run all tests locally. :)
I know it's a PITA but is necessary to maintain code quality over time.
JerryKwan: Good advice.
I an using a Windows development environment right now, I will change to a Linux environment and setup the hooks later | diff --git a/proxy/http/parser/parser.py b/proxy/http/parser/parser.py
index f81a100..151e037 100644
--- a/proxy/http/parser/parser.py
+++ b/proxy/http/parser/parser.py
@@ -27,7 +27,6 @@ from .protocol import ProxyProtocol
from .chunk import ChunkParser, chunkParserStates
from .types import httpParserTypes, httpParserStates
-
flags.add_argument(
'--enable-proxy-protocol',
action='store_true',
@@ -305,16 +304,27 @@ class HttpParser:
def _process_line(self, raw: bytes) -> None:
if self.type == httpParserTypes.REQUEST_PARSER:
+ # Ref:
+ # https://datatracker.ietf.org/doc/html/rfc2616#section-5.1
+ # https://greenbytes.de/tech/webdav/rfc7230.html#request.line
+ # https://greenbytes.de/tech/webdav/rfc7231.html#methods
+ # http://www.iana.org/assignments/http-methods/http-methods.xhtml
if self.protocol is not None and self.protocol.version is None:
# We expect to receive entire proxy protocol v1 line
# in one network read and don't expect partial packets
self.protocol.parse(raw)
else:
line = raw.split(WHITESPACE)
- self.method = line[0].upper()
- self.set_url(line[1])
- self.version = line[2]
- self.state = httpParserStates.LINE_RCVD
+ if len(line) == 3:
+ self.method = line[0].upper()
+ self.set_url(line[1])
+ self.version = line[2]
+ self.state = httpParserStates.LINE_RCVD
+ else:
+ # raise exception
+ # TODO, it would be better to use raise HttpProtocolException,
+ # but we should solve circular import problem first
+ raise NotImplementedError('Invalid request line')
else:
line = raw.split(WHITESPACE)
self.version = line[0]
| [HttpParser] Handle invalid/malformed request chunks from client
**Describe the bug**
Currently, `HttpParser` works well assuming incoming client is not notorious :) Handle cases when client can send invalid chunks in requests.
**To Reproduce**
Steps to reproduce the behavior:
1. Run `proxy.py` as `proxy.py --pac-file proxy.pac`
2. `telnet localhost 8899` and hit `Enter` key to send line feed
```
$ telnet localhost 8899
Trying ::1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
```
3. See error
```
2019-10-11 11:12:06,277 - pid:55396 [E] run:2215 - Exception while handling connection <socket.socket fd=27, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::1', 8899, 0, 0), raddr=('::1', 49902, 0, 0)>
Traceback (most recent call last):
File "./proxy.py", line 2205, in run
teardown = self.run_once()
File "./proxy.py", line 2173, in run_once
teardown = self.handle_events(readables, writables)
File "./proxy.py", line 2138, in handle_events
teardown = self.handle_readables(readables)
File "./proxy.py", line 2076, in handle_readables
self.request.parse(client_data)
File "./proxy.py", line 615, in parse
more, raw = self.process(raw)
File "./proxy.py", line 625, in process
self.process_line(line)
File "./proxy.py", line 667, in process_line
self.url = urlparse.urlsplit(line[1])
IndexError: list index out of range
2019-10-11 11:12:06,279 - pid:55396 [I] access_log:1955 - ::1:49902 - None
```
**Expected behavior**
`HttpParser` must either ignore invalid chunks or be strict about it and drop the connection.
| abhinavsingh/proxy.py | diff --git a/tests/http/test_http_parser.py b/tests/http/test_http_parser.py
index 11aa5c4..4ef4412 100644
--- a/tests/http/test_http_parser.py
+++ b/tests/http/test_http_parser.py
@@ -23,6 +23,15 @@ class TestHttpParser(unittest.TestCase):
def setUp(self) -> None:
self.parser = HttpParser(httpParserTypes.REQUEST_PARSER)
+ def test_issue_127(self) -> None:
+ with self.assertRaises(NotImplementedError):
+ self.parser.parse(CRLF)
+
+ with self.assertRaises(NotImplementedError):
+ raw = b'qwqrqw!@!#@!#ad adfad\r\n'
+ while True:
+ self.parser.parse(raw)
+
def test_issue_398(self) -> None:
p = HttpParser(httpParserTypes.RESPONSE_PARSER)
p.parse(HTTP_1_0 + b' 200 OK' + CRLF)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 2.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
-e git+https://github.com/abhinavsingh/proxy.py.git@8052c907e8ed7bd889a13c8029a657675d6fd13a#egg=proxy.py
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
tomli==2.2.1
typing_extensions==4.13.0
| name: proxy.py
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- coverage==7.8.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- proxy-py==2.3.2.dev157+g8052c90
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- tomli==2.2.1
- typing-extensions==4.13.0
prefix: /opt/conda/envs/proxy.py
| [
"tests/http/test_http_parser.py::TestHttpParser::test_issue_127"
] | [] | [
"tests/http/test_http_parser.py::TestHttpParser::test_build_header",
"tests/http/test_http_parser.py::TestHttpParser::test_build_request",
"tests/http/test_http_parser.py::TestHttpParser::test_build_response",
"tests/http/test_http_parser.py::TestHttpParser::test_build_response_adds_content_length_header",
"tests/http/test_http_parser.py::TestHttpParser::test_chunked_request_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_chunked_response_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_connect_request_with_crlf_as_separate_chunk",
"tests/http/test_http_parser.py::TestHttpParser::test_connect_request_without_host_header_request_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_find_line",
"tests/http/test_http_parser.py::TestHttpParser::test_find_line_returns_None",
"tests/http/test_http_parser.py::TestHttpParser::test_get_full_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_get_partial_parse1",
"tests/http/test_http_parser.py::TestHttpParser::test_get_partial_parse2",
"tests/http/test_http_parser.py::TestHttpParser::test_has_header",
"tests/http/test_http_parser.py::TestHttpParser::test_header_raises",
"tests/http/test_http_parser.py::TestHttpParser::test_invalid_ipv6_in_request_line",
"tests/http/test_http_parser.py::TestHttpParser::test_is_http_1_1_keep_alive",
"tests/http/test_http_parser.py::TestHttpParser::test_is_http_1_1_keep_alive_with_non_close_connection_header",
"tests/http/test_http_parser.py::TestHttpParser::test_is_not_http_1_1_keep_alive_for_http_1_0",
"tests/http/test_http_parser.py::TestHttpParser::test_is_not_http_1_1_keep_alive_with_close_header",
"tests/http/test_http_parser.py::TestHttpParser::test_issue_398",
"tests/http/test_http_parser.py::TestHttpParser::test_line_rcvd_to_rcving_headers_state_change",
"tests/http/test_http_parser.py::TestHttpParser::test_paramiko_doc",
"tests/http/test_http_parser.py::TestHttpParser::test_pipelined_chunked_response_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_pipelined_response_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_post_full_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_post_partial_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_proxy_protocol",
"tests/http/test_http_parser.py::TestHttpParser::test_proxy_protocol_not_for_response_parser",
"tests/http/test_http_parser.py::TestHttpParser::test_request_factory",
"tests/http/test_http_parser.py::TestHttpParser::test_request_parse_without_content_length",
"tests/http/test_http_parser.py::TestHttpParser::test_response_factory",
"tests/http/test_http_parser.py::TestHttpParser::test_response_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_response_parse_without_content_length",
"tests/http/test_http_parser.py::TestHttpParser::test_response_partial_parse",
"tests/http/test_http_parser.py::TestHttpParser::test_set_host_port_raises",
"tests/http/test_http_parser.py::TestHttpParser::test_unicode_character_domain_connect",
"tests/http/test_http_parser.py::TestHttpParser::test_urlparse",
"tests/http/test_http_parser.py::TestHttpParser::test_urlparse_on_invalid_connect_request",
"tests/http/test_http_parser.py::TestHttpParser::test_valid_ipv6_in_request_line"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,600 | 479 | [
"proxy/http/parser/parser.py"
] |
asottile__pyupgrade-568 | f5b16fcfdffb755b8ca41b9d1bc343075853a5ab | 2021-11-16 00:52:23 | 7f31a6d99129204aab4c1ab9460e70311829757f | diff --git a/pyupgrade/_plugins/typing_pep604.py b/pyupgrade/_plugins/typing_pep604.py
index 6ffcc20..8d55009 100644
--- a/pyupgrade/_plugins/typing_pep604.py
+++ b/pyupgrade/_plugins/typing_pep604.py
@@ -126,6 +126,15 @@ def _supported_version(state: State) -> bool:
)
+def _any_arg_is_str(node_slice: ast.expr) -> bool:
+ return (
+ isinstance(node_slice, ast.Str) or (
+ isinstance(node_slice, ast.Tuple) and
+ any(isinstance(elt, ast.Str) for elt in node_slice.elts)
+ )
+ )
+
+
@register(ast.Subscript)
def visit_Subscript(
state: State,
@@ -135,6 +144,17 @@ def visit_Subscript(
if not _supported_version(state):
return
+ # prevent rewriting forward annotations
+ if (
+ (sys.version_info >= (3, 9) and _any_arg_is_str(node.slice)) or
+ (
+ sys.version_info < (3, 9) and
+ isinstance(node.slice, ast.Index) and
+ _any_arg_is_str(node.slice.value)
+ )
+ ):
+ return
+
if is_name_attr(node.value, state.from_imports, 'typing', ('Optional',)):
yield ast_to_offset(node), _fix_optional
elif is_name_attr(node.value, state.from_imports, 'typing', ('Union',)):
| Do not upgrade string annotations types wrapped in `Optional` to new Union | formatting
Simplistic python code:
```python
qqq: "int" | None = 0
```
Output:
```
python qqq.py
Traceback (most recent call last):
File "qqq.py", line 2, in <module>
qqq: "int" | None = 0
TypeError: unsupported operand type(s) for |: 'str' and 'NoneType'
```
When running pyupgrade a segment of code was updated to use the `|` notation and caused this explosion. I worked around it, but I am sure others might run into similar issues.
| asottile/pyupgrade | diff --git a/tests/features/typing_pep604_test.py b/tests/features/typing_pep604_test.py
index 503bc2a..7b734e9 100644
--- a/tests/features/typing_pep604_test.py
+++ b/tests/features/typing_pep604_test.py
@@ -41,6 +41,19 @@ from pyupgrade._main import _fix_plugins
(3, 10),
id='3.10+ empty Union',
),
+ # https://github.com/asottile/pyupgrade/issues/567
+ pytest.param(
+ 'from typing import Optional\n'
+ 'def f() -> Optional["str"]: ...\n',
+ (3, 10),
+ id='3.10+ Optional of forward reference',
+ ),
+ pytest.param(
+ 'from typing import Union\n'
+ 'def f() -> Union[int, "str"]: ...\n',
+ (3, 10),
+ id='3.10+ Union of forward reference',
+ ),
),
)
def test_fix_pep604_types_noop(s, version):
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 2.29 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
-e git+https://github.com/asottile/pyupgrade.git@f5b16fcfdffb755b8ca41b9d1bc343075853a5ab#egg=pyupgrade
tokenize_rt==6.1.0
tomli==2.2.1
| name: pyupgrade
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tokenize-rt==6.1.0
- tomli==2.2.1
prefix: /opt/conda/envs/pyupgrade
| [
"tests/features/typing_pep604_test.py::test_fix_pep604_types_noop[3.10+"
] | [] | [
"tests/features/typing_pep604_test.py::test_fix_pep604_types_noop[<3.10",
"tests/features/typing_pep604_test.py::test_fix_pep604_types_noop[<3.9",
"tests/features/typing_pep604_test.py::test_noop_keep_runtime_typing",
"tests/features/typing_pep604_test.py::test_keep_runtime_typing_ignored_in_py310",
"tests/features/typing_pep604_test.py::test_fix_pep604_types[Union",
"tests/features/typing_pep604_test.py::test_fix_pep604_types[Union,",
"tests/features/typing_pep604_test.py::test_fix_pep604_types[Optional",
"tests/features/typing_pep604_test.py::test_fix_pep604_types[nested",
"tests/features/typing_pep604_test.py::test_fix_generic_types_future_annotations[variable",
"tests/features/typing_pep604_test.py::test_fix_generic_types_future_annotations[argument",
"tests/features/typing_pep604_test.py::test_fix_generic_types_future_annotations[return"
] | [] | MIT License | 11,605 | 365 | [
"pyupgrade/_plugins/typing_pep604.py"
] |
|
VirtusLab__git-machete-348 | 931fd2c58aaebdc325e1fd2c9ceacecee80f72e7 | 2021-11-16 14:09:49 | e5b100971d2980207bdec315e76a55ea88c8324c | diff --git a/git_machete/client.py b/git_machete/client.py
index 556fa3d..d1d9146 100644
--- a/git_machete/client.py
+++ b/git_machete/client.py
@@ -1631,6 +1631,7 @@ class MacheteClient:
*,
branch: LocalBranchShortName,
is_called_from_traverse: bool,
+ is_called_from_create_pr: bool,
opt_push_untracked: bool,
opt_push_tracked: bool,
opt_yes: bool
@@ -1654,6 +1655,7 @@ class MacheteClient:
new_remote=rems[index],
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=is_called_from_create_pr,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
@@ -1667,12 +1669,13 @@ class MacheteClient:
new_remote: str,
branch: LocalBranchShortName,
is_called_from_traverse: bool,
+ is_called_from_create_pr: bool,
opt_push_untracked: bool,
opt_push_tracked: bool,
opt_yes: bool
) -> None:
rems: List[str] = self.__git.get_remotes()
- can_pick_other_remote = len(rems) > 1
+ can_pick_other_remote = len(rems) > 1 and not is_called_from_create_pr
other_remote_choice = "o[ther-remote]" if can_pick_other_remote else ""
remote_branch = RemoteBranchShortName.of(f"{new_remote}/{branch}")
if not self.__git.get_commit_sha_by_revision(remote_branch):
@@ -1694,6 +1697,7 @@ class MacheteClient:
self.__pick_remote(
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=is_called_from_create_pr,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
@@ -1708,6 +1712,7 @@ class MacheteClient:
self.__pick_remote(
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=is_called_from_create_pr,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
@@ -1783,6 +1788,7 @@ class MacheteClient:
self.__pick_remote(
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=is_called_from_create_pr,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
@@ -1994,9 +2000,24 @@ class MacheteClient:
self.flush_caches()
base: Optional[LocalBranchShortName] = self.up_branch.get(LocalBranchShortName.of(head))
+ if not base:
+ raise MacheteException(f'Could not determine base branch for PR. Branch `{head}` is a root branch.')
org: str
repo: str
- _, (org, repo) = self.__derive_remote_and_github_org_and_repo()
+ remote, (org, repo) = self.__derive_remote_and_github_org_and_repo()
+ print(f"Fetching {remote}...")
+ self.__git.fetch_remote(remote)
+ if '/'.join([remote, base]) not in self.__git.get_remote_branches():
+ warn(f'Base branch for this PR (`{base}`) is not found on remote, pushing...')
+ self.handle_untracked_branch(
+ branch=base,
+ new_remote=remote,
+ is_called_from_traverse=False,
+ is_called_from_create_pr=True,
+ opt_push_tracked=False,
+ opt_push_untracked=True,
+ opt_yes=False)
+
current_user: Optional[str] = git_machete.github.derive_current_user_login()
debug(f'create_github_pr({head})', f'organization is {org}, repository is {repo}')
debug(f'create_github_pr({head})', 'current GitHub user is ' + (current_user or '<none>'))
@@ -2079,13 +2100,16 @@ class MacheteClient:
new_remote=rmt,
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=False,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
elif len(rems) == 1:
self.handle_untracked_branch(
- new_remote=rems[0], branch=branch,
+ new_remote=rems[0],
+ branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=False,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
@@ -2094,6 +2118,7 @@ class MacheteClient:
new_remote="origin",
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=False,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
@@ -2103,6 +2128,7 @@ class MacheteClient:
self.__pick_remote(
branch=branch,
is_called_from_traverse=is_called_from_traverse,
+ is_called_from_create_pr=False,
opt_push_untracked=opt_push_untracked,
opt_push_tracked=opt_push_tracked,
opt_yes=opt_yes)
| `github create-pr`: check if base branch for PR exists in remote
Attempt to create a pull request with base branch being already deleted from remote ends up with `Unprocessable Entity` error. (example in #332).
Proposed solution:
Perform `git fetch <remote>` at the beginning of `create-pr`. if base branch is not present in remote branches, perform `handle_untracked_branch` with relevant remote for missing base branch. | VirtusLab/git-machete | diff --git a/git_machete/tests/functional/test_machete.py b/git_machete/tests/functional/test_machete.py
index 36165d7..55749e7 100644
--- a/git_machete/tests/functional/test_machete.py
+++ b/git_machete/tests/functional/test_machete.py
@@ -1927,6 +1927,8 @@ class MacheteTester(unittest.TestCase):
git_api_state_for_test_create_pr = MockGithubAPIState([{'head': {'ref': 'ignore-trailing', 'repo': mock_repository_info}, 'user': {'login': 'github_user'}, 'base': {'ref': 'hotfix/add-trigger'}, 'number': '3', 'html_url': 'www.github.com', 'state': 'open'}],
issues=[{'number': '4'}, {'number': '5'}, {'number': '6'}])
+ # We need to mock GITHUB_REMOTE_PATTERNS in the tests for `test_github_create_pr` due to `git fetch` executed by `create-pr` subcommand.
+ @mock.patch('git_machete.github.GITHUB_REMOTE_PATTERNS', FAKE_GITHUB_REMOTE_PATTERNS)
@mock.patch('git_machete.utils.run_cmd', mock_run_cmd) # to hide git outputs in tests
@mock.patch('git_machete.options.CommandLineOptions', FakeCommandLineOptions)
@mock.patch('git_machete.client.MacheteClient.ask_if', mock_ask_if)
@@ -2093,6 +2095,47 @@ class MacheteTester(unittest.TestCase):
self.assertEqual(e.exception.parameter, expected_error_message,
'Verify that expected error message has appeared when creating PR from root branch.')
+ git_api_state_for_test_create_pr_missing_base_branch_on_remote = MockGithubAPIState([{'head': {'ref': 'chore/redundant_checks', 'repo': mock_repository_info}, 'user': {'login': 'github_user'}, 'base': {'ref': 'restrict_access'}, 'number': '18', 'html_url': 'www.github.com', 'state': 'open'}])
+
+ # We need to mock GITHUB_REMOTE_PATTERNS in the tests for `test_github_create_pr` due to `git fetch` executed by `create-pr` subcommand.
+ @mock.patch('git_machete.github.GITHUB_REMOTE_PATTERNS', FAKE_GITHUB_REMOTE_PATTERNS)
+ @mock.patch('git_machete.utils.run_cmd', mock_run_cmd) # to hide git outputs in tests
+ @mock.patch('git_machete.options.CommandLineOptions', FakeCommandLineOptions)
+ @mock.patch('git_machete.client.MacheteClient.ask_if', mock_ask_if)
+ @mock.patch('urllib.request.urlopen', MockContextManager)
+ @mock.patch('urllib.request.Request', git_api_state_for_test_create_pr_missing_base_branch_on_remote.new_request())
+ def test_github_create_pr_missing_base_branch_on_remote(self) -> None:
+ (
+ self.repo_sandbox.new_branch("root")
+ .commit("initial commit")
+ .new_branch("develop")
+ .commit("first commit on develop")
+ .push()
+ .new_branch("feature/api_handling")
+ .commit("Introduce GET and POST methods on API")
+ .new_branch("feature/api_exception_handling")
+ .commit("catch exceptions coming from API")
+ .push()
+ .delete_branch("root")
+ )
+
+ self.launch_command('discover')
+
+ expected_msg = ("Fetching origin...\n"
+ "Warn: Base branch for this PR (`feature/api_handling`) is not found on remote, pushing...\n"
+ "Creating a PR from `feature/api_exception_handling` to `feature/api_handling`... OK, see www.github.com\n")
+ self.assert_command(['github', 'create-pr'], expected_msg, strip_indentation=False)
+ self.assert_command(
+ ['status'],
+ """
+ develop
+ |
+ o-feature/api_handling
+ |
+ o-feature/api_exception_handling * PR #19
+ """,
+ )
+
git_api_state_for_test_checkout_prs = MockGithubAPIState([
{'head': {'ref': 'chore/redundant_checks', 'repo': mock_repository_info}, 'user': {'login': 'github_user'}, 'base': {'ref': 'restrict_access'}, 'number': '18', 'html_url': 'www.github.com', 'state': 'open'},
{'head': {'ref': 'restrict_access', 'repo': mock_repository_info}, 'user': {'login': 'github_user'}, 'base': {'ref': 'allow-ownership-link'}, 'number': '17', 'html_url': 'www.github.com', 'state': 'open'},
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_issue_reference",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 1
} | 3.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup==1.2.2
-e git+https://github.com/VirtusLab/git-machete.git@931fd2c58aaebdc325e1fd2c9ceacecee80f72e7#egg=git_machete
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
tomli==2.2.1
| name: git-machete
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/git-machete
| [
"git_machete/tests/functional/test_machete.py::MacheteTester::test_github_create_pr_missing_base_branch_on_remote"
] | [] | [
"git_machete/tests/functional/test_machete.py::MacheteTester::test_add",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_advance_with_few_possible_downstream_branches_and_yes_option",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_advance_with_no_downstream_branches",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_advance_with_one_downstream_branch",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_anno_prs",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_branch_reappers_in_definition",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_checkout_prs",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_checkout_prs_freshly_cloned",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_checkout_prs_from_fork_with_deleted_repo",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_discover_traverse_squash",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_github_create_pr",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_down",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_first_root_with_downstream",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_first_root_without_downstream",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_last",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_next_successor_exists",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_next_successor_on_another_root_tree",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_prev_successor_exists",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_prev_successor_on_another_root_tree",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_root",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_go_up",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_help",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_log",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_retarget_pr",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_down",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_first",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_last",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_next",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_prev",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_root",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_show_up",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out_with_down_fork_point_and_multiple_children_of_last_branch",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out_with_invalid_down_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_slide_out_with_valid_down_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_squash_merge",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_squash_with_invalid_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_squash_with_valid_fork_point",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_traverse_no_push",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_traverse_no_push_override",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_traverse_no_push_untracked",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_update_with_fork_point_not_specified",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_update_with_fork_point_specified",
"git_machete/tests/functional/test_machete.py::MacheteTester::test_update_with_invalid_fork_point"
] | [] | MIT License | 11,612 | 1,332 | [
"git_machete/client.py"
] |
|
mhostetter__galois-206 | 158f5ff81fad4aa89bf4d55d0e05d57a57d54b70 | 2021-11-16 15:43:04 | d94c3b61dfb31127990d5811077e33861bc4953a | codecov[bot]: # [Codecov](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) Report
> Merging [#206](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) (83ab1f4) into [master](https://codecov.io/gh/mhostetter/galois/commit/158f5ff81fad4aa89bf4d55d0e05d57a57d54b70?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) (158f5ff) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter)
```diff
@@ Coverage Diff @@
## master #206 +/- ##
=======================================
Coverage 92.81% 92.81%
=======================================
Files 38 38
Lines 4326 4327 +1
=======================================
+ Hits 4015 4016 +1
Misses 311 311
```
| [Impacted Files](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) | Coverage Δ | |
|---|---|---|
| [galois/\_codes/\_bch.py](https://codecov.io/gh/mhostetter/galois/pull/206/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19jb2Rlcy9fYmNoLnB5) | `97.95% <100.00%> (ø)` | |
| [galois/\_codes/\_cyclic.py](https://codecov.io/gh/mhostetter/galois/pull/206/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19jb2Rlcy9fY3ljbGljLnB5) | `94.59% <100.00%> (+0.15%)` | :arrow_up: |
| [galois/\_fields/\_array.py](https://codecov.io/gh/mhostetter/galois/pull/206/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19maWVsZHMvX2FycmF5LnB5) | `93.77% <100.00%> (ø)` | |
| [galois/\_fields/\_class.py](https://codecov.io/gh/mhostetter/galois/pull/206/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19maWVsZHMvX2NsYXNzLnB5) | `90.00% <100.00%> (ø)` | |
| [galois/\_polys/\_functions.py](https://codecov.io/gh/mhostetter/galois/pull/206/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19wb2x5cy9fZnVuY3Rpb25zLnB5) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter). Last update [158f5ff...83ab1f4](https://codecov.io/gh/mhostetter/galois/pull/206?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter).
| diff --git a/galois/_codes/_bch.py b/galois/_codes/_bch.py
index 2278eae7e..48c95131c 100644
--- a/galois/_codes/_bch.py
+++ b/galois/_codes/_bch.py
@@ -89,7 +89,7 @@ def bch_valid_codes(n, t_min=1):
while True:
c = 1
roots = alpha**(c + np.arange(0, 2*t))
- powers = GF.characteristic**np.arange(0, GF.degree)
+ powers = GF.characteristic**np.arange(0, GF.degree, dtype=GF.dtypes[-1])
conjugates = np.unique(np.power.outer(roots, powers))
g_degree = len(conjugates)
k = n - g_degree
@@ -201,7 +201,7 @@ class BCH:
# minimal polynomial and then doing an LCM, we will compute all the unique conjugates of all the roots
# and then compute (x - c1)*(x - c2)*...*(x - cn), which is equivalent.
roots = alpha**(c + np.arange(0, 2*t))
- powers = GF.characteristic**np.arange(0, GF.degree)
+ powers = GF.characteristic**np.arange(0, GF.degree, dtype=GF.dtypes[-1])
conjugates = np.unique(np.power.outer(roots, powers))
g_degree = len(conjugates)
diff --git a/galois/_codes/_cyclic.py b/galois/_codes/_cyclic.py
index 289b5527a..19da32611 100644
--- a/galois/_codes/_cyclic.py
+++ b/galois/_codes/_cyclic.py
@@ -109,6 +109,7 @@ def roots_to_parity_check_matrix(n, roots):
if not isinstance(roots, FieldArray):
raise TypeError(f"Argument `roots` must be a galois.FieldArray, not {type(roots)}.")
- H = np.power.outer(roots, np.arange(n - 1, -1, -1))
+ GF = type(roots)
+ H = np.power.outer(roots, np.arange(n - 1, -1, -1, dtype=GF.dtypes[-1]))
return H
diff --git a/galois/_fields/_array.py b/galois/_fields/_array.py
index dcfc80c2b..d7554ea94 100644
--- a/galois/_fields/_array.py
+++ b/galois/_fields/_array.py
@@ -765,7 +765,7 @@ class FieldArray(np.ndarray, metaclass=FieldClass):
subfield = field.prime_subfield
p = field.characteristic
m = field.degree
- conjugates = np.power.outer(self, p**np.arange(0, m, dtype=self.dtype))
+ conjugates = np.power.outer(self, p**np.arange(0, m, dtype=field.dtypes[-1]))
trace = np.add.reduce(conjugates, axis=-1)
return subfield(trace)
diff --git a/galois/_fields/_class.py b/galois/_fields/_class.py
index fe72b56fb..746214926 100644
--- a/galois/_fields/_class.py
+++ b/galois/_fields/_class.py
@@ -313,7 +313,7 @@ class FieldClass(FunctionMeta, UfuncMeta, PropertiesMeta):
if cls.display_mode == "power":
# Order elements by powers of the primitive element
- x_default = np.concatenate((np.atleast_1d(cls(0)), cls.primitive_element**np.arange(0, cls.order - 1)))
+ x_default = np.concatenate((np.atleast_1d(cls(0)), cls.primitive_element**np.arange(0, cls.order - 1, dtype=cls.dtypes[-1])))
else:
x_default = cls.Elements()
y_default = x_default if operation != "/" else x_default[1:]
diff --git a/galois/_polys/_functions.py b/galois/_polys/_functions.py
index 8fd3d83de..34a50c27b 100644
--- a/galois/_polys/_functions.py
+++ b/galois/_polys/_functions.py
@@ -113,7 +113,7 @@ def minimal_poly(element):
if field.is_prime_field:
return x - element
else:
- conjugates = np.unique(element**(field.characteristic**np.arange(0, field.degree)))
+ conjugates = np.unique(element**(field.characteristic**np.arange(0, field.degree, dtype=field.dtypes[-1])))
poly = Poly.Roots(conjugates, field=field)
poly = Poly(poly.coeffs, field=field.prime_subfield)
return poly
| Error in `minimal_poly()` with large fields
As discovered [here](https://github.com/mhostetter/galois/issues/185#issuecomment-969938384), `galois.minimal_poly()` fails for large extension fields.
Here's a reproducible example:
```python
In [1]: import galois
In [2]: poly = galois.Poly.Degrees([256, 241, 178, 121, 0]); poly
Out[2]: Poly(x^256 + x^241 + x^178 + x^121 + 1, GF(2))
In [3]: GF = galois.GF((2**256), irreducible_poly=poly, primitive_element=2, verify=False)
In [4]: print(GF.properties)
GF(2^256):
characteristic: 2
degree: 256
order: 115792089237316195423570985008687907853269984665640564039457584007913129639936
irreducible_poly: x^256 + x^241 + x^178 + x^121 + 1
is_primitive_poly: True
primitive_element: x
In [5]: x = GF(4); x
Out[5]: GF(4, order=2^256)
In [6]: galois.minimal_poly(x)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-6-976c7185bfb2> in <module>
----> 1 galois.minimal_poly(x)
/mnt/c/Users/matth/repos/galois/galois/_polys/_functions.py in minimal_poly(element)
116 conjugates = np.unique(element**(field.characteristic**np.arange(0, field.degree)))
117 poly = Poly.Roots(conjugates, field=field)
--> 118 poly = Poly(poly.coeffs, field=field.prime_subfield)
119 return poly
/mnt/c/Users/matth/repos/galois/galois/_polys/_poly.py in __new__(cls, coeffs, field, order)
109 coeffs = coeffs[::-1] # Ensure it's in descending-degree order
110
--> 111 coeffs, field = cls._convert_coeffs(coeffs, field)
112
113 if field is GF2:
/mnt/c/Users/matth/repos/galois/galois/_polys/_poly.py in _convert_coeffs(cls, coeffs, field)
136 # Ensure coeffs is an iterable
137 coeffs = coeffs.tolist()
--> 138 coeffs = field([int(-field(abs(c))) if c < 0 else c for c in coeffs])
139
140 return coeffs, field
/mnt/c/Users/matth/repos/galois/galois/_fields/_array.py in __new__(cls, array, dtype, copy, order, ndmin)
116 if cls is FieldArray:
117 raise NotImplementedError("FieldArray is an abstract base class that cannot be directly instantiated. Instead, create a FieldArray subclass for GF(p^m) arithmetic using `GF = galois.GF(p**m)` and instantiate an array using `x = GF(array_like)`.")
--> 118 return cls._array(array, dtype=dtype, copy=copy, order=order, ndmin=ndmin)
119
120 def __init__(self, array, dtype=None, copy=True, order="K", ndmin=0):
/mnt/c/Users/matth/repos/galois/galois/_fields/_array.py in _array(cls, array_like, dtype, copy, order, ndmin)
171 def _array(cls, array_like, dtype=None, copy=True, order="K", ndmin=0):
172 dtype = cls._get_dtype(dtype)
--> 173 array_like = cls._check_array_like_object(array_like)
174 array = np.array(array_like, dtype=dtype, copy=copy, order=order, ndmin=ndmin)
175 return array.view(cls)
/mnt/c/Users/matth/repos/galois/galois/_fields/_array.py in _check_array_like_object(cls, array_like)
191 # Recursively check the items in the iterable to ensure they're of the correct type
192 # and that their values are in range
--> 193 array_like = cls._check_iterable_types_and_values(array_like)
194 elif isinstance(array_like, np.ndarray):
195 # If this a NumPy array, but not a FieldArray, verify the array
/mnt/c/Users/matth/repos/galois/galois/_fields/_array.py in _check_iterable_types_and_values(cls, iterable)
218 raise TypeError(f"When {cls.name} arrays are created/assigned with an iterable, each element must be an integer. Found type {type(item)}.")
219
--> 220 cls._check_array_values(item)
221 # if not 0 <= item < cls.order:
222 # raise ValueError(f"{cls.name} arrays must have elements in 0 <= x < {cls.order}, not {item}.")
/mnt/c/Users/matth/repos/galois/galois/_fields/_array.py in _check_array_values(cls, array)
257 idxs = np.logical_or(array < 0, array >= cls.order)
258 values = array if array.ndim == 0 else array[idxs]
--> 259 raise ValueError(f"{cls.name} arrays must have elements in `0 <= x < {cls.order}`, not {values}.")
260
261 @classmethod
ValueError: GF(2) arrays must have elements in `0 <= x < 2`, not 107745580774404846491629807443664560507035291931888949065819222618122380761054.
```
After this PR, the example runs as follows:
```python
In [1]: import galois
In [2]: poly = galois.Poly.Degrees([256, 241, 178, 121, 0]); poly
Out[2]: Poly(x^256 + x^241 + x^178 + x^121 + 1, GF(2))
In [3]: GF = galois.GF((2**256), irreducible_poly=poly, primitive_element=2, verify=False)
In [4]: print(GF.properties)
GF(2^256):
characteristic: 2
degree: 256
order: 115792089237316195423570985008687907853269984665640564039457584007913129639936
irreducible_poly: x^256 + x^241 + x^178 + x^121 + 1
is_primitive_poly: True
primitive_element: x
In [5]: x = GF(4); x
Out[5]: GF(4, order=2^256)
In [6]: galois.minimal_poly(x)
Out[6]: Poly(x^256 + x^241 + x^178 + x^121 + 1, GF(2))
``` | mhostetter/galois | diff --git a/tests/polys/test_minimal_polys.py b/tests/polys/test_minimal_polys.py
index 814d5507f..daec41c4c 100644
--- a/tests/polys/test_minimal_polys.py
+++ b/tests/polys/test_minimal_polys.py
@@ -380,3 +380,11 @@ def test_minimal_poly(characteristic, degree):
e = GFpm(item[0])
poly = galois.Poly(item[1], field=GFp)
assert galois.minimal_poly(e) == poly
+
+
+def test_minimal_poly_large_field():
+ # Test vectors generated with SageMath
+ GF = galois.GF(2**100)
+ galois.minimal_poly(GF(2)) == galois.Poly.String("x^100 + x^57 + x^56 + x^55 + x^52 + x^48 + x^47 + x^46 + x^45 + x^44 + x^43 + x^41 + x^37 + x^36 + x^35 + x^34 + x^31 + x^30 + x^27 + x^25 + x^24 + x^22 + x^20 + x^19 + x^16 + x^15 + x^11 + x^9 + x^8 + x^6 + x^5 + x^3 + 1")
+ galois.minimal_poly(GF(3)) == galois.Poly.String("x^100 + x^96 + x^68 + x^64 + x^57 + x^55 + x^54 + x^53 + x^51 + x^50 + x^48 + x^47 + x^42 + x^41 + x^38 + x^36 + x^31 + x^29 + x^26 + x^24 + x^15 + x^14 + x^12 + x^9 + x^8 + x^5 + x^2 + x + 1")
+ galois.minimal_poly(GF(6)) == galois.Poly.String("x^100 + x^78 + x^76 + x^74 + x^73 + x^71 + x^67 + x^66 + x^65 + x^62 + x^60 + x^55 + x^52 + x^51 + x^50 + x^48 + x^47 + x^45 + x^42 + x^41 + x^35 + x^34 + x^33 + x^31 + x^30 + x^29 + x^28 + x^27 + x^26 + x^23 + x^22 + x^21 + x^20 + x^19 + x^16 + x^14 + x^13 + x^12 + x^10 + x^9 + x^8 + x^6 + x^3 + x + 1")
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 5
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-benchmark"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "python3 -m pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | astroid==3.3.9
coverage==7.8.0
dill==0.3.9
exceptiongroup==1.2.2
-e git+https://github.com/mhostetter/galois.git@158f5ff81fad4aa89bf4d55d0e05d57a57d54b70#egg=galois
iniconfig==2.1.0
isort==6.0.1
llvmlite==0.36.0
mccabe==0.7.0
numba==0.53.1
numpy==1.20.3
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
py-cpuinfo==9.0.0
pylint==3.3.6
pytest==8.3.5
pytest-benchmark==5.1.0
pytest-cov==6.0.0
tomli==2.2.1
tomlkit==0.13.2
typing_extensions==4.13.0
| name: galois
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- astroid==3.3.9
- coverage==7.8.0
- dill==0.3.9
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- isort==6.0.1
- llvmlite==0.36.0
- mccabe==0.7.0
- numba==0.53.1
- numpy==1.20.3
- packaging==24.2
- platformdirs==4.3.7
- pluggy==1.5.0
- py-cpuinfo==9.0.0
- pylint==3.3.6
- pytest==8.3.5
- pytest-benchmark==5.1.0
- pytest-cov==6.0.0
- tomli==2.2.1
- tomlkit==0.13.2
- typing-extensions==4.13.0
prefix: /opt/conda/envs/galois
| [
"tests/polys/test_minimal_polys.py::test_minimal_poly_large_field"
] | [] | [
"tests/polys/test_minimal_polys.py::test_minimal_poly_exceptions",
"tests/polys/test_minimal_polys.py::test_minimal_poly[2-1]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[2-2]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[2-3]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[2-4]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[3-1]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[3-2]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[3-3]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[3-4]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[5-1]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[5-2]",
"tests/polys/test_minimal_polys.py::test_minimal_poly[5-3]"
] | [] | MIT License | 11,614 | 1,151 | [
"galois/_codes/_bch.py",
"galois/_codes/_cyclic.py",
"galois/_fields/_array.py",
"galois/_fields/_class.py",
"galois/_polys/_functions.py"
] |
aesara-devs__aesara-667 | 972694585039e65cf67b7f8d829ccdd3694dede5 | 2021-11-16 16:29:09 | 972694585039e65cf67b7f8d829ccdd3694dede5 | codecov[bot]: # [Codecov](https://codecov.io/gh/aesara-devs/aesara/pull/667?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#667](https://codecov.io/gh/aesara-devs/aesara/pull/667?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (9507d09) into [main](https://codecov.io/gh/aesara-devs/aesara/commit/cbf91122296b68ee2ad592b2312d56f6ff65ba53?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (cbf9112) will **decrease** coverage by `0.00%`.
> The diff coverage is `80.00%`.
[](https://codecov.io/gh/aesara-devs/aesara/pull/667?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)
```diff
@@ Coverage Diff @@
## main #667 +/- ##
==========================================
- Coverage 77.16% 77.16% -0.01%
==========================================
Files 156 156
Lines 47007 47010 +3
Branches 10281 10283 +2
==========================================
+ Hits 36271 36273 +2
Misses 8150 8150
- Partials 2586 2587 +1
```
| [Impacted Files](https://codecov.io/gh/aesara-devs/aesara/pull/667?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | |
|---|---|---|
| [aesara/tensor/random/type.py](https://codecov.io/gh/aesara-devs/aesara/pull/667/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-YWVzYXJhL3RlbnNvci9yYW5kb20vdHlwZS5weQ==) | `89.89% <66.66%> (-0.73%)` | :arrow_down: |
| [aesara/link/numba/dispatch/basic.py](https://codecov.io/gh/aesara-devs/aesara/pull/667/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-YWVzYXJhL2xpbmsvbnVtYmEvZGlzcGF0Y2gvYmFzaWMucHk=) | `93.21% <100.00%> (ø)` | |
| [aesara/link/numba/dispatch/random.py](https://codecov.io/gh/aesara-devs/aesara/pull/667/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-YWVzYXJhL2xpbmsvbnVtYmEvZGlzcGF0Y2gvcmFuZG9tLnB5) | `100.00% <100.00%> (ø)` | |
| diff --git a/aesara/link/numba/dispatch/basic.py b/aesara/link/numba/dispatch/basic.py
index 90868834b..d2bdf92e6 100644
--- a/aesara/link/numba/dispatch/basic.py
+++ b/aesara/link/numba/dispatch/basic.py
@@ -430,7 +430,9 @@ def numba_funcify_DeepCopyOp(op, node, **kwargs):
# Scalars are apparently returned as actual Python scalar types and not
# NumPy scalars, so we need two separate Numba functions for each case.
- if node.outputs[0].type.ndim == 0:
+
+ # The type can also be RandomType with no ndims
+ if not hasattr(node.outputs[0].type, "ndim") or node.outputs[0].type.ndim == 0:
# TODO: Do we really need to compile a pass-through function like this?
@numba.njit(inline="always")
def deepcopyop(x):
diff --git a/aesara/link/numba/dispatch/random.py b/aesara/link/numba/dispatch/random.py
index 6b932df5d..681782809 100644
--- a/aesara/link/numba/dispatch/random.py
+++ b/aesara/link/numba/dispatch/random.py
@@ -4,7 +4,9 @@ from typing import Any, Callable, Dict, Optional
import numba
import numba.np.unsafe.ndarray as numba_ndarray
import numpy as np
-from numba import _helperlib
+from numba import _helperlib, types
+from numba.core import cgutils
+from numba.extending import NativeValue, box, models, register_model, typeof_impl, unbox
from numpy.random import RandomState
import aesara.tensor.random.basic as aer
@@ -22,12 +24,71 @@ from aesara.tensor.random.type import RandomStateType
from aesara.tensor.random.var import RandomStateSharedVariable
+class RandomStateNumbaType(types.Type):
+ def __init__(self):
+ super(RandomStateNumbaType, self).__init__(name="RandomState")
+
+
+random_state_numba_type = RandomStateNumbaType()
+
+
+@typeof_impl.register(RandomState)
+def typeof_index(val, c):
+ return random_state_numba_type
+
+
+@register_model(RandomStateNumbaType)
+class RandomStateNumbaModel(models.StructModel):
+ def __init__(self, dmm, fe_type):
+ members = [
+ # TODO: We can add support for boxing and unboxing
+ # the attributes that describe a RandomState so that
+ # they can be accessed inside njit functions, if required.
+ ("state_key", types.Array(types.uint32, 1, "C")),
+ ]
+ models.StructModel.__init__(self, dmm, fe_type, members)
+
+
+@unbox(RandomStateNumbaType)
+def unbox_random_state(typ, obj, c):
+ """Convert a `RandomState` object to a native `RandomStateNumbaModel` structure.
+
+ Note that this will create a 'fake' structure which will just get the
+ `RandomState` objects accepted in Numba functions but the actual information
+ of the Numba's random state is stored internally and can be accessed
+ anytime using ``numba._helperlib.rnd_get_np_state_ptr()``.
+ """
+ interval = cgutils.create_struct_proxy(typ)(c.context, c.builder)
+ is_error = cgutils.is_not_null(c.builder, c.pyapi.err_occurred())
+ return NativeValue(interval._getvalue(), is_error=is_error)
+
+
+@box(RandomStateNumbaType)
+def box_random_state(typ, val, c):
+ """Convert a native `RandomStateNumbaModel` structure to an `RandomState` object
+ using Numba's internal state array.
+
+ Note that `RandomStateNumbaModel` is just a placeholder structure with no
+ inherent information about Numba internal random state, all that information
+ is instead retrieved from Numba using ``_helperlib.rnd_get_state()`` and a new
+ `RandomState` is constructed using the Numba's current internal state.
+ """
+ pos, state_list = _helperlib.rnd_get_state(_helperlib.rnd_get_np_state_ptr())
+ rng = RandomState()
+ rng.set_state(("MT19937", state_list, pos))
+ class_obj = c.pyapi.unserialize(c.pyapi.serialize_object(rng))
+ return class_obj
+
+
@numba_typify.register(RandomState)
def numba_typify_RandomState(state, **kwargs):
+ # The numba_typify in this case is just an passthrough function
+ # that synchronizes Numba's internal random state with the current
+ # RandomState object
ints, index = state.get_state()[1:3]
ptr = _helperlib.rnd_get_np_state_ptr()
_helperlib.rnd_set_state(ptr, (index, [int(x) for x in ints]))
- return ints
+ return state
def make_numba_random_fn(node, np_random_func):
| Numba implementation of `RandomState` cannot update values in Graph.
## Description of your problem or feature request
**Please provide a minimal, self-contained, and reproducible example.**
```python
import aesara
aesara.config.mode = "NUMBA"
import aesara.tensor as at
import numpy as np
rng = aesara.shared(np.random.RandomState(1))
rng_new = aesara.shared(np.random.RandomState(2))
x = at.random.normal(rng=rng)
# This will first throw an error in DeepCopyOp but that can be bypassed by removing the conditional check.
aesara.function([],x,updates={rng:rng_new})()
```
The issue is that we essentially replace the `RandomStateType` of any given graph with Numba's internal state array in:
https://github.com/aesara-devs/aesara/blob/7c32fc48cc971889242c8a124ea577d8618f0ef2/aesara/link/numba/dispatch/random.py#L25-L30
However this state array isn't recognized by `RandomStateType.filter()` as a valid value. Hence it cannot update the rng with a new one. | aesara-devs/aesara | diff --git a/tests/link/test_numba.py b/tests/link/test_numba.py
index f1e2090c9..3f91f503b 100644
--- a/tests/link/test_numba.py
+++ b/tests/link/test_numba.py
@@ -27,6 +27,7 @@ from aesara.graph.optdb import OptimizationQuery
from aesara.graph.type import Type
from aesara.ifelse import ifelse
from aesara.link.numba.dispatch import basic as numba_basic
+from aesara.link.numba.dispatch import numba_typify
from aesara.link.numba.linker import NumbaLinker
from aesara.scalar.basic import Composite
from aesara.scan.basic import scan
@@ -293,6 +294,26 @@ def test_create_numba_signature(v, expected, force_scalar):
assert res == expected
[email protected](
+ "input, wrapper_fn, check_fn",
+ [
+ (
+ np.random.RandomState(1),
+ numba_typify,
+ lambda x, y: np.all(x.get_state()[1] == y.get_state()[1]),
+ )
+ ],
+)
+def test_numba_box_unbox(input, wrapper_fn, check_fn):
+ input = wrapper_fn(input)
+
+ pass_through = numba.njit(lambda x: x)
+ res = pass_through(input)
+
+ assert isinstance(res, type(input))
+ assert check_fn(res, input)
+
+
@pytest.mark.parametrize(
"inputs, input_vals, output_fn, exc",
[
@@ -2925,6 +2946,17 @@ def test_RandomVariable(rv_op, dist_args, size):
)
+def test_RandomState_updates():
+ rng = shared(np.random.RandomState(1))
+ rng_new = shared(np.random.RandomState(2))
+
+ x = aet.random.normal(size=10, rng=rng)
+ res = function([], x, updates={rng: rng_new}, mode=numba_mode)()
+
+ ref = np.random.RandomState(2).normal(size=10)
+ assert np.allclose(res, ref)
+
+
def test_random_Generator():
rng = shared(np.random.default_rng(29402))
g = aer.normal(rng=rng)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 2
} | 2.2 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.7",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/aesara-devs/aesara.git@972694585039e65cf67b7f8d829ccdd3694dede5#egg=aesara
alabaster @ file:///home/conda/feedstock_root/build_artifacts/alabaster_1673645646525/work
Babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1702422572539/work
backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work
backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1702571698061/work
black @ file:///home/conda/feedstock_root/build_artifacts/black-recipe_1666773063432/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1725278078093/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1666183775483/work
cfgv @ file:///home/conda/feedstock_root/build_artifacts/cfgv_1629909281805/work
chardet @ file:///home/conda/feedstock_root/build_artifacts/chardet_1656142026456/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1728479282467/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1651215140632/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1666700638685/work
coverage @ file:///home/conda/feedstock_root/build_artifacts/coverage_1664603898546/work
coveralls @ file:///home/conda/feedstock_root/build_artifacts/coveralls_1636750625813/work
Cython @ file:///home/conda/feedstock_root/build_artifacts/cython_1659101942790/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work
diff-cover @ file:///home/conda/feedstock_root/build_artifacts/diff-cover_1689422918381/work
distlib @ file:///home/conda/feedstock_root/build_artifacts/distlib_1728557174656/work
docopt==0.6.2
docutils @ file:///home/conda/feedstock_root/build_artifacts/docutils_1657104278180/work
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1720869315914/work
execnet @ file:///home/conda/feedstock_root/build_artifacts/execnet_1688933357483/work
filelock @ file:///home/conda/feedstock_root/build_artifacts/filelock_1726613473834/work
flake8 @ file:///home/conda/feedstock_root/build_artifacts/flake8_1659645013175/work
gmpy2 @ file:///home/conda/feedstock_root/build_artifacts/gmpy2_1641732916896/work
identify @ file:///home/conda/feedstock_root/build_artifacts/identify_1732589372185/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1726459485162/work
imagesize @ file:///home/conda/feedstock_root/build_artifacts/imagesize_1656939531508/work
importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1653252814274/work
iniconfig @ file:///home/conda/feedstock_root/build_artifacts/iniconfig_1673103042956/work
ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1651240553635/work
isort @ file:///home/conda/feedstock_root/build_artifacts/isort_1675293796116/work
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1696326070614/work
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1715127149914/work
llvmlite==0.39.1
Mako @ file:///home/conda/feedstock_root/build_artifacts/mako_1715711344987/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737551960/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1713250518406/work
mccabe @ file:///home/conda/feedstock_root/build_artifacts/mccabe_1643049622439/work
mkl-service==2.4.0
mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1678228039184/work
mypy-extensions @ file:///home/conda/feedstock_root/build_artifacts/mypy_extensions_1675543315189/work
nodeenv @ file:///home/conda/feedstock_root/build_artifacts/nodeenv_1717585263558/work
numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1665771418417/work
numba-scipy @ file:///home/conda/feedstock_root/build_artifacts/numba-scipy_1725282941410/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1649806299270/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1696202382185/work
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1712320355065/work
pathspec @ file:///home/conda/feedstock_root/build_artifacts/pathspec_1702249949303/work
pep8==1.7.1
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1706113125309/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1696272223550/work
pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1648772594554/work
pre-commit @ file:///home/conda/feedstock_root/build_artifacts/pre-commit_1657541073402/work
prompt_toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1727341649933/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pycodestyle @ file:///home/conda/feedstock_root/build_artifacts/pycodestyle_1659638152915/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
pydot @ file:///home/conda/feedstock_root/build_artifacts/pydot_1654961324879/work
pyflakes @ file:///home/conda/feedstock_root/build_artifacts/pyflakes_1659210156976/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1700607939962/work
pygpu==0.7.6
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1724616129934/work
pypolyagamma @ file:///home/conda/feedstock_root/build_artifacts/pypolyagamma_1636458243950/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1648857264451/work
pytest @ file:///home/conda/feedstock_root/build_artifacts/pytest_1704035161844/work
pytest-cov @ file:///home/conda/feedstock_root/build_artifacts/pytest-cov_1684964868191/work
pytest-xdist @ file:///home/conda/feedstock_root/build_artifacts/pytest-xdist_1700592942746/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1726055524169/work
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1648757092905/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1716354486713/work
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1637806658031/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
snowballstemmer @ file:///home/conda/feedstock_root/build_artifacts/snowballstemmer_1637143057757/work
Sphinx @ file:///home/conda/feedstock_root/build_artifacts/sphinx_1665915552897/work
sphinx-rtd-theme @ file:///home/conda/feedstock_root/build_artifacts/sphinx_rtd_theme_1701183475238/work
sphinxcontrib-applehelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-applehelp_1674487779667/work
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-htmlhelp_1675256494457/work
sphinxcontrib-jquery @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-jquery_1678808969227/work
sphinxcontrib-jsmath @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-jsmath_1691604704163/work
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-serializinghtml_1649380998999/work
sympy @ file:///home/conda/feedstock_root/build_artifacts/sympy_1661297069208/work
toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1604308577558/work
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1727974628237/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1675110562325/work
typed-ast @ file:///home/conda/feedstock_root/build_artifacts/typed-ast_1653226021340/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1688315532570/work
ukkonen @ file:///home/conda/feedstock_root/build_artifacts/ukkonen_1649407025308/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1708239446578/work
virtualenv @ file:///home/conda/feedstock_root/build_artifacts/virtualenv_1681949329741/work
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1699959196938/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1677313463193/work
| name: aesara
channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _openmp_mutex=4.5=3_kmp_llvm
- adwaita-icon-theme=48.0=unix_0
- alabaster=0.7.13=pyhd8ed1ab_0
- at-spi2-atk=2.38.0=h0630a04_3
- at-spi2-core=2.40.3=h0630a04_0
- atk-1.0=2.38.0=h04ea711_2
- babel=2.14.0=pyhd8ed1ab_0
- backcall=0.2.0=pyh9f0ad1d_0
- backports=1.0=pyhd8ed1ab_4
- backports.functools_lru_cache=2.0.0=pyhd8ed1ab_0
- binutils=2.43=h4852527_4
- binutils_impl_linux-64=2.43=h4bf12b8_4
- binutils_linux-64=2.43=h4852527_4
- black=22.10.0=py37h89c1867_1
- brotli-python=1.0.9=py37hd23a5d3_7
- bzip2=1.0.8=h4bc722e_7
- c-compiler=1.9.0=h2b85faf_0
- ca-certificates=2025.1.31=hbcca054_0
- cairo=1.18.4=h3394656_0
- certifi=2024.8.30=pyhd8ed1ab_0
- cffi=1.15.1=py37h43b0acd_1
- cfgv=3.3.1=pyhd8ed1ab_0
- chardet=5.0.0=py37h89c1867_0
- charset-normalizer=3.4.0=pyhd8ed1ab_0
- click=8.1.3=py37h89c1867_0
- colorama=0.4.6=pyhd8ed1ab_0
- compilers=1.9.0=ha770c72_0
- coverage=6.5.0=py37h540881e_0
- coveralls=3.3.1=pyhd8ed1ab_0
- cxx-compiler=1.9.0=h1a2810e_0
- cython=0.29.32=py37hd23a5d3_0
- dbus=1.13.6=h5008d03_3
- decorator=5.1.1=pyhd8ed1ab_0
- diff-cover=7.7.0=pyhd8ed1ab_0
- distlib=0.3.9=pyhd8ed1ab_0
- docopt=0.6.2=py_1
- docutils=0.19=py37h89c1867_0
- epoxy=1.5.10=h166bdaf_1
- exceptiongroup=1.2.2=pyhd8ed1ab_0
- execnet=2.0.2=pyhd8ed1ab_0
- expat=2.7.0=h5888daf_0
- filelock=3.16.1=pyhd8ed1ab_0
- flake8=5.0.4=pyhd8ed1ab_0
- font-ttf-dejavu-sans-mono=2.37=hab24e00_0
- font-ttf-inconsolata=3.000=h77eed37_0
- font-ttf-source-code-pro=2.038=h77eed37_0
- font-ttf-ubuntu=0.83=h77eed37_3
- fontconfig=2.15.0=h7e30c49_1
- fonts-conda-ecosystem=1=0
- fonts-conda-forge=1=0
- fortran-compiler=1.9.0=h36df796_0
- freetype=2.13.3=h48d6fc4_0
- fribidi=1.0.10=h36c2ea0_0
- gcc=13.3.0=h9576a4e_2
- gcc_impl_linux-64=13.3.0=h1e990d8_2
- gcc_linux-64=13.3.0=hc28eda2_8
- gdk-pixbuf=2.42.12=hb9ae30d_0
- gfortran=13.3.0=h9576a4e_2
- gfortran_impl_linux-64=13.3.0=h84c1745_2
- gfortran_linux-64=13.3.0=hb919d3a_8
- glib-tools=2.84.0=h4833e2c_0
- gmp=6.3.0=hac33072_2
- gmpy2=2.1.2=py37h025e8b9_0
- graphite2=1.3.13=h59595ed_1003
- graphviz=12.2.1=h5ae0cbf_1
- gtk3=3.24.43=h0c6a113_5
- gts=0.7.6=h977cf35_4
- gxx=13.3.0=h9576a4e_2
- gxx_impl_linux-64=13.3.0=hae580e1_2
- gxx_linux-64=13.3.0=h6834431_8
- harfbuzz=11.0.0=h76408a6_0
- hicolor-icon-theme=0.17=ha770c72_2
- icu=75.1=he02047a_0
- identify=2.6.3=pyhd8ed1ab_0
- idna=3.10=pyhd8ed1ab_0
- imagesize=1.4.1=pyhd8ed1ab_0
- importlib-metadata=4.11.4=py37h89c1867_0
- importlib_metadata=4.11.4=hd8ed1ab_0
- iniconfig=2.0.0=pyhd8ed1ab_0
- ipython=7.33.0=py37h89c1867_0
- isort=5.11.5=pyhd8ed1ab_0
- jedi=0.19.1=pyhd8ed1ab_0
- jinja2=3.1.4=pyhd8ed1ab_0
- kernel-headers_linux-64=3.10.0=he073ed8_18
- keyutils=1.6.1=h166bdaf_0
- krb5=1.21.3=h659f571_0
- ld_impl_linux-64=2.43=h712a8e2_4
- lerc=4.0.0=h27087fc_0
- libblas=3.9.0=16_linux64_mkl
- libcblas=3.9.0=16_linux64_mkl
- libcups=2.3.3=h4637d8d_4
- libdeflate=1.23=h4ddbbb0_0
- libedit=3.1.20250104=pl5321h7949ede_0
- libexpat=2.7.0=h5888daf_0
- libffi=3.4.6=h2dba641_0
- libgcc=14.2.0=h767d61c_2
- libgcc-devel_linux-64=13.3.0=hc03c837_102
- libgcc-ng=14.2.0=h69a702a_2
- libgd=2.3.3=h6f5c62b_11
- libgfortran=14.2.0=h69a702a_2
- libgfortran-ng=14.2.0=h69a702a_2
- libgfortran5=14.2.0=hf1ad2bd_2
- libglib=2.84.0=h2ff4ddf_0
- libgomp=14.2.0=h767d61c_2
- libgpuarray=0.7.6=h7f98852_1003
- libhwloc=2.11.2=default_h0d58e46_1001
- libiconv=1.18=h4ce23a2_1
- libjpeg-turbo=3.0.0=hd590300_1
- liblapack=3.9.0=16_linux64_mkl
- libllvm11=11.1.0=he0ac6c6_5
- liblzma=5.6.4=hb9d3cd8_0
- liblzma-devel=5.6.4=hb9d3cd8_0
- libnsl=2.0.1=hd590300_0
- libpng=1.6.47=h943b412_0
- librsvg=2.58.4=he92a37e_3
- libsanitizer=13.3.0=he8ea267_2
- libsqlite=3.49.1=hee588c1_2
- libstdcxx=14.2.0=h8f9b012_2
- libstdcxx-devel_linux-64=13.3.0=hc03c837_102
- libstdcxx-ng=14.2.0=h4852527_2
- libtiff=4.7.0=hd9ff511_3
- libuuid=2.38.1=h0b41bf4_0
- libwebp-base=1.5.0=h851e524_0
- libxcb=1.17.0=h8a09558_0
- libxkbcommon=1.8.1=hc4a0caf_0
- libxml2=2.13.7=h8d12d68_0
- libzlib=1.3.1=hb9d3cd8_2
- llvm-openmp=20.1.1=h024ca30_1
- llvmlite=0.39.1=py37h0761922_0
- mako=1.3.5=pyhd8ed1ab_0
- markupsafe=2.1.1=py37h540881e_1
- matplotlib-inline=0.1.7=pyhd8ed1ab_0
- mccabe=0.7.0=pyhd8ed1ab_0
- mkl=2022.2.1=h6508926_16999
- mkl-service=2.4.0=py37h94185c7_0
- mpc=1.3.1=h24ddda3_1
- mpfr=4.2.1=h90cbb55_3
- mpmath=1.3.0=pyhd8ed1ab_0
- mypy_extensions=1.0.0=pyha770c72_0
- ncurses=6.5=h2d0b736_3
- nodeenv=1.9.1=pyhd8ed1ab_0
- numba=0.56.3=py37hf081915_0
- numba-scipy=0.4.0=pyhd8ed1ab_1
- numpy=1.21.6=py37h976b520_0
- openssl=3.4.1=h7b32b05_0
- packaging=23.2=pyhd8ed1ab_0
- pango=1.56.3=h9ac818e_1
- parso=0.8.4=pyhd8ed1ab_0
- pathspec=0.12.1=pyhd8ed1ab_0
- pcre2=10.44=hba22ea6_2
- pep8=1.7.1=py_0
- pexpect=4.9.0=pyhd8ed1ab_0
- pickleshare=0.7.5=py_1003
- pip=24.0=pyhd8ed1ab_0
- pixman=0.44.2=h29eaf8c_0
- platformdirs=3.11.0=pyhd8ed1ab_0
- pluggy=1.0.0=py37h89c1867_3
- pre-commit=2.20.0=py37h89c1867_0
- prompt-toolkit=3.0.48=pyha770c72_0
- pthread-stubs=0.4=hb9d3cd8_1002
- ptyprocess=0.7.0=pyhd3deb0d_0
- pycodestyle=2.9.1=pyhd8ed1ab_0
- pycparser=2.21=pyhd8ed1ab_0
- pydot=1.4.2=py37h89c1867_2
- pyflakes=2.5.0=pyhd8ed1ab_0
- pygments=2.17.2=pyhd8ed1ab_0
- pygpu=0.7.6=py37hb1e94ed_1003
- pyparsing=3.1.4=pyhd8ed1ab_0
- pypolyagamma=1.2.3=py37he8f5f7f_3
- pysocks=1.7.1=py37h89c1867_5
- pytest=7.4.4=pyhd8ed1ab_0
- pytest-cov=4.1.0=pyhd8ed1ab_0
- pytest-xdist=3.5.0=pyhd8ed1ab_0
- python=3.7.12=hf930737_100_cpython
- python_abi=3.7=4_cp37m
- pytz=2024.2=pyhd8ed1ab_0
- pyyaml=6.0=py37h540881e_4
- readline=8.2=h8c095d6_2
- requests=2.32.2=pyhd8ed1ab_0
- scipy=1.7.3=py37hf2a6cf1_0
- setuptools=69.0.3=pyhd8ed1ab_0
- six=1.16.0=pyh6c4a22f_0
- snowballstemmer=2.2.0=pyhd8ed1ab_0
- sphinx=5.3.0=pyhd8ed1ab_0
- sphinx_rtd_theme=2.0.0=pyha770c72_0
- sphinxcontrib-applehelp=1.0.4=pyhd8ed1ab_0
- sphinxcontrib-devhelp=1.0.2=py_0
- sphinxcontrib-htmlhelp=2.0.1=pyhd8ed1ab_0
- sphinxcontrib-jquery=4.1=pyhd8ed1ab_0
- sphinxcontrib-jsmath=1.0.1=pyhd8ed1ab_0
- sphinxcontrib-qthelp=1.0.3=py_0
- sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_2
- sqlite=3.49.1=h9eae976_2
- sympy=1.10.1=py37h89c1867_1
- sysroot_linux-64=2.17=h0157908_18
- tbb=2021.13.0=hceb3a55_1
- tk=8.6.13=noxft_h4845f30_101
- toml=0.10.2=pyhd8ed1ab_0
- tomli=2.0.2=pyhd8ed1ab_0
- traitlets=5.9.0=pyhd8ed1ab_0
- typed-ast=1.5.4=py37h540881e_0
- typing-extensions=4.7.1=hd8ed1ab_0
- typing_extensions=4.7.1=pyha770c72_0
- tzdata=2025b=h78e105d_0
- ukkonen=1.0.1=py37h7cecad7_2
- urllib3=2.2.1=pyhd8ed1ab_0
- virtualenv=20.21.1=pyhd8ed1ab_0
- wayland=1.23.1=h3e06ad9_0
- wcwidth=0.2.10=pyhd8ed1ab_0
- wheel=0.42.0=pyhd8ed1ab_0
- xkeyboard-config=2.43=hb9d3cd8_0
- xorg-libice=1.1.2=hb9d3cd8_0
- xorg-libsm=1.2.6=he73a12e_0
- xorg-libx11=1.8.12=h4f16b4b_0
- xorg-libxau=1.0.12=hb9d3cd8_0
- xorg-libxcomposite=0.4.6=hb9d3cd8_2
- xorg-libxcursor=1.2.3=hb9d3cd8_0
- xorg-libxdamage=1.1.6=hb9d3cd8_0
- xorg-libxdmcp=1.1.5=hb9d3cd8_0
- xorg-libxext=1.3.6=hb9d3cd8_0
- xorg-libxfixes=6.0.1=hb9d3cd8_0
- xorg-libxi=1.8.2=hb9d3cd8_0
- xorg-libxinerama=1.1.5=h5888daf_1
- xorg-libxrandr=1.5.4=hb9d3cd8_0
- xorg-libxrender=0.9.12=hb9d3cd8_0
- xorg-libxtst=1.2.5=hb9d3cd8_3
- xz=5.6.4=hbcc6ac9_0
- xz-gpl-tools=5.6.4=hbcc6ac9_0
- xz-tools=5.6.4=hb9d3cd8_0
- yaml=0.2.5=h7f98852_2
- zipp=3.15.0=pyhd8ed1ab_0
- zstd=1.5.7=hb8e6e7a_2
prefix: /opt/conda/envs/aesara
| [
"tests/link/test_numba.py::test_numba_box_unbox[input0-numba_typify-<lambda>]"
] | [
"tests/link/test_numba.py::test_RandomVariable[normal_rv{0,",
"tests/link/test_numba.py::test_shared",
"tests/link/test_numba.py::test_RandomVariable[uniform_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[triangular_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[lognormal_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[exponential_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[weibull_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[logistic_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[geometric_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[hypergeometric_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[wald_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[laplace_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[binomial_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[randint_rv{0,",
"tests/link/test_numba.py::test_RandomState_updates",
"tests/link/test_numba.py::test_scan_multiple_output",
"tests/link/test_numba.py::test_scan_tap_output",
"tests/link/test_numba.py::test_scan_while"
] | [
"tests/link/test_numba.py::test_get_numba_type[v0-None-False-True]",
"tests/link/test_numba.py::test_get_numba_type[v1-expected1-False-False]",
"tests/link/test_numba.py::test_get_numba_type[v2-expected2-False-False]",
"tests/link/test_numba.py::test_get_numba_type[v3-expected3-True-False]",
"tests/link/test_numba.py::test_get_numba_type[v4-expected4-False-False]",
"tests/link/test_numba.py::test_get_numba_type[v5-expected5-False-False]",
"tests/link/test_numba.py::test_get_numba_type[v6-expected6-True-False]",
"tests/link/test_numba.py::test_create_numba_signature[v0-expected0-False]",
"tests/link/test_numba.py::test_create_numba_signature[v1-expected1-True]",
"tests/link/test_numba.py::test_create_numba_signature[v2-expected2-False]",
"tests/link/test_numba.py::test_create_numba_signature[v3-expected3-True]",
"tests/link/test_numba.py::test_create_numba_signature[v4-expected4-False]",
"tests/link/test_numba.py::test_create_numba_signature[v5-expected5-True]",
"tests/link/test_numba.py::test_create_numba_signature[v6-expected6-False]",
"tests/link/test_numba.py::test_create_numba_signature[v7-expected7-True]",
"tests/link/test_numba.py::test_Elemwise[inputs0-input_vals0-<lambda>-None]",
"tests/link/test_numba.py::test_Elemwise[inputs1-input_vals1-<lambda>-None]",
"tests/link/test_numba.py::test_Elemwise[inputs2-input_vals2-<lambda>-None]",
"tests/link/test_numba.py::test_Elemwise[inputs3-input_vals3-<lambda>-None]",
"tests/link/test_numba.py::test_Elemwise[inputs4-input_vals4-<lambda>-None]",
"tests/link/test_numba.py::test_Elemwise[inputs5-input_vals5-<lambda>-NotImplementedError]",
"tests/link/test_numba.py::test_numba_Composite[inputs0-input_values0-<lambda>]",
"tests/link/test_numba.py::test_numba_Composite[inputs1-input_values1-<lambda>]",
"tests/link/test_numba.py::test_numba_Composite[inputs2-input_values2-<lambda>]",
"tests/link/test_numba.py::test_Subtensor[x0-indices0]",
"tests/link/test_numba.py::test_Subtensor[x1-indices1]",
"tests/link/test_numba.py::test_Subtensor[x2-indices2]",
"tests/link/test_numba.py::test_Subtensor[x3-indices3]",
"tests/link/test_numba.py::test_AdvancedSubtensor1[x0-indices0]",
"tests/link/test_numba.py::test_AdvancedSubtensor[x0-indices0]",
"tests/link/test_numba.py::test_AdvancedSubtensor[x1-indices1]",
"tests/link/test_numba.py::test_IncSubtensor[x0-y0-indices0]",
"tests/link/test_numba.py::test_IncSubtensor[x1-y1-indices1]",
"tests/link/test_numba.py::test_IncSubtensor[x2-y2-indices2]",
"tests/link/test_numba.py::test_IncSubtensor[x3-y3-indices3]",
"tests/link/test_numba.py::test_AdvancedIncSubtensor1[x0-y0-indices0]",
"tests/link/test_numba.py::test_AdvancedIncSubtensor[x0-y0-indices0]",
"tests/link/test_numba.py::test_AdvancedIncSubtensor[x1-y1-indices1]",
"tests/link/test_numba.py::test_Shape[x0-1]",
"tests/link/test_numba.py::test_Alloc[0.0-shape0]",
"tests/link/test_numba.py::test_Alloc[1.1-shape1]",
"tests/link/test_numba.py::test_Alloc[v2-shape2]",
"tests/link/test_numba.py::test_Alloc[v3-shape3]",
"tests/link/test_numba.py::test_AllocEmpty",
"tests/link/test_numba.py::test_AllocDiag[v0-0]",
"tests/link/test_numba.py::test_AllocDiag[v1-1]",
"tests/link/test_numba.py::test_AllocDiag[v2--1]",
"tests/link/test_numba.py::test_Dimshuffle[v0-new_order0-True]",
"tests/link/test_numba.py::test_Dimshuffle[v1-new_order1-True]",
"tests/link/test_numba.py::test_Dimshuffle[v2-new_order2-True]",
"tests/link/test_numba.py::test_Dimshuffle[v3-new_order3-True]",
"tests/link/test_numba.py::test_Dimshuffle[v4-new_order4-True]",
"tests/link/test_numba.py::test_Dimshuffle[v5-new_order5-True]",
"tests/link/test_numba.py::test_Dimshuffle[v6-new_order6-True]",
"tests/link/test_numba.py::test_TensorFromScalar[v0]",
"tests/link/test_numba.py::test_ScalarFromTensor[v0]",
"tests/link/test_numba.py::test_Rebroadcast[v0-axis0-False]",
"tests/link/test_numba.py::test_Rebroadcast[v1-axis1-False]",
"tests/link/test_numba.py::test_Rebroadcast[v2-axis2-True]",
"tests/link/test_numba.py::test_Cast[v0-dtype0]",
"tests/link/test_numba.py::test_Cast[v1-dtype1]",
"tests/link/test_numba.py::test_Inv[v0-dtype0]",
"tests/link/test_numba.py::test_Reshape[v0-shape0-0]",
"tests/link/test_numba.py::test_Reshape[v1-shape1-2]",
"tests/link/test_numba.py::test_Reshape[v2-shape2-2]",
"tests/link/test_numba.py::test_Reshape_scalar",
"tests/link/test_numba.py::test_SpecifyShape[v0-shape0-False]",
"tests/link/test_numba.py::test_SpecifyShape[v1-shape1-True]",
"tests/link/test_numba.py::test_ViewOp[v0]",
"tests/link/test_numba.py::test_Second[x0-y0]",
"tests/link/test_numba.py::test_Second[x1-y1]",
"tests/link/test_numba.py::test_Clip[v0-3.0-7.0]",
"tests/link/test_numba.py::test_Clip[v1-3.0-7.0]",
"tests/link/test_numba.py::test_Clip[v2-7.0-3.0]",
"tests/link/test_numba.py::test_scalar_Elemwise_Clip",
"tests/link/test_numba.py::test_MakeVector[vals0-float64]",
"tests/link/test_numba.py::test_MakeVector[vals1-float64]",
"tests/link/test_numba.py::test_MakeVector[vals2-float64]",
"tests/link/test_numba.py::test_ARange[start0-stop0-step0-float64]",
"tests/link/test_numba.py::test_CAReduce[sum-0-v0-False]",
"tests/link/test_numba.py::test_CAReduce[all-0-v1-False]",
"tests/link/test_numba.py::test_CAReduce[sum-0-v2-False]",
"tests/link/test_numba.py::test_CAReduce[sum-axis3-v3-False]",
"tests/link/test_numba.py::test_CAReduce[sum-axis4-v4-False]",
"tests/link/test_numba.py::test_CAReduce[sum-None-v5-False]",
"tests/link/test_numba.py::test_CAReduce[sum-1-v6-False]",
"tests/link/test_numba.py::test_CAReduce[prod-0-v7-False]",
"tests/link/test_numba.py::test_CAReduce[prod-0-v8-False]",
"tests/link/test_numba.py::test_CAReduce[prod-1-v9-False]",
"tests/link/test_numba.py::test_CAReduce[max-None-v10-True]",
"tests/link/test_numba.py::test_Join[vals0-0]",
"tests/link/test_numba.py::test_Join[vals1-0]",
"tests/link/test_numba.py::test_Join[vals2-1]",
"tests/link/test_numba.py::test_Join[vals3-1]",
"tests/link/test_numba.py::test_Join_view",
"tests/link/test_numba.py::test_ExtractDiag[val0-0]",
"tests/link/test_numba.py::test_ExtractDiag[val1-0]",
"tests/link/test_numba.py::test_Eye[n0-None-0-None]",
"tests/link/test_numba.py::test_Eye[n1-m1-0-float32]",
"tests/link/test_numba.py::test_Eye[n2-m2-1-int64]",
"tests/link/test_numba.py::test_perform[inputs0-MySingleOut-UserWarning]",
"tests/link/test_numba.py::test_perform[inputs1-MyMultiOut-UserWarning]",
"tests/link/test_numba.py::test_Bartlett[val0]",
"tests/link/test_numba.py::test_CumOp[val0-1-add]",
"tests/link/test_numba.py::test_CumOp[val1-0-add]",
"tests/link/test_numba.py::test_CumOp[val2-1-add]",
"tests/link/test_numba.py::test_CumOp[val3-0-mul]",
"tests/link/test_numba.py::test_CumOp[val4-1-mul]",
"tests/link/test_numba.py::test_DiffOp[val0-0-0]",
"tests/link/test_numba.py::test_DiffOp[val1-0-1]",
"tests/link/test_numba.py::test_DiffOp[val2-1-0]",
"tests/link/test_numba.py::test_DiffOp[val3-1-1]",
"tests/link/test_numba.py::test_DiffOp[val4-0-0]",
"tests/link/test_numba.py::test_FillDiagonal[a0-val0]",
"tests/link/test_numba.py::test_FillDiagonalOffset[a0-val0-offset0]",
"tests/link/test_numba.py::test_FillDiagonalOffset[a1-val1-offset1]",
"tests/link/test_numba.py::test_FillDiagonalOffset[a2-val2-offset2]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr0-shape0-raise-C-None]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr1-shape1-raise-C-None]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr2-shape2-raise-C-None]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr3-shape3-raise-F-NotImplementedError]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr4-shape4-raise-C-ValueError]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr5-shape5-wrap-C-None]",
"tests/link/test_numba.py::test_RavelMultiIndex[arr6-shape6-clip-C-None]",
"tests/link/test_numba.py::test_Repeat[x0-repeats0-None-None]",
"tests/link/test_numba.py::test_Repeat[x1-repeats1-None-None]",
"tests/link/test_numba.py::test_Repeat[x2-repeats2-None-None]",
"tests/link/test_numba.py::test_Repeat[x3-repeats3-0-UserWarning]",
"tests/link/test_numba.py::test_Unique[x0-None-False-False-False-None]",
"tests/link/test_numba.py::test_Unique[x1-None-False-False-False-None]",
"tests/link/test_numba.py::test_Unique[x2-None-False-False-False-None]",
"tests/link/test_numba.py::test_Unique[x3-0-False-False-False-UserWarning]",
"tests/link/test_numba.py::test_Unique[x4-0-True-True-True-UserWarning]",
"tests/link/test_numba.py::test_UnravelIndex[arr0-shape0-C-None]",
"tests/link/test_numba.py::test_UnravelIndex[arr1-shape1-C-None]",
"tests/link/test_numba.py::test_UnravelIndex[arr2-shape2-F-NotImplementedError]",
"tests/link/test_numba.py::test_Searchsorted[a0-v0-left-None-None]",
"tests/link/test_numba.py::test_Searchsorted[a2-v2-right-sorter2-UserWarning]",
"tests/link/test_numba.py::test_BroadcastTo[x0-shape0-UserWarning]",
"tests/link/test_numba.py::test_Dot[x0-y0-None]",
"tests/link/test_numba.py::test_Dot[x1-y1-None]",
"tests/link/test_numba.py::test_Dot[x2-y2-None]",
"tests/link/test_numba.py::test_Dot[x3-y3-None]",
"tests/link/test_numba.py::test_Softmax[x0-None]",
"tests/link/test_numba.py::test_Softmax[x1-None]",
"tests/link/test_numba.py::test_LogSoftmax[x0-None]",
"tests/link/test_numba.py::test_LogSoftmax[x1-None]",
"tests/link/test_numba.py::test_Softplus[x0-None]",
"tests/link/test_numba.py::test_Softplus[x1-None]",
"tests/link/test_numba.py::test_Softplus[x2-None]",
"tests/link/test_numba.py::test_Softplus[x3-None]",
"tests/link/test_numba.py::test_Softplus[x4-None]",
"tests/link/test_numba.py::test_Softplus[x5-None]",
"tests/link/test_numba.py::test_MaxAndArgmax[x0-axes0-None]",
"tests/link/test_numba.py::test_MaxAndArgmax[x1-axes1-None]",
"tests/link/test_numba.py::test_MaxAndArgmax[x2-axes2-None]",
"tests/link/test_numba.py::test_MaxAndArgmax[x3-axes3-None]",
"tests/link/test_numba.py::test_Cholesky[x0-True-None]",
"tests/link/test_numba.py::test_Cholesky[x1-True-None]",
"tests/link/test_numba.py::test_Cholesky[x2-False-UserWarning]",
"tests/link/test_numba.py::test_Solve[A0-x0-gen-None]",
"tests/link/test_numba.py::test_Solve[A1-x1-gen-None]",
"tests/link/test_numba.py::test_Solve[A2-x2-sym-UserWarning]",
"tests/link/test_numba.py::test_Det[x0-None]",
"tests/link/test_numba.py::test_Det[x1-None]",
"tests/link/test_numba.py::test_Eig[x0-None]",
"tests/link/test_numba.py::test_Eig[x1-None]",
"tests/link/test_numba.py::test_Eig[x2-None]",
"tests/link/test_numba.py::test_Eigh[x0-L-None]",
"tests/link/test_numba.py::test_Eigh[x1-U-UserWarning]",
"tests/link/test_numba.py::test_matrix_inverses[MatrixInverse-x0-None-op_args0]",
"tests/link/test_numba.py::test_matrix_inverses[MatrixInverse-x1-None-op_args1]",
"tests/link/test_numba.py::test_matrix_inverses[Inv-x2-None-op_args2]",
"tests/link/test_numba.py::test_matrix_inverses[Inv-x3-None-op_args3]",
"tests/link/test_numba.py::test_matrix_inverses[MatrixPinv-x4-None-op_args4]",
"tests/link/test_numba.py::test_matrix_inverses[MatrixPinv-x5-None-op_args5]",
"tests/link/test_numba.py::test_QRFull[x0-reduced-None]",
"tests/link/test_numba.py::test_QRFull[x1-r-None]",
"tests/link/test_numba.py::test_QRFull[x2-reduced-None]",
"tests/link/test_numba.py::test_QRFull[x3-complete-UserWarning]",
"tests/link/test_numba.py::test_SVD[x0-True-True-None]",
"tests/link/test_numba.py::test_SVD[x1-False-True-None]",
"tests/link/test_numba.py::test_SVD[x2-True-True-None]",
"tests/link/test_numba.py::test_SVD[x3-True-False-UserWarning]",
"tests/link/test_numba.py::test_BatchedDot[x0-y0-None]",
"tests/link/test_numba.py::test_BatchedDot[x1-y1-None]",
"tests/link/test_numba.py::test_RandomVariable[poisson_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[halfnormal_rv{0,",
"tests/link/test_numba.py::test_RandomVariable[bernoulli_rv{0,",
"tests/link/test_numba.py::test_random_Generator",
"tests/link/test_numba.py::test_numba_ifelse[inputs0-<lambda>-true_vals0-false_vals0]",
"tests/link/test_numba.py::test_numba_ifelse[inputs1-<lambda>-true_vals1-false_vals1]",
"tests/link/test_numba.py::test_numba_ifelse[inputs2-<lambda>-true_vals2-false_vals2]",
"tests/link/test_numba.py::test_numba_ifelse[inputs3-<lambda>-true_vals3-false_vals3]",
"tests/link/test_numba.py::test_numba_ifelse[inputs4-<lambda>-true_vals4-false_vals4]",
"tests/link/test_numba.py::test_numba_ifelse[inputs5-<lambda>-true_vals5-false_vals5]"
] | [] | 3-clause BSD License | 11,615 | 1,189 | [
"aesara/link/numba/dispatch/basic.py",
"aesara/link/numba/dispatch/random.py"
] |
nltk__nltk-2888 | 68e4e589eb62750993aabef5554548973fe1e280 | 2021-11-17 10:33:42 | dd1494ea0b88ea92a95034777863828e6552fde2 | diff --git a/nltk/grammar.py b/nltk/grammar.py
index 49c38300a..630d5c6f7 100644
--- a/nltk/grammar.py
+++ b/nltk/grammar.py
@@ -5,6 +5,7 @@
# Edward Loper <[email protected]>
# Jason Narad <[email protected]>
# Peter Ljunglöf <[email protected]>
+# Tom Aarsen <>
# URL: <https://www.nltk.org/>
# For license information, see LICENSE.TXT
#
@@ -1317,7 +1318,7 @@ def _read_fcfg_production(input, fstruct_reader):
_ARROW_RE = re.compile(r"\s* -> \s*", re.VERBOSE)
_PROBABILITY_RE = re.compile(r"( \[ [\d\.]+ \] ) \s*", re.VERBOSE)
-_TERMINAL_RE = re.compile(r'( "[^"]+" | \'[^\']+\' ) \s*', re.VERBOSE)
+_TERMINAL_RE = re.compile(r'( "[^"]*" | \'[^\']*\' ) \s*', re.VERBOSE)
_DISJUNCTION_RE = re.compile(r"\| \s*", re.VERBOSE)
@@ -1531,48 +1532,6 @@ def cfg_demo():
print()
-toy_pcfg1 = PCFG.fromstring(
- """
- S -> NP VP [1.0]
- NP -> Det N [0.5] | NP PP [0.25] | 'John' [0.1] | 'I' [0.15]
- Det -> 'the' [0.8] | 'my' [0.2]
- N -> 'man' [0.5] | 'telescope' [0.5]
- VP -> VP PP [0.1] | V NP [0.7] | V [0.2]
- V -> 'ate' [0.35] | 'saw' [0.65]
- PP -> P NP [1.0]
- P -> 'with' [0.61] | 'under' [0.39]
- """
-)
-
-toy_pcfg2 = PCFG.fromstring(
- """
- S -> NP VP [1.0]
- VP -> V NP [.59]
- VP -> V [.40]
- VP -> VP PP [.01]
- NP -> Det N [.41]
- NP -> Name [.28]
- NP -> NP PP [.31]
- PP -> P NP [1.0]
- V -> 'saw' [.21]
- V -> 'ate' [.51]
- V -> 'ran' [.28]
- N -> 'boy' [.11]
- N -> 'cookie' [.12]
- N -> 'table' [.13]
- N -> 'telescope' [.14]
- N -> 'hill' [.5]
- Name -> 'Jack' [.52]
- Name -> 'Bob' [.48]
- P -> 'with' [.61]
- P -> 'under' [.39]
- Det -> 'the' [.41]
- Det -> 'a' [.31]
- Det -> 'my' [.28]
- """
-)
-
-
def pcfg_demo():
"""
A demonstration showing how a ``PCFG`` can be created and used.
@@ -1582,6 +1541,47 @@ def pcfg_demo():
from nltk.corpus import treebank
from nltk.parse import pchart
+ toy_pcfg1 = PCFG.fromstring(
+ """
+ S -> NP VP [1.0]
+ NP -> Det N [0.5] | NP PP [0.25] | 'John' [0.1] | 'I' [0.15]
+ Det -> 'the' [0.8] | 'my' [0.2]
+ N -> 'man' [0.5] | 'telescope' [0.5]
+ VP -> VP PP [0.1] | V NP [0.7] | V [0.2]
+ V -> 'ate' [0.35] | 'saw' [0.65]
+ PP -> P NP [1.0]
+ P -> 'with' [0.61] | 'under' [0.39]
+ """
+ )
+
+ toy_pcfg2 = PCFG.fromstring(
+ """
+ S -> NP VP [1.0]
+ VP -> V NP [.59]
+ VP -> V [.40]
+ VP -> VP PP [.01]
+ NP -> Det N [.41]
+ NP -> Name [.28]
+ NP -> NP PP [.31]
+ PP -> P NP [1.0]
+ V -> 'saw' [.21]
+ V -> 'ate' [.51]
+ V -> 'ran' [.28]
+ N -> 'boy' [.11]
+ N -> 'cookie' [.12]
+ N -> 'table' [.13]
+ N -> 'telescope' [.14]
+ N -> 'hill' [.5]
+ Name -> 'Jack' [.52]
+ Name -> 'Bob' [.48]
+ P -> 'with' [.61]
+ P -> 'under' [.39]
+ Det -> 'the' [.41]
+ Det -> 'a' [.31]
+ Det -> 'my' [.28]
+ """
+ )
+
pcfg_prods = toy_pcfg1.productions()
pcfg_prod = pcfg_prods[2]
diff --git a/nltk/parse/generate.py b/nltk/parse/generate.py
index 951020afa..9eaa92584 100644
--- a/nltk/parse/generate.py
+++ b/nltk/parse/generate.py
@@ -42,14 +42,11 @@ def _generate_all(grammar, items, depth):
for frag1 in _generate_one(grammar, items[0], depth):
for frag2 in _generate_all(grammar, items[1:], depth):
yield frag1 + frag2
- except RuntimeError as _error:
- if _error.message == "maximum recursion depth exceeded":
- # Helpful error message while still showing the recursion stack.
- raise RuntimeError(
- "The grammar has rule(s) that yield infinite recursion!!"
- ) from _error
- else:
- raise
+ except RecursionError as error:
+ # Helpful error message while still showing the recursion stack.
+ raise RuntimeError(
+ "The grammar has rule(s) that yield infinite recursion!"
+ ) from error
else:
yield []
diff --git a/nltk/parse/util.py b/nltk/parse/util.py
index b2714e0ec..66e62d303 100644
--- a/nltk/parse/util.py
+++ b/nltk/parse/util.py
@@ -1,6 +1,7 @@
# Natural Language Toolkit: Parser Utility Functions
#
# Author: Ewan Klein <[email protected]>
+# Tom Aarsen <>
#
# Copyright (C) 2001-2021 NLTK Project
# URL: <https://www.nltk.org/>
diff --git a/nltk/parse/viterbi.py b/nltk/parse/viterbi.py
index 3629292ef..c02765285 100644
--- a/nltk/parse/viterbi.py
+++ b/nltk/parse/viterbi.py
@@ -337,9 +337,50 @@ def demo():
import time
from nltk import tokenize
- from nltk.grammar import toy_pcfg1, toy_pcfg2
+ from nltk.grammar import PCFG
from nltk.parse import ViterbiParser
+ toy_pcfg1 = PCFG.fromstring(
+ """
+ S -> NP VP [1.0]
+ NP -> Det N [0.5] | NP PP [0.25] | 'John' [0.1] | 'I' [0.15]
+ Det -> 'the' [0.8] | 'my' [0.2]
+ N -> 'man' [0.5] | 'telescope' [0.5]
+ VP -> VP PP [0.1] | V NP [0.7] | V [0.2]
+ V -> 'ate' [0.35] | 'saw' [0.65]
+ PP -> P NP [1.0]
+ P -> 'with' [0.61] | 'under' [0.39]
+ """
+ )
+
+ toy_pcfg2 = PCFG.fromstring(
+ """
+ S -> NP VP [1.0]
+ VP -> V NP [.59]
+ VP -> V [.40]
+ VP -> VP PP [.01]
+ NP -> Det N [.41]
+ NP -> Name [.28]
+ NP -> NP PP [.31]
+ PP -> P NP [1.0]
+ V -> 'saw' [.21]
+ V -> 'ate' [.51]
+ V -> 'ran' [.28]
+ N -> 'boy' [.11]
+ N -> 'cookie' [.12]
+ N -> 'table' [.13]
+ N -> 'telescope' [.14]
+ N -> 'hill' [.5]
+ Name -> 'Jack' [.52]
+ Name -> 'Bob' [.48]
+ P -> 'with' [.61]
+ P -> 'under' [.39]
+ Det -> 'the' [.41]
+ Det -> 'a' [.31]
+ Det -> 'my' [.28]
+ """
+ )
+
# Define two demos. Each demo has a sentence and a grammar.
demos = [
("I saw the man with my telescope", toy_pcfg1),
| CFG.fromstring cannot handle epsilons
There are times when one wants to include an empty terminal, such as:
```
S -> A B
A -> 'a'
B -> 'b' | ''
```
However, when trying to read it via `CFG.fromstring`, I get
```
ERROR:root:An unexpected error occurred while tokenizing input
```
Interestingly, `Tree` has no problems with empty terminals:
```Python
tree = Tree('S', [
Tree('A', ['a']),
Tree('B', [''])
])
tree.pos()
```
prints
```Python
[('a', 'A'), ('', 'B')]
``` | nltk/nltk | diff --git a/nltk/test/generate.doctest b/nltk/test/generate.doctest
index a23f53a9c..ff9b96ddb 100644
--- a/nltk/test/generate.doctest
+++ b/nltk/test/generate.doctest
@@ -64,3 +64,15 @@ The number of sentences of different max depths:
114
>>> len(list(generate(grammar)))
114
+
+Infinite grammars will throw a RecursionError when not bounded by some ``depth``:
+
+ >>> grammar = CFG.fromstring("""
+ ... S -> A B
+ ... A -> B
+ ... B -> "b" | A
+ ... """)
+ >>> list(generate(grammar))
+ Traceback (most recent call last):
+ ...
+ RuntimeError: The grammar has rule(s) that yield infinite recursion!
diff --git a/nltk/test/grammar.doctest b/nltk/test/grammar.doctest
index 91349bc81..fce33264a 100644
--- a/nltk/test/grammar.doctest
+++ b/nltk/test/grammar.doctest
@@ -46,3 +46,24 @@ Chomsky Normal Form grammar (Test for bug 474)
>>> g = CFG.fromstring("VP^<TOP> -> VBP NP^<VP-TOP>")
>>> g.productions()[0].lhs()
VP^<TOP>
+
+Grammars can contain both empty strings and empty productions:
+
+ >>> from nltk.grammar import CFG
+ >>> from nltk.parse.generate import generate
+ >>> grammar = CFG.fromstring("""
+ ... S -> A B
+ ... A -> 'a'
+ ... # An empty string:
+ ... B -> 'b' | ''
+ ... """)
+ >>> list(generate(grammar))
+ [['a', 'b'], ['a', '']]
+ >>> grammar = CFG.fromstring("""
+ ... S -> A B
+ ... A -> 'a'
+ ... # An empty production:
+ ... B -> 'b' |
+ ... """)
+ >>> list(generate(grammar))
+ [['a', 'b'], ['a']]
diff --git a/nltk/test/parse.doctest b/nltk/test/parse.doctest
index 818783bde..187a1ca14 100644
--- a/nltk/test/parse.doctest
+++ b/nltk/test/parse.doctest
@@ -545,7 +545,43 @@ Unit tests for the Probabilistic CFG class
>>> from nltk.corpus import treebank
>>> from itertools import islice
- >>> from nltk.grammar import PCFG, induce_pcfg, toy_pcfg1, toy_pcfg2
+ >>> from nltk.grammar import PCFG, induce_pcfg
+ >>> toy_pcfg1 = PCFG.fromstring("""
+ ... S -> NP VP [1.0]
+ ... NP -> Det N [0.5] | NP PP [0.25] | 'John' [0.1] | 'I' [0.15]
+ ... Det -> 'the' [0.8] | 'my' [0.2]
+ ... N -> 'man' [0.5] | 'telescope' [0.5]
+ ... VP -> VP PP [0.1] | V NP [0.7] | V [0.2]
+ ... V -> 'ate' [0.35] | 'saw' [0.65]
+ ... PP -> P NP [1.0]
+ ... P -> 'with' [0.61] | 'under' [0.39]
+ ... """)
+
+ >>> toy_pcfg2 = PCFG.fromstring("""
+ ... S -> NP VP [1.0]
+ ... VP -> V NP [.59]
+ ... VP -> V [.40]
+ ... VP -> VP PP [.01]
+ ... NP -> Det N [.41]
+ ... NP -> Name [.28]
+ ... NP -> NP PP [.31]
+ ... PP -> P NP [1.0]
+ ... V -> 'saw' [.21]
+ ... V -> 'ate' [.51]
+ ... V -> 'ran' [.28]
+ ... N -> 'boy' [.11]
+ ... N -> 'cookie' [.12]
+ ... N -> 'table' [.13]
+ ... N -> 'telescope' [.14]
+ ... N -> 'hill' [.5]
+ ... Name -> 'Jack' [.52]
+ ... Name -> 'Bob' [.48]
+ ... P -> 'with' [.61]
+ ... P -> 'under' [.39]
+ ... Det -> 'the' [.41]
+ ... Det -> 'a' [.31]
+ ... Det -> 'my' [.28]
+ ... """)
Create a set of PCFG productions.
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 4
} | 3.6 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-xdist"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | click==8.1.8
coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
iniconfig==2.1.0
joblib==1.4.2
-e git+https://github.com/nltk/nltk.git@68e4e589eb62750993aabef5554548973fe1e280#egg=nltk
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
regex==2024.11.6
tomli==2.2.1
tqdm==4.67.1
| name: nltk
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- click==8.1.8
- coverage==7.8.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- iniconfig==2.1.0
- joblib==1.4.2
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- regex==2024.11.6
- tomli==2.2.1
- tqdm==4.67.1
prefix: /opt/conda/envs/nltk
| [
"nltk/test/generate.doctest::generate.doctest",
"nltk/test/grammar.doctest::grammar.doctest"
] | [
"nltk/test/parse.doctest::parse.doctest"
] | [] | [] | Apache License 2.0 | 11,621 | 2,500 | [
"nltk/grammar.py",
"nltk/parse/generate.py",
"nltk/parse/util.py",
"nltk/parse/viterbi.py"
] |
|
dr-prodigy__python-holidays-555 | 5d89951a3390a8cf3ff73580e93aaace0bca0071 | 2021-11-17 13:26:13 | 940b6b807588c0cc835b1966a229175b00eb3f75 | coveralls: ## Pull Request Test Coverage Report for [Build 1471793367](https://coveralls.io/builds/44334201)
* **2** of **2** **(100.0%)** changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage increased (+**0.0005%**) to **98.694%**
---
| Totals | [](https://coveralls.io/builds/44334201) |
| :-- | --: |
| Change from base [Build 1288461108](https://coveralls.io/builds/43163534): | 0.0005% |
| Covered Lines: | 5505 |
| Relevant Lines: | 5513 |
---
##### 💛 - [Coveralls](https://coveralls.io)
| diff --git a/holidays/countries/spain.py b/holidays/countries/spain.py
index 6b2c8dd0..3fd94870 100644
--- a/holidays/countries/spain.py
+++ b/holidays/countries/spain.py
@@ -185,7 +185,10 @@ class Spain(HolidayBase):
elif self.prov == "NC":
self._is_observed(date(year, SEP, 27), "Día de Navarra")
elif self.prov == "PV":
- self._is_observed(date(year, OCT, 25), "Día del Páis Vasco")
+ if 2011 <= year <= 2013:
+ self._is_observed(
+ date(year, OCT, 25), "Día del Páis Vasco"
+ )
elif self.prov == "RI":
self._is_observed(date(year, JUN, 9), "Día de La Rioja")
| October 25 is no longer holiday in Spain Prov=PV
I'm using the WORKDAY integration of Home Assistant to obtain a binary sensor for workdays.
AFAIK python-holidays is being used "under the hood" in this integration
Yesterday October 25th was wrongly marked as holiday.
It's not holiday since 2014.
More info (sorry, in spanish): [https://es.wikipedia.org/wiki/D%C3%ADa_del_Pa%C3%ADs_Vasco#Creaci%C3%B3n_y_desaparici%C3%B3n_de_la_festividad] | dr-prodigy/python-holidays | diff --git a/test/countries/test_spain.py b/test/countries/test_spain.py
index 6108ad57..822ced95 100644
--- a/test/countries/test_spain.py
+++ b/test/countries/test_spain.py
@@ -84,7 +84,6 @@ class TestSpain(unittest.TestCase):
(9, 11): ["CT"],
(9, 27): ["NC"],
(10, 9): ["VC"],
- (10, 25): ["PV"],
}
for prov, prov_holidays in self.prov_holidays.items():
for year in range(2010, 2025):
@@ -142,3 +141,11 @@ class TestSpain(unittest.TestCase):
date(year, *fest_day) in prov_holidays,
prov in fest_prov,
)
+
+ def test_change_of_province_specific_days(self):
+ prov_holidays = self.prov_holidays["PV"]
+ self.assertNotIn(date(2010, 10, 25), prov_holidays)
+ self.assertIn(date(2011, 10, 25), prov_holidays)
+ self.assertIn(date(2012, 10, 25), prov_holidays)
+ self.assertIn(date(2013, 10, 25), prov_holidays)
+ self.assertNotIn(date(2014, 10, 25), prov_holidays)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | .0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": null,
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements_dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | cfgv==3.4.0
convertdate==2.4.0
coverage==7.8.0
distlib==0.3.9
exceptiongroup==1.2.2
filelock==3.18.0
flake8==7.2.0
hijri-converter==2.3.1
-e git+https://github.com/dr-prodigy/python-holidays.git@5d89951a3390a8cf3ff73580e93aaace0bca0071#egg=holidays
identify==2.6.9
iniconfig==2.1.0
korean-lunar-calendar==0.3.1
mccabe==0.7.0
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
pre_commit==4.2.0
pycodestyle==2.13.0
pyflakes==3.3.2
PyMeeus==0.5.12
pytest==8.3.5
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
PyYAML==6.0.2
six==1.17.0
tomli==2.2.1
virtualenv==20.29.3
| name: python-holidays
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- cfgv==3.4.0
- convertdate==2.4.0
- coverage==7.8.0
- distlib==0.3.9
- exceptiongroup==1.2.2
- filelock==3.18.0
- flake8==7.2.0
- hijri-converter==2.3.1
- holidays==0.11.4
- identify==2.6.9
- iniconfig==2.1.0
- korean-lunar-calendar==0.3.1
- mccabe==0.7.0
- nodeenv==1.9.1
- packaging==24.2
- platformdirs==4.3.7
- pluggy==1.5.0
- pre-commit==4.2.0
- pycodestyle==2.13.0
- pyflakes==3.3.2
- pymeeus==0.5.12
- pytest==8.3.5
- pytest-cov==6.0.0
- python-dateutil==2.9.0.post0
- pyyaml==6.0.2
- six==1.17.0
- tomli==2.2.1
- virtualenv==20.29.3
prefix: /opt/conda/envs/python-holidays
| [
"test/countries/test_spain.py::TestSpain::test_change_of_province_specific_days"
] | [] | [
"test/countries/test_spain.py::TestSpain::test_fixed_holidays",
"test/countries/test_spain.py::TestSpain::test_fixed_holidays_observed",
"test/countries/test_spain.py::TestSpain::test_province_specific_days",
"test/countries/test_spain.py::TestSpain::test_variable_days_in_2016"
] | [] | MIT License | 11,623 | 234 | [
"holidays/countries/spain.py"
] |
timvink__mkdocs-table-reader-plugin-21 | 45e3105e364d70f0ecd72b3b2935ff0ed0b257fe | 2021-11-17 15:55:57 | 45e3105e364d70f0ecd72b3b2935ff0ed0b257fe | diff --git a/mkdocs_table_reader_plugin/plugin.py b/mkdocs_table_reader_plugin/plugin.py
index 3e9d4c2..9912e3f 100644
--- a/mkdocs_table_reader_plugin/plugin.py
+++ b/mkdocs_table_reader_plugin/plugin.py
@@ -81,9 +81,10 @@ class TableReaderPlugin(BasePlugin):
plugins = [p for p in config.get("plugins")]
- if "macros" in plugins:
- if plugins.index("table-reader") > plugins.index("macros"):
- raise ConfigurationError("[table-reader]: Incompatible plugin order: Define 'table-reader' before 'macros' in your mkdocs.yml.")
+ for post_load_plugin in ["macros", "markdownextradata"]:
+ if post_load_plugin in plugins:
+ if plugins.index("table-reader") > plugins.index(post_load_plugin):
+ raise ConfigurationError(f"[table-reader]: Incompatible plugin order: Define 'table-reader' before '{post_load_plugin}' in your mkdocs.yml.")
def on_page_markdown(self, markdown, page, config, files, **kwargs):
@@ -115,7 +116,7 @@ class TableReaderPlugin(BasePlugin):
# match group 0: to extract any leading whitespace
# match group 1: to extract the arguments (positional and keywords)
tag_pattern = re.compile(
- "( *)\{\{ %s\((.+)\) \}\}" % reader, flags=re.IGNORECASE
+ "( *)\{\{\s+%s\((.+)\)\s+\}\}" % reader, flags=re.IGNORECASE
)
matches = re.findall(tag_pattern, markdown)
diff --git a/setup.py b/setup.py
index 272eee4..2a5d010 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setup(
name="mkdocs-table-reader-plugin",
- version="0.6",
+ version="0.6.1",
description="MkDocs plugin to directly insert tables from files into markdown.",
long_description=long_description,
long_description_content_type="text/markdown",
| Conflict with mkdocs-markdownextradata-plugin
When using both the `mkdocs-markdownextradata-plugin` and this `mkdocs-table-reader-plugin`, there is a conflict when using the `{{ read_csv("table.csv") }}` (and other) placeholders from `mkdocs-table-reader-plugin` which are tried to be interpreted as `mkdocs-markdownextradata-plugin` placeholders.
When running `mkdocs serve` on docs containing `{{ read_csv("table.csv") }}`, then an error occurs:
`jinja2.exceptions.UndefinedError: 'read_csv' is undefined`.
This seems to be caused by the `mkdocs-table-reader-plugin` placeholders to be trying to be interpreted as `mkdocs-markdownextradata-plugin` placeholders, because both rely on the same `{{ placeholder }}` pattern within the markdown docs.
A temporary solution is to specify a different placeholder pattern for `mkdocs-markdownextradata-plugin` in the `mkdocs.yml`:
```
plugins:
- search
- markdownextradata:
jinja_options:
variable_start_string: "{{{"
variable_end_string: "}}}"
``` | timvink/mkdocs-table-reader-plugin | diff --git a/tests/fixtures/basic_setup/docs/bad_tags.md b/tests/fixtures/basic_setup/docs/bad_tags.md
index 47f81e7..00b4590 100644
--- a/tests/fixtures/basic_setup/docs/bad_tags.md
+++ b/tests/fixtures/basic_setup/docs/bad_tags.md
@@ -8,9 +8,6 @@ some badly formatted tags:
{{ read_csv() }}
-## Strange and wrong characters
-
-{{ read\_csv('path') }}
## No proper spaces
diff --git a/tests/fixtures/basic_setup/mkdocs.yml b/tests/fixtures/basic_setup/mkdocs.yml
index a7c596b..a8cedf8 100644
--- a/tests/fixtures/basic_setup/mkdocs.yml
+++ b/tests/fixtures/basic_setup/mkdocs.yml
@@ -1,5 +1,5 @@
site_name: test git_table_reader site
-use_directory_urls: true
+use_directory_urls: false
plugins:
- search
diff --git a/tests/fixtures/datapathproject/mkdocs.yml b/tests/fixtures/datapathproject/mkdocs.yml
index 9ba92b9..bf25f75 100644
--- a/tests/fixtures/datapathproject/mkdocs.yml
+++ b/tests/fixtures/datapathproject/mkdocs.yml
@@ -1,5 +1,5 @@
site_name: test git_table_reader site
-use_directory_urls: true
+use_directory_urls: false
plugins:
- search
diff --git a/tests/fixtures/datapathproject/mkdocs_trailingslash.yml b/tests/fixtures/datapathproject/mkdocs_trailingslash.yml
index 32c22f5..ee11250 100644
--- a/tests/fixtures/datapathproject/mkdocs_trailingslash.yml
+++ b/tests/fixtures/datapathproject/mkdocs_trailingslash.yml
@@ -1,5 +1,5 @@
site_name: test git_table_reader site
-use_directory_urls: true
+use_directory_urls: false
plugins:
- search
diff --git a/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml
new file mode 100644
index 0000000..3485308
--- /dev/null
+++ b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml
@@ -0,0 +1,13 @@
+site_name: test git_table_reader site
+use_directory_urls: true
+
+plugins:
+ - search
+ - table-reader
+ - markdownextradata
+
+extra:
+ customer:
+ name: Your name here
+ web: www.example.com
+ salt: salt.example.com
\ No newline at end of file
diff --git a/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml
new file mode 100644
index 0000000..812a329
--- /dev/null
+++ b/tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml
@@ -0,0 +1,13 @@
+site_name: test git_table_reader site
+use_directory_urls: true
+
+plugins:
+ - search
+ - markdownextradata
+ - table-reader
+
+extra:
+ customer:
+ name: Your name here
+ web: www.example.com
+ salt: salt.example.com
\ No newline at end of file
diff --git a/tests/test_build.py b/tests/test_build.py
index 7d2442a..08dab3f 100644
--- a/tests/test_build.py
+++ b/tests/test_build.py
@@ -178,6 +178,27 @@ def test_compatibility_markdownextradata(tmp_path):
# Make sure the extradata 'web' is inserted
assert re.search(r"www.example.com", contents)
+ tmp_proj = setup_clean_mkdocs_folder(
+ "tests/fixtures/markdownextradata/mkdocs_w_markdownextradata_wrong_order.yml", tmp_path
+ )
+
+ result = build_docs_setup(tmp_proj)
+ assert result.exit_code == 1, "'mkdocs build' command should have failed"
+
+ # Make sure correct error is raised
+ assert (
+ "[table-reader]: Incompatible plugin order:"
+ in result.output
+ )
+
+ # With correct order, no error
+ tmp_proj = setup_clean_mkdocs_folder(
+ "tests/fixtures/markdownextradata/mkdocs_w_markdownextradata.yml", tmp_path
+ )
+
+ result = build_docs_setup(tmp_proj)
+ assert result.exit_code == 0, "'mkdocs build' command should have succeeded"
+
def test_datapath_1(tmp_path):
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 3
},
"num_modified_files": 2
} | 0.6 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"codecov",
"click",
"xlrd>=1.0.0",
"mkdocs-markdownextradata-plugin",
"mkdocs-macros-plugin",
"openpyxl"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"tests/test_requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
codecov==2.1.13
coverage==7.8.0
et_xmlfile==2.0.0
exceptiongroup==1.2.2
ghp-import==2.1.0
hjson==3.1.0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
Markdown==3.7
MarkupSafe==3.0.2
mergedeep==1.3.4
mkdocs==1.6.1
mkdocs-get-deps==0.2.0
mkdocs-macros-plugin==1.3.7
mkdocs-markdownextradata-plugin==0.2.6
-e git+https://github.com/timvink/mkdocs-table-reader-plugin.git@45e3105e364d70f0ecd72b3b2935ff0ed0b257fe#egg=mkdocs_table_reader_plugin
numpy==2.0.2
openpyxl==3.1.5
packaging==24.2
pandas==2.2.3
pathspec==0.12.1
platformdirs==4.3.7
pluggy==1.5.0
pytest==8.3.5
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
pyyaml_env_tag==0.1
requests==2.32.3
six==1.17.0
super_collections==0.5.3
tabulate==0.9.0
termcolor==2.5.0
tomli==2.2.1
tzdata==2025.2
urllib3==2.3.0
watchdog==6.0.0
xlrd==2.0.1
zipp==3.21.0
| name: mkdocs-table-reader-plugin
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2025.1.31
- charset-normalizer==3.4.1
- click==8.1.8
- codecov==2.1.13
- coverage==7.8.0
- et-xmlfile==2.0.0
- exceptiongroup==1.2.2
- ghp-import==2.1.0
- hjson==3.1.0
- idna==3.10
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markdown==3.7
- markupsafe==3.0.2
- mergedeep==1.3.4
- mkdocs==1.6.1
- mkdocs-get-deps==0.2.0
- mkdocs-macros-plugin==1.3.7
- mkdocs-markdownextradata-plugin==0.2.6
- numpy==2.0.2
- openpyxl==3.1.5
- packaging==24.2
- pandas==2.2.3
- pathspec==0.12.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pytest==8.3.5
- pytest-cov==6.0.0
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pyyaml==6.0.2
- pyyaml-env-tag==0.1
- requests==2.32.3
- six==1.17.0
- super-collections==0.5.3
- tabulate==0.9.0
- termcolor==2.5.0
- tomli==2.2.1
- tzdata==2025.2
- urllib3==2.3.0
- watchdog==6.0.0
- xlrd==2.0.1
- zipp==3.21.0
prefix: /opt/conda/envs/mkdocs-table-reader-plugin
| [
"tests/test_build.py::test_compatibility_markdownextradata"
] | [] | [
"tests/test_build.py::test_table_output",
"tests/test_build.py::test_compatibility_macros_plugin",
"tests/test_build.py::test_datapath_1",
"tests/test_build.py::test_datapath_trailing",
"tests/test_build.py::test_datapath_with_spaces",
"tests/test_build.py::test_tablepath_with_spaces",
"tests/test_build.py::test_wrong_path"
] | [] | MIT License | 11,624 | 500 | [
"mkdocs_table_reader_plugin/plugin.py",
"setup.py"
] |
|
python-pillow__Pillow-5839 | d6e42f330710ddb854ba56eda7a025b4025fab1e | 2021-11-18 11:02:45 | 282d8250c6f8469f5c1127d6e918fb3960b59da3 | diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py
index 29de8a06b..a6a842b1d 100644
--- a/src/PIL/TiffImagePlugin.py
+++ b/src/PIL/TiffImagePlugin.py
@@ -89,7 +89,10 @@ DATE_TIME = 306
ARTIST = 315
PREDICTOR = 317
COLORMAP = 320
+TILEWIDTH = 322
+TILELENGTH = 323
TILEOFFSETS = 324
+TILEBYTECOUNTS = 325
SUBIFD = 330
EXTRASAMPLES = 338
SAMPLEFORMAT = 339
@@ -1649,6 +1652,7 @@ def _save(im, fp, filename):
}.items():
ifd.setdefault(tag, value)
+ blocklist = [TILEWIDTH, TILELENGTH, TILEOFFSETS, TILEBYTECOUNTS]
if libtiff:
if "quality" in encoderinfo:
quality = encoderinfo["quality"]
@@ -1680,7 +1684,7 @@ def _save(im, fp, filename):
# BITSPERSAMPLE, etc), passing arrays with a different length will result in
# segfaults. Block these tags until we add extra validation.
# SUBIFD may also cause a segfault.
- blocklist = [
+ blocklist += [
REFERENCEBLACKWHITE,
SAMPLEFORMAT,
STRIPBYTECOUNTS,
@@ -1753,6 +1757,8 @@ def _save(im, fp, filename):
raise OSError(f"encoder error {s} when writing image file")
else:
+ for tag in blocklist:
+ del ifd[tag]
offset = ifd.save(fp)
ImageFile._save(
| Three TIFF tags cause display issues in GIS software
When I run my GeoTIFF though Pillow while trying to preserve the TIFF info I end up with 3 additional TIFF tags in the output (`StripOffsets`, `RowsPerStrip`, `StripByteCounts`). The resulting output GeoTIFF is now displayed incorrectly in the GIS software `ESRI ArcMap` (all cell values are now `NoData`), but is displayed correctly with `Pillow` or `Matplotlib`. The input GeoTIFF image is produced with `ESRI ArcMap` and does not have the 3 extra TIFF tags.
This could of course be an issue with `ESRI ArcMap`, but I believe the 3 Pillow generated TIFF tags might be wrong. They show up as:
```
StripOffsets = (810,)
RowsPerStrip = (40,)
StripByteCounts = (6400,)
```
Input GeoTIFF:
[dem_input.zip](https://github.com/python-pillow/Pillow/files/7557972/dem_input.zip)
```python
from PIL import Image
EXTRA_TIFF_TAGS = {"StripOffsets" : 273, "RowsPerStrip" : 278, "StripByteCounts" : 279}
image_input = Image.open("dem_input.tif")
print([TAG in image_input.tag._tagdata for TAG in EXTRA_TIFF_TAGS.values()]) # [False, False, False]
image_input.save("dem_output.tif", tiffinfo = image_input.tag)
image_output = Image.open("dem_output.tif")
print([TAG in image_output.tag._tagdata for TAG in EXTRA_TIFF_TAGS.values()]) # [True, True, True]
print([image_output.tag[TAG] for TAG in EXTRA_TIFF_TAGS.values()]) # [(810,), (40,), (6400,)]
```
| python-pillow/Pillow | diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py
index 6ac90f778..d9fa1e4b4 100644
--- a/Tests/test_file_libtiff.py
+++ b/Tests/test_file_libtiff.py
@@ -920,6 +920,23 @@ class TestFileLibTiff(LibTiffTestCase):
with Image.open("Tests/images/tiff_strip_planar_16bit_RGBa.tiff") as im:
assert_image_equal_tofile(im, "Tests/images/tiff_16bit_RGBa_target.png")
+ @pytest.mark.parametrize("compression", (None, "jpeg"))
+ def test_block_tile_tags(self, compression, tmp_path):
+ im = hopper()
+ out = str(tmp_path / "temp.tif")
+
+ tags = {
+ TiffImagePlugin.TILEWIDTH: 256,
+ TiffImagePlugin.TILELENGTH: 256,
+ TiffImagePlugin.TILEOFFSETS: 256,
+ TiffImagePlugin.TILEBYTECOUNTS: 256,
+ }
+ im.save(out, exif=tags, compression=compression)
+
+ with Image.open(out) as reloaded:
+ for tag in tags.keys():
+ assert tag not in reloaded.getexif()
+
def test_old_style_jpeg(self):
with Image.open("Tests/images/old-style-jpeg-compression.tif") as im:
assert_image_equal_tofile(im, "Tests/images/old-style-jpeg-compression.png")
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 8.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-timeout",
"pytest-reverse"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc libtiff-dev libjpeg-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
babel==2.17.0
black==25.1.0
build==1.2.2.post1
certifi==2025.1.31
charset-normalizer==3.4.1
check-manifest==0.50
click==8.1.8
coverage==7.8.0
defusedxml==0.7.1
docutils==0.21.2
exceptiongroup==1.2.2
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
markdown2==2.5.3
MarkupSafe==3.0.2
mypy-extensions==1.0.0
olefile==0.47
packaging==24.2
pathspec==0.12.1
-e git+https://github.com/python-pillow/Pillow.git@d6e42f330710ddb854ba56eda7a025b4025fab1e#egg=Pillow
platformdirs==4.3.7
pluggy==1.5.0
Pygments==2.19.1
pyproject_hooks==1.2.0
pyroma==4.2
pytest==8.3.5
pytest-cov==6.0.0
pytest-reverse==1.8.0
pytest-timeout==2.3.1
requests==2.32.3
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-copybutton==0.5.2
sphinx-issues==5.0.0
sphinx-removed-in==0.2.3
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
sphinxext-opengraph==0.9.1
tomli==2.2.1
trove-classifiers==2025.3.19.19
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0
| name: Pillow
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- black==25.1.0
- build==1.2.2.post1
- certifi==2025.1.31
- charset-normalizer==3.4.1
- check-manifest==0.50
- click==8.1.8
- coverage==7.8.0
- defusedxml==0.7.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markdown2==2.5.3
- markupsafe==3.0.2
- mypy-extensions==1.0.0
- olefile==0.47
- packaging==24.2
- pathspec==0.12.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pygments==2.19.1
- pyproject-hooks==1.2.0
- pyroma==4.2
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-reverse==1.8.0
- pytest-timeout==2.3.1
- requests==2.32.3
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinx-copybutton==0.5.2
- sphinx-issues==5.0.0
- sphinx-removed-in==0.2.3
- sphinx-rtd-theme==3.0.2
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jquery==4.1
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- sphinxext-opengraph==0.9.1
- tomli==2.2.1
- trove-classifiers==2025.3.19.19
- typing-extensions==4.13.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/Pillow
| [
"Tests/test_file_libtiff.py::TestFileLibTiff::test_block_tile_tags[None]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_block_tile_tags[jpeg]"
] | [
"Tests/test_file_libtiff.py::TestFileLibTiff::test_custom_metadata"
] | [
"Tests/test_file_libtiff.py::TestFileLibTiff::test_version",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_large",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_tiff_file",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_tiff_bytesio",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_non_disk_file_object",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_eq_png",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_fillorder_eq_png",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_write",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_adobe_deflate_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_write_metadata",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_additional_metadata",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_subifd",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_xmlpacket_tag",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_int_dpi",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g3_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_little_endian",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_big_endian",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_string_info",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_12bit_rawmode",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_blur",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_compressions",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiff_jpeg_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiff_deflate_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_quality",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_cmyk_save",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_palette_save",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_fp_leak",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage_nframes",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage_seek_backwards",
"Tests/test_file_libtiff.py::TestFileLibTiff::test__next",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_4bit",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_gray_semibyte_per_pixel",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_bytesio",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_ycbcr",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_crashing_metadata",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_page_number_x_0",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_fd_duplication",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_read_icc",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_write_icc",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_tiff_with_jpegtables",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_16bit_RGB_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_16bit_RGBa_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_gimp_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_sampleformat",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_lzw",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_cmyk_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_cmyk_16l_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_ycbcr_jpeg_2x2_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_ycbcr_jpeg_1x1_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_cmyk_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_ycbcr_jpeg_1x1_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_ycbcr_jpeg_2x2_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_planar_rgb",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_planar_rgb",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_planar_16bit_RGB",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_planar_16bit_RGB",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_planar_16bit_RGBa",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_planar_16bit_RGBa",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_old_style_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_open_missing_samplesperpixel",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_no_rows_per_strip",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_orientation",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_sampleformat_not_corrupted",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_realloc_overflow",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_multistrip[tiff_adobe_deflate]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_multistrip[jpeg]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_single_strip",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_zero[tiff_adobe_deflate]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_zero[None]"
] | [] | MIT-CMU License | 11,634 | 446 | [
"src/PIL/TiffImagePlugin.py"
] |
|
encode__httpcore-441 | e4aa75f9ea955628347f836af8a42df9e8977c1b | 2021-11-18 14:59:43 | e4aa75f9ea955628347f836af8a42df9e8977c1b | diff --git a/httpcore/_async/http2.py b/httpcore/_async/http2.py
index 8f05eb4..025daf0 100644
--- a/httpcore/_async/http2.py
+++ b/httpcore/_async/http2.py
@@ -9,7 +9,11 @@ import h2.events
import h2.exceptions
import h2.settings
-from .._exceptions import ConnectionNotAvailable, RemoteProtocolError
+from .._exceptions import (
+ ConnectionNotAvailable,
+ LocalProtocolError,
+ RemoteProtocolError,
+)
from .._models import Origin, Request, Response
from .._synchronization import AsyncLock, AsyncSemaphore
from .._trace import Trace
@@ -56,6 +60,7 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
self._events: typing.Dict[int, h2.events.Event] = {}
self._read_exception: typing.Optional[Exception] = None
self._write_exception: typing.Optional[Exception] = None
+ self._connection_error_event: typing.Optional[h2.events.Event] = None
async def handle_async_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
@@ -114,11 +119,28 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
content=HTTP2ConnectionByteStream(self, request, stream_id=stream_id),
extensions={"stream_id": stream_id, "http_version": b"HTTP/2"},
)
- except Exception: # noqa: PIE786
+ except Exception as exc: # noqa: PIE786
kwargs = {"stream_id": stream_id}
async with Trace("http2.response_closed", request, kwargs):
await self._response_closed(stream_id=stream_id)
- raise
+
+ if isinstance(exc, h2.exceptions.ProtocolError):
+ # One case where h2 can raise a protocol error is when a
+ # closed frame has been seen by the state machine.
+ #
+ # This happens when one stream is reading, and encounters
+ # a GOAWAY event. Other flows of control may then raise
+ # a protocol error at any point they interact with the 'h2_state'.
+ #
+ # In this case we'll have stored the event, and should raise
+ # it as a RemoteProtocolError.
+ if self._connection_error_event:
+ raise RemoteProtocolError(self._connection_error_event)
+ # If h2 raises a protocol error in some other state then we
+ # must somehow have made a protocol violation.
+ raise LocalProtocolError(exc) # pragma: nocover
+
+ raise exc
async def _send_connection_init(self, request: Request) -> None:
"""
@@ -235,10 +257,17 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
) -> h2.events.Event:
while not self._events.get(stream_id):
await self._receive_events(request, stream_id)
- return self._events[stream_id].pop(0)
+ event = self._events[stream_id].pop(0)
+ # The StreamReset event applies to a single stream.
+ if hasattr(event, "error_code"):
+ raise RemoteProtocolError(event)
+ return event
async def _receive_events(self, request: Request, stream_id: int = None) -> None:
async with self._read_lock:
+ if self._connection_error_event is not None: # pragma: nocover
+ raise RemoteProtocolError(self._connection_error_event)
+
# This conditional is a bit icky. We don't want to block reading if we've
# actually got an event to return for a given stream. We need to do that
# check *within* the atomic read lock. Though it also need to be optional,
@@ -250,7 +279,10 @@ class AsyncHTTP2Connection(AsyncConnectionInterface):
for event in events:
event_stream_id = getattr(event, "stream_id", 0)
- if hasattr(event, "error_code"):
+ # The ConnectionTerminatedEvent applies to the entire connection,
+ # and should be saved so it can be raised on all streams.
+ if hasattr(event, "error_code") and event_stream_id == 0:
+ self._connection_error_event = event
raise RemoteProtocolError(event)
if event_stream_id in self._events:
diff --git a/httpcore/_sync/http2.py b/httpcore/_sync/http2.py
index 9976cfe..97ac0ec 100644
--- a/httpcore/_sync/http2.py
+++ b/httpcore/_sync/http2.py
@@ -9,7 +9,11 @@ import h2.events
import h2.exceptions
import h2.settings
-from .._exceptions import ConnectionNotAvailable, RemoteProtocolError
+from .._exceptions import (
+ ConnectionNotAvailable,
+ LocalProtocolError,
+ RemoteProtocolError,
+)
from .._models import Origin, Request, Response
from .._synchronization import Lock, Semaphore
from .._trace import Trace
@@ -56,6 +60,7 @@ class HTTP2Connection(ConnectionInterface):
self._events: typing.Dict[int, h2.events.Event] = {}
self._read_exception: typing.Optional[Exception] = None
self._write_exception: typing.Optional[Exception] = None
+ self._connection_error_event: typing.Optional[h2.events.Event] = None
def handle_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
@@ -114,11 +119,28 @@ class HTTP2Connection(ConnectionInterface):
content=HTTP2ConnectionByteStream(self, request, stream_id=stream_id),
extensions={"stream_id": stream_id, "http_version": b"HTTP/2"},
)
- except Exception: # noqa: PIE786
+ except Exception as exc: # noqa: PIE786
kwargs = {"stream_id": stream_id}
with Trace("http2.response_closed", request, kwargs):
self._response_closed(stream_id=stream_id)
- raise
+
+ if isinstance(exc, h2.exceptions.ProtocolError):
+ # One case where h2 can raise a protocol error is when a
+ # closed frame has been seen by the state machine.
+ #
+ # This happens when one stream is reading, and encounters
+ # a GOAWAY event. Other flows of control may then raise
+ # a protocol error at any point they interact with the 'h2_state'.
+ #
+ # In this case we'll have stored the event, and should raise
+ # it as a RemoteProtocolError.
+ if self._connection_error_event:
+ raise RemoteProtocolError(self._connection_error_event)
+ # If h2 raises a protocol error in some other state then we
+ # must somehow have made a protocol violation.
+ raise LocalProtocolError(exc) # pragma: nocover
+
+ raise exc
def _send_connection_init(self, request: Request) -> None:
"""
@@ -235,10 +257,17 @@ class HTTP2Connection(ConnectionInterface):
) -> h2.events.Event:
while not self._events.get(stream_id):
self._receive_events(request, stream_id)
- return self._events[stream_id].pop(0)
+ event = self._events[stream_id].pop(0)
+ # The StreamReset event applies to a single stream.
+ if hasattr(event, "error_code"):
+ raise RemoteProtocolError(event)
+ return event
def _receive_events(self, request: Request, stream_id: int = None) -> None:
with self._read_lock:
+ if self._connection_error_event is not None: # pragma: nocover
+ raise RemoteProtocolError(self._connection_error_event)
+
# This conditional is a bit icky. We don't want to block reading if we've
# actually got an event to return for a given stream. We need to do that
# check *within* the atomic read lock. Though it also need to be optional,
@@ -250,7 +279,10 @@ class HTTP2Connection(ConnectionInterface):
for event in events:
event_stream_id = getattr(event, "stream_id", 0)
- if hasattr(event, "error_code"):
+ # The ConnectionTerminatedEvent applies to the entire connection,
+ # and should be saved so it can be raised on all streams.
+ if hasattr(event, "error_code") and event_stream_id == 0:
+ self._connection_error_event = event
raise RemoteProtocolError(event)
if event_stream_id in self._events:
| possibly wrong handling of error_code?
https://github.com/encode/httpx/blob/50d337e807839c21e796fd8b01c67d8a672a9721/httpx/_dispatch/http2.py#L147-L155
IIRC, RFC defines 2 messages that may carry `error_code`:
* RST_STREAM - forcibly close 1 stream
* GOAWAY - close entire connection (gracefully or forcibly)
In addition, `h2` might generate `ResetStream` event internally:
> when the remote party has made a protocol error which only affects a single stream
I find it weird that there's only this one place where `error_code` is evaluated in the library 🤔 | encode/httpcore | diff --git a/tests/_async/test_http2.py b/tests/_async/test_http2.py
index 84915e6..95def84 100644
--- a/tests/_async/test_http2.py
+++ b/tests/_async/test_http2.py
@@ -98,10 +98,10 @@ async def test_http2_connection_with_remote_protocol_error():
@pytest.mark.anyio
-async def test_http2_connection_with_stream_cancelled():
+async def test_http2_connection_with_rst_stream():
"""
- If a remote protocol error occurs, then no response will be returned,
- and the connection will not be reusable.
+ If a stream reset occurs, then no response will be returned,
+ but the connection will remain reusable for other requests.
"""
origin = Origin(b"https", b"example.com", 443)
stream = AsyncMockStream(
@@ -117,13 +117,76 @@ async def test_http2_connection_with_stream_cancelled():
),
flags=["END_HEADERS"],
).serialize(),
+ # Stream is closed midway through the first response...
hyperframe.frame.RstStreamFrame(stream_id=1, error_code=8).serialize(),
+ # ...Which doesn't prevent the second response.
+ hyperframe.frame.HeadersFrame(
+ stream_id=3,
+ data=hpack.Encoder().encode(
+ [
+ (b":status", b"200"),
+ (b"content-type", b"plain/text"),
+ ]
+ ),
+ flags=["END_HEADERS"],
+ ).serialize(),
+ hyperframe.frame.DataFrame(
+ stream_id=3, data=b"Hello, world!", flags=["END_STREAM"]
+ ).serialize(),
b"",
]
)
async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn:
with pytest.raises(RemoteProtocolError):
await conn.request("GET", "https://example.com/")
+ response = await conn.request("GET", "https://example.com/")
+ assert response.status == 200
+
+
[email protected]
+async def test_http2_connection_with_goaway():
+ """
+ If a stream reset occurs, then no response will be returned,
+ but the connection will remain reusable for other requests.
+ """
+ origin = Origin(b"https", b"example.com", 443)
+ stream = AsyncMockStream(
+ [
+ hyperframe.frame.SettingsFrame().serialize(),
+ hyperframe.frame.HeadersFrame(
+ stream_id=1,
+ data=hpack.Encoder().encode(
+ [
+ (b":status", b"200"),
+ (b"content-type", b"plain/text"),
+ ]
+ ),
+ flags=["END_HEADERS"],
+ ).serialize(),
+ # Connection is closed midway through the first response...
+ hyperframe.frame.GoAwayFrame(stream_id=0, error_code=0).serialize(),
+ # ...We'll never get to this second response.
+ hyperframe.frame.HeadersFrame(
+ stream_id=3,
+ data=hpack.Encoder().encode(
+ [
+ (b":status", b"200"),
+ (b"content-type", b"plain/text"),
+ ]
+ ),
+ flags=["END_HEADERS"],
+ ).serialize(),
+ hyperframe.frame.DataFrame(
+ stream_id=3, data=b"Hello, world!", flags=["END_STREAM"]
+ ).serialize(),
+ b"",
+ ]
+ )
+ async with AsyncHTTP2Connection(origin=origin, stream=stream) as conn:
+ with pytest.raises(RemoteProtocolError):
+ await conn.request("GET", "https://example.com/")
+ with pytest.raises(RemoteProtocolError):
+ await conn.request("GET", "https://example.com/")
@pytest.mark.anyio
diff --git a/tests/_sync/test_http2.py b/tests/_sync/test_http2.py
index fd65b14..0804441 100644
--- a/tests/_sync/test_http2.py
+++ b/tests/_sync/test_http2.py
@@ -98,10 +98,10 @@ def test_http2_connection_with_remote_protocol_error():
-def test_http2_connection_with_stream_cancelled():
+def test_http2_connection_with_rst_stream():
"""
- If a remote protocol error occurs, then no response will be returned,
- and the connection will not be reusable.
+ If a stream reset occurs, then no response will be returned,
+ but the connection will remain reusable for other requests.
"""
origin = Origin(b"https", b"example.com", 443)
stream = MockStream(
@@ -117,13 +117,76 @@ def test_http2_connection_with_stream_cancelled():
),
flags=["END_HEADERS"],
).serialize(),
+ # Stream is closed midway through the first response...
hyperframe.frame.RstStreamFrame(stream_id=1, error_code=8).serialize(),
+ # ...Which doesn't prevent the second response.
+ hyperframe.frame.HeadersFrame(
+ stream_id=3,
+ data=hpack.Encoder().encode(
+ [
+ (b":status", b"200"),
+ (b"content-type", b"plain/text"),
+ ]
+ ),
+ flags=["END_HEADERS"],
+ ).serialize(),
+ hyperframe.frame.DataFrame(
+ stream_id=3, data=b"Hello, world!", flags=["END_STREAM"]
+ ).serialize(),
b"",
]
)
with HTTP2Connection(origin=origin, stream=stream) as conn:
with pytest.raises(RemoteProtocolError):
conn.request("GET", "https://example.com/")
+ response = conn.request("GET", "https://example.com/")
+ assert response.status == 200
+
+
+
+def test_http2_connection_with_goaway():
+ """
+ If a stream reset occurs, then no response will be returned,
+ but the connection will remain reusable for other requests.
+ """
+ origin = Origin(b"https", b"example.com", 443)
+ stream = MockStream(
+ [
+ hyperframe.frame.SettingsFrame().serialize(),
+ hyperframe.frame.HeadersFrame(
+ stream_id=1,
+ data=hpack.Encoder().encode(
+ [
+ (b":status", b"200"),
+ (b"content-type", b"plain/text"),
+ ]
+ ),
+ flags=["END_HEADERS"],
+ ).serialize(),
+ # Connection is closed midway through the first response...
+ hyperframe.frame.GoAwayFrame(stream_id=0, error_code=0).serialize(),
+ # ...We'll never get to this second response.
+ hyperframe.frame.HeadersFrame(
+ stream_id=3,
+ data=hpack.Encoder().encode(
+ [
+ (b":status", b"200"),
+ (b"content-type", b"plain/text"),
+ ]
+ ),
+ flags=["END_HEADERS"],
+ ).serialize(),
+ hyperframe.frame.DataFrame(
+ stream_id=3, data=b"Hello, world!", flags=["END_STREAM"]
+ ).serialize(),
+ b"",
+ ]
+ )
+ with HTTP2Connection(origin=origin, stream=stream) as conn:
+ with pytest.raises(RemoteProtocolError):
+ conn.request("GET", "https://example.com/")
+ with pytest.raises(RemoteProtocolError):
+ conn.request("GET", "https://example.com/")
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 2
} | 0.14 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[http2]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio",
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | anyio==3.3.4
async-generator==1.10
attrs==25.3.0
autoflake==1.4
backports.tarfile==1.2.0
black==21.10b0
blinker==1.9.0
brotlicffi==1.1.0.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.8.0
cryptography==44.0.2
decorator==5.2.1
docutils==0.21.2
exceptiongroup==1.2.2
execnet==2.1.1
flake8==4.0.1
flake8-bugbear==21.9.2
flake8-pie==0.6.1
flasgger==0.9.7.1
Flask==3.1.0
ghp-import==2.1.0
greenlet==2.0.2
h11==0.12.0
h2==4.2.0
hpack==4.1.0
httpbin==0.10.2
-e git+https://github.com/encode/httpcore.git@e4aa75f9ea955628347f836af8a42df9e8977c1b#egg=httpcore
Hypercorn==0.11.2
hyperframe==6.1.0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
isort==5.9.3
itsdangerous==2.2.0
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
Jinja2==3.1.6
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
keyring==25.6.0
Markdown==3.7
MarkupSafe==2.1.5
mccabe==0.6.1
mergedeep==1.3.4
mistune==3.1.3
mkdocs==1.2.2
mkdocs-autorefs==0.3.0
mkdocs-material==7.3.0
mkdocs-material-extensions==1.0.3
mkdocstrings==0.16.1
more-itertools==10.6.0
mypy==0.910
mypy_extensions==0.4.4
nh3==0.2.21
outcome==1.3.0.post0
packaging==24.2
pathspec==0.12.1
pkginfo==1.12.1.2
platformdirs==4.3.7
pluggy==1.5.0
pproxy==2.7.8
priority==2.0.0
py==1.11.0
pycodestyle==2.8.0
pycparser==2.22
pyflakes==2.4.0
Pygments==2.19.1
pymdown-extensions==8.2
pytest==8.3.5
pytest-asyncio==0.15.1
pytest-cov==6.0.0
pytest-httpbin==1.0.0
pytest-mock==3.14.0
pytest-trio==0.7.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pytkdocs==0.12.0
PyYAML==6.0.2
pyyaml_env_tag==0.1
readme_renderer==44.0
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==2.0.0
rpds-py==0.24.0
SecretStorage==3.3.3
six==1.17.0
sniffio==1.3.1
sortedcontainers==2.4.0
toml==0.10.2
tomli==1.2.3
tqdm==4.67.1
trio==0.19.0
trio-typing==0.5.1
trustme==0.9.0
twine==3.4.2
types-certifi==2021.10.8.0
typing_extensions==4.13.0
urllib3==2.3.0
watchdog==6.0.0
Werkzeug==3.1.3
wsproto==1.2.0
zipp==3.21.0
| name: httpcore
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- anyio==3.3.4
- async-generator==1.10
- attrs==25.3.0
- autoflake==1.4
- backports-tarfile==1.2.0
- black==21.10b0
- blinker==1.9.0
- brotlicffi==1.1.0.0
- certifi==2025.1.31
- cffi==1.17.1
- charset-normalizer==3.4.1
- click==8.1.8
- colorama==0.4.6
- coverage==7.8.0
- cryptography==44.0.2
- decorator==5.2.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- execnet==2.1.1
- flake8==4.0.1
- flake8-bugbear==21.9.2
- flake8-pie==0.6.1
- flasgger==0.9.7.1
- flask==3.1.0
- ghp-import==2.1.0
- greenlet==2.0.2
- h11==0.12.0
- h2==4.2.0
- hpack==4.1.0
- httpbin==0.10.2
- hypercorn==0.11.2
- hyperframe==6.1.0
- idna==3.10
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- isort==5.9.3
- itsdangerous==2.2.0
- jaraco-classes==3.4.0
- jaraco-context==6.0.1
- jaraco-functools==4.1.0
- jeepney==0.9.0
- jinja2==3.1.6
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- keyring==25.6.0
- markdown==3.7
- markupsafe==2.1.5
- mccabe==0.6.1
- mergedeep==1.3.4
- mistune==3.1.3
- mkdocs==1.2.2
- mkdocs-autorefs==0.3.0
- mkdocs-material==7.3.0
- mkdocs-material-extensions==1.0.3
- mkdocstrings==0.16.1
- more-itertools==10.6.0
- mypy==0.910
- mypy-extensions==0.4.4
- nh3==0.2.21
- outcome==1.3.0.post0
- packaging==24.2
- pathspec==0.12.1
- pkginfo==1.12.1.2
- platformdirs==4.3.7
- pluggy==1.5.0
- pproxy==2.7.8
- priority==2.0.0
- py==1.11.0
- pycodestyle==2.8.0
- pycparser==2.22
- pyflakes==2.4.0
- pygments==2.19.1
- pymdown-extensions==8.2
- pytest==8.3.5
- pytest-asyncio==0.15.1
- pytest-cov==6.0.0
- pytest-httpbin==1.0.0
- pytest-mock==3.14.0
- pytest-trio==0.7.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- pytkdocs==0.12.0
- pyyaml==6.0.2
- pyyaml-env-tag==0.1
- readme-renderer==44.0
- referencing==0.36.2
- regex==2024.11.6
- requests==2.32.3
- requests-toolbelt==1.0.0
- rfc3986==2.0.0
- rpds-py==0.24.0
- secretstorage==3.3.3
- six==1.17.0
- sniffio==1.3.1
- sortedcontainers==2.4.0
- toml==0.10.2
- tomli==1.2.3
- tqdm==4.67.1
- trio==0.19.0
- trio-typing==0.5.1
- trustme==0.9.0
- twine==3.4.2
- types-certifi==2021.10.8.0
- typing-extensions==4.13.0
- urllib3==2.3.0
- watchdog==6.0.0
- werkzeug==3.1.3
- wheel==0.37.0
- wsproto==1.2.0
- zipp==3.21.0
prefix: /opt/conda/envs/httpcore
| [
"tests/_async/test_http2.py::test_http2_connection_with_goaway[asyncio]",
"tests/_async/test_http2.py::test_http2_connection_with_goaway[trio]",
"tests/_sync/test_http2.py::test_http2_connection_with_goaway"
] | [] | [
"tests/_async/test_http2.py::test_http2_connection[asyncio]",
"tests/_async/test_http2.py::test_http2_connection[trio]",
"tests/_async/test_http2.py::test_http2_connection_post_request[asyncio]",
"tests/_async/test_http2.py::test_http2_connection_post_request[trio]",
"tests/_async/test_http2.py::test_http2_connection_with_remote_protocol_error[asyncio]",
"tests/_async/test_http2.py::test_http2_connection_with_remote_protocol_error[trio]",
"tests/_async/test_http2.py::test_http2_connection_with_rst_stream[asyncio]",
"tests/_async/test_http2.py::test_http2_connection_with_rst_stream[trio]",
"tests/_async/test_http2.py::test_http2_connection_with_flow_control[asyncio]",
"tests/_async/test_http2.py::test_http2_connection_with_flow_control[trio]",
"tests/_async/test_http2.py::test_http2_connection_attempt_close[asyncio]",
"tests/_async/test_http2.py::test_http2_connection_attempt_close[trio]",
"tests/_async/test_http2.py::test_http2_request_to_incorrect_origin[asyncio]",
"tests/_async/test_http2.py::test_http2_request_to_incorrect_origin[trio]",
"tests/_sync/test_http2.py::test_http2_connection",
"tests/_sync/test_http2.py::test_http2_connection_post_request",
"tests/_sync/test_http2.py::test_http2_connection_with_remote_protocol_error",
"tests/_sync/test_http2.py::test_http2_connection_with_rst_stream",
"tests/_sync/test_http2.py::test_http2_connection_with_flow_control",
"tests/_sync/test_http2.py::test_http2_connection_attempt_close",
"tests/_sync/test_http2.py::test_http2_request_to_incorrect_origin"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,638 | 1,958 | [
"httpcore/_async/http2.py",
"httpcore/_sync/http2.py"
] |
|
lebrice__SimpleParsing-99 | 9d4e4c89991a0dc3220723a203a8a8ae3ede9cca | 2021-11-19 00:53:43 | 404f7f3183308ba180918f42c236de1dd733e964 | diff --git a/simple_parsing/utils.py b/simple_parsing/utils.py
index 56f41da..88b14ff 100644
--- a/simple_parsing/utils.py
+++ b/simple_parsing/utils.py
@@ -187,8 +187,8 @@ def get_item_type(container_type: Type[Container[T]]) -> T:
def get_argparse_type_for_container(
- container_type: Type,
-) -> Union[Type, Callable[[str], bool]]:
+ container_type: Type[Container[T]],
+) -> Union[Type[T], Callable[[str], T]]:
"""Gets the argparse 'type' option to be used for a given container type.
When an annotation is present, the 'type' option of argparse is set to that type.
if not, then the default value of 'str' is returned.
@@ -208,6 +208,12 @@ def get_argparse_type_for_container(
return str2bool
if T is Any:
return str
+ if is_enum(T):
+ # IDEA: Fix this weirdness by first moving all this weird parsing logic into the
+ # field wrapper class, and then split it up into different subclasses of FieldWrapper,
+ # each for a different type of field.
+ from simple_parsing.wrappers.field_parsing import parse_enum
+ return parse_enum(T)
return T
diff --git a/simple_parsing/wrappers/field_parsing.py b/simple_parsing/wrappers/field_parsing.py
index 05bf312..09baf37 100644
--- a/simple_parsing/wrappers/field_parsing.py
+++ b/simple_parsing/wrappers/field_parsing.py
@@ -3,6 +3,8 @@
Somewhat analogous to the 'parse' function in the
`helpers.serialization.parsing` package.
"""
+import enum
+import functools
from dataclasses import Field
from logging import getLogger
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, TypeVar, Union
@@ -11,6 +13,7 @@ import typing_inspect as tpi
from ..utils import (
get_type_arguments,
+ is_enum,
is_homogeneous_tuple_type,
is_list,
is_tuple,
@@ -122,7 +125,10 @@ def get_parsing_fn(t: Type[T]) -> Callable[[Any], T]:
logger.debug(f"parsing a Union field: {t}")
args = get_type_arguments(t)
return parse_union(*args)
-
+
+ elif is_enum(t):
+ logger.debug(f"Parsing an Enum field of type {t}")
+ return parse_enum(t)
# import typing_inspect as tpi
# from .serializable import get_dataclass_type_from_forward_ref, Serializable
@@ -237,7 +243,6 @@ def parse_tuple(
return parsed_value
- _parse_tuple.__name__ = "BOB"
return _parse_tuple
@@ -256,3 +261,36 @@ def no_op(v: T) -> T:
[type]: The value unchanged.
"""
return v
+
+
+E = TypeVar("E", bound=enum.Enum)
+
+
+def parse_enum(enum_type: Type[E]) -> Callable[[str], E]:
+ """Returns a function to use to parse an enum of type `enum_type` from a string.
+
+ Parameters
+ ----------
+ - enum_type : Type[enum.Enum]
+
+ The type of enum to create a parsing function for.
+
+ Returns
+ -------
+ Callable[[str], E]
+ A function that parses an enum object of type `enum_type` from a string.
+ """
+ # Save the function, since the same type will always be parsed the same way. Also
+ # makes testing easier.
+ if enum_type in _parsing_fns:
+ return _parsing_fns[enum_type]
+
+ # NOTE: Use `functools.wraps` so that fn name is the enum, so the metavar shows up
+ # just like the enum on the command-line, and not like
+ # "(...).parse_enum.<locals>._parse_enum" or something.
+ @functools.wraps(enum_type)
+ def _parse_enum(v: str) -> E:
+ return enum_type[v]
+ _parsing_fns[enum_type] = _parse_enum
+ return _parse_enum
+
\ No newline at end of file
| Lists of enums are parsed by value on the command line
**Describe the bug**
While enums seem to be parsed by member name, a list of them seems to be parsed by member value, but only if the value is a string, not an integer
**To Reproduce**
```python
import enum
from typing import *
from dataclasses import dataclass
from simple_parsing import ArgumentParser
from simple_parsing.helpers import list_field
parser = ArgumentParser()
class Color(enum.Enum):
RED = "RED"
ORANGE = "ORANGE"
BLUE = "BLUE"
class Temperature(enum.Enum):
HOT = 1
WARM = 0
COLD = -1
MONTREAL = -35
@dataclass
class MyPreferences:
"""You can use Enums"""
color: Color = Color.BLUE # my favorite colour
# a list of colors
color_list: List[Color] = list_field(Color.ORANGE)
# pick a temperature
temp: Temperature = Temperature.WARM
# a list of temperatures
temp_list: List[Temperature] = list_field(Temperature.COLD, Temperature.WARM)
parser.add_arguments(MyPreferences, "my_preferences")
args = parser.parse_args()
prefs: MyPreferences = args.my_preferences
print(prefs)
```
**Expected behavior**
A clear and concise description of what you expected to happen.
```console
$ python issue.py --color ORANGE --color_list RED BLUE --temp MONTREAL
MyPreferences(color=<Color.ORANGE: 'ORANGE'>, color_list=[<Color.RED: 'RED'>, <Color.BLUE: 'BLUE'>], temp=<Temperature.MONTREAL: -35>, temp_list=[<Temperature.COLD: -1>, <Temperature.WARM: 0>])
$ python issue.py --color ORANGE --color_list RED BLUE --temp MONTREAL --temp_list MONTREAL
MyPreferences(color=<Color.ORANGE: 'ORANGE'>, color_list=[<Color.RED: 'RED'>, <Color.BLUE: 'BLUE'>], temp=<Temperature.MONTREAL: -35>, temp_list=[<Temperature.MONTREAL: -35>])
```
**Actual behavior**
A clear and concise description of what is happening.
```console
$ python issue.py --color ORANGE --color_list RED BLUE --temp MONTREAL --temp_list MONTREAL
usage: enums.py [-h] [--color Color] [--color_list Color] [--temp Temperature]
[--temp_list Temperature]
enums.py: error: argument --temp_list: invalid Temperature value: 'MONTREAL'
```
**Desktop (please complete the following information):**
- Version 0.0.15.post1
- Python version: 3.9.0
**Additional context**
If I add the proper encoders and decoders, I can load and save both kinds of enum lists from .json files just fine:
```
@encode.register
def encode_Color(obj: Color) -> str:
return obj.name
register_decoding_fn(Color, Color)
@encode.register
def encode_Temperature(obj: Temperature) -> str:
return obj.name
register_decoding_fn(Temperature, lambda temp: Temperature[temp])
``` | lebrice/SimpleParsing | diff --git a/test/test_base.py b/test/test_base.py
index fb12434..2e36962 100644
--- a/test/test_base.py
+++ b/test/test_base.py
@@ -244,3 +244,76 @@ def test_using_a_Type_type():
foo = OtherFoo.setup("")
assert foo.a == Extended()
+
+
+def test_issue62():
+ import enum
+ from simple_parsing.helpers import list_field
+ from typing import List
+ parser = ArgumentParser()
+
+ class Color(enum.Enum):
+ RED = "red"
+ ORANGE = "orange"
+ BLUE = "blue"
+
+ class Temperature(enum.Enum):
+ HOT = 1
+ WARM = 0
+ COLD = -1
+ MONTREAL = -35
+
+ @dataclass
+ class MyPreferences(TestSetup):
+ """You can use Enums"""
+
+ color: Color = Color.BLUE # my favorite colour
+ # a list of colors
+ color_list: List[Color] = list_field(Color.ORANGE)
+ # Some floats.
+ floats: List[float] = list_field(1.1, 2.2, 3.3)
+ # pick a temperature
+ temp: Temperature = Temperature.WARM
+ # a list of temperatures
+ temp_list: List[Temperature] = list_field(Temperature.COLD, Temperature.WARM)
+
+ parser.add_arguments(MyPreferences, "my_preferences")
+ assert MyPreferences.setup(
+ "--color ORANGE --color_list RED BLUE --temp MONTREAL"
+ ) == MyPreferences(
+ color=Color.ORANGE,
+ color_list=[Color.RED, Color.BLUE],
+ temp=Temperature.MONTREAL,
+ temp_list=[Temperature.COLD, Temperature.WARM],
+ )
+ assert MyPreferences.setup(
+ "--color ORANGE --color_list RED BLUE --temp MONTREAL --temp_list MONTREAL HOT"
+ ) == MyPreferences(
+ color=Color.ORANGE,
+ color_list=[Color.RED, Color.BLUE],
+ temp=Temperature.MONTREAL,
+ temp_list=[Temperature.MONTREAL, Temperature.HOT],
+ )
+ assert Temperature["MONTREAL"] is Temperature.MONTREAL
+ assert Temperature(-35) is Temperature.MONTREAL
+
+ # NOTE: This kind of test (comparing the help str) is unreliable, changes depending on the
+ # python version.
+ # assert MyPreferences.get_help_text() == textwrap.dedent("""\
+ # usage: pytest [-h] [--color Color] [--color_list Color] [--floats float]
+ # [--temp Temperature] [--temp_list Temperature]
+
+ # optional arguments:
+ # -h, --help show this help message and exit
+
+ # test_issue62.<locals>.MyPreferences ['my_preferences']:
+ # You can use Enums
+
+ # --color Color my favorite colour (default: BLUE)
+ # --color_list Color a list of colors (default: [<Color.ORANGE: 'orange'>])
+ # --floats float Some floats. (default: [1.1, 2.2, 3.3])
+ # --temp Temperature pick a temperature (default: WARM)
+ # --temp_list Temperature
+ # a list of temperatures (default: [<Temperature.COLD:
+ # -1>, <Temperature.WARM: 0>])
+ # """)
diff --git a/test/test_fields.py b/test/test_fields.py
index a026d3c..9056766 100644
--- a/test/test_fields.py
+++ b/test/test_fields.py
@@ -46,14 +46,14 @@ class Color(Enum):
from simple_parsing.wrappers.field_parsing import get_parsing_fn
from simple_parsing.utils import str2bool
-
+from simple_parsing.wrappers.field_parsing import parse_enum
@pytest.mark.parametrize(
"annotation, expected_options",
[
(Tuple[int, int], dict(nargs=2, type=int)),
- (Tuple[Color, Color], dict(nargs=2, type=Color)),
- (Optional[Tuple[Color, Color]], dict(nargs=2, type=Color, required=False)),
+ (Tuple[Color, Color], dict(nargs=2, type=parse_enum(Color))),
+ (Optional[Tuple[Color, Color]], dict(nargs=2, type=parse_enum(Color), required=False)),
(List[str], dict(nargs="*", type=str)),
(Optional[List[str]], dict(nargs="*", type=str, required=False)),
(Optional[str], dict(nargs="?", type=str, required=False)),
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
mypy-extensions==1.0.0
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
-e git+https://github.com/lebrice/SimpleParsing.git@9d4e4c89991a0dc3220723a203a8a8ae3ede9cca#egg=simple_parsing
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing-inspect==0.9.0
typing_extensions==4.13.0
| name: SimpleParsing
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- mypy-extensions==1.0.0
- typing-extensions==4.13.0
- typing-inspect==0.9.0
prefix: /opt/conda/envs/SimpleParsing
| [
"test/test_base.py::test_basic_required_argument[simple_attribute0]",
"test/test_base.py::test_basic_required_argument[simple_attribute1]",
"test/test_base.py::test_basic_required_argument[simple_attribute2]",
"test/test_base.py::test_basic_required_argument[simple_attribute3]",
"test/test_base.py::test_basic_required_argument[simple_attribute4]",
"test/test_base.py::test_basic_required_argument[simple_attribute5]",
"test/test_base.py::test_basic_required_argument[simple_attribute6]",
"test/test_base.py::test_basic_required_argument[simple_attribute7]",
"test/test_base.py::test_basic_required_argument[simple_attribute8]",
"test/test_base.py::test_basic_required_argument[simple_attribute9]",
"test/test_base.py::test_basic_required_argument[simple_attribute10]",
"test/test_base.py::test_basic_required_argument[simple_attribute11]",
"test/test_base.py::test_basic_required_argument[simple_attribute12]",
"test/test_base.py::test_basic_required_argument[simple_attribute13]",
"test/test_base.py::test_basic_required_argument[simple_attribute14]",
"test/test_base.py::test_basic_required_argument[simple_attribute15]",
"test/test_base.py::test_basic_required_argument[simple_attribute16]",
"test/test_base.py::test_basic_required_argument[simple_attribute17]",
"test/test_base.py::test_basic_required_argument[simple_attribute18]",
"test/test_base.py::test_basic_required_argument[simple_attribute19]",
"test/test_base.py::test_basic_required_argument[simple_attribute20]",
"test/test_base.py::test_basic_required_argument[simple_attribute21]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute0]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute1]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute2]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute3]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute4]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute5]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute6]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute7]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute8]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute9]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute10]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute11]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute12]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute13]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute14]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute15]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute16]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute17]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute18]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute19]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute20]",
"test/test_base.py::test_not_passing_required_argument_raises_error[simple_attribute21]",
"test/test_base.py::test_basic_optional_argument[simple_attribute0]",
"test/test_base.py::test_basic_optional_argument[simple_attribute1]",
"test/test_base.py::test_basic_optional_argument[simple_attribute2]",
"test/test_base.py::test_basic_optional_argument[simple_attribute3]",
"test/test_base.py::test_basic_optional_argument[simple_attribute4]",
"test/test_base.py::test_basic_optional_argument[simple_attribute5]",
"test/test_base.py::test_basic_optional_argument[simple_attribute6]",
"test/test_base.py::test_basic_optional_argument[simple_attribute7]",
"test/test_base.py::test_basic_optional_argument[simple_attribute8]",
"test/test_base.py::test_basic_optional_argument[simple_attribute9]",
"test/test_base.py::test_basic_optional_argument[simple_attribute10]",
"test/test_base.py::test_basic_optional_argument[simple_attribute11]",
"test/test_base.py::test_basic_optional_argument[simple_attribute12]",
"test/test_base.py::test_basic_optional_argument[simple_attribute13]",
"test/test_base.py::test_basic_optional_argument[simple_attribute14]",
"test/test_base.py::test_basic_optional_argument[simple_attribute15]",
"test/test_base.py::test_basic_optional_argument[simple_attribute16]",
"test/test_base.py::test_basic_optional_argument[simple_attribute17]",
"test/test_base.py::test_basic_optional_argument[simple_attribute18]",
"test/test_base.py::test_basic_optional_argument[simple_attribute19]",
"test/test_base.py::test_basic_optional_argument[simple_attribute20]",
"test/test_base.py::test_basic_optional_argument[simple_attribute21]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute0]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute1]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute2]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute3]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute4]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute5]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute6]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute7]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute8]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute9]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute10]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute11]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute12]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute13]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute14]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute15]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute16]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute17]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute18]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute19]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute20]",
"test/test_base.py::test_works_fine_with_other_argparse_arguments[simple_attribute21]",
"test/test_base.py::test_arg_value_is_set_when_args_are_provided[int-0-1234]",
"test/test_base.py::test_arg_value_is_set_when_args_are_provided[float-0.0-123.456]",
"test/test_base.py::test_arg_value_is_set_when_args_are_provided[str--bobby_boots]",
"test/test_base.py::test_arg_value_is_set_when_args_are_provided[bool-False-True]",
"test/test_base.py::test_not_providing_required_argument_throws_error[int]",
"test/test_base.py::test_not_providing_required_argument_throws_error[float]",
"test/test_base.py::test_not_providing_required_argument_throws_error[str]",
"test/test_base.py::test_not_providing_required_argument_throws_error[bool]",
"test/test_base.py::test_not_providing_required_argument_name_but_no_value_throws_error[int]",
"test/test_base.py::test_not_providing_required_argument_name_but_no_value_throws_error[float]",
"test/test_base.py::test_not_providing_required_argument_name_but_no_value_throws_error[str]",
"test/test_base.py::test_parse_base_simple_works",
"test/test_base.py::test_parse_multiple_works",
"test/test_base.py::test_parse_multiple_inconsistent_throws_error",
"test/test_base.py::test_help_displays_class_docstring_text",
"test/test_base.py::test_enum_attributes_work",
"test/test_base.py::test_passing_default_value[simple_attribute0]",
"test/test_base.py::test_passing_default_value[simple_attribute1]",
"test/test_base.py::test_passing_default_value[simple_attribute2]",
"test/test_base.py::test_passing_default_value[simple_attribute3]",
"test/test_base.py::test_passing_default_value[simple_attribute4]",
"test/test_base.py::test_passing_default_value[simple_attribute5]",
"test/test_base.py::test_passing_default_value[simple_attribute6]",
"test/test_base.py::test_passing_default_value[simple_attribute7]",
"test/test_base.py::test_passing_default_value[simple_attribute8]",
"test/test_base.py::test_passing_default_value[simple_attribute9]",
"test/test_base.py::test_passing_default_value[simple_attribute10]",
"test/test_base.py::test_passing_default_value[simple_attribute11]",
"test/test_base.py::test_passing_default_value[simple_attribute12]",
"test/test_base.py::test_passing_default_value[simple_attribute13]",
"test/test_base.py::test_passing_default_value[simple_attribute14]",
"test/test_base.py::test_passing_default_value[simple_attribute15]",
"test/test_base.py::test_passing_default_value[simple_attribute16]",
"test/test_base.py::test_passing_default_value[simple_attribute17]",
"test/test_base.py::test_passing_default_value[simple_attribute18]",
"test/test_base.py::test_passing_default_value[simple_attribute19]",
"test/test_base.py::test_passing_default_value[simple_attribute20]",
"test/test_base.py::test_passing_default_value[simple_attribute21]",
"test/test_base.py::test_parsing_twice",
"test/test_base.py::test_passing_instance",
"test/test_base.py::test_using_a_Type_type",
"test/test_base.py::test_issue62",
"test/test_fields.py::test_cmd_false_doesnt_create_conflicts",
"test/test_fields.py::test_generated_options_from_annotation[annotation0-expected_options0]",
"test/test_fields.py::test_generated_options_from_annotation[annotation1-expected_options1]",
"test/test_fields.py::test_generated_options_from_annotation[annotation2-expected_options2]",
"test/test_fields.py::test_generated_options_from_annotation[annotation3-expected_options3]",
"test/test_fields.py::test_generated_options_from_annotation[annotation4-expected_options4]",
"test/test_fields.py::test_generated_options_from_annotation[annotation5-expected_options5]",
"test/test_fields.py::test_generated_options_from_annotation[annotation6-expected_options6]"
] | [] | [] | [] | MIT License | 11,644 | 1,020 | [
"simple_parsing/utils.py",
"simple_parsing/wrappers/field_parsing.py"
] |
|
ResearchObject__ro-crate-py-95 | 7a5d25f3f4f8f4ca68f42cc582cf61378589bbe2 | 2021-11-19 13:55:00 | 6fe2b480f2e31baec3f3958c95067bb8d7e1ad9b | diff --git a/rocrate/model/preview.py b/rocrate/model/preview.py
index 553eacc..03013b9 100644
--- a/rocrate/model/preview.py
+++ b/rocrate/model/preview.py
@@ -32,8 +32,8 @@ class Preview(File):
"""
BASENAME = "ro-crate-preview.html"
- def __init__(self, crate, source=None):
- super().__init__(crate, source, self.BASENAME, None)
+ def __init__(self, crate, source=None, properties=None):
+ super().__init__(crate, source, self.BASENAME, properties=properties)
def _empty(self):
# default properties of the metadata entry
diff --git a/rocrate/rocrate.py b/rocrate/rocrate.py
index 8e3564e..af7a1cb 100644
--- a/rocrate/rocrate.py
+++ b/rocrate/rocrate.py
@@ -180,8 +180,9 @@ class ROCrate():
assert root_id == root_entity.pop('@id')
parts = root_entity.pop('hasPart', [])
self.add(RootDataset(self, properties=root_entity))
- if not gen_preview and Preview.BASENAME in entities:
- self.add(Preview(self, source / Preview.BASENAME))
+ preview_entity = entities.pop(Preview.BASENAME, None)
+ if preview_entity and not gen_preview:
+ self.add(Preview(self, source / Preview.BASENAME, properties=preview_entity))
type_map = OrderedDict((_.__name__, _) for _ in subclasses(FileOrDir))
for data_entity_ref in parts:
id_ = data_entity_ref['@id']
| Duplicate preview entry in output crate
```python
import shutil
from rocrate.rocrate import ROCrate
shutil.rmtree("/tmp/out_crate", ignore_errors=True)
crate = ROCrate("test/test-data/read_crate")
crate.write("/tmp/out_crate")
```
The output crate has:
```javascript
{
"@id": "ro-crate-preview.html",
"@type": "CreativeWork",
"about": {
"@id": "./"
}
},
```
but also:
```javascript
{
"@id": "#ro-crate-preview.html",
"@type": "CreativeWork",
"about": {
"@id": "./"
}
},
``` | ResearchObject/ro-crate-py | diff --git a/test/test_read.py b/test/test_read.py
index 8db4036..ac173f1 100644
--- a/test/test_read.py
+++ b/test/test_read.py
@@ -33,7 +33,6 @@ _URL = ('https://raw.githubusercontent.com/ResearchObject/ro-crate-py/master/'
@pytest.mark.parametrize("gen_preview,from_zip", [(False, False), (True, False), (True, True)])
def test_crate_dir_loading(test_data_dir, tmpdir, helpers, gen_preview, from_zip):
- # load crate
crate_dir = test_data_dir / 'read_crate'
if from_zip:
zip_source = shutil.make_archive(tmpdir / "read_crate.crate", "zip", crate_dir)
@@ -41,7 +40,21 @@ def test_crate_dir_loading(test_data_dir, tmpdir, helpers, gen_preview, from_zip
else:
crate = ROCrate(crate_dir, gen_preview=gen_preview)
- # check loaded entities and properties
+ assert set(_["@id"] for _ in crate.default_entities) == {
+ "./",
+ "ro-crate-metadata.json",
+ "ro-crate-preview.html"
+ }
+ assert set(_["@id"] for _ in crate.data_entities) == {
+ "test_galaxy_wf.ga",
+ "abstract_wf.cwl",
+ "test_file_galaxy.txt",
+ "https://raw.githubusercontent.com/ResearchObject/ro-crate-py/master/test/test-data/sample_file.txt",
+ "examples/",
+ "test/",
+ }
+ assert set(_["@id"] for _ in crate.contextual_entities) == {"#joe"}
+
root = crate.dereference('./')
assert crate.root_dataset is root
root_prop = root.properties()
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 0.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.7",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aiohttp==3.8.6
aiosignal==1.3.1
arcp==0.2.1
async-timeout==4.0.3
asynctest==0.13.0
attrs==24.2.0
bioblend==1.2.0
CacheControl==0.13.1
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
click==8.1.8
exceptiongroup==1.2.2
filelock==3.12.2
frozenlist==1.3.3
galaxy2cwl==0.1.4
gxformat2==0.20.0
idna==3.10
importlib-metadata==4.13.0
importlib-resources==5.12.0
iniconfig==2.0.0
isodate==0.6.1
Jinja2==3.1.6
MarkupSafe==2.1.5
mistune==2.0.5
msgpack==1.0.5
multidict==6.0.5
mypy-extensions==1.0.0
packaging==24.0
pluggy==1.2.0
pyparsing==3.1.4
pytest==7.4.4
python-dateutil==2.9.0.post0
PyYAML==6.0.1
rdflib==6.3.2
requests==2.31.0
requests-toolbelt==1.0.0
-e git+https://github.com/ResearchObject/ro-crate-py.git@7a5d25f3f4f8f4ca68f42cc582cf61378589bbe2#egg=rocrate
ruamel.yaml==0.17.40
ruamel.yaml.clib==0.2.8
schema-salad==8.4.20230808163024
six==1.17.0
tinydb==4.8.0
tomli==2.0.1
tuspy==1.1.0
typing_extensions==4.7.1
urllib3==2.0.7
yarl==1.9.4
zipp==3.15.0
| name: ro-crate-py
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=22.3.1=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- aiohttp==3.8.6
- aiosignal==1.3.1
- arcp==0.2.1
- async-timeout==4.0.3
- asynctest==0.13.0
- attrs==24.2.0
- bioblend==1.2.0
- cachecontrol==0.13.1
- charset-normalizer==3.4.1
- click==8.1.8
- exceptiongroup==1.2.2
- filelock==3.12.2
- frozenlist==1.3.3
- galaxy2cwl==0.1.4
- gxformat2==0.20.0
- idna==3.10
- importlib-metadata==4.13.0
- importlib-resources==5.12.0
- iniconfig==2.0.0
- isodate==0.6.1
- jinja2==3.1.6
- markupsafe==2.1.5
- mistune==2.0.5
- msgpack==1.0.5
- multidict==6.0.5
- mypy-extensions==1.0.0
- packaging==24.0
- pluggy==1.2.0
- pyparsing==3.1.4
- pytest==7.4.4
- python-dateutil==2.9.0.post0
- pyyaml==6.0.1
- rdflib==6.3.2
- requests==2.31.0
- requests-toolbelt==1.0.0
- ruamel-yaml==0.17.40
- ruamel-yaml-clib==0.2.8
- schema-salad==8.4.20230808163024
- six==1.17.0
- tinydb==4.8.0
- tomli==2.0.1
- tuspy==1.1.0
- typing-extensions==4.7.1
- urllib3==2.0.7
- yarl==1.9.4
- zipp==3.15.0
prefix: /opt/conda/envs/ro-crate-py
| [
"test/test_read.py::test_crate_dir_loading[False-False]",
"test/test_read.py::test_crate_dir_loading[True-False]",
"test/test_read.py::test_crate_dir_loading[True-True]"
] | [] | [
"test/test_read.py::test_legacy_crate",
"test/test_read.py::test_bad_crate",
"test/test_read.py::test_init[False]",
"test/test_read.py::test_init[True]",
"test/test_read.py::test_init_preview[False-False]",
"test/test_read.py::test_init_preview[False-True]",
"test/test_read.py::test_init_preview[True-False]",
"test/test_read.py::test_init_preview[True-True]",
"test/test_read.py::test_no_parts",
"test/test_read.py::test_extra_data[False]",
"test/test_read.py::test_extra_data[True]",
"test/test_read.py::test_missing_dir",
"test/test_read.py::test_missing_file",
"test/test_read.py::test_generic_data_entity"
] | [] | Apache License 2.0 | 11,648 | 394 | [
"rocrate/model/preview.py",
"rocrate/rocrate.py"
] |
|
asottile__add-trailing-comma-154 | d370e91067c0ee7f4a87b86e4f8f2c483fd59c21 | 2021-11-20 17:56:59 | 4850deff3e74a0e7d0384c30ecea72a3fa594c4b | diff --git a/add_trailing_comma/_plugins/literals.py b/add_trailing_comma/_plugins/literals.py
index c5771be..53bdcf6 100644
--- a/add_trailing_comma/_plugins/literals.py
+++ b/add_trailing_comma/_plugins/literals.py
@@ -26,12 +26,11 @@ def _fix_literal(
*,
one_el_tuple: bool,
) -> None:
- if tokens[i].src in START_BRACES: # pragma: no branch (<py38)
- fix_brace(
- tokens, find_simple(i, tokens),
- add_comma=True,
- remove_comma=not one_el_tuple,
- )
+ fix_brace(
+ tokens, find_simple(i, tokens),
+ add_comma=True,
+ remove_comma=not one_el_tuple,
+ )
@register(ast.Set)
@@ -90,6 +89,27 @@ def _fix_tuple(
)
+def _fix_tuple_py38(
+ i: int,
+ tokens: List[Token],
+ *,
+ one_el_tuple: bool,
+) -> None: # pragma: no cover (<py38)
+ if tokens[i].src in START_BRACES:
+ fix = find_simple(i, tokens)
+
+ # for tuples we *must* find a comma, otherwise it is not a tuple
+ if fix is None or not fix.multi_arg:
+ return
+
+ fix_brace(
+ tokens,
+ fix,
+ add_comma=True,
+ remove_comma=not one_el_tuple,
+ )
+
+
@register(ast.Tuple)
def visit_Tuple(
state: State,
@@ -105,5 +125,5 @@ def visit_Tuple(
func = functools.partial(_fix_tuple, one_el_tuple=is_one_el)
yield ast_to_offset(node), func
else: # pragma: no cover (py38+)
- func = functools.partial(_fix_literal, one_el_tuple=is_one_el)
+ func = functools.partial(_fix_tuple_py38, one_el_tuple=is_one_el)
yield ast_to_offset(node), func
| Tool may change variables from type `T` to `tuple[T]`
Hey, I found this while using this as a pre-commit hook (big fan of the the project & your tools btw! :)).
It seems the tool may change turn a type into a tuple[type] in a situation like this;
```py
x = (
object # < comma is added here
), object
``` | asottile/add-trailing-comma | diff --git a/tests/features/literals_test.py b/tests/features/literals_test.py
index 74f543e..f5dda44 100644
--- a/tests/features/literals_test.py
+++ b/tests/features/literals_test.py
@@ -15,6 +15,12 @@ from add_trailing_comma._main import _fix_src
' pass\n'
'[x] = {y}',
pytest.param('x[1, 2, 3, 4]', id='multi-slice'),
+ pytest.param(
+ 'x = (\n'
+ ' object\n'
+ '), object\n',
+ id='regression test for #153',
+ ),
),
)
def test_noop_literals(src):
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 2.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/asottile/add-trailing-comma.git@d370e91067c0ee7f4a87b86e4f8f2c483fd59c21#egg=add_trailing_comma
covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
tokenize_rt==6.1.0
tomli==2.2.1
| name: add-trailing-comma
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tokenize-rt==6.1.0
- tomli==2.2.1
prefix: /opt/conda/envs/add-trailing-comma
| [
"tests/features/literals_test.py::test_noop_literals[regression"
] | [] | [
"tests/features/literals_test.py::test_noop_literals[(1,",
"tests/features/literals_test.py::test_noop_literals[[1,",
"tests/features/literals_test.py::test_noop_literals[{1,",
"tests/features/literals_test.py::test_noop_literals[{1:",
"tests/features/literals_test.py::test_noop_literals[if",
"tests/features/literals_test.py::test_noop_literals[multi-slice]",
"tests/features/literals_test.py::test_fixes_literals[x",
"tests/features/literals_test.py::test_fixes_literals[(\\n",
"tests/features/literals_test.py::test_fixes_literals[multi-line",
"tests/features/literals_test.py::test_fixes_literals[single",
"tests/features/literals_test.py::test_fixes_literals[nested",
"tests/features/literals_test.py::test_fixes_py35_plus_literals[x",
"tests/features/literals_test.py::test_noop_tuple_literal_without_braces"
] | [] | MIT License | 11,656 | 497 | [
"add_trailing_comma/_plugins/literals.py"
] |
|
eWaterCycle__era5cli-102 | ad5508a481add3116da9b7f95aad6eafe7cc0b4b | 2021-11-22 20:35:48 | ad5508a481add3116da9b7f95aad6eafe7cc0b4b | codecov[bot]: # [Codecov](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle) Report
> Merging [#102](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle) (088348f) into [master](https://codecov.io/gh/eWaterCycle/era5cli/commit/2240bc1e2d78a8a4e6a375daa89d8acc6609348e?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle) (2240bc1) will **increase** coverage by `0.62%`.
> The diff coverage is `97.72%`.
[](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle)
```diff
@@ Coverage Diff @@
## master #102 +/- ##
==========================================
+ Coverage 98.32% 98.94% +0.62%
==========================================
Files 7 7
Lines 358 380 +22
==========================================
+ Hits 352 376 +24
+ Misses 6 4 -2
```
| [Impacted Files](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle) | Coverage Δ | |
|---|---|---|
| [era5cli/cli.py](https://codecov.io/gh/eWaterCycle/era5cli/pull/102/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle#diff-ZXJhNWNsaS9jbGkucHk=) | `98.03% <87.50%> (+1.16%)` | :arrow_up: |
| [era5cli/\_\_version\_\_.py](https://codecov.io/gh/eWaterCycle/era5cli/pull/102/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle#diff-ZXJhNWNsaS9fX3ZlcnNpb25fXy5weQ==) | `100.00% <100.00%> (ø)` | |
| [era5cli/fetch.py](https://codecov.io/gh/eWaterCycle/era5cli/pull/102/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle#diff-ZXJhNWNsaS9mZXRjaC5weQ==) | `99.45% <100.00%> (+0.65%)` | :arrow_up: |
| [era5cli/inputref.py](https://codecov.io/gh/eWaterCycle/era5cli/pull/102/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle#diff-ZXJhNWNsaS9pbnB1dHJlZi5weQ==) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle). Last update [ad5508a...088348f](https://codecov.io/gh/eWaterCycle/era5cli/pull/102?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=eWaterCycle).
bvreede: Some notes:
- I think the way calls and results are now mapped to the test can be improved, but I don't quite know how. One issue is that they need to be explicitly added to the `call_result` tuple, which may be forgotten and then not throw an error. A lesser point would be that moving around tests is not possible without renaming. (e.g. call1 and call3 should follow each other, but in order to do that, call2 and call3 need to be renamed as well as moved...)
- codecov fails because that one line extra in `main()` >.<
bvreede: Thanks to @sverhoeven and @SarahAlidoost! :)
bvreede: Great suggestion, @sverhoeven, especially since it unveiled a missing warning message in the test!
| diff --git a/era5cli/cli.py b/era5cli/cli.py
index fadea62..f7cb0d7 100644
--- a/era5cli/cli.py
+++ b/era5cli/cli.py
@@ -425,10 +425,12 @@ def _execute(args):
return True
-def main():
+def main(argv=None):
"""Main."""
# get arguments
- args = _parse_args(sys.argv[1:])
+ if argv is None:
+ argv = sys.argv
+ args = _parse_args(argv[1:])
_execute(args)
| Add integration tests
At the moment, we test era5cli in two ways:
- Test if arguments given on the command line are parsed correctly and entered correctly to the Fetch class (`test_cli.py`)
- Test if information given to the Fetch class result in a correct CDS query (`test_fetch.py`).
It would be good to also add integration tests that combine these two, where arguments are given and the final query is asserted. This would make it easier to write tests for the tool to assert correct behavior of the tool as a whole. | eWaterCycle/era5cli | diff --git a/tests/test_cli.py b/tests/test_cli.py
index 6390f32..1184ed1 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -1,4 +1,4 @@
-"""Tests for era5cli utility functios."""
+"""Tests for era5cli utility functions."""
import unittest.mock as mock
import pytest
diff --git a/tests/test_integration.py b/tests/test_integration.py
new file mode 100644
index 0000000..1055dbc
--- /dev/null
+++ b/tests/test_integration.py
@@ -0,0 +1,128 @@
+"""Tests to check the full era5cli workflow."""
+
+import logging
+import pytest
+
+from textwrap import dedent
+
+from era5cli.cli import main
+
+
+# combine calls with result and possible warning message
+call_result = [
+ {
+ # orography is translated to geopotential in the query
+ "call": dedent("""\
+ era5cli hourly --variables orography --startyear 2008 --dryrun
+ """),
+ "result": dedent("""\
+ reanalysis-era5-single-levels {'variable': 'geopotential', 'year':
+ 2008, 'month': ['01', '02', '03', '04', '05', '06', '07', '08',
+ '09', '10', '11', '12'], 'time': ['00:00', '01:00', '02:00',
+ '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00',
+ '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00',
+ '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
+ 'format': 'netcdf', 'product_type': 'reanalysis', 'day': ['01',
+ '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12',
+ '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23',
+ '24', '25', '26', '27', '28', '29', '30', '31']}
+ era5_orography_2008_hourly.nc"""),
+ "warn": "The variable 'orography' has been deprecated by CDS."
+ },
+ {
+ # geopotential needs '--levels surface' to be correctly interpreted
+ "call": dedent("""\
+ era5cli hourly --variables geopotential --startyear 2008 --dryrun
+ --levels surface"""),
+ "result": dedent("""\
+ reanalysis-era5-single-levels {'variable': 'geopotential', 'year':
+ 2008, 'month': ['01', '02', '03', '04', '05', '06', '07', '08',
+ '09', '10', '11', '12'], 'time': ['00:00', '01:00', '02:00',
+ '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00',
+ '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00',
+ '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
+ 'format': 'netcdf', 'product_type': 'reanalysis', 'day': ['01',
+ '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12',
+ '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23',
+ '24', '25', '26', '27', '28', '29', '30', '31']}
+ era5_geopotential_2008_hourly.nc"""),
+ "warn": "Getting variable from surface level data."
+ },
+ {
+ # without --levels surface, geopotential calls pressure level data
+ "call": dedent("""\
+ era5cli hourly --variables geopotential --startyear 2008
+ --dryrun"""),
+ "result": dedent("""\
+ reanalysis-era5-pressure-levels {'variable': 'geopotential',
+ 'year': 2008, 'month': ['01', '02', '03', '04', '05', '06', '07',
+ '08', '09', '10', '11', '12'], 'time': ['00:00', '01:00', '02:00',
+ '03:00', '04:00', '05:00', '06:00', '07:00', '08:00', '09:00',
+ '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00',
+ '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00'],
+ 'format': 'netcdf', 'pressure_level': [1, 2, 3, 5, 7, 10, 20, 30,
+ 50, 70, 100, 125, 150, 175, 200, 225, 250, 300, 350, 400, 450, 500,
+ 550, 600, 650, 700, 750, 775, 800, 825, 850, 875, 900, 925, 950,
+ 975, 1000], 'product_type': 'reanalysis', 'day': ['01', '02', '03',
+ '04', '05', '06', '07', '08', '09', '10', '11', '12', '13', '14',
+ '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25',
+ '26', '27', '28', '29', '30', '31']}
+ era5_geopotential_2008_hourly.nc"""),
+ "warn": "Getting variable from pressure level data."
+ },
+ {
+ # preliminary-back-extension is combined with monthly-means
+ "call": dedent("""\
+ era5cli monthly --variables temperature --startyear 1960 --prelimbe
+ --dryrun"""),
+ "result": dedent("""\
+ reanalysis-era5-pressure-levels-monthly-means-preliminary-back-extension
+ {'variable': 'temperature', 'year': 1960, 'month': ['01', '02',
+ '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'],
+ 'time': ['00:00'], 'format': 'netcdf', 'pressure_level': [1, 2, 3,
+ 5, 7, 10, 20, 30, 50, 70, 100, 125, 150, 175, 200, 225, 250, 300,
+ 350, 400, 450, 500, 550, 600, 650, 700, 750, 775, 800, 825, 850,
+ 875, 900, 925, 950, 975, 1000], 'product_type':
+ 'reanalysis-monthly-means-of-daily-means'}
+ era5_temperature_1960_monthly.nc""")
+ },
+ {
+ # era5-Land is combined with monthly means
+ "call": dedent("""\
+ era5cli monthly --variables snow_cover --startyear 2008 --land
+ --dryrun"""),
+ "result": dedent("""\
+ reanalysis-era5-land-monthly-means {'variable': 'snow_cover',
+ 'year': 2008, 'month': ['01', '02', '03', '04', '05', '06', '07',
+ '08', '09', '10', '11', '12'], 'time': ['00:00'], 'format':
+ 'netcdf', 'product_type': 'monthly_averaged_reanalysis'}
+ era5-land_snow_cover_2008_monthly.nc""")
+ }
+]
+
+
+def clean_ids(call):
+ call = call.replace('\n', ' ')
+ call = call.replace('--dryrun', '')
+ return(call)
+
+
+ids = [clean_ids(item["call"]) for item in call_result]
+
+
[email protected]("call_result", call_result, ids=ids)
+def test_main(call_result, capsys, caplog):
+ call = call_result["call"].split()
+ result = call_result["result"].replace('\n', ' ') + '\n'
+ # until the actual fetch is monkeypatched, make sure the tests are dryruns
+ if '--dryrun' not in call:
+ pytest.fail('call must be a dryrun')
+ with caplog.at_level(logging.INFO):
+ main(call)
+ captured = capsys.readouterr().out
+ assert result == captured
+ try:
+ warn = call_result["warn"]
+ assert warn in caplog.text
+ except KeyError:
+ assert caplog.text == ''
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 1
},
"num_modified_files": 1
} | 1.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | cdsapi==0.4.0
certifi==2025.1.31
cftime==1.6.4.post1
charset-normalizer==3.4.1
dill==0.3.9
-e git+https://github.com/eWaterCycle/era5cli.git@ad5508a481add3116da9b7f95aad6eafe7cc0b4b#egg=era5cli
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
multiprocess==0.70.17
netCDF4==1.7.2
numpy==2.0.2
packaging==24.2
pathos==0.3.3
pluggy==1.5.0
pox==0.3.5
ppft==1.7.6.9
PTable==0.9.2
pytest==8.3.5
requests==2.32.3
tomli==2.2.1
tqdm==4.67.1
urllib3==2.3.0
| name: era5cli
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- cdsapi==0.4.0
- certifi==2025.1.31
- cftime==1.6.4.post1
- charset-normalizer==3.4.1
- dill==0.3.9
- era5cli==1.2.1
- exceptiongroup==1.2.2
- idna==3.10
- iniconfig==2.1.0
- multiprocess==0.70.17
- netcdf4==1.7.2
- numpy==2.0.2
- packaging==24.2
- pathos==0.3.3
- pluggy==1.5.0
- pox==0.3.5
- ppft==1.7.6.9
- ptable==0.9.2
- pytest==8.3.5
- requests==2.32.3
- tomli==2.2.1
- tqdm==4.67.1
- urllib3==2.3.0
prefix: /opt/conda/envs/era5cli
| [
"tests/test_integration.py::test_main[era5cli"
] | [] | [
"tests/test_cli.py::test_parse_args",
"tests/test_cli.py::test_area_argument",
"tests/test_cli.py::test_period_args",
"tests/test_cli.py::test_level_arguments",
"tests/test_cli.py::test_main_fetch",
"tests/test_cli.py::test_main_info"
] | [] | Apache License 2.0 | 11,666 | 143 | [
"era5cli/cli.py"
] |
python-pillow__Pillow-5848 | ae7c2cb2e6a1d5bf3050cc0076d6155e56342c3c | 2021-11-22 21:29:16 | 282d8250c6f8469f5c1127d6e918fb3960b59da3 | diff --git a/src/PIL/TiffImagePlugin.py b/src/PIL/TiffImagePlugin.py
index a6a842b1d..5df5c4f4c 100644
--- a/src/PIL/TiffImagePlugin.py
+++ b/src/PIL/TiffImagePlugin.py
@@ -1676,8 +1676,6 @@ def _save(im, fp, filename):
# optional types for non core tags
types = {}
- # SAMPLEFORMAT is determined by the image format and should not be copied
- # from legacy_ifd.
# STRIPOFFSETS and STRIPBYTECOUNTS are added by the library
# based on the data in the strip.
# The other tags expect arrays with a certain length (fixed or depending on
@@ -1686,7 +1684,6 @@ def _save(im, fp, filename):
# SUBIFD may also cause a segfault.
blocklist += [
REFERENCEBLACKWHITE,
- SAMPLEFORMAT,
STRIPBYTECOUNTS,
STRIPOFFSETS,
TRANSFERFUNCTION,
@@ -1702,9 +1699,14 @@ def _save(im, fp, filename):
legacy_ifd = {}
if hasattr(im, "tag"):
legacy_ifd = im.tag.to_v2()
- for tag, value in itertools.chain(
- ifd.items(), getattr(im, "tag_v2", {}).items(), legacy_ifd.items()
- ):
+
+ # SAMPLEFORMAT is determined by the image format and should not be copied
+ # from legacy_ifd.
+ supplied_tags = {**getattr(im, "tag_v2", {}), **legacy_ifd}
+ if SAMPLEFORMAT in supplied_tags:
+ del supplied_tags[SAMPLEFORMAT]
+
+ for tag, value in itertools.chain(ifd.items(), supplied_tags.items()):
# Libtiff can only process certain core items without adding
# them to the custom dictionary.
# Custom items are supported for int, float, unicode, string and byte
@@ -1729,6 +1731,9 @@ def _save(im, fp, filename):
else:
atts[tag] = value
+ if SAMPLEFORMAT in atts and len(atts[SAMPLEFORMAT]) == 1:
+ atts[SAMPLEFORMAT] = atts[SAMPLEFORMAT][0]
+
logger.debug("Converted items: %s" % sorted(atts.items()))
# libtiff always expects the bytes in native order.
| Incorrect image data and type after TIFF compression
When saving an image containing float data as a compressed TIFF the output image data and number type is incorrect (here the `float32` becomes `int32`). The output is correct if I specify `compression = None` or if the input image data is of e.g. type `uint8`. If I specify `compression = "something wrong"` I get no error message, the compression defaults to `"compression": "raw"`, but the output image data and type is still wrong.
```python
import numpy as np
from PIL import Image
from tempfile import TemporaryFile
with TemporaryFile() as fp:
Z = np.array([[np.pi, np.pi], [np.pi, np.pi]], dtype = np.float32)
img = Image.fromarray(Z)
img.save(fp, format = "TIFF", compression = "packbits")
img = Image.open(fp)
print(img.info) # {'compression': 'packbits', 'dpi': (1, 1), 'resolution': (1, 1)}
Z = np.asarray(img)
print(Z) # [[1078530011, 1078530011], [1078530011, 1078530011]]
print(Z.dtype) # int32
``` | python-pillow/Pillow | diff --git a/Tests/test_file_libtiff.py b/Tests/test_file_libtiff.py
index d9fa1e4b4..e40a19394 100644
--- a/Tests/test_file_libtiff.py
+++ b/Tests/test_file_libtiff.py
@@ -9,7 +9,7 @@ from ctypes import c_float
import pytest
from PIL import Image, ImageFilter, TiffImagePlugin, TiffTags, features
-from PIL.TiffImagePlugin import STRIPOFFSETS, SUBIFD
+from PIL.TiffImagePlugin import SAMPLEFORMAT, STRIPOFFSETS, SUBIFD
from .helper import (
assert_image_equal,
@@ -825,6 +825,17 @@ class TestFileLibTiff(LibTiffTestCase):
assert_image_equal_tofile(im, "Tests/images/copyleft.png", mode="RGB")
+ def test_sampleformat_write(self, tmp_path):
+ im = Image.new("F", (1, 1))
+ out = str(tmp_path / "temp.tif")
+ TiffImagePlugin.WRITE_LIBTIFF = True
+ im.save(out)
+ TiffImagePlugin.WRITE_LIBTIFF = False
+
+ with Image.open(out) as reloaded:
+ assert reloaded.mode == "F"
+ assert reloaded.getexif()[SAMPLEFORMAT] == 3
+
def test_lzw(self):
with Image.open("Tests/images/hopper_lzw.tif") as im:
assert im.mode == "RGB"
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 1
} | 8.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-timeout",
"pytest-reverse"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc libtiff-dev libjpeg-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
babel==2.17.0
black==25.1.0
build==1.2.2.post1
certifi==2025.1.31
charset-normalizer==3.4.1
check-manifest==0.50
click==8.1.8
coverage==7.8.0
defusedxml==0.7.1
docutils==0.21.2
exceptiongroup==1.2.2
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
markdown2==2.5.3
MarkupSafe==3.0.2
mypy-extensions==1.0.0
olefile==0.47
packaging==24.2
pathspec==0.12.1
-e git+https://github.com/python-pillow/Pillow.git@ae7c2cb2e6a1d5bf3050cc0076d6155e56342c3c#egg=Pillow
platformdirs==4.3.7
pluggy==1.5.0
Pygments==2.19.1
pyproject_hooks==1.2.0
pyroma==4.2
pytest==8.3.5
pytest-cov==6.0.0
pytest-reverse==1.8.0
pytest-timeout==2.3.1
requests==2.32.3
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-copybutton==0.5.2
sphinx-issues==5.0.0
sphinx-removed-in==0.2.3
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
sphinxext-opengraph==0.9.1
tomli==2.2.1
trove-classifiers==2025.3.19.19
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0
| name: Pillow
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- black==25.1.0
- build==1.2.2.post1
- certifi==2025.1.31
- charset-normalizer==3.4.1
- check-manifest==0.50
- click==8.1.8
- coverage==7.8.0
- defusedxml==0.7.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markdown2==2.5.3
- markupsafe==3.0.2
- mypy-extensions==1.0.0
- olefile==0.47
- packaging==24.2
- pathspec==0.12.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pygments==2.19.1
- pyproject-hooks==1.2.0
- pyroma==4.2
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-reverse==1.8.0
- pytest-timeout==2.3.1
- requests==2.32.3
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinx-copybutton==0.5.2
- sphinx-issues==5.0.0
- sphinx-removed-in==0.2.3
- sphinx-rtd-theme==3.0.2
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jquery==4.1
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- sphinxext-opengraph==0.9.1
- tomli==2.2.1
- trove-classifiers==2025.3.19.19
- typing-extensions==4.13.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/Pillow
| [
"Tests/test_file_libtiff.py::TestFileLibTiff::test_sampleformat_write"
] | [
"Tests/test_file_libtiff.py::TestFileLibTiff::test_custom_metadata"
] | [
"Tests/test_file_libtiff.py::TestFileLibTiff::test_version",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_large",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_tiff_file",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_tiff_bytesio",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_non_disk_file_object",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_eq_png",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_fillorder_eq_png",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_write",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_adobe_deflate_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_write_metadata",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_additional_metadata",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_subifd",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_xmlpacket_tag",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_int_dpi",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g3_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_little_endian",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_big_endian",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_g4_string_info",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_12bit_rawmode",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_blur",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_compressions",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiff_jpeg_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiff_deflate_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_quality",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_cmyk_save",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_palette_save",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_fp_leak",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage_nframes",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage_seek_backwards",
"Tests/test_file_libtiff.py::TestFileLibTiff::test__next",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_4bit",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_gray_semibyte_per_pixel",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_bytesio",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_ycbcr",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_crashing_metadata",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_page_number_x_0",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_fd_duplication",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_read_icc",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_write_icc",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_multipage_compression",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_tiff_with_jpegtables",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_16bit_RGB_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_16bit_RGBa_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_gimp_tiff",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_sampleformat",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_lzw",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_cmyk_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_cmyk_16l_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_ycbcr_jpeg_2x2_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_ycbcr_jpeg_1x1_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_cmyk_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_ycbcr_jpeg_1x1_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_ycbcr_jpeg_2x2_sampling",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_planar_rgb",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_planar_rgb",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_planar_16bit_RGB",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_planar_16bit_RGB",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_tiled_planar_16bit_RGBa",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_strip_planar_16bit_RGBa",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_block_tile_tags[None]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_block_tile_tags[jpeg]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_old_style_jpeg",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_open_missing_samplesperpixel",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_no_rows_per_strip",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_orientation",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_sampleformat_not_corrupted",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_realloc_overflow",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_multistrip[tiff_adobe_deflate]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_multistrip[jpeg]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_single_strip",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_zero[tiff_adobe_deflate]",
"Tests/test_file_libtiff.py::TestFileLibTiff::test_save_zero[None]"
] | [] | MIT-CMU License | 11,668 | 566 | [
"src/PIL/TiffImagePlugin.py"
] |
|
qiboteam__qibo-521 | 0ac5791e24be0609d15665ab40461d540edc1f05 | 2021-11-24 14:33:52 | 0209995beed0a681c0e0551ea7dc60e521116418 | diff --git a/src/qibo/abstractions/states.py b/src/qibo/abstractions/states.py
index 247004bfb..def03cd8a 100644
--- a/src/qibo/abstractions/states.py
+++ b/src/qibo/abstractions/states.py
@@ -68,6 +68,28 @@ class AbstractState(ABC):
"".format(len(x), self.nqubits))
self._tensor = x
+ @abstractmethod
+ def symbolic(self, decimals=5, cutoff=1e-10, max_terms=20): # pragma: no cover
+ """Dirac notation representation of the state in the computational basis.
+
+ Args:
+ decimals (int): Number of decimals for the amplitudes.
+ Default is 5.
+ cutoff (float): Amplitudes with absolute value smaller than the
+ cutoff are ignored from the representation.
+ Default is 1e-10.
+ max_terms (int): Maximum number of terms to print. If the state
+ contains more terms they will be ignored.
+ Default is 20.
+
+ Returns:
+ A string representing the state in the computational basis.
+ """
+ raise_error(NotImplementedError)
+
+ def __repr__(self):
+ return self.symbolic()
+
@abstractmethod
def __array__(self): # pragma: no cover
"""State's tensor representation as an array."""
@@ -78,14 +100,31 @@ class AbstractState(ABC):
"""State's tensor representation as a numpy array."""
raise_error(NotImplementedError)
- def state(self, numpy=False):
+ def state(self, numpy=False, decimals=-1, cutoff=1e-10, max_terms=20):
"""State's tensor representation as an backend tensor.
Args:
numpy (bool): If ``True`` the returned tensor will be a numpy array,
otherwise it will follow the backend tensor type.
Default is ``False``.
+ decimals (int): If positive the Diract representation of the state
+ in the computational basis will be returned as a string.
+ ``decimals`` will be the number of decimals of each amplitude.
+ Default is -1.
+ cutoff (float): Amplitudes with absolute value smaller than the
+ cutoff are ignored from the Dirac representation.
+ Ignored if ``decimals < 0``. Default is 1e-10.
+ max_terms (int): Maximum number of terms in the Dirac representation.
+ If the state contains more terms they will be ignored.
+ Ignored if ``decimals < 0``. Default is 20.
+
+ Returns:
+ If ``decimals < 0`` a tensor representing the state in the computational
+ basis, otherwise a string with the Dirac representation of the state
+ in the computational basis.
"""
+ if decimals >= 0:
+ return self.symbolic(decimals, cutoff, max_terms)
if numpy:
return self.numpy()
return self.tensor
diff --git a/src/qibo/core/states.py b/src/qibo/core/states.py
index a055f4e99..97f9c8981 100644
--- a/src/qibo/core/states.py
+++ b/src/qibo/core/states.py
@@ -38,6 +38,19 @@ class VectorState(AbstractState):
def numpy(self):
return self.__array__()
+ def symbolic(self, decimals=5, cutoff=1e-10, max_terms=20):
+ state = self.numpy()
+ terms = []
+ for i in K.np.nonzero(state)[0]:
+ b = bin(i)[2:].zfill(self.nqubits)
+ if K.np.abs(state[i]) >= cutoff:
+ x = round(state[i], decimals)
+ terms.append(f"{x}|{b}>")
+ if len(terms) >= max_terms:
+ terms.append("...")
+ break
+ return " + ".join(terms)
+
@classmethod
def zero_state(cls, nqubits):
state = cls(nqubits)
@@ -132,6 +145,21 @@ class VectorState(AbstractState):
class MatrixState(VectorState):
+ def symbolic(self, decimals=5, cutoff=1e-10, max_terms=20):
+ state = self.numpy()
+ terms = []
+ indi, indj = K.np.nonzero(state)
+ for i, j in zip(indi, indj):
+ bi = bin(i)[2:].zfill(self.nqubits)
+ bj = bin(j)[2:].zfill(self.nqubits)
+ if K.np.abs(state[i, j]) >= cutoff:
+ x = round(state[i, j], decimals)
+ terms.append(f"{x}|{bi}><{bj}|")
+ if len(terms) >= max_terms:
+ terms.append("...")
+ break
+ return " + ".join(terms)
+
@property
def shape(self):
return (self.nstates, self.nstates)
| State in computational basis
We should provide a state option to print results in the computational basis. | qiboteam/qibo | diff --git a/src/qibo/tests/test_core_states.py b/src/qibo/tests/test_core_states.py
index af7279bb9..4037369d7 100644
--- a/src/qibo/tests/test_core_states.py
+++ b/src/qibo/tests/test_core_states.py
@@ -68,6 +68,49 @@ def test_vector_state_to_density_matrix(backend):
state.to_density_matrix()
[email protected]("target", range(5))
[email protected]("density_matrix", [False, True])
+def test_state_representation(target, density_matrix):
+ from qibo import models, gates
+ c = models.Circuit(5, density_matrix=density_matrix)
+ c.add(gates.H(target))
+ result = c()
+ bstring = target * "0" + "1" + (4 - target) * "0"
+ if density_matrix:
+ target_str = 3 * [f"(0.5+0j)|00000><00000| + (0.5+0j)|00000><{bstring}| + (0.5+0j)|{bstring}><00000| + (0.5+0j)|{bstring}><{bstring}|"]
+ else:
+ target_str = [f"(0.70711+0j)|00000> + (0.70711+0j)|{bstring}>",
+ f"(0.7+0j)|00000> + (0.7+0j)|{bstring}>",
+ f"(0.71+0j)|00000> + (0.71+0j)|{bstring}>"]
+ assert str(result) == target_str[0]
+ assert result.state(decimals=5) == target_str[0]
+ assert result.symbolic(decimals=1) == target_str[1]
+ assert result.symbolic(decimals=2) == target_str[2]
+
+
[email protected]("density_matrix", [False, True])
+def test_state_representation_max_terms(density_matrix):
+ from qibo import models, gates
+ c = models.Circuit(5, density_matrix=density_matrix)
+ c.add(gates.H(i) for i in range(5))
+ result = c()
+ if density_matrix:
+ assert result.symbolic(max_terms=3) == "(0.03125+0j)|00000><00000| + (0.03125+0j)|00000><00001| + (0.03125+0j)|00000><00010| + ..."
+ assert result.symbolic(max_terms=5) == "(0.03125+0j)|00000><00000| + (0.03125+0j)|00000><00001| + (0.03125+0j)|00000><00010| + (0.03125+0j)|00000><00011| + (0.03125+0j)|00000><00100| + ..."
+ else:
+ assert result.symbolic(max_terms=3) == "(0.17678+0j)|00000> + (0.17678+0j)|00001> + (0.17678+0j)|00010> + ..."
+ assert result.symbolic(max_terms=5) == "(0.17678+0j)|00000> + (0.17678+0j)|00001> + (0.17678+0j)|00010> + (0.17678+0j)|00011> + (0.17678+0j)|00100> + ..."
+
+
+def test_state_representation_cutoff():
+ from qibo import models, gates
+ c = models.Circuit(2)
+ c.add(gates.RX(0, theta=0.1))
+ result = c()
+ assert result.state(decimals=5) == "(0.99875+0j)|00> + -0.04998j|10>"
+ assert result.state(decimals=5, cutoff=0.1) == "(0.99875+0j)|00>"
+
+
@pytest.mark.parametrize("state_type", ["VectorState", "MatrixState"])
@pytest.mark.parametrize("use_gate", [False, True])
def test_state_probabilities(backend, state_type, use_gate):
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 1
},
"num_modified_files": 2
} | 0.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.7",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi @ file:///croot/certifi_1671487769961/work/certifi
cma==4.0.0
cycler==0.11.0
exceptiongroup==1.2.2
fonttools==4.38.0
importlib-metadata==6.7.0
iniconfig==2.0.0
joblib==1.3.2
kiwisolver==1.4.5
matplotlib==3.5.3
mpmath==1.3.0
numpy==1.21.6
packaging==24.0
Pillow==9.5.0
pluggy==1.2.0
psutil==7.0.0
pyparsing==3.1.4
pytest==7.4.4
python-dateutil==2.9.0.post0
PyYAML==6.0.1
-e git+https://github.com/qiboteam/qibo.git@0ac5791e24be0609d15665ab40461d540edc1f05#egg=qibo
scipy==1.7.3
six==1.17.0
sympy==1.10.1
tomli==2.0.1
typing_extensions==4.7.1
zipp==3.15.0
| name: qibo
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=22.3.1=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- cma==4.0.0
- cycler==0.11.0
- exceptiongroup==1.2.2
- fonttools==4.38.0
- importlib-metadata==6.7.0
- iniconfig==2.0.0
- joblib==1.3.2
- kiwisolver==1.4.5
- matplotlib==3.5.3
- mpmath==1.3.0
- numpy==1.21.6
- packaging==24.0
- pillow==9.5.0
- pluggy==1.2.0
- psutil==7.0.0
- pyparsing==3.1.4
- pytest==7.4.4
- python-dateutil==2.9.0.post0
- pyyaml==6.0.1
- scipy==1.7.3
- six==1.17.0
- sympy==1.10.1
- tomli==2.0.1
- typing-extensions==4.7.1
- zipp==3.15.0
prefix: /opt/conda/envs/qibo
| [
"src/qibo/tests/test_core_states.py::test_state_representation[False-0]",
"src/qibo/tests/test_core_states.py::test_state_representation[False-1]",
"src/qibo/tests/test_core_states.py::test_state_representation[False-2]",
"src/qibo/tests/test_core_states.py::test_state_representation[False-3]",
"src/qibo/tests/test_core_states.py::test_state_representation[False-4]",
"src/qibo/tests/test_core_states.py::test_state_representation[True-0]",
"src/qibo/tests/test_core_states.py::test_state_representation[True-1]",
"src/qibo/tests/test_core_states.py::test_state_representation[True-2]",
"src/qibo/tests/test_core_states.py::test_state_representation[True-3]",
"src/qibo/tests/test_core_states.py::test_state_representation[True-4]",
"src/qibo/tests/test_core_states.py::test_state_representation_max_terms[False]",
"src/qibo/tests/test_core_states.py::test_state_representation_max_terms[True]",
"src/qibo/tests/test_core_states.py::test_state_representation_cutoff"
] | [] | [
"src/qibo/tests/test_core_states.py::test_state_shape_and_dtype[numpy]",
"src/qibo/tests/test_core_states.py::test_vector_state_tensor_setter[numpy-None]",
"src/qibo/tests/test_core_states.py::test_vector_state_tensor_setter[numpy-2]",
"src/qibo/tests/test_core_states.py::test_matrix_state_tensor_setter[numpy-None]",
"src/qibo/tests/test_core_states.py::test_matrix_state_tensor_setter[numpy-2]",
"src/qibo/tests/test_core_states.py::test_zero_state_initialization[numpy]",
"src/qibo/tests/test_core_states.py::test_plus_state_initialization[numpy]",
"src/qibo/tests/test_core_states.py::test_vector_state_to_density_matrix[numpy]",
"src/qibo/tests/test_core_states.py::test_state_probabilities[numpy-False-VectorState]",
"src/qibo/tests/test_core_states.py::test_state_probabilities[numpy-False-MatrixState]",
"src/qibo/tests/test_core_states.py::test_state_probabilities[numpy-True-VectorState]",
"src/qibo/tests/test_core_states.py::test_state_probabilities[numpy-True-MatrixState]",
"src/qibo/tests/test_core_states.py::test_state_probabilities_errors",
"src/qibo/tests/test_core_states.py::test_state_measure[None]",
"src/qibo/tests/test_core_states.py::test_state_measure[registers1]",
"src/qibo/tests/test_core_states.py::test_state_set_measurements[None]",
"src/qibo/tests/test_core_states.py::test_state_set_measurements[registers1]",
"src/qibo/tests/test_core_states.py::test_state_apply_bitflips",
"src/qibo/tests/test_core_states.py::test_vector_state_expectation[numpy-True]",
"src/qibo/tests/test_core_states.py::test_vector_state_expectation[numpy-False]",
"src/qibo/tests/test_core_states.py::test_matrix_state_expectation[numpy-True]",
"src/qibo/tests/test_core_states.py::test_matrix_state_expectation[numpy-False]"
] | [] | Apache License 2.0 | 11,674 | 1,169 | [
"src/qibo/abstractions/states.py",
"src/qibo/core/states.py"
] |
|
encode__uvicorn-1267 | 81802ceee2a2c62f0b10f78e2b6366b47bc76f72 | 2021-11-24 15:47:36 | ecd2cc721851788c463b7e4e8b1772193a762439 | diff --git a/uvicorn/config.py b/uvicorn/config.py
index 683a830..59c94b4 100644
--- a/uvicorn/config.py
+++ b/uvicorn/config.py
@@ -180,7 +180,15 @@ def resolve_reload_patterns(
directories = list(set(directories).difference(set(children)))
- return (list(set(patterns)), directories)
+ return list(set(patterns)), directories
+
+
+def _normalize_dirs(dirs: Union[List[str], str, None]) -> List[str]:
+ if dirs is None:
+ return []
+ if isinstance(dirs, str):
+ return [dirs]
+ return list(set(dirs))
class Config:
@@ -291,9 +299,9 @@ class Config:
)
if self.should_reload:
- reload_dirs = list(set(reload_dirs)) if reload_dirs else []
- reload_includes = list(set(reload_includes)) if reload_includes else []
- reload_excludes = list(set(reload_excludes)) if reload_excludes else []
+ reload_dirs = _normalize_dirs(reload_dirs)
+ reload_includes = _normalize_dirs(reload_includes)
+ reload_excludes = _normalize_dirs(reload_excludes)
self.reload_includes, self.reload_dirs = resolve_reload_patterns(
reload_includes, reload_dirs
diff --git a/uvicorn/protocols/websockets/websockets_impl.py b/uvicorn/protocols/websockets/websockets_impl.py
index f4fa67f..7caabad 100644
--- a/uvicorn/protocols/websockets/websockets_impl.py
+++ b/uvicorn/protocols/websockets/websockets_impl.py
@@ -282,10 +282,17 @@ class WebSocketProtocol(_LoggerMixin, websockets.WebSocketServerProtocol):
return {"type": "websocket.connect"}
await self.handshake_completed_event.wait()
+
+ if self.closed_event.is_set():
+ # If client disconnected, use WebSocketServerProtocol.close_code property.
+ # If the handshake failed or the app closed before handshake completion,
+ # use 1006 Abnormal Closure.
+ return {"type": "websocket.disconnect", "code": self.close_code or 1006}
+
try:
- await self.ensure_open()
data = await self.recv()
except websockets.ConnectionClosed as exc:
+ self.closed_event.set()
return {"type": "websocket.disconnect", "code": exc.code}
msg = {"type": "websocket.receive"}
| Passing `reload_dirs` as a string instead of a list
@Roang-zero1 @euri10 @Kludex this PR introduced a regression and deleted the test for it (`test_reload_dir_is_set()`). Previously you could pass `reload_dirs` a string instead of a list. Now:
```python
Config('myapp:app', reload=True, reload_dirs='src')
```
prints:
```
WARNING: Provided reload directories ['r', 'c', 's'] did not contain valid directories, watching current working directory.
```
https://github.com/encode/uvicorn/pull/820/files#diff-6982a5e270879281f9182303a9da9776148857b46325afb230e50ef8eb3264c9R294
(Of course, `set` expects an iterable... and strings are iterables of chars.)
_Originally posted by @HansBrende in https://github.com/encode/uvicorn/issues/820#issuecomment-977957988_ | encode/uvicorn | diff --git a/tests/protocols/test_websocket.py b/tests/protocols/test_websocket.py
index 2bd45b7..b444b3f 100644
--- a/tests/protocols/test_websocket.py
+++ b/tests/protocols/test_websocket.py
@@ -1,3 +1,5 @@
+import asyncio
+
import httpx
import pytest
@@ -543,3 +545,67 @@ async def test_send_binary_data_to_server_bigger_than_default(
with pytest.raises(websockets.ConnectionClosedError) as e:
data = await send_text("ws://127.0.0.1:8000")
assert e.value.code == expected_result
+
+
[email protected]
[email protected]("ws_protocol_cls", WS_PROTOCOLS)
[email protected]("http_protocol_cls", HTTP_PROTOCOLS)
+async def test_server_reject_connection(ws_protocol_cls, http_protocol_cls):
+ async def app(scope, receive, send):
+ assert scope["type"] == "websocket"
+
+ # Pull up first recv message.
+ message = await receive()
+ assert message["type"] == "websocket.connect"
+
+ # Reject the connection.
+ await send({"type": "websocket.close"})
+ # -- At this point websockets' recv() is unusable. --
+
+ # This doesn't raise `TypeError`:
+ # See https://github.com/encode/uvicorn/issues/244
+ message = await receive()
+ assert message["type"] == "websocket.disconnect"
+
+ async def websocket_session(url):
+ try:
+ async with websockets.connect(url):
+ pass
+ except Exception:
+ pass
+
+ config = Config(app=app, ws=ws_protocol_cls, http=http_protocol_cls, lifespan="off")
+ async with run_server(config):
+ await websocket_session("ws://127.0.0.1:8000")
+
+
[email protected]
[email protected]("ws_protocol_cls", WS_PROTOCOLS)
[email protected]("http_protocol_cls", HTTP_PROTOCOLS)
+async def test_server_can_read_messages_in_buffer_after_close(
+ ws_protocol_cls, http_protocol_cls
+):
+ frames = []
+
+ class App(WebSocketResponse):
+ async def websocket_connect(self, message):
+ await self.send({"type": "websocket.accept"})
+ # Ensure server doesn't start reading frames from read buffer until
+ # after client has sent close frame, but server is still able to
+ # read these frames
+ await asyncio.sleep(0.2)
+
+ async def websocket_receive(self, message):
+ frames.append(message.get("bytes"))
+
+ async def send_text(url):
+ async with websockets.connect(url) as websocket:
+ await websocket.send(b"abc")
+ await websocket.send(b"abc")
+ await websocket.send(b"abc")
+
+ config = Config(app=App, ws=ws_protocol_cls, http=http_protocol_cls, lifespan="off")
+ async with run_server(config):
+ await send_text("ws://127.0.0.1:8000")
+
+ assert frames == [b"abc", b"abc", b"abc"]
diff --git a/tests/test_config.py b/tests/test_config.py
index 7a04092..265d09b 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -119,6 +119,10 @@ def test_reload_dir_is_set(
== f"Will watch for changes in these directories: {[str(app_dir)]}"
)
assert config.reload_dirs == [app_dir]
+ config = Config(
+ app="tests.test_config:asgi_app", reload=True, reload_dirs=str(app_dir)
+ )
+ assert config.reload_dirs == [app_dir]
def test_non_existant_reload_dir_is_not_set(
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 3
},
"num_modified_files": 2
} | 0.15 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[standard]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | anyio==3.7.1
asgiref==3.8.1
attrs==25.3.0
autoflake==1.4
backports.tarfile==1.2.0
black==21.9b0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==5.5
coverage-conditional-plugin==0.4.0
cryptography==3.4.8
docutils==0.21.2
exceptiongroup==1.2.2
flake8==3.9.2
ghp-import==2.1.0
h11==0.12.0
httpcore==0.13.7
httptools==0.3.0
httpx==1.0.0b0
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
isort==5.9.3
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
Jinja2==3.1.6
keyring==25.6.0
Markdown==3.7
MarkupSafe==3.0.2
mccabe==0.6.1
mergedeep==1.3.4
mkdocs==1.2.3
mkdocs-material==7.2.6
mkdocs-material-extensions==1.3.1
more-itertools==10.6.0
mypy==0.910
mypy_extensions==0.4.4
nh3==0.2.21
packaging==24.2
pathspec==0.12.1
pkginfo==1.12.1.2
platformdirs==4.3.7
pluggy==1.5.0
py==1.11.0
pycodestyle==2.7.0
pycparser==2.22
pyflakes==2.3.1
Pygments==2.19.1
pymdown-extensions==10.14.3
pytest==6.2.5
pytest-asyncio==0.15.1
pytest-mock==3.6.1
python-dateutil==2.9.0.post0
python-dotenv==1.1.0
PyYAML==6.0.2
pyyaml_env_tag==0.1
readme_renderer==44.0
regex==2024.11.6
requests==2.32.3
requests-toolbelt==1.0.0
rfc3986==1.5.0
SecretStorage==3.3.3
six==1.17.0
sniffio==1.3.1
toml==0.10.2
tomli==1.2.3
tqdm==4.67.1
trustme==0.9.0
twine==3.4.2
types-click==7.1.5
types-PyYAML==5.4.10
typing_extensions==4.13.0
urllib3==2.3.0
-e git+https://github.com/encode/uvicorn.git@81802ceee2a2c62f0b10f78e2b6366b47bc76f72#egg=uvicorn
uvloop==0.21.0
watchdog==6.0.0
watchgod==0.8.2
websockets==15.0.1
wsproto==1.0.0
zipp==3.21.0
| name: uvicorn
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- anyio==3.7.1
- asgiref==3.8.1
- attrs==25.3.0
- autoflake==1.4
- backports-tarfile==1.2.0
- black==21.9b0
- certifi==2025.1.31
- cffi==1.17.1
- charset-normalizer==3.4.1
- click==8.1.8
- colorama==0.4.6
- coverage==5.5
- coverage-conditional-plugin==0.4.0
- cryptography==3.4.8
- docutils==0.21.2
- exceptiongroup==1.2.2
- flake8==3.9.2
- ghp-import==2.1.0
- h11==0.12.0
- httpcore==0.13.7
- httptools==0.3.0
- httpx==1.0.0b0
- idna==3.10
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- isort==5.9.3
- jaraco-classes==3.4.0
- jaraco-context==6.0.1
- jaraco-functools==4.1.0
- jeepney==0.9.0
- jinja2==3.1.6
- keyring==25.6.0
- markdown==3.7
- markupsafe==3.0.2
- mccabe==0.6.1
- mergedeep==1.3.4
- mkdocs==1.2.3
- mkdocs-material==7.2.6
- mkdocs-material-extensions==1.3.1
- more-itertools==10.6.0
- mypy==0.910
- mypy-extensions==0.4.4
- nh3==0.2.21
- packaging==24.2
- pathspec==0.12.1
- pkginfo==1.12.1.2
- platformdirs==4.3.7
- pluggy==1.5.0
- py==1.11.0
- pycodestyle==2.7.0
- pycparser==2.22
- pyflakes==2.3.1
- pygments==2.19.1
- pymdown-extensions==10.14.3
- pytest==6.2.5
- pytest-asyncio==0.15.1
- pytest-mock==3.6.1
- python-dateutil==2.9.0.post0
- python-dotenv==1.1.0
- pyyaml==6.0.2
- pyyaml-env-tag==0.1
- readme-renderer==44.0
- regex==2024.11.6
- requests==2.32.3
- requests-toolbelt==1.0.0
- rfc3986==1.5.0
- secretstorage==3.3.3
- six==1.17.0
- sniffio==1.3.1
- toml==0.10.2
- tomli==1.2.3
- tqdm==4.67.1
- trustme==0.9.0
- twine==3.4.2
- types-click==7.1.5
- types-pyyaml==5.4.10
- typing-extensions==4.13.0
- urllib3==2.3.0
- uvloop==0.21.0
- watchdog==6.0.0
- watchgod==0.8.2
- websockets==15.0.1
- wheel==0.37.0
- wsproto==1.0.0
- zipp==3.21.0
prefix: /opt/conda/envs/uvicorn
| [
"tests/protocols/test_websocket.py::test_server_can_read_messages_in_buffer_after_close[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_server_can_read_messages_in_buffer_after_close[HttpToolsProtocol-WebSocketProtocol]",
"tests/test_config.py::test_reload_dir_is_set"
] | [
"tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=defaults",
"tests/protocols/test_websocket.py::test_invalid_upgrade[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_invalid_upgrade[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_accept_connection[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_accept_connection[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_accept_connection[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_accept_connection[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_supports_permessage_deflate_extension[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_headers[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_headers[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_headers[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_headers[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_path_and_raw_path[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_path_and_raw_path[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_path_and_raw_path[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_path_and_raw_path[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_missing_handshake[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_missing_handshake[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_missing_handshake[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_missing_handshake[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_before_handshake[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_before_handshake[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_before_handshake[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_before_handshake[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_asgi_return_value[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_asgi_return_value[HttpToolsProtocol-WebSocketProtocol]"
] | [
"tests/protocols/test_websocket.py::test_invalid_upgrade[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_invalid_upgrade[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_close_connection[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_close_connection[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_close_connection[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_close_connection[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_client[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_client[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_client[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_client[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_client[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_client[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_client[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_client[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_and_close_connection[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_and_close_connection[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_and_close_connection[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_and_close_connection[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_server[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_server[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_server[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_text_data_to_server[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_server[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_server[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_server[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_server[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_after_protocol_close[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_after_protocol_close[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_after_protocol_close[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_send_after_protocol_close[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_duplicate_handshake[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_duplicate_handshake[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_duplicate_handshake[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_duplicate_handshake[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_asgi_return_value[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_asgi_return_value[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-None-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-None-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-None-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-None-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1000-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1000-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1000-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1000-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1001-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1001-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1001-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[none_as_reason-1001-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-None-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-None-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-None-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-None-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1000-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1000-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1000-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1000-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1001-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1001-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1001-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[normal_reason-1001-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-None-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-None-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-None-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-None-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1000-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1000-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1000-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1000-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1001-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1001-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1001-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_app_close[without_reason-1001-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_client_close[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_client_close[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_client_close[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_client_close[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto1-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto1-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto1-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto1-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto2-H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto2-H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto2-HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_subprotocols[proto2-HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_send_binary_data_to_server_bigger_than_default[max=10",
"tests/protocols/test_websocket.py::test_server_reject_connection[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_server_reject_connection[H11Protocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_server_reject_connection[HttpToolsProtocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_server_reject_connection[HttpToolsProtocol-WebSocketProtocol]",
"tests/protocols/test_websocket.py::test_server_can_read_messages_in_buffer_after_close[H11Protocol-WSProtocol]",
"tests/protocols/test_websocket.py::test_server_can_read_messages_in_buffer_after_close[HttpToolsProtocol-WSProtocol]",
"tests/test_config.py::test_debug_app",
"tests/test_config.py::test_config_should_reload_is_set[asgi_app-False]",
"tests/test_config.py::test_config_should_reload_is_set[tests.test_config:asgi_app-True]",
"tests/test_config.py::test_should_warn_on_invalid_reload_configuration",
"tests/test_config.py::test_non_existant_reload_dir_is_not_set",
"tests/test_config.py::test_reload_subdir_removal",
"tests/test_config.py::test_reload_included_dir_is_added_to_reload_dirs",
"tests/test_config.py::test_reload_dir_subdirectories_are_removed",
"tests/test_config.py::test_reload_excluded_subdirectories_are_removed",
"tests/test_config.py::test_reload_includes_exclude_dir_patterns_are_matched",
"tests/test_config.py::test_wsgi_app",
"tests/test_config.py::test_proxy_headers",
"tests/test_config.py::test_app_unimportable_module",
"tests/test_config.py::test_app_unimportable_other",
"tests/test_config.py::test_app_factory",
"tests/test_config.py::test_concrete_http_class",
"tests/test_config.py::test_socket_bind",
"tests/test_config.py::test_ssl_config",
"tests/test_config.py::test_ssl_config_combined",
"tests/test_config.py::test_asgi_version[asgi_app-3.0]",
"tests/test_config.py::test_asgi_version[asgi2_app-2.0]",
"tests/test_config.py::test_log_config_default[use_colors_not_provided]",
"tests/test_config.py::test_log_config_default[use_colors_invalid_value]",
"tests/test_config.py::test_log_config_default[use_colors_enabled]",
"tests/test_config.py::test_log_config_default[use_colors_disabled]",
"tests/test_config.py::test_log_config_json",
"tests/test_config.py::test_log_config_yaml[log_config.yml]",
"tests/test_config.py::test_log_config_yaml[log_config.yaml]",
"tests/test_config.py::test_log_config_file",
"tests/test_config.py::test_env_file[0-127.0.0.1]",
"tests/test_config.py::test_env_file[0-127.0.0.2]",
"tests/test_config.py::test_env_file[1-127.0.0.1]",
"tests/test_config.py::test_env_file[1-127.0.0.2]",
"tests/test_config.py::test_config_access_log[access",
"tests/test_config.py::test_config_log_level[5]",
"tests/test_config.py::test_config_log_level[10]",
"tests/test_config.py::test_config_log_level[20]",
"tests/test_config.py::test_config_log_level[30]",
"tests/test_config.py::test_config_log_level[40]",
"tests/test_config.py::test_config_log_level[50]",
"tests/test_config.py::test_ws_max_size",
"tests/test_config.py::test_bind_unix_socket_works_with_reload_or_workers[--reload=True",
"tests/test_config.py::test_bind_unix_socket_works_with_reload_or_workers[--reload=False",
"tests/test_config.py::test_bind_fd_works_with_reload_or_workers[--reload=True",
"tests/test_config.py::test_bind_fd_works_with_reload_or_workers[--reload=False"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,675 | 576 | [
"uvicorn/config.py",
"uvicorn/protocols/websockets/websockets_impl.py"
] |
|
mjs__imapclient-451 | 8ececac1c7aa4d7eb5c8846c88e8c41ce08c6340 | 2021-11-25 18:41:54 | 0cc82d30186f8acb02e2674a0a6093343d0b7634 | mjs: I'm find with exposing the socket. Thank you for including suitable warnings in the docstring.
I will try and test with Python 3.4. My laptop doesn't currently have old Python versions installed (or Docker) but I need to get that sorted out anyway.
The example makes sense but I wonder if it could be simpler. Does it really need to use threading?
I agree that keeping the existing simpler IDLE example is probably best. A link in the docs to the select based example might be nice.
NicolasLM: I agree that the example seems complicated. Isn't it possible to do the same thing on the main thread?
Also `select` is a low level API with sharp edges. As an example of an issue I ran into, most kernels are compiled with select being able to work with file descriptors with an ID lesser than 1025. So if your application opens a bunch of files, then opens a socket, this socket can get ID 1060 and won't work with select. The call to `select.select([socket], [], [])` will return an error.
That is why I would rather see this example use the `selectors` module which picks the best primitive according to the OS instead of relying on the common denominator.
BoniLindsley: I have changed the example to use `selectors`. I will clean-up the history with another force-push once everything is okay.
However, I now feel it is a bad example of `socket()` usage. Other than a slightly earlier detection of disconnect, it is mostly equivalent to directly using `while response := idle_check(remaining_time)` which already polls. I think the use of `socket()` only really shines in an event handling loop. Three potential options come to mind:
- Use the `selector` example as is. Readers might wonder "why poll at all?"
- Make an `asyncio` example. Likely lengthy. Not easily compatible with Windows which has no asyncio signal handling.
- Drop the example. It is a know-what-you-are-doing API. Users might be less clear on what is allowed with `socket()`.
NicolasLM: I agree that IDLE in synchronous Python feels weird and is much better used as part of an event loop. That being said users are going to be super confused if we steer them in the direction of using IMAPClient synchronously for establishing connections and then switching to a framework like asyncio for IDLE. I did just that at a previous job to monitor thousands of mailboxes and people stumbling upon the code were always very confused.
With unlimited time we could remove the use of imaplib, split the code into IO/sans-IO and let users decide if they want synchronous or async code.
So let's merge that for now and see later if we can provide a better user interface for IDLE.
NicolasLM: @BoniLindsley Could you squash your commits please? | diff --git a/examples/idle_selector_example.py b/examples/idle_selector_example.py
new file mode 100644
index 0000000..e8ff729
--- /dev/null
+++ b/examples/idle_selector_example.py
@@ -0,0 +1,36 @@
+from datetime import datetime, timedelta
+from selectors import DefaultSelector, EVENT_READ
+
+from imapclient import IMAPClient
+
+HOST = "localhost"
+USERNAME = "user"
+PASSWORD = "Tr0ub4dor&3"
+RESPONSE_TIMEOUT_SECONDS = 15
+IDLE_SECONDS = 60 * 24
+
+with IMAPClient(HOST, timeout=RESPONSE_TIMEOUT_SECONDS) as server:
+ server.login(USERNAME, PASSWORD)
+ server.select_folder("INBOX", readonly=True)
+ server.idle()
+ print(
+ "Connection is now in IDLE mode,"
+ " send yourself an email or quit with ^c"
+ )
+ try:
+ with DefaultSelector() as selector:
+ selector.register(server.socket(), EVENT_READ, None)
+ now = datetime.now
+ end_at = now() + timedelta(seconds=IDLE_SECONDS)
+ while selector.select((end_at - now()).total_seconds()):
+ responses = server.idle_check(timeout=0)
+ if not responses:
+ raise ConnectionError(
+ "Socket readable without data. Likely closed."
+ )
+ print("Server sent:", responses)
+ print("IDLE time out.")
+ except KeyboardInterrupt:
+ print("") # Newline after the typically echoed ^C.
+ server.idle_done()
+ print("IDLE mode done")
diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py
index 8d58693..a7bc703 100644
--- a/imapclient/imapclient.py
+++ b/imapclient/imapclient.py
@@ -11,6 +11,7 @@ import select
import socket
import sys
import re
+import warnings
from collections import namedtuple
from datetime import datetime, date
from operator import itemgetter
@@ -329,10 +330,26 @@ class IMAPClient(object):
def _set_read_timeout(self):
if self._timeout is not None:
- self._sock.settimeout(self._timeout.read)
+ self.socket().settimeout(self._timeout.read)
@property
def _sock(self):
+ warnings.warn("_sock is deprecated. Use socket().", DeprecationWarning)
+ return self.socket()
+
+ def socket(self):
+ """Returns socket used to connect to server.
+
+ The socket is provided for polling purposes only.
+ It can be used in,
+ for example, :py:meth:`selectors.BaseSelector.register`
+ and :py:meth:`asyncio.loop.add_reader` to wait for data.
+
+ .. WARNING::
+ All other uses of the returned socket are unsupported.
+ This includes reading from and writing to the socket,
+ as they are likely to break internal bookkeeping of messages.
+ """
# In py2, imaplib has sslobj (for SSL connections), and sock for non-SSL.
# In the py3 version it's just sock.
return getattr(self._imap, "sslobj", self._imap.sock)
@@ -919,7 +936,7 @@ class IMAPClient(object):
(1, b'EXISTS'),
(1, b'FETCH', (b'FLAGS', (b'\\NotJunk',)))]
"""
- sock = self._sock
+ sock = self.socket()
# make the socket non-blocking so the timeout can be
# implemented for this call
| Accessing the socket used by `IMAPClient`
To watch a mailbox using IDLE, the current documentation suggests [using a busyloop](https://imapclient.readthedocs.io/en/2.2.0/advanced.html#watching-a-mailbox-using-idle) with a relatively small timeout to check for responses. A small timeout because `IMAPClient.idle_check` uses a [blocking poll](https://github.com/mjs/imapclient/blob/master/imapclient/imapclient.py#L936) with this timeout and handling `KeyboardInterrup` is not possible while it blocks. An alternative to the busy loop was suggested in <https://github.com/mjs/imapclient/issues/322>, using `select.select` to poll both the connecting socket and a separate socket.
However, in order to poll the socket, access to the underlying socket is required, available as `IMAPClient._sock`. My understanding is that this attribute is an implementation detail. Can this be relied upon? If not, is it possible to make the socket available as part of the API? | mjs/imapclient | diff --git a/tests/test_imapclient.py b/tests/test_imapclient.py
index 4a065de..d42db68 100644
--- a/tests/test_imapclient.py
+++ b/tests/test_imapclient.py
@@ -7,6 +7,7 @@ from __future__ import unicode_literals
import itertools
import socket
import sys
+import warnings
from datetime import datetime
import logging
@@ -1055,3 +1056,12 @@ class TestProtocolError(IMAPClientTest):
with self.assertRaises(ProtocolError):
client._consume_until_tagged_response(sentinel.tag, b"IDLE")
+
+class TestSocket(IMAPClientTest):
+ def test_issues_warning_for_deprecating_sock_property(self):
+ mock_sock = Mock()
+ self.client._imap.sock = self.client._imap.sslobj = mock_sock
+ with warnings.catch_warnings(record=True) as warnings_caught:
+ warnings.simplefilter("always", DeprecationWarning)
+ assert self.client._sock == self.client.socket()
+ assert len(warnings_caught) == 1
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_added_files",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 3
},
"num_modified_files": 1
} | 2.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[test]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
-e git+https://github.com/mjs/imapclient.git@8ececac1c7aa4d7eb5c8846c88e8c41ce08c6340#egg=IMAPClient
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
six==1.17.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
| name: imapclient
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- six==1.17.0
prefix: /opt/conda/envs/imapclient
| [
"tests/test_imapclient.py::TestSocket::test_issues_warning_for_deprecating_sock_property"
] | [] | [
"tests/test_imapclient.py::TestListFolders::test_blanks",
"tests/test_imapclient.py::TestListFolders::test_empty_response",
"tests/test_imapclient.py::TestListFolders::test_folder_encode_off",
"tests/test_imapclient.py::TestListFolders::test_funky_characters",
"tests/test_imapclient.py::TestListFolders::test_list_folders",
"tests/test_imapclient.py::TestListFolders::test_list_folders_NO",
"tests/test_imapclient.py::TestListFolders::test_list_sub_folders",
"tests/test_imapclient.py::TestListFolders::test_list_sub_folders_NO",
"tests/test_imapclient.py::TestListFolders::test_mixed",
"tests/test_imapclient.py::TestListFolders::test_quoted_specials",
"tests/test_imapclient.py::TestListFolders::test_simple",
"tests/test_imapclient.py::TestListFolders::test_unquoted_numeric_folder_name",
"tests/test_imapclient.py::TestListFolders::test_unquoted_numeric_folder_name_parsed_as_long",
"tests/test_imapclient.py::TestListFolders::test_utf7_decoding",
"tests/test_imapclient.py::TestListFolders::test_without_quotes",
"tests/test_imapclient.py::TestFindSpecialFolder::test_find_special_folder_with_special_use",
"tests/test_imapclient.py::TestFindSpecialFolder::test_find_special_folder_with_special_use_single_flag",
"tests/test_imapclient.py::TestFindSpecialFolder::test_find_special_folder_without_special_use_nor_namespace",
"tests/test_imapclient.py::TestSelectFolder::test_normal",
"tests/test_imapclient.py::TestSelectFolder::test_unselect",
"tests/test_imapclient.py::TestAppend::test_multiappend",
"tests/test_imapclient.py::TestAppend::test_with_msg_time",
"tests/test_imapclient.py::TestAppend::test_without_msg_time",
"tests/test_imapclient.py::TestAclMethods::test_getacl",
"tests/test_imapclient.py::TestAclMethods::test_setacl",
"tests/test_imapclient.py::TestQuota::test__get_quota",
"tests/test_imapclient.py::TestQuota::test_get_quota_root",
"tests/test_imapclient.py::TestQuota::test_parse_quota",
"tests/test_imapclient.py::TestQuota::test_set_quota",
"tests/test_imapclient.py::TestIdleAndNoop::test_consume_until_tagged_response",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_check_blocking",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_check_blocking_poll",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_check_timeout",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_check_timeout_poll",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_check_with_data",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_check_with_data_poll",
"tests/test_imapclient.py::TestIdleAndNoop::test_idle_done",
"tests/test_imapclient.py::TestIdleAndNoop::test_noop",
"tests/test_imapclient.py::TestDebugLogging::test_IMAP_is_patched",
"tests/test_imapclient.py::TestDebugLogging::test_redacted_password",
"tests/test_imapclient.py::TestTimeNormalisation::test_default",
"tests/test_imapclient.py::TestTimeNormalisation::test_pass_through",
"tests/test_imapclient.py::TestNamespace::test_complex",
"tests/test_imapclient.py::TestNamespace::test_folder_decoding",
"tests/test_imapclient.py::TestNamespace::test_other_only",
"tests/test_imapclient.py::TestNamespace::test_simple",
"tests/test_imapclient.py::TestNamespace::test_without_folder_decoding",
"tests/test_imapclient.py::TestCapabilities::test_caching",
"tests/test_imapclient.py::TestCapabilities::test_decorator",
"tests/test_imapclient.py::TestCapabilities::test_has_capability",
"tests/test_imapclient.py::TestCapabilities::test_post_auth_request",
"tests/test_imapclient.py::TestCapabilities::test_preauth",
"tests/test_imapclient.py::TestCapabilities::test_server_returned_capability_after_auth",
"tests/test_imapclient.py::TestCapabilities::test_with_starttls",
"tests/test_imapclient.py::TestId::test_id",
"tests/test_imapclient.py::TestId::test_invalid_parameters",
"tests/test_imapclient.py::TestId::test_no_support",
"tests/test_imapclient.py::TestRawCommand::test_complex",
"tests/test_imapclient.py::TestRawCommand::test_embedded_literal",
"tests/test_imapclient.py::TestRawCommand::test_failed_continuation_wait",
"tests/test_imapclient.py::TestRawCommand::test_invalid_input_type",
"tests/test_imapclient.py::TestRawCommand::test_literal_at_end",
"tests/test_imapclient.py::TestRawCommand::test_literal_plus",
"tests/test_imapclient.py::TestRawCommand::test_multiple_literals",
"tests/test_imapclient.py::TestRawCommand::test_not_uid",
"tests/test_imapclient.py::TestRawCommand::test_plain",
"tests/test_imapclient.py::TestExpunge::test_expunge",
"tests/test_imapclient.py::TestExpunge::test_id_expunge",
"tests/test_imapclient.py::TestShutdown::test_shutdown",
"tests/test_imapclient.py::TestContextManager::test_context_manager",
"tests/test_imapclient.py::TestContextManager::test_context_manager_fail_closing",
"tests/test_imapclient.py::TestContextManager::test_exception_inside_context_manager",
"tests/test_imapclient.py::TestProtocolError::test_tagged_response_with_parse_error"
] | [] | BSD License | 11,683 | 849 | [
"imapclient/imapclient.py"
] |
sqlfluff__sqlfluff-1985 | 9b42f11af82857f7bcccc90ed911cba0b73468b8 | 2021-11-26 18:10:00 | 7aecf672872d05b608d614dc1f2b040e17a4f902 | jpy-git: Just looking up where to add inline ignore tests for this.
codecov[bot]: # [Codecov](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) Report
> Merging [#1985](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) (a76a4b7) into [main](https://codecov.io/gh/sqlfluff/sqlfluff/commit/3bca62f8d6b2b4f5e9603d8782f3473805a14543?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) (3bca62f) will **not change** coverage.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff)
```diff
@@ Coverage Diff @@
## main #1985 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 148 148
Lines 10290 10291 +1
=========================================
+ Hits 10290 10291 +1
```
| [Impacted Files](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff) | Coverage Δ | |
|---|---|---|
| [src/sqlfluff/core/linter/linter.py](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff#diff-c3JjL3NxbGZsdWZmL2NvcmUvbGludGVyL2xpbnRlci5weQ==) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff). Last update [3bca62f...a76a4b7](https://codecov.io/gh/sqlfluff/sqlfluff/pull/1985?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=sqlfluff).
tunetheweb: Should we add a test case?
tunetheweb: Ah missed your comment!
jpy-git: @tunetheweb I've added the unit tests now 😄
tunetheweb: Probably getting really picky here but I presume this handles other inline comments too (I think it does but not sure)?
```sql
this_is_not_so_big a # Hash inline comment --noqa: L012
this_is_not_so_big a /* Full inline comment */ --noqa: L012
```
Should we add test cases just to be sure?
jpy-git: @tunetheweb got those extra unit tests added now 👍
jpy-git: LGTM 🚀 | diff --git a/src/sqlfluff/core/linter/linter.py b/src/sqlfluff/core/linter/linter.py
index 2ca7dc670..5a3c1216d 100644
--- a/src/sqlfluff/core/linter/linter.py
+++ b/src/sqlfluff/core/linter/linter.py
@@ -228,6 +228,12 @@ class Linter:
def parse_noqa(comment: str, line_no: int):
"""Extract ignore mask entries from a comment string."""
# Also trim any whitespace afterward
+
+ # Comment lines can also have noqa e.g.
+ # --dafhsdkfwdiruweksdkjdaffldfsdlfjksd -- noqa: L016
+ # Therefore extract last possible inline ignore.
+ comment = [c.strip() for c in comment.split("--")][-1]
+
if comment.startswith("noqa"):
# This is an ignore identifier
comment_remainder = comment[4:]
| Disable rule inline doesn't work for commented sections of code
## Expected Behaviour
Adding -- noqa: L016 to the end of a commented line should ignore the 'Line too long' rule
## Observed Behaviour
Rule still fails for commented line even with the --noqa addition
## Steps to Reproduce
-- kkajshdkjhndkndansdjkasndjks knasdkasdkjaskjdhkajhdjkadn kahdkahnsjkdhkajdiundueubebd dkldkkljdalsd -- noqa: L016
## Dialect
Snowflake
## Version
SQLFluff v 0.8.2, Python v 3.8.2
## Configuration
```
[sqlfluff]
verbose = 0
nocolor = False
dialect = snowflake
templater = jinja
rules = None
exclude_rules = None
recurse = 0
output_line_length = 80
runaway_limit = 10
ignore_templated_areas = True
sql_file_exts = .sql,.sql.j2,.dml,.ddl
[sqlfluff:indentation]
indented_joins = False
template_blocks_indent = True
[sqlfluff:templater]
unwrap_wrapped_queries = True
[sqlfluff:templater:jinja]
apply_dbt_builtins = True
[sqlfluff:templater:jinja:macros]
# Macros provided as builtins for dbt projects
dbt_ref = {% macro ref(model_ref) %}{{model_ref}}{% endmacro %}
dbt_source = {% macro source(source_name, table) %}{{source_name}}_{{table}}{% endmacro %}
dbt_config = {% macro config() %}{% for k in kwargs %}{% endfor %}{% endmacro %}
dbt_var = {% macro var(variable) %}item{% endmacro %}
dbt_is_incremental = {% macro is_incremental() %}True{% endmacro %}
[sqlfluff:rules]
tab_space_size = 4
max_line_length = 80
indent_unit = space
comma_style = trailing
allow_scalar = False
single_table_references = unqualified
unquoted_identifiers_policy = all
[sqlfluff:rules:L003]
lint_templated_tokens = True
[sqlfluff:rules:L010]
capitalisation_policy = upper
[sqlfluff:rules:L014]
extended_capitalisation_policy = lower
[sqlfluff:rules:L016]
ignore_comment_lines = False
[sqlfluff:rules:L029]
unquoted_identifiers_policy = aliases
[sqlfluff:rules:L030]
capitalisation_policy = lower
[sqlfluff:rules:L038]
select_clause_trailing_comma = forbid
[sqlfluff:rules:L040]
capitalisation_policy = upper
[sqlfluff:rules:L042]
forbid_subquery_in = both
[sqlfluff:rules:L047]
prefer_count_1 = False
```
| sqlfluff/sqlfluff | diff --git a/test/core/linter_test.py b/test/core/linter_test.py
index 8f9c6abce..3df15c0c8 100644
--- a/test/core/linter_test.py
+++ b/test/core/linter_test.py
@@ -383,6 +383,10 @@ def test__linter__encoding(fname, config_encoding, lexerror):
("noqa: disable=L010", NoQaDirective(0, ("L010",), "disable")),
("noqa: disable=all", NoQaDirective(0, None, "disable")),
("noqa: disable", SQLParseError),
+ (
+ "Inline comment before inline ignore -- noqa:L001,L002",
+ NoQaDirective(0, ("L001", "L002"), None),
+ ),
],
)
def test_parse_noqa(input, expected):
@@ -520,6 +524,33 @@ def test_parse_noqa(input, expected):
],
[2],
],
+ [
+ [
+ dict(
+ comment="Inline comment before inline ignore -- noqa: L002",
+ line_no=1,
+ )
+ ],
+ [DummyLintError(1)],
+ [0],
+ ],
+ [
+ [
+ dict(
+ comment="Inline comment before inline ignore -- noqa: L002",
+ line_no=1,
+ ),
+ dict(
+ comment="Inline comment before inline ignore -- noqa: L002",
+ line_no=2,
+ ),
+ ],
+ [
+ DummyLintError(1),
+ DummyLintError(2),
+ ],
+ [0, 1],
+ ],
],
ids=[
"1_violation_no_ignore",
@@ -538,6 +569,8 @@ def test_parse_noqa(input, expected):
"1_violation_line_4_ignore_disable_all_2_3",
"4_violations_two_types_disable_specific_enable_all",
"4_violations_two_types_disable_all_enable_specific",
+ "1_violations_comment_inline_ignore",
+ "2_violations_comment_inline_ignore",
],
)
def test_linted_file_ignore_masked_violations(
@@ -564,6 +597,7 @@ def test_linter_noqa():
lntr = Linter(
config=FluffConfig(
overrides={
+ "dialect": "bigquery", # Use bigquery to allow hash comments.
"rules": "L012",
}
)
@@ -585,7 +619,10 @@ def test_linter_noqa():
col_m m,
col_n n, --noqa: disable=all
col_o o,
- col_p p --noqa: enable=all
+ col_p p, --noqa: enable=all
+ col_q q, --Inline comment --noqa: L012
+ col_r r, /* Block comment */ --noqa: L012
+ col_s s # hash comment --noqa: L012
FROM foo
"""
result = lntr.lint_string(sql)
@@ -598,6 +635,7 @@ def test_linter_noqa_with_templating():
lntr = Linter(
config=FluffConfig(
overrides={
+ "dialect": "bigquery", # Use bigquery to allow hash comments.
"templater": "jinja",
"rules": "L016",
}
@@ -607,7 +645,9 @@ def test_linter_noqa_with_templating():
{%- set a_var = ["1", "2"] -%}
SELECT
this_is_just_a_very_long_line_for_demonstration_purposes_of_a_bug_involving_templated_sql_files, --noqa: L016
- this_is_not_so_big
+ this_is_not_so_big a, --Inline comment --noqa: L012
+ this_is_not_so_big b, /* Block comment */ --noqa: L012
+ this_is_not_so_big c # hash comment --noqa: L012
FROM
a_table
"""
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 0.8 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | appdirs==1.4.4
cached-property==2.0.1
chardet==5.2.0
click==8.1.8
colorama==0.4.6
diff_cover==9.2.4
exceptiongroup==1.2.2
iniconfig==2.1.0
Jinja2==3.1.6
MarkupSafe==3.0.2
oyaml==1.0
packaging==24.2
pathspec==0.12.1
pluggy==1.5.0
Pygments==2.19.1
pytest==8.3.5
PyYAML==6.0.2
-e git+https://github.com/sqlfluff/sqlfluff.git@9b42f11af82857f7bcccc90ed911cba0b73468b8#egg=sqlfluff
tblib==3.0.0
toml==0.10.2
tomli==2.2.1
tqdm==4.67.1
typing_extensions==4.13.0
| name: sqlfluff
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- appdirs==1.4.4
- cached-property==2.0.1
- chardet==5.2.0
- click==8.1.8
- colorama==0.4.6
- diff-cover==9.2.4
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- jinja2==3.1.6
- markupsafe==3.0.2
- oyaml==1.0
- packaging==24.2
- pathspec==0.12.1
- pluggy==1.5.0
- pygments==2.19.1
- pytest==8.3.5
- pyyaml==6.0.2
- tblib==3.0.0
- toml==0.10.2
- tomli==2.2.1
- tqdm==4.67.1
- typing-extensions==4.13.0
prefix: /opt/conda/envs/sqlfluff
| [
"test/core/linter_test.py::test_parse_noqa[Inline",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violations_comment_inline_ignore]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[2_violations_comment_inline_ignore]",
"test/core/linter_test.py::test_linter_noqa"
] | [] | [
"test/core/linter_test.py::test__linter__path_from_paths__dir",
"test/core/linter_test.py::test__linter__path_from_paths__default",
"test/core/linter_test.py::test__linter__path_from_paths__exts",
"test/core/linter_test.py::test__linter__path_from_paths__file",
"test/core/linter_test.py::test__linter__path_from_paths__not_exist",
"test/core/linter_test.py::test__linter__path_from_paths__not_exist_ignore",
"test/core/linter_test.py::test__linter__path_from_paths__explicit_ignore",
"test/core/linter_test.py::test__linter__path_from_paths__dot",
"test/core/linter_test.py::test__linter__path_from_paths__ignore[test/fixtures/linter/sqlfluffignore]",
"test/core/linter_test.py::test__linter__path_from_paths__ignore[test/fixtures/linter/sqlfluffignore/]",
"test/core/linter_test.py::test__linter__path_from_paths__ignore[test/fixtures/linter/sqlfluffignore/.]",
"test/core/linter_test.py::test__linter__lint_string_vs_file[test/fixtures/linter/indentation_errors.sql]",
"test/core/linter_test.py::test__linter__lint_string_vs_file[test/fixtures/linter/whitespace_errors.sql]",
"test/core/linter_test.py::test__linter__get_violations_filter_rules[None-7]",
"test/core/linter_test.py::test__linter__get_violations_filter_rules[L010-2]",
"test/core/linter_test.py::test__linter__get_violations_filter_rules[rules2-2]",
"test/core/linter_test.py::test__linter__linting_result__sum_dicts",
"test/core/linter_test.py::test__linter__linting_result__combine_dicts",
"test/core/linter_test.py::test__linter__linting_result_check_tuples_by_path[False-list]",
"test/core/linter_test.py::test__linter__linting_result_check_tuples_by_path[True-dict]",
"test/core/linter_test.py::test__linter__linting_result_get_violations[1]",
"test/core/linter_test.py::test__linter__linting_result_get_violations[2]",
"test/core/linter_test.py::test__linter__linting_parallel_thread[False]",
"test/core/linter_test.py::test__linter__linting_parallel_thread[True]",
"test/core/linter_test.py::test_lint_path_parallel_wrapper_exception",
"test/core/linter_test.py::test__linter__linting_unexpected_error_handled_gracefully",
"test/core/linter_test.py::test__linter__raises_malformed_noqa",
"test/core/linter_test.py::test__linter__empty_file",
"test/core/linter_test.py::test__linter__mask_templated_violations[True-check_tuples0]",
"test/core/linter_test.py::test__linter__mask_templated_violations[False-check_tuples1]",
"test/core/linter_test.py::test__linter__encoding[test/fixtures/linter/encoding-utf-8.sql-autodetect-False]",
"test/core/linter_test.py::test__linter__encoding[test/fixtures/linter/encoding-utf-8-sig.sql-autodetect-False]",
"test/core/linter_test.py::test__linter__encoding[test/fixtures/linter/encoding-utf-8.sql-utf-8-False]",
"test/core/linter_test.py::test__linter__encoding[test/fixtures/linter/encoding-utf-8-sig.sql-utf-8-True]",
"test/core/linter_test.py::test__linter__encoding[test/fixtures/linter/encoding-utf-8.sql-utf-8-sig-False]",
"test/core/linter_test.py::test__linter__encoding[test/fixtures/linter/encoding-utf-8-sig.sql-utf-8-sig-False]",
"test/core/linter_test.py::test_parse_noqa[-None]",
"test/core/linter_test.py::test_parse_noqa[noqa-expected1]",
"test/core/linter_test.py::test_parse_noqa[noqa?-SQLParseError]",
"test/core/linter_test.py::test_parse_noqa[noqa:-expected3]",
"test/core/linter_test.py::test_parse_noqa[noqa:L001,L002-expected4]",
"test/core/linter_test.py::test_parse_noqa[noqa:",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_no_ignore]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_ignore_specific_line]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_ignore_different_specific_line]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_ignore_different_specific_rule]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_ignore_enable_this_range]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_ignore_disable_this_range]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_1_ignore_disable_specific_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_2_ignore_disable_specific_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_3_ignore_disable_specific_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_4_ignore_disable_specific_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_1_ignore_disable_all_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_2_ignore_disable_all_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_3_ignore_disable_all_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[1_violation_line_4_ignore_disable_all_2_3]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[4_violations_two_types_disable_specific_enable_all]",
"test/core/linter_test.py::test_linted_file_ignore_masked_violations[4_violations_two_types_disable_all_enable_specific]",
"test/core/linter_test.py::test_linter_noqa_with_templating",
"test/core/linter_test.py::test_delayed_exception",
"test/core/linter_test.py::test__attempt_to_change_templater_warning",
"test/core/linter_test.py::test_safe_create_replace_file[utf8_create]",
"test/core/linter_test.py::test_safe_create_replace_file[utf8_update]",
"test/core/linter_test.py::test_safe_create_replace_file[utf8_special_char]",
"test/core/linter_test.py::test_safe_create_replace_file[incorrect_encoding]"
] | [] | MIT License | 11,693 | 228 | [
"src/sqlfluff/core/linter/linter.py"
] |
microsoft__pybryt-130 | 4506ddccd82b3a3a4ca517ca586266b18f47a7a0 | 2021-11-27 05:28:09 | 45a89cc8b0e1bbca74d05b6941524457513768b3 | diff --git a/pybryt/cli.py b/pybryt/cli.py
index 2920198..cbcbabe 100644
--- a/pybryt/cli.py
+++ b/pybryt/cli.py
@@ -37,17 +37,15 @@ def compile_reference(src, dest, name):
@click_cli.command()
[email protected]("-n", "--name", default=None, type=click.STRING,
- help="Optional name for the reference implementation")
[email protected]("--output-nb", default=None, type=click.Path(dir_okay=False),
[email protected]("--output", default=None, type=click.Path(dir_okay=False),
help="Path at which to write the output notebook from executing the student submission")
[email protected]("-o", "--output", default=None, type=click.Path(dir_okay=False),
[email protected]("-d", "--dest", default=None, type=click.Path(dir_okay=False),
help="Path at which to write the results of the check")
@click.option("-t", "--type", "output_type", default="pickle", show_default=True,
type=click.Choice(["pickle", "json", "report"]), help="Type of output to write")
@click.argument("ref", type=click.Path(exists=True, dir_okay=False))
@click.argument("stu", type=click.Path(exists=True, dir_okay=False))
-def check(ref, stu, name, output_nb, output, output_type):
+def check(ref, stu, output, dest, output_type):
"""
Run a student submission against a reference implementation.
@@ -65,11 +63,11 @@ def check(ref, stu, name, output_nb, output, output_type):
except:
raise RuntimeError(f"Could not load the reference implementation {ref}")
- if output is None:
- output = get_stem(stu) + "_results" + (".pkl", ".json")[output_type == "json"]
+ if dest is None:
+ dest = get_stem(stu) + "_results" + (".pkl", ".json")[output_type == "json"]
if os.path.splitext(stu)[1] == ".ipynb":
- stu = StudentImplementation(stu, output=output_nb)
+ stu = StudentImplementation(stu, output=output)
else:
try:
stu = StudentImplementation.load(stu)
@@ -80,16 +78,16 @@ def check(ref, stu, name, output_nb, output, output_type):
if output_type == "pickle":
if isinstance(res, list):
- with open(output, "wb+") as f:
+ with open(dest, "wb+") as f:
dill.dump(res, f)
else:
- res.dump(output)
+ res.dump(dest)
elif output_type == "json":
if isinstance(res, list):
d = [r.to_dict() for r in res]
else:
d = res.to_dict()
- with open(output, "w+") as f:
+ with open(dest, "w+") as f:
json.dump(d, f, indent=2)
elif output_type == "report":
report = generate_report(res)
@@ -99,17 +97,17 @@ def check(ref, stu, name, output_nb, output, output_type):
@click_cli.command()
@click.option("-p", "--parallel", is_flag=True, default=False,
help="Execute notebooks in parallel using the multiprocessing library")
[email protected]("-o", "--output", default=None, type=click.Path(),
[email protected]("-d", "--dest", default=None, type=click.Path(),
help="Path at which to write the pickled student implementation")
@click.option("--timeout", default=1200, type=click.INT,
help="Timeout for notebook execution in seconds")
@click.argument("subm", nargs=-1, type=click.Path(exists=True, dir_okay=False))
-def execute(subm, parallel, output, timeout):
+def execute(subm, parallel, dest, timeout):
"""
Execute student submissions to generate memory footprints.
Executes the student submission(s) SUBM at writes the pickled objects to some output file. If
- OUTPUT is unspecified, this defaults to "./{SUBM.stem}.pkl" (e.g. for SUBM
+ DEST is unspecified, this defaults to "./{SUBM.stem}.pkl" (e.g. for SUBM
"submissions/subm01.ipynb", this is "./subm01.pkl").
"""
if len(subm) == 0:
@@ -117,23 +115,23 @@ def execute(subm, parallel, output, timeout):
stus = generate_student_impls(subm, parallel=parallel, timeout=timeout)
- if output is None:
- output = "./"
+ if dest is None:
+ dest = "./"
if len(subm) == 1:
- if os.path.isdir(output):
+ if os.path.isdir(dest):
stem = get_stem(subm[0])
- output = os.path.join(output, stem + ".pkl")
+ output = os.path.join(dest, stem + ".pkl")
stus[0].dump(output)
else:
- if not os.path.isdir(output):
- raise ValueError(f"Output directory {output} does not exist or is not a directory")
+ if not os.path.isdir(dest):
+ raise ValueError(f"Destination directory {dest} does not exist or is not a directory")
for s, stu in zip(subm, stus):
stem = get_stem(s)
- path = os.path.join(output, stem + ".pkl")
+ path = os.path.join(dest, stem + ".pkl")
stu.dump(path)
| Unify CLI argument language
There's some small disconnects in the naming of CLI arguments, e.g. the interchangeability of `dest` and `output`. These should be fixed. This would also allow the inclusion of the output argument for student implementations in `pybryt execute`. | microsoft/pybryt | diff --git a/tests/test_cli.py b/tests/test_cli.py
index 69528d8..3db1cba 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -143,10 +143,10 @@ def test_execute():
mocked_generate.assert_called_with(fns, parallel=False, timeout=100)
# check for error on nonexistance output dir
- result = runner.invoke(click_cli, ["execute", *fns, "-o", "/some/fake/path"])
+ result = runner.invoke(click_cli, ["execute", *fns, "-d", "/some/fake/path"])
assert result.exit_code == 1
assert isinstance(result.exception, ValueError)
- assert result.exception.args[0] == "Output directory /some/fake/path does not exist or is not a directory"
+ assert result.exception.args[0] == "Destination directory /some/fake/path does not exist or is not a directory"
# check other errors
result = runner.invoke(click_cli, ["execute"])
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 0
},
"num_modified_files": 1
} | 0.3 | {
"env_vars": {
"JUPYTER_PLATFORM_DIRS": "1"
},
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"otter-grader"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
annotated-types==0.7.0
asttokens==3.0.0
astunparse==1.6.3
attrs==25.3.0
babel==2.17.0
beautifulsoup4==4.13.3
bleach==6.2.0
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
comm==0.2.2
Cython==3.0.12
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
dill==0.3.9
docutils==0.21.2
exceptiongroup==1.2.2
executing==2.2.0
fastjsonschema==2.21.1
fica==0.4.1
greenlet==3.1.1
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
ipykernel==6.29.5
ipylab==1.0.0
ipython==8.18.1
ipywidgets==8.1.5
jedi==0.19.2
Jinja2==3.1.6
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
jupyterlab_widgets==3.0.13
jupytext==1.16.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mdit-py-plugins==0.4.2
mdurl==0.1.2
mistune==3.1.3
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
numpy==2.0.2
otter-grader==6.1.2
packaging==24.2
pandas==2.2.3
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
platformdirs==4.3.7
playwright==1.51.0
pluggy==1.5.0
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
-e git+https://github.com/microsoft/pybryt.git@4506ddccd82b3a3a4ca517ca586266b18f47a7a0#egg=pybryt
pydantic==2.11.1
pydantic_core==2.33.0
pyee==12.1.1
Pygments==2.19.1
pytest==8.3.5
python-dateutil==2.9.0.post0
python-on-whales==0.76.1
pytz==2025.2
PyYAML==6.0.2
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rpds-py==0.24.0
six==1.17.0
snowballstemmer==2.2.0
soupsieve==2.6
Sphinx==7.4.7
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
stack-data==0.6.3
tinycss2==1.4.0
tomli==2.2.1
tornado==6.4.2
traitlets==5.14.3
typing-inspection==0.4.0
typing_extensions==4.13.0
tzdata==2025.2
urllib3==2.3.0
wcwidth==0.2.13
webencodings==0.5.1
widgetsnbextension==4.0.13
wrapt==1.17.2
zipp==3.21.0
| name: pybryt
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- annotated-types==0.7.0
- asttokens==3.0.0
- astunparse==1.6.3
- attrs==25.3.0
- babel==2.17.0
- beautifulsoup4==4.13.3
- bleach==6.2.0
- certifi==2025.1.31
- charset-normalizer==3.4.1
- click==8.1.8
- comm==0.2.2
- cython==3.0.12
- debugpy==1.8.13
- decorator==5.2.1
- defusedxml==0.7.1
- dill==0.3.9
- docutils==0.21.2
- exceptiongroup==1.2.2
- executing==2.2.0
- fastjsonschema==2.21.1
- fica==0.4.1
- greenlet==3.1.1
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- ipykernel==6.29.5
- ipylab==1.0.0
- ipython==8.18.1
- ipywidgets==8.1.5
- jedi==0.19.2
- jinja2==3.1.6
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- jupyter-client==8.6.3
- jupyter-core==5.7.2
- jupyterlab-pygments==0.3.0
- jupyterlab-widgets==3.0.13
- jupytext==1.16.7
- markdown-it-py==3.0.0
- markupsafe==3.0.2
- matplotlib-inline==0.1.7
- mdit-py-plugins==0.4.2
- mdurl==0.1.2
- mistune==3.1.3
- nbclient==0.10.2
- nbconvert==7.16.6
- nbformat==5.10.4
- nest-asyncio==1.6.0
- numpy==2.0.2
- otter-grader==6.1.2
- packaging==24.2
- pandas==2.2.3
- pandocfilters==1.5.1
- parso==0.8.4
- pexpect==4.9.0
- platformdirs==4.3.7
- playwright==1.51.0
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- psutil==7.0.0
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pydantic==2.11.1
- pydantic-core==2.33.0
- pyee==12.1.1
- pygments==2.19.1
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- python-on-whales==0.76.1
- pytz==2025.2
- pyyaml==6.0.2
- pyzmq==26.3.0
- referencing==0.36.2
- requests==2.32.3
- rpds-py==0.24.0
- six==1.17.0
- snowballstemmer==2.2.0
- soupsieve==2.6
- sphinx==7.4.7
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- stack-data==0.6.3
- tinycss2==1.4.0
- tomli==2.2.1
- tornado==6.4.2
- traitlets==5.14.3
- typing-extensions==4.13.0
- typing-inspection==0.4.0
- tzdata==2025.2
- urllib3==2.3.0
- wcwidth==0.2.13
- webencodings==0.5.1
- widgetsnbextension==4.0.13
- wrapt==1.17.2
- zipp==3.21.0
prefix: /opt/conda/envs/pybryt
| [
"tests/test_cli.py::test_execute"
] | [] | [
"tests/test_cli.py::test_check",
"tests/test_cli.py::test_compile",
"tests/test_cli.py::test_cli_func"
] | [] | MIT License | 11,696 | 1,303 | [
"pybryt/cli.py"
] |
|
PyCQA__flake8-bugbear-209 | 9e311d5af7ffd2bba272fc6471b8ecfe21bf1993 | 2021-11-29 18:59:11 | c0a9c878dd50b57e8f39f34b07f1730866c9d86d | diff --git a/bugbear.py b/bugbear.py
index 77b4dc6..9249550 100644
--- a/bugbear.py
+++ b/bugbear.py
@@ -639,7 +639,6 @@ class BugBearVisitor(ast.NodeVisitor):
if isinstance(
subnode.value,
(
- ast.Str,
ast.Num,
ast.Bytes,
ast.NameConstant,
| B018 wrongly detects inline variable or attribute docstrings
Having an inline attribute doc string or a module variable docstring, it is wrongly marked as B018 (sample from sphinx doc):
```
module_level_variable2 = 98765
"""int: Module level variable documented inline.
The docstring may span multiple lines. The type may optionally be specified
on the first line, separated by a colon.
"""
``` | PyCQA/flake8-bugbear | diff --git a/tests/b018_classes.py b/tests/b018_classes.py
index 12195c0..551b14e 100644
--- a/tests/b018_classes.py
+++ b/tests/b018_classes.py
@@ -1,6 +1,6 @@
"""
Should emit:
-B018 - on lines 15-26, 30, 32
+B018 - on lines 16-26, 30, 33
"""
@@ -30,3 +30,4 @@ class Foo3:
123
a = 2
"str"
+ 1
diff --git a/tests/b018_functions.py b/tests/b018_functions.py
index 9764274..f8c3f77 100644
--- a/tests/b018_functions.py
+++ b/tests/b018_functions.py
@@ -1,6 +1,6 @@
"""
Should emit:
-B018 - on lines 14-25, 29, 31
+B018 - on lines 15-25, 29, 32
"""
@@ -29,3 +29,4 @@ def foo3():
123
a = 2
"str"
+ 3
diff --git a/tests/test_bugbear.py b/tests/test_bugbear.py
index c05b828..319a508 100644
--- a/tests/test_bugbear.py
+++ b/tests/test_bugbear.py
@@ -234,9 +234,9 @@ class BugbearTestCase(unittest.TestCase):
bbc = BugBearChecker(filename=str(filename))
errors = list(bbc.run())
- expected = [B018(line, 4) for line in range(14, 26)]
+ expected = [B018(line, 4) for line in range(15, 26)]
expected.append(B018(29, 4))
- expected.append(B018(31, 4))
+ expected.append(B018(32, 4))
self.assertEqual(errors, self.errors(*expected))
def test_b018_classes(self):
@@ -244,9 +244,9 @@ class BugbearTestCase(unittest.TestCase):
bbc = BugBearChecker(filename=str(filename))
errors = list(bbc.run())
- expected = [B018(line, 4) for line in range(15, 27)]
+ expected = [B018(line, 4) for line in range(16, 27)]
expected.append(B018(30, 4))
- expected.append(B018(32, 4))
+ expected.append(B018(33, 4))
self.assertEqual(errors, self.errors(*expected))
def test_b901(self):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 21.11 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"black",
"isort",
"pytest"
],
"pre_install": [],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
black==25.1.0
cfgv==3.4.0
click==8.1.8
coverage==7.8.0
distlib==0.3.9
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
filelock==3.18.0
flake8==7.2.0
-e git+https://github.com/PyCQA/flake8-bugbear.git@9e311d5af7ffd2bba272fc6471b8ecfe21bf1993#egg=flake8_bugbear
hypothesis==6.130.5
hypothesmith==0.3.3
identify==2.6.9
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
isort==6.0.1
lark==1.2.2
libcst==1.7.0
mccabe==0.7.0
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging @ file:///croot/packaging_1734472117206/work
pathspec==0.12.1
platformdirs==4.3.7
pluggy @ file:///croot/pluggy_1733169602837/work
pre_commit==4.2.0
pycodestyle==2.13.0
pyflakes==3.3.2
pytest @ file:///croot/pytest_1738938843180/work
PyYAML==6.0.2
sortedcontainers==2.4.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing_extensions==4.13.0
virtualenv==20.29.3
| name: flake8-bugbear
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- black==25.1.0
- cfgv==3.4.0
- click==8.1.8
- coverage==7.8.0
- distlib==0.3.9
- filelock==3.18.0
- flake8==7.2.0
- flake8-bugbear==21.11.28
- hypothesis==6.130.5
- hypothesmith==0.3.3
- identify==2.6.9
- isort==6.0.1
- lark==1.2.2
- libcst==1.7.0
- mccabe==0.7.0
- mypy-extensions==1.0.0
- nodeenv==1.9.1
- pathspec==0.12.1
- platformdirs==4.3.7
- pre-commit==4.2.0
- pycodestyle==2.13.0
- pyflakes==3.3.2
- pyyaml==6.0.2
- sortedcontainers==2.4.0
- typing-extensions==4.13.0
- virtualenv==20.29.3
prefix: /opt/conda/envs/flake8-bugbear
| [
"tests/test_bugbear.py::BugbearTestCase::test_b018_classes",
"tests/test_bugbear.py::BugbearTestCase::test_b018_functions"
] | [
"tests/test_bugbear.py::BugbearTestCase::test_selfclean_bugbear"
] | [
"tests/test_bugbear.py::BugbearTestCase::test_b001",
"tests/test_bugbear.py::BugbearTestCase::test_b002",
"tests/test_bugbear.py::BugbearTestCase::test_b003",
"tests/test_bugbear.py::BugbearTestCase::test_b004",
"tests/test_bugbear.py::BugbearTestCase::test_b005",
"tests/test_bugbear.py::BugbearTestCase::test_b006_b008",
"tests/test_bugbear.py::BugbearTestCase::test_b007",
"tests/test_bugbear.py::BugbearTestCase::test_b008_extended",
"tests/test_bugbear.py::BugbearTestCase::test_b009_b010",
"tests/test_bugbear.py::BugbearTestCase::test_b011",
"tests/test_bugbear.py::BugbearTestCase::test_b012",
"tests/test_bugbear.py::BugbearTestCase::test_b013",
"tests/test_bugbear.py::BugbearTestCase::test_b014",
"tests/test_bugbear.py::BugbearTestCase::test_b015",
"tests/test_bugbear.py::BugbearTestCase::test_b016",
"tests/test_bugbear.py::BugbearTestCase::test_b017",
"tests/test_bugbear.py::BugbearTestCase::test_b901",
"tests/test_bugbear.py::BugbearTestCase::test_b902",
"tests/test_bugbear.py::BugbearTestCase::test_b902_py38",
"tests/test_bugbear.py::BugbearTestCase::test_b903",
"tests/test_bugbear.py::BugbearTestCase::test_b904",
"tests/test_bugbear.py::BugbearTestCase::test_b950",
"tests/test_bugbear.py::BugbearTestCase::test_selfclean_test_bugbear",
"tests/test_bugbear.py::TestFuzz::test_does_not_crash_on_any_valid_code",
"tests/test_bugbear.py::TestFuzz::test_does_not_crash_on_call_in_except_statement",
"tests/test_bugbear.py::TestFuzz::test_does_not_crash_on_site_code",
"tests/test_bugbear.py::TestFuzz::test_does_not_crash_on_tuple_expansion_in_except_statement"
] | [] | MIT License | 11,718 | 103 | [
"bugbear.py"
] |
|
executablebooks__mdit-py-plugins-31 | bb061190339e6e2083e8c192ef8b089bece72c3f | 2021-12-02 06:49:57 | bb061190339e6e2083e8c192ef8b089bece72c3f | codecov[bot]: # [Codecov](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) Report
> Merging [#31](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) (1bd859a) into [master](https://codecov.io/gh/executablebooks/mdit-py-plugins/commit/bb061190339e6e2083e8c192ef8b089bece72c3f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) (bb06119) will **decrease** coverage by `0.05%`.
> The diff coverage is `90.90%`.
[](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)
```diff
@@ Coverage Diff @@
## master #31 +/- ##
==========================================
- Coverage 93.26% 93.20% -0.06%
==========================================
Files 24 24
Lines 1233 1237 +4
==========================================
+ Hits 1150 1153 +3
- Misses 83 84 +1
```
| Flag | Coverage Δ | |
|---|---|---|
| pytests | `93.20% <90.90%> (-0.06%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks) | Coverage Δ | |
|---|---|---|
| [mdit\_py\_plugins/myst\_blocks/index.py](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks#diff-bWRpdF9weV9wbHVnaW5zL215c3RfYmxvY2tzL2luZGV4LnB5) | `95.55% <90.90%> (-0.96%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Last update [bb06119...1bd859a](https://codecov.io/gh/executablebooks/mdit-py-plugins/pull/31?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=executablebooks).
| diff --git a/mdit_py_plugins/myst_blocks/index.py b/mdit_py_plugins/myst_blocks/index.py
index 16baaaa..d0e4cf6 100644
--- a/mdit_py_plugins/myst_blocks/index.py
+++ b/mdit_py_plugins/myst_blocks/index.py
@@ -1,12 +1,9 @@
import itertools
-import re
from markdown_it import MarkdownIt
from markdown_it.common.utils import escapeHtml, isSpace
from markdown_it.rules_block import StateBlock
-TARGET_PATTERN = re.compile(r"^\(([a-zA-Z0-9\|\@\<\>\*\.\/\_\-\+\:]{1,100})\)\=\s*$")
-
def myst_block_plugin(md: MarkdownIt):
"""Parse MyST targets (``(name)=``), blockquotes (``% comment``) and block breaks (``+++``)."""
@@ -122,8 +119,12 @@ def target(state: StateBlock, startLine: int, endLine: int, silent: bool):
if state.sCount[startLine] - state.blkIndent >= 4:
return False
- match = TARGET_PATTERN.match(state.src[pos:maximum])
- if not match:
+ text = state.src[pos:maximum].strip()
+ if not text.startswith("("):
+ return False
+ if not text.endswith(")="):
+ return False
+ if not text[1:-2]:
return False
if silent:
@@ -133,17 +134,17 @@ def target(state: StateBlock, startLine: int, endLine: int, silent: bool):
token = state.push("myst_target", "", 0)
token.attrSet("class", "myst-target")
- token.content = match.group(1)
+ token.content = text[1:-2]
token.map = [startLine, state.line]
return True
def render_myst_target(self, tokens, idx, options, env):
- content = tokens[idx].content
- return (
- '<div class="myst-target">' f"target = <code>{escapeHtml(content)}</code></div>"
- )
+ label = tokens[idx].content
+ class_name = "myst-target"
+ target = f'<a href="#{label}">({label})=</a>'
+ return f'<div class="{class_name}">{target}</div>'
def render_myst_line_comment(self, tokens, idx, options, env):
| Support spaces in labels
### Describe the enhancement you'd like
It would be useful if it were possible to use spaces in labels, like so:
```md
(my label)=
# My header
Ref for [](my label).
```
In https://github.com/executablebooks/meta/discussions/467#discussioncomment-1223602 we discovered that, while reStructuredText supports spaces in labels, like `.. _my label:`, the MyST parser does not.
### Benefit
This would be useful for people who are coming from the rST / Sphinx ecosystem, since this is already supported in rST. However it's probably not a huge number of people using labels this way because most seem to use `-` or `_` for this kind of thing.
### Implementation
The fix for this would probably somewhere around here:
https://github.com/executablebooks/mdit-py-plugins/blob/a0f7ffac84b2eb768a508c2e7a1c286df0c2b56a/mdit_py_plugins/myst_blocks/index.py#L116 | executablebooks/mdit-py-plugins | diff --git a/tests/fixtures/myst_block.md b/tests/fixtures/myst_block.md
index 38d0771..90bf9d3 100644
--- a/tests/fixtures/myst_block.md
+++ b/tests/fixtures/myst_block.md
@@ -41,32 +41,58 @@ a
<hr class="myst-block">
.
-
Target:
.
(a)=
.
-<div class="myst-target">target = <code>a</code></div>
+<div class="myst-target"><a href="#a">(a)=</a></div>
+.
+
+Target characters:
+.
+(a bc |@<>*./_-+:)=
+.
+<div class="myst-target"><a href="#a bc |@<>*./_-+:">(a bc |@<>*./_-+:)=</a></div>
+.
+
+Empty target:
+.
+()=
+.
+<p>()=</p>
.
+Escaped target:
+.
+\(a)=
+.
+<p>(a)=</p>
+.
+
+Indented target:
+.
+ (a)=
+.
+<div class="myst-target"><a href="#a">(a)=</a></div>
+.
Target terminates other blocks:
.
a
-(a)=
+(a-b)=
- b
-(a)=
+(a b)=
> c
(a)=
.
<p>a</p>
-<div class="myst-target">target = <code>a</code></div><ul>
+<div class="myst-target"><a href="#a-b">(a-b)=</a></div><ul>
<li>b</li>
</ul>
-<div class="myst-target">target = <code>a</code></div><blockquote>
+<div class="myst-target"><a href="#a b">(a b)=</a></div><blockquote>
<p>c</p>
</blockquote>
-<div class="myst-target">target = <code>a</code></div>
+<div class="myst-target"><a href="#a">(a)=</a></div>
.
Comment:
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 1
} | 0.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==21.4.0
exceptiongroup==1.2.2
iniconfig==2.1.0
markdown-it-py==1.1.0
-e git+https://github.com/executablebooks/mdit-py-plugins.git@bb061190339e6e2083e8c192ef8b089bece72c3f#egg=mdit_py_plugins
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
tomli==2.2.1
| name: mdit-py-plugins
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==21.4.0
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- markdown-it-py==1.1.0
- mdit-py-plugins==0.2.8
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/mdit-py-plugins
| [
"tests/test_myst_block.py::test_all[44-Target:-(a)=\\n-<div",
"tests/test_myst_block.py::test_all[51-Target",
"tests/test_myst_block.py::test_all[72-Indented",
"tests/test_myst_block.py::test_all[79-Target"
] | [] | [
"tests/test_amsmath.py::test_fixtures[1-equation",
"tests/test_amsmath.py::test_fixtures[14-equation*",
"tests/test_amsmath.py::test_fixtures[27-multline",
"tests/test_amsmath.py::test_fixtures[40-multline*",
"tests/test_amsmath.py::test_fixtures[53-gather",
"tests/test_amsmath.py::test_fixtures[66-gather*",
"tests/test_amsmath.py::test_fixtures[79-align",
"tests/test_amsmath.py::test_fixtures[92-align*",
"tests/test_amsmath.py::test_fixtures[105-alignat",
"tests/test_amsmath.py::test_fixtures[118-alignat*",
"tests/test_amsmath.py::test_fixtures[131-flalign",
"tests/test_amsmath.py::test_fixtures[144-flalign*",
"tests/test_amsmath.py::test_fixtures[157-equation",
"tests/test_amsmath.py::test_fixtures[174-equation",
"tests/test_amsmath.py::test_fixtures[191-`alignat`",
"tests/test_amsmath.py::test_fixtures[206-`alignat*`",
"tests/test_anchors.py::test_fixtures[1-basic",
"tests/test_anchors.py::test_fixtures[14-space:-#",
"tests/test_anchors.py::test_fixtures[21-characters:-#",
"tests/test_anchors.py::test_fixtures[28-emoji:-#",
"tests/test_anchors.py::test_fixtures[35-html",
"tests/test_anchors.py::test_fixtures[42-uniqueness:-#",
"tests/test_anchors.py::test_fixtures[53-standard",
"tests/test_anchors.py::test_fixtures[60-standard",
"tests/test_colon_fence.py::test_fixtures[4--:::\\n<\\n",
"tests/test_colon_fence.py::test_fixtures[18--::\\nfoo\\n::\\n-<p>::\\nfoo\\n::</p>\\n]",
"tests/test_colon_fence.py::test_fixtures[31--:::\\naaa\\n~~~\\n:::\\n-<pre><code>aaa\\n~~~\\n</code></pre>\\n]",
"tests/test_colon_fence.py::test_fixtures[45--:::\\naaa\\n```\\n:::\\n-<pre><code>aaa\\n```\\n</code></pre>\\n]",
"tests/test_colon_fence.py::test_fixtures[59--::::\\naaa\\n:::\\n::::::\\n-<pre><code>aaa\\n:::\\n</code></pre>\\n]",
"tests/test_colon_fence.py::test_fixtures[73--:::\\n-<pre><code></code></pre>\\n]",
"tests/test_colon_fence.py::test_fixtures[82--:::::\\n\\n:::\\naaa\\n-<pre><code>\\n:::\\naaa\\n</code></pre>\\n]",
"tests/test_colon_fence.py::test_fixtures[97-->",
"tests/test_colon_fence.py::test_fixtures[113--:::\\n\\n",
"tests/test_colon_fence.py::test_fixtures[127--:::\\n:::\\n-<pre><code></code></pre>\\n]",
"tests/test_colon_fence.py::test_fixtures[137--",
"tests/test_colon_fence.py::test_fixtures[151--",
"tests/test_colon_fence.py::test_fixtures[167--",
"tests/test_colon_fence.py::test_fixtures[183--",
"tests/test_colon_fence.py::test_fixtures[197--:::\\naaa\\n",
"tests/test_colon_fence.py::test_fixtures[209--",
"tests/test_colon_fence.py::test_fixtures[221--:::\\naaa\\n",
"tests/test_colon_fence.py::test_fixtures[234--:::",
"tests/test_colon_fence.py::test_fixtures[245--foo\\n:::\\nbar\\n:::\\nbaz\\n-<p>foo</p>\\n<pre><code>bar\\n</code></pre>\\n<p>baz</p>\\n]",
"tests/test_colon_fence.py::test_fixtures[261--:::ruby\\ndef",
"tests/test_colon_fence.py::test_fixtures[277--::::;\\n::::\\n-<pre><code",
"tests/test_colon_fence.py::test_fixtures[287--:::",
"tests/test_colon_fence.py::test_fixtures[298--:::\\n:::",
"tests/test_colon_fence.py::test_fixtures[312--:::\\n:::",
"tests/test_colon_fence.py::test_fixtures[323-Ending",
"tests/test_colon_fence.py::test_fixtures[333-Nested",
"tests/test_colon_fence.py::test_fixtures[347-Name",
"tests/test_colon_fence.py::test_fixtures[357-They",
"tests/test_colon_fence.py::test_fixtures[369-They",
"tests/test_colon_fence.py::test_fixtures[383-Or",
"tests/test_colon_fence.py::test_fixtures[399-List",
"tests/test_container.py::test_all[2-Simple",
"tests/test_container.py::test_all[13-Delimiters",
"tests/test_container.py::test_all[25-Could",
"tests/test_container.py::test_all[40-Ending",
"tests/test_container.py::test_all[52-Nested",
"tests/test_container.py::test_all[68-Incorrectly",
"tests/test_container.py::test_all[89-Marker",
"tests/test_container.py::test_all[103-But",
"tests/test_container.py::test_all[116-Some",
"tests/test_container.py::test_all[132-Name",
"tests/test_container.py::test_all[144-Or",
"tests/test_container.py::test_all[156-It",
"tests/test_container.py::test_all[168-But",
"tests/test_container.py::test_all[181-This",
"tests/test_container.py::test_all[193-Containers",
"tests/test_container.py::test_all[204-They",
"tests/test_container.py::test_all[218-They",
"tests/test_container.py::test_all[236-Or",
"tests/test_container.py::test_all[256-List",
"tests/test_deflist.py::test_all[3--Term",
"tests/test_deflist.py::test_all[33--Term",
"tests/test_deflist.py::test_all[53--Term",
"tests/test_deflist.py::test_all[72--Term",
"tests/test_deflist.py::test_all[92--Non-term",
"tests/test_deflist.py::test_all[107-List",
"tests/test_deflist.py::test_all[137-Regression",
"tests/test_deflist.py::test_all[160--#",
"tests/test_deflist.py::test_all[170--test\\n",
"tests/test_deflist.py::test_all[198-Regression",
"tests/test_deflist.py::test_all[213-Regression",
"tests/test_deflist.py::test_all[231-Coverage,",
"tests/test_deflist.py::test_all[240-Coverage,",
"tests/test_dollarmath.py::test_inline_func",
"tests/test_dollarmath.py::test_block_func",
"tests/test_dollarmath.py::test_dollarmath_fixtures[1-single",
"tests/test_dollarmath.py::test_dollarmath_fixtures[8-double-dollar-$$\\n-<p>$$</p>\\n]",
"tests/test_dollarmath.py::test_dollarmath_fixtures[15-single",
"tests/test_dollarmath.py::test_dollarmath_fixtures[22-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[29-simple",
"tests/test_dollarmath.py::test_dollarmath_fixtures[36-simple",
"tests/test_dollarmath.py::test_dollarmath_fixtures[43-equation",
"tests/test_dollarmath.py::test_dollarmath_fixtures[50-use",
"tests/test_dollarmath.py::test_dollarmath_fixtures[57-use",
"tests/test_dollarmath.py::test_dollarmath_fixtures[64-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[71-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[78-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[85-exponentiation",
"tests/test_dollarmath.py::test_dollarmath_fixtures[92-conjugate",
"tests/test_dollarmath.py::test_dollarmath_fixtures[99-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[108-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[118-single",
"tests/test_dollarmath.py::test_dollarmath_fixtures[127-display",
"tests/test_dollarmath.py::test_dollarmath_fixtures[136-display",
"tests/test_dollarmath.py::test_dollarmath_fixtures[146-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[158-underline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[168-after",
"tests/test_dollarmath.py::test_dollarmath_fixtures[179-following",
"tests/test_dollarmath.py::test_dollarmath_fixtures[186-consecutive",
"tests/test_dollarmath.py::test_dollarmath_fixtures[193-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[200-display",
"tests/test_dollarmath.py::test_dollarmath_fixtures[211-multiple",
"tests/test_dollarmath.py::test_dollarmath_fixtures[229-equation",
"tests/test_dollarmath.py::test_dollarmath_fixtures[248-multiline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[263-vector",
"tests/test_dollarmath.py::test_dollarmath_fixtures[276-display",
"tests/test_dollarmath.py::test_dollarmath_fixtures[286-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[293-equation",
"tests/test_dollarmath.py::test_dollarmath_fixtures[307-numbered",
"tests/test_dollarmath.py::test_dollarmath_fixtures[322-Equations",
"tests/test_dollarmath.py::test_dollarmath_fixtures[338-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[345-Sum",
"tests/test_dollarmath.py::test_dollarmath_fixtures[354-Sum",
"tests/test_dollarmath.py::test_dollarmath_fixtures[364-equation",
"tests/test_dollarmath.py::test_dollarmath_fixtures[378-inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[391-display",
"tests/test_dollarmath.py::test_dollarmath_fixtures[409-mixed",
"tests/test_dollarmath.py::test_dollarmath_fixtures[429-dollar",
"tests/test_dollarmath.py::test_dollarmath_fixtures[438-empty",
"tests/test_dollarmath.py::test_dollarmath_fixtures[448-or",
"tests/test_dollarmath.py::test_dollarmath_fixtures[459-new",
"tests/test_dollarmath.py::test_dollarmath_fixtures[468-math-escaping:",
"tests/test_dollarmath.py::test_dollarmath_fixtures[475-math-escaping:",
"tests/test_dollarmath.py::test_dollarmath_fixtures[482-math-escaping:",
"tests/test_dollarmath.py::test_dollarmath_fixtures[489-math-escaping:",
"tests/test_dollarmath.py::test_dollarmath_fixtures[496-math-escaping:",
"tests/test_dollarmath.py::test_dollarmath_fixtures[503-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[510-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[517-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[524-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[531-Inline",
"tests/test_dollarmath.py::test_dollarmath_fixtures[544-display",
"tests/test_footnote.py::test_footnote_def",
"tests/test_footnote.py::test_footnote_ref",
"tests/test_footnote.py::test_footnote_inline",
"tests/test_footnote.py::test_footnote_tail",
"tests/test_footnote.py::test_plugin_render",
"tests/test_footnote.py::test_all[2-Pandoc",
"tests/test_footnote.py::test_all[46--[^1][^2][^3]\\n\\n[^1]:",
"tests/test_footnote.py::test_all[69-They",
"tests/test_footnote.py::test_all[90--[^",
"tests/test_footnote.py::test_all[104--Here",
"tests/test_footnote.py::test_all[124--foo^[",
"tests/test_footnote.py::test_all[139-Duplicate",
"tests/test_footnote.py::test_all[157--[^xxxxx]",
"tests/test_footnote.py::test_all[182--[^xxxxx]",
"tests/test_footnote.py::test_all[203-Indents",
"tests/test_footnote.py::test_all[220-Security",
"tests/test_footnote.py::test_all[237-Security",
"tests/test_footnote.py::test_all[254-Should",
"tests/test_footnote.py::test_all[268-Nested",
"tests/test_footnote.py::test_all[302-Empty",
"tests/test_front_matter.py::test_all[2-should",
"tests/test_front_matter.py::test_all[13-should",
"tests/test_front_matter.py::test_all[24-should",
"tests/test_front_matter.py::test_all[35-should",
"tests/test_front_matter.py::test_all[50-should",
"tests/test_front_matter.py::test_all[65-should",
"tests/test_front_matter.py::test_all[77-should",
"tests/test_front_matter.py::test_token",
"tests/test_front_matter.py::test_short_source",
"tests/test_myst_block.py::test_all[2-Block",
"tests/test_myst_block.py::test_all[9-Block",
"tests/test_myst_block.py::test_all[16-Block",
"tests/test_myst_block.py::test_all[23-Block",
"tests/test_myst_block.py::test_all[58-Empty",
"tests/test_myst_block.py::test_all[65-Escaped",
"tests/test_myst_block.py::test_all[98-Comment:-%",
"tests/test_myst_block.py::test_all[105-Comment",
"tests/test_myst_block.py::test_all[124-Multiline",
"tests/test_myst_block.py::test_block_token",
"tests/test_myst_block.py::test_comment_token",
"tests/test_myst_role.py::test_basic",
"tests/test_myst_role.py::test_all[2-Basic:-{abc}`xyz`\\n-<p><code",
"tests/test_myst_role.py::test_all[9-Surrounding",
"tests/test_myst_role.py::test_all[16-In",
"tests/test_myst_role.py::test_all[24-Surrounding",
"tests/test_myst_role.py::test_all[31-In",
"tests/test_myst_role.py::test_all[40-In",
"tests/test_myst_role.py::test_all[49-Multiple",
"tests/test_myst_role.py::test_all[56-Unbalanced",
"tests/test_myst_role.py::test_all[63-Space",
"tests/test_myst_role.py::test_all[70-Escaped:-\\\\{abc}`xyz`\\n-<p>{abc}<code>xyz</code></p>\\n]",
"tests/test_substitution.py::test_fixtures[1-Basic",
"tests/test_substitution.py::test_fixtures[11-Basic",
"tests/test_substitution.py::test_fixtures[21-Same",
"tests/test_substitution.py::test_fixtures[28-No",
"tests/test_substitution.py::test_fixtures[41-Inside",
"tests/test_substitution.py::test_fixtures[54-New",
"tests/test_substitution.py::test_fixtures[63-Blocks:--",
"tests/test_substitution.py::test_fixtures[86-Inline:--",
"tests/test_substitution.py::test_fixtures[105-Tables:-|",
"tests/test_tasklists.py::test_all[3---",
"tests/test_tasklists.py::test_all[20---",
"tests/test_tasklists.py::test_all[44--#",
"tests/test_tasklists.py::test_all[94--1.",
"tests/test_texmath.py::test_inline_func",
"tests/test_texmath.py::test_block_func",
"tests/test_texmath.py::test_dollar_fixtures[1-single",
"tests/test_texmath.py::test_dollar_fixtures[8-inline",
"tests/test_texmath.py::test_dollar_fixtures[15-simple",
"tests/test_texmath.py::test_dollar_fixtures[22-simple",
"tests/test_texmath.py::test_dollar_fixtures[29-equation",
"tests/test_texmath.py::test_dollar_fixtures[36-use",
"tests/test_texmath.py::test_dollar_fixtures[43-use",
"tests/test_texmath.py::test_dollar_fixtures[50-inline",
"tests/test_texmath.py::test_dollar_fixtures[57-inline",
"tests/test_texmath.py::test_dollar_fixtures[64-inline",
"tests/test_texmath.py::test_dollar_fixtures[71-exponentiation",
"tests/test_texmath.py::test_dollar_fixtures[78-conjugate",
"tests/test_texmath.py::test_dollar_fixtures[85-Inline",
"tests/test_texmath.py::test_dollar_fixtures[94-Inline",
"tests/test_texmath.py::test_dollar_fixtures[104-single",
"tests/test_texmath.py::test_dollar_fixtures[113-display",
"tests/test_texmath.py::test_dollar_fixtures[122-inline",
"tests/test_texmath.py::test_dollar_fixtures[134-underline",
"tests/test_texmath.py::test_dollar_fixtures[144-after",
"tests/test_texmath.py::test_dollar_fixtures[155-following",
"tests/test_texmath.py::test_dollar_fixtures[162-consecutive",
"tests/test_texmath.py::test_dollar_fixtures[169-inline",
"tests/test_texmath.py::test_dollar_fixtures[176-display",
"tests/test_texmath.py::test_dollar_fixtures[189-multiple",
"tests/test_texmath.py::test_dollar_fixtures[211-equation",
"tests/test_texmath.py::test_dollar_fixtures[233-multiline",
"tests/test_texmath.py::test_dollar_fixtures[248-vector",
"tests/test_texmath.py::test_dollar_fixtures[261-display",
"tests/test_texmath.py::test_dollar_fixtures[270-inline",
"tests/test_texmath.py::test_dollar_fixtures[277-equation",
"tests/test_texmath.py::test_dollar_fixtures[291-numbered",
"tests/test_texmath.py::test_dollar_fixtures[305-Equations",
"tests/test_texmath.py::test_dollar_fixtures[321-Inline",
"tests/test_texmath.py::test_dollar_fixtures[328-Sum",
"tests/test_texmath.py::test_dollar_fixtures[337-Sum",
"tests/test_texmath.py::test_dollar_fixtures[346-equation",
"tests/test_texmath.py::test_dollar_fixtures[359-inline",
"tests/test_texmath.py::test_dollar_fixtures[372-display",
"tests/test_texmath.py::test_dollar_fixtures[389-mixed",
"tests/test_texmath.py::test_dollar_fixtures[410-dollar",
"tests/test_texmath.py::test_dollar_fixtures[419-empty",
"tests/test_texmath.py::test_dollar_fixtures[429-or",
"tests/test_texmath.py::test_bracket_fixtures[1-single",
"tests/test_texmath.py::test_bracket_fixtures[8-inline",
"tests/test_texmath.py::test_bracket_fixtures[15-simple",
"tests/test_texmath.py::test_bracket_fixtures[22-simple",
"tests/test_texmath.py::test_bracket_fixtures[29-equation",
"tests/test_texmath.py::test_bracket_fixtures[36-use",
"tests/test_texmath.py::test_bracket_fixtures[43-use",
"tests/test_texmath.py::test_bracket_fixtures[50-inline",
"tests/test_texmath.py::test_bracket_fixtures[57-inline",
"tests/test_texmath.py::test_bracket_fixtures[64-inline",
"tests/test_texmath.py::test_bracket_fixtures[71-exponentiation",
"tests/test_texmath.py::test_bracket_fixtures[78-conjugate",
"tests/test_texmath.py::test_bracket_fixtures[85-Inline",
"tests/test_texmath.py::test_bracket_fixtures[94-Inline",
"tests/test_texmath.py::test_bracket_fixtures[104-single",
"tests/test_texmath.py::test_bracket_fixtures[113-display",
"tests/test_texmath.py::test_bracket_fixtures[122-inline",
"tests/test_texmath.py::test_bracket_fixtures[134-underline",
"tests/test_texmath.py::test_bracket_fixtures[144-after",
"tests/test_texmath.py::test_bracket_fixtures[155-following",
"tests/test_texmath.py::test_bracket_fixtures[162-consecutive",
"tests/test_texmath.py::test_bracket_fixtures[169-inline",
"tests/test_texmath.py::test_bracket_fixtures[176-display",
"tests/test_texmath.py::test_bracket_fixtures[189-multiple",
"tests/test_texmath.py::test_bracket_fixtures[211-equation",
"tests/test_texmath.py::test_bracket_fixtures[233-multiline",
"tests/test_texmath.py::test_bracket_fixtures[248-vector",
"tests/test_texmath.py::test_bracket_fixtures[261-display",
"tests/test_texmath.py::test_bracket_fixtures[270-inline",
"tests/test_texmath.py::test_bracket_fixtures[277-equation",
"tests/test_texmath.py::test_bracket_fixtures[291-numbered",
"tests/test_texmath.py::test_bracket_fixtures[305-Equations",
"tests/test_texmath.py::test_bracket_fixtures[321-Inline",
"tests/test_texmath.py::test_bracket_fixtures[328-Sum",
"tests/test_texmath.py::test_bracket_fixtures[337-Sum",
"tests/test_texmath.py::test_bracket_fixtures[346-equation",
"tests/test_texmath.py::test_bracket_fixtures[359-inline",
"tests/test_texmath.py::test_bracket_fixtures[372-display",
"tests/test_wordcount.py::test_all[1-syntax",
"tests/test_wordcount.py::test_all[25-non-words-Geeksforgeeks,",
"tests/test_wordcount.py::test_all[35-lore"
] | [] | MIT License | 11,733 | 561 | [
"mdit_py_plugins/myst_blocks/index.py"
] |
ml31415__numpy-groupies-48 | fe49287542ef3a8c23a008bc8d351812c3265462 | 2021-12-02 17:09:09 | c11987005cccea1b3e990aba02ece482f3a00b1d | diff --git a/numpy_groupies/aggregate_numba.py b/numpy_groupies/aggregate_numba.py
index 7cbc441..3113fa0 100644
--- a/numpy_groupies/aggregate_numba.py
+++ b/numpy_groupies/aggregate_numba.py
@@ -38,8 +38,8 @@ class AggregateOp(object):
def __call__(self, group_idx, a, size=None, fill_value=0, order='C',
dtype=None, axis=None, ddof=0):
- iv = input_validation(group_idx, a, size=size, order=order, axis=axis, check_bounds=False)
- group_idx, a, flat_size, ndim_idx, size = iv
+ iv = input_validation(group_idx, a, size=size, order=order, axis=axis, check_bounds=False, func=self.func)
+ group_idx, a, flat_size, ndim_idx, size, unravel_shape = iv
# TODO: The typecheck should be done by the class itself, not by check_dtype
dtype = check_dtype(dtype, self.func, a, len(group_idx))
@@ -57,10 +57,13 @@ class AggregateOp(object):
self._finalize(ret, counter, fill_value)
if self.outer:
- return outer
+ ret = outer
# Deal with ndimensional indexing
if ndim_idx > 1:
+ if unravel_shape is not None:
+ # argreductions only
+ ret = np.unravel_index(ret, unravel_shape)[axis]
ret = ret.reshape(size, order=order)
return ret
@@ -192,7 +195,7 @@ class AggregateGeneric(AggregateOp):
def __call__(self, group_idx, a, size=None, fill_value=0, order='C',
dtype=None, axis=None, ddof=0):
iv = input_validation(group_idx, a, size=size, order=order, axis=axis, check_bounds=False)
- group_idx, a, flat_size, ndim_idx, size = iv
+ group_idx, a, flat_size, ndim_idx, size, _ = iv
# TODO: The typecheck should be done by the class itself, not by check_dtype
dtype = check_dtype(dtype, self.func, a, len(group_idx))
diff --git a/numpy_groupies/aggregate_numpy.py b/numpy_groupies/aggregate_numpy.py
index e5b6d72..af8f3dd 100644
--- a/numpy_groupies/aggregate_numpy.py
+++ b/numpy_groupies/aggregate_numpy.py
@@ -152,7 +152,7 @@ def _var(group_idx, a, size, fill_value, dtype=np.dtype(np.float64),
raise ValueError("cannot take variance with scalar a")
counts = np.bincount(group_idx, minlength=size)
sums = np.bincount(group_idx, weights=a, minlength=size)
- with np.errstate(divide='ignore'):
+ with np.errstate(divide='ignore', invalid='ignore'):
means = sums.astype(dtype) / counts
ret = np.bincount(group_idx, (a - means[group_idx]) ** 2,
minlength=size) / (counts - ddof)
@@ -253,8 +253,9 @@ _impl_dict.update(('nan' + k, v) for k, v in list(_impl_dict.items())
def _aggregate_base(group_idx, a, func='sum', size=None, fill_value=0,
order='C', dtype=None, axis=None, _impl_dict=_impl_dict,
_nansqueeze=False, cache=None, **kwargs):
- group_idx, a, flat_size, ndim_idx, size = input_validation(group_idx, a,
- size=size, order=order, axis=axis)
+ group_idx, a, flat_size, ndim_idx, size, unravel_shape = input_validation(group_idx, a,
+ size=size, order=order, axis=axis, func=func)
+
if group_idx.dtype == np.dtype("uint64"):
# Force conversion to signed int, to avoid issues with bincount etc later
group_idx = group_idx.astype(int)
@@ -282,6 +283,8 @@ def _aggregate_base(group_idx, a, func='sum', size=None, fill_value=0,
# deal with ndimensional indexing
if ndim_idx > 1:
+ if unravel_shape is not None:
+ ret = np.unravel_index(ret, unravel_shape)[axis]
ret = ret.reshape(size, order=order)
return ret
diff --git a/numpy_groupies/utils_numpy.py b/numpy_groupies/utils_numpy.py
index a15945b..41ec2c9 100644
--- a/numpy_groupies/utils_numpy.py
+++ b/numpy_groupies/utils_numpy.py
@@ -236,7 +236,7 @@ def offset_labels(group_idx, inshape, axis, order, size):
def input_validation(group_idx, a, size=None, order='C', axis=None,
- ravel_group_idx=True, check_bounds=True, method="ravel"):
+ ravel_group_idx=True, check_bounds=True, method="ravel", func=None):
""" Do some fairly extensive checking of group_idx and a, trying to
give the user as much help as possible with what is wrong. Also,
convert ndim-indexing to 1d indexing.
@@ -276,10 +276,18 @@ def input_validation(group_idx, a, size=None, order='C', axis=None,
raise NotImplementedError("when using axis arg, size must be"
"None or scalar.")
else:
+ is_form_3 = group_idx.ndim == 1 and a.ndim > 1 and axis is not None
+ orig_shape = a.shape if is_form_3 else group_idx.shape
+ if "arg" in func:
+ unravel_shape = orig_shape
+ else:
+ unravel_shape = None
+
group_idx, size = _ravel_group_idx(group_idx, a, axis, size, order, method=method)
flat_size = np.prod(size)
ndim_idx = ndim_a
- return group_idx.ravel(), a.ravel(), flat_size, ndim_idx, size
+ size = orig_shape if is_form_3 and not callable(func) and "cum" in func else size
+ return group_idx.ravel(), a.ravel(), flat_size, ndim_idx, size, unravel_shape
if ndim_idx == 1:
if size is None:
@@ -310,7 +318,7 @@ def input_validation(group_idx, a, size=None, order='C', axis=None,
raise ValueError("group_idx and a must be of the same length, or a"
" can be scalar")
- return group_idx, a, flat_size, ndim_idx, size
+ return group_idx, a, flat_size, ndim_idx, size, None
### General tools ###
| bug with argmax and nd array
``` python
from numpy_groupies.aggregate_numpy import aggregate
import numpy as np
labels = np.array([0, 0, 2, 2, 2, 1, 1, 2, 2, 1, 1, 0], dtype=int)
array = np.array([[1] * 12, [1] * 12])
aggregate(labels, array, axis=-1, func="argmax")
```
gives
```
array([[ 0, 5, 2],
[12, 17, 14]])
```
The real answer is
```
array([[0, 5, 2],
[0, 5, 2]])
```
so it looks like a `ravel_multi_index` is missing. | ml31415/numpy-groupies | diff --git a/numpy_groupies/tests/__init__.py b/numpy_groupies/tests/__init__.py
index 3ed1972..9b69489 100644
--- a/numpy_groupies/tests/__init__.py
+++ b/numpy_groupies/tests/__init__.py
@@ -53,3 +53,8 @@ def _wrap_notimplemented_xfail(impl, name=None):
else:
_try_xfail.__name__ = impl.__name__
return _try_xfail
+
+
+func_list = ('sum', 'prod', 'min', 'max', 'all', 'any', 'mean', 'std', 'var', 'len',
+ 'argmin', 'argmax', 'anynan', 'allnan', 'cumsum',
+ 'nansum', 'nanprod', 'nanmin', 'nanmax', 'nanmean', 'nanstd', 'nanvar','nanlen')
diff --git a/numpy_groupies/tests/test_compare.py b/numpy_groupies/tests/test_compare.py
index e0d9d2d..27514a5 100644
--- a/numpy_groupies/tests/test_compare.py
+++ b/numpy_groupies/tests/test_compare.py
@@ -10,7 +10,7 @@ import pytest
from . import (aggregate_purepy, aggregate_numpy_ufunc, aggregate_numpy,
aggregate_weave, aggregate_numba, aggregate_pandas,
- _wrap_notimplemented_xfail, _impl_name)
+ _wrap_notimplemented_xfail, _impl_name, func_list)
class AttrDict(dict):
__getattr__ = dict.__getitem__
@@ -71,13 +71,6 @@ def func_preserve_order(iterator):
for i, x in enumerate(iterator, 1):
tmp += x ** i
return tmp
-
-
-func_list = ('sum', 'prod', 'min', 'max', 'all', 'any', 'mean', 'std', 'var', 'len',
- 'argmin', 'argmax', 'anynan', 'allnan', 'cumsum', func_arbitrary, func_preserve_order,
- 'nansum', 'nanprod', 'nanmin', 'nanmax', 'nanmean', 'nanstd', 'nanvar','nanlen')
-
-
@pytest.mark.parametrize(["func", "fill_value"], product(func_list, [0, 1, np.nan]),
ids=lambda x: getattr(x, '__name__', x))
def test_cmp(aggregate_cmp, func, fill_value, decimal=10):
diff --git a/numpy_groupies/tests/test_generic.py b/numpy_groupies/tests/test_generic.py
index cc201d5..3b27db9 100644
--- a/numpy_groupies/tests/test_generic.py
+++ b/numpy_groupies/tests/test_generic.py
@@ -4,7 +4,7 @@ import itertools
import numpy as np
import pytest
-from . import _implementations, _impl_name, _wrap_notimplemented_xfail
+from . import _implementations, _impl_name, _wrap_notimplemented_xfail, func_list
@pytest.fixture(params=_implementations, ids=_impl_name)
@@ -294,3 +294,69 @@ def test_sort(aggregate_all, order):
res = aggregate_all(group_idx, a, func="sort", reverse=reverse)
np.testing.assert_array_equal(res, ref)
+
+
[email protected]("axis", (0, 1))
[email protected]("size", ((12,), (12, 5)))
[email protected]("func", func_list)
+def test_agg_along_axis(aggregate_all, size, func, axis):
+ if len(size) == axis:
+ pytest.skip()
+
+ group_idx = np.zeros(size[axis], dtype=int)
+ array = np.random.randn(*size)
+
+ # add some NaNs to test out nan-skipping
+ if "nan" in func and "nanarg" not in func:
+ array[[1, 4, 5], ...] = np.nan
+ elif "nanarg" in func and array.ndim > 1:
+ array[[1, 4, 5], 1] = np.nan
+ if func in ["any", "all"]:
+ array = array > 0.5
+
+ # construct expected values for all cases
+ if func == "len":
+ expected = np.array(size[axis])
+ elif func == "nanlen":
+ expected = np.array((~np.isnan(array)).sum(axis=axis))
+ elif func == "anynan":
+ expected = np.isnan(array).any(axis=axis)
+ elif func == "allnan":
+ expected = np.isnan(array).all(axis=axis)
+ else:
+ with np.errstate(invalid="ignore", divide="ignore"):
+ expected = getattr(np, func)(array, axis=axis)
+
+ # The default fill_value is 0, the following makes the output
+ # match numpy
+ fill_values = {
+ "nanprod": 1,
+ "nanvar": np.nan,
+ "nanstd": np.nan,
+ "nanmax": np.nan,
+ "nanmin": np.nan,
+ "nanmean": np.nan,
+ }
+
+ # TODO: These xfails need to be fixed...
+ if len(size) > 1:
+ if func == "allnan":
+ # This only fails for numba
+ pytest.xfail()
+
+ actual = aggregate_all(
+ group_idx, array, axis=axis, func=func, fill_value=fill_values.get(func, 0)
+ )
+ assert actual.ndim == array.ndim
+
+ # argmin, argmax don't support keepdims so we can't use that to construct expected
+ # instead we squeeze out the extra dims in actual.
+ np.testing.assert_allclose(actual.squeeze(), expected)
+
+def test_argreduction_nD_array_1D_idx(aggregate_all):
+ # regression test for GH41
+ labels = np.array([0, 0, 2, 2, 2, 1, 1, 2, 2, 1, 1, 0], dtype=int)
+ array = np.array([[1] * 12, [1] * 12])
+ actual = aggregate_all(labels, array, axis=-1, func="argmax")
+ expected = np.array([[0, 5, 2], [0, 5, 2]])
+ np.testing.assert_equal(actual, expected)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 3
} | 0.9 | {
"env_vars": null,
"env_yml_path": [
"ci/environment.yml"
],
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "environment.yml",
"pip_packages": null,
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1733218098505/work
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
iniconfig @ file:///home/conda/feedstock_root/build_artifacts/iniconfig_1733223141826/work
llvmlite==0.43.0
numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1718888028049/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1732314280888/work/dist/numpy-2.0.2-cp39-cp39-linux_x86_64.whl#sha256=62d98eb3da9f13e6b227c430d01026b7427f341b3fdcb838430f2a9e520417b1
-e git+https://github.com/ml31415/numpy-groupies.git@fe49287542ef3a8c23a008bc8d351812c3265462#egg=numpy_groupies
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas @ file:///home/conda/feedstock_root/build_artifacts/pandas_1736810577256/work
pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1733222765875/work
pytest @ file:///home/conda/feedstock_root/build_artifacts/pytest_1740946542080/work
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1706886791323/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1733256695513/work
tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1742745135198/work
| name: numpy-groupies
channels:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=conda_forge
- _openmp_mutex=4.5=2_gnu
- bzip2=1.0.8=h4bc722e_7
- ca-certificates=2025.1.31=hbcca054_0
- colorama=0.4.6=pyhd8ed1ab_1
- exceptiongroup=1.2.2=pyhd8ed1ab_1
- iniconfig=2.0.0=pyhd8ed1ab_1
- ld_impl_linux-64=2.43=h712a8e2_4
- libblas=3.9.0=31_h59b9bed_openblas
- libcblas=3.9.0=31_he106b2a_openblas
- libffi=3.4.6=h2dba641_0
- libgcc=14.2.0=h767d61c_2
- libgcc-ng=14.2.0=h69a702a_2
- libgfortran=14.2.0=h69a702a_2
- libgfortran5=14.2.0=hf1ad2bd_2
- libgomp=14.2.0=h767d61c_2
- liblapack=3.9.0=31_h7ac8fdf_openblas
- libllvm14=14.0.6=hcd5def8_4
- liblzma=5.6.4=hb9d3cd8_0
- libnsl=2.0.1=hd590300_0
- libopenblas=0.3.29=pthreads_h94d23a6_0
- libsqlite=3.49.1=hee588c1_2
- libstdcxx=14.2.0=h8f9b012_2
- libstdcxx-ng=14.2.0=h4852527_2
- libuuid=2.38.1=h0b41bf4_0
- libxcrypt=4.4.36=hd590300_1
- libzlib=1.3.1=hb9d3cd8_2
- llvmlite=0.43.0=py39hf8b6b1a_1
- ncurses=6.5=h2d0b736_3
- numba=0.60.0=py39h0320e7d_0
- numpy=2.0.2=py39h9cb892a_1
- openssl=3.4.1=h7b32b05_0
- packaging=24.2=pyhd8ed1ab_2
- pandas=2.2.3=py39h3b40f6f_2
- pip=25.0.1=pyh8b19718_0
- pluggy=1.5.0=pyhd8ed1ab_1
- pytest=8.3.5=pyhd8ed1ab_0
- python=3.9.21=h9c0c6dc_1_cpython
- python-dateutil=2.9.0.post0=pyhff2d567_1
- python-tzdata=2025.2=pyhd8ed1ab_0
- python_abi=3.9=5_cp39
- pytz=2024.1=pyhd8ed1ab_0
- readline=8.2=h8c095d6_2
- setuptools=75.8.2=pyhff2d567_0
- six=1.17.0=pyhd8ed1ab_0
- tk=8.6.13=noxft_h4845f30_101
- tomli=2.2.1=pyhd8ed1ab_1
- tzdata=2025b=h78e105d_0
- wheel=0.45.1=pyhd8ed1ab_1
prefix: /opt/conda/envs/numpy-groupies
| [
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-argmin-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-argmin-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-argmax-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-argmax-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-cumsum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-cumsum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-argmin-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-argmin-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-argmax-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-argmax-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-cumsum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-cumsum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-argmin-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-argmin-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-argmax-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-argmax-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-cumsum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-cumsum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_argreduction_nD_array_1D_idx[numpy]",
"numpy_groupies/tests/test_generic.py::test_argreduction_nD_array_1D_idx[numba]",
"numpy_groupies/tests/test_generic.py::test_argreduction_nD_array_1D_idx[pandas]"
] | [] | [
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-sum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-sum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-sum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-prod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-prod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-prod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-min-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-min-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-min-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-max-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-max-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-max-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-all-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-all-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-any-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-any-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-mean-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-mean-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-mean-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-std-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-std-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-std-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-var-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-var-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-var-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-len-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-len-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-argmin-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-argmin-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-argmax-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-argmax-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-anynan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-anynan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-allnan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-allnan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nansum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nansum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nansum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanprod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanprod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanprod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmin-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmin-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmin-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmax-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmax-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmax-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmean-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmean-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanmean-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanstd-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanstd-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanstd-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanvar-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanvar-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanvar-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanlen-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[np/py-nanlen-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-sum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-sum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-sum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-prod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-prod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-prod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-min-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-min-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-min-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-max-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-max-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-max-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-all-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-all-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-all-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-any-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-any-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-any-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-len-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-len-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-len-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-anynan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-anynan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-anynan-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-allnan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-allnan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[ufunc/np-allnan-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[ufunc/np-2-C]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[ufunc/np-2-F]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[ufunc/np-3-C]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[ufunc/np-3-F]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-sum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-sum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-sum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-prod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-prod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-prod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-min-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-min-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-min-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-max-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-max-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-max-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-all-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-all-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-all-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-any-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-any-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-any-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-mean-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-mean-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-mean-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-std-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-std-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-std-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-var-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-var-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-var-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-len-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-len-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-len-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-argmin-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-argmin-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-argmin-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-argmax-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-argmax-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-argmax-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-anynan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-anynan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-anynan-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-allnan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-allnan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-allnan-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-cumsum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-cumsum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-cumsum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nansum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nansum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nansum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanprod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanprod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanprod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmin-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmin-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmin-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmax-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmax-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmax-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmean-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmean-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanmean-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanstd-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanstd-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanstd-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanvar-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanvar-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanvar-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanlen-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanlen-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[numba/np-nanlen-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[numba/np-2-C]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[numba/np-2-F]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[numba/np-3-C]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[numba/np-3-F]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-sum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-sum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-sum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-prod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-prod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-prod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-min-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-min-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-min-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-max-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-max-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-max-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-all-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-all-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-all-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-any-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-any-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-any-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-mean-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-mean-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-mean-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-std-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-std-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-std-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-var-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-var-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-var-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-len-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-len-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-len-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-argmin-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-argmin-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-argmin-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-argmax-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-argmax-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-argmax-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-anynan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-anynan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-anynan-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-allnan-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-allnan-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-allnan-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-cumsum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-cumsum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-cumsum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nansum-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nansum-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nansum-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanprod-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanprod-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanprod-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmin-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmin-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmin-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmax-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmax-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmax-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmean-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmean-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanmean-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanstd-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanstd-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanstd-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanvar-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanvar-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanvar-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanlen-0]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanlen-1]",
"numpy_groupies/tests/test_compare.py::test_cmp[pandas/np-nanlen-nan]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[pandas/np-2-C]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[pandas/np-2-F]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[pandas/np-3-C]",
"numpy_groupies/tests/test_compare.py::test_cmp_ndim[pandas/np-3-F]",
"numpy_groupies/tests/test_generic.py::test_preserve_missing[purepy]",
"numpy_groupies/tests/test_generic.py::test_preserve_missing[ufunc]",
"numpy_groupies/tests/test_generic.py::test_preserve_missing[numpy]",
"numpy_groupies/tests/test_generic.py::test_preserve_missing[numba]",
"numpy_groupies/tests/test_generic.py::test_preserve_missing[pandas]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[purepy-int]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[purepy-uint32]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[purepy-uint64]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[ufunc-int]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[ufunc-uint32]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[ufunc-uint64]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[numpy-int]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[numpy-uint32]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[numpy-uint64]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[numba-int]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[numba-uint32]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[numba-uint64]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[pandas-int]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[pandas-uint32]",
"numpy_groupies/tests/test_generic.py::test_uint_group_idx[pandas-uint64]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset[purepy]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset[ufunc]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset[numpy]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset[numba]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset[pandas]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[purepy-std]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[purepy-var]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[purepy-mean]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[numpy-std]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[numpy-var]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[numpy-mean]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[numba-std]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[numba-var]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[numba-mean]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[pandas-std]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[pandas-var]",
"numpy_groupies/tests/test_generic.py::test_float_enforcement[pandas-mean]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset_prod[purepy]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset_prod[ufunc]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset_prod[numpy]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset_prod[numba]",
"numpy_groupies/tests/test_generic.py::test_start_with_offset_prod[pandas]",
"numpy_groupies/tests/test_generic.py::test_no_negative_indices[purepy]",
"numpy_groupies/tests/test_generic.py::test_no_negative_indices[ufunc]",
"numpy_groupies/tests/test_generic.py::test_no_negative_indices[numpy]",
"numpy_groupies/tests/test_generic.py::test_no_negative_indices[numba]",
"numpy_groupies/tests/test_generic.py::test_no_negative_indices[pandas]",
"numpy_groupies/tests/test_generic.py::test_parameter_missing[purepy]",
"numpy_groupies/tests/test_generic.py::test_parameter_missing[ufunc]",
"numpy_groupies/tests/test_generic.py::test_parameter_missing[numpy]",
"numpy_groupies/tests/test_generic.py::test_parameter_missing[numba]",
"numpy_groupies/tests/test_generic.py::test_parameter_missing[pandas]",
"numpy_groupies/tests/test_generic.py::test_shape_mismatch[purepy]",
"numpy_groupies/tests/test_generic.py::test_shape_mismatch[ufunc]",
"numpy_groupies/tests/test_generic.py::test_shape_mismatch[numpy]",
"numpy_groupies/tests/test_generic.py::test_shape_mismatch[numba]",
"numpy_groupies/tests/test_generic.py::test_shape_mismatch[pandas]",
"numpy_groupies/tests/test_generic.py::test_create_lists[purepy]",
"numpy_groupies/tests/test_generic.py::test_create_lists[numpy]",
"numpy_groupies/tests/test_generic.py::test_item_counting[purepy]",
"numpy_groupies/tests/test_generic.py::test_item_counting[numpy]",
"numpy_groupies/tests/test_generic.py::test_item_counting[numba]",
"numpy_groupies/tests/test_generic.py::test_item_counting[pandas]",
"numpy_groupies/tests/test_generic.py::test_fill_value[purepy-array]",
"numpy_groupies/tests/test_generic.py::test_fill_value[purepy-sum]",
"numpy_groupies/tests/test_generic.py::test_fill_value[ufunc-sum]",
"numpy_groupies/tests/test_generic.py::test_fill_value[numpy-array]",
"numpy_groupies/tests/test_generic.py::test_fill_value[numpy-sum]",
"numpy_groupies/tests/test_generic.py::test_fill_value[numba-sum]",
"numpy_groupies/tests/test_generic.py::test_fill_value[pandas-sum]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[purepy-C]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[purepy-F]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[ufunc-C]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[ufunc-F]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[numpy-C]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[numpy-F]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[numba-C]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[numba-F]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[pandas-C]",
"numpy_groupies/tests/test_generic.py::test_array_ordering[pandas-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[ufunc-None]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[ufunc-size1]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[numpy-None]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[numpy-size1]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[numba-None]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[numba-size1]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[pandas-None]",
"numpy_groupies/tests/test_generic.py::test_ndim_group_idx[pandas-size1]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[ufunc-1-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[ufunc-1-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[ufunc-2-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[ufunc-2-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[ufunc-3-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[ufunc-3-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numpy-1-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numpy-1-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numpy-2-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numpy-2-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numpy-3-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numpy-3-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numba-1-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numba-1-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numba-2-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numba-2-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numba-3-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[numba-3-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[pandas-1-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[pandas-1-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[pandas-2-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[pandas-2-F]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[pandas-3-C]",
"numpy_groupies/tests/test_generic.py::test_ndim_indexing[pandas-3-F]",
"numpy_groupies/tests/test_generic.py::test_len[purepy]",
"numpy_groupies/tests/test_generic.py::test_len[ufunc]",
"numpy_groupies/tests/test_generic.py::test_len[numpy]",
"numpy_groupies/tests/test_generic.py::test_len[numba]",
"numpy_groupies/tests/test_generic.py::test_len[pandas]",
"numpy_groupies/tests/test_generic.py::test_nan_len[purepy]",
"numpy_groupies/tests/test_generic.py::test_nan_len[numpy]",
"numpy_groupies/tests/test_generic.py::test_nan_len[numba]",
"numpy_groupies/tests/test_generic.py::test_nan_len[pandas]",
"numpy_groupies/tests/test_generic.py::test_first_last[purepy-first]",
"numpy_groupies/tests/test_generic.py::test_first_last[purepy-last]",
"numpy_groupies/tests/test_generic.py::test_first_last[numpy-first]",
"numpy_groupies/tests/test_generic.py::test_first_last[numpy-last]",
"numpy_groupies/tests/test_generic.py::test_first_last[numba-first]",
"numpy_groupies/tests/test_generic.py::test_first_last[numba-last]",
"numpy_groupies/tests/test_generic.py::test_first_last[pandas-first]",
"numpy_groupies/tests/test_generic.py::test_first_last[pandas-last]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[purepy-nanfirst-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[purepy-nanfirst-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[purepy-nanfirst-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[purepy-nanlast-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[purepy-nanlast-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[purepy-nanlast-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numpy-nanfirst-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numpy-nanfirst-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numpy-nanfirst-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numpy-nanlast-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numpy-nanlast-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numpy-nanlast-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numba-nanfirst-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numba-nanfirst-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numba-nanfirst-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numba-nanlast-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numba-nanlast-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[numba-nanlast-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[pandas-nanfirst-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[pandas-nanfirst-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[pandas-nanfirst-4]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[pandas-nanlast-0]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[pandas-nanlast-2]",
"numpy_groupies/tests/test_generic.py::test_nan_first_last[pandas-nanlast-4]",
"numpy_groupies/tests/test_generic.py::test_ddof[purepy-var-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[purepy-var-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[purepy-var-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[purepy-std-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[purepy-std-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[purepy-std-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[numpy-var-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[numpy-var-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[numpy-var-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[numpy-std-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[numpy-std-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[numpy-std-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[numba-var-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[numba-var-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[numba-var-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[numba-std-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[numba-std-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[numba-std-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[pandas-var-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[pandas-var-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[pandas-var-2]",
"numpy_groupies/tests/test_generic.py::test_ddof[pandas-std-0]",
"numpy_groupies/tests/test_generic.py::test_ddof[pandas-std-1]",
"numpy_groupies/tests/test_generic.py::test_ddof[pandas-std-2]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[purepy-sum]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[purepy-prod]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[purepy-mean]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[purepy-var]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[purepy-std]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[ufunc-sum]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[ufunc-prod]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numpy-sum]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numpy-prod]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numpy-mean]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numpy-var]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numpy-std]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numba-sum]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numba-prod]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numba-mean]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numba-var]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[numba-std]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[pandas-sum]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[pandas-prod]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[pandas-mean]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[pandas-var]",
"numpy_groupies/tests/test_generic.py::test_scalar_input[pandas-std]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-sum]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-prod]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-mean]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-var]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-std]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-all]",
"numpy_groupies/tests/test_generic.py::test_nan_input[purepy-any]",
"numpy_groupies/tests/test_generic.py::test_nan_input[ufunc-sum]",
"numpy_groupies/tests/test_generic.py::test_nan_input[ufunc-prod]",
"numpy_groupies/tests/test_generic.py::test_nan_input[ufunc-all]",
"numpy_groupies/tests/test_generic.py::test_nan_input[ufunc-any]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-sum]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-prod]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-mean]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-var]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-std]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-all]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numpy-any]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-sum]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-prod]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-mean]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-var]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-std]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-all]",
"numpy_groupies/tests/test_generic.py::test_nan_input[numba-any]",
"numpy_groupies/tests/test_generic.py::test_nan_input_len[purepy]",
"numpy_groupies/tests/test_generic.py::test_nan_input_len[ufunc]",
"numpy_groupies/tests/test_generic.py::test_nan_input_len[numpy]",
"numpy_groupies/tests/test_generic.py::test_nan_input_len[numba]",
"numpy_groupies/tests/test_generic.py::test_argmin_argmax[purepy]",
"numpy_groupies/tests/test_generic.py::test_argmin_argmax[numpy]",
"numpy_groupies/tests/test_generic.py::test_argmin_argmax[numba]",
"numpy_groupies/tests/test_generic.py::test_argmin_argmax[pandas]",
"numpy_groupies/tests/test_generic.py::test_mean[purepy]",
"numpy_groupies/tests/test_generic.py::test_mean[numpy]",
"numpy_groupies/tests/test_generic.py::test_mean[numba]",
"numpy_groupies/tests/test_generic.py::test_mean[pandas]",
"numpy_groupies/tests/test_generic.py::test_cumsum[numpy]",
"numpy_groupies/tests/test_generic.py::test_cumsum[numba]",
"numpy_groupies/tests/test_generic.py::test_cumsum[pandas]",
"numpy_groupies/tests/test_generic.py::test_cummax[numba]",
"numpy_groupies/tests/test_generic.py::test_cummax[pandas]",
"numpy_groupies/tests/test_generic.py::test_list_ordering[purepy-normal]",
"numpy_groupies/tests/test_generic.py::test_list_ordering[purepy-reverse]",
"numpy_groupies/tests/test_generic.py::test_list_ordering[numpy-normal]",
"numpy_groupies/tests/test_generic.py::test_list_ordering[numpy-reverse]",
"numpy_groupies/tests/test_generic.py::test_sort[purepy-normal]",
"numpy_groupies/tests/test_generic.py::test_sort[purepy-reverse]",
"numpy_groupies/tests/test_generic.py::test_sort[numpy-normal]",
"numpy_groupies/tests/test_generic.py::test_sort[numpy-reverse]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-sum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-sum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-sum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-prod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-prod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-prod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-min-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-min-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-min-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-max-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-max-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-max-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-all-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-all-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-all-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-any-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-any-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-any-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-len-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-len-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-len-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-anynan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-anynan-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-anynan-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[ufunc-allnan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-sum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-sum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-sum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-prod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-prod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-prod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-min-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-min-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-min-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-max-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-max-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-max-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-all-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-all-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-all-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-any-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-any-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-any-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-mean-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-mean-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-mean-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-std-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-std-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-std-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-var-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-var-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-var-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-len-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-len-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-len-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-argmin-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-argmax-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-anynan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-anynan-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-anynan-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-allnan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-cumsum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nansum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nansum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nansum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanprod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanprod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanprod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmin-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmin-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmin-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmax-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmax-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmax-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmean-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmean-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanmean-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanstd-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanstd-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanstd-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanvar-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanvar-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanvar-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanlen-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanlen-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numpy-nanlen-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-sum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-sum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-sum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-prod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-prod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-prod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-min-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-min-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-min-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-max-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-max-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-max-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-all-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-all-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-all-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-any-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-any-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-any-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-mean-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-mean-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-mean-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-std-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-std-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-std-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-var-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-var-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-var-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-len-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-len-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-len-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-argmin-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-argmax-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-anynan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-anynan-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-anynan-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-allnan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-cumsum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nansum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nansum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nansum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanprod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanprod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanprod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmin-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmin-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmin-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmax-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmax-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmax-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmean-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmean-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanmean-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanstd-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanstd-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanstd-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanvar-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanvar-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanvar-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanlen-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanlen-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[numba-nanlen-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-sum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-sum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-sum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-prod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-prod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-prod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-min-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-min-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-min-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-max-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-max-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-max-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-all-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-all-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-all-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-any-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-any-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-any-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-mean-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-mean-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-mean-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-std-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-std-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-std-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-var-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-var-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-var-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-len-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-len-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-len-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-argmin-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-argmax-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-anynan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-anynan-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-anynan-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-allnan-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-cumsum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nansum-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nansum-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nansum-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanprod-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanprod-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanprod-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmin-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmin-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmin-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmax-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmax-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmax-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmean-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmean-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanmean-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanstd-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanstd-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanstd-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanvar-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanvar-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanvar-size1-1]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanlen-size0-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanlen-size1-0]",
"numpy_groupies/tests/test_generic.py::test_agg_along_axis[pandas-nanlen-size1-1]"
] | [] | BSD 2-Clause "Simplified" License | 11,736 | 1,573 | [
"numpy_groupies/aggregate_numba.py",
"numpy_groupies/aggregate_numpy.py",
"numpy_groupies/utils_numpy.py"
] |
|
frictionlessdata__frictionless-py-952 | 1b5a274bba5b736d1d7c4fc4a3eb62e64f56d1c0 | 2021-12-02 18:13:59 | a05cf3f9b28869085130533babaf8f63a9f269d4 | roll: Thanks, @didiez, good catch!
Can you please add a simple test highlighting the bug? Also, are you interested in improving the error message at https://github.com/frictionlessdata/frictionless-py/blob/main/frictionless/resource.py#L978? We can do it in this PR to fully resolve #951
didiez: Sure, tests added :+1:
However, while I was adding the `cells` attribute checking to the existing foreign key tests, I have noticed that the values found in the report for the `None` (empty) cells were the string `"None"`. Is there any reason to cast every cell to string?
Should we replace the current `cells=list(map(str, row.values()))` by `cells=row.cells` to preserve the cell types and the `None` values?
https://github.com/frictionlessdata/frictionless-py/blob/1b5a274bba5b736d1d7c4fc4a3eb62e64f56d1c0/frictionless/errors/row.py#L45
This also applies to `CellError.from_row(..)`
https://github.com/frictionlessdata/frictionless-py/blob/1b5a274bba5b736d1d7c4fc4a3eb62e64f56d1c0/frictionless/errors/cell.py#L78
roll: @didiez
I would replace "None" by "". In general, the idea of cells being strings is that clients are able to show the row without handling data types but I need to review this approach. Maybe using `row.to_list(json=True)`... But I need to create a breaking release for changes like this
didiez: The `""` (empty) string sounds good to fix this without breaking things in a bugfix release.
As of today, we didn't need cells with types in the report, but could be useful in some scenarios.
didiez: @roll Should we also fix the "None" from `CellError.from_row(..)` in this PR or better to open a new one?
roll: @didiez
Using this one is fine I think. Can you please also add the change check for this to the tests?
roll: @didiez
row.cells is needed to provide an original cells information. Sorry for being slightly out of the context. Can the fk bug be somewhere else?
didiez: > @didiez row.cells is needed to provide an original cells information. Sorry for being slightly out of the context.
I am not sure I'm following. Should we use `row.values()` or `row.cells` when creating the errors? The last revert was just to keep the old behaviour of CellError/RowError.from_row. However, in `fragments/row.py` the value passed to the error is `cells`.
> Can the fk bug be somewhere else?
I did a quick search and I think this bug (shows headers as row values) was only present for `RowError` when using `from_row` method (also in every subclass)
roll: @didiez
I did a quick analysis and I think we need to use `cells=list(map(to_str, row.cells))` in the both `from_row` calls. The idea of the `errors.cells` is to provide original row cells while `row.values()` will return a cleaned version. Sorry for misleading you
roll: So I think the problems we solve:
- https://github.com/frictionlessdata/frictionless-py/blob/main/frictionless/errors/row.py#L45
- https://github.com/frictionlessdata/frictionless-py/blob/main/frictionless/errors/cell.py#L78
- and inappropriate stringification for `None` (solved by your `to_str`) | diff --git a/frictionless/errors/cell.py b/frictionless/errors/cell.py
index b6dad8f0..c8455e4d 100644
--- a/frictionless/errors/cell.py
+++ b/frictionless/errors/cell.py
@@ -73,9 +73,10 @@ class CellError(RowError):
if field_name == name:
cell = row[field_name]
field_position = row.field_positions[field_number - 1]
+ to_str = lambda v: str(v) if v is not None else ""
return cls(
note=note,
- cells=list(map(str, row.values())),
+ cells=list(map(to_str, row.cells)),
row_number=row.row_number,
row_position=row.row_position,
cell=str(cell),
diff --git a/frictionless/errors/row.py b/frictionless/errors/row.py
index b377d72c..cbb975f0 100644
--- a/frictionless/errors/row.py
+++ b/frictionless/errors/row.py
@@ -40,9 +40,10 @@ class RowError(TableError):
Returns:
RowError: error
"""
+ to_str = lambda v: str(v) if v is not None else ""
return cls(
note=note,
- cells=list(map(str, row)),
+ cells=list(map(to_str, row.cells)),
row_number=row.row_number,
row_position=row.row_position,
)
diff --git a/frictionless/row.py b/frictionless/row.py
index 4e5c64c4..ae2e6140 100644
--- a/frictionless/row.py
+++ b/frictionless/row.py
@@ -276,6 +276,7 @@ class Row(dict):
# Prepare context
cells = self.__cells
+ to_str = lambda v: str(v) if v is not None else ""
fields = self.__field_info["objects"]
field_mapping = self.__field_info["mapping"]
field_positions = self.__field_info["positions"]
@@ -311,7 +312,7 @@ class Row(dict):
self.__errors.append(
errors.TypeError(
note=type_note,
- cells=list(map(str, cells)),
+ cells=list(map(to_str, cells)),
row_number=self.__row_number,
row_position=self.__row_position,
cell=str(source),
@@ -327,7 +328,7 @@ class Row(dict):
self.__errors.append(
errors.ConstraintError(
note=note,
- cells=list(map(str, cells)),
+ cells=list(map(to_str, cells)),
row_number=self.__row_number,
row_position=self.__row_position,
cell=str(source),
@@ -350,7 +351,7 @@ class Row(dict):
self.__errors.append(
errors.ExtraCellError(
note="",
- cells=list(map(str, cells)),
+ cells=list(map(to_str, cells)),
row_number=self.__row_number,
row_position=self.__row_position,
cell=str(cell),
@@ -369,7 +370,7 @@ class Row(dict):
self.__errors.append(
errors.MissingCellError(
note="",
- cells=list(map(str, cells)),
+ cells=list(map(to_str, cells)),
row_number=self.__row_number,
row_position=self.__row_position,
cell="",
@@ -385,7 +386,7 @@ class Row(dict):
self.__errors = [
errors.BlankRowError(
note="",
- cells=list(map(str, cells)),
+ cells=list(map(to_str, cells)),
row_number=self.__row_number,
row_position=self.__row_position,
)
| Foreign key errors showing headers instead of row values
# Overview
* Version: **`v4.22.1`**
The foreign key errors returned in the report are the **header** values of the resource instead of the actual **row values**. Also, the message does not provide any hints about the problem: which is the foreign key violated? which fields?
I would expect more details about the `foreign-key-error` alongside the other fields of the error found in the report. Does it makes sense?

# How to reproduce
Here is ZIP with a minimal example to reproduce the problem: [frictionless-foreign-key-bug.zip](https://github.com/frictionlessdata/frictionless-py/files/7633635/frictionless-foreign-key-bug.zip)
Use the **awesome** `frictionless CLI` and `jq` just to get to the errors:
```
frictionless validate datapackage.json --type package --json | jq .tasks[].errors
```
Result:
```json
[
{
"cells": [
"id",
"first_name",
"last_name",
"dept_id"
],
"rowNumber": 8,
"rowPosition": 9,
"code": "foreign-key-error",
"name": "ForeignKey Error",
"tags": [
"#table",
"#row"
],
"note": "not found in the lookup table",
"message": "Row at position \"9\" violates the foreign key: not found in the lookup table",
"description": "Values in the foreign key fields should exist in the reference table"
},
{
"cells": [
"id",
"first_name",
"last_name",
"dept_id"
],
"rowNumber": 18,
"rowPosition": 19,
"code": "foreign-key-error",
"name": "ForeignKey Error",
"tags": [
"#table",
"#row"
],
"note": "not found in the lookup table",
"message": "Row at position \"19\" violates the foreign key: not found in the lookup table",
"description": "Values in the foreign key fields should exist in the reference table"
}
]
[]
```
Please replace this line with full information about your idea or problem. If it's a bug share as much as possible to reproduce it
---
Please preserve this line to notify @roll (lead of this repository)
| frictionlessdata/frictionless-py | diff --git a/tests/validate/test_package.py b/tests/validate/test_package.py
index 5aaae10b..b1c019b4 100644
--- a/tests/validate/test_package.py
+++ b/tests/validate/test_package.py
@@ -206,8 +206,8 @@ def test_validate_package_schema_foreign_key_self_referenced_resource_violation(
descriptor = deepcopy(DESCRIPTOR_FK)
del descriptor["resources"][0]["data"][4]
report = validate(descriptor)
- assert report.flatten(["rowPosition", "fieldPosition", "code"]) == [
- [4, None, "foreign-key-error"],
+ assert report.flatten(["rowPosition", "fieldPosition", "code", "cells"]) == [
+ [4, None, "foreign-key-error", ["3", "rome", "4"]],
]
@@ -215,8 +215,8 @@ def test_validate_package_schema_foreign_key_internal_resource_violation():
descriptor = deepcopy(DESCRIPTOR_FK)
del descriptor["resources"][1]["data"][4]
report = validate(descriptor)
- assert report.flatten(["rowPosition", "fieldPosition", "code"]) == [
- [5, None, "foreign-key-error"],
+ assert report.flatten(["rowPosition", "fieldPosition", "code", "cells"]) == [
+ [5, None, "foreign-key-error", ["4", "rio", ""]],
]
@@ -224,11 +224,11 @@ def test_validate_package_schema_foreign_key_internal_resource_violation_non_exi
descriptor = deepcopy(DESCRIPTOR_FK)
descriptor["resources"][1]["data"] = [["label", "population"], [10, 10]]
report = validate(descriptor)
- assert report.flatten(["rowPosition", "fieldPosition", "code"]) == [
- [2, None, "foreign-key-error"],
- [3, None, "foreign-key-error"],
- [4, None, "foreign-key-error"],
- [5, None, "foreign-key-error"],
+ assert report.flatten(["rowPosition", "fieldPosition", "code", "cells"]) == [
+ [2, None, "foreign-key-error", ["1", "london", "2"]],
+ [3, None, "foreign-key-error", ["2", "paris", "3"]],
+ [4, None, "foreign-key-error", ["3", "rome", "4"]],
+ [5, None, "foreign-key-error", ["4", "rio", ""]],
]
diff --git a/tests/validate/test_resource.py b/tests/validate/test_resource.py
index 918d5755..64eb0b90 100644
--- a/tests/validate/test_resource.py
+++ b/tests/validate/test_resource.py
@@ -587,8 +587,8 @@ def test_validate_schema_foreign_key_error_self_referencing_invalid():
},
}
report = validate(source)
- assert report.flatten(["rowPosition", "fieldPosition", "code"]) == [
- [6, None, "foreign-key-error"],
+ assert report.flatten(["rowPosition", "fieldPosition", "code", "cells"]) == [
+ [6, None, "foreign-key-error", ["5", "6", "Rome"]],
]
@@ -609,6 +609,8 @@ def test_validate_schema_unique_error_and_type_error():
["a1", 100],
["a2", "bad"],
["a3", 100],
+ ["a4", 0],
+ ["a5", 0],
]
schema = {
"fields": [
@@ -617,9 +619,10 @@ def test_validate_schema_unique_error_and_type_error():
]
}
report = validate(source, schema=schema)
- assert report.flatten(["rowPosition", "fieldPosition", "code"]) == [
- [3, 2, "type-error"],
- [4, 2, "unique-error"],
+ assert report.flatten(["rowPosition", "fieldPosition", "code", "cells"]) == [
+ [3, 2, "type-error", ["a2", "bad"]],
+ [4, 2, "unique-error", ["a3", "100"]],
+ [6, 2, "unique-error", ["a5", "0"]],
]
@@ -835,8 +838,8 @@ def test_validate_detector_headers_errors():
}
detector = Detector(schema_sync=True)
report = validate(source, schema=schema, detector=detector)
- assert report.flatten(["rowPosition", "fieldPosition", "code"]) == [
- [4, 4, "constraint-error"],
+ assert report.flatten(["rowPosition", "fieldPosition", "code", "cells"]) == [
+ [4, 4, "constraint-error", ["3", "Smith", "Paul", ""]],
]
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 3
},
"num_modified_files": 3
} | 4.22 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install --upgrade -e .[bigquery,ckan,excel,gsheets,html,json,ods,pandas,s3,server,spss,sql,dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc",
"apt-get install -y postgresql libpq-dev"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | asttokens==3.0.0
attrs==25.3.0
black==23.12.1
blinker==1.9.0
boto3==1.37.23
botocore==1.37.23
cached-property==2.0.1
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
ckanapi==4.8
click==8.1.8
coverage==7.8.0
cryptography==44.0.2
cssselect==1.3.0
databind==4.5.2
databind.core==4.5.2
databind.json==4.5.2
decorator==5.2.1
deepmerge==2.0
Deprecated==1.2.18
docopt==0.6.2
docspec==2.2.1
docspec-python==2.2.1
docstring_parser==0.11
et_xmlfile==2.0.0
exceptiongroup==1.2.2
execnet==2.1.1
executing==2.2.0
ezodf==0.3.2
Flask==3.1.0
-e git+https://github.com/frictionlessdata/frictionless-py.git@1b5a274bba5b736d1d7c4fc4a3eb62e64f56d1c0#egg=frictionless
gitdb==4.0.12
GitPython==3.1.44
giturlparse==0.12.0
google-api-core==2.24.2
google-api-python-client==2.166.0
google-auth==2.38.0
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.1
googleapis-common-protos==1.69.2
greenlet==3.1.1
gunicorn==23.0.0
httplib2==0.22.0
idna==3.10
ijson==3.3.0
importlib_metadata==8.6.1
iniconfig==2.1.0
ipython==8.18.1
isodate==0.7.2
itsdangerous==2.2.0
jedi==0.19.2
Jinja2==3.1.6
jmespath==1.0.1
jsonlines==4.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
livemark==0.110.8
livereload==2.7.1
lxml==5.3.1
markdown-it-py==3.0.0
marko==1.3.1
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mccabe==0.7.0
mdurl==0.1.2
moto==5.1.2
multidict==6.2.0
mypy==1.15.0
mypy-extensions==1.0.0
nr-date==2.1.0
nr-stream==1.1.5
nr.util==0.8.12
numpy==2.0.2
oauth2client==4.1.3
oauthlib==3.2.2
openpyxl==3.1.5
packaging==24.2
pandas==2.2.3
parso==0.8.4
pathspec==0.12.1
petl==1.7.15
pexpect==4.9.0
platformdirs==4.3.7
pluggy==1.5.0
prompt_toolkit==3.0.50
propcache==0.3.1
proto-plus==1.26.1
protobuf==6.30.2
psycopg2==2.9.10
ptyprocess==0.7.0
pure_eval==0.2.3
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycodestyle==2.13.0
pycparser==2.22
pydoc-markdown==4.8.2
pydocstyle==6.3.0
pyflakes==3.3.2
Pygments==2.19.1
pygsheets==2.0.6
pylama==8.4.1
PyMySQL==1.1.1
pyparsing==3.2.3
pyquery==1.4.3
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-only==2.1.2
pytest-vcr==1.0.2
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-dotenv==1.1.0
python-slugify==8.0.4
pytz==2025.2
PyYAML==6.0.2
referencing==0.36.2
requests==2.32.3
requests-mock==1.12.1
requests-oauthlib==2.0.0
responses==0.25.7
rfc3986==2.0.0
rich==14.0.0
rpds-py==0.24.0
rsa==4.9
s3transfer==0.11.4
savReaderWriter==3.4.2
shellingham==1.5.4
simpleeval==1.0.3
simplejson==3.20.1
six==1.17.0
smmap==5.0.2
snowballstemmer==2.2.0
SQLAlchemy==2.0.40
stack-data==0.6.3
stringcase==1.2.0
text-unidecode==1.3
tomli==2.2.1
tomli_w==1.2.0
tornado==6.4.2
traitlets==5.14.3
typeapi==2.2.4
typer==0.15.2
typing_extensions==4.13.0
tzdata==2025.2
uritemplate==4.1.1
urllib3==1.26.20
validators==0.34.0
vcrpy==7.0.0
watchdog==6.0.0
wcwidth==0.2.13
Werkzeug==3.1.3
wrapt==1.17.2
xlrd==2.0.1
xlwt==1.3.0
xmltodict==0.14.2
yapf==0.43.0
yarl==1.18.3
zipp==3.21.0
| name: frictionless-py
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- asttokens==3.0.0
- attrs==25.3.0
- black==23.12.1
- blinker==1.9.0
- boto3==1.37.23
- botocore==1.37.23
- cached-property==2.0.1
- cachetools==5.5.2
- certifi==2025.1.31
- cffi==1.17.1
- chardet==5.2.0
- charset-normalizer==3.4.1
- ckanapi==4.8
- click==8.1.8
- coverage==7.8.0
- cryptography==44.0.2
- cssselect==1.3.0
- databind==4.5.2
- databind-core==4.5.2
- databind-json==4.5.2
- decorator==5.2.1
- deepmerge==2.0
- deprecated==1.2.18
- docopt==0.6.2
- docspec==2.2.1
- docspec-python==2.2.1
- docstring-parser==0.11
- et-xmlfile==2.0.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- executing==2.2.0
- ezodf==0.3.2
- flask==3.1.0
- frictionless==4.22.1
- gitdb==4.0.12
- gitpython==3.1.44
- giturlparse==0.12.0
- google-api-core==2.24.2
- google-api-python-client==2.166.0
- google-auth==2.38.0
- google-auth-httplib2==0.2.0
- google-auth-oauthlib==1.2.1
- googleapis-common-protos==1.69.2
- greenlet==3.1.1
- gunicorn==23.0.0
- httplib2==0.22.0
- idna==3.10
- ijson==3.3.0
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- ipython==8.18.1
- isodate==0.7.2
- itsdangerous==2.2.0
- jedi==0.19.2
- jinja2==3.1.6
- jmespath==1.0.1
- jsonlines==4.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- livemark==0.110.8
- livereload==2.7.1
- lxml==5.3.1
- markdown-it-py==3.0.0
- marko==1.3.1
- markupsafe==3.0.2
- matplotlib-inline==0.1.7
- mccabe==0.7.0
- mdurl==0.1.2
- moto==5.1.2
- multidict==6.2.0
- mypy==1.15.0
- mypy-extensions==1.0.0
- nr-date==2.1.0
- nr-stream==1.1.5
- nr-util==0.8.12
- numpy==2.0.2
- oauth2client==4.1.3
- oauthlib==3.2.2
- openpyxl==3.1.5
- packaging==24.2
- pandas==2.2.3
- parso==0.8.4
- pathspec==0.12.1
- petl==1.7.15
- pexpect==4.9.0
- platformdirs==4.3.7
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- propcache==0.3.1
- proto-plus==1.26.1
- protobuf==6.30.2
- psycopg2==2.9.10
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pyasn1==0.6.1
- pyasn1-modules==0.4.2
- pycodestyle==2.13.0
- pycparser==2.22
- pydoc-markdown==4.8.2
- pydocstyle==6.3.0
- pyflakes==3.3.2
- pygments==2.19.1
- pygsheets==2.0.6
- pylama==8.4.1
- pymysql==1.1.1
- pyparsing==3.2.3
- pyquery==1.4.3
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-only==2.1.2
- pytest-vcr==1.0.2
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- python-dotenv==1.1.0
- python-slugify==8.0.4
- pytz==2025.2
- pyyaml==6.0.2
- referencing==0.36.2
- requests==2.32.3
- requests-mock==1.12.1
- requests-oauthlib==2.0.0
- responses==0.25.7
- rfc3986==2.0.0
- rich==14.0.0
- rpds-py==0.24.0
- rsa==4.9
- s3transfer==0.11.4
- savreaderwriter==3.4.2
- shellingham==1.5.4
- simpleeval==1.0.3
- simplejson==3.20.1
- six==1.17.0
- smmap==5.0.2
- snowballstemmer==2.2.0
- sqlalchemy==2.0.40
- stack-data==0.6.3
- stringcase==1.2.0
- text-unidecode==1.3
- tomli==2.2.1
- tomli-w==1.2.0
- tornado==6.4.2
- traitlets==5.14.3
- typeapi==2.2.4
- typer==0.15.2
- typing-extensions==4.13.0
- tzdata==2025.2
- uritemplate==4.1.1
- urllib3==1.26.20
- validators==0.34.0
- vcrpy==7.0.0
- watchdog==6.0.0
- wcwidth==0.2.13
- werkzeug==3.1.3
- wrapt==1.17.2
- xlrd==2.0.1
- xlwt==1.3.0
- xmltodict==0.14.2
- yapf==0.43.0
- yarl==1.18.3
- zipp==3.21.0
prefix: /opt/conda/envs/frictionless-py
| [
"tests/validate/test_package.py::test_validate_package_schema_foreign_key_self_referenced_resource_violation",
"tests/validate/test_package.py::test_validate_package_schema_foreign_key_internal_resource_violation",
"tests/validate/test_package.py::test_validate_package_schema_foreign_key_internal_resource_violation_non_existent",
"tests/validate/test_resource.py::test_validate_schema_foreign_key_error_self_referencing_invalid",
"tests/validate/test_resource.py::test_validate_detector_headers_errors"
] | [] | [
"tests/validate/test_package.py::test_validate_package",
"tests/validate/test_package.py::test_validate_package_from_dict",
"tests/validate/test_package.py::test_validate_package_from_dict_invalid",
"tests/validate/test_package.py::test_validate_package_from_path",
"tests/validate/test_package.py::test_validate_package_from_path_invalid",
"tests/validate/test_package.py::test_validate_package_from_zip",
"tests/validate/test_package.py::test_validate_package_from_zip_invalid",
"tests/validate/test_package.py::test_validate_package_with_non_tabular",
"tests/validate/test_package.py::test_validate_package_invalid_descriptor_path",
"tests/validate/test_package.py::test_validate_package_invalid_package",
"tests/validate/test_package.py::test_validate_package_invalid_package_original",
"tests/validate/test_package.py::test_validate_package_invalid_table",
"tests/validate/test_package.py::test_validate_package_pathlib_source",
"tests/validate/test_package.py::test_validate_package_infer",
"tests/validate/test_package.py::test_validate_package_dialect_header_false",
"tests/validate/test_package.py::test_validate_package_with_schema_as_string",
"tests/validate/test_package.py::test_validate_package_schema_foreign_key_error",
"tests/validate/test_package.py::test_validate_package_schema_foreign_key_not_defined",
"tests/validate/test_package.py::test_validate_package_stats",
"tests/validate/test_package.py::test_validate_package_stats_invalid",
"tests/validate/test_package.py::test_validate_package_stats_size",
"tests/validate/test_package.py::test_validate_package_stats_size_invalid",
"tests/validate/test_package.py::test_validate_package_stats_hash",
"tests/validate/test_package.py::test_check_file_package_stats_hash_invalid",
"tests/validate/test_package.py::test_check_file_package_stats_hash_not_supported_algorithm",
"tests/validate/test_package.py::test_validate_package_mixed_issue_170",
"tests/validate/test_package.py::test_validate_package_invalid_json_issue_192",
"tests/validate/test_package.py::test_validate_package_composite_primary_key_unique_issue_215",
"tests/validate/test_package.py::test_validate_package_composite_primary_key_not_unique_issue_215",
"tests/validate/test_package.py::test_validate_package_geopoint_required_constraint_issue_231",
"tests/validate/test_package.py::test_validate_package_number_test_issue_232",
"tests/validate/test_package.py::test_validate_package_with_schema_issue_348",
"tests/validate/test_package.py::test_validate_package_using_detector_schema_sync_issue_847",
"tests/validate/test_package.py::test_validate_package_descriptor_type_package",
"tests/validate/test_package.py::test_validate_package_descriptor_type_package_invalid",
"tests/validate/test_package.py::test_validate_package_with_diacritic_symbol_issue_905",
"tests/validate/test_resource.py::test_validate",
"tests/validate/test_resource.py::test_validate_invalid_source",
"tests/validate/test_resource.py::test_validate_invalid_resource",
"tests/validate/test_resource.py::test_validate_invalid_resource_original",
"tests/validate/test_resource.py::test_validate_invalid_table",
"tests/validate/test_resource.py::test_validate_resource_with_schema_as_string",
"tests/validate/test_resource.py::test_validate_from_path",
"tests/validate/test_resource.py::test_validate_invalid",
"tests/validate/test_resource.py::test_validate_blank_headers",
"tests/validate/test_resource.py::test_validate_duplicate_headers",
"tests/validate/test_resource.py::test_validate_defective_rows",
"tests/validate/test_resource.py::test_validate_blank_rows",
"tests/validate/test_resource.py::test_validate_blank_rows_multiple",
"tests/validate/test_resource.py::test_validate_blank_cell_not_required",
"tests/validate/test_resource.py::test_validate_no_data",
"tests/validate/test_resource.py::test_validate_no_rows",
"tests/validate/test_resource.py::test_validate_no_rows_with_compression",
"tests/validate/test_resource.py::test_validate_task_error",
"tests/validate/test_resource.py::test_validate_source_invalid",
"tests/validate/test_resource.py::test_validate_source_pathlib_path_table",
"tests/validate/test_resource.py::test_validate_scheme",
"tests/validate/test_resource.py::test_validate_scheme_invalid",
"tests/validate/test_resource.py::test_validate_format",
"tests/validate/test_resource.py::test_validate_format_non_tabular",
"tests/validate/test_resource.py::test_validate_encoding",
"tests/validate/test_resource.py::test_validate_encoding_invalid",
"tests/validate/test_resource.py::test_validate_compression",
"tests/validate/test_resource.py::test_validate_compression_explicit",
"tests/validate/test_resource.py::test_validate_compression_invalid",
"tests/validate/test_resource.py::test_validate_dialect_delimiter",
"tests/validate/test_resource.py::test_validate_layout_none",
"tests/validate/test_resource.py::test_validate_layout_none_extra_cell",
"tests/validate/test_resource.py::test_validate_layout_number",
"tests/validate/test_resource.py::test_validate_layout_list_of_numbers",
"tests/validate/test_resource.py::test_validate_layout_list_of_numbers_and_headers_join",
"tests/validate/test_resource.py::test_validate_layout_pick_fields",
"tests/validate/test_resource.py::test_validate_layout_pick_fields_regex",
"tests/validate/test_resource.py::test_validate_layout_skip_fields",
"tests/validate/test_resource.py::test_validate_layout_skip_fields_regex",
"tests/validate/test_resource.py::test_validate_layout_limit_fields",
"tests/validate/test_resource.py::test_validate_layout_offset_fields",
"tests/validate/test_resource.py::test_validate_layout_limit_and_offset_fields",
"tests/validate/test_resource.py::test_validate_layout_pick_rows",
"tests/validate/test_resource.py::test_validate_layout_pick_rows_regex",
"tests/validate/test_resource.py::test_validate_layout_skip_rows",
"tests/validate/test_resource.py::test_validate_layout_skip_rows_regex",
"tests/validate/test_resource.py::test_validate_layout_skip_rows_blank",
"tests/validate/test_resource.py::test_validate_layout_pick_rows_and_fields",
"tests/validate/test_resource.py::test_validate_layout_skip_rows_and_fields",
"tests/validate/test_resource.py::test_validate_layout_limit_rows",
"tests/validate/test_resource.py::test_validate_layout_offset_rows",
"tests/validate/test_resource.py::test_validate_layout_limit_and_offset_rows",
"tests/validate/test_resource.py::test_validate_layout_invalid_limit_rows",
"tests/validate/test_resource.py::test_validate_layout_structure_errors_with_limit_rows",
"tests/validate/test_resource.py::test_validate_schema_invalid",
"tests/validate/test_resource.py::test_validate_schema_invalid_json",
"tests/validate/test_resource.py::test_validate_schema_extra_headers_and_cells",
"tests/validate/test_resource.py::test_validate_schema_multiple_errors",
"tests/validate/test_resource.py::test_validate_schema_min_length_constraint",
"tests/validate/test_resource.py::test_validate_schema_max_length_constraint",
"tests/validate/test_resource.py::test_validate_schema_minimum_constraint",
"tests/validate/test_resource.py::test_validate_schema_maximum_constraint",
"tests/validate/test_resource.py::test_validate_schema_foreign_key_error_self_referencing",
"tests/validate/test_resource.py::test_validate_schema_unique_error",
"tests/validate/test_resource.py::test_validate_schema_unique_error_and_type_error",
"tests/validate/test_resource.py::test_validate_schema_primary_key_error",
"tests/validate/test_resource.py::test_validate_schema_primary_key_and_unique_error",
"tests/validate/test_resource.py::test_validate_schema_primary_key_error_composite",
"tests/validate/test_resource.py::test_validate_stats_hash",
"tests/validate/test_resource.py::test_validate_stats_hash_invalid",
"tests/validate/test_resource.py::test_validate_stats_hash_md5",
"tests/validate/test_resource.py::test_validate_stats_hash_md5_invalid",
"tests/validate/test_resource.py::test_validate_stats_hash_sha1",
"tests/validate/test_resource.py::test_validate_stats_hash_sha1_invalid",
"tests/validate/test_resource.py::test_validate_stats_hash_sha256",
"tests/validate/test_resource.py::test_validate_stats_hash_sha256_invalid",
"tests/validate/test_resource.py::test_validate_stats_hash_sha512",
"tests/validate/test_resource.py::test_validate_stats_hash_sha512_invalid",
"tests/validate/test_resource.py::test_validate_stats_bytes",
"tests/validate/test_resource.py::test_validate_stats_bytes_invalid",
"tests/validate/test_resource.py::test_validate_stats_rows",
"tests/validate/test_resource.py::test_validate_stats_rows_invalid",
"tests/validate/test_resource.py::test_validate_detector_sync_schema",
"tests/validate/test_resource.py::test_validate_detector_sync_schema_invalid",
"tests/validate/test_resource.py::test_validate_detector_patch_schema",
"tests/validate/test_resource.py::test_validate_detector_patch_schema_fields",
"tests/validate/test_resource.py::test_validate_detector_infer_type_string",
"tests/validate/test_resource.py::test_validate_detector_infer_type_any",
"tests/validate/test_resource.py::test_validate_detector_infer_names",
"tests/validate/test_resource.py::test_validate_pick_errors",
"tests/validate/test_resource.py::test_validate_pick_errors_tags",
"tests/validate/test_resource.py::test_validate_skip_errors",
"tests/validate/test_resource.py::test_validate_skip_errors_tags",
"tests/validate/test_resource.py::test_validate_invalid_limit_errors",
"tests/validate/test_resource.py::test_validate_structure_errors_with_limit_errors",
"tests/validate/test_resource.py::test_validate_custom_check",
"tests/validate/test_resource.py::test_validate_custom_check_with_arguments",
"tests/validate/test_resource.py::test_validate_custom_check_function_based",
"tests/validate/test_resource.py::test_validate_custom_check_bad_name",
"tests/validate/test_resource.py::test_validate_infer_fields_issue_223",
"tests/validate/test_resource.py::test_validate_infer_fields_issue_225",
"tests/validate/test_resource.py::test_validate_fails_with_wrong_encoding_issue_274",
"tests/validate/test_resource.py::test_validate_wide_table_with_order_fields_issue_277",
"tests/validate/test_resource.py::test_validate_invalid_table_schema_issue_304",
"tests/validate/test_resource.py::test_validate_table_is_invalid_issue_312",
"tests/validate/test_resource.py::test_validate_order_fields_issue_313",
"tests/validate/test_resource.py::test_validate_missing_local_file_raises_scheme_error_issue_315",
"tests/validate/test_resource.py::test_validate_inline_not_a_binary_issue_349",
"tests/validate/test_resource.py::test_validate_newline_inside_label_issue_811",
"tests/validate/test_resource.py::test_validate_resource_from_json_format_issue_827",
"tests/validate/test_resource.py::test_validate_resource_none_is_not_iterable_enum_constraint_issue_833",
"tests/validate/test_resource.py::test_validate_resource_header_row_has_first_number_issue_870",
"tests/validate/test_resource.py::test_validate_resource_descriptor_type_invalid"
] | [] | MIT License | 11,738 | 849 | [
"frictionless/errors/cell.py",
"frictionless/errors/row.py",
"frictionless/row.py"
] |
alvinwan__TexSoup-132 | f91d4e71b21aa6852378d2d60ecc551b39e05bf0 | 2021-12-03 14:24:38 | 19451a322a51e12fd30a9a391301aa31b937e9e2 | coveralls:
[](https://coveralls.io/builds/44742185)
Coverage remained the same at 100.0% when pulling **2a19a56d68fc9f3e444b971031d33802f9b9c7e2 on masonproffitt:fix_118_def-without-braces** into **f91d4e71b21aa6852378d2d60ecc551b39e05bf0 on alvinwan:master**.
masonproffitt: I've adjusted it so that now it will reproduce the lack of braces:
```python
>>> TexSoup.TexSoup(r'\def\foo{bar}')
\def\foo{bar}
``` | diff --git a/TexSoup/data.py b/TexSoup/data.py
index f7279c8..58cd070 100644
--- a/TexSoup/data.py
+++ b/TexSoup/data.py
@@ -1317,7 +1317,7 @@ class TexArgs(list):
"""
arg = self.__coerce(arg)
- if isinstance(arg, TexGroup):
+ if isinstance(arg, (TexGroup, TexCmd)):
super().insert(i, arg)
if len(self) <= 1:
diff --git a/TexSoup/reader.py b/TexSoup/reader.py
index 3347393..fd53989 100644
--- a/TexSoup/reader.py
+++ b/TexSoup/reader.py
@@ -391,7 +391,7 @@ def read_arg_required(
b. A curly-brace delimiter. If the required argument is brace-delimited,
the contents of the brace group are used as the argument.
c. Spacer or not, if a brace group is not found, simply use the next
- character.
+ character, unless it is a backslash, in which case use the full command name
:param Buffer src: a buffer of tokens
:param TexArgs args: existing arguments to extend
@@ -422,7 +422,12 @@ def read_arg_required(
n_required -= 1
continue
elif src.hasNext() and n_required > 0:
- args.append('{%s}' % next(src))
+ next_token = next(src)
+ if next_token.category == TC.Escape:
+ name, _ = read_command(src, 0, 0, tolerance=tolerance, mode=mode)
+ args.append(TexCmd(name, position=next_token.position))
+ else:
+ args.append('{%s}' % next_token)
n_required -= 1
continue
| \def\command not parsed correctly
For example, `\def\arraystretch{1.1}` will be parsed as `\def{\}{arraystretch}{1.1}`. The bad part of this result is it breaks the balance of braces as `\}` is escaped. | alvinwan/TexSoup | diff --git a/tests/test_parser.py b/tests/test_parser.py
index 136710e..bb175ff 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -384,6 +384,14 @@ def test_def_item():
assert soup.item is not None
+def test_def_without_braces():
+ """Tests that def without braces around the new command parses correctly"""
+ soup = TexSoup(r"\def\acommandname{replacement text}")
+ assert len(soup.find("def").args) == 2
+ assert str(soup.find("def").args[0]) == r"\acommandname"
+ assert str(soup.find("def").args[1]) == "{replacement text}"
+
+
def test_grouping_optional_argument():
"""Tests that grouping occurs correctly"""
soup = TexSoup(r"\begin{Theorem}[The argopt contains {$]\int_\infty$} the square bracket]\end{Theorem}")
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 0.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"coverage",
"coveralls"
],
"pre_install": null,
"python": "3.7",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
coverage==6.5.0
coveralls==3.3.1
docopt==0.6.2
exceptiongroup==1.2.2
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
packaging==24.0
pluggy==1.2.0
pytest==7.4.4
pytest-cov==4.1.0
requests==2.31.0
-e git+https://github.com/alvinwan/TexSoup.git@f91d4e71b21aa6852378d2d60ecc551b39e05bf0#egg=TexSoup
tomli==2.0.1
typing_extensions==4.7.1
urllib3==2.0.7
zipp==3.15.0
| name: TexSoup
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=22.3.1=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- charset-normalizer==3.4.1
- coverage==6.5.0
- coveralls==3.3.1
- docopt==0.6.2
- exceptiongroup==1.2.2
- idna==3.10
- importlib-metadata==6.7.0
- iniconfig==2.0.0
- packaging==24.0
- pluggy==1.2.0
- pytest==7.4.4
- pytest-cov==4.1.0
- requests==2.31.0
- tomli==2.0.1
- typing-extensions==4.7.1
- urllib3==2.0.7
- zipp==3.15.0
prefix: /opt/conda/envs/TexSoup
| [
"tests/test_parser.py::test_def_without_braces"
] | [] | [
"tests/test_api.py::test_navigation_attributes",
"tests/test_api.py::test_navigation_parent",
"tests/test_api.py::test_navigation_children",
"tests/test_api.py::test_navigation_descendants",
"tests/test_api.py::test_navigation_positions",
"tests/test_api.py::test_find_basic",
"tests/test_api.py::test_find_by_command",
"tests/test_api.py::test_find_env",
"tests/test_api.py::test_delete",
"tests/test_api.py::test_delete_arg",
"tests/test_api.py::test_delete_token",
"tests/test_api.py::test_replace_single",
"tests/test_api.py::test_replace_multiple",
"tests/test_api.py::test_append",
"tests/test_api.py::test_insert",
"tests/test_api.py::test_change_string",
"tests/test_api.py::test_change_name",
"tests/test_api.py::test_access_position",
"tests/test_api.py::test_math_env_change",
"tests/test_api.py::test_text",
"tests/test_api.py::test_search_regex",
"tests/test_api.py::test_search_regex_precompiled_pattern",
"tests/test_api.py::test_skip_envs",
"tests/test_load_edit_save.py::test_load_save",
"tests/test_load_edit_save.py::test_load_edit_save",
"tests/test_parser.py::test_commands_only",
"tests/test_parser.py::test_commands_envs_only",
"tests/test_parser.py::test_commands_envs_text",
"tests/test_parser.py::test_text_preserved",
"tests/test_parser.py::test_command_name_parse",
"tests/test_parser.py::test_command_env_name_parse",
"tests/test_parser.py::test_commands_without_arguments",
"tests/test_parser.py::test_unlabeled_environment",
"tests/test_parser.py::test_ignore_environment",
"tests/test_parser.py::test_inline_math",
"tests/test_parser.py::test_escaped_characters",
"tests/test_parser.py::test_math_environment_weirdness",
"tests/test_parser.py::test_tokenize_punctuation_command_names",
"tests/test_parser.py::test_item_parsing",
"tests/test_parser.py::test_item_argument_parsing",
"tests/test_parser.py::test_comment_escaping",
"tests/test_parser.py::test_comment_unparsed",
"tests/test_parser.py::test_comment_after_escape",
"tests/test_parser.py::test_items_with_labels",
"tests/test_parser.py::test_multiline_args",
"tests/test_parser.py::test_nested_commands",
"tests/test_parser.py::test_def_item",
"tests/test_parser.py::test_grouping_optional_argument",
"tests/test_parser.py::test_basic_whitespace",
"tests/test_parser.py::test_whitespace_in_command",
"tests/test_parser.py::test_math_environment_whitespace",
"tests/test_parser.py::test_non_letter_commands",
"tests/test_parser.py::test_math_environment_escape",
"tests/test_parser.py::test_punctuation_command_structure",
"tests/test_parser.py::test_non_punctuation_command_structure",
"tests/test_parser.py::test_allow_unclosed_non_curly_braces",
"tests/test_parser.py::test_buffer",
"tests/test_parser.py::test_to_buffer",
"tests/test_parser.py::test_unclosed_commands",
"tests/test_parser.py::test_unclosed_environments",
"tests/test_parser.py::test_unclosed_math_environments",
"tests/test_parser.py::test_arg_parse",
"tests/test_parser.py::test_tolerance_env_unclosed",
"tests/test_search.py::test_commands_without_any_sort_arguments",
"tests/test_search.py::test_commands_with_one_or_more_arguments",
"tests/test_search.py::test_list_search",
"TexSoup/__init__.py::TexSoup.TexSoup",
"TexSoup/category.py::TexSoup.category.categorize",
"TexSoup/data.py::TexSoup.data.TexArgs",
"TexSoup/data.py::TexSoup.data.TexArgs.__contains__",
"TexSoup/data.py::TexSoup.data.TexArgs.__getitem__",
"TexSoup/data.py::TexSoup.data.TexArgs.__repr__",
"TexSoup/data.py::TexSoup.data.TexArgs.__str__",
"TexSoup/data.py::TexSoup.data.TexArgs.append",
"TexSoup/data.py::TexSoup.data.TexArgs.clear",
"TexSoup/data.py::TexSoup.data.TexArgs.extend",
"TexSoup/data.py::TexSoup.data.TexArgs.insert",
"TexSoup/data.py::TexSoup.data.TexArgs.pop",
"TexSoup/data.py::TexSoup.data.TexArgs.remove",
"TexSoup/data.py::TexSoup.data.TexArgs.reverse",
"TexSoup/data.py::TexSoup.data.TexCmd",
"TexSoup/data.py::TexSoup.data.TexEnv",
"TexSoup/data.py::TexSoup.data.TexEnv.__init__",
"TexSoup/data.py::TexSoup.data.TexExpr.__eq__",
"TexSoup/data.py::TexSoup.data.TexExpr.all",
"TexSoup/data.py::TexSoup.data.TexExpr.append",
"TexSoup/data.py::TexSoup.data.TexExpr.contents",
"TexSoup/data.py::TexSoup.data.TexExpr.insert",
"TexSoup/data.py::TexSoup.data.TexExpr.remove",
"TexSoup/data.py::TexSoup.data.TexExpr.string",
"TexSoup/data.py::TexSoup.data.TexGroup.parse",
"TexSoup/data.py::TexSoup.data.TexNamedEnv",
"TexSoup/data.py::TexSoup.data.TexNode.__iter__",
"TexSoup/data.py::TexSoup.data.TexNode.__match__",
"TexSoup/data.py::TexSoup.data.TexNode.all",
"TexSoup/data.py::TexSoup.data.TexNode.append",
"TexSoup/data.py::TexSoup.data.TexNode.args",
"TexSoup/data.py::TexSoup.data.TexNode.char_pos_to_line",
"TexSoup/data.py::TexSoup.data.TexNode.children",
"TexSoup/data.py::TexSoup.data.TexNode.contents",
"TexSoup/data.py::TexSoup.data.TexNode.copy",
"TexSoup/data.py::TexSoup.data.TexNode.count",
"TexSoup/data.py::TexSoup.data.TexNode.delete",
"TexSoup/data.py::TexSoup.data.TexNode.descendants",
"TexSoup/data.py::TexSoup.data.TexNode.find",
"TexSoup/data.py::TexSoup.data.TexNode.find_all",
"TexSoup/data.py::TexSoup.data.TexNode.insert",
"TexSoup/data.py::TexSoup.data.TexNode.name",
"TexSoup/data.py::TexSoup.data.TexNode.remove",
"TexSoup/data.py::TexSoup.data.TexNode.replace",
"TexSoup/data.py::TexSoup.data.TexNode.replace_with",
"TexSoup/data.py::TexSoup.data.TexNode.string",
"TexSoup/data.py::TexSoup.data.TexNode.text",
"TexSoup/data.py::TexSoup.data.TexText",
"TexSoup/data.py::TexSoup.data.TexText.__contains__",
"TexSoup/data.py::TexSoup.data.TexText.__eq__",
"TexSoup/data.py::TexSoup.data.TexText.__repr__",
"TexSoup/data.py::TexSoup.data.TexText.__str__",
"TexSoup/reader.py::TexSoup.reader.make_read_peek",
"TexSoup/reader.py::TexSoup.reader.read_arg",
"TexSoup/reader.py::TexSoup.reader.read_arg_required",
"TexSoup/reader.py::TexSoup.reader.read_args",
"TexSoup/reader.py::TexSoup.reader.read_command",
"TexSoup/reader.py::TexSoup.reader.read_env",
"TexSoup/reader.py::TexSoup.reader.read_item",
"TexSoup/reader.py::TexSoup.reader.read_math_env",
"TexSoup/reader.py::TexSoup.reader.read_skip_env",
"TexSoup/reader.py::TexSoup.reader.read_spacer",
"TexSoup/tokens.py::TexSoup.tokens.next_token",
"TexSoup/tokens.py::TexSoup.tokens.tokenize",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_command_name",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_escaped_symbols",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_ignore",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_line_break",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_line_comment",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_math_asym_switch",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_math_sym_switch",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_spacers",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_string",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_symbols",
"TexSoup/utils.py::TexSoup.utils.Buffer",
"TexSoup/utils.py::TexSoup.utils.Buffer.__getitem__",
"TexSoup/utils.py::TexSoup.utils.Buffer.backward",
"TexSoup/utils.py::TexSoup.utils.Buffer.forward",
"TexSoup/utils.py::TexSoup.utils.Buffer.forward_until",
"TexSoup/utils.py::TexSoup.utils.CharToLineOffset",
"TexSoup/utils.py::TexSoup.utils.MixedBuffer.__init__",
"TexSoup/utils.py::TexSoup.utils.Token.__add__",
"TexSoup/utils.py::TexSoup.utils.Token.__contains__",
"TexSoup/utils.py::TexSoup.utils.Token.__eq__",
"TexSoup/utils.py::TexSoup.utils.Token.__getitem__",
"TexSoup/utils.py::TexSoup.utils.Token.__hash__",
"TexSoup/utils.py::TexSoup.utils.Token.__iadd__",
"TexSoup/utils.py::TexSoup.utils.Token.__iter__",
"TexSoup/utils.py::TexSoup.utils.Token.__radd__",
"TexSoup/utils.py::TexSoup.utils.Token.lstrip",
"TexSoup/utils.py::TexSoup.utils.Token.rstrip",
"TexSoup/utils.py::TexSoup.utils.to_list"
] | [] | BSD 2-Clause "Simplified" License | 11,745 | 444 | [
"TexSoup/data.py",
"TexSoup/reader.py"
] |
alvinwan__TexSoup-133 | f91d4e71b21aa6852378d2d60ecc551b39e05bf0 | 2021-12-03 22:31:51 | 19451a322a51e12fd30a9a391301aa31b937e9e2 | coveralls:
[](https://coveralls.io/builds/44754315)
Coverage remained the same at 100.0% when pulling **8d68a717e4cb3876f2bb269ddf781224f6719a71 on masonproffitt:fix_117_retain-control-spaces** into **f91d4e71b21aa6852378d2d60ecc551b39e05bf0 on alvinwan:master**.
| diff --git a/TexSoup/data.py b/TexSoup/data.py
index f7279c8..58cd070 100644
--- a/TexSoup/data.py
+++ b/TexSoup/data.py
@@ -1317,7 +1317,7 @@ class TexArgs(list):
"""
arg = self.__coerce(arg)
- if isinstance(arg, TexGroup):
+ if isinstance(arg, (TexGroup, TexCmd)):
super().insert(i, arg)
if len(self) <= 1:
diff --git a/TexSoup/reader.py b/TexSoup/reader.py
index 3347393..fd53989 100644
--- a/TexSoup/reader.py
+++ b/TexSoup/reader.py
@@ -391,7 +391,7 @@ def read_arg_required(
b. A curly-brace delimiter. If the required argument is brace-delimited,
the contents of the brace group are used as the argument.
c. Spacer or not, if a brace group is not found, simply use the next
- character.
+ character, unless it is a backslash, in which case use the full command name
:param Buffer src: a buffer of tokens
:param TexArgs args: existing arguments to extend
@@ -422,7 +422,12 @@ def read_arg_required(
n_required -= 1
continue
elif src.hasNext() and n_required > 0:
- args.append('{%s}' % next(src))
+ next_token = next(src)
+ if next_token.category == TC.Escape:
+ name, _ = read_command(src, 0, 0, tolerance=tolerance, mode=mode)
+ args.append(TexCmd(name, position=next_token.position))
+ else:
+ args.append('{%s}' % next_token)
n_required -= 1
continue
diff --git a/TexSoup/tokens.py b/TexSoup/tokens.py
index 1f66cd5..492c50e 100644
--- a/TexSoup/tokens.py
+++ b/TexSoup/tokens.py
@@ -116,14 +116,15 @@ def tokenize_escaped_symbols(text, prev=None):
'\\}'
>>> tokenize_escaped_symbols(categorize(r'\%'))
'\\%'
- >>> tokenize_escaped_symbols(categorize(r'\ %')) # not even one spacer is allowed
+ >>> tokenize_escaped_symbols(categorize(r'\ '))
+ '\\ '
"""
if text.peek().category == CC.Escape \
and text.peek(1) \
and text.peek(1).category in (
CC.Escape, CC.GroupBegin, CC.GroupEnd, CC.MathSwitch,
CC.Alignment, CC.Macro, CC.Superscript, CC.Subscript,
- CC.Active, CC.Comment, CC.Other):
+ CC.Spacer, CC.Active, CC.Comment, CC.Other):
result = text.forward(2)
result.category = TC.EscapedComment
return result
| Control spaces "\ " in math mode don't make the roundtrip
People often use `\ ` (called control space) to insert a little extra space in math mode—to avoid the default behaviour of ignoring math spaces.
In TexSoup these get eaten up somehow, so when serialize back out, the tex is different:
Failing test case:
```python
def test_contol_space_command():
"""A control space "\ " can be used to insert extra spacing in math mode."""
math_with_spaces = r"""$a \ = \ \sin\theta$"""
soup = TexSoup(math_with_spaces)
assert str(soup) == math_with_spaces, 'Control spaces not preserved in math'
```
<img width="561" alt="Screen Shot 2020-10-18 at 1 10 39 AM" src="https://user-images.githubusercontent.com/163966/96359259-cb07c400-10de-11eb-9364-228d308bc34b.png">
expected: `$a \ = \ \sin\theta$`
observed: `$a \=\\sin\theta$`
Here are the tokens in case that's helpful:
```
'$'_MathSwitch
'a '_Text
'\'_Escape
' = '_Text
'\'_Escape
' '_MergedSpacer
'\'_Escape
'sin'_CommandName
'\'_Escape
'theta'_CommandName
'$'_MathSwitch
```
See https://tex.stackexchange.com/a/74354 for a complete list of all special LaTeX spacing commands inside and outide of math mode.
No urgency to fix this --- perhaps it is even a feature, since prevents users from trying to override default LaTeX spacing behaviour :)
| alvinwan/TexSoup | diff --git a/tests/test_parser.py b/tests/test_parser.py
index 136710e..60ea596 100644
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -189,9 +189,9 @@ def test_escaped_characters():
"""
soup = TexSoup(r"""
\begin{itemize}
- \item Ice cream costs \$4-\$5 around here. \}[\{]
+ \item Ice cream costs \$4-\$5 around here. \}\ [\{]
\end{itemize}""")
- assert str(soup.item).strip() == r'\item Ice cream costs \$4-\$5 around here. \}[\{]'
+ assert str(soup.item).strip() == r'\item Ice cream costs \$4-\$5 around here. \}\ [\{]'
assert '\\$4-\\$5' in str(soup), 'Escaped characters not properly rendered.'
@@ -384,6 +384,14 @@ def test_def_item():
assert soup.item is not None
+def test_def_without_braces():
+ """Tests that def without braces around the new command parses correctly"""
+ soup = TexSoup(r"\def\acommandname{replacement text}")
+ assert len(soup.find("def").args) == 2
+ assert str(soup.find("def").args[0]) == r"\acommandname"
+ assert str(soup.find("def").args[1]) == "{replacement text}"
+
+
def test_grouping_optional_argument():
"""Tests that grouping occurs correctly"""
soup = TexSoup(r"\begin{Theorem}[The argopt contains {$]\int_\infty$} the square bracket]\end{Theorem}")
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 3
} | 0.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"coverage",
"coveralls"
],
"pre_install": null,
"python": "3.6",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==22.2.0
certifi==2021.5.30
charset-normalizer==2.0.12
coverage==6.2
coveralls==3.3.1
docopt==0.6.2
idna==3.10
importlib-metadata==4.8.3
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
py==1.11.0
pyparsing==3.1.4
pytest==7.0.1
pytest-cov==4.0.0
requests==2.27.1
-e git+https://github.com/alvinwan/TexSoup.git@f91d4e71b21aa6852378d2d60ecc551b39e05bf0#egg=TexSoup
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
zipp==3.6.0
| name: TexSoup
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2021.5.30=py36h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.3=he6710b0_2
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=21.2.2=py36h06a4308_0
- python=3.6.13=h12debd9_1
- readline=8.2=h5eee18b_0
- setuptools=58.0.4=py36h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==22.2.0
- charset-normalizer==2.0.12
- coverage==6.2
- coveralls==3.3.1
- docopt==0.6.2
- idna==3.10
- importlib-metadata==4.8.3
- iniconfig==1.1.1
- packaging==21.3
- pluggy==1.0.0
- py==1.11.0
- pyparsing==3.1.4
- pytest==7.0.1
- pytest-cov==4.0.0
- requests==2.27.1
- tomli==1.2.3
- typing-extensions==4.1.1
- urllib3==1.26.20
- zipp==3.6.0
prefix: /opt/conda/envs/TexSoup
| [
"tests/test_parser.py::test_escaped_characters",
"tests/test_parser.py::test_def_without_braces"
] | [] | [
"tests/test_api.py::test_navigation_attributes",
"tests/test_api.py::test_navigation_parent",
"tests/test_api.py::test_navigation_children",
"tests/test_api.py::test_navigation_descendants",
"tests/test_api.py::test_navigation_positions",
"tests/test_api.py::test_find_basic",
"tests/test_api.py::test_find_by_command",
"tests/test_api.py::test_find_env",
"tests/test_api.py::test_delete",
"tests/test_api.py::test_delete_arg",
"tests/test_api.py::test_delete_token",
"tests/test_api.py::test_replace_single",
"tests/test_api.py::test_replace_multiple",
"tests/test_api.py::test_append",
"tests/test_api.py::test_insert",
"tests/test_api.py::test_change_string",
"tests/test_api.py::test_change_name",
"tests/test_api.py::test_access_position",
"tests/test_api.py::test_math_env_change",
"tests/test_api.py::test_text",
"tests/test_api.py::test_search_regex",
"tests/test_api.py::test_search_regex_precompiled_pattern",
"tests/test_api.py::test_skip_envs",
"tests/test_load_edit_save.py::test_load_save",
"tests/test_load_edit_save.py::test_load_edit_save",
"tests/test_parser.py::test_commands_only",
"tests/test_parser.py::test_commands_envs_only",
"tests/test_parser.py::test_commands_envs_text",
"tests/test_parser.py::test_text_preserved",
"tests/test_parser.py::test_command_name_parse",
"tests/test_parser.py::test_command_env_name_parse",
"tests/test_parser.py::test_commands_without_arguments",
"tests/test_parser.py::test_unlabeled_environment",
"tests/test_parser.py::test_ignore_environment",
"tests/test_parser.py::test_inline_math",
"tests/test_parser.py::test_math_environment_weirdness",
"tests/test_parser.py::test_tokenize_punctuation_command_names",
"tests/test_parser.py::test_item_parsing",
"tests/test_parser.py::test_item_argument_parsing",
"tests/test_parser.py::test_comment_escaping",
"tests/test_parser.py::test_comment_unparsed",
"tests/test_parser.py::test_comment_after_escape",
"tests/test_parser.py::test_items_with_labels",
"tests/test_parser.py::test_multiline_args",
"tests/test_parser.py::test_nested_commands",
"tests/test_parser.py::test_def_item",
"tests/test_parser.py::test_grouping_optional_argument",
"tests/test_parser.py::test_basic_whitespace",
"tests/test_parser.py::test_whitespace_in_command",
"tests/test_parser.py::test_math_environment_whitespace",
"tests/test_parser.py::test_non_letter_commands",
"tests/test_parser.py::test_math_environment_escape",
"tests/test_parser.py::test_punctuation_command_structure",
"tests/test_parser.py::test_non_punctuation_command_structure",
"tests/test_parser.py::test_allow_unclosed_non_curly_braces",
"tests/test_parser.py::test_buffer",
"tests/test_parser.py::test_to_buffer",
"tests/test_parser.py::test_unclosed_commands",
"tests/test_parser.py::test_unclosed_environments",
"tests/test_parser.py::test_unclosed_math_environments",
"tests/test_parser.py::test_arg_parse",
"tests/test_parser.py::test_tolerance_env_unclosed",
"tests/test_search.py::test_commands_without_any_sort_arguments",
"tests/test_search.py::test_commands_with_one_or_more_arguments",
"tests/test_search.py::test_list_search",
"TexSoup/__init__.py::TexSoup.TexSoup",
"TexSoup/category.py::TexSoup.category.categorize",
"TexSoup/data.py::TexSoup.data.TexArgs",
"TexSoup/data.py::TexSoup.data.TexArgs.__contains__",
"TexSoup/data.py::TexSoup.data.TexArgs.__getitem__",
"TexSoup/data.py::TexSoup.data.TexArgs.__repr__",
"TexSoup/data.py::TexSoup.data.TexArgs.__str__",
"TexSoup/data.py::TexSoup.data.TexArgs.append",
"TexSoup/data.py::TexSoup.data.TexArgs.clear",
"TexSoup/data.py::TexSoup.data.TexArgs.extend",
"TexSoup/data.py::TexSoup.data.TexArgs.insert",
"TexSoup/data.py::TexSoup.data.TexArgs.pop",
"TexSoup/data.py::TexSoup.data.TexArgs.remove",
"TexSoup/data.py::TexSoup.data.TexArgs.reverse",
"TexSoup/data.py::TexSoup.data.TexCmd",
"TexSoup/data.py::TexSoup.data.TexEnv",
"TexSoup/data.py::TexSoup.data.TexEnv.__init__",
"TexSoup/data.py::TexSoup.data.TexExpr.__eq__",
"TexSoup/data.py::TexSoup.data.TexExpr.all",
"TexSoup/data.py::TexSoup.data.TexExpr.append",
"TexSoup/data.py::TexSoup.data.TexExpr.contents",
"TexSoup/data.py::TexSoup.data.TexExpr.insert",
"TexSoup/data.py::TexSoup.data.TexExpr.remove",
"TexSoup/data.py::TexSoup.data.TexExpr.string",
"TexSoup/data.py::TexSoup.data.TexGroup.parse",
"TexSoup/data.py::TexSoup.data.TexNamedEnv",
"TexSoup/data.py::TexSoup.data.TexNode.__iter__",
"TexSoup/data.py::TexSoup.data.TexNode.__match__",
"TexSoup/data.py::TexSoup.data.TexNode.all",
"TexSoup/data.py::TexSoup.data.TexNode.append",
"TexSoup/data.py::TexSoup.data.TexNode.args",
"TexSoup/data.py::TexSoup.data.TexNode.char_pos_to_line",
"TexSoup/data.py::TexSoup.data.TexNode.children",
"TexSoup/data.py::TexSoup.data.TexNode.contents",
"TexSoup/data.py::TexSoup.data.TexNode.copy",
"TexSoup/data.py::TexSoup.data.TexNode.count",
"TexSoup/data.py::TexSoup.data.TexNode.delete",
"TexSoup/data.py::TexSoup.data.TexNode.descendants",
"TexSoup/data.py::TexSoup.data.TexNode.find",
"TexSoup/data.py::TexSoup.data.TexNode.find_all",
"TexSoup/data.py::TexSoup.data.TexNode.insert",
"TexSoup/data.py::TexSoup.data.TexNode.name",
"TexSoup/data.py::TexSoup.data.TexNode.remove",
"TexSoup/data.py::TexSoup.data.TexNode.replace",
"TexSoup/data.py::TexSoup.data.TexNode.replace_with",
"TexSoup/data.py::TexSoup.data.TexNode.string",
"TexSoup/data.py::TexSoup.data.TexNode.text",
"TexSoup/data.py::TexSoup.data.TexText",
"TexSoup/data.py::TexSoup.data.TexText.__contains__",
"TexSoup/data.py::TexSoup.data.TexText.__eq__",
"TexSoup/data.py::TexSoup.data.TexText.__repr__",
"TexSoup/data.py::TexSoup.data.TexText.__str__",
"TexSoup/reader.py::TexSoup.reader.make_read_peek",
"TexSoup/reader.py::TexSoup.reader.read_arg",
"TexSoup/reader.py::TexSoup.reader.read_arg_required",
"TexSoup/reader.py::TexSoup.reader.read_args",
"TexSoup/reader.py::TexSoup.reader.read_command",
"TexSoup/reader.py::TexSoup.reader.read_env",
"TexSoup/reader.py::TexSoup.reader.read_item",
"TexSoup/reader.py::TexSoup.reader.read_math_env",
"TexSoup/reader.py::TexSoup.reader.read_skip_env",
"TexSoup/reader.py::TexSoup.reader.read_spacer",
"TexSoup/tokens.py::TexSoup.tokens.next_token",
"TexSoup/tokens.py::TexSoup.tokens.tokenize",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_command_name",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_escaped_symbols",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_ignore",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_line_break",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_line_comment",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_math_asym_switch",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_math_sym_switch",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_spacers",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_string",
"TexSoup/tokens.py::TexSoup.tokens.tokenize_symbols",
"TexSoup/utils.py::TexSoup.utils.Buffer",
"TexSoup/utils.py::TexSoup.utils.Buffer.__getitem__",
"TexSoup/utils.py::TexSoup.utils.Buffer.backward",
"TexSoup/utils.py::TexSoup.utils.Buffer.forward",
"TexSoup/utils.py::TexSoup.utils.Buffer.forward_until",
"TexSoup/utils.py::TexSoup.utils.CharToLineOffset",
"TexSoup/utils.py::TexSoup.utils.MixedBuffer.__init__",
"TexSoup/utils.py::TexSoup.utils.Token.__add__",
"TexSoup/utils.py::TexSoup.utils.Token.__contains__",
"TexSoup/utils.py::TexSoup.utils.Token.__eq__",
"TexSoup/utils.py::TexSoup.utils.Token.__getitem__",
"TexSoup/utils.py::TexSoup.utils.Token.__hash__",
"TexSoup/utils.py::TexSoup.utils.Token.__iadd__",
"TexSoup/utils.py::TexSoup.utils.Token.__iter__",
"TexSoup/utils.py::TexSoup.utils.Token.__radd__",
"TexSoup/utils.py::TexSoup.utils.Token.lstrip",
"TexSoup/utils.py::TexSoup.utils.Token.rstrip",
"TexSoup/utils.py::TexSoup.utils.to_list"
] | [] | BSD 2-Clause "Simplified" License | 11,750 | 700 | [
"TexSoup/data.py",
"TexSoup/reader.py",
"TexSoup/tokens.py"
] |
tefra__xsdata-633 | 33605f0cc138ddbf421a6528355006d0eed939c2 | 2021-12-04 15:27:26 | 33605f0cc138ddbf421a6528355006d0eed939c2 | diff --git a/xsdata/codegen/container.py b/xsdata/codegen/container.py
index 72f1b728..ed195ae5 100644
--- a/xsdata/codegen/container.py
+++ b/xsdata/codegen/container.py
@@ -22,7 +22,6 @@ from xsdata.codegen.handlers import ClassNameConflictHandler
from xsdata.codegen.mixins import ContainerInterface
from xsdata.codegen.models import Class
from xsdata.codegen.models import get_qname
-from xsdata.codegen.models import should_generate
from xsdata.codegen.models import Status
from xsdata.codegen.utils import ClassUtils
from xsdata.models.config import GeneratorConfig
@@ -152,13 +151,25 @@ class ClassContainer(ContainerInterface):
designator.run()
def filter_classes(self):
- """If there is any class derived from complexType or element then
- filter classes that should be generated, otherwise leave the container
- as it is."""
+ """
+ Filter classes to be generated.
+
+ 1. If there are no global elements generate them all
+ 2. Generate all global types and the referred types
+ """
+
+ # No global elements, generate them all!!!
+ if not any(obj.is_global_type for obj in self):
+ return
+
+ occurs = {}
+ for obj in self:
+ if obj.is_global_type:
+ occurs[obj.ref] = None
+ occurs.update({ref: None for ref in obj.references})
- candidates = list(filter(should_generate, self))
- if candidates:
- self.data = collections.group_by(candidates, key=get_qname)
+ candidates = [obj for obj in self if obj.ref in occurs]
+ self.data = collections.group_by(candidates, key=get_qname)
def add(self, item: Class):
"""Add class item to the container."""
diff --git a/xsdata/codegen/handlers/attribute_compound_choice.py b/xsdata/codegen/handlers/attribute_compound_choice.py
index b64b0bf5..6739c477 100644
--- a/xsdata/codegen/handlers/attribute_compound_choice.py
+++ b/xsdata/codegen/handlers/attribute_compound_choice.py
@@ -47,7 +47,7 @@ class AttributeCompoundChoiceHandler(RelativeHandlerInterface):
min_occurs = []
max_occurs = []
for attr in attrs:
- target.attrs.remove(attr)
+ ClassUtils.remove_attribute(target, attr)
names.append(attr.local_name)
min_occurs.append(attr.restrictions.min_occurs or 0)
max_occurs.append(attr.restrictions.max_occurs or 0)
diff --git a/xsdata/codegen/handlers/attribute_group.py b/xsdata/codegen/handlers/attribute_group.py
index 7244f48d..ef1dbf60 100644
--- a/xsdata/codegen/handlers/attribute_group.py
+++ b/xsdata/codegen/handlers/attribute_group.py
@@ -42,6 +42,6 @@ class AttributeGroupHandler(RelativeHandlerInterface):
raise AnalyzerValueError(f"Group attribute not found: `{qname}`")
if source is target:
- target.attrs.remove(attr)
+ ClassUtils.remove_attribute(target, attr)
else:
ClassUtils.copy_group_attributes(source, target, attr)
diff --git a/xsdata/codegen/handlers/attribute_overrides.py b/xsdata/codegen/handlers/attribute_overrides.py
index b66116ce..2490f1be 100644
--- a/xsdata/codegen/handlers/attribute_overrides.py
+++ b/xsdata/codegen/handlers/attribute_overrides.py
@@ -53,7 +53,12 @@ class AttributeOverridesHandler(RelativeHandlerInterface):
and bool_eq(attr.restrictions.tokens, source_attr.restrictions.tokens)
and bool_eq(attr.restrictions.nillable, source_attr.restrictions.nillable)
):
- ClassUtils.remove_attribute(target, attr)
+ cls.remove_attribute(target, attr)
+
+ @classmethod
+ def remove_attribute(cls, target: Class, attr: Attr):
+ ClassUtils.remove_attribute(target, attr)
+ ClassUtils.clean_inner_classes(target)
@classmethod
def resolve_conflict(cls, attr: Attr, source_attr: Attr):
diff --git a/xsdata/codegen/handlers/attribute_type.py b/xsdata/codegen/handlers/attribute_type.py
index e89b45ce..102f5c3e 100644
--- a/xsdata/codegen/handlers/attribute_type.py
+++ b/xsdata/codegen/handlers/attribute_type.py
@@ -143,7 +143,7 @@ class AttributeTypeHandler(RelativeHandlerInterface):
elif source.is_element and source.abstract:
# Substitution groups with abstract elements are used like
# placeholders and shouldn't be added as standalone fields.
- target.attrs.remove(attr)
+ ClassUtils.remove_attribute(target, attr)
else:
if source.nillable:
attr.restrictions.nillable = True
diff --git a/xsdata/codegen/models.py b/xsdata/codegen/models.py
index b4568dfc..d1dd9b01 100644
--- a/xsdata/codegen/models.py
+++ b/xsdata/codegen/models.py
@@ -31,6 +31,7 @@ xml_type_map = {
}
SIMPLE_TYPES = (Tag.EXTENSION, Tag.LIST, Tag.SIMPLE_TYPE, Tag.UNION)
+GLOBAL_TYPES = (Tag.ELEMENT, Tag.BINDING_OPERATION, Tag.BINDING_MESSAGE, Tag.MESSAGE)
@dataclass
@@ -458,6 +459,10 @@ class Class:
"""Shortcut for qname local name."""
return namespaces.local_name(self.qname)
+ @property
+ def ref(self) -> int:
+ return id(self)
+
@property
def target_namespace(self) -> Optional[str]:
return namespaces.target_uri(self.qname)
@@ -484,17 +489,25 @@ class Class:
xs:element."""
return self.tag == Tag.ELEMENT
+ @property
+ def is_enumeration(self) -> bool:
+ """Return whether all attributes are derived from xs:enumeration."""
+ return len(self.attrs) > 0 and all(attr.is_enumeration for attr in self.attrs)
+
+ @property
+ def is_global_type(self) -> bool:
+ """Return whether this instance is a non abstract element, wsdl binding
+ class or a complex type without simple content."""
+ return (not self.abstract and self.tag in GLOBAL_TYPES) or (
+ self.tag == Tag.COMPLEX_TYPE and not self.is_simple_type
+ )
+
@property
def is_group(self) -> bool:
"""Return whether this attribute is derived from an xs:group or
xs:attributeGroup."""
return self.tag in (Tag.ATTRIBUTE_GROUP, Tag.GROUP)
- @property
- def is_enumeration(self) -> bool:
- """Return whether all attributes are derived from xs:enumeration."""
- return len(self.attrs) > 0 and all(attr.is_enumeration for attr in self.attrs)
-
@property
def is_nillable(self) -> bool:
"""Return whether this class represents a nillable xml element."""
@@ -520,15 +533,25 @@ class Class:
)
@property
- def should_generate(self) -> bool:
- """Return whether this instance should be generated."""
- return (
- self.tag
- in (Tag.ELEMENT, Tag.BINDING_OPERATION, Tag.BINDING_MESSAGE, Tag.MESSAGE)
- or self.tag == Tag.COMPLEX_TYPE
- and not self.is_simple_type
- or self.is_enumeration
- )
+ def references(self) -> Iterator[int]:
+ def all_refs():
+ for ext in self.extensions:
+ yield ext.type.reference
+
+ for attr in self.attrs:
+ for tp in attr.types:
+ yield tp.reference
+
+ for choice in attr.choices:
+ for ctp in choice.types:
+ yield ctp.reference
+
+ for inner in self.inner:
+ yield from inner.references
+
+ for ref in all_refs():
+ if ref:
+ yield ref
@property
def target_module(self) -> str:
@@ -602,4 +625,3 @@ get_slug = operator.attrgetter("slug")
get_target_namespace = operator.attrgetter("target_namespace")
is_enumeration = operator.attrgetter("is_enumeration")
is_group = operator.attrgetter("is_group")
-should_generate = operator.attrgetter("should_generate")
diff --git a/xsdata/codegen/utils.py b/xsdata/codegen/utils.py
index 917745e8..40af0222 100644
--- a/xsdata/codegen/utils.py
+++ b/xsdata/codegen/utils.py
@@ -23,11 +23,9 @@ class ClassUtils:
@classmethod
def remove_attribute(cls, target: Class, attr: Attr):
- """Remove the given attr from the target class and clean inner
- classes."""
- target.attrs.remove(attr)
-
- cls.clean_inner_classes(target)
+ """Safely remove the given attr from the target class by check obj
+ ids."""
+ target.attrs = [at for at in target.attrs if id(at) != id(attr)]
@classmethod
def clean_inner_classes(cls, target: Class):
| Abstract stuff has not fully been filtered
From the NeTEx schema;
```python
@dataclass
class Route2(LinkSequenceVersionStructure):
"""
Dummy supertype for Route.
"""
class Meta:
name = "Route_"
namespace = "http://www.netex.org.uk/netex"
```
```xsd
<xsd:element name="Route_" type="LinkSequence_VersionStructure" abstract="true" substitutionGroup="LinkSequence">
<xsd:annotation>
<xsd:documentation>Dummy supertype for Route.</xsd:documentation>
</xsd:annotation>
</xsd:element>
``` | tefra/xsdata | diff --git a/tests/codegen/models/test_class.py b/tests/codegen/models/test_class.py
index 5526164b..899ce6c8 100644
--- a/tests/codegen/models/test_class.py
+++ b/tests/codegen/models/test_class.py
@@ -112,6 +112,13 @@ class ClassTests(FactoryTestCase):
obj = ClassFactory.create(tag=Tag.SIMPLE_TYPE)
self.assertFalse(obj.is_complex)
+ def test_property_is_element(self):
+ obj = ClassFactory.create(tag=Tag.ELEMENT)
+ self.assertTrue(obj.is_element)
+
+ obj = ClassFactory.create(tag=Tag.SIMPLE_TYPE)
+ self.assertFalse(obj.is_element)
+
def test_property_is_enumeration(self):
obj = ClassFactory.enumeration(2)
self.assertTrue(obj.is_enumeration)
@@ -122,7 +129,22 @@ class ClassTests(FactoryTestCase):
obj.attrs.clear()
self.assertFalse(obj.is_enumeration)
- def test_is_simple_type(self):
+ def test_property_is_global_type(self):
+ obj = ClassFactory.create(abstract=True, tag=Tag.ELEMENT)
+ self.assertFalse(obj.is_global_type)
+
+ obj = ClassFactory.create(tag=Tag.ELEMENT)
+ self.assertTrue(obj.is_global_type)
+
+ obj = ClassFactory.create(tag=Tag.COMPLEX_TYPE)
+ obj.extensions.append(ExtensionFactory.create())
+ self.assertTrue(obj.is_global_type)
+
+ obj.extensions.clear()
+ obj.attrs.append(AttrFactory.create(tag=Tag.EXTENSION))
+ self.assertFalse(obj.is_global_type)
+
+ def test_property_is_simple_type(self):
obj = ClassFactory.elements(2)
self.assertFalse(obj.is_simple_type)
@@ -142,27 +164,27 @@ class ClassTests(FactoryTestCase):
self.assertTrue(ClassFactory.create(tag=Tag.ATTRIBUTE_GROUP).is_group)
self.assertFalse(ClassFactory.create(tag=Tag.ELEMENT).is_group)
- def test_property_should_generate(self):
- obj = ClassFactory.create(tag=Tag.ELEMENT)
- self.assertTrue(obj.should_generate)
-
- obj = ClassFactory.create(tag=Tag.COMPLEX_TYPE)
- self.assertTrue(obj.should_generate)
+ def test_property_ref(self):
+ obj = ClassFactory.create()
+ self.assertEqual(id(obj), obj.ref)
- obj.attrs.append(AttrFactory.create(tag=Tag.EXTENSION))
- self.assertFalse(obj.should_generate)
+ def test_property_references(self):
+ ext_1 = ExtensionFactory.create(AttrTypeFactory.create(reference=1))
+ ext_2 = ExtensionFactory.create(AttrTypeFactory.create(reference=2))
- obj = ClassFactory.create(tag=Tag.BINDING_OPERATION)
- self.assertTrue(obj.should_generate)
+ obj = ClassFactory.elements(3)
+ obj.extensions.append(ext_1)
+ obj.extensions.append(ext_2)
- obj = ClassFactory.create(tag=Tag.BINDING_MESSAGE)
- self.assertTrue(obj.should_generate)
+ obj.attrs[0].types[0].reference = 3
+ obj.attrs[1].choices.append(AttrFactory.create())
+ obj.attrs[1].choices[0].types[0].reference = 4
+ obj.attrs[2].types[0].reference = 5
- obj = ClassFactory.enumeration(2)
- self.assertTrue(obj.should_generate)
+ obj.inner.append(ClassFactory.elements(2))
+ obj.inner[0].attrs[1].types[0].reference = 6
- obj = ClassFactory.create(tag=Tag.SIMPLE_TYPE)
- self.assertFalse(obj.should_generate)
+ self.assertEqual(list(range(1, 7)), list(obj.references))
def test_property_target_module(self):
diff --git a/tests/codegen/test_container.py b/tests/codegen/test_container.py
index b4cc109b..9d84ff96 100644
--- a/tests/codegen/test_container.py
+++ b/tests/codegen/test_container.py
@@ -7,6 +7,7 @@ from xsdata.codegen.models import Status
from xsdata.models.config import GeneratorConfig
from xsdata.models.enums import Tag
from xsdata.utils.testing import AttrFactory
+from xsdata.utils.testing import AttrTypeFactory
from xsdata.utils.testing import ClassFactory
from xsdata.utils.testing import FactoryTestCase
@@ -131,24 +132,25 @@ class ClassContainerTests(FactoryTestCase):
for obj in self.container:
self.assertEqual(Status.FLATTENED, obj.status)
- @mock.patch.object(Class, "should_generate", new_callable=mock.PropertyMock)
- def test_filter_classes(self, mock_class_should_generate):
- mock_class_should_generate.side_effect = [True, False, False, True, False]
+ def test_filter_classes(self):
+ complex_type = ClassFactory.elements(1)
+ enum_1 = ClassFactory.enumeration(2)
+ complex_type.attrs[0].types[0].reference = enum_1.ref
+
+ simple_type = ClassFactory.simple_type()
+ enum_2 = ClassFactory.enumeration(3)
+ simple_type.attrs[0].types[0].reference = enum_2.ref
+
+ element = ClassFactory.create(tag=Tag.ELEMENT, abstract=True)
- classes = ClassFactory.list(5)
container = ClassContainer(config=GeneratorConfig())
- container.extend(classes)
+ container.extend([complex_type, enum_1, enum_2, simple_type, element])
- expected = [
- classes[0],
- classes[3],
- ]
+ expected = [complex_type, enum_1]
container.filter_classes()
self.assertEqual(expected, list(container))
- @mock.patch.object(Class, "should_generate", new_callable=mock.PropertyMock)
- def test_filter_classes_with_only_simple_types(self, mock_class_should_generate):
- mock_class_should_generate.return_value = False
+ def test_filter_classes_with_only_simple_types(self):
classes = [ClassFactory.enumeration(2), ClassFactory.simple_type()]
container = ClassContainer(config=GeneratorConfig())
container.extend(classes)
diff --git a/tests/codegen/test_utils.py b/tests/codegen/test_utils.py
index bfc6dfcd..41bbf24b 100644
--- a/tests/codegen/test_utils.py
+++ b/tests/codegen/test_utils.py
@@ -15,8 +15,7 @@ from xsdata.utils.testing import FactoryTestCase
class ClassUtilsTests(FactoryTestCase):
- @mock.patch.object(ClassUtils, "clean_inner_classes")
- def test_remove_attribute(self, mock_clean_inner_classes):
+ def test_remove_attribute(self):
target = ClassFactory.elements(1)
attr = target.attrs[0]
@@ -24,8 +23,6 @@ class ClassUtilsTests(FactoryTestCase):
ClassUtils.remove_attribute(target, attr)
self.assertEqual(0, len(target.attrs))
- mock_clean_inner_classes.assert_called_once_with(target)
-
@mock.patch.object(ClassUtils, "is_orphan_inner")
def test_clean_inner_classes(self, mock_is_orphan_inner):
mock_is_orphan_inner.side_effect = [True, False, True]
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 7
} | 21.11 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[cli,lxml,soap]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-benchmark",
"pytest-cov"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
click-default-group==1.2.4
coverage==7.8.0
docformatter==1.7.5
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
Jinja2==3.1.6
lxml==5.3.1
MarkupSafe==3.0.2
packaging==24.2
pluggy==1.5.0
py-cpuinfo==9.0.0
pytest==8.3.5
pytest-benchmark==5.1.0
pytest-cov==6.0.0
requests==2.32.3
tomli==2.2.1
toposort==1.10
untokenize==0.1.1
urllib3==2.3.0
-e git+https://github.com/tefra/xsdata.git@33605f0cc138ddbf421a6528355006d0eed939c2#egg=xsdata
| name: xsdata
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2025.1.31
- charset-normalizer==3.4.1
- click==8.1.8
- click-default-group==1.2.4
- coverage==7.8.0
- docformatter==1.7.5
- exceptiongroup==1.2.2
- idna==3.10
- iniconfig==2.1.0
- jinja2==3.1.6
- lxml==5.3.1
- markupsafe==3.0.2
- packaging==24.2
- pluggy==1.5.0
- py-cpuinfo==9.0.0
- pytest==8.3.5
- pytest-benchmark==5.1.0
- pytest-cov==6.0.0
- requests==2.32.3
- tomli==2.2.1
- toposort==1.10
- untokenize==0.1.1
- urllib3==2.3.0
prefix: /opt/conda/envs/xsdata
| [
"tests/codegen/models/test_class.py::ClassTests::test_property_is_global_type",
"tests/codegen/models/test_class.py::ClassTests::test_property_ref",
"tests/codegen/models/test_class.py::ClassTests::test_property_references",
"tests/codegen/test_container.py::ClassContainerTests::test_filter_classes",
"tests/codegen/test_container.py::ClassContainerTests::test_filter_classes_with_only_simple_types"
] | [] | [
"tests/codegen/models/test_class.py::ClassTests::test_dependencies",
"tests/codegen/models/test_class.py::ClassTests::test_property_has_suffix_attr",
"tests/codegen/models/test_class.py::ClassTests::test_property_is_complex",
"tests/codegen/models/test_class.py::ClassTests::test_property_is_element",
"tests/codegen/models/test_class.py::ClassTests::test_property_is_enumeration",
"tests/codegen/models/test_class.py::ClassTests::test_property_is_group",
"tests/codegen/models/test_class.py::ClassTests::test_property_is_mixed",
"tests/codegen/models/test_class.py::ClassTests::test_property_is_simple_type",
"tests/codegen/models/test_class.py::ClassTests::test_property_target_module",
"tests/codegen/test_container.py::ClassContainerTests::test_find",
"tests/codegen/test_container.py::ClassContainerTests::test_find_inner",
"tests/codegen/test_container.py::ClassContainerTests::test_first",
"tests/codegen/test_container.py::ClassContainerTests::test_initialize",
"tests/codegen/test_container.py::ClassContainerTests::test_process_class",
"tests/codegen/test_container.py::ClassContainerTests::test_process_classes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_clean_inner_classes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_clone_attribute",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_attributes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_extensions",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_group_attributes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_inner_class",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_inner_class_check_circular_reference",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_inner_class_rename_simple_inner_type",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_inner_class_skip_non_forward_reference",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_inner_class_with_missing_inner",
"tests/codegen/test_utils.py::ClassUtilsTests::test_copy_inner_classes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_filter_types",
"tests/codegen/test_utils.py::ClassUtilsTests::test_find_inner",
"tests/codegen/test_utils.py::ClassUtilsTests::test_flatten",
"tests/codegen/test_utils.py::ClassUtilsTests::test_is_orphan_inner",
"tests/codegen/test_utils.py::ClassUtilsTests::test_merge_attributes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_reduce_attributes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_reduce_classes",
"tests/codegen/test_utils.py::ClassUtilsTests::test_remove_attribute",
"tests/codegen/test_utils.py::ClassUtilsTests::test_rename_attribute_by_preference"
] | [] | MIT License | 11,753 | 2,216 | [
"xsdata/codegen/container.py",
"xsdata/codegen/handlers/attribute_compound_choice.py",
"xsdata/codegen/handlers/attribute_group.py",
"xsdata/codegen/handlers/attribute_overrides.py",
"xsdata/codegen/handlers/attribute_type.py",
"xsdata/codegen/models.py",
"xsdata/codegen/utils.py"
] |
|
pre-commit__pre-commit-2154 | a737d5fe2f083150b31425777eed0803a0ca23e0 | 2021-12-04 21:05:45 | 657e76ba77ef4ae5b6e2ebe5f06cacdbf22a19a2 | diff --git a/pre_commit/clientlib.py b/pre_commit/clientlib.py
index 6377a8b..b8f2368 100644
--- a/pre_commit/clientlib.py
+++ b/pre_commit/clientlib.py
@@ -144,18 +144,13 @@ class OptionalSensibleRegexAtHook(cfgv.OptionalNoDefault):
f"regex, not a glob -- matching '/*' probably isn't what you "
f'want here',
)
- if r'[\/]' in dct.get(self.key, ''):
- logger.warning(
- fr'pre-commit normalizes slashes in the {self.key!r} field '
- fr'in hook {dct.get("id")!r} to forward slashes, so you '
- fr'can use / instead of [\/]',
- )
- if r'[/\\]' in dct.get(self.key, ''):
- logger.warning(
- fr'pre-commit normalizes slashes in the {self.key!r} field '
- fr'in hook {dct.get("id")!r} to forward slashes, so you '
- fr'can use / instead of [/\\]',
- )
+ for fwd_slash_re in (r'[\\/]', r'[\/]', r'[/\\]'):
+ if fwd_slash_re in dct.get(self.key, ''):
+ logger.warning(
+ fr'pre-commit normalizes slashes in the {self.key!r} '
+ fr'field in hook {dct.get("id")!r} to forward slashes, '
+ fr'so you can use / instead of {fwd_slash_re}',
+ )
class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault):
@@ -167,18 +162,13 @@ class OptionalSensibleRegexAtTop(cfgv.OptionalNoDefault):
f'The top-level {self.key!r} field is a regex, not a glob -- '
f"matching '/*' probably isn't what you want here",
)
- if r'[\/]' in dct.get(self.key, ''):
- logger.warning(
- fr'pre-commit normalizes the slashes in the top-level '
- fr'{self.key!r} field to forward slashes, so you can use / '
- fr'instead of [\/]',
- )
- if r'[/\\]' in dct.get(self.key, ''):
- logger.warning(
- fr'pre-commit normalizes the slashes in the top-level '
- fr'{self.key!r} field to forward slashes, so you can use / '
- fr'instead of [/\\]',
- )
+ for fwd_slash_re in (r'[\\/]', r'[\/]', r'[/\\]'):
+ if fwd_slash_re in dct.get(self.key, ''):
+ logger.warning(
+ fr'pre-commit normalizes the slashes in the top-level '
+ fr'{self.key!r} field to forward slashes, so you '
+ fr'can use / instead of {fwd_slash_re}',
+ )
class MigrateShaToRev:
| More on warnings for regular expressions
Hi!
As briefly discussed here:
https://github.com/pre-commit/pre-commit/pull/2053#issuecomment-983436239
`pre-commit` could detect the `[\\/]` regular expression as well.
As of now (pre-commit 2.16.0), such a regex does not trigger any warnings.
Besides, IIRC, the regex `[\/]`, currently detected, matches the single character `/` (not `/` and `\`), so I think it shouldn't be mentioned as an erroneous way for matching both kinds of slashes.
(see https://regex101.com/r/FRPiLZ/1)
Thanks! | pre-commit/pre-commit | diff --git a/tests/clientlib_test.py b/tests/clientlib_test.py
index 5427b1d..a2be51b 100644
--- a/tests/clientlib_test.py
+++ b/tests/clientlib_test.py
@@ -265,6 +265,11 @@ def test_warn_mutable_rev_conditional():
r"pre-commit normalizes slashes in the 'files' field in hook "
r"'flake8' to forward slashes, so you can use / instead of [/\\]",
),
+ (
+ r'dir[\\/].*\.py',
+ r"pre-commit normalizes slashes in the 'files' field in hook "
+ r"'flake8' to forward slashes, so you can use / instead of [\\/]",
+ ),
),
)
def test_validate_optional_sensible_regex_at_hook(caplog, regex, warning):
@@ -295,6 +300,11 @@ def test_validate_optional_sensible_regex_at_hook(caplog, regex, warning):
r"pre-commit normalizes the slashes in the top-level 'files' "
r'field to forward slashes, so you can use / instead of [/\\]',
),
+ (
+ r'dir[\\/].*\.py',
+ r"pre-commit normalizes the slashes in the top-level 'files' "
+ r'field to forward slashes, so you can use / instead of [\\/]',
+ ),
),
)
def test_validate_optional_sensible_regex_at_top_level(caplog, regex, warning):
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 2.16 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": null,
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | cfgv==3.4.0
covdefaults==2.3.0
coverage==7.8.0
distlib==0.3.9
exceptiongroup==1.2.2
filelock==3.18.0
identify==2.6.9
iniconfig==2.1.0
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
-e git+https://github.com/pre-commit/pre-commit.git@a737d5fe2f083150b31425777eed0803a0ca23e0#egg=pre_commit
pytest==8.3.5
pytest-env==1.1.5
PyYAML==6.0.2
re-assert==1.1.0
regex==2024.11.6
toml==0.10.2
tomli==2.2.1
virtualenv==20.29.3
| name: pre-commit
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- cfgv==3.4.0
- covdefaults==2.3.0
- coverage==7.8.0
- distlib==0.3.9
- exceptiongroup==1.2.2
- filelock==3.18.0
- identify==2.6.9
- iniconfig==2.1.0
- nodeenv==1.9.1
- packaging==24.2
- platformdirs==4.3.7
- pluggy==1.5.0
- pytest==8.3.5
- pytest-env==1.1.5
- pyyaml==6.0.2
- re-assert==1.1.0
- regex==2024.11.6
- toml==0.10.2
- tomli==2.2.1
- virtualenv==20.29.3
prefix: /opt/conda/envs/pre-commit
| [
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_hook[dir[\\\\\\\\/].*\\\\.py-pre-commit",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_top_level[dir[\\\\\\\\/].*\\\\.py-pre-commit"
] | [] | [
"tests/clientlib_test.py::test_check_type_tag_failures[definitely-not-a-tag]",
"tests/clientlib_test.py::test_check_type_tag_failures[fiel]",
"tests/clientlib_test.py::test_check_type_tag_success",
"tests/clientlib_test.py::test_config_valid[config_obj0-True]",
"tests/clientlib_test.py::test_config_valid[config_obj1-True]",
"tests/clientlib_test.py::test_config_valid[config_obj2-False]",
"tests/clientlib_test.py::test_local_hooks_with_rev_fails",
"tests/clientlib_test.py::test_config_with_local_hooks_definition_passes",
"tests/clientlib_test.py::test_config_schema_does_not_contain_defaults",
"tests/clientlib_test.py::test_validate_manifest_main_ok",
"tests/clientlib_test.py::test_validate_config_main_ok",
"tests/clientlib_test.py::test_validate_config_old_list_format_ok",
"tests/clientlib_test.py::test_validate_warn_on_unknown_keys_at_repo_level",
"tests/clientlib_test.py::test_validate_warn_on_unknown_keys_at_top_level",
"tests/clientlib_test.py::test_ci_map_key_allowed_at_top_level",
"tests/clientlib_test.py::test_ci_key_must_be_map",
"tests/clientlib_test.py::test_warn_mutable_rev_ok[v0.12.4]",
"tests/clientlib_test.py::test_warn_mutable_rev_ok[b27f281]",
"tests/clientlib_test.py::test_warn_mutable_rev_ok[b27f281eb9398fc8504415d7fbdabf119ea8c5e1]",
"tests/clientlib_test.py::test_warn_mutable_rev_ok[19.10b0]",
"tests/clientlib_test.py::test_warn_mutable_rev_ok[4.3.21-2]",
"tests/clientlib_test.py::test_warn_mutable_rev_invalid[]",
"tests/clientlib_test.py::test_warn_mutable_rev_invalid[HEAD]",
"tests/clientlib_test.py::test_warn_mutable_rev_invalid[stable]",
"tests/clientlib_test.py::test_warn_mutable_rev_invalid[master]",
"tests/clientlib_test.py::test_warn_mutable_rev_invalid[some_branch_name]",
"tests/clientlib_test.py::test_warn_mutable_rev_conditional",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_hook[dir/*.py-The",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_hook[dir[\\\\/].*\\\\.py-pre-commit",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_hook[dir[/\\\\\\\\].*\\\\.py-pre-commit",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_top_level[dir/*.py-The",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_top_level[dir[\\\\/].*\\\\.py-pre-commit",
"tests/clientlib_test.py::test_validate_optional_sensible_regex_at_top_level[dir[/\\\\\\\\].*\\\\.py-pre-commit",
"tests/clientlib_test.py::test_mains_not_ok[validate_config_main]",
"tests/clientlib_test.py::test_mains_not_ok[validate_manifest_main]",
"tests/clientlib_test.py::test_valid_manifests[manifest_obj0-True]",
"tests/clientlib_test.py::test_valid_manifests[manifest_obj1-True]",
"tests/clientlib_test.py::test_valid_manifests[manifest_obj2-True]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct0]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct1]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct2]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_ok[dct3]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_dont_specify_both",
"tests/clientlib_test.py::test_migrate_sha_to_rev_conditional_check_failures[dct0]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_conditional_check_failures[dct1]",
"tests/clientlib_test.py::test_migrate_sha_to_rev_conditional_check_failures[dct2]",
"tests/clientlib_test.py::test_migrate_to_sha_apply_default",
"tests/clientlib_test.py::test_migrate_to_sha_ok",
"tests/clientlib_test.py::test_meta_hook_invalid[config_repo0]",
"tests/clientlib_test.py::test_meta_hook_invalid[config_repo1]",
"tests/clientlib_test.py::test_meta_hook_invalid[config_repo2]",
"tests/clientlib_test.py::test_meta_check_hooks_apply_only_at_top_level",
"tests/clientlib_test.py::test_default_language_version_invalid[mapping0]",
"tests/clientlib_test.py::test_default_language_version_invalid[mapping1]",
"tests/clientlib_test.py::test_minimum_pre_commit_version_failing",
"tests/clientlib_test.py::test_minimum_pre_commit_version_passing",
"tests/clientlib_test.py::test_warn_additional[schema0]",
"tests/clientlib_test.py::test_warn_additional[schema1]"
] | [] | MIT License | 11,754 | 688 | [
"pre_commit/clientlib.py"
] |
|
iterative__dvc-7103 | 9803db6a64cd61352804c41accdd1a404971af13 | 2021-12-06 21:18:12 | 9803db6a64cd61352804c41accdd1a404971af13 | diff --git a/dvc/command/experiments.py b/dvc/command/experiments.py
index 5aa63e158..b097e9e12 100644
--- a/dvc/command/experiments.py
+++ b/dvc/command/experiments.py
@@ -851,7 +851,7 @@ class CmdExperimentsInit(CmdBase):
force=self.args.force,
)
- name = self.args.name or self.args.type
+ name = self.args.name or "train"
text = ui.rich_text.assemble(
"\n" if self.args.interactive else "",
diff --git a/dvc/repo/experiments/init.py b/dvc/repo/experiments/init.py
index feefa01d0..d0aaa4786 100644
--- a/dvc/repo/experiments/init.py
+++ b/dvc/repo/experiments/init.py
@@ -213,7 +213,7 @@ def init(
from dvc.dvcfile import make_dvcfile
dvcfile = make_dvcfile(repo, "dvc.yaml")
- name = name or type
+ name = name or "train"
_check_stage_exists(dvcfile, name, force=force)
| exp init: change stage name to `train`
@dberenbaum, with `--dl`, I don't think `dl` as a default stage name makes sense. Maybe we should go with `train` then?
_Originally posted by @skshetry in https://github.com/iterative/dvc/issues/6446#issuecomment-986792458_ | iterative/dvc | diff --git a/tests/func/experiments/test_init.py b/tests/func/experiments/test_init.py
index 4aabd049a..1ed59d879 100644
--- a/tests/func/experiments/test_init.py
+++ b/tests/func/experiments/test_init.py
@@ -30,10 +30,10 @@ def test_init_simple(tmp_dir, scm, dvc, capsys):
assert main(["exp", "init", script]) == 0
out, err = capsys.readouterr()
assert not err
- assert "Created default stage in dvc.yaml" in out
+ assert "Created train stage in dvc.yaml" in out
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": script,
"deps": ["data", "src"],
"metrics": [{"metrics.json": {"cache": False}}],
@@ -46,38 +46,32 @@ def test_init_simple(tmp_dir, scm, dvc, capsys):
@pytest.mark.parametrize("interactive", [True, False])
[email protected]("typ", ["default", "live"])
-def test_when_stage_already_exists_with_same_name(
- tmp_dir, dvc, interactive, typ
-):
- (tmp_dir / "dvc.yaml").dump({"stages": {typ: {"cmd": "test"}}})
+def test_when_stage_already_exists_with_same_name(tmp_dir, dvc, interactive):
+ (tmp_dir / "dvc.yaml").dump({"stages": {"train": {"cmd": "test"}}})
with pytest.raises(DuplicateStageName) as exc:
init(
dvc,
interactive=interactive,
- type=typ,
overrides={"cmd": "true"},
defaults=CmdExperimentsInit.DEFAULTS,
)
assert (
- str(exc.value) == f"Stage '{typ}' already exists in 'dvc.yaml'. "
+ str(exc.value) == "Stage 'train' already exists in 'dvc.yaml'. "
"Use '--force' to overwrite."
)
[email protected]("typ", ["default", "live"])
-def test_when_stage_force_if_already_exists(tmp_dir, dvc, typ):
+def test_when_stage_force_if_already_exists(tmp_dir, dvc):
(tmp_dir / "params.yaml").dump({"foo": 1})
- (tmp_dir / "dvc.yaml").dump({"stages": {typ: {"cmd": "test"}}})
+ (tmp_dir / "dvc.yaml").dump({"stages": {"train": {"cmd": "test"}}})
init(
dvc,
- type=typ,
force=True,
overrides={"cmd": "true"},
defaults=CmdExperimentsInit.DEFAULTS,
)
d = (tmp_dir / "dvc.yaml").parse()
- assert d["stages"][typ]["cmd"] == "true"
+ assert d["stages"]["train"]["cmd"] == "true"
def test_with_a_custom_name(tmp_dir, dvc):
@@ -91,7 +85,7 @@ def test_init_with_no_defaults_non_interactive(tmp_dir, scm, dvc):
init(dvc, defaults={}, overrides={"cmd": "python script.py"})
assert (tmp_dir / "dvc.yaml").parse() == {
- "stages": {"default": {"cmd": "python script.py"}}
+ "stages": {"train": {"cmd": "python script.py"}}
}
scm._reset()
assert not (tmp_dir / "dvc.lock").exists()
@@ -134,7 +128,7 @@ def test_init_interactive_when_no_path_prompts_need_to_be_asked(
)
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": "cmd",
"deps": ["data", "src"],
"live": {"dvclive": {"html": True, "summary": True}},
@@ -159,7 +153,7 @@ def test_when_params_is_omitted_in_interactive_mode(tmp_dir, scm, dvc):
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": "python script.py",
"deps": ["data", "script.py"],
"metrics": [{"metrics.json": {"cache": False}}],
@@ -189,7 +183,7 @@ def test_init_interactive_params_validation(tmp_dir, dvc, capsys):
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": "python script.py",
"deps": ["data", "script.py"],
"metrics": [{"metrics.json": {"cache": False}}],
@@ -232,7 +226,7 @@ def test_init_with_no_defaults_interactive(tmp_dir, dvc):
)
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": "python script.py",
"deps": ["python script.py", "script.py"],
"metrics": [{"metric": {"cache": False}}],
@@ -278,7 +272,7 @@ def test_init_interactive_default(
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": "python script.py",
"deps": ["data", "script.py"],
"metrics": [{"metrics.json": {"cache": False}}],
@@ -359,7 +353,7 @@ def test_init_interactive_live(
)
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "dl": {
+ "train": {
"cmd": "python script.py",
"deps": ["data", "script.py"],
"live": {"dvclive": {"html": True, "summary": True}},
@@ -403,7 +397,7 @@ def test_init_with_type_live_and_models_plots_provided(
)
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "dl": {
+ "train": {
"cmd": "cmd",
"deps": ["data", "src"],
"live": {"dvclive": {"html": True, "summary": True}},
@@ -436,7 +430,7 @@ def test_init_with_type_default_and_live_provided(
)
assert (tmp_dir / "dvc.yaml").parse() == {
"stages": {
- "default": {
+ "train": {
"cmd": "cmd",
"deps": ["data", "src"],
"live": {"live": {"html": True, "summary": True}},
diff --git a/tests/unit/command/test_experiments.py b/tests/unit/command/test_experiments.py
index c256c2184..8a3681d7c 100644
--- a/tests/unit/command/test_experiments.py
+++ b/tests/unit/command/test_experiments.py
@@ -628,7 +628,7 @@ def test_experiments_init(dvc, scm, mocker, capsys, extra_args):
interactive=False,
force=False,
)
- expected = "Created default stage in dvc.yaml."
+ expected = "Created train stage in dvc.yaml."
if not extra_args:
expected += (
' To run, use "dvc exp run".\n'
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 2.8 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | adlfs==2023.8.0
aiobotocore==1.4.2
aiohappyeyeballs==2.6.1
aiohttp==3.11.14
aiohttp-retry==2.9.1
aioitertools==0.12.0
aiosignal==1.3.2
aliyun-python-sdk-core==2.16.0
aliyun-python-sdk-kms==2.16.5
anyio==4.9.0
appdirs==1.4.4
argcomplete==3.6.1
astroid==2.9.3
async-timeout==5.0.1
asyncssh==2.8.1
atpublic==5.1
attrs==21.4.0
azure-core==1.32.0
azure-datalake-store==0.0.53
azure-identity==1.21.0
azure-storage-blob==12.25.1
bcrypt==4.3.0
boto==2.49.0
boto3==1.17.106
botocore==1.20.106
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
collective.checkdocs==0.2
colorama==0.4.6
configobj==5.0.9
coverage==7.8.0
crc32c==2.2.post0
crcmod==1.7
cryptography==43.0.3
decorator==5.2.1
defusedxml==0.7.1
dictdiffer==0.9.0
diskcache==5.6.3
distro==1.9.0
docker==7.1.0
docker-compose==1.29.2
dockerpty==0.4.1
docopt==0.6.2
docutils==0.21.2
dpath==2.2.0
dulwich==0.22.8
-e git+https://github.com/iterative/dvc.git@9803db6a64cd61352804c41accdd1a404971af13#egg=dvc
dvc-ssh==0.0.1a0
dvclive==0.4.5
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
execnet==2.1.1
filelock==3.4.0
flaky==3.7.0
flatten-dict==0.4.2
flufl.lock==8.1.0
frozenlist==1.5.0
fsspec==2021.11.0
funcy==2.0
future==1.0.0
gcsfs==2021.11.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==2.24.2
google-api-python-client==2.166.0
google-auth==2.38.0
google-auth-httplib2==0.2.0
google-auth-oauthlib==1.2.1
google-cloud-core==2.4.3
google-cloud-storage==1.43.0
google-compute-engine==2.8.13
google-crc32c==1.7.1
google-resumable-media==2.7.2
googleapis-common-protos==1.69.2
grandalf==0.6
h11==0.14.0
hdfs==2.6.0
httpcore==1.0.7
httplib2==0.22.0
httpx==0.28.1
idna==3.10
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
isodate==0.7.2
isort==5.13.2
Jinja2==3.1.6
jmespath==0.10.0
json5==0.10.0
jsonschema==3.2.0
knack==0.12.0
lazy-object-proxy==1.10.0
markdown-it-py==2.2.0
MarkupSafe==3.0.2
mccabe==0.6.1
mdurl==0.1.2
miutil==0.13
mock==4.0.3
mock-ssh-server==0.9.1
msal==1.32.0
msal-extensions==1.3.1
multidict==6.2.0
mypy==0.910
mypy_extensions==0.4.4
nanotime==0.5.2
networkx==3.2.1
oauth2client==4.1.3
oauthlib==3.2.2
oss2==2.19.1
ossfs==2021.8.0
packaging @ file:///croot/packaging_1734472117206/work
paramiko==3.5.1
pathspec==0.9.0
pillow==11.1.0
platformdirs==4.3.7
pluggy @ file:///croot/pluggy_1733169602837/work
ply==3.11
propcache==0.3.1
proto-plus==1.26.1
protobuf==6.30.2
psutil==7.0.0
py==1.11.0
pyarrow==19.0.1
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycparser==2.22
pycryptodome==3.22.0
pydocstyle==6.1.1
pydot==3.0.4
PyDrive2==1.21.3
pygit2==1.15.1
Pygments==2.10.0
pygtrie==2.5.0
PyJWT==2.10.1
pylint==2.12.2
pylint-plugin-utils==0.6
pylint-pytest==1.1.2
PyNaCl==1.5.0
pyOpenSSL==24.2.1
pyparsing==3.2.3
pyrsistent==0.20.0
pytest==6.2.5
pytest-cov==3.0.0
pytest-docker==0.10.3
pytest-forked==1.6.0
pytest-lazy-fixture==0.6.3
pytest-mock==3.6.1
pytest-timeout==2.0.1
pytest-xdist==2.4.0
python-benedict==0.34.1
python-dateutil==2.9.0.post0
python-dotenv==0.21.1
python-fsutil==0.15.0
python-slugify==8.0.4
python-terraform==0.10.1
PyYAML==5.4.1
rangehttpserver==1.2.0
requests==2.32.3
requests-oauthlib==2.0.0
rich==13.2.0
rsa==4.9
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
s3fs==2021.11.0
s3transfer==0.4.2
scmrepo==0.0.3
shortuuid==1.0.13
shtab==1.7.1
six==1.17.0
smmap==5.0.2
sniffio==1.3.1
snowballstemmer==2.2.0
sshfs==2022.3.1
tabulate==0.9.0
text-unidecode==1.3
texttable==1.7.0
toml==0.10.2
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
tpi==2.1.0
tqdm==4.67.1
types-requests==2.26.1
types-tabulate==0.8.3
types-toml==0.10.1
typing_extensions==4.13.0
uritemplate==4.1.1
urllib3==1.26.20
voluptuous==0.15.2
webdav4==0.10.0
websocket-client==0.59.0
wget==3.2
wrapt==1.13.3
WsgiDAV==3.1.1
xmltodict==0.12.0
yarl==1.18.3
zc.lockfile==3.0.post1
| name: dvc
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- adlfs==2023.8.0
- aiobotocore==1.4.2
- aiohappyeyeballs==2.6.1
- aiohttp==3.11.14
- aiohttp-retry==2.9.1
- aioitertools==0.12.0
- aiosignal==1.3.2
- aliyun-python-sdk-core==2.16.0
- aliyun-python-sdk-kms==2.16.5
- anyio==4.9.0
- appdirs==1.4.4
- argcomplete==3.6.1
- astroid==2.9.3
- async-timeout==5.0.1
- asyncssh==2.8.1
- atpublic==5.1
- attrs==21.4.0
- azure-core==1.32.0
- azure-datalake-store==0.0.53
- azure-identity==1.21.0
- azure-storage-blob==12.25.1
- bcrypt==4.3.0
- boto==2.49.0
- boto3==1.17.106
- botocore==1.20.106
- cachetools==5.5.2
- certifi==2025.1.31
- cffi==1.17.1
- charset-normalizer==3.4.1
- collective-checkdocs==0.2
- colorama==0.4.6
- configobj==5.0.9
- coverage==7.8.0
- crc32c==2.2.post0
- crcmod==1.7
- cryptography==43.0.3
- decorator==5.2.1
- defusedxml==0.7.1
- dictdiffer==0.9.0
- diskcache==5.6.3
- distro==1.9.0
- docker==7.1.0
- docker-compose==1.29.2
- dockerpty==0.4.1
- docopt==0.6.2
- docutils==0.21.2
- dpath==2.2.0
- dulwich==0.22.8
- dvc==2.8.4.dev107+g9803db6a6
- dvc-ssh==0.0.1a0
- dvclive==0.4.5
- execnet==2.1.1
- filelock==3.4.0
- flaky==3.7.0
- flatten-dict==0.4.2
- flufl-lock==8.1.0
- frozenlist==1.5.0
- fsspec==2021.11.0
- funcy==2.0
- future==1.0.0
- gcsfs==2021.11.0
- gitdb==4.0.12
- gitpython==3.1.44
- google-api-core==2.24.2
- google-api-python-client==2.166.0
- google-auth==2.38.0
- google-auth-httplib2==0.2.0
- google-auth-oauthlib==1.2.1
- google-cloud-core==2.4.3
- google-cloud-storage==1.43.0
- google-compute-engine==2.8.13
- google-crc32c==1.7.1
- google-resumable-media==2.7.2
- googleapis-common-protos==1.69.2
- grandalf==0.6
- h11==0.14.0
- hdfs==2.6.0
- httpcore==1.0.7
- httplib2==0.22.0
- httpx==0.28.1
- idna==3.10
- isodate==0.7.2
- isort==5.13.2
- jinja2==3.1.6
- jmespath==0.10.0
- json5==0.10.0
- jsonschema==3.2.0
- knack==0.12.0
- lazy-object-proxy==1.10.0
- markdown-it-py==2.2.0
- markupsafe==3.0.2
- mccabe==0.6.1
- mdurl==0.1.2
- miutil==0.13
- mock==4.0.3
- mock-ssh-server==0.9.1
- msal==1.32.0
- msal-extensions==1.3.1
- multidict==6.2.0
- mypy==0.910
- mypy-extensions==0.4.4
- nanotime==0.5.2
- networkx==3.2.1
- oauth2client==4.1.3
- oauthlib==3.2.2
- oss2==2.19.1
- ossfs==2021.8.0
- paramiko==3.5.1
- pathspec==0.9.0
- pillow==11.1.0
- platformdirs==4.3.7
- ply==3.11
- propcache==0.3.1
- proto-plus==1.26.1
- protobuf==6.30.2
- psutil==7.0.0
- py==1.11.0
- pyarrow==19.0.1
- pyasn1==0.6.1
- pyasn1-modules==0.4.2
- pycparser==2.22
- pycryptodome==3.22.0
- pydocstyle==6.1.1
- pydot==3.0.4
- pydrive2==1.21.3
- pygit2==1.15.1
- pygments==2.10.0
- pygtrie==2.5.0
- pyjwt==2.10.1
- pylint==2.12.2
- pylint-plugin-utils==0.6
- pylint-pytest==1.1.2
- pynacl==1.5.0
- pyopenssl==24.2.1
- pyparsing==3.2.3
- pyrsistent==0.20.0
- pytest==6.2.5
- pytest-cov==3.0.0
- pytest-docker==0.10.3
- pytest-forked==1.6.0
- pytest-lazy-fixture==0.6.3
- pytest-mock==3.6.1
- pytest-timeout==2.0.1
- pytest-xdist==2.4.0
- python-benedict==0.34.1
- python-dateutil==2.9.0.post0
- python-dotenv==0.21.1
- python-fsutil==0.15.0
- python-slugify==8.0.4
- python-terraform==0.10.1
- pyyaml==5.4.1
- rangehttpserver==1.2.0
- requests==2.32.3
- requests-oauthlib==2.0.0
- rich==13.2.0
- rsa==4.9
- ruamel-yaml==0.18.10
- ruamel-yaml-clib==0.2.12
- s3fs==2021.11.0
- s3transfer==0.4.2
- scmrepo==0.0.3
- shortuuid==1.0.13
- shtab==1.7.1
- six==1.17.0
- smmap==5.0.2
- sniffio==1.3.1
- snowballstemmer==2.2.0
- sshfs==2022.3.1
- tabulate==0.9.0
- text-unidecode==1.3
- texttable==1.7.0
- toml==0.10.2
- tpi==2.1.0
- tqdm==4.67.1
- types-requests==2.26.1
- types-tabulate==0.8.3
- types-toml==0.10.1
- typing-extensions==4.13.0
- uritemplate==4.1.1
- urllib3==1.26.20
- voluptuous==0.15.2
- webdav4==0.10.0
- websocket-client==0.59.0
- wget==3.2
- wheel==0.37.0
- wrapt==1.13.3
- wsgidav==3.1.1
- xmltodict==0.12.0
- yarl==1.18.3
- zc-lockfile==3.0.post1
prefix: /opt/conda/envs/dvc
| [
"tests/func/experiments/test_init.py::test_init_simple",
"tests/func/experiments/test_init.py::test_when_stage_already_exists_with_same_name[True]",
"tests/func/experiments/test_init.py::test_when_stage_already_exists_with_same_name[False]",
"tests/func/experiments/test_init.py::test_when_stage_force_if_already_exists",
"tests/func/experiments/test_init.py::test_init_with_no_defaults_non_interactive",
"tests/func/experiments/test_init.py::test_init_interactive_when_no_path_prompts_need_to_be_asked[extra_overrides0-inp0]",
"tests/func/experiments/test_init.py::test_init_interactive_when_no_path_prompts_need_to_be_asked[extra_overrides1-inp1]",
"tests/func/experiments/test_init.py::test_when_params_is_omitted_in_interactive_mode",
"tests/func/experiments/test_init.py::test_init_interactive_params_validation",
"tests/func/experiments/test_init.py::test_init_with_no_defaults_interactive",
"tests/func/experiments/test_init.py::test_init_interactive_default[non-interactive]",
"tests/func/experiments/test_init.py::test_init_interactive_default[interactive]",
"tests/func/experiments/test_init.py::test_init_interactive_live[non-interactive]",
"tests/func/experiments/test_init.py::test_init_interactive_live[interactive]",
"tests/func/experiments/test_init.py::test_init_interactive_live[interactive-cmd-provided]",
"tests/func/experiments/test_init.py::test_init_interactive_live[interactive-cmd-models-provided]",
"tests/func/experiments/test_init.py::test_init_with_type_live_and_models_plots_provided[False-None]",
"tests/func/experiments/test_init.py::test_init_with_type_live_and_models_plots_provided[True-inp1]",
"tests/func/experiments/test_init.py::test_init_with_type_default_and_live_provided[False-None]",
"tests/func/experiments/test_init.py::test_init_with_type_default_and_live_provided[True-inp1]",
"tests/unit/command/test_experiments.py::test_experiments_init[extra_args0]",
"tests/unit/command/test_experiments.py::test_experiments_init[extra_args1]"
] | [] | [
"tests/func/experiments/test_init.py::test_with_a_custom_name",
"tests/func/experiments/test_init.py::test_abort_confirmation",
"tests/unit/command/test_experiments.py::test_experiments_apply",
"tests/unit/command/test_experiments.py::test_experiments_diff",
"tests/unit/command/test_experiments.py::test_experiments_diff_revs",
"tests/unit/command/test_experiments.py::test_experiments_show",
"tests/unit/command/test_experiments.py::test_experiments_run",
"tests/unit/command/test_experiments.py::test_experiments_gc",
"tests/unit/command/test_experiments.py::test_experiments_branch",
"tests/unit/command/test_experiments.py::test_experiments_list",
"tests/unit/command/test_experiments.py::test_experiments_push",
"tests/unit/command/test_experiments.py::test_experiments_pull",
"tests/unit/command/test_experiments.py::test_experiments_remove[True-False-None]",
"tests/unit/command/test_experiments.py::test_experiments_remove[False-True-None]",
"tests/unit/command/test_experiments.py::test_experiments_remove[False-False-True]",
"tests/unit/command/test_experiments.py::test_show_experiments_csv",
"tests/unit/command/test_experiments.py::test_show_experiments_md",
"tests/unit/command/test_experiments.py::test_show_experiments_sort_by[asc]",
"tests/unit/command/test_experiments.py::test_show_experiments_sort_by[desc]",
"tests/unit/command/test_experiments.py::test_experiments_init_config",
"tests/unit/command/test_experiments.py::test_experiments_init_explicit",
"tests/unit/command/test_experiments.py::test_experiments_init_cmd_required_for_non_interactive_mode",
"tests/unit/command/test_experiments.py::test_experiments_init_cmd_not_required_for_interactive_mode",
"tests/unit/command/test_experiments.py::test_experiments_init_extra_args[extra_args0-expected_kw0]",
"tests/unit/command/test_experiments.py::test_experiments_init_extra_args[extra_args1-expected_kw1]",
"tests/unit/command/test_experiments.py::test_experiments_init_extra_args[extra_args2-expected_kw2]",
"tests/unit/command/test_experiments.py::test_experiments_init_extra_args[extra_args3-expected_kw3]",
"tests/unit/command/test_experiments.py::test_experiments_init_extra_args[extra_args4-expected_kw4]",
"tests/unit/command/test_experiments.py::test_experiments_init_type_invalid_choice"
] | [] | Apache License 2.0 | 11,764 | 288 | [
"dvc/command/experiments.py",
"dvc/repo/experiments/init.py"
] |
|
fgnt__lazy_dataset-49 | ff1e16cc68fb98620ccd2e639112c1801d12c4a8 | 2021-12-07 09:17:10 | ff1e16cc68fb98620ccd2e639112c1801d12c4a8 | diff --git a/lazy_dataset/core.py b/lazy_dataset/core.py
index 6a55273..56cb6c9 100644
--- a/lazy_dataset/core.py
+++ b/lazy_dataset/core.py
@@ -27,7 +27,7 @@ def _get_serialize_and_deserialize(immutable_warranty):
def new(
- examples: Union[list, dict],
+ examples: Union[list, dict, 'Dataset'],
immutable_warranty: str = 'pickle',
name: str = None,
):
@@ -73,6 +73,9 @@ def new(
>>> ds = lazy_dataset.new([1, 2, 3, 4, 5])
>>> list(ds)
[1, 2, 3, 4, 5]
+ >>> lazy_dataset.new(ds)
+ ListDataset(len=5)
+ MapDataset(_pickle.loads)
"""
if isinstance(examples, dict):
@@ -81,6 +84,9 @@ def new(
elif isinstance(examples, (tuple, list)):
dataset = from_list(
examples, immutable_warranty=immutable_warranty, name=name)
+ elif isinstance(examples, Dataset):
+ dataset = from_dataset(
+ examples, immutable_warranty=immutable_warranty, name=name)
else:
raise TypeError(type(examples), examples)
return dataset
@@ -97,7 +103,7 @@ def from_dict(
def from_list(
- examples: list,
+ examples: [list, tuple],
immutable_warranty: str = 'pickle',
name: str = None,
):
@@ -107,6 +113,50 @@ def from_list(
return ListDataset(examples, name=name).map(deserialize)
+def from_dataset(
+ examples: 'Dataset',
+ immutable_warranty: str = 'pickle',
+ name: str = None,
+):
+ """
+ Similar to caching. Iterates over the whole dataset and creates a new
+ dataset from the obtained examples. If the input dataset has `.items()`,
+ the new dataset will be indexable and have `.keys()` and `.items()` (even
+ if the input dataset did not have `.keys()`). If not, the new
+ dataset will not have `.keys()`.
+
+ Example:
+ >>> ds = from_dataset(new([1, 2, 3, 4]))
+ >>> ds
+ ListDataset(len=4)
+ MapDataset(_pickle.loads)
+ >>> list(ds)
+ [1, 2, 3, 4]
+ >>> ds = from_dataset(new({'a': 1, 'b': 2, 'c': 3, 'd': 4}).map(lambda x: x**2))
+ >>> ds
+ DictDataset(len=4)
+ MapDataset(_pickle.loads)
+ >>> dict(ds)
+ {'a': 1, 'b': 4, 'c': 9, 'd': 16}
+
+ Works with filtered datasets:
+ >>> ds = from_dataset(new([1, 2, 3, 4]).filter(lambda x: x%2))
+ >>> list(ds)
+ [1, 3]
+ >>> ds = from_dataset(new({'a': 1, 'b': 2, 'c': 3, 'd': 4}).filter(lambda x: x%2))
+ >>> dict(ds)
+ {'a': 1, 'c': 3}
+ """
+ try:
+ items = list(examples.items())
+ except ItemsNotDefined:
+ return from_list(list(examples),
+ immutable_warranty=immutable_warranty, name=name)
+ else:
+ return from_dict(dict(items),
+ immutable_warranty=immutable_warranty, name=name)
+
+
def concatenate(*datasets):
"""
Create a new `Dataset` by concatenation of all passed datasets.
@@ -666,7 +716,7 @@ class Dataset:
)
idx = [i for i, e in enumerate(self) if filter_fn(e)]
if len(self) > len(idx):
- LOG.info(f'Filtered {len(self)-len(idx)} of {len(self)} examples.')
+ LOG.info(f'Filtered {len(self) - len(idx)} of {len(self)} examples.')
return self[idx]
def catch(self, exceptions=FilterException,
@@ -1415,13 +1465,7 @@ class Dataset:
assert self.indexable or self.ordered, (
'Caching is only supported for indexable or ordered datasets.'
)
-
- try:
- self.keys()
- except NotImplementedError:
- return from_list(list(self))
- else:
- return from_dict(dict(self))
+ return new(self)
def diskcache(
self,
@@ -3572,8 +3616,8 @@ class ProfilingDataset(Dataset):
hits += f' ({self.hit_count[1]} filtered)'
# Better alternative for the name "fetch duration"?
- r += (f' (fetch duration = {datetime.timedelta(seconds=self.time[0])}, '
- f'{hits})')
+ r += (f' (fetch duration = {datetime.timedelta(seconds=self.time[0])}, '
+ f'{hits})')
return r
def __len__(self):
| Support lazy_dataset.new(other_dataset)
It would be logical if `lazy_dataset.new` would accept another dataset, like this:
```python
import lazy_dataset
lazy_dataset.new(lazy_dataset.new([1, 2, 3, 4]))
```
But it is unclear how `new` should handle datasets. It could
- return the input dataset
- make a copy of the dataset (`return dataset.copy(freeze=??)`)
- cache and transform into `ListDataset` or `DictDataset`, i.e., `lazy_dataset.new(list(lazy_dataset.new([1, 2, 3, 4])))` or `lazy_dataset.new(dict(lazy_dataset.new({'a': 1, 'b': 2})))` | fgnt/lazy_dataset | diff --git a/tests/test_str.py b/tests/test_str.py
index 493b9cb..5c0660c 100644
--- a/tests/test_str.py
+++ b/tests/test_str.py
@@ -66,7 +66,7 @@ def test():
ds = ds_dict.filter(lambda ex: True).cache(lazy=False)
check(ds, 'MapDataset(_pickle.loads)',
- ' ListDataset(len=4)\n'
+ ' DictDataset(len=4)\n'
'MapDataset(_pickle.loads)')
ds = ds_dict.diskcache()
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 1
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[all]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest",
"pytest-cov",
"codecov"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.7",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs @ file:///croot/attrs_1668696182826/work
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
codecov==2.1.13
coverage==7.2.7
diskcache==5.6.3
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
humanfriendly==10.0
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
-e git+https://github.com/fgnt/lazy_dataset.git@ff1e16cc68fb98620ccd2e639112c1801d12c4a8#egg=lazy_dataset
mock==5.2.0
numpy==1.21.6
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
psutil==7.0.0
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pytest==7.1.2
pytest-cov==4.1.0
requests==2.31.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
urllib3==2.0.7
zipp @ file:///croot/zipp_1672387121353/work
| name: lazy_dataset
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- attrs=22.1.0=py37h06a4308_0
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- flit-core=3.6.0=pyhd3eb1b0_0
- importlib-metadata=4.11.3=py37h06a4308_0
- importlib_metadata=4.11.3=hd3eb1b0_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- packaging=22.0=py37h06a4308_0
- pip=22.3.1=py37h06a4308_0
- pluggy=1.0.0=py37h06a4308_1
- py=1.11.0=pyhd3eb1b0_0
- pytest=7.1.2=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py37h06a4308_0
- typing_extensions=4.4.0=py37h06a4308_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zipp=3.11.0=py37h06a4308_0
- zlib=1.2.13=h5eee18b_1
- pip:
- charset-normalizer==3.4.1
- codecov==2.1.13
- coverage==7.2.7
- diskcache==5.6.3
- humanfriendly==10.0
- idna==3.10
- mock==5.2.0
- numpy==1.21.6
- psutil==7.0.0
- pytest-cov==4.1.0
- requests==2.31.0
- urllib3==2.0.7
prefix: /opt/conda/envs/lazy_dataset
| [
"tests/test_str.py::test"
] | [] | [] | [] | MIT License | 11,766 | 1,204 | [
"lazy_dataset/core.py"
] |
|
feature-engine__feature_engine-339 | cceeed2515b9dd709779c91185eb7e3a0bcddcb7 | 2021-12-07 18:41:44 | d26e5684091501d49ce40c1fc854d6f7510dc530 | dodoarg: Sorry about the verbose responses @solegalli, I tried to keep it simple in the PR description but unfortunately this opened a small can of worms :/
solegalli: > Sorry about the verbose responses @solegalli, I tried to keep it simple in the PR description but unfortunately this opened a small can of worms :/
No problem at all, I am always happy to learn new stuff :)
thanks for the detail and dedication
solegalli: Hi @dodoarg
Suggested a few changes here:https://github.com/dodoarg/feature_engine/pull/2
This is ready to go. Thank you!
dodoarg: I believe this is ready to go now?
solegalli: @SunnyxBd small change here in one of the classes you are working on. | diff --git a/feature_engine/selection/target_mean_selection.py b/feature_engine/selection/target_mean_selection.py
index c55717b..6eba350 100644
--- a/feature_engine/selection/target_mean_selection.py
+++ b/feature_engine/selection/target_mean_selection.py
@@ -201,7 +201,7 @@ class SelectByTargetMeanPerformance(BaseSelector):
# find categorical and numerical variables
self.variables_categorical_ = list(X.select_dtypes(include="O").columns)
self.variables_numerical_ = list(
- X.select_dtypes(include=["float", "integer"]).columns
+ X.select_dtypes(include="number").columns
)
# obtain cross-validation indeces
diff --git a/feature_engine/variable_manipulation.py b/feature_engine/variable_manipulation.py
index a8430cb..a043dad 100644
--- a/feature_engine/variable_manipulation.py
+++ b/feature_engine/variable_manipulation.py
@@ -4,6 +4,10 @@ from typing import Any, List, Union
import pandas as pd
+from pandas.api.types import is_numeric_dtype as is_numeric
+from pandas.api.types import is_categorical_dtype as is_categorical
+from pandas.api.types import is_object_dtype as is_object
+
Variables = Union[None, int, str, List[Union[str, int]]]
@@ -44,40 +48,47 @@ def _find_or_check_numerical_variables(
Parameters
----------
- X : Pandas DataFrame
+ X : Pandas DataFrame.
variables : variable or list of variables. Defaults to None.
Raises
------
ValueError
- If there are no numerical variables in the df or the df is empty
+ If there are no numerical variables in the df or the df is empty.
TypeError
- If any of the user provided variables are not numerical
+ If any of the user provided variables are not numerical.
Returns
-------
- variables: List of numerical variables
+ variables: List of numerical variables.
"""
- if isinstance(variables, (str, int)):
- variables = [variables]
-
- elif not variables:
+ if variables is None:
# find numerical variables in dataset
variables = list(X.select_dtypes(include="number").columns)
if len(variables) == 0:
raise ValueError(
- "No numerical variables in this dataframe. Please check variable"
- "format with pandas dtypes"
+ "No numerical variables found in this dataframe. Please check "
+ "variable format with pandas dtypes."
)
+ elif isinstance(variables, (str, int)):
+ if is_numeric(X[variables]):
+ variables = [variables]
+ else:
+ raise TypeError("The variable entered is not numeric.")
+
else:
+ if len(variables) == 0:
+ raise ValueError("The list of variables is empty.")
+
# check that user entered variables are of type numerical
- if any(X[variables].select_dtypes(exclude="number").columns):
- raise TypeError(
- "Some of the variables are not numerical. Please cast them as "
- "numerical before using this transformer"
- )
+ else:
+ if len(X[variables].select_dtypes(exclude="number").columns) > 0:
+ raise TypeError(
+ "Some of the variables are not numerical. Please cast them as "
+ "numerical before using this transformer."
+ )
return variables
@@ -91,38 +102,47 @@ def _find_or_check_categorical_variables(
Parameters
----------
- X : pandas DataFrame
+ X : pandas DataFrame.
variables : variable or list of variables. Defaults to None.
Raises
------
ValueError
- If there are no categorical variables in df or df is empty
+ If there are no categorical variables in df or df is empty.
TypeError
- If any of the user provided variables are not categorical
+ If any of the user provided variables are not categorical.
Returns
-------
- variables : List of categorical variables
+ variables : List of categorical variables.
"""
- if isinstance(variables, (str, int)):
- variables = [variables]
-
- elif not variables:
+ if variables is None:
+ # find categorical variables in dataset
variables = list(X.select_dtypes(include=["O", "category"]).columns)
if len(variables) == 0:
raise ValueError(
- "No categorical variables in this dataframe. Please check the "
- "variables format with pandas dtypes"
+ "No categorical variables found in this dataframe. Please check "
+ "variable format with pandas dtypes."
)
+ elif isinstance(variables, (str, int)):
+ if is_categorical(X[variables]) or is_object(X[variables]):
+ variables = [variables]
+ else:
+ raise TypeError("The variable entered is not categorical.")
+
else:
- if any(X[variables].select_dtypes(exclude=["O", "category"]).columns):
- raise TypeError(
- "Some of the variables are not categorical. Please cast them as object "
- "or category before calling this transformer"
- )
+ if len(variables) == 0:
+ raise ValueError("The list of variables is empty.")
+
+ # check that user entered variables are of type numerical
+ else:
+ if len(X[variables].select_dtypes(exclude=["O", "category"]).columns) > 0:
+ raise TypeError(
+ "Some of the variables are not categorical. Please cast them as "
+ "categorical or object before using this transformer."
+ )
return variables
| no numerical or categorical variable checks when user passes string instead of list
`_find_or_check_numerical_variable`s and `_find_or_check_categorical_variables` don't check variable type when user passes string instead of list
Copying @dodoarg code that spots this issue:
Please have a look at the demo below (on the PowerTransformer, which I haven't touched in my fork) <br>
Here, _variables_ is passed as a list and the correct TypeError is thrown at the _find_or_check_numerical_variables level:
```
>>> pt = PowerTransformer(variables=["City"])
>>> pt.fit(df)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\feature_engine\feature_engine\transformation\power.py", line 82, in fit
X = super().fit(X)
File "D:\feature_engine\feature_engine\base_transformers.py", line 98, in fit
self.variables_ = _find_or_check_numerical_variables(X, self.variables)
File "D:\feature_engine\feature_engine\variable_manipulation.py", line 82, in _find_or_check_numerical_variables
raise TypeError(
TypeError: Some of the variables are not numerical. Please cast them as numerical before using this transformer
```
Here instead variables is passed as a str (which _check_input_parameter_variables __allows__) but _find_or_check_numerical_variables doesn't actually run any checks, so the logic goes on up until the line where the column is checked for the presence of inf, which fails because City is an object variable, and should not have made it that far in the code
```
>>> pt = PowerTransformer(variables="City")
>>> pt.fit(df)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\feature_engine\feature_engine\transformation\power.py", line 82, in fit
X = super().fit(X)
File "D:\feature_engine\feature_engine\base_transformers.py", line 102, in fit
_check_contains_inf(X, self.variables_)
File "D:\feature_engine\feature_engine\dataframe_checks.py", line 127, in _check_contains_inf
if np.isinf(X[variables]).values.any():
File "D:\Vari\Anaconda3\envs\ML\lib\site-packages\pandas\core\generic.py", line 1936, in __array_ufunc__
return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
File "D:\Vari\Anaconda3\envs\ML\lib\site-packages\pandas\core\arraylike.py", line 366, in array_ufunc
result = mgr.apply(getattr(ufunc, method))
File "D:\Vari\Anaconda3\envs\ML\lib\site-packages\pandas\core\internals\managers.py", line 425, in apply
applied = b.apply(f, **kwargs)
File "D:\Vari\Anaconda3\envs\ML\lib\site-packages\pandas\core\internals\blocks.py", line 378, in apply
result = func(self.values, **kwargs)
TypeError: ufunc 'isinf' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
>>>
```
| feature-engine/feature_engine | diff --git a/tests/test_variable_manipulation.py b/tests/test_variable_manipulation.py
index 647eb70..eafb2e8 100644
--- a/tests/test_variable_manipulation.py
+++ b/tests/test_variable_manipulation.py
@@ -44,9 +44,21 @@ def test_find_or_check_numerical_variables(df_vartypes, df_numeric_columns):
assert _find_or_check_numerical_variables(df_vartypes, var_num) == ["Age"]
assert _find_or_check_numerical_variables(df_vartypes, vars_none) == vars_num
+ with pytest.raises(TypeError):
+ assert _find_or_check_numerical_variables(df_vartypes, "City")
+
+ with pytest.raises(TypeError):
+ assert _find_or_check_numerical_variables(df_numeric_columns, 0)
+
+ with pytest.raises(TypeError):
+ assert _find_or_check_numerical_variables(df_numeric_columns, [1, 3])
+
with pytest.raises(TypeError):
assert _find_or_check_numerical_variables(df_vartypes, vars_mix)
+ with pytest.raises(ValueError):
+ assert _find_or_check_numerical_variables(df_vartypes, variables=[])
+
with pytest.raises(ValueError):
assert _find_or_check_numerical_variables(df_vartypes[["Name", "City"]], None)
@@ -61,13 +73,26 @@ def test_find_or_check_categorical_variables(df_vartypes, df_numeric_columns):
assert _find_or_check_categorical_variables(df_vartypes, vars_cat) == vars_cat
assert _find_or_check_categorical_variables(df_vartypes, None) == vars_cat
+ with pytest.raises(TypeError):
+ assert _find_or_check_categorical_variables(df_vartypes, "Marks")
+
+ with pytest.raises(TypeError):
+ assert _find_or_check_categorical_variables(df_numeric_columns, 3)
+
+ with pytest.raises(TypeError):
+ assert _find_or_check_categorical_variables(df_numeric_columns, [0, 2])
+
with pytest.raises(TypeError):
assert _find_or_check_categorical_variables(df_vartypes, vars_mix)
+ with pytest.raises(ValueError):
+ assert _find_or_check_categorical_variables(df_vartypes, variables=[])
+
with pytest.raises(ValueError):
assert _find_or_check_categorical_variables(df_vartypes[["Age", "Marks"]], None)
assert _find_or_check_categorical_variables(df_numeric_columns, [0, 1]) == [0, 1]
+ assert _find_or_check_categorical_variables(df_numeric_columns, 0) == [0]
assert _find_or_check_categorical_variables(df_numeric_columns, 1) == [1]
df_vartypes["Age"] = df_vartypes["Age"].astype("category")
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 2
} | 1.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest>=5.4.1",
"black>=21.5b1",
"flake8>=3.9.2",
"mypy>=0.740",
"isort>=5.8.0",
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | black==25.1.0
click==8.1.8
exceptiongroup==1.2.2
-e git+https://github.com/feature-engine/feature_engine.git@cceeed2515b9dd709779c91185eb7e3a0bcddcb7#egg=feature_engine
flake8==7.2.0
iniconfig==2.1.0
isort==6.0.1
joblib==1.4.2
mccabe==0.7.0
mypy==1.15.0
mypy-extensions==1.0.0
numpy==2.0.2
packaging==24.2
pandas==2.2.3
pathspec==0.12.1
patsy==1.0.1
platformdirs==4.3.7
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.2
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
scikit-learn==1.6.1
scipy==1.13.1
six==1.17.0
statsmodels==0.14.4
threadpoolctl==3.6.0
tomli==2.2.1
typing_extensions==4.13.0
tzdata==2025.2
| name: feature_engine
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- black==25.1.0
- click==8.1.8
- exceptiongroup==1.2.2
- flake8==7.2.0
- iniconfig==2.1.0
- isort==6.0.1
- joblib==1.4.2
- mccabe==0.7.0
- mypy==1.15.0
- mypy-extensions==1.0.0
- numpy==2.0.2
- packaging==24.2
- pandas==2.2.3
- pathspec==0.12.1
- patsy==1.0.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pycodestyle==2.13.0
- pyflakes==3.3.2
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- scikit-learn==1.6.1
- scipy==1.13.1
- six==1.17.0
- statsmodels==0.14.4
- threadpoolctl==3.6.0
- tomli==2.2.1
- typing-extensions==4.13.0
- tzdata==2025.2
prefix: /opt/conda/envs/feature_engine
| [
"tests/test_variable_manipulation.py::test_find_or_check_numerical_variables",
"tests/test_variable_manipulation.py::test_find_or_check_categorical_variables"
] | [] | [
"tests/test_variable_manipulation.py::test_check_input_parameter_variables",
"tests/test_variable_manipulation.py::test_find_all_variables"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,767 | 1,290 | [
"feature_engine/selection/target_mean_selection.py",
"feature_engine/variable_manipulation.py"
] |
smarie__python-makefun-78 | d9757b0dfbf1cf91f827582ee70bb8aa4dc44792 | 2021-12-07 21:26:00 | d9757b0dfbf1cf91f827582ee70bb8aa4dc44792 | diff --git a/src/makefun/main.py b/src/makefun/main.py
index 7184475..5aa3073 100644
--- a/src/makefun/main.py
+++ b/src/makefun/main.py
@@ -33,6 +33,13 @@ except ImportError:
def isgeneratorfunction(f):
return False
+try:
+ from inspect import isasyncgenfunction
+except ImportError:
+ # assume no generator function in old Python versions
+ def isasyncgenfunction(f):
+ return False
+
try: # python 3.5+
from typing import Callable, Any, Union, Iterable, Dict, Tuple, Mapping
except ImportError:
@@ -246,6 +253,8 @@ def create_function(func_signature, # type: Union[str, Signature]
else:
from makefun._main_legacy_py import get_legacy_py_generator_body_template
body = get_legacy_py_generator_body_template() % (func_signature_str, params_str)
+ elif isasyncgenfunction(func_impl):
+ body = "async def %s\n async for y in _func_impl_(%s):\n yield y\n" % (func_signature_str, params_str)
else:
body = "def %s\n return _func_impl_(%s)\n" % (func_signature_str, params_str)
@@ -1123,6 +1132,9 @@ def partial(f, # type: Callable
else:
from makefun._main_legacy_py import make_partial_using_yield
partial_f = make_partial_using_yield(new_sig, f, *preset_pos_args, **preset_kwargs)
+ elif isasyncgenfunction(f) and sys.version_info >= (3, 6):
+ from makefun._main_latest_py import make_partial_using_async_for_in_yield
+ partial_f = make_partial_using_async_for_in_yield(new_sig, f, *preset_pos_args, **preset_kwargs)
else:
@wraps(f, new_sig=new_sig)
def partial_f(*args, **kwargs):
| Asynchronous Generators are not properly handled
When wrapping a async generator function, the resulting wrapped function was not an async generator anymore, causing code to break.
Background: https://www.python.org/dev/peps/pep-0525/ | smarie/python-makefun | diff --git a/src/makefun/_main_latest_py.py b/src/makefun/_main_latest_py.py
index df89eda..ecf497e 100644
--- a/src/makefun/_main_latest_py.py
+++ b/src/makefun/_main_latest_py.py
@@ -22,3 +22,22 @@ def make_partial_using_yield_from(new_sig, f, *preset_pos_args, **preset_kwargs)
kwargs.update(preset_kwargs) # for python 3.4: explicit dict update
yield from f(*chain(preset_pos_args, args), **kwargs)
return partial_f
+
+
+def make_partial_using_async_for_in_yield(new_sig, f, *preset_pos_args, **preset_kwargs):
+ """
+ Makes a 'partial' when f is a async generator and python is new enough to support `async for v in f(): yield v`
+
+ :param new_sig:
+ :param f:
+ :param presets:
+ :return:
+ """
+
+ @wraps(f, new_sig=new_sig)
+ async def partial_f(*args, **kwargs):
+ kwargs.update(preset_kwargs)
+ async for v in f(*chain(preset_pos_args, args), **kwargs):
+ yield v
+
+ return partial_f
diff --git a/tests/_test_py36.py b/tests/_test_py36.py
new file mode 100644
index 0000000..d6d0358
--- /dev/null
+++ b/tests/_test_py36.py
@@ -0,0 +1,21 @@
+from makefun import wraps, partial
+
+
+def make_async_generator():
+ async def f(v):
+ yield v
+
+ return f
+
+
+def make_async_generator_wrapper(f):
+ @wraps(f)
+ async def wrapper(*args, **kwargs):
+ async for v in f(*args, **kwargs):
+ yield v
+
+ return wrapper
+
+
+def make_async_generator_partial(f, *args, **kwargs):
+ return partial(f, *args, **kwargs)
diff --git a/tests/test_issues.py b/tests/test_issues.py
index c12334c..d69885f 100644
--- a/tests/test_issues.py
+++ b/tests/test_issues.py
@@ -1,3 +1,4 @@
+import inspect
import sys
import pytest
@@ -224,3 +225,31 @@ def test_issue_76():
f2 = create_function("zoo(a)", f, func=f)
assert f2(3) == 4
+
+
[email protected](sys.version_info < (3, 6), reason="requires python 3.6 or higher (async generator)")
+def test_issue_77_async_generator_wraps():
+ import asyncio
+ from ._test_py36 import make_async_generator, make_async_generator_wrapper
+
+ f = make_async_generator()
+ wrapper = make_async_generator_wrapper(f)
+
+ assert inspect.isasyncgenfunction(f)
+ assert inspect.isasyncgenfunction(wrapper)
+
+ assert asyncio.get_event_loop().run_until_complete(asyncio.ensure_future(wrapper(1).__anext__())) == 1
+
+
[email protected](sys.version_info < (3, 6), reason="requires python 3.6 or higher (async generator)")
+def test_issue_77_async_generator_partial():
+ import asyncio
+ from ._test_py36 import make_async_generator, make_async_generator_partial
+
+ f = make_async_generator()
+ f_partial = make_async_generator_partial(f, v=1)
+
+ assert inspect.isasyncgenfunction(f)
+ assert inspect.isasyncgenfunction(f_partial)
+
+ assert asyncio.get_event_loop().run_until_complete(asyncio.ensure_future(f_partial().__anext__())) == 1
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 1.12 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
-e git+https://github.com/smarie/python-makefun.git@d9757b0dfbf1cf91f827582ee70bb8aa4dc44792#egg=makefun
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
| name: python-makefun
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- makefun==1.12.1
prefix: /opt/conda/envs/python-makefun
| [
"tests/test_issues.py::test_issue_77_async_generator_wraps",
"tests/test_issues.py::test_issue_77_async_generator_partial"
] | [] | [
"tests/test_issues.py::test_varpositional2",
"tests/test_issues.py::test_invalid_signature_str",
"tests/test_issues.py::test_invalid_signature_str_py3",
"tests/test_issues.py::test_return_annotation_in_py2",
"tests/test_issues.py::test_init_replaced",
"tests/test_issues.py::test_issue_55",
"tests/test_issues.py::test_partial_noargs",
"tests/test_issues.py::test_wraps_dict",
"tests/test_issues.py::test_issue_62",
"tests/test_issues.py::test_issue_63",
"tests/test_issues.py::test_issue_66",
"tests/test_issues.py::test_issue_pr_67",
"tests/test_issues.py::test_issue_76"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,769 | 461 | [
"src/makefun/main.py"
] |
|
infobloxopen__infoblox-client-295 | b6af5306673744ee1de9285ef6b1cd90e0838f6e | 2021-12-08 18:18:59 | b6af5306673744ee1de9285ef6b1cd90e0838f6e | diff --git a/infoblox_client/objects.py b/infoblox_client/objects.py
index 6ca7bd1..3c817b6 100644
--- a/infoblox_client/objects.py
+++ b/infoblox_client/objects.py
@@ -639,7 +639,7 @@ class Dhcpddns(SubObjects):
class Dhcpmember(SubObjects):
- _fields = ['ipv4addr', 'ipv6addr', 'name']
+ _fields = ['_struct', 'ipv4addr', 'ipv6addr', 'name']
class Dhcpoption(SubObjects):
@@ -7533,7 +7533,7 @@ class NetworkV4(Network):
_custom_field_processing = {
'logic_filter_rules': Logicfilterrule.from_dict,
- 'members': Msdhcpserver.from_dict,
+ 'members': Dhcpmember.from_dict,
'options': Dhcpoption.from_dict,
'vlans': Vlanlink.from_dict,
'zone_associations': Zoneassociation.from_dict,
@@ -8518,7 +8518,7 @@ class NetworkTemplateV4(NetworkTemplate):
_custom_field_processing = {
'logic_filter_rules': Logicfilterrule.from_dict,
- 'members': Msdhcpserver.from_dict,
+ 'members': Dhcpmember.from_dict,
'options': Dhcpoption.from_dict,
}
| _custom_field_processing bug in NetworkV4 fails to properly serialize members
High-level API call to NetworkV4 fails to serialize members properly. This has been confirmed on the infoblox-client 0.5.0, as well as, _master_. This was tested and confirmed on NIOS v8.5.3 and v8.5.4.
Steps to reproduce:
1. create a DHCP-enabled network 192.168.1.0/24 and associate two (2) Grid DHCP Member servers (NOT Microsoft Servers)
2. perform the following call in the Infoblox client:
`res = objects.Network.search(conn, return_fields=['members'], network='192.168.1.0/24')`
The following is returned:
<pre>
NetworkV4: members="[Msdhcpserver: ipv4addr="192.168.1.5", name="dhcp01.example.com",
Msdhcpserver: ipv4addr="192.168.1.6", name="dhcp02.example.com"]",
_ref="network/ZG5zLm5ldHdvcmskMTAuMC4zMi4wLzI0LzA:192.168.1.0/24/default"
</pre>
There are a few issues with this:
* _struct is missing from the list where the value is either 'msdhcpserver' | 'dhcpmember'
* It's interpreting the members as Msdhcpserver objects 100% of the time instead of using _struct to determine the type of DHCP server that is associated with the network
This issue is also seen with the NetworkTemplate.
This issue is only related to the high-level calls to objects.py and NOT when using the connector low-level calls. | infobloxopen/infoblox-client | diff --git a/tests/test_objects.py b/tests/test_objects.py
index 217d4a7..bf8f4fa 100644
--- a/tests/test_objects.py
+++ b/tests/test_objects.py
@@ -121,6 +121,64 @@ class TestObjects(unittest.TestCase):
extattrs=None, force_proxy=False, return_fields=mock.ANY,
max_results=None)
+ def test_search_network_with_grid_dhcp_members(self):
+ found = {
+ '_ref': 'network/ZG5zLm5ldHdvcmskMTAuMC4zMi4wLzI0LzA:10.0.32.0/24/default',
+ 'members': [
+ {'_struct': 'dhcpmember', 'ipv4addr': '192.168.10.67', 'name': 'dhcp01.example.com'},
+ {'_struct': 'dhcpmember', 'ipv4addr': '192.168.11.67', 'name': 'dhcp02.example.com'}
+ ]
+ }
+ connector = self._mock_connector(get_object=[found])
+
+ network = objects.Network.search(
+ connector,
+ network_view='some-view',
+ network='10.0.32.0/24',
+ return_fields=['members']
+ )
+ connector.get_object.assert_called_once_with(
+ 'network',
+ {'network_view': 'some-view', 'network': '10.0.32.0/24'},
+ extattrs=None, force_proxy=False, return_fields=['members'],
+ max_results=None
+ )
+ self.assertIsInstance(network.members[0], objects.Dhcpmember)
+ self.assertIsInstance(network.members[1], objects.Dhcpmember)
+ self.assertEqual('dhcpmember', network.members[0]._struct)
+ self.assertEqual('dhcpmember', network.members[1]._struct)
+ self.assertEqual('192.168.10.67', network.members[0].ipv4addr)
+ self.assertEqual('192.168.11.67', network.members[1].ipv4addr)
+
+ def test_search_network_with_ms_dhcp_members(self):
+ found = {
+ '_ref': 'network/ZG5zLm5ldHdvcmskMTAuMC4zMi4wLzI0LzA:10.0.32.0/24/default',
+ 'members': [
+ {'_struct': 'msdhcpserver', 'ipv4addr': '192.168.10.67', 'name': 'dhcp01.example.com'},
+ {'_struct': 'msdhcpserver', 'ipv4addr': '192.168.11.67', 'name': 'dhcp02.example.com'}
+ ]
+ }
+ connector = self._mock_connector(get_object=[found])
+
+ network = objects.Network.search(
+ connector,
+ network_view='some-view',
+ network='10.0.32.0/24',
+ return_fields=['members']
+ )
+ connector.get_object.assert_called_once_with(
+ 'network',
+ {'network_view': 'some-view', 'network': '10.0.32.0/24'},
+ extattrs=None, force_proxy=False, return_fields=['members'],
+ max_results=None
+ )
+ self.assertIsInstance(network.members[0], objects.Dhcpmember)
+ self.assertIsInstance(network.members[1], objects.Dhcpmember)
+ self.assertEqual('msdhcpserver', network.members[0]._struct)
+ self.assertEqual('msdhcpserver', network.members[1]._struct)
+ self.assertEqual('192.168.10.67', network.members[0].ipv4addr)
+ self.assertEqual('192.168.11.67', network.members[1].ipv4addr)
+
def test_search_network_with_results(self):
found = {"_ref": "network/ZG5zLm5ldHdvcmskMTAuMzkuMTEuMC8yNC8w"
":10.39.11.0/24/default",
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 1
} | 0.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"mock",
"netaddr"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi==2025.1.31
charset-normalizer==3.4.1
debtcollector==3.0.0
exceptiongroup==1.2.2
idna==3.10
-e git+https://github.com/infobloxopen/infoblox-client.git@b6af5306673744ee1de9285ef6b1cd90e0838f6e#egg=infoblox_client
iniconfig==2.1.0
iso8601==2.1.0
mock==5.2.0
msgpack==1.1.0
netaddr==1.3.0
oslo.config==9.7.1
oslo.context==5.7.1
oslo.i18n==6.5.1
oslo.log==7.1.0
oslo.serialization==5.7.0
oslo.utils==8.2.0
packaging==24.2
pbr==6.1.1
pluggy==1.5.0
psutil==7.0.0
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
rfc3986==2.0.0
six==1.17.0
stevedore==5.4.1
tomli==2.2.1
tzdata==2025.2
urllib3==2.3.0
wrapt==1.17.2
| name: infoblox-client
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2025.1.31
- charset-normalizer==3.4.1
- debtcollector==3.0.0
- exceptiongroup==1.2.2
- idna==3.10
- iniconfig==2.1.0
- iso8601==2.1.0
- mock==5.2.0
- msgpack==1.1.0
- netaddr==1.3.0
- oslo-config==9.7.1
- oslo-context==5.7.1
- oslo-i18n==6.5.1
- oslo-log==7.1.0
- oslo-serialization==5.7.0
- oslo-utils==8.2.0
- packaging==24.2
- pbr==6.1.1
- pluggy==1.5.0
- psutil==7.0.0
- pyparsing==3.2.3
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pyyaml==6.0.2
- requests==2.32.3
- rfc3986==2.0.0
- six==1.17.0
- stevedore==5.4.1
- tomli==2.2.1
- tzdata==2025.2
- urllib3==2.3.0
- wrapt==1.17.2
prefix: /opt/conda/envs/infoblox-client
| [
"tests/test_objects.py::TestObjects::test_search_network_with_grid_dhcp_members",
"tests/test_objects.py::TestObjects::test_search_network_with_ms_dhcp_members"
] | [] | [
"tests/test_objects.py::TestObjects::test_Create_MX_Record",
"tests/test_objects.py::TestObjects::test_TXT_Record",
"tests/test_objects.py::TestObjects::test__process_value",
"tests/test_objects.py::TestObjects::test__remap_fields_support_unknown_fields",
"tests/test_objects.py::TestObjects::test_call_upload_file",
"tests/test_objects.py::TestObjects::test_create_IP",
"tests/test_objects.py::TestObjects::test_create_fails_on_multiple_api_objects",
"tests/test_objects.py::TestObjects::test_create_fixed_address",
"tests/test_objects.py::TestObjects::test_create_fixed_address_v6",
"tests/test_objects.py::TestObjects::test_create_host_record_with_ip",
"tests/test_objects.py::TestObjects::test_create_host_record_with_ttl",
"tests/test_objects.py::TestObjects::test_ea_parse_generate",
"tests/test_objects.py::TestObjects::test_ea_returns_ea_dict",
"tests/test_objects.py::TestObjects::test_ea_returns_none",
"tests/test_objects.py::TestObjects::test_ea_set_get",
"tests/test_objects.py::TestObjects::test_ea_to_dict",
"tests/test_objects.py::TestObjects::test_fixed_address_v6",
"tests/test_objects.py::TestObjects::test_get_tenant",
"tests/test_objects.py::TestObjects::test_ip_version",
"tests/test_objects.py::TestObjects::test_search_and_delete_MX_Record",
"tests/test_objects.py::TestObjects::test_search_and_delete_host_record",
"tests/test_objects.py::TestObjects::test_search_ipaddress",
"tests/test_objects.py::TestObjects::test_search_network",
"tests/test_objects.py::TestObjects::test_search_network_v6",
"tests/test_objects.py::TestObjects::test_search_network_v6_using_network_field",
"tests/test_objects.py::TestObjects::test_search_network_with_results",
"tests/test_objects.py::TestObjects::test_update_MX_Record",
"tests/test_objects.py::TestObjects::test_update_fields_on_create",
"tests/test_objects.py::TestObjects::test_update_fields_on_create_v6",
"tests/test_objects.py::TestObjects::test_update_from_dict"
] | [] | Apache License 2.0 | 11,773 | 322 | [
"infoblox_client/objects.py"
] |
|
adafruit__Adafruit_CircuitPython_GPS-76 | b9e06e93f258ef3251b8104e19c9cfd435d12d60 | 2021-12-08 21:02:48 | b9e06e93f258ef3251b8104e19c9cfd435d12d60 | diff --git a/adafruit_gps.py b/adafruit_gps.py
index 10bc89c..a28a065 100644
--- a/adafruit_gps.py
+++ b/adafruit_gps.py
@@ -50,11 +50,11 @@ _ST_MAX = _RMC_4_1
_SENTENCE_PARAMS = (
# 0 - _GLL
- "dcdcfcC",
+ "dcdcscC",
# 1 - _RMC
- "fcdcdcffiDCC",
+ "scdcdcffsDCC",
# 2 - _GGA
- "fdcdciiffsfsIS",
+ "sdcdciiffsfsIS",
# 3 - _GSA
"ciIIIIIIIIIIIIfff",
# 4 - _GSA_4_11
@@ -68,7 +68,7 @@ _SENTENCE_PARAMS = (
# 8 - _GSV19
"iiiiiiIiiiIiiiIiiiI",
# 9 - _RMC_4_1
- "fcdcdcffiDCCC",
+ "scdcdcffsDCCC",
)
@@ -394,9 +394,9 @@ class GPS:
return (data_type, sentence[delimiter + 1 :])
def _update_timestamp_utc(self, time_utc, date=None):
- hours = time_utc // 10000
- mins = (time_utc // 100) % 100
- secs = time_utc % 100
+ hours = int(time_utc[0:2])
+ mins = int(time_utc[2:4])
+ secs = int(time_utc[4:6])
if date is None:
if self.timestamp_utc is None:
day, month, year = 0, 0, 0
@@ -405,9 +405,9 @@ class GPS:
month = self.timestamp_utc.tm_mon
year = self.timestamp_utc.tm_year
else:
- day = date // 10000
- month = (date // 100) % 100
- year = 2000 + date % 100
+ day = int(date[0:2])
+ month = int(date[2:4])
+ year = 2000 + int(date[4:6])
self.timestamp_utc = time.struct_time(
(year, month, day, hours, mins, secs, 0, 0, -1)
@@ -429,7 +429,7 @@ class GPS:
self.longitude = _read_degrees(data, 2, "w")
# UTC time of position
- self._update_timestamp_utc(int(data[4]))
+ self._update_timestamp_utc(data[4])
# Status Valid(A) or Invalid(V)
self.isactivedata = data[5]
@@ -450,7 +450,7 @@ class GPS:
return False # Params didn't parse
# UTC time of position and date
- self._update_timestamp_utc(int(data[0]), data[8])
+ self._update_timestamp_utc(data[0], data[8])
# Status Valid(A) or Invalid(V)
self.isactivedata = data[1]
@@ -494,7 +494,7 @@ class GPS:
return False # Params didn't parse
# UTC time of position
- self._update_timestamp_utc(int(data[0]))
+ self._update_timestamp_utc(data[0])
# Latitude
self.latitude = _read_degrees(data, 1, "s")
| Usage of float causes timestamp_utc to be imprecise
NMEA timestamp is written as HHMMSS.sss, which is stored as float in the module.
Later it is converted to int which is inaccurate:
See example:
```
>> int(184105.000)
184104
```
This is then math'ed into the fields in time_struct.
Propose storing the NMEA sentence as string instead, and grabbing the sections of the sting directly. | adafruit/Adafruit_CircuitPython_GPS | diff --git a/tests/adafruit_gps_test.py b/tests/adafruit_gps_test.py
index 9e09c85..8a956f3 100644
--- a/tests/adafruit_gps_test.py
+++ b/tests/adafruit_gps_test.py
@@ -140,14 +140,14 @@ def test_GPS_update_timestamp_UTC_date_None():
assert gps.datetime is None
assert gps.timestamp_utc is None
exp_struct = time.struct_time((0, 0, 0, 22, 14, 11, 0, 0, -1))
- gps._update_timestamp_utc(time_utc=221411)
+ gps._update_timestamp_utc(time_utc="221411")
assert gps.timestamp_utc == exp_struct
def test_GPS_update_timestamp_UTC_date_not_None():
gps = GPS(uart=UartMock())
exp_struct = time.struct_time((2021, 10, 2, 22, 14, 11, 0, 0, -1))
- gps._update_timestamp_utc(time_utc=221411, date=21021)
+ gps._update_timestamp_utc(time_utc="221411", date="021021")
assert gps.timestamp_utc == exp_struct
@@ -157,7 +157,7 @@ def test_GPS_update_timestamp_timestamp_utc_was_not_none_new_date_none():
gps.timestamp_utc = time.struct_time((2021, 10, 2, 22, 10, 11, 0, 0, -1))
exp_struct = time.struct_time((2021, 10, 2, 22, 14, 11, 0, 0, -1))
# update the timestamp
- gps._update_timestamp_utc(time_utc=221411)
+ gps._update_timestamp_utc(time_utc="221411")
assert gps.timestamp_utc == exp_struct
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 3.9 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"covdefaults",
"coverage",
"freezegun",
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | Adafruit-Blinka==8.56.0
adafruit-circuitpython-busdevice==5.2.11
adafruit-circuitpython-connectionmanager==3.1.3
-e git+https://github.com/adafruit/Adafruit_CircuitPython_GPS.git@b9e06e93f258ef3251b8104e19c9cfd435d12d60#egg=adafruit_circuitpython_gps
adafruit-circuitpython-requests==4.1.10
adafruit-circuitpython-typing==1.11.2
Adafruit-PlatformDetect==3.77.0
Adafruit-PureIO==1.1.11
binho-host-adapter==0.1.6
covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
freezegun==1.5.1
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pyftdi==0.56.0
pyserial==3.5
pytest==8.3.5
python-dateutil==2.9.0.post0
pyusb==1.3.1
six==1.17.0
sysv_ipc==1.1.0
toml==0.10.2
tomli==2.2.1
typing_extensions==4.13.0
| name: Adafruit_CircuitPython_GPS
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- adafruit-blinka==8.56.0
- adafruit-circuitpython-busdevice==5.2.11
- adafruit-circuitpython-connectionmanager==3.1.3
- adafruit-circuitpython-requests==4.1.10
- adafruit-circuitpython-typing==1.11.2
- adafruit-platformdetect==3.77.0
- adafruit-pureio==1.1.11
- binho-host-adapter==0.1.6
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- freezegun==1.5.1
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pyftdi==0.56.0
- pyserial==3.5
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pyusb==1.3.1
- six==1.17.0
- sysv-ipc==1.1.0
- toml==0.10.2
- tomli==2.2.1
- typing-extensions==4.13.0
prefix: /opt/conda/envs/Adafruit_CircuitPython_GPS
| [
"tests/adafruit_gps_test.py::test_GPS_update_timestamp_UTC_date_None",
"tests/adafruit_gps_test.py::test_GPS_update_timestamp_UTC_date_not_None",
"tests/adafruit_gps_test.py::test_GPS_update_timestamp_timestamp_utc_was_not_none_new_date_none"
] | [] | [
"tests/adafruit_gps_test.py::test_parse_degrees[leading",
"tests/adafruit_gps_test.py::test_parse_degrees[regular",
"tests/adafruit_gps_test.py::test_parse_degrees[long",
"tests/adafruit_gps_test.py::test_parse_degrees_too_short",
"tests/adafruit_gps_test.py::test_parse_int",
"tests/adafruit_gps_test.py::test_parse_int_invalid[None]",
"tests/adafruit_gps_test.py::test_parse_int_invalid[]",
"tests/adafruit_gps_test.py::test_parse_float",
"tests/adafruit_gps_test.py::test_parse_float_invalid[None]",
"tests/adafruit_gps_test.py::test_parse_float_invalid[]",
"tests/adafruit_gps_test.py::test_read_degrees[south",
"tests/adafruit_gps_test.py::test_read_degrees[north",
"tests/adafruit_gps_test.py::test_read_degrees[west",
"tests/adafruit_gps_test.py::test_read_degrees[east",
"tests/adafruit_gps_test.py::test_parse_str_invalid[None]",
"tests/adafruit_gps_test.py::test_parse_str_invalid[]",
"tests/adafruit_gps_test.py::test_parse_str_valid",
"tests/adafruit_gps_test.py::test_parse_talker_prop_code",
"tests/adafruit_gps_test.py::test_parse_talker_regular",
"tests/adafruit_gps_test.py::test_parse_data_unknown_sentence_type[-1]",
"tests/adafruit_gps_test.py::test_parse_data_unknown_sentence_type[10]",
"tests/adafruit_gps_test.py::test_param_types_does_not_match_data_items",
"tests/adafruit_gps_test.py::test_parse_data_unexpected_parameter_type",
"tests/adafruit_gps_test.py::test_read_sentence_too_few_in_waiting",
"tests/adafruit_gps_test.py::test_GPS_update_with_unknown_talker",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_no_magnetic_variation",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_fix_is_set",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_fix_is_set_new",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_invalid_checksum",
"tests/adafruit_gps_test.py::test_GPS_update_empty_sentence",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_has_magnetic_variation[W]",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_has_magnetic_variation[E]",
"tests/adafruit_gps_test.py::test_parse_sentence_invalid_delimiter",
"tests/adafruit_gps_test.py::test_GPS_update_sentence_is_None",
"tests/adafruit_gps_test.py::test_GPS_update_rmc_debug_shows_sentence",
"tests/adafruit_gps_test.py::test_GPS_update_data_type_too_short",
"tests/adafruit_gps_test.py::test_GPS_send_command_with_checksum",
"tests/adafruit_gps_test.py::test_GPS_send_command_without_checksum",
"tests/adafruit_gps_test.py::test_GPS_update_from_GLL",
"tests/adafruit_gps_test.py::test_GPS_update_from_RMC",
"tests/adafruit_gps_test.py::test_GPS_update_from_GGA",
"tests/adafruit_gps_test.py::test_GPS_update_from_GSA[smaller",
"tests/adafruit_gps_test.py::test_GPS_update_from_GSA[greater",
"tests/adafruit_gps_test.py::test_GPS_update_from_GSV_first_part",
"tests/adafruit_gps_test.py::test_GPS_update_from_GSV_both_parts_sats_are_removed"
] | [] | MIT License | 11,776 | 852 | [
"adafruit_gps.py"
] |
|
rsagroup__rsatoolbox-220 | 68cd39309987cdc87b47806e616920a25d6a6260 | 2021-12-08 23:05:56 | 25cfa25c8fdb6545cd85c94756a328f4e19b4d42 | diff --git a/rsatoolbox/rdm/transform.py b/rsatoolbox/rdm/transform.py
index a0999ba7..caa12257 100644
--- a/rsatoolbox/rdm/transform.py
+++ b/rsatoolbox/rdm/transform.py
@@ -30,8 +30,11 @@ def rank_transform(rdms, method='average'):
dissimilarities = rdms.get_vectors()
dissimilarities = np.array([rankdata(dissimilarities[i], method=method)
for i in range(rdms.n_rdm)])
+ measure = rdms.dissimilarity_measure
+ if not measure[-7:] == '(ranks)':
+ measure = measure + ' (ranks)'
rdms_new = RDMs(dissimilarities,
- dissimilarity_measure=rdms.dissimilarity_measure,
+ dissimilarity_measure=measure,
descriptors=deepcopy(rdms.descriptors),
rdm_descriptors=deepcopy(rdms.rdm_descriptors),
pattern_descriptors=deepcopy(rdms.pattern_descriptors))
| rank transform does not update dissimilarity measure
Perhaps it should be adapted, for example _euclidean_ becomes _euclidean (ranks)_
https://github.com/rsagroup/rsatoolbox/blob/11d394852695851d3d1dabb059adfc277ad996e6/rsatoolbox/rdm/transform.py#L34 | rsagroup/rsatoolbox | diff --git a/tests/test_rdm.py b/tests/test_rdm.py
index efdf3ad6..e92c5c31 100644
--- a/tests/test_rdm.py
+++ b/tests/test_rdm.py
@@ -244,6 +244,7 @@ class TestRDM(unittest.TestCase):
rank_rdm = rank_transform(rdms)
self.assertEqual(rank_rdm.n_rdm, rdms.n_rdm)
self.assertEqual(rank_rdm.n_cond, rdms.n_cond)
+ self.assertEqual(rank_rdm.dissimilarity_measure, 'Euclidean (ranks)')
def test_sqrt_transform(self):
from rsatoolbox.rdm import sqrt_transform
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 1
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | contourpy==1.3.0
coverage==7.8.0
cycler==0.12.1
exceptiongroup==1.2.2
fonttools==4.56.0
h5py==3.13.0
imageio==2.37.0
importlib_resources==6.5.2
iniconfig==2.1.0
joblib==1.4.2
kiwisolver==1.4.7
lazy_loader==0.4
matplotlib==3.9.4
networkx==3.2.1
numpy==2.0.2
packaging==24.2
petname==2.2
pillow==11.1.0
pluggy==1.5.0
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
-e git+https://github.com/rsagroup/rsatoolbox.git@68cd39309987cdc87b47806e616920a25d6a6260#egg=rsatoolbox
scikit-image==0.24.0
scikit-learn==1.6.1
scipy==1.13.1
six==1.17.0
threadpoolctl==3.6.0
tifffile==2024.8.30
tomli==2.2.1
tqdm==4.67.1
zipp==3.21.0
| name: rsatoolbox
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- contourpy==1.3.0
- coverage==7.8.0
- cycler==0.12.1
- exceptiongroup==1.2.2
- fonttools==4.56.0
- h5py==3.13.0
- imageio==2.37.0
- importlib-resources==6.5.2
- iniconfig==2.1.0
- joblib==1.4.2
- kiwisolver==1.4.7
- lazy-loader==0.4
- matplotlib==3.9.4
- networkx==3.2.1
- numpy==2.0.2
- packaging==24.2
- petname==2.2
- pillow==11.1.0
- pluggy==1.5.0
- pyparsing==3.2.3
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- scikit-image==0.24.0
- scikit-learn==1.6.1
- scipy==1.13.1
- six==1.17.0
- threadpoolctl==3.6.0
- tifffile==2024.8.30
- tomli==2.2.1
- tqdm==4.67.1
- zipp==3.21.0
prefix: /opt/conda/envs/rsatoolbox
| [
"tests/test_rdm.py::TestRDM::test_rank_transform"
] | [
"tests/test_rdm.py::TestRDM::test_categorical_rdm",
"tests/test_rdm.py::TestSave::test_save_load"
] | [
"tests/test_rdm.py::TestRDM::test_concat",
"tests/test_rdm.py::TestRDM::test_concat_varargs_multiple_rdms",
"tests/test_rdm.py::TestRDM::test_concat_varargs_one_rdm",
"tests/test_rdm.py::TestRDM::test_positive_transform",
"tests/test_rdm.py::TestRDM::test_rdm2d_get_matrices",
"tests/test_rdm.py::TestRDM::test_rdm2d_get_vectors",
"tests/test_rdm.py::TestRDM::test_rdm2d_init",
"tests/test_rdm.py::TestRDM::test_rdm3d_get_matrices",
"tests/test_rdm.py::TestRDM::test_rdm3d_get_vectors",
"tests/test_rdm.py::TestRDM::test_rdm3d_init",
"tests/test_rdm.py::TestRDM::test_rdm_append",
"tests/test_rdm.py::TestRDM::test_rdm_idx",
"tests/test_rdm.py::TestRDM::test_rdm_idx_len_is_1",
"tests/test_rdm.py::TestRDM::test_rdm_iter",
"tests/test_rdm.py::TestRDM::test_rdm_len",
"tests/test_rdm.py::TestRDM::test_rdm_subsample",
"tests/test_rdm.py::TestRDM::test_rdm_subsample_pattern",
"tests/test_rdm.py::TestRDM::test_rdm_subset",
"tests/test_rdm.py::TestRDM::test_rdm_subset_len",
"tests/test_rdm.py::TestRDM::test_rdm_subset_pattern",
"tests/test_rdm.py::TestRDM::test_reorder",
"tests/test_rdm.py::TestRDM::test_sort_by_alpha",
"tests/test_rdm.py::TestRDM::test_sort_by_list",
"tests/test_rdm.py::TestRDM::test_sqrt_transform",
"tests/test_rdm.py::TestRDM::test_transform",
"tests/test_rdm.py::TestSave::test_dict_conversion",
"tests/test_rdm.py::TestRDMLists::test_pattern_subsample_list",
"tests/test_rdm.py::TestRDMLists::test_pattern_subset_list",
"tests/test_rdm.py::TestRDMLists::test_rdm_append_list",
"tests/test_rdm.py::TestRDMLists::test_rdm_indexing",
"tests/test_rdm.py::TestRDMLists::test_rdm_init_list",
"tests/test_rdm.py::TestRDMLists::test_rdm_subsample_list",
"tests/test_rdm.py::TestRDMLists::test_rdm_subset_list"
] | [] | MIT License | 11,782 | 251 | [
"rsatoolbox/rdm/transform.py"
] |
|
PMEAL__OpenPNM-2216 | af5c148155e16793697f0e754846a0ca83eb50e1 | 2021-12-09 14:31:21 | e4c9f799076c334904088df34b8f04da7802a08b | diff --git a/openpnm/core/_base.py b/openpnm/core/_base.py
index 3b64fb4a5..1a4a429b3 100644
--- a/openpnm/core/_base.py
+++ b/openpnm/core/_base.py
@@ -682,14 +682,14 @@ class Base(dict):
[False False False False]
"""
- # Fetch sources list depending on type of self
+ # Fetch subdomains list depending on type of self
proj = self.project
if self._isa() in ['network', 'geometry']:
- sources = list(proj.geometries().values())
+ subdomains = list(proj.geometries().values())
elif self._isa() in ['phase', 'physics']:
- sources = list(proj.find_physics(phase=self))
+ subdomains= list(proj.find_physics(phase=self))
elif self._isa() in ['algorithm', 'base']:
- sources = [self]
+ subdomains= [self]
else:
raise Exception('Unrecognized object type, cannot find dependents')
@@ -698,23 +698,26 @@ class Base(dict):
N = self.project.network._count(element)
# Attempt to fetch the requested array from each object
- arrs = [obj.get(prop, None) for obj in sources]
+ arrs = [obj.get(prop, None) for obj in subdomains]
# Check for missing sources, and add None to arrs if necessary
- if N > sum([obj._count(element) for obj in sources]):
+ if N > sum([obj._count(element) for obj in subdomains]):
arrs.append(None)
# Obtain list of locations for inserting values
- locs = [self._get_indices(element, item.name) for item in sources]
+ locs = [self._get_indices(element, item.name) for item in subdomains]
if np.all([item is None for item in arrs]): # prop not found anywhere
raise KeyError(prop)
# Let's start by handling the easy cases first
if not any([a is None for a in arrs]):
- # All objs present and array found on all objs
- shape = list(arrs[0].shape)
- shape[0] = N
+ # All objs are present and array found on all objs
+ try:
+ W = max([a.shape[1] for a in arrs]) # Width of array
+ shape = [N, W]
+ except:
+ shape = [N, ]
types = [a.dtype for a in arrs]
if len(set(types)) == 1:
# All types are the same
| Interleave data could infer the wrong shape
In line 803, depending on which object comes first, the inferred shape could be wrong. For instance, if we have `(Nt,1)` and `(Nt,2)` conductances, it'll break (the opposite accidentally works fine, since it'll broadcast the values). See #1676.
https://github.com/PMEAL/OpenPNM/blob/8fbac00f5a01e6b4b57f74d6c89d00a64a594a3d/openpnm/core/Base.py#L800-L805 | PMEAL/OpenPNM | diff --git a/tests/unit/core/InterleaveDataTest.py b/tests/unit/core/InterleaveDataTest.py
index ad0d57d1e..83f521919 100644
--- a/tests/unit/core/InterleaveDataTest.py
+++ b/tests/unit/core/InterleaveDataTest.py
@@ -301,6 +301,29 @@ class InterleaveDataTest:
with pytest.raises(Exception):
pn['pore.bee.bop'] = 1
+ def test_interleaving_nt_by_1_with_nt_by_2(self):
+ pn = op.network.Cubic(shape=[10, 1, 1])
+ geo1 = op.geometry.SpheresAndCylinders(network=pn, pores=range(5),
+ throats=range(4))
+ geo2 = op.geometry.SpheresAndCylinders(network=pn, pores=range(5, 10),
+ throats=range(4, 9))
+ geo1['throat.conduit_data'] = np.ones((geo1.Nt, 2))
+ geo2['throat.conduit_data'] = np.ones((geo2.Nt, 1))*2
+ a = np.array([[1., 1.],
+ [1., 1.],
+ [1., 1.],
+ [1., 1.],
+ [2., 2.],
+ [2., 2.],
+ [2., 2.],
+ [2., 2.],
+ [2., 2.]])
+ assert np.all(pn['throat.conduit_data'] == a)
+ # Now do it the other way
+ geo1['throat.conduit_data'] = np.ones((geo1.Nt, 1))
+ geo2['throat.conduit_data'] = np.ones((geo2.Nt, 2))*2
+ assert np.all(pn['throat.conduit_data'] == a)
+
if __name__ == '__main__':
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_issue_reference"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 2.8 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.8",
"reqs_path": [
"requirements/pip_requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | asttokens==3.0.0
attr==0.3.2
attrs==25.3.0
auto-all==1.4.1
backcall==0.2.0
chemicals==1.3.3
contourpy==1.1.1
cycler==0.12.1
decorator==5.2.1
docrep==0.3.2
exceptiongroup==1.2.2
executing==2.2.0
flatdict==4.0.1
fluids==1.1.0
fonttools==4.56.0
gitdb==4.0.12
GitPython==3.1.44
h5py==3.11.0
imageio==2.35.1
importlib_metadata==8.5.0
importlib_resources==6.4.5
iniconfig==2.1.0
intel-cmplr-lib-ur==2025.1.0
intel-openmp==2025.1.0
ipython==8.12.3
jedi==0.19.2
json-tricks==3.17.3
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.7
lazy_loader==0.4
llvmlite==0.41.1
matplotlib==3.7.5
matplotlib-inline==0.1.7
mkl==2025.1.0
mpmath==1.3.0
networkx==3.1
numba==0.58.1
numpy==1.24.4
-e git+https://github.com/PMEAL/OpenPNM.git@af5c148155e16793697f0e754846a0ca83eb50e1#egg=openpnm
packaging==24.2
pandas==2.0.3
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
pillow==10.4.0
pkgutil_resolve_name==1.3.10
pluggy==1.5.0
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
Pygments==2.19.1
pypardiso==0.4.6
pyparsing==3.1.4
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyWavelets==1.4.1
referencing==0.35.1
rpds-py==0.20.1
scikit-image==0.21.0
scipy==1.10.1
six==1.17.0
smmap==5.0.2
stack-data==0.6.3
sympy==1.13.3
tbb==2022.1.0
tcmlib==1.3.0
terminaltables==3.1.10
tifffile==2023.7.10
tomli==2.2.1
tqdm==4.67.1
traitlets==5.14.3
traits==7.0.2
transforms3d==0.4.2
typing_extensions==4.13.0
tzdata==2025.2
umf==0.10.0
wcwidth==0.2.13
zipp==3.20.2
| name: OpenPNM
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=24.2=py38h06a4308_0
- python=3.8.20=he870216_0
- readline=8.2=h5eee18b_0
- setuptools=75.1.0=py38h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.44.0=py38h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- asttokens==3.0.0
- attr==0.3.2
- attrs==25.3.0
- auto-all==1.4.1
- backcall==0.2.0
- chemicals==1.3.3
- contourpy==1.1.1
- cycler==0.12.1
- decorator==5.2.1
- docrep==0.3.2
- exceptiongroup==1.2.2
- executing==2.2.0
- flatdict==4.0.1
- fluids==1.1.0
- fonttools==4.56.0
- gitdb==4.0.12
- gitpython==3.1.44
- h5py==3.11.0
- imageio==2.35.1
- importlib-metadata==8.5.0
- importlib-resources==6.4.5
- iniconfig==2.1.0
- intel-cmplr-lib-ur==2025.1.0
- intel-openmp==2025.1.0
- ipython==8.12.3
- jedi==0.19.2
- json-tricks==3.17.3
- jsonschema==4.23.0
- jsonschema-specifications==2023.12.1
- kiwisolver==1.4.7
- lazy-loader==0.4
- llvmlite==0.41.1
- matplotlib==3.7.5
- matplotlib-inline==0.1.7
- mkl==2025.1.0
- mpmath==1.3.0
- networkx==3.1
- numba==0.58.1
- numpy==1.24.4
- packaging==24.2
- pandas==2.0.3
- parso==0.8.4
- pexpect==4.9.0
- pickleshare==0.7.5
- pillow==10.4.0
- pkgutil-resolve-name==1.3.10
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pygments==2.19.1
- pypardiso==0.4.6
- pyparsing==3.1.4
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pywavelets==1.4.1
- referencing==0.35.1
- rpds-py==0.20.1
- scikit-image==0.21.0
- scipy==1.10.1
- six==1.17.0
- smmap==5.0.2
- stack-data==0.6.3
- sympy==1.13.3
- tbb==2022.1.0
- tcmlib==1.3.0
- terminaltables==3.1.10
- tifffile==2023.7.10
- tomli==2.2.1
- tqdm==4.67.1
- traitlets==5.14.3
- traits==7.0.2
- transforms3d==0.4.2
- typing-extensions==4.13.0
- tzdata==2025.2
- umf==0.10.0
- wcwidth==0.2.13
- zipp==3.20.2
prefix: /opt/conda/envs/OpenPNM
| [
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_nt_by_1_with_nt_by_2"
] | [
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_missing_objects",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_partial_data",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_int",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_object",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_int_missing_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_int_missing_physics"
] | [
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_drop_locations_from_geom_successively_with_single_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_mixed_data",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_bool",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_float",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_key_error",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_float_missing_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_bool_missing_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_float_missing_physics",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_bool_missing_physics",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_writing_subdict_names_across_subdomains"
] | [] | MIT License | 11,787 | 619 | [
"openpnm/core/_base.py"
] |
|
encode__starlette-1356 | f53faba229e3fa2844bc3753e233d9c1f54cca52 | 2021-12-10 14:24:53 | 9d282a937c968b6b3068730af2c8967aec80b736 | aminalaee: I'll try to refactor the tests for partial Route tests. | diff --git a/starlette/routing.py b/starlette/routing.py
index 3c11c1b..982980c 100644
--- a/starlette/routing.py
+++ b/starlette/routing.py
@@ -276,7 +276,10 @@ class WebSocketRoute(BaseRoute):
self.endpoint = endpoint
self.name = get_name(endpoint) if name is None else name
- if inspect.isfunction(endpoint) or inspect.ismethod(endpoint):
+ endpoint_handler = endpoint
+ while isinstance(endpoint_handler, functools.partial):
+ endpoint_handler = endpoint_handler.func
+ if inspect.isfunction(endpoint_handler) or inspect.ismethod(endpoint_handler):
# Endpoint is function or method. Treat it as `func(websocket)`.
self.app = websocket_session(endpoint)
else:
| WebSocketRoute does not work with functools.partial
### Checklist
- [x] The bug is reproducible against the latest release and/or `master`.
- [x] There are no similar issues or pull requests to fix it yet.
### Describe the bug
Accessing a WebSocketRoute with async function wrapped in functools.partial raises TypeError.
### To reproduce
```python
import functools
from starlette.applications import Starlette
from starlette.routing import WebSocketRoute
async def handle_ws(ws):
pass
app = Starlette(debug=True, routes=[
WebSocketRoute("/", functools.partial(handle_ws)),
])
```
Install `uvicorn[standard]`, run with `uvicorn bug:app`.
Access `ws://localhost:8000` with e.g. [wscat](https://github.com/websockets/wscat).
### Expected behavior
WebSocketRoute should work with functools.partial just like Route.
### Actual behavior
The route fails because it is treated as an ASGI application (ref. https://github.com/encode/starlette/blob/f53faba229e3fa2844bc3753e233d9c1f54cca52/starlette/routing.py#L279-L284).
### Debugging material
```
Traceback (most recent call last):
File "/tmp/bug/venv/lib/python3.9/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 199, in run_asgi
result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
File "/tmp/bug/venv/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/middleware/errors.py", line 146, in __call__
await self.app(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/exceptions.py", line 58, in __call__
await self.app(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "/tmp/bug/venv/lib/python3.9/site-packages/starlette/routing.py", line 315, in handle
await self.app(scope, receive, send)
TypeError: handle_ws() takes 1 positional argument but 3 were given
```
### Environment
- OS: Arch Linux
- Python version: 3.9.9
- Starlette version: 0.17.1
### Additional context
Support for functools.partial for Route was introduced in #984.
Those changes to `Route.__init__` fix this bug too but just copying them feels unsustainable. | encode/starlette | diff --git a/tests/test_routing.py b/tests/test_routing.py
index e1374cc..dcb9965 100644
--- a/tests/test_routing.py
+++ b/tests/test_routing.py
@@ -32,6 +32,28 @@ def user_no_match(request): # pragma: no cover
return Response(content, media_type="text/plain")
+async def partial_endpoint(arg, request):
+ return JSONResponse({"arg": arg})
+
+
+async def partial_ws_endpoint(websocket: WebSocket):
+ await websocket.accept()
+ await websocket.send_json({"url": str(websocket.url)})
+ await websocket.close()
+
+
+class PartialRoutes:
+ @classmethod
+ async def async_endpoint(cls, arg, request):
+ return JSONResponse({"arg": arg})
+
+ @classmethod
+ async def async_ws_endpoint(cls, websocket: WebSocket):
+ await websocket.accept()
+ await websocket.send_json({"url": str(websocket.url)})
+ await websocket.close()
+
+
app = Router(
[
Route("/", endpoint=homepage, methods=["GET"]),
@@ -44,6 +66,21 @@ app = Router(
Route("/nomatch", endpoint=user_no_match),
],
),
+ Mount(
+ "/partial",
+ routes=[
+ Route("/", endpoint=functools.partial(partial_endpoint, "foo")),
+ Route(
+ "/cls",
+ endpoint=functools.partial(PartialRoutes.async_endpoint, "foo"),
+ ),
+ WebSocketRoute("/ws", endpoint=functools.partial(partial_ws_endpoint)),
+ WebSocketRoute(
+ "/ws/cls",
+ endpoint=functools.partial(PartialRoutes.async_ws_endpoint),
+ ),
+ ],
+ ),
Mount("/static", app=Response("xxxxx", media_type="image/png")),
]
)
@@ -91,14 +128,14 @@ def path_with_parentheses(request):
@app.websocket_route("/ws")
-async def websocket_endpoint(session):
+async def websocket_endpoint(session: WebSocket):
await session.accept()
await session.send_text("Hello, world!")
await session.close()
@app.websocket_route("/ws/{room}")
-async def websocket_params(session):
+async def websocket_params(session: WebSocket):
await session.accept()
await session.send_text(f"Hello, {session.path_params['room']}!")
await session.close()
@@ -628,40 +665,28 @@ def test_raise_on_shutdown(test_client_factory):
pass # pragma: nocover
-class AsyncEndpointClassMethod:
- @classmethod
- async def async_endpoint(cls, arg, request):
- return JSONResponse({"arg": arg})
-
-
-async def _partial_async_endpoint(arg, request):
- return JSONResponse({"arg": arg})
-
-
-partial_async_endpoint = functools.partial(_partial_async_endpoint, "foo")
-partial_cls_async_endpoint = functools.partial(
- AsyncEndpointClassMethod.async_endpoint, "foo"
-)
-
-partial_async_app = Router(
- routes=[
- Route("/", partial_async_endpoint),
- Route("/cls", partial_cls_async_endpoint),
- ]
-)
-
-
def test_partial_async_endpoint(test_client_factory):
- test_client = test_client_factory(partial_async_app)
- response = test_client.get("/")
+ test_client = test_client_factory(app)
+ response = test_client.get("/partial")
assert response.status_code == 200
assert response.json() == {"arg": "foo"}
- cls_method_response = test_client.get("/cls")
+ cls_method_response = test_client.get("/partial/cls")
assert cls_method_response.status_code == 200
assert cls_method_response.json() == {"arg": "foo"}
+def test_partial_async_ws_endpoint(test_client_factory):
+ test_client = test_client_factory(app)
+ with test_client.websocket_connect("/partial/ws") as websocket:
+ data = websocket.receive_json()
+ assert data == {"url": "ws://testserver/partial/ws"}
+
+ with test_client.websocket_connect("/partial/ws/cls") as websocket:
+ data = websocket.receive_json()
+ assert data == {"url": "ws://testserver/partial/ws/cls"}
+
+
def test_duplicated_param_names():
with pytest.raises(
ValueError,
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 0.17 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[full]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.6",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aiocontextvars==0.2.2
aiosqlite==0.17.0
anyio==3.6.2
appdirs==1.4.4
async-generator==1.10
attrs==22.2.0
autoflake==1.4
black==20.8b1
bleach==4.1.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
click==8.0.4
colorama==0.4.5
contextlib2==21.6.0
contextvars==2.4
coverage==6.2
cryptography==40.0.2
databases==0.5.5
dataclasses==0.8
docutils==0.18.1
flake8==5.0.4
ghp-import==2.1.0
greenlet==2.0.2
idna==3.10
immutables==0.19
importlib-metadata==4.2.0
importlib-resources==5.4.0
iniconfig==1.1.1
isort==5.10.1
itsdangerous==2.0.1
jeepney==0.7.1
Jinja2==3.0.3
keyring==23.4.1
Markdown==3.3.4
MarkupSafe==2.0.1
mccabe==0.7.0
mergedeep==1.3.4
mkautodoc==0.2.0
mkdocs==1.2.4
mkdocs-material==8.2.7
mkdocs-material-extensions==1.0.3
mypy==0.971
mypy-extensions==1.0.0
outcome==1.1.0
packaging==21.3
pathspec==0.9.0
pkginfo==1.10.0
pluggy==1.0.0
py==1.11.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.14.0
pymdown-extensions==9.1
pyparsing==3.1.4
pytest==7.0.1
python-dateutil==2.9.0.post0
python-multipart==0.0.5
PyYAML==6.0.1
pyyaml_env_tag==0.1
readme-renderer==34.0
regex==2023.8.8
requests==2.27.1
requests-toolbelt==1.0.0
rfc3986==1.5.0
SecretStorage==3.3.3
six==1.17.0
sniffio==1.2.0
sortedcontainers==2.4.0
SQLAlchemy==1.4.54
-e git+https://github.com/encode/starlette.git@f53faba229e3fa2844bc3753e233d9c1f54cca52#egg=starlette
toml==0.10.2
tomli==1.2.3
tqdm==4.64.1
trio==0.19.0
twine==3.8.0
typed-ast==1.5.5
types-contextvars==2.4.7.3
types-dataclasses==0.6.6
types-PyYAML==6.0.12.12
types-requests==2.31.0.5
types-urllib3==1.26.25.14
typing_extensions==4.1.1
urllib3==1.26.20
watchdog==2.3.1
webencodings==0.5.1
zipp==3.6.0
| name: starlette
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2021.5.30=py36h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.3=he6710b0_2
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=21.2.2=py36h06a4308_0
- python=3.6.13=h12debd9_1
- readline=8.2=h5eee18b_0
- setuptools=58.0.4=py36h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- aiocontextvars==0.2.2
- aiosqlite==0.17.0
- anyio==3.6.2
- appdirs==1.4.4
- async-generator==1.10
- attrs==22.2.0
- autoflake==1.4
- black==20.8b1
- bleach==4.1.0
- cffi==1.15.1
- charset-normalizer==2.0.12
- click==8.0.4
- colorama==0.4.5
- contextlib2==21.6.0
- contextvars==2.4
- coverage==6.2
- cryptography==40.0.2
- databases==0.5.5
- dataclasses==0.8
- docutils==0.18.1
- flake8==5.0.4
- ghp-import==2.1.0
- greenlet==2.0.2
- idna==3.10
- immutables==0.19
- importlib-metadata==4.2.0
- importlib-resources==5.4.0
- iniconfig==1.1.1
- isort==5.10.1
- itsdangerous==2.0.1
- jeepney==0.7.1
- jinja2==3.0.3
- keyring==23.4.1
- markdown==3.3.4
- markupsafe==2.0.1
- mccabe==0.7.0
- mergedeep==1.3.4
- mkautodoc==0.2.0
- mkdocs==1.2.4
- mkdocs-material==8.2.7
- mkdocs-material-extensions==1.0.3
- mypy==0.971
- mypy-extensions==1.0.0
- outcome==1.1.0
- packaging==21.3
- pathspec==0.9.0
- pkginfo==1.10.0
- pluggy==1.0.0
- py==1.11.0
- pycodestyle==2.9.1
- pycparser==2.21
- pyflakes==2.5.0
- pygments==2.14.0
- pymdown-extensions==9.1
- pyparsing==3.1.4
- pytest==7.0.1
- python-dateutil==2.9.0.post0
- python-multipart==0.0.5
- pyyaml==6.0.1
- pyyaml-env-tag==0.1
- readme-renderer==34.0
- regex==2023.8.8
- requests==2.27.1
- requests-toolbelt==1.0.0
- rfc3986==1.5.0
- secretstorage==3.3.3
- six==1.17.0
- sniffio==1.2.0
- sortedcontainers==2.4.0
- sqlalchemy==1.4.54
- toml==0.10.2
- tomli==1.2.3
- tqdm==4.64.1
- trio==0.19.0
- twine==3.8.0
- typed-ast==1.5.5
- types-contextvars==2.4.7.3
- types-dataclasses==0.6.6
- types-pyyaml==6.0.12.12
- types-requests==2.31.0.5
- types-urllib3==1.26.25.14
- typing-extensions==4.1.1
- urllib3==1.26.20
- watchdog==2.3.1
- webencodings==0.5.1
- zipp==3.6.0
prefix: /opt/conda/envs/starlette
| [
"tests/test_routing.py::test_partial_async_ws_endpoint[asyncio]",
"tests/test_routing.py::test_partial_async_ws_endpoint[trio]"
] | [] | [
"tests/test_routing.py::test_router[asyncio]",
"tests/test_routing.py::test_router[trio]",
"tests/test_routing.py::test_route_converters[asyncio]",
"tests/test_routing.py::test_route_converters[trio]",
"tests/test_routing.py::test_url_path_for",
"tests/test_routing.py::test_url_for",
"tests/test_routing.py::test_router_add_route[asyncio]",
"tests/test_routing.py::test_router_add_route[trio]",
"tests/test_routing.py::test_router_duplicate_path[asyncio]",
"tests/test_routing.py::test_router_duplicate_path[trio]",
"tests/test_routing.py::test_router_add_websocket_route[asyncio]",
"tests/test_routing.py::test_router_add_websocket_route[trio]",
"tests/test_routing.py::test_protocol_switch[asyncio]",
"tests/test_routing.py::test_protocol_switch[trio]",
"tests/test_routing.py::test_mount_urls[asyncio]",
"tests/test_routing.py::test_mount_urls[trio]",
"tests/test_routing.py::test_reverse_mount_urls",
"tests/test_routing.py::test_mount_at_root[asyncio]",
"tests/test_routing.py::test_mount_at_root[trio]",
"tests/test_routing.py::test_host_routing[asyncio]",
"tests/test_routing.py::test_host_routing[trio]",
"tests/test_routing.py::test_host_reverse_urls",
"tests/test_routing.py::test_subdomain_routing[asyncio]",
"tests/test_routing.py::test_subdomain_routing[trio]",
"tests/test_routing.py::test_subdomain_reverse_urls",
"tests/test_routing.py::test_url_for_with_root_path[asyncio]",
"tests/test_routing.py::test_url_for_with_root_path[trio]",
"tests/test_routing.py::test_url_for_with_double_mount",
"tests/test_routing.py::test_standalone_route_matches[asyncio]",
"tests/test_routing.py::test_standalone_route_matches[trio]",
"tests/test_routing.py::test_standalone_route_does_not_match[asyncio]",
"tests/test_routing.py::test_standalone_route_does_not_match[trio]",
"tests/test_routing.py::test_standalone_ws_route_matches[asyncio]",
"tests/test_routing.py::test_standalone_ws_route_matches[trio]",
"tests/test_routing.py::test_standalone_ws_route_does_not_match[asyncio]",
"tests/test_routing.py::test_standalone_ws_route_does_not_match[trio]",
"tests/test_routing.py::test_lifespan_async[asyncio]",
"tests/test_routing.py::test_lifespan_async[trio]",
"tests/test_routing.py::test_lifespan_sync[asyncio]",
"tests/test_routing.py::test_lifespan_sync[trio]",
"tests/test_routing.py::test_raise_on_startup[asyncio]",
"tests/test_routing.py::test_raise_on_startup[trio]",
"tests/test_routing.py::test_raise_on_shutdown[asyncio]",
"tests/test_routing.py::test_raise_on_shutdown[trio]",
"tests/test_routing.py::test_partial_async_endpoint[asyncio]",
"tests/test_routing.py::test_partial_async_endpoint[trio]",
"tests/test_routing.py::test_duplicated_param_names"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,794 | 183 | [
"starlette/routing.py"
] |
TheUncleKai__bbutils-20 | 79e59c76c09b1f76cc67a3d2b1bcad484ce0029b | 2021-12-10 15:08:12 | c627eddf38872cd09cac5235caa38b658dc3fe75 | diff --git a/bbutil/__init__.py b/bbutil/__init__.py
index d289f07..f758209 100644
--- a/bbutil/__init__.py
+++ b/bbutil/__init__.py
@@ -59,7 +59,7 @@ __major__ = 4
__minor__ = 0
#: version patch
-__patch__ = 5
+__patch__ = 6
#: package version
__version__ = "{0:d}.{1:d}.{2:d}.{3:d}".format(__milestone__, __major__, __minor__, __patch__)
diff --git a/bbutil/logging/__init__.py b/bbutil/logging/__init__.py
index c5e9dbe..f231310 100755
--- a/bbutil/logging/__init__.py
+++ b/bbutil/logging/__init__.py
@@ -37,7 +37,7 @@ __all__ = [
_index = {
0: ["INFORM", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
1: ["INFORM", "DEBUG1", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
- 2: ["INFORM", "DEBUG1", "DEBUG1", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
+ 2: ["INFORM", "DEBUG1", "DEBUG2", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"],
3: ["INFORM", "DEBUG1", "DEBUG2", "DEBUG3", "WARN", "ERROR", "EXCEPTION", "TIMER", "PROGRESS"]
}
diff --git a/bbutil/logging/writer/console.py b/bbutil/logging/writer/console.py
index b769bf7..bdc2386 100755
--- a/bbutil/logging/writer/console.py
+++ b/bbutil/logging/writer/console.py
@@ -84,6 +84,7 @@ class ConsoleWriter(Writer):
self.styles: Dict[str, _Style] = _schemes
self.encoding: str = ""
+ self.app_space: int = 0
self.text_space: int = 15
self.seperator: str = "|"
self.length: int = 0
@@ -103,6 +104,10 @@ class ConsoleWriter(Writer):
if item is not None:
self.text_space = item
+ item = kwargs.get("app_space", None)
+ if item is not None:
+ self.app_space = item
+
item = kwargs.get("seperator", None)
if item is not None:
self.seperator = item
@@ -192,7 +197,10 @@ class ConsoleWriter(Writer):
return
def _create_color(self, item: Message, text: str) -> str:
- appname = "{0:s} ".format(item.app).ljust(self.text_space)
+ _app_space = self.app_space
+ if self.app_space == 0:
+ _app_space = len(item.app) + 5
+ appname = "{0:s} ".format(item.app).ljust(_app_space)
scheme = self.styles[item.level].scheme
if item.tag == "":
| Fix appname bug in logging
Fix appname bug in logging, it uses the same width as the tags. Thats stupid. | TheUncleKai/bbutils | diff --git a/tests.json b/tests.json
index efb2357..5e650f7 100644
--- a/tests.json
+++ b/tests.json
@@ -82,6 +82,10 @@
"test_write_04",
"test_write_05",
"test_write_06",
+ "test_write_07",
+ "test_write_08",
+ "test_write_09",
+ "test_write_10",
"test_clear_01",
"test_clear_02"
]
diff --git a/tests/logging/console.py b/tests/logging/console.py
index e7ce01a..505e772 100755
--- a/tests/logging/console.py
+++ b/tests/logging/console.py
@@ -21,10 +21,15 @@ import sys
import unittest
import unittest.mock as mock
-from bbutil.logging.writer.console import ConsoleWriter
+import colorama
+
+from bbutil.logging.writer.console import ConsoleWriter, _Style
from bbutil.logging.types import Message, Progress, Writer
+RESET_ALL = colorama.Style.RESET_ALL
+
+
class Callback(object):
def __init__(self, writer: Writer):
@@ -241,6 +246,157 @@ class TestConsoleWriter(unittest.TestCase):
self.assertFalse(write_called)
return
+ def test_write_07(self):
+ message = Message(app="TEST", level="INFORM", tag="TEST", content="This is a test!")
+
+ _style = _Style("INFORM", "BRIGHT", "GREEN", "")
+
+ item = ConsoleWriter()
+ item.open()
+ item.stdout = SysWrite()
+
+ item.write(message)
+
+ write_called = item.stdout.write.called
+ call = item.stdout.write.call_args_list[0]
+ (args, kwargs) = call
+ data = args[0]
+
+ print(data)
+
+ _tag = "TEST".ljust(15)
+ _app_space = len("TEST") + 5
+ _app = "{0:s} ".format("TEST").ljust(_app_space)
+
+ content = "{0:s}{1:s}{2:s} {3:s}{4:s} {5:s}{6:s}\n".format(RESET_ALL,
+ _app,
+ _style.scheme,
+ _tag,
+ "|",
+ RESET_ALL,
+ "This is a test!")
+
+ self.assertTrue(write_called)
+ self.assertIn(message.app, data)
+ self.assertIn(message.tag, data)
+ self.assertIn(message.content, data)
+ self.assertEqual(content, data)
+ return
+
+ def test_write_08(self):
+ message = Message(app="TEST", level="INFORM", tag="TEST", content="This is a test!")
+
+ _style = _Style("INFORM", "BRIGHT", "GREEN", "")
+
+ item = ConsoleWriter()
+ item.setup(app_space=15)
+ item.open()
+ item.stdout = SysWrite()
+
+ item.write(message)
+
+ write_called = item.stdout.write.called
+ call = item.stdout.write.call_args_list[0]
+ (args, kwargs) = call
+ data = args[0]
+
+ print(data)
+
+ _tag = "TEST".ljust(15)
+ _app_space = len("TEST") + 5
+ _app = "{0:s} ".format("TEST").ljust(15)
+
+ content = "{0:s}{1:s}{2:s} {3:s}{4:s} {5:s}{6:s}\n".format(RESET_ALL,
+ _app,
+ _style.scheme,
+ _tag,
+ "|",
+ RESET_ALL,
+ "This is a test!")
+
+ self.assertTrue(write_called)
+ self.assertIn(message.app, data)
+ self.assertIn(message.tag, data)
+ self.assertIn(message.content, data)
+ self.assertEqual(content, data)
+ return
+
+ def test_write_09(self):
+ message = Message(app="TEST", level="INFORM", tag="TEST", content="This is a test!")
+
+ _style = _Style("INFORM", "BRIGHT", "GREEN", "")
+
+ item = ConsoleWriter()
+ item.setup(app_space=10)
+ item.open()
+ item.stdout = SysWrite()
+
+ item.write(message)
+
+ write_called = item.stdout.write.called
+ call = item.stdout.write.call_args_list[0]
+ (args, kwargs) = call
+ data = args[0]
+
+ print(data)
+
+ _tag = "TEST".ljust(15)
+ _app_space = len("TEST") + 5
+ _app = "{0:s} ".format("TEST").ljust(15)
+
+ content = "{0:s}{1:s}{2:s} {3:s}{4:s} {5:s}{6:s}\n".format(RESET_ALL,
+ _app,
+ _style.scheme,
+ _tag,
+ "|",
+ RESET_ALL,
+ "This is a test!")
+
+ self.assertTrue(write_called)
+ self.assertIn(message.app, data)
+ self.assertIn(message.tag, data)
+ self.assertIn(message.content, data)
+ self.assertNotEqual(content, data)
+ return
+
+ def test_write_10(self):
+ message = Message(app="TEST", level="INFORM", tag="TEST", content="This is a test!")
+
+ _style = _Style("INFORM", "BRIGHT", "GREEN", "")
+
+ item = ConsoleWriter()
+ item.setup(text_space=10)
+ item.open()
+ item.stdout = SysWrite()
+
+ item.write(message)
+
+ write_called = item.stdout.write.called
+ call = item.stdout.write.call_args_list[0]
+ (args, kwargs) = call
+ data = args[0]
+
+ print(data)
+
+ _tag = "TEST".ljust(10)
+ _app_space = len("TEST") + 5
+ _app = "{0:s} ".format("TEST").ljust(_app_space)
+
+ content = "{0:s}{1:s}{2:s} {3:s}{4:s} {5:s}{6:s}\n".format(RESET_ALL,
+ _app,
+ _style.scheme,
+ _tag,
+ "|",
+ RESET_ALL,
+ "This is a test!")
+
+ self.assertTrue(write_called)
+ self.assertIn(message.app, data)
+ self.assertIn(message.tag, data)
+ self.assertIn(message.content, data)
+ self.assertEqual(content, data)
+ return
+
def test_clear_01(self):
message = Message(app="TEST", content="This is a test!", raw=True)
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 0
},
"num_modified_files": 3
} | 0.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/TheUncleKai/bbutils.git@79e59c76c09b1f76cc67a3d2b1bcad484ce0029b#egg=bbutils
colorama==0.4.3
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
tomli==2.2.1
| name: bbutils
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- colorama==0.4.3
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/bbutils
| [
"tests/logging/console.py::TestConsoleWriter::test_write_07",
"tests/logging/console.py::TestConsoleWriter::test_write_09",
"tests/logging/console.py::TestConsoleWriter::test_write_10"
] | [
"tests/logging/console.py::TestConsoleWriter::test_constructor",
"tests/logging/console.py::TestConsoleWriter::test_setup"
] | [
"tests/logging/console.py::TestConsoleWriter::test_add_style",
"tests/logging/console.py::TestConsoleWriter::test_clear_01",
"tests/logging/console.py::TestConsoleWriter::test_clear_02",
"tests/logging/console.py::TestConsoleWriter::test_open",
"tests/logging/console.py::TestConsoleWriter::test_write_01",
"tests/logging/console.py::TestConsoleWriter::test_write_02",
"tests/logging/console.py::TestConsoleWriter::test_write_03",
"tests/logging/console.py::TestConsoleWriter::test_write_04",
"tests/logging/console.py::TestConsoleWriter::test_write_05",
"tests/logging/console.py::TestConsoleWriter::test_write_06",
"tests/logging/console.py::TestConsoleWriter::test_write_08"
] | [] | Apache License 2.0 | 11,795 | 761 | [
"bbutil/__init__.py",
"bbutil/logging/__init__.py",
"bbutil/logging/writer/console.py"
] |
|
lektor__lektor-960 | c7419cf6f6a986740da680fa158055cc83a5befe | 2021-12-13 02:02:31 | c22e224ec56620c2a1d90016d74518970b1dd578 | diff --git a/lektor/db.py b/lektor/db.py
index 6cfcea9..bae4b54 100644
--- a/lektor/db.py
+++ b/lektor/db.py
@@ -6,7 +6,6 @@ import hashlib
import operator
import os
import posixpath
-import warnings
from collections import OrderedDict
from datetime import timedelta
from itertools import islice
@@ -832,21 +831,9 @@ class Image(Attachment):
return rv
return Undefined("The format of the image could not be determined.")
- def thumbnail(
- self, width=None, height=None, crop=None, mode=None, upscale=None, quality=None
- ):
+ def thumbnail(self, width=None, height=None, mode=None, upscale=None, quality=None):
"""Utility to create thumbnails."""
- # `crop` exists to preserve backward-compatibility, and will be removed.
- if crop is not None and mode is not None:
- raise ValueError("Arguments `crop` and `mode` are mutually exclusive.")
-
- if crop is not None:
- warnings.warn(
- 'The `crop` argument is deprecated. Use `mode="crop"` instead.'
- )
- mode = "crop"
-
if mode is None:
mode = ThumbnailMode.DEFAULT
else:
diff --git a/lektor/imagetools.py b/lektor/imagetools.py
index fcfcc1a..0418aa5 100644
--- a/lektor/imagetools.py
+++ b/lektor/imagetools.py
@@ -593,16 +593,6 @@ def make_image_thumbnail(
would_upscale = computed_width > source_width or computed_height > source_height
- # this part needs to be removed once backward-compatibility period passes
- if would_upscale and upscale is None:
- warnings.warn(
- "Your image is being scaled up since the requested thumbnail "
- "size is larger than the source. This default will change "
- "in the future. If you want to preserve the current behaviour, "
- "use `upscale=True`."
- )
- upscale = True
-
if would_upscale and not upscale:
return Thumbnail(source_url_path, source_width, source_height)
| Disable deprecated implicit thumbnail upscaling?
Implicit thumbnail upscaling, as well as the `crop` argument to [`Image.thumbnail`](https://github.com/lektor/lektor/blob/f135d73a11ac557bff4f1068958e71b6b526ee63/lektor/db.py#L818) have been [deprecated](https://github.com/lektor/lektor/blob/f135d73a11ac557bff4f1068958e71b6b526ee63/lektor/imagetools.py#L598) since release 3.2.0.
This issue is here to make sure we don't forget to disable those features when the time is right.
(This issue should probably be attached to the [4.0 Milestone](https://github.com/lektor/lektor/milestone/5), but I don't think that I have sufficient privileges to do so.)
Refs: #551, #885 | lektor/lektor | diff --git a/tests/test_images.py b/tests/test_images.py
index 8609864..ae13a53 100644
--- a/tests/test_images.py
+++ b/tests/test_images.py
@@ -329,12 +329,11 @@ class Test_make_image_thumbnail:
assert rv.url_path != source_url_path
assert len(ctx.sub_artifacts) == 1
- def test_implicit_upscale(self, ctx, test_jpg, source_url_path):
- with pytest.warns(UserWarning, match=r"image is being scaled up"):
- rv = make_image_thumbnail(ctx, test_jpg, source_url_path, 512)
- assert (rv.width, rv.height) == (512, 683)
- assert rv.url_path == "[email protected]"
- assert len(ctx.sub_artifacts) == 1
+ def test_no_implicit_upscale(self, ctx, test_jpg, source_url_path):
+ rv = make_image_thumbnail(ctx, test_jpg, source_url_path, 512)
+ assert (rv.width, rv.height) == (384, 512)
+ assert rv.url_path == "test.jpg"
+ assert len(ctx.sub_artifacts) == 0
@pytest.mark.parametrize("mode", iter(ThumbnailMode))
def test_upscale_false(self, ctx, test_jpg, source_url_path, mode):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 1
},
"num_modified_files": 2
} | 3.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | babel==2.17.0
blinker==1.9.0
certifi==2025.1.31
charset-normalizer==3.4.1
click==8.1.8
Deprecated==1.2.18
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
ExifRead==3.0.0
filetype==1.2.0
Flask==2.3.3
idna==3.10
importlib_metadata==8.6.1
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
inifile==0.4.1
itsdangerous==2.2.0
Jinja2==3.1.6
-e git+https://github.com/lektor/lektor.git@c7419cf6f6a986740da680fa158055cc83a5befe#egg=Lektor
MarkupSafe==3.0.2
marshmallow==3.26.1
marshmallow_dataclass==8.7.1
mistune==2.0.5
mypy-extensions==1.0.0
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
python-slugify==8.0.4
pytz==2025.2
requests==2.32.3
text-unidecode==1.3
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
typeguard==4.4.2
typing-inspect==0.9.0
typing_extensions==4.13.0
urllib3==2.3.0
watchdog==6.0.0
Werkzeug==2.3.8
wrapt==1.17.2
zipp==3.21.0
| name: lektor
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- babel==2.17.0
- blinker==1.9.0
- certifi==2025.1.31
- charset-normalizer==3.4.1
- click==8.1.8
- deprecated==1.2.18
- exifread==3.0.0
- filetype==1.2.0
- flask==2.3.3
- idna==3.10
- importlib-metadata==8.6.1
- inifile==0.4.1
- itsdangerous==2.2.0
- jinja2==3.1.6
- lektor==3.3.3.dev118+gc7419cf
- markupsafe==3.0.2
- marshmallow==3.26.1
- marshmallow-dataclass==8.7.1
- mistune==2.0.5
- mypy-extensions==1.0.0
- python-slugify==8.0.4
- pytz==2025.2
- requests==2.32.3
- text-unidecode==1.3
- typeguard==4.4.2
- typing-extensions==4.13.0
- typing-inspect==0.9.0
- urllib3==2.3.0
- watchdog==6.0.0
- werkzeug==2.3.8
- wrapt==1.17.2
- zipp==3.21.0
prefix: /opt/conda/envs/lektor
| [
"tests/test_images.py::Test_make_image_thumbnail::test_no_implicit_upscale"
] | [] | [
"tests/test_images.py::test_exif",
"tests/test_images.py::test_image_attributes",
"tests/test_images.py::test_is_rotated",
"tests/test_images.py::test_image_info_svg_declaration",
"tests/test_images.py::test_image_info_svg_length",
"tests/test_images.py::test_thumbnail_dimensions_reported",
"tests/test_images.py::test_dimensions",
"tests/test_images.py::Test_make_image_thumbnail::test_no_width_or_height",
"tests/test_images.py::Test_make_image_thumbnail::test_warn_fallback_to_fit",
"tests/test_images.py::Test_make_image_thumbnail::test_unknown_image_format",
"tests/test_images.py::Test_make_image_thumbnail::test_svg",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[50-None-ThumbnailMode.FIT-None-expect0]",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[None-128-ThumbnailMode.FIT-None-expect1]",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[50-50-ThumbnailMode.CROP-None-expect2]",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[50-50-ThumbnailMode.STRETCH-None-expect3]",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[512-None-ThumbnailMode.FIT-True-expect4]",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[512-512-ThumbnailMode.CROP-None-expect5]",
"tests/test_images.py::Test_make_image_thumbnail::test_scale[512-512-ThumbnailMode.STRETCH-None-expect6]",
"tests/test_images.py::Test_make_image_thumbnail::test_upscale_false[ThumbnailMode.FIT]",
"tests/test_images.py::Test_make_image_thumbnail::test_upscale_false[ThumbnailMode.CROP]",
"tests/test_images.py::Test_make_image_thumbnail::test_upscale_false[ThumbnailMode.STRETCH]"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,807 | 525 | [
"lektor/db.py",
"lektor/imagetools.py"
] |
|
level12__keg-storage-56 | 02003a8efcaf29c9167ed68ddee13a1f8a1bed2d | 2021-12-13 20:48:56 | 02003a8efcaf29c9167ed68ddee13a1f8a1bed2d | diff --git a/keg_storage/backends/base.py b/keg_storage/backends/base.py
index dedaa6b..dcc51ba 100644
--- a/keg_storage/backends/base.py
+++ b/keg_storage/backends/base.py
@@ -158,6 +158,12 @@ class StorageBackend:
"""
raise NotImplementedError()
+ def copy(self, path: str, new_path: str):
+ """
+ Copy the remote file specified by `path` to `new_path`.
+ """
+ raise NotImplementedError()
+
def link_to(
self,
path: str,
diff --git a/keg_storage/backends/filesystem.py b/keg_storage/backends/filesystem.py
index a0a7d04..49c7171 100644
--- a/keg_storage/backends/filesystem.py
+++ b/keg_storage/backends/filesystem.py
@@ -122,6 +122,9 @@ class LocalFSStorage(base.InternalLinksStorageBackend):
return LocalFSFile(path, mode)
+ def copy(self, path: str, new_path: str):
+ return self.put(path, new_path)
+
def delete(self, path: str):
self._validate_path(path)
path = self._resolve_path(path)
diff --git a/keg_storage/backends/s3.py b/keg_storage/backends/s3.py
index 96952a2..ca6b2b2 100644
--- a/keg_storage/backends/s3.py
+++ b/keg_storage/backends/s3.py
@@ -248,6 +248,16 @@ class S3Storage(StorageBackend):
else:
raise ValueError('Unsupported mode. Accepted modes are FileMode.read or FileMode.write')
+ def copy(self, current_file, new_file):
+ self.client.copy_object(
+ CopySource={
+ 'Bucket': self.bucket,
+ 'Key': current_file
+ },
+ Bucket=self.bucket,
+ Key=new_file
+ )
+
def delete(self, path):
self.client.delete_object(
Bucket=self.bucket,
diff --git a/keg_storage/cli.py b/keg_storage/cli.py
index c1abd3f..4aa39bc 100644
--- a/keg_storage/cli.py
+++ b/keg_storage/cli.py
@@ -84,6 +84,15 @@ def storage_put(ctx, file, key):
err=True)
[email protected]('copy')
[email protected]('src_key')
[email protected]('dest_key')
[email protected]_context
+def storage_copy(ctx, src_key, dest_key):
+ ctx.obj.data['storage'].copy(src_key, dest_key)
+ click.echo(f"Copied {src_key} to {dest_key}.")
+
+
@storage.command('delete')
@click.argument('path')
@click.pass_context
| Implement method(s) to natively copy objects in S3 and local storage backends
Need a way to natively copy objects so that files don't need to be downloaded and re-uploaded in order to duplicate. | level12/keg-storage | diff --git a/keg_storage/tests/test_backend_filesystem.py b/keg_storage/tests/test_backend_filesystem.py
index 168f922..1f82295 100644
--- a/keg_storage/tests/test_backend_filesystem.py
+++ b/keg_storage/tests/test_backend_filesystem.py
@@ -193,6 +193,22 @@ class TestLocalFSStorage:
assert fp.read() == file_data2
assert f.fp.closed is True
+ def test_copy_file(self, tmp_path: pathlib.Path):
+ root = tmp_path.joinpath('root')
+ root.mkdir()
+
+ file_path = root.joinpath('file.txt')
+ file_path_copy = root.joinpath('file2.txt')
+ fs = backends.LocalFSStorage(root)
+ file_data1 = os.urandom(100)
+
+ with fs.open('file.txt', backends.FileMode.write) as f:
+ f.write(file_data1)
+ fs.copy(str(file_path), str(file_path_copy))
+
+ with file_path_copy.open('rb') as fp:
+ assert fp.read() == file_data1
+
def test_open_for_writing_creates_directories(self, tmp_path: pathlib.Path):
root = tmp_path.joinpath('root')
root.mkdir()
diff --git a/keg_storage/tests/test_backend_s3.py b/keg_storage/tests/test_backend_s3.py
index 220add6..971f1d2 100644
--- a/keg_storage/tests/test_backend_s3.py
+++ b/keg_storage/tests/test_backend_s3.py
@@ -285,6 +285,19 @@ class TestS3Storage:
}
)
+ def test_copy(self, m_boto):
+ s3 = backends.S3Storage('bucket', aws_region='us-east-1')
+ s3.copy('foo/bar', 'foo/baz')
+
+ s3.client.copy_object.assert_called_once_with(
+ CopySource={
+ 'Bucket': 'bucket',
+ 'Key': 'foo/bar'
+ },
+ Bucket='bucket',
+ Key='foo/baz'
+ )
+
def test_write_abort(self, m_boto):
m_client = mock.MagicMock()
m_client.create_multipart_upload.return_value = {'UploadId': 'upload-id'}
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 4
} | 0.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[test,keg]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | appdirs==1.4.4
arrow==1.3.0
azure-core==1.32.0
azure-storage-blob==12.25.1
bcrypt==4.3.0
beautifulsoup4==4.13.3
BlazeUtils==0.7.0
blinker==1.9.0
boto3==1.37.23
botocore==1.37.23
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.8.0
cryptography==44.0.2
distlib==0.3.9
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
filelock==3.18.0
flake8==7.2.0
Flask==3.1.0
Flask-SQLAlchemy==3.1.1
Flask-WebTest==0.1.6
Flask-WTF==1.2.2
freezegun==1.5.1
greenlet==3.1.1
humanize==4.12.2
idna==3.10
importlib_metadata==8.6.1
infinity==1.5
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
intervals==0.9.2
isodate==0.7.2
itsdangerous==2.2.0
Jinja2==3.1.6
jmespath==1.0.1
Keg==0.11.1
KegElements==0.12.1
-e git+https://github.com/level12/keg-storage.git@02003a8efcaf29c9167ed68ddee13a1f8a1bed2d#egg=KegStorage
MarkupSafe==3.0.2
mccabe==0.7.0
packaging @ file:///croot/packaging_1734472117206/work
paramiko==3.5.1
platformdirs==4.3.7
pluggy @ file:///croot/pluggy_1733169602837/work
pycodestyle==2.13.0
pycparser==2.22
pyflakes==3.3.2
PyNaCl==1.5.0
pyproject-api==1.9.0
pytest @ file:///croot/pytest_1738938843180/work
pytest-cov==6.0.0
pytest-cover==3.0.0
pytest-coverage==0.0
python-dateutil==2.9.0.post0
python-json-logger==3.3.0
pytz==2025.2
requests==2.32.3
s3transfer==0.11.4
sentry-sdk==2.25.0
six==1.17.0
soupsieve==2.6
SQLAlchemy==2.0.40
SQLAlchemy-Utils==0.41.2
tomli==2.2.1
tox==4.25.0
types-python-dateutil==2.9.0.20241206
typing_extensions==4.13.0
urllib3==1.26.20
validators==0.34.0
virtualenv==20.29.3
waitress==3.0.2
WebOb==1.8.9
WebTest==3.0.4
Werkzeug==3.1.3
wrapt==1.17.2
WTForms==3.2.1
WTForms-Alchemy==0.19.0
WTForms-Components==0.11.0
zipp==3.21.0
| name: keg-storage
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- appdirs==1.4.4
- arrow==1.3.0
- azure-core==1.32.0
- azure-storage-blob==12.25.1
- bcrypt==4.3.0
- beautifulsoup4==4.13.3
- blazeutils==0.7.0
- blinker==1.9.0
- boto3==1.37.23
- botocore==1.37.23
- cachetools==5.5.2
- certifi==2025.1.31
- cffi==1.17.1
- chardet==5.2.0
- charset-normalizer==3.4.1
- click==8.1.8
- colorama==0.4.6
- coverage==7.8.0
- cryptography==44.0.2
- distlib==0.3.9
- filelock==3.18.0
- flake8==7.2.0
- flask==3.1.0
- flask-sqlalchemy==3.1.1
- flask-webtest==0.1.6
- flask-wtf==1.2.2
- freezegun==1.5.1
- greenlet==3.1.1
- humanize==4.12.2
- idna==3.10
- importlib-metadata==8.6.1
- infinity==1.5
- intervals==0.9.2
- isodate==0.7.2
- itsdangerous==2.2.0
- jinja2==3.1.6
- jmespath==1.0.1
- keg==0.11.1
- kegelements==0.12.1
- markupsafe==3.0.2
- mccabe==0.7.0
- paramiko==3.5.1
- platformdirs==4.3.7
- pycodestyle==2.13.0
- pycparser==2.22
- pyflakes==3.3.2
- pynacl==1.5.0
- pyproject-api==1.9.0
- pytest-cov==6.0.0
- pytest-cover==3.0.0
- pytest-coverage==0.0
- python-dateutil==2.9.0.post0
- python-json-logger==3.3.0
- pytz==2025.2
- requests==2.32.3
- s3transfer==0.11.4
- sentry-sdk==2.25.0
- six==1.17.0
- soupsieve==2.6
- sqlalchemy==2.0.40
- sqlalchemy-utils==0.41.2
- tomli==2.2.1
- tox==4.25.0
- types-python-dateutil==2.9.0.20241206
- typing-extensions==4.13.0
- urllib3==1.26.20
- validators==0.34.0
- virtualenv==20.29.3
- waitress==3.0.2
- webob==1.8.9
- webtest==3.0.4
- werkzeug==3.1.3
- wrapt==1.17.2
- wtforms==3.2.1
- wtforms-alchemy==0.19.0
- wtforms-components==0.11.0
- zipp==3.21.0
prefix: /opt/conda/envs/keg-storage
| [
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_copy_file",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_copy"
] | [] | [
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_init",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_init_not_dir",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_init_does_not_exist",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_list_success",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_list_failures",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_open_for_reading",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_open_for_writing",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_open_for_writing_creates_directories",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_open_for_read_write",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_open_failures",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_delete_success",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_delete_failures",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[~-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[~-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[~-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[?-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[?-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[?-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[*-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[*-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[*-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\t-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\t-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\t-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\n-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\n-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\n-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\r-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\r-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\r-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\x0b-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\x0b-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\x0b-delete-args2]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\x0c-list-args0]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\x0c-open-args1]",
"keg_storage/tests/test_backend_filesystem.py::TestLocalFSStorage::test_validates_path[\\x0c-delete-args2]",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_init_sets_up_correctly",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_list",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_list_pagenated",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_delete",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_open_read",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_open_write",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_open_read_write",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_read_operations",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_read_not_found",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_write_operations",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_write_abort",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_write_flushes",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_link_to_bad_operation",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_link_to_success[d-get_object-extra_params0]",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_link_to_success[u-put_object-extra_params1]",
"keg_storage/tests/test_backend_s3.py::TestS3Storage::test_link_to_success[r-delete_object-extra_params2]"
] | [] | BSD License | 11,811 | 670 | [
"keg_storage/backends/base.py",
"keg_storage/backends/filesystem.py",
"keg_storage/backends/s3.py",
"keg_storage/cli.py"
] |
|
PMEAL__OpenPNM-2230 | 703437e816546e12ec2ff71350961d666edbda9d | 2021-12-14 06:45:36 | e4c9f799076c334904088df34b8f04da7802a08b | diff --git a/openpnm/core/_base.py b/openpnm/core/_base.py
index a10d5a9d8..8e72baeb7 100644
--- a/openpnm/core/_base.py
+++ b/openpnm/core/_base.py
@@ -715,11 +715,14 @@ class Base(dict):
# Let's start by handling the easy cases first
if not any([a is None for a in arrs]):
+ # If any arrays are more than 1 column, then make they all are
+ if np.any(np.array([a.ndim for a in arrs]) > 1):
+ arrs = [np.atleast_2d(a).T if a.ndim == 1 else a for a in arrs]
# All objs are present and array found on all objs
try:
W = max([a.shape[1] for a in arrs]) # Width of array
shape = [N, W]
- except:
+ except IndexError:
shape = [N, ]
types = [a.dtype for a in arrs]
if len(set(types)) == 1:
| Interleave data breaks when dealing with a combination of (Nt,1) and (Nt,2) conductance models
**Describe the bug**
Suppose you have two geometries, one involves a conductance model that returns (Nt,1), and the other (Nt,2). Calling `throat.conductance` on the phase object fails.
**To Reproduce**
Steps to reproduce the behavior, ideally a code snippet that only reproduces the bug:
```python
import numpy as np
import openpnm as op
np.random.seed(10)
ws = op.Workspace()
net = op.network.Cubic(shape=[5, 1, 1])
geom2 = op.geometry.SpheresAndCylinders(network=net, pores=net.Ps, throats=net.Ts[:-1])
geom1 = op.geometry.SpheresAndCylinders(network=net, throats=net.Ts[-1])
air = op.phases.Air(network=net)
phys2 = op.physics.Standard(network=net, phase=air, geometry=geom1)
phys1 = op.physics.Standard(network=net, phase=air, geometry=geom2)
mod = op.models.physics.ad_dif_conductance.ad_dif
phys2.add_model("throat.foo", model=mod)
phys1["throat.foo"] = 1.234
g = air["throat.foo"]
print(g)
```
```python
Traceback (most recent call last):
File "/home/amin/Code/scripts/temp.py", line 22, in <module>
g = air["throat.foo"]
File "/home/amin/Code/OpenPNM/openpnm/phases/GenericPhase.py", line 92, in __getitem__
vals = super().__getitem__(key)
File "/home/amin/Code/OpenPNM/openpnm/core/Base.py", line 27, in __getitem__
vals = super().__getitem__(key)
File "/home/amin/Code/OpenPNM/openpnm/core/Base.py", line 254, in __getitem__
vals = self.interleave_data(key)
File "/home/amin/Code/OpenPNM/openpnm/core/Base.py", line 810, in interleave_data
temp_arr[inds] = vals
ValueError: shape mismatch: value array of shape (3,) could not be broadcast to indexing result of shape (3,2)
``` | PMEAL/OpenPNM | diff --git a/tests/unit/core/InterleaveDataTest.py b/tests/unit/core/InterleaveDataTest.py
index 83f521919..f4c0ca9cb 100644
--- a/tests/unit/core/InterleaveDataTest.py
+++ b/tests/unit/core/InterleaveDataTest.py
@@ -323,6 +323,15 @@ class InterleaveDataTest:
geo1['throat.conduit_data'] = np.ones((geo1.Nt, 1))
geo2['throat.conduit_data'] = np.ones((geo2.Nt, 2))*2
assert np.all(pn['throat.conduit_data'] == a)
+ # Now do it with 1D arrays
+ geo1['throat.conduit_data'] = np.ones((geo1.Nt, ))
+ geo2['throat.conduit_data'] = np.ones((geo2.Nt, 2))*2
+ assert np.all(pn['throat.conduit_data'] == a)
+ # Now do it the other way
+ geo1['throat.conduit_data'] = np.ones((geo1.Nt, 2))
+ geo2['throat.conduit_data'] = np.ones((geo2.Nt, ))*2
+ assert np.all(pn['throat.conduit_data'] == a)
+
if __name__ == '__main__':
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 2.8 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.8",
"reqs_path": [
"requirements/pip_requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | asttokens==3.0.0
attr==0.3.2
attrs==25.3.0
auto-all==1.4.1
backcall==0.2.0
chemicals==1.3.3
contourpy==1.1.1
cycler==0.12.1
decorator==5.2.1
docrep==0.3.2
exceptiongroup==1.2.2
executing==2.2.0
flatdict==4.0.1
fluids==1.1.0
fonttools==4.56.0
gitdb==4.0.12
GitPython==3.1.44
h5py==3.11.0
imageio==2.35.1
importlib_metadata==8.5.0
importlib_resources==6.4.5
iniconfig==2.1.0
intel-cmplr-lib-ur==2025.1.0
intel-openmp==2025.1.0
ipython==8.12.3
jedi==0.19.2
json-tricks==3.17.3
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.7
lazy_loader==0.4
llvmlite==0.41.1
matplotlib==3.7.5
matplotlib-inline==0.1.7
mkl==2025.1.0
mpmath==1.3.0
networkx==3.1
numba==0.58.1
numpy==1.24.4
-e git+https://github.com/PMEAL/OpenPNM.git@703437e816546e12ec2ff71350961d666edbda9d#egg=openpnm
packaging==24.2
pandas==2.0.3
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
pillow==10.4.0
pkgutil_resolve_name==1.3.10
pluggy==1.5.0
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
Pygments==2.19.1
pypardiso==0.4.6
pyparsing==3.1.4
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyWavelets==1.4.1
referencing==0.35.1
rpds-py==0.20.1
scikit-image==0.21.0
scipy==1.10.1
six==1.17.0
smmap==5.0.2
stack-data==0.6.3
sympy==1.13.3
tbb==2022.1.0
tcmlib==1.3.0
terminaltables==3.1.10
tifffile==2023.7.10
tomli==2.2.1
tqdm==4.67.1
traitlets==5.14.3
traits==7.0.2
transforms3d==0.4.2
typing_extensions==4.13.0
tzdata==2025.2
umf==0.10.0
wcwidth==0.2.13
zipp==3.20.2
| name: OpenPNM
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=24.2=py38h06a4308_0
- python=3.8.20=he870216_0
- readline=8.2=h5eee18b_0
- setuptools=75.1.0=py38h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.44.0=py38h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- asttokens==3.0.0
- attr==0.3.2
- attrs==25.3.0
- auto-all==1.4.1
- backcall==0.2.0
- chemicals==1.3.3
- contourpy==1.1.1
- cycler==0.12.1
- decorator==5.2.1
- docrep==0.3.2
- exceptiongroup==1.2.2
- executing==2.2.0
- flatdict==4.0.1
- fluids==1.1.0
- fonttools==4.56.0
- gitdb==4.0.12
- gitpython==3.1.44
- h5py==3.11.0
- imageio==2.35.1
- importlib-metadata==8.5.0
- importlib-resources==6.4.5
- iniconfig==2.1.0
- intel-cmplr-lib-ur==2025.1.0
- intel-openmp==2025.1.0
- ipython==8.12.3
- jedi==0.19.2
- json-tricks==3.17.3
- jsonschema==4.23.0
- jsonschema-specifications==2023.12.1
- kiwisolver==1.4.7
- lazy-loader==0.4
- llvmlite==0.41.1
- matplotlib==3.7.5
- matplotlib-inline==0.1.7
- mkl==2025.1.0
- mpmath==1.3.0
- networkx==3.1
- numba==0.58.1
- numpy==1.24.4
- packaging==24.2
- pandas==2.0.3
- parso==0.8.4
- pexpect==4.9.0
- pickleshare==0.7.5
- pillow==10.4.0
- pkgutil-resolve-name==1.3.10
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pygments==2.19.1
- pypardiso==0.4.6
- pyparsing==3.1.4
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pywavelets==1.4.1
- referencing==0.35.1
- rpds-py==0.20.1
- scikit-image==0.21.0
- scipy==1.10.1
- six==1.17.0
- smmap==5.0.2
- stack-data==0.6.3
- sympy==1.13.3
- tbb==2022.1.0
- tcmlib==1.3.0
- terminaltables==3.1.10
- tifffile==2023.7.10
- tomli==2.2.1
- tqdm==4.67.1
- traitlets==5.14.3
- traits==7.0.2
- transforms3d==0.4.2
- typing-extensions==4.13.0
- tzdata==2025.2
- umf==0.10.0
- wcwidth==0.2.13
- zipp==3.20.2
prefix: /opt/conda/envs/OpenPNM
| [
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_nt_by_1_with_nt_by_2"
] | [
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_missing_objects",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_partial_data",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_int",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_object",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_int_missing_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_int_missing_physics"
] | [
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_drop_locations_from_geom_successively_with_single_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleaving_mixed_data",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_bool",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_float",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_key_error",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_float_missing_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_bool_missing_geometry",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_float_missing_physics",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_interleave_data_bool_missing_physics",
"tests/unit/core/InterleaveDataTest.py::InterleaveDataTest::test_writing_subdict_names_across_subdomains"
] | [] | MIT License | 11,812 | 265 | [
"openpnm/core/_base.py"
] |
|
magpylib__magpylib-430 | 8c3050d0fd0ef9111b237bd543bcc8991db9d3f5 | 2021-12-14 15:30:07 | 67c8209deef43c94316467a6148973a90d6b02f8 | codecov-commenter: # [Codecov](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) Report
> Merging [#430](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) (178f98c) into [development](https://codecov.io/gh/magpylib/magpylib/commit/29fc06b77a86fe5708c527e736008b3a0b6d70ab?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) (29fc06b) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib)
```diff
@@ Coverage Diff @@
## development #430 +/- ##
============================================
Coverage 99.74% 99.74%
============================================
Files 46 46
Lines 4732 4734 +2
============================================
+ Hits 4720 4722 +2
Misses 12 12
```
| [Impacted Files](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib) | Coverage Δ | |
|---|---|---|
| [magpylib/\_src/display/disp\_utility.py](https://codecov.io/gh/magpylib/magpylib/pull/430/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib#diff-bWFncHlsaWIvX3NyYy9kaXNwbGF5L2Rpc3BfdXRpbGl0eS5weQ==) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib). Last update [29fc06b...178f98c](https://codecov.io/gh/magpylib/magpylib/pull/430?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=magpylib).
| diff --git a/magpylib/_src/display/disp_utility.py b/magpylib/_src/display/disp_utility.py
index e45ce47a..dd18e77d 100644
--- a/magpylib/_src/display/disp_utility.py
+++ b/magpylib/_src/display/disp_utility.py
@@ -31,15 +31,22 @@ def place_and_orient_model3d(
return {**model_dict, xyz[0]: x, xyz[1]: y, xyz[2]: z, **kwargs}
-def draw_arrow(vec, pos, sign=1, arrow_size=1) -> Tuple:
+def draw_arrowed_line(vec, pos, sign=1, arrow_size=1) -> Tuple:
"""
Provides x,y,z coordinates of an arrow drawn in the x-y-plane (z=0), showing up the y-axis and
centered in x,y,z=(0,0,0). The arrow vertices are then turned in the direction of `vec` and
moved to position `pos`.
"""
+ norm = np.linalg.norm(vec)
+ nvec = np.array(vec) / norm
+ yaxis = np.array([0, 1, 0])
+ cross = np.cross(nvec, yaxis)
+ dot = np.dot(nvec, yaxis)
+ n = np.linalg.norm(cross)
+ if dot==-1:
+ sign *= -1
hy = sign * 0.1 * arrow_size
hx = 0.06 * arrow_size
- norm = np.linalg.norm(vec)
arrow = (
np.array(
[
@@ -54,11 +61,6 @@ def draw_arrow(vec, pos, sign=1, arrow_size=1) -> Tuple:
)
* norm
)
- nvec = np.array(vec) / norm
- yaxis = np.array([0, 1, 0])
- cross = np.cross(nvec, yaxis)
- dot = np.dot(nvec, yaxis)
- n = np.linalg.norm(cross)
if n != 0:
t = np.arccos(dot)
R = RotScipy.from_rotvec(-t * cross / n)
@@ -73,7 +75,7 @@ def draw_arrow_from_vertices(vertices, current, arrow_size):
positions = vertices[:-1] + vectors / 2
vertices = np.concatenate(
[
- draw_arrow(vec, pos, np.sign(current), arrow_size=arrow_size)
+ draw_arrowed_line(vec, pos, np.sign(current), arrow_size=arrow_size)
for vec, pos in zip(vectors, positions)
],
axis=1,
| Wrong direction of Line currents
**Describe the bug**
Line currents seem to show wrong directions in some situations
**To Reproduce**
```python
import magpylib as magpy
import numpy as np
current = 10
vert1=np.array([
[-500,-500,-500],
[-500,500,-500],
[-500,500,500],
[-500,-500,500],
[-500,-500,-500],
])
vert2 = vert1 + np.array((1000,0,0))
l1 = magpy.current.Line(current=current,vertices=vert1)
l2 = magpy.current.Line(current=current,vertices=vert2)
c = magpy.Collection(l1, l2)
c.display(backend='matplotlib')
```
**Expected behavior**
All arrows should flow in the same direction
**Screenshots**

**Additional context**
current development branch 8c3050d0fd0ef9111b237bd543bcc8991db9d3f5 | magpylib/magpylib | diff --git a/tests/test_display_utility.py b/tests/test_display_utility.py
new file mode 100644
index 00000000..214686dc
--- /dev/null
+++ b/tests/test_display_utility.py
@@ -0,0 +1,28 @@
+import numpy as np
+from magpylib._src.display.disp_utility import draw_arrow_from_vertices
+
+def test_draw_arrow_from_vertices():
+ """tests also the edge case when a vertex is in -y direction"""
+ vertices = np.array([
+ [-1., 1., 1.],
+ [-1., -1., 1.],
+ [-1., -1., -1.],
+ [-1., 1., -1.],
+ [-1., 1., 1.]
+ ])
+ result = draw_arrow_from_vertices(vertices, current=1, arrow_size=1)
+ expected = np.array([
+ [-1. , -1. , -1.12, -1. , -0.88, -1. , -1. , -1. , -1. ,
+ -1.12, -1. , -0.88, -1. , -1. , -1. , -1. , -1.12, -1. ,
+ -0.88, -1. , -1. , -1. , -1. , -1.12, -1. , -0.88, -1. ,
+ -1. ],
+ [-1. , 0. , 0.2 , 0. , 0.2 , 0. , 1. , -1. , -1. ,
+ -1. , -1. , -1. , -1. , -1. , -1. , 0. , -0.2 , 0. ,
+ -0.2 , 0. , 1. , 1. , 1. , 1. , 1. , 1. , 1. ,
+ 1. ],
+ [ 1. , 1. , 1. , 1. , 1. , 1. , 1. , 1. , 0. ,
+ 0.2 , 0. , 0.2 , 0. , -1. , -1. , -1. , -1. , -1. ,
+ -1. , -1. , -1. , -1. , 0. , -0.2 , 0. , -0.2 , 0. ,
+ 1. ]
+ ])
+ assert np.allclose(result, expected), 'draw arrow from vertices failed'
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_git_commit_hash",
"has_media"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 1
},
"num_modified_files": 1
} | 3.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"codecov",
"pylint"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"docs/requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
astroid==3.3.9
babel==2.17.0
certifi==2025.1.31
charset-normalizer==3.4.1
codecov==2.1.13
commonmark==0.9.1
contourpy==1.3.0
coverage==7.8.0
cycler==0.12.1
dill==0.3.9
docutils==0.17.1
exceptiongroup==1.2.2
fonttools==4.56.0
idna==3.10
imagesize==1.4.1
importlib_resources==6.5.2
iniconfig==2.1.0
isort==6.0.1
Jinja2==3.1.6
kiwisolver==1.4.7
-e git+https://github.com/magpylib/magpylib.git@8c3050d0fd0ef9111b237bd543bcc8991db9d3f5#egg=magpylib
MarkupSafe==3.0.2
matplotlib==3.9.4
mccabe==0.7.0
numpy==2.0.2
packaging==24.2
pillow==11.1.0
platformdirs==4.3.7
pluggy==1.5.0
Pygments==2.19.1
pylint==3.3.6
pyparsing==3.2.3
pytest==8.3.5
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
recommonmark==0.7.1
requests==2.32.3
scipy==1.13.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==4.2.0
sphinx-rtd-theme==1.3.0
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tomli==2.2.1
tomlkit==0.13.2
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0
| name: magpylib
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- astroid==3.3.9
- babel==2.17.0
- certifi==2025.1.31
- charset-normalizer==3.4.1
- codecov==2.1.13
- commonmark==0.9.1
- contourpy==1.3.0
- coverage==7.8.0
- cycler==0.12.1
- dill==0.3.9
- docutils==0.17.1
- exceptiongroup==1.2.2
- fonttools==4.56.0
- idna==3.10
- imagesize==1.4.1
- importlib-resources==6.5.2
- iniconfig==2.1.0
- isort==6.0.1
- jinja2==3.1.6
- kiwisolver==1.4.7
- markupsafe==3.0.2
- matplotlib==3.9.4
- mccabe==0.7.0
- numpy==2.0.2
- packaging==24.2
- pillow==11.1.0
- platformdirs==4.3.7
- pluggy==1.5.0
- pygments==2.19.1
- pylint==3.3.6
- pyparsing==3.2.3
- pytest==8.3.5
- pytest-cov==6.0.0
- python-dateutil==2.9.0.post0
- recommonmark==0.7.1
- requests==2.32.3
- scipy==1.13.1
- six==1.17.0
- snowballstemmer==2.2.0
- sphinx==4.2.0
- sphinx-rtd-theme==1.3.0
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jquery==4.1
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- tomli==2.2.1
- tomlkit==0.13.2
- typing-extensions==4.13.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/magpylib
| [
"tests/test_display_utility.py::test_draw_arrow_from_vertices"
] | [] | [] | [] | BSD 2-Clause "Simplified" License | 11,815 | 607 | [
"magpylib/_src/display/disp_utility.py"
] |
nilearn__nilearn-3098 | d43706724a72df089080f62d9f1d9c319fa391b7 | 2021-12-15 12:34:11 | f40ecbae9e546987e517f8e27208cc3a9ea445d1 | github-actions[bot]: 👋 @NicolasGensollen Thanks for creating a PR!
Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.
Please make sure it is compliant with our [contributing guidelines](https://nilearn.github.io/development.html#contribution-guidelines). In particular, be sure it checks the boxes listed below.
- [ ] PR has an interpretable title.
- [ ] PR links to Github issue with mention "Closes #XXXX"
- [ ] Code is PEP8-compliant.
- [ ] (Bug fixes) There is at least one test that would fail under the original bug conditions.
- [ ] (New features) There is at least one unit test per new function / class.
- [ ] (New features) The new feature is demoed in at least one relevant example.
We will review it as quick as possible, feel free to ping us with questions if needed.
codecov[bot]: # [Codecov](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn) Report
> Merging [#3098](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn) (6530172) into [main](https://codecov.io/gh/nilearn/nilearn/commit/18ab12f78033059ed4bfb878449b0d54ce1fa243?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn) (18ab12f) will **decrease** coverage by `24.28%`.
> The diff coverage is `37.50%`.
[](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn)
```diff
@@ Coverage Diff @@
## main #3098 +/- ##
===========================================
- Coverage 90.21% 65.93% -24.29%
===========================================
Files 112 112
Lines 14456 14415 -41
Branches 2961 2893 -68
===========================================
- Hits 13041 9504 -3537
- Misses 843 4466 +3623
+ Partials 572 445 -127
```
| [Impacted Files](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn) | Coverage Δ | |
|---|---|---|
| [nilearn/datasets/atlas.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9kYXRhc2V0cy9hdGxhcy5weQ==) | `90.61% <37.50%> (-2.20%)` | :arrow_down: |
| [nilearn/reporting/utils.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9yZXBvcnRpbmcvdXRpbHMucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [nilearn/reporting/\_\_init\_\_.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9yZXBvcnRpbmcvX19pbml0X18ucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [nilearn/plotting/edge\_detect.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9lZGdlX2RldGVjdC5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [nilearn/plotting/html\_surface.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9odG1sX3N1cmZhY2UucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [nilearn/plotting/html\_document.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9odG1sX2RvY3VtZW50LnB5) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [nilearn/plotting/displays/\_\_init\_\_.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9kaXNwbGF5cy9fX2luaXRfXy5weQ==) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [nilearn/plotting/displays/\_projectors.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9kaXNwbGF5cy9fcHJvamVjdG9ycy5weQ==) | `0.00% <0.00%> (-98.24%)` | :arrow_down: |
| [nilearn/plotting/html\_connectome.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9odG1sX2Nvbm5lY3RvbWUucHk=) | `0.00% <0.00%> (-97.85%)` | :arrow_down: |
| [nilearn/plotting/js\_plotting\_utils.py](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn#diff-bmlsZWFybi9wbG90dGluZy9qc19wbG90dGluZ191dGlscy5weQ==) | `0.00% <0.00%> (-97.71%)` | :arrow_down: |
| ... and [36 more](https://codecov.io/gh/nilearn/nilearn/pull/3098/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn) | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn). Last update [18ab12f...6530172](https://codecov.io/gh/nilearn/nilearn/pull/3098?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=nilearn).
NicolasGensollen: @ymzayek do you think you could review this PR if you have the time?
This is the last one in the `0.9.1` milestone and I'd like to have another approval before merging.
Thanks!
ymzayek: @NicolasGensollen sure I will have a look in about an hour or so and will get back to you asap
NicolasGensollen: @ymzayek No worries, there is no rush ! ;) | diff --git a/nilearn/datasets/atlas.py b/nilearn/datasets/atlas.py
index 049992801..2429f7111 100644
--- a/nilearn/datasets/atlas.py
+++ b/nilearn/datasets/atlas.py
@@ -1093,32 +1093,43 @@ def fetch_atlas_aal(version='SPM12', data_dir=None, url=None, resume=True,
'Please choose one among %s.' %
(version, str(versions)))
- if url is None:
- baseurl = "http://www.gin.cnrs.fr/AAL_files/aal_for_%s.tar.gz"
- url = baseurl % version
- opts = {'uncompress': True}
-
dataset_name = "aal_" + version
- # keys and basenames would need to be handled for each spm_version
- # for now spm_version 12 is hardcoded.
- basenames = ("AAL.nii", "AAL.xml")
- filenames = [(os.path.join('aal', 'atlas', f), url, opts)
- for f in basenames]
+ opts = {'uncompress': True}
- data_dir = _get_dataset_dir(dataset_name, data_dir=data_dir,
- verbose=verbose)
- atlas_img, labels_file = _fetch_files(data_dir, filenames, resume=resume,
- verbose=verbose)
+ if url is None:
+ if version == 'SPM12':
+ url = "http://www.gin.cnrs.fr/AAL_files/aal_for_SPM12.tar.gz"
+ basenames = ("AAL.nii", "AAL.xml")
+ filenames = [(os.path.join('aal', 'atlas', f), url, opts)
+ for f in basenames]
+ else:
+ url = f"http://www.gin.cnrs.fr/wp-content/uploads/aal_for_{version}.zip" # noqa
+ basenames = ("ROI_MNI_V4.nii", "ROI_MNI_V4.txt")
+ filenames = [(os.path.join(f'aal_for_{version}', f), url, opts)
+ for f in basenames]
- fdescr = _get_dataset_descr(dataset_name)
- # We return the labels contained in the xml file as a dictionary
- xml_tree = xml.etree.ElementTree.parse(labels_file)
- root = xml_tree.getroot()
+ data_dir = _get_dataset_dir(
+ dataset_name, data_dir=data_dir, verbose=verbose
+ )
+ atlas_img, labels_file = _fetch_files(
+ data_dir, filenames, resume=resume, verbose=verbose
+ )
+ fdescr = _get_dataset_descr("aal_SPM12")
labels = []
indices = []
- for label in root.iter('label'):
- indices.append(label.find('index').text)
- labels.append(label.find('name').text)
+ if version == 'SPM12':
+ xml_tree = xml.etree.ElementTree.parse(labels_file)
+ root = xml_tree.getroot()
+ for label in root.iter('label'):
+ indices.append(label.find('index').text)
+ labels.append(label.find('name').text)
+ else:
+ with open(labels_file, "r") as fp:
+ for line in fp.readlines():
+ _, label, index = line.strip().split('\t')
+ indices.append(index)
+ labels.append(label)
+ fdescr = fdescr.replace("SPM 12", version)
params = {'description': fdescr, 'maps': atlas_img,
'labels': labels, 'indices': indices}
| `fetch_atlas_aal` download error with `SPM5` and `SPM8`
With Nilearn 0.8.2.dev.
I haven't investigated further than trying all possible versions with cleaned data cache, so I might have missed something.
It seems to work for `SPM12` (the default), but fails on my machine with all other versions.
Code to reproduce:
```python
from nilearn import datasets
b = datasets.fetch_atlas_aal(version='SPM5') # 'SPM8' gives same error
```
```
OSError Traceback (most recent call last)
<ipython-input-97-6fd2a3e7006b> in <module>
----> 1 b = datasets.fetch_atlas_aal(version='SPM5')
~/GitRepos/nilearn-fork/nilearn/datasets/atlas.py in fetch_atlas_aal(version, data_dir, url, resume, verbose)
938 see :footcite:`AAL_atlas`,
939 and :footcite:`TZOURIOMAZOYER2002273`.
--> 940
941 Parameters
942 ----------
~/GitRepos/nilearn-fork/nilearn/datasets/utils.py in _fetch_files(data_dir, files, resume, verbose, session)
706 with requests.Session() as session:
707 session.mount("ftp:", _NaiveFTPAdapter())
--> 708 return _fetch_files(
709 data_dir, files, resume=resume,
710 verbose=verbose, session=session)
~/GitRepos/nilearn-fork/nilearn/datasets/utils.py in _fetch_files(data_dir, files, resume, verbose, session)
784 if os.path.exists(temp_dir):
785 shutil.rmtree(temp_dir)
--> 786 raise IOError('Fetching aborted: ' + abort)
787 files_.append(target_file)
788 # If needed, move files from temps directory to final directory.
OSError: Fetching aborted: Not a gzipped file (b'\x1f\x9d')
> /home/nicolas/GitRepos/nilearn-fork/nilearn/datasets/utils.py(786)_fetch_files()
784 if os.path.exists(temp_dir):
785 shutil.rmtree(temp_dir)
--> 786 raise IOError('Fetching aborted: ' + abort)
787 files_.append(target_file)
788 # If needed, move files from temps directory to final directory.
``` | nilearn/nilearn | diff --git a/doc/changes/latest.rst b/doc/changes/latest.rst
index 33df8ce45..7ca065176 100644
--- a/doc/changes/latest.rst
+++ b/doc/changes/latest.rst
@@ -17,6 +17,7 @@ Fixes
- Fix function :func:`~datasets.fetch_abide_pcp` which was returning empty phenotypes and ``func_preproc`` after release ``0.9.0`` due to supporting pandas dataframes in fetchers (:gh:`3174` by `Nicolas Gensollen`_).
- Fix function :func:`~datasets.fetch_atlas_harvard_oxford` and :func:`~datasets.fetch_atlas_juelich` which were returning the image in the `filename` attribute instead of the path to the image (:gh:`3179` by `Raphael Meudec`_).
- Fix colorbars in :func:`~plotting.plot_stat_map`, :func:`~plotting.plot_glass_brain` and :func:`~plotting.plot_surf_stat_map` which could extend beyond the figure for users with newest matplotlib version (>=3.5.1) (:gh:`3188` by `Raphael Meudec`_)
+- Function :func:`~datasets.fetch_atlas_aal` now works with all supported versions of ``SPM`` (5, 8, and 12). (:gh:`3098` by `Nicolas Gensollen`_).
Enhancements
------------
diff --git a/nilearn/datasets/tests/test_atlas.py b/nilearn/datasets/tests/test_atlas.py
index a53396210..8d2db0dd3 100644
--- a/nilearn/datasets/tests/test_atlas.py
+++ b/nilearn/datasets/tests/test_atlas.py
@@ -435,28 +435,49 @@ def test_fetch_atlas_difumo(tmp_path, request_mocker):
dimension=128, resolution_mm=3.14)
-def test_fetch_atlas_aal(tmp_path, request_mocker):
- metadata = (b"<?xml version='1.0' encoding='us-ascii'?>"
- b"<metadata></metadata>")
- archive_root = Path("aal", "atlas")
[email protected]
+def aal_archive_root(version):
+ if version == 'SPM12':
+ return Path("aal", "atlas")
+ else:
+ return Path(f"aal_for_{version}")
+
+
[email protected]("version,archive_format,url_key",
+ [('SPM5', 'zip', 'uploads'),
+ ('SPM8', 'zip', 'uploads'),
+ ('SPM12', 'gztar', 'AAL_files')])
+def test_fetch_atlas_aal(version, archive_format, url_key, aal_archive_root,
+ tmp_path, request_mocker):
+ metadata = "A\tB\tC\n"
+ if version == 'SPM12':
+ metadata = (b"<?xml version='1.0' encoding='us-ascii'?>"
+ b"<metadata><label><index>1</index>"
+ b"<name>A</name></label></metadata>")
+ label_file = "AAL.xml" if version == 'SPM12' else "ROI_MNI_V4.txt"
+ atlas_file = "AAL.nii" if version == 'SPM12' else "ROI_MNI_V4.nii"
aal_data = dict_to_archive(
- {archive_root / "AAL.xml": metadata, archive_root / "AAL.nii": ""})
-
- request_mocker.url_mapping["*AAL_files*"] = aal_data
- dataset = atlas.fetch_atlas_aal(data_dir=tmp_path, verbose=0)
+ {aal_archive_root / label_file: metadata,
+ aal_archive_root / atlas_file: ""},
+ archive_format=archive_format
+ )
+ request_mocker.url_mapping[f"*{url_key}*"] = aal_data
+ dataset = atlas.fetch_atlas_aal(
+ version=version, data_dir=tmp_path, verbose=0
+ )
assert isinstance(dataset.maps, str)
assert isinstance(dataset.labels, list)
assert isinstance(dataset.indices, list)
assert request_mocker.url_count == 1
+ assert dataset.description != ''
- with pytest.raises(ValueError,
- match='The version of AAL requested "FLS33"'
- ):
- atlas.fetch_atlas_aal(version="FLS33",
- data_dir=tmp_path,
- verbose=0)
- assert dataset.description != ''
+def test_fetch_atlas_aal_version_error(tmp_path, request_mocker):
+ with pytest.raises(ValueError,
+ match='The version of AAL requested "FLS33"'):
+ atlas.fetch_atlas_aal(
+ version="FLS33", data_dir=tmp_path, verbose=0
+ )
def test_fetch_atlas_basc_multiscale_2015(tmp_path, request_mocker):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 0.9 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
babel==2.17.0
certifi==2025.1.31
charset-normalizer==3.4.1
codecov==2.1.13
contourpy==1.3.0
coverage==7.8.0
cycler==0.12.1
Cython==3.0.12
docutils==0.21.2
exceptiongroup==1.2.2
flake8==7.2.0
fonttools==4.56.0
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
importlib_resources==6.5.2
iniconfig==2.1.0
intel-cmplr-lib-ur==2025.1.0
intel-openmp==2025.1.0
Jinja2==3.1.6
joblib==1.4.2
kaleido==0.2.1
kiwisolver==1.4.7
latexcodec==3.0.0
lxml==5.3.1
MarkupSafe==3.0.2
matplotlib==3.9.4
mccabe==0.7.0
memory-profiler==0.61.0
mkl==2025.1.0
narwhals==1.32.0
nibabel==5.3.2
-e git+https://github.com/nilearn/nilearn.git@d43706724a72df089080f62d9f1d9c319fa391b7#egg=nilearn
numpy==2.0.2
numpydoc==1.8.0
packaging==24.2
pandas==2.2.3
pillow==11.1.0
plotly==6.0.1
pluggy==1.5.0
psutil==7.0.0
pybtex==0.24.0
pybtex-docutils==1.0.3
pycodestyle==2.13.0
pyflakes==3.3.1
Pygments==2.19.1
pyparsing==3.2.3
pytest==8.3.5
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
requests==2.32.3
scikit-learn==1.6.1
scipy==1.13.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-copybutton==0.5.2
sphinx-gallery==0.19.0
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-bibtex==2.6.3
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
sphinxext-opengraph==0.9.1
tabulate==0.9.0
tbb==2022.1.0
tcmlib==1.3.0
threadpoolctl==3.6.0
tomli==2.2.1
typing_extensions==4.13.0
tzdata==2025.2
umf==0.10.0
urllib3==2.3.0
zipp==3.21.0
| name: nilearn
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- certifi==2025.1.31
- charset-normalizer==3.4.1
- codecov==2.1.13
- contourpy==1.3.0
- coverage==7.8.0
- cycler==0.12.1
- cython==3.0.12
- docutils==0.21.2
- exceptiongroup==1.2.2
- flake8==7.2.0
- fonttools==4.56.0
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- importlib-resources==6.5.2
- iniconfig==2.1.0
- intel-cmplr-lib-ur==2025.1.0
- intel-openmp==2025.1.0
- jinja2==3.1.6
- joblib==1.4.2
- kaleido==0.2.1
- kiwisolver==1.4.7
- latexcodec==3.0.0
- lxml==5.3.1
- markupsafe==3.0.2
- matplotlib==3.9.4
- mccabe==0.7.0
- memory-profiler==0.61.0
- mkl==2025.1.0
- narwhals==1.32.0
- nibabel==5.3.2
- numpy==2.0.2
- numpydoc==1.8.0
- packaging==24.2
- pandas==2.2.3
- pillow==11.1.0
- plotly==6.0.1
- pluggy==1.5.0
- psutil==7.0.0
- pybtex==0.24.0
- pybtex-docutils==1.0.3
- pycodestyle==2.13.0
- pyflakes==3.3.1
- pygments==2.19.1
- pyparsing==3.2.3
- pytest==8.3.5
- pytest-cov==6.0.0
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pyyaml==6.0.2
- requests==2.32.3
- scikit-learn==1.6.1
- scipy==1.13.1
- six==1.17.0
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinx-copybutton==0.5.2
- sphinx-gallery==0.19.0
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-bibtex==2.6.3
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- sphinxext-opengraph==0.9.1
- tabulate==0.9.0
- tbb==2022.1.0
- tcmlib==1.3.0
- threadpoolctl==3.6.0
- tomli==2.2.1
- typing-extensions==4.13.0
- tzdata==2025.2
- umf==0.10.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/nilearn
| [
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_aal[SPM5-zip-uploads]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_aal[SPM8-zip-uploads]"
] | [
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl[HarvardOxford--Cortical-cort-prob-1mm-False-False]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl[HarvardOxford--Subcortical-sub-maxprob-thr0-1mm-False-True]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl[HarvardOxford--Cortical-Lateralized-cortl-maxprob-thr0-1mm-True-True]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl[Juelich--prob-1mm-False-False]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl[Juelich--maxprob-thr0-1mm-False-False]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl[Juelich--maxprob-thr0-1mm-False-True]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_destrieux_2009[True]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_destrieux_2009[False]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_talairach",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_pauli_2017",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_schaefer_2018"
] | [
"nilearn/datasets/tests/test_atlas.py::test_get_dataset_dir",
"nilearn/datasets/tests/test_atlas.py::test_downloader",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_source",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl_errors[HarvardOxford-cortl-prob-1mm]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_fsl_errors[Juelich-prob-1mm]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_craddock_2012",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_smith_2009",
"nilearn/datasets/tests/test_atlas.py::test_fetch_coords_power_2011",
"nilearn/datasets/tests/test_atlas.py::test_fetch_coords_seitzman_2018",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_msdl",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_yeo_2011",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_difumo",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_aal[SPM12-gztar-AAL_files]",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_aal_version_error",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_basc_multiscale_2015",
"nilearn/datasets/tests/test_atlas.py::test_fetch_coords_dosenbach_2010",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_allen_2011",
"nilearn/datasets/tests/test_atlas.py::test_fetch_atlas_surf_destrieux"
] | [] | New BSD License | 11,817 | 827 | [
"nilearn/datasets/atlas.py"
] |
celery__py-amqp-379 | be6b5ededa5654ca43cea67927667456e32523a3 | 2021-12-15 18:29:37 | be6b5ededa5654ca43cea67927667456e32523a3 | michael-lazar: working on fixing that test now | diff --git a/amqp/transport.py b/amqp/transport.py
index 177fb22..b87f9fe 100644
--- a/amqp/transport.py
+++ b/amqp/transport.py
@@ -272,7 +272,11 @@ class _AbstractTransport:
def close(self):
if self.sock is not None:
- self._shutdown_transport()
+ try:
+ self._shutdown_transport()
+ except OSError:
+ pass
+
# Call shutdown first to make sure that pending messages
# reach the AMQP broker if the program exits after
# calling this method.
@@ -280,7 +284,11 @@ class _AbstractTransport:
self.sock.shutdown(socket.SHUT_RDWR)
except OSError:
pass
- self.sock.close()
+
+ try:
+ self.sock.close()
+ except OSError:
+ pass
self.sock = None
self.connected = False
| 5.0.7 SSL connection problem
After upgrade to the 5.0.7 celery workers are unable to connect to RabbitMQ (3.9.11) using SSL. Worker dies immediately after start and following exceptions are logged. Reverting to 5.0.6 solves the connection problem.
<pre>2021-12-15 07:31:14 [11] CRITICAL Unrecoverable error: OperationalError('[Errno 32] Broken pipe') (/usr/local/lib/python3.9/site-packages/celery/worker/worker.py:start)
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/kombu/connection.py", line 524, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/kombu/messaging.py", line 193, in _publish
[maybe_declare(entity) for entity in declare]
File "/usr/local/lib/python3.9/site-packages/kombu/messaging.py", line 193, in <listcomp>
[maybe_declare(entity) for entity in declare]
File "/usr/local/lib/python3.9/site-packages/kombu/messaging.py", line 99, in maybe_declare
return maybe_declare(entity, self.channel, retry, **retry_policy)
File "/usr/local/lib/python3.9/site-packages/kombu/common.py", line 110, in maybe_declare
return _maybe_declare(entity, channel)
File "/usr/local/lib/python3.9/site-packages/kombu/common.py", line 150, in _maybe_declare
entity.declare(channel=channel)
File "/usr/local/lib/python3.9/site-packages/kombu/entity.py", line 180, in declare
return (channel or self.channel).exchange_declare(
File "/usr/local/lib/python3.9/site-packages/amqp/channel.py", line 608, in exchange_declare
self.send_method(
File "/usr/local/lib/python3.9/site-packages/amqp/abstract_channel.py", line 57, in send_method
conn.frame_writer(1, self.channel_id, sig, args, content)
File "/usr/local/lib/python3.9/site-packages/amqp/method_framing.py", line 183, in write_frame
write(view[:offset])
File "/usr/local/lib/python3.9/site-packages/amqp/transport.py", line 355, in write
self._write(s)
File "/usr/local/lib/python3.9/site-packages/amqp/transport.py", line 599, in _write
n = write(s)
File "/usr/local/lib/python3.9/ssl.py", line 1118, in write
return self._sslobj.write(data)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/kombu/connection.py", line 447, in _reraise_as_library_errors
yield
File "/usr/local/lib/python3.9/site-packages/kombu/connection.py", line 536, in _ensured
self.collect()
File "/usr/local/lib/python3.9/site-packages/kombu/connection.py", line 366, in collect
gc_transport(self._connection)
File "/usr/local/lib/python3.9/site-packages/kombu/transport/pyamqp.py", line 173, in _collect
connection.collect()
File "/usr/local/lib/python3.9/site-packages/amqp/connection.py", line 470, in collect
self._transport.close()
File "/usr/local/lib/python3.9/site-packages/amqp/transport.py", line 275, in close
self._shutdown_transport()
File "/usr/local/lib/python3.9/site-packages/amqp/transport.py", line 564, in _shutdown_transport
self.sock = self.sock.unwrap()
File "/usr/local/lib/python3.9/ssl.py", line 1285, in unwrap
s = self._sslobj.shutdown()
BrokenPipeError: [Errno 32] Broken pipe
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/celery/worker/worker.py", line 203, in start
self.blueprint.start(self)
File "/usr/local/lib/python3.9/site-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/usr/local/lib/python3.9/site-packages/celery/bootsteps.py", line 365, in start
return self.obj.start()
File "/usr/local/lib/python3.9/site-packages/celery/worker/consumer/consumer.py", line 326, in start
blueprint.start(self)
File "/usr/local/lib/python3.9/site-packages/celery/bootsteps.py", line 116, in start
step.start(parent)
File "/usr/local/lib/python3.9/site-packages/celery/worker/consumer/mingle.py", line 37, in start
self.sync(c)
File "/usr/local/lib/python3.9/site-packages/celery/worker/consumer/mingle.py", line 41, in sync
replies = self.send_hello(c)
File "/usr/local/lib/python3.9/site-packages/celery/worker/consumer/mingle.py", line 54, in send_hello
replies = inspect.hello(c.hostname, our_revoked._data) or {}
File "/usr/local/lib/python3.9/site-packages/celery/app/control.py", line 389, in hello
return self._request('hello', from_node=from_node, revoked=revoked)
File "/usr/local/lib/python3.9/site-packages/celery/app/control.py", line 106, in _request
return self._prepare(self.app.control.broadcast(
File "/usr/local/lib/python3.9/site-packages/celery/app/control.py", line 741, in broadcast
return self.mailbox(conn)._broadcast(
File "/usr/local/lib/python3.9/site-packages/kombu/pidbox.py", line 335, in _broadcast
self._publish(command, arguments, destination=destination,
File "/usr/local/lib/python3.9/site-packages/kombu/pidbox.py", line 303, in _publish
producer.publish(
File "/usr/local/lib/python3.9/site-packages/kombu/messaging.py", line 177, in publish
return _publish(
File "/usr/local/lib/python3.9/site-packages/kombu/connection.py", line 557, in _ensured
errback and errback(exc, 0)
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/kombu/connection.py", line 451, in _reraise_as_library_errors
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: [Errno 32] Broken pipe
</pre> | celery/py-amqp | diff --git a/t/unit/test_transport.py b/t/unit/test_transport.py
index b111497..348b6c2 100644
--- a/t/unit/test_transport.py
+++ b/t/unit/test_transport.py
@@ -587,6 +587,16 @@ class test_AbstractTransport_connect:
self.t.connect()
assert self.t.connected and self.t.sock is sock_obj
+ def test_close__close_error(self):
+ # sock.close() can raise an error if the fd is invalid
+ # make sure the socket is properly deallocated
+ sock = self.t.sock = Mock()
+ sock.unwrap.return_value = sock
+ sock.close.side_effect = OSError
+ self.t.close()
+ sock.close.assert_called_with()
+ assert self.t.sock is None and self.t.connected is False
+
class test_SSLTransport:
class Transport(transport.SSLTransport):
@@ -835,6 +845,14 @@ class test_SSLTransport:
self.t._shutdown_transport()
assert self.t.sock is sock.unwrap()
+ def test_close__unwrap_error(self):
+ # sock.unwrap() can raise an error if the was a connection failure
+ # make sure the socket is properly closed and deallocated
+ sock = self.t.sock = Mock()
+ sock.unwrap.side_effect = OSError
+ self.t.close()
+ assert self.t.sock is None
+
def test_read_EOF(self):
self.t.sock = Mock(name='SSLSocket')
self.t.connected = True
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 5.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"flake8",
"flakeplus",
"pydocstyle"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/default.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/celery/py-amqp.git@be6b5ededa5654ca43cea67927667456e32523a3#egg=amqp
exceptiongroup==1.2.2
flake8==7.2.0
flakeplus==1.1.0
iniconfig==2.1.0
mccabe==0.7.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pydocstyle==6.3.0
pyflakes==3.3.2
pytest==8.3.5
snowballstemmer==2.2.0
tomli==2.2.1
Unipath==1.1
vine==5.0.0
| name: py-amqp
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- exceptiongroup==1.2.2
- flake8==7.2.0
- flakeplus==1.1.0
- iniconfig==2.1.0
- mccabe==0.7.0
- packaging==24.2
- pluggy==1.5.0
- pycodestyle==2.13.0
- pydocstyle==6.3.0
- pyflakes==3.3.2
- pytest==8.3.5
- snowballstemmer==2.2.0
- tomli==2.2.1
- unipath==1.1
- vine==5.0.0
prefix: /opt/conda/envs/py-amqp
| [
"t/unit/test_transport.py::test_AbstractTransport_connect::test_close__close_error",
"t/unit/test_transport.py::test_SSLTransport::test_close__unwrap_error"
] | [] | [
"t/unit/test_transport.py::test_socket_options::test_backward_compatibility_tcp_transport",
"t/unit/test_transport.py::test_socket_options::test_backward_compatibility_SSL_transport",
"t/unit/test_transport.py::test_socket_options::test_use_default_sock_tcp_opts",
"t/unit/test_transport.py::test_socket_options::test_set_single_sock_tcp_opt_tcp_transport",
"t/unit/test_transport.py::test_socket_options::test_set_single_sock_tcp_opt_SSL_transport",
"t/unit/test_transport.py::test_socket_options::test_values_are_set",
"t/unit/test_transport.py::test_socket_options::test_passing_wrong_options",
"t/unit/test_transport.py::test_socket_options::test_passing_wrong_value_options",
"t/unit/test_transport.py::test_socket_options::test_passing_value_as_string",
"t/unit/test_transport.py::test_socket_options::test_passing_tcp_nodelay",
"t/unit/test_transport.py::test_socket_options::test_platform_socket_opts",
"t/unit/test_transport.py::test_socket_options::test_set_sockopt_opts_timeout",
"t/unit/test_transport.py::test_AbstractTransport::test_port",
"t/unit/test_transport.py::test_AbstractTransport::test_read",
"t/unit/test_transport.py::test_AbstractTransport::test_setup_transport",
"t/unit/test_transport.py::test_AbstractTransport::test_shutdown_transport",
"t/unit/test_transport.py::test_AbstractTransport::test_write",
"t/unit/test_transport.py::test_AbstractTransport::test_close",
"t/unit/test_transport.py::test_AbstractTransport::test_close_os_error",
"t/unit/test_transport.py::test_AbstractTransport::test_read_frame__timeout",
"t/unit/test_transport.py::test_AbstractTransport::test_read_frame__SSLError",
"t/unit/test_transport.py::test_AbstractTransport::test_read_frame__EINTR",
"t/unit/test_transport.py::test_AbstractTransport::test_read_frame__EBADF",
"t/unit/test_transport.py::test_AbstractTransport::test_read_frame__simple",
"t/unit/test_transport.py::test_AbstractTransport::test_read_frame__long",
"t/unit/test_transport.py::test_AbstractTransport::test_write__success",
"t/unit/test_transport.py::test_AbstractTransport::test_write__socket_timeout",
"t/unit/test_transport.py::test_AbstractTransport::test_write__EINTR",
"t/unit/test_transport.py::test_AbstractTransport::test_having_timeout_none",
"t/unit/test_transport.py::test_AbstractTransport::test_set_timeout",
"t/unit/test_transport.py::test_AbstractTransport::test_set_timeout_exception_raised",
"t/unit/test_transport.py::test_AbstractTransport::test_set_same_timeout",
"t/unit/test_transport.py::test_AbstractTransport::test_set_timeout_ewouldblock_exc",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_socket_fails",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_socket_initialization_fails",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_multiple_addr_entries_fails",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_multiple_addr_entries_succeed",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_short_curcuit_on_INET_succeed",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_short_curcuit_on_INET_fails",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_getaddrinfo_raises_gaierror",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_getaddrinfo_raises_gaierror_once_recovers",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_survives_not_implemented_set_cloexec",
"t/unit/test_transport.py::test_AbstractTransport_connect::test_connect_already_connected",
"t/unit/test_transport.py::test_SSLTransport::test_repr_disconnected",
"t/unit/test_transport.py::test_SSLTransport::test_repr_connected",
"t/unit/test_transport.py::test_SSLTransport::test_setup_transport",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_context",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_certfile",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_ca_certs",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_ciphers",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_cert_reqs",
"t/unit/test_transport.py::test_SSLTransport::test_wrap_socket_sni_setting_sni_header",
"t/unit/test_transport.py::test_SSLTransport::test_shutdown_transport",
"t/unit/test_transport.py::test_SSLTransport::test_read_EOF",
"t/unit/test_transport.py::test_SSLTransport::test_write_success",
"t/unit/test_transport.py::test_SSLTransport::test_write_socket_closed",
"t/unit/test_transport.py::test_SSLTransport::test_write_ValueError",
"t/unit/test_transport.py::test_SSLTransport::test_read_timeout",
"t/unit/test_transport.py::test_SSLTransport::test_read_SSLError",
"t/unit/test_transport.py::test_TCPTransport::test_repr_disconnected",
"t/unit/test_transport.py::test_TCPTransport::test_repr_connected",
"t/unit/test_transport.py::test_TCPTransport::test_setup_transport",
"t/unit/test_transport.py::test_TCPTransport::test_read_EOF",
"t/unit/test_transport.py::test_TCPTransport::test_read_frame__windowstimeout"
] | [] | BSD License (3 Clause) | 11,820 | 222 | [
"amqp/transport.py"
] |
PMEAL__OpenPNM-2243 | 846dc907049f1a411907be762e7cc013b72429e1 | 2021-12-15 19:13:19 | e4c9f799076c334904088df34b8f04da7802a08b | diff --git a/openpnm/core/_base.py b/openpnm/core/_base.py
index 3fac92c54..3152d64ab 100644
--- a/openpnm/core/_base.py
+++ b/openpnm/core/_base.py
@@ -182,6 +182,11 @@ class Base(dict):
raise Exception('Provided array is wrong length for ' + key)
def __getitem__(self, key):
+ # If the key is a just a numerical value, the kick it directly back
+ # This allows one to do either value='pore.blah' or value=1.0
+ if isinstance(key, (int, float, bool, complex)):
+ return key
+
element, prop = key.split('.', 1)
if key in self.keys():
diff --git a/openpnm/core/_mixins.py b/openpnm/core/_mixins.py
index 83eb8704e..7fde4490d 100644
--- a/openpnm/core/_mixins.py
+++ b/openpnm/core/_mixins.py
@@ -15,6 +15,11 @@ class ParamMixin:
self._params._value = "Values"
def __getitem__(self, key):
+ # If the key is a just a numerical value, the kick it directly back
+ # This allows one to do either value='pore.blah' or value=1.0
+ if isinstance(key, (int, float, bool, complex)):
+ return key
+
if key.startswith('param'):
try:
vals = self._params[key]
diff --git a/openpnm/core/_subdomain.py b/openpnm/core/_subdomain.py
index fd2acc56f..a88362bbc 100644
--- a/openpnm/core/_subdomain.py
+++ b/openpnm/core/_subdomain.py
@@ -19,6 +19,11 @@ class Subdomain(Base, LabelMixin):
"""
def __getitem__(self, key):
+ # If the key is a just a numerical value, the kick it directly back
+ # This allows one to do either value='pore.blah' or value=1.0
+ if isinstance(key, (int, float, bool, complex)):
+ return key
+
element = key.split('.')[0]
# Try to get vals directly first
vals = self.get(key)
diff --git a/openpnm/network/_generic.py b/openpnm/network/_generic.py
index 1232b0e42..767ca840a 100644
--- a/openpnm/network/_generic.py
+++ b/openpnm/network/_generic.py
@@ -121,6 +121,11 @@ class GenericNetwork(ParamMixin, Base, ModelsMixin, LabelMixin):
super().__setitem__(key, value)
def __getitem__(self, key):
+ # If the key is a just a numerical value, the kick it directly back
+ # This allows one to do either value='pore.blah' or value=1.0
+ if isinstance(key, (int, float, bool, complex)):
+ return key
+
element, prop = key.split('.', 1)
# Deal with special keys first
if key.split('.')[-1] == self.name:
diff --git a/openpnm/phases/_generic.py b/openpnm/phases/_generic.py
index d69ef8206..ccf2bee0a 100644
--- a/openpnm/phases/_generic.py
+++ b/openpnm/phases/_generic.py
@@ -48,6 +48,10 @@ class GenericPhase(ParamMixin, Base, ModelsMixin, LabelMixin):
self['pore.pressure'] = 101325.0
def __getitem__(self, key):
+ # If the key is a just a numerical value, the kick it directly back
+ # This allows one to do either value='pore.blah' or value=1.0
+ if isinstance(key, (int, float, bool, complex)):
+ return key
element, prop = key.split('.', 1)
# Deal with special keys first
if prop == '_id':
| Allow passing scalar values as argument to built-in source term models
Something like:
```python
mod = op.models.physics.generic_source_term.standard_kinetics
k, n = 1e-4, 2
phys.add_model(
X="pore.concentration",
propname="pore.rxn",
model=mod, prefactor=k, exponent=n,
regen_mode="deferred"
)
``` | PMEAL/OpenPNM | diff --git a/tests/unit/core/BaseTest.py b/tests/unit/core/BaseTest.py
index c66304e21..482f323d8 100644
--- a/tests/unit/core/BaseTest.py
+++ b/tests/unit/core/BaseTest.py
@@ -699,6 +699,16 @@ class BaseTest:
with pytest.raises(KeyError):
_ = self.geo['pore.blah']
+ def test_getitem_with_numeric_value(self):
+ assert self.geo[5.0] == 5.0
+ assert self.net[44] == 44
+ assert self.phase1[True] == True
+ assert self.phase2[False] == False
+ assert self.phys1[0.1] == 0.1
+ assert self.phys2[4j] == 4j
+ a = op.algorithms.GenericTransport(network=self.net, phase=self.phase1)
+ assert a[0] == 0
+
def test_interpolate_data(self):
self.geo['throat.tester'] = np.linspace(0, 1.0, self.geo.network.Nt)
self.geo['pore.tester'] = np.linspace(0, 1.0, self.geo.network.Np)
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 5
} | 2.8 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.8",
"reqs_path": [
"requirements/pip_requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | asttokens==3.0.0
attr==0.3.2
attrs==25.3.0
auto-all==1.4.1
backcall==0.2.0
chemicals==1.3.3
contourpy==1.1.1
cycler==0.12.1
decorator==5.2.1
docrep==0.3.2
exceptiongroup==1.2.2
executing==2.2.0
flatdict==4.0.1
fluids==1.1.0
fonttools==4.56.0
gitdb==4.0.12
GitPython==3.1.44
h5py==3.11.0
imageio==2.35.1
importlib_metadata==8.5.0
importlib_resources==6.4.5
iniconfig==2.1.0
intel-cmplr-lib-ur==2025.1.0
intel-openmp==2025.1.0
ipython==8.12.3
jedi==0.19.2
json-tricks==3.17.3
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.7
lazy_loader==0.4
llvmlite==0.41.1
matplotlib==3.7.5
matplotlib-inline==0.1.7
mkl==2025.1.0
mpmath==1.3.0
networkx==3.1
numba==0.58.1
numpy==1.24.4
-e git+https://github.com/PMEAL/OpenPNM.git@846dc907049f1a411907be762e7cc013b72429e1#egg=openpnm
packaging==24.2
pandas==2.0.3
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
pillow==10.4.0
pkgutil_resolve_name==1.3.10
pluggy==1.5.0
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
Pygments==2.19.1
pypardiso==0.4.6
pyparsing==3.1.4
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyWavelets==1.4.1
referencing==0.35.1
rpds-py==0.20.1
scikit-image==0.21.0
scipy==1.10.1
six==1.17.0
smmap==5.0.2
stack-data==0.6.3
sympy==1.13.3
tbb==2022.1.0
tcmlib==1.3.0
terminaltables==3.1.10
tifffile==2023.7.10
tomli==2.2.1
tqdm==4.67.1
traitlets==5.14.3
traits==7.0.2
transforms3d==0.4.2
typing_extensions==4.13.0
tzdata==2025.2
umf==0.10.0
wcwidth==0.2.13
zipp==3.20.2
| name: OpenPNM
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=24.2=py38h06a4308_0
- python=3.8.20=he870216_0
- readline=8.2=h5eee18b_0
- setuptools=75.1.0=py38h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.44.0=py38h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- asttokens==3.0.0
- attr==0.3.2
- attrs==25.3.0
- auto-all==1.4.1
- backcall==0.2.0
- chemicals==1.3.3
- contourpy==1.1.1
- cycler==0.12.1
- decorator==5.2.1
- docrep==0.3.2
- exceptiongroup==1.2.2
- executing==2.2.0
- flatdict==4.0.1
- fluids==1.1.0
- fonttools==4.56.0
- gitdb==4.0.12
- gitpython==3.1.44
- h5py==3.11.0
- imageio==2.35.1
- importlib-metadata==8.5.0
- importlib-resources==6.4.5
- iniconfig==2.1.0
- intel-cmplr-lib-ur==2025.1.0
- intel-openmp==2025.1.0
- ipython==8.12.3
- jedi==0.19.2
- json-tricks==3.17.3
- jsonschema==4.23.0
- jsonschema-specifications==2023.12.1
- kiwisolver==1.4.7
- lazy-loader==0.4
- llvmlite==0.41.1
- matplotlib==3.7.5
- matplotlib-inline==0.1.7
- mkl==2025.1.0
- mpmath==1.3.0
- networkx==3.1
- numba==0.58.1
- numpy==1.24.4
- packaging==24.2
- pandas==2.0.3
- parso==0.8.4
- pexpect==4.9.0
- pickleshare==0.7.5
- pillow==10.4.0
- pkgutil-resolve-name==1.3.10
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pygments==2.19.1
- pypardiso==0.4.6
- pyparsing==3.1.4
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pywavelets==1.4.1
- referencing==0.35.1
- rpds-py==0.20.1
- scikit-image==0.21.0
- scipy==1.10.1
- six==1.17.0
- smmap==5.0.2
- stack-data==0.6.3
- sympy==1.13.3
- tbb==2022.1.0
- tcmlib==1.3.0
- terminaltables==3.1.10
- tifffile==2023.7.10
- tomli==2.2.1
- tqdm==4.67.1
- traitlets==5.14.3
- traits==7.0.2
- transforms3d==0.4.2
- typing-extensions==4.13.0
- tzdata==2025.2
- umf==0.10.0
- wcwidth==0.2.13
- zipp==3.20.2
prefix: /opt/conda/envs/OpenPNM
| [
"tests/unit/core/BaseTest.py::BaseTest::test_getitem_with_numeric_value"
] | [
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_two_geometries"
] | [
"tests/unit/core/BaseTest.py::BaseTest::test_clear_model_data",
"tests/unit/core/BaseTest.py::BaseTest::test_clear_model_data_when_model_returns_dictionary",
"tests/unit/core/BaseTest.py::BaseTest::test_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_one_label",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_two_labels_or",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_two_labels_xnor",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_two_labels_not_xor",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_two_labels_nor",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_two_labels_nand",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_bad_mode",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_empty_list",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_asmask",
"tests/unit/core/BaseTest.py::BaseTest::test_pores_and_throats_with_to_global",
"tests/unit/core/BaseTest.py::BaseTest::test_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_throats_asmask",
"tests/unit/core/BaseTest.py::BaseTest::test_throats_one_label",
"tests/unit/core/BaseTest.py::BaseTest::test_throats_two_labels_or",
"tests/unit/core/BaseTest.py::BaseTest::test_throats_two_labels_xnor",
"tests/unit/core/BaseTest.py::BaseTest::test_throats_two_labels_xor",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_no_label",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_one_label_as_string",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_one_label_as_list",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_two_labels_or",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_two_labels_xnor",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_two_labels_xnor_empty",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_two_labels_xor",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_two_labels_nor",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_empty_locations",
"tests/unit/core/BaseTest.py::BaseTest::test_filter_by_label_pores_and_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_tomask_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_tomask_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_tomask_pores_and_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_toindices_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_toindices_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_toindices_float_mask",
"tests/unit/core/BaseTest.py::BaseTest::test_toindices_invalid_mask",
"tests/unit/core/BaseTest.py::BaseTest::test_toindices_wrong_mask",
"tests/unit/core/BaseTest.py::BaseTest::test_count",
"tests/unit/core/BaseTest.py::BaseTest::test_num_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_num_pores_one_label",
"tests/unit/core/BaseTest.py::BaseTest::test_num_pores_two_labels_or",
"tests/unit/core/BaseTest.py::BaseTest::test_num_pores_two_labels_xnor",
"tests/unit/core/BaseTest.py::BaseTest::test_num_pores_two_labels_xor",
"tests/unit/core/BaseTest.py::BaseTest::test_num_pores_two_labels_nor",
"tests/unit/core/BaseTest.py::BaseTest::test_num_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_num_throats_one_label",
"tests/unit/core/BaseTest.py::BaseTest::test_num_throats_two_labels_or",
"tests/unit/core/BaseTest.py::BaseTest::test_num_throats_two_labels_xnor",
"tests/unit/core/BaseTest.py::BaseTest::test_num_throats_two_labels_xor",
"tests/unit/core/BaseTest.py::BaseTest::test_num_throats_two_labels_nor",
"tests/unit/core/BaseTest.py::BaseTest::test_keys_mode_skip",
"tests/unit/core/BaseTest.py::BaseTest::test_keys_mode_props",
"tests/unit/core/BaseTest.py::BaseTest::test_keys_mode_labels",
"tests/unit/core/BaseTest.py::BaseTest::test_keys_element_pores_mode_all",
"tests/unit/core/BaseTest.py::BaseTest::test_keys_element_throats_mode_all",
"tests/unit/core/BaseTest.py::BaseTest::test_keys_mode_props_and_labels",
"tests/unit/core/BaseTest.py::BaseTest::test_props_all",
"tests/unit/core/BaseTest.py::BaseTest::test_props_models",
"tests/unit/core/BaseTest.py::BaseTest::test_props_constants",
"tests/unit/core/BaseTest.py::BaseTest::test_props_pores_all",
"tests/unit/core/BaseTest.py::BaseTest::test_props_pores_models",
"tests/unit/core/BaseTest.py::BaseTest::test_props_pores_constants",
"tests/unit/core/BaseTest.py::BaseTest::test_props_hidden_keys",
"tests/unit/core/BaseTest.py::BaseTest::test_labels",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_pores_and_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_foo",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_all_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_all_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_one_pore",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_on_list_of_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_locations_boolean",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_or",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_and",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_xor",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_nand",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_xnor",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_nor",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_pores_mode_foo",
"tests/unit/core/BaseTest.py::BaseTest::test_labels_hidden_key",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_indices_boolean",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_indices_None",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_indices_int",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_indices_list",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_element_None",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_element_various_strings",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_element_bad_string",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_element_duplicate",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_element_single_true",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_element_props",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_labels_none",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_labels_string",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_labels_wildcards",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_labels_duplicates",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_mode_string",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_mode_single",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_mode_allowed",
"tests/unit/core/BaseTest.py::BaseTest::test_parse_mode_duplicate",
"tests/unit/core/BaseTest.py::BaseTest::test_setitem_wrong_prefix",
"tests/unit/core/BaseTest.py::BaseTest::test_setitem_wrong_length",
"tests/unit/core/BaseTest.py::BaseTest::test_setitem_replace_all",
"tests/unit/core/BaseTest.py::BaseTest::test_setitem_overwrite_into_all",
"tests/unit/core/BaseTest.py::BaseTest::test_setitem_subdict_conflicts",
"tests/unit/core/BaseTest.py::BaseTest::test_object_name_name_conflict",
"tests/unit/core/BaseTest.py::BaseTest::test_object_name_array_conflict",
"tests/unit/core/BaseTest.py::BaseTest::test_get_indices",
"tests/unit/core/BaseTest.py::BaseTest::test_get_indices_wildcard",
"tests/unit/core/BaseTest.py::BaseTest::test_write_dict",
"tests/unit/core/BaseTest.py::BaseTest::test_getitem_with_no_matches",
"tests/unit/core/BaseTest.py::BaseTest::test_interpolate_data",
"tests/unit/core/BaseTest.py::BaseTest::test_get_no_matches",
"tests/unit/core/BaseTest.py::BaseTest::test_get_string",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_network_from_network",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_network_from_one_geometry",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_network_from_two_geometries",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_phase_from_phase",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_phase_from_one_physics",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_phase_from_two_physics",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_getitem_on_one_geometry",
"tests/unit/core/BaseTest.py::BaseTest::test_subdict_lookup_errors",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_add_to_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_add_to_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_overwrite_on_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_overwrite_on_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_remove_from_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_remove_from_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_purge_from_pores",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_purge_from_throats",
"tests/unit/core/BaseTest.py::BaseTest::test_set_label_purge_nonexistent_label",
"tests/unit/core/BaseTest.py::BaseTest::test_renaming_to_current_name_is_allowed",
"tests/unit/core/BaseTest.py::BaseTest::test_object_names_must_be_unique_within_project",
"tests/unit/core/BaseTest.py::BaseTest::test_get_conduit_data",
"tests/unit/core/BaseTest.py::BaseTest::test_get_conduit_data_different_props",
"tests/unit/core/BaseTest.py::BaseTest::test_del_nested_dicts"
] | [] | MIT License | 11,824 | 992 | [
"openpnm/core/_base.py",
"openpnm/core/_mixins.py",
"openpnm/core/_subdomain.py",
"openpnm/network/_generic.py",
"openpnm/phases/_generic.py"
] |
|
python-pillow__Pillow-5891 | 2a3867016978f540b258f7653940cc410a4eb85e | 2021-12-15 20:37:48 | 282d8250c6f8469f5c1127d6e918fb3960b59da3 | diff --git a/src/PIL/Image.py b/src/PIL/Image.py
index 0fca3fa5c..3677cccc3 100644
--- a/src/PIL/Image.py
+++ b/src/PIL/Image.py
@@ -644,6 +644,22 @@ class Image:
id(self),
)
+ def _repr_pretty_(self, p, cycle):
+ """IPython plain text display support"""
+
+ # Same as __repr__ but without unpredicatable id(self),
+ # to keep Jupyter notebook `text/plain` output stable.
+ p.text(
+ "<%s.%s image mode=%s size=%dx%d>"
+ % (
+ self.__class__.__module__,
+ self.__class__.__name__,
+ self.mode,
+ self.size[0],
+ self.size[1],
+ )
+ )
+
def _repr_png_(self):
"""iPython display hook support
| Changing Jupyter plain text output on every cell run
### What did you do?
I'm using Pillow to generate simple images in Jupyter environment:
```python
from PIL import Image
Image.frombuffer('RGB', (16,16), bytes([100]*(16*16)))
```
It works nicely!

### What did you expect to happen?
I expect every run of the cell produce the same output in the notebook file, to avoid needless changes in Git.
### What actually happened?
Every run produces different hash in text representation of the output. For example: `at 0x1075D8370`.
```diff
$ git diff test.ipynb
diff --git a/test.ipynb b/test.ipynb
index f769d4b..a4dd8af 100644
--- a/test.ipynb
+++ b/test.ipynb
@@ -9,7 +9,7 @@
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGUlEQVR4nGPc62fCQApgIkn1qIZRDUNKAwADRwFfBBwAnwAAAABJRU5ErkJggg==",
"text/plain": [
- "<PIL.Image.Image image mode=RGB size=16x16 at 0x1075D8370>"
+ "<PIL.Image.Image image mode=RGB size=16x16 at 0x108C50160>"
]
},
"execution_count": 1,
```
Compare with Matplotlib output:
```json
"data": {
"image/png": "...",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
}
```
### What are your OS, Python and Pillow versions?
* OS: Mac OS 10.15.6
* Python: 3.9.8
* Pillow: 8.4.0 | python-pillow/Pillow | diff --git a/Tests/test_image.py b/Tests/test_image.py
index cf60f42af..db3e3063e 100644
--- a/Tests/test_image.py
+++ b/Tests/test_image.py
@@ -88,6 +88,17 @@ class TestImage:
# with pytest.raises(MemoryError):
# Image.new("L", (1000000, 1000000))
+ def test_repr_pretty(self):
+ class Pretty:
+ def text(self, text):
+ self.pretty_output = text
+
+ im = Image.new("L", (100, 100))
+
+ p = Pretty()
+ im._repr_pretty_(p, None)
+ assert p.pretty_output == "<PIL.Image.Image image mode=L size=100x100>"
+
def test_open_formats(self):
PNGFILE = "Tests/images/hopper.png"
JPGFILE = "Tests/images/hopper.jpg"
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 8.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-timeout",
"pytest-reverse"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc libtiff-dev libjpeg-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
babel==2.17.0
black==25.1.0
build==1.2.2.post1
certifi==2025.1.31
charset-normalizer==3.4.1
check-manifest==0.50
click==8.1.8
coverage==7.8.0
defusedxml==0.7.1
docutils==0.21.2
exceptiongroup==1.2.2
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
markdown2==2.5.3
MarkupSafe==3.0.2
mypy-extensions==1.0.0
olefile==0.47
packaging==24.2
pathspec==0.12.1
-e git+https://github.com/python-pillow/Pillow.git@2a3867016978f540b258f7653940cc410a4eb85e#egg=Pillow
platformdirs==4.3.7
pluggy==1.5.0
Pygments==2.19.1
pyproject_hooks==1.2.0
pyroma==4.2
pytest==8.3.5
pytest-cov==6.0.0
pytest-reverse==1.8.0
pytest-timeout==2.3.1
requests==2.32.3
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-copybutton==0.5.2
sphinx-issues==5.0.0
sphinx-removed-in==0.2.3
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
sphinxext-opengraph==0.9.1
tomli==2.2.1
trove-classifiers==2025.3.19.19
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0
| name: Pillow
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- black==25.1.0
- build==1.2.2.post1
- certifi==2025.1.31
- charset-normalizer==3.4.1
- check-manifest==0.50
- click==8.1.8
- coverage==7.8.0
- defusedxml==0.7.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markdown2==2.5.3
- markupsafe==3.0.2
- mypy-extensions==1.0.0
- olefile==0.47
- packaging==24.2
- pathspec==0.12.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pygments==2.19.1
- pyproject-hooks==1.2.0
- pyroma==4.2
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-reverse==1.8.0
- pytest-timeout==2.3.1
- requests==2.32.3
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinx-copybutton==0.5.2
- sphinx-issues==5.0.0
- sphinx-removed-in==0.2.3
- sphinx-rtd-theme==3.0.2
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jquery==4.1
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- sphinxext-opengraph==0.9.1
- tomli==2.2.1
- trove-classifiers==2025.3.19.19
- typing-extensions==4.13.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/Pillow
| [
"Tests/test_image.py::TestImage::test_repr_pretty"
] | [
"Tests/test_image.py::TestImage::test_no_resource_warning_on_save"
] | [
"Tests/test_image.py::TestImage::test_image_modes_success",
"Tests/test_image.py::TestImage::test_image_modes_fail",
"Tests/test_image.py::TestImage::test_exception_inheritance",
"Tests/test_image.py::TestImage::test_sanity",
"Tests/test_image.py::TestImage::test_open_formats",
"Tests/test_image.py::TestImage::test_width_height",
"Tests/test_image.py::TestImage::test_invalid_image",
"Tests/test_image.py::TestImage::test_bad_mode",
"Tests/test_image.py::TestImage::test_stringio",
"Tests/test_image.py::TestImage::test_pathlib",
"Tests/test_image.py::TestImage::test_fp_name",
"Tests/test_image.py::TestImage::test_tempfile",
"Tests/test_image.py::TestImage::test_unknown_extension",
"Tests/test_image.py::TestImage::test_internals",
"Tests/test_image.py::TestImage::test_readonly_save",
"Tests/test_image.py::TestImage::test_dump",
"Tests/test_image.py::TestImage::test_comparison_with_other_type",
"Tests/test_image.py::TestImage::test_expand_x",
"Tests/test_image.py::TestImage::test_expand_xy",
"Tests/test_image.py::TestImage::test_getbands",
"Tests/test_image.py::TestImage::test_getchannel_wrong_params",
"Tests/test_image.py::TestImage::test_getchannel",
"Tests/test_image.py::TestImage::test_getbbox",
"Tests/test_image.py::TestImage::test_ne",
"Tests/test_image.py::TestImage::test_alpha_composite",
"Tests/test_image.py::TestImage::test_alpha_inplace",
"Tests/test_image.py::TestImage::test_registered_extensions_uninitialized",
"Tests/test_image.py::TestImage::test_registered_extensions",
"Tests/test_image.py::TestImage::test_effect_mandelbrot",
"Tests/test_image.py::TestImage::test_effect_mandelbrot_bad_arguments",
"Tests/test_image.py::TestImage::test_effect_noise",
"Tests/test_image.py::TestImage::test_effect_spread",
"Tests/test_image.py::TestImage::test_effect_spread_zero",
"Tests/test_image.py::TestImage::test_check_size",
"Tests/test_image.py::TestImage::test_storage_neg",
"Tests/test_image.py::TestImage::test_one_item_tuple",
"Tests/test_image.py::TestImage::test_linear_gradient_wrong_mode",
"Tests/test_image.py::TestImage::test_linear_gradient",
"Tests/test_image.py::TestImage::test_radial_gradient_wrong_mode",
"Tests/test_image.py::TestImage::test_radial_gradient",
"Tests/test_image.py::TestImage::test_register_extensions",
"Tests/test_image.py::TestImage::test_remap_palette",
"Tests/test_image.py::TestImage::test__new",
"Tests/test_image.py::TestImage::test_p_from_rgb_rgba",
"Tests/test_image.py::TestImage::test_load_on_nonexclusive_multiframe",
"Tests/test_image.py::TestImage::test_exif_jpeg",
"Tests/test_image.py::TestImage::test_exif_webp",
"Tests/test_image.py::TestImage::test_exif_png",
"Tests/test_image.py::TestImage::test_exif_interop",
"Tests/test_image.py::TestImage::test_exif_ifd",
"Tests/test_image.py::TestImage::test_exif_load_from_fp",
"Tests/test_image.py::TestImage::test_categories_deprecation",
"Tests/test_image.py::TestImage::test_overrun[fli_overrun.bin]",
"Tests/test_image.py::TestImage::test_overrun[sgi_overrun.bin]",
"Tests/test_image.py::TestImage::test_overrun[sgi_overrun_expandrow.bin]",
"Tests/test_image.py::TestImage::test_overrun[sgi_overrun_expandrow2.bin]",
"Tests/test_image.py::TestImage::test_overrun[pcx_overrun.bin]",
"Tests/test_image.py::TestImage::test_overrun[pcx_overrun2.bin]",
"Tests/test_image.py::TestImage::test_overrun[ossfuzz-4836216264589312.pcx]",
"Tests/test_image.py::TestImage::test_overrun[01r_00.pcx]",
"Tests/test_image.py::TestImage::test_fli_overrun2",
"Tests/test_image.py::TestRegistry::test_encode_registry",
"Tests/test_image.py::TestRegistry::test_encode_registry_fail"
] | [] | MIT-CMU License | 11,826 | 221 | [
"src/PIL/Image.py"
] |
|
PMEAL__OpenPNM-2266 | bc4a7da27aa23ff0fc74b1ae0bc18a4451db3223 | 2021-12-17 05:10:43 | e4c9f799076c334904088df34b8f04da7802a08b | diff --git a/openpnm/topotools/_topotools.py b/openpnm/topotools/_topotools.py
index ce44e9c9a..2cbf51a9b 100644
--- a/openpnm/topotools/_topotools.py
+++ b/openpnm/topotools/_topotools.py
@@ -1890,6 +1890,39 @@ def filter_pores_by_z(network, pores, z=1):
hits = pores[orphans]
return hits
+
+def find_interface_throats(network, P1, P2):
+ """
+ Finds all throats between two sets pores with the given labels.
+
+ Parameters
+ ----------
+ network : GenericNetwork
+ The network on which the query is to be performed
+ P1 : array_like str
+ The (label of) first set of pores
+ P2 : array_like or str
+ The (label of) second set of pores
+
+ Returns
+ -------
+ ndarray
+ List of interface throats between the two given sets of pores
+
+ Notes
+ -----
+ This method requires that the two labels do not share any pores.
+
+ """
+ P1 = network.pores(P1) if isinstance(P1, str) else P1
+ P2 = network.pores(P2) if isinstance(P2, str) else P2
+ if np.intersect1d(P1, P2).size != 0:
+ raise Exception("P1 and P2 must not share any pores.")
+ Ts1 = network.find_neighbor_throats(pores=P1, mode="xor")
+ Ts2 = network.find_neighbor_throats(pores=P2, mode="xor")
+ return np.intersect1d(Ts1, Ts2)
+
+
end_all()
| Find rate between two sets of pores
Here's a handy function that calculates the rate between two sets of pores `P1` and `P2`. I'm not sure if it's worth adding it to `openpnm`.
```python
def rate_interface(alg, P1, P2):
if np.intersect1d(P1, P2).size != 0:
raise Exception("P1 and P2 must not share any pores.")
net = alg.network
Ts_int = find_interface_throats(net, P1, P2)
conns_int = net.conns[Ts_int].copy()
# Account for throat direction, i.e. if there exists [i, j] in conns
# such that i is in P2 and j is in P1, it must be replaced with [j, i]
mask = np.in1d(conns_int[:, 0], P2)
rates = alg.rate(throats=Ts_int, mode="single")
rates[mask] *= -1
return rates.sum()
def find_interface_throats(network, P1, P2):
r"""
Finds all throats between two sets pores: ``P1`` and ``P2``.
This method requires that ``P1`` and ``P2`` not share any pores.
"""
Ts1 = network.find_neighbor_throats(pores=P1, mode="xor")
Ts2 = network.find_neighbor_throats(pores=P2, mode="xor")
return np.intersect1d(Ts1, Ts2)
```
The only issue is that this method assumes that the rate returned by `GenericTransport.rate` is direction-dependent, which is not currently the case. I propose making the `rate` method, direction dependent. @jgostick and I already had a little conversation regarding this in #1835.
**Edit**: I also propose adding this method to `GenericTransport` (of course if other people think that's a good idea). | PMEAL/OpenPNM | diff --git a/tests/unit/topotools/TopotoolsTest.py b/tests/unit/topotools/TopotoolsTest.py
index 3c7e9012f..6f3283234 100644
--- a/tests/unit/topotools/TopotoolsTest.py
+++ b/tests/unit/topotools/TopotoolsTest.py
@@ -586,6 +586,21 @@ class TopotoolsTest:
with pytest.raises(Exception):
_ = op.topotools.get_spacing(net)
+ def test_find_interface_throats(self):
+ net = op.network.Cubic([5, 1, 1])
+ with pytest.raises(Exception):
+ op.topotools.find_interface_throats(net, [1, 2, 3], [3, 4, 5])
+ # Test pores that do have an interface
+ Ts_int = op.topotools.find_interface_throats(net, 0, 1)
+ assert_allclose(Ts_int, np.array([0]))
+ # Test pores without an interface
+ Ts_int = op.topotools.find_interface_throats(net, 2, 4)
+ assert_allclose(Ts_int, np.array([]))
+ # Test calling the function with labels
+ net["pore.internal"] = ~net["pore.surface"]
+ Ts_int = op.topotools.find_interface_throats(net, "internal", "surface")
+ assert_allclose(Ts_int, np.array([0, 3]))
+
if __name__ == '__main__':
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_issue_reference"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 3
},
"num_modified_files": 1
} | 2.8 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.8",
"reqs_path": [
"requirements/pip_requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | asttokens==3.0.0
attr==0.3.2
attrs==25.3.0
auto-all==1.4.1
backcall==0.2.0
chemicals==1.3.3
contourpy==1.1.1
cycler==0.12.1
decorator==5.2.1
docrep==0.3.2
exceptiongroup==1.2.2
executing==2.2.0
flatdict==4.0.1
fluids==1.1.0
fonttools==4.56.0
gitdb==4.0.12
GitPython==3.1.44
h5py==3.11.0
imageio==2.35.1
importlib_metadata==8.5.0
importlib_resources==6.4.5
iniconfig==2.1.0
intel-cmplr-lib-ur==2025.1.0
intel-openmp==2025.1.0
ipython==8.12.3
jedi==0.19.2
json-tricks==3.17.3
jsonschema==4.23.0
jsonschema-specifications==2023.12.1
kiwisolver==1.4.7
lazy_loader==0.4
llvmlite==0.41.1
matplotlib==3.7.5
matplotlib-inline==0.1.7
mkl==2025.1.0
mpmath==1.3.0
networkx==3.1
numba==0.58.1
numpy==1.24.4
-e git+https://github.com/PMEAL/OpenPNM.git@bc4a7da27aa23ff0fc74b1ae0bc18a4451db3223#egg=openpnm
packaging==24.2
pandas==2.0.3
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
pillow==10.4.0
pkgutil_resolve_name==1.3.10
pluggy==1.5.0
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
Pygments==2.19.1
pypardiso==0.4.6
pyparsing==3.1.4
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyWavelets==1.4.1
referencing==0.35.1
rpds-py==0.20.1
scikit-image==0.21.0
scipy==1.10.1
six==1.17.0
smmap==5.0.2
stack-data==0.6.3
sympy==1.13.3
tbb==2022.1.0
tcmlib==1.3.0
terminaltables==3.1.10
tifffile==2023.7.10
tomli==2.2.1
tqdm==4.67.1
traitlets==5.14.3
traits==7.0.2
transforms3d==0.4.2
typing_extensions==4.13.0
tzdata==2025.2
umf==0.10.0
wcwidth==0.2.13
zipp==3.20.2
| name: OpenPNM
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=24.2=py38h06a4308_0
- python=3.8.20=he870216_0
- readline=8.2=h5eee18b_0
- setuptools=75.1.0=py38h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.44.0=py38h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- asttokens==3.0.0
- attr==0.3.2
- attrs==25.3.0
- auto-all==1.4.1
- backcall==0.2.0
- chemicals==1.3.3
- contourpy==1.1.1
- cycler==0.12.1
- decorator==5.2.1
- docrep==0.3.2
- exceptiongroup==1.2.2
- executing==2.2.0
- flatdict==4.0.1
- fluids==1.1.0
- fonttools==4.56.0
- gitdb==4.0.12
- gitpython==3.1.44
- h5py==3.11.0
- imageio==2.35.1
- importlib-metadata==8.5.0
- importlib-resources==6.4.5
- iniconfig==2.1.0
- intel-cmplr-lib-ur==2025.1.0
- intel-openmp==2025.1.0
- ipython==8.12.3
- jedi==0.19.2
- json-tricks==3.17.3
- jsonschema==4.23.0
- jsonschema-specifications==2023.12.1
- kiwisolver==1.4.7
- lazy-loader==0.4
- llvmlite==0.41.1
- matplotlib==3.7.5
- matplotlib-inline==0.1.7
- mkl==2025.1.0
- mpmath==1.3.0
- networkx==3.1
- numba==0.58.1
- numpy==1.24.4
- packaging==24.2
- pandas==2.0.3
- parso==0.8.4
- pexpect==4.9.0
- pickleshare==0.7.5
- pillow==10.4.0
- pkgutil-resolve-name==1.3.10
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pygments==2.19.1
- pypardiso==0.4.6
- pyparsing==3.1.4
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pywavelets==1.4.1
- referencing==0.35.1
- rpds-py==0.20.1
- scikit-image==0.21.0
- scipy==1.10.1
- six==1.17.0
- smmap==5.0.2
- stack-data==0.6.3
- sympy==1.13.3
- tbb==2022.1.0
- tcmlib==1.3.0
- terminaltables==3.1.10
- tifffile==2023.7.10
- tomli==2.2.1
- tqdm==4.67.1
- traitlets==5.14.3
- traits==7.0.2
- transforms3d==0.4.2
- typing-extensions==4.13.0
- tzdata==2025.2
- umf==0.10.0
- wcwidth==0.2.13
- zipp==3.20.2
prefix: /opt/conda/envs/OpenPNM
| [
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_find_interface_throats"
] | [] | [
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_filter_pores_by_z",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_label_faces",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_label_faces_tol",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_find_surface_pores_default_markers",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_find_surface_pores_custom_markers_2d",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_find_surface_pores_custom_markers_3d",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_find_pore_to_pore_distance",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_template_sphere_shell",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_template_cylinder_annulus",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_add_boundary_pores",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_clone_pores_mode_parents",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_clone_pores_mode_sibings",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_clone_pores_mode_isolated",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_clone_pores_with_labels",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_merge_networks",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_merge_networks_with_active_geometries",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_subdivide_3d",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_subdivide_2d",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_merge_pores",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_merge_pores_coords",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_connect_pores",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_ispercolating",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_trim_pores",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_trim_throats",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_iscoplanar",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_extend",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_extend_geometry_present",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_extend_phase_present",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_stitch_radius_no_connections",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_stitch_10_connections",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_stitch_with_multiple_labels",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_stitch_repeatedly",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_dimensionality",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_stitch_pores",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_is_fully_connected",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_is_fully_connected_with_alg",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_could_not_be_found",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_1D",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_2D",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_3D",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_2D_uneven",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_3D_uneven",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_shape_1D",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_shape_2D",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_shape_3D",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_shape_extremely_small_spacing",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_3d_rotated",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_3d_rotated_uneven",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_2d_sheared",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_2d_sheared_uneven",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_3d_sheared",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_3d_sheared_uneven",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_on_joggled_network",
"tests/unit/topotools/TopotoolsTest.py::TopotoolsTest::test_spacing_on_network_with_boundary_pores"
] | [] | MIT License | 11,834 | 424 | [
"openpnm/topotools/_topotools.py"
] |
|
fnl__syntok-17 | 10ee9b1525a513ae0fb08762b91beb24a26389ca | 2021-12-17 09:09:53 | 10ee9b1525a513ae0fb08762b91beb24a26389ca | fnl: I think offsets should all ways be truthful to the input text, as that is where there value lies: tracking the provenance of a token.
So even can’t would become “ca”:0, “not”:2 in that scenario.
Does that seem right to you, too?
KDercksen: Yes, I agree actually! I was doubting myself because of the comment written [here](https://github.com/fnl/syntok/blob/master/syntok/segmenter.py#L37) though.
I do think it would be best, even if the token text changes ("n't" -> "not"), that the offsets should be truthful to the original text. I can change the PR to reflect this! | diff --git a/syntok/tokenizer.py b/syntok/tokenizer.py
index e27a705..edb3f7f 100644
--- a/syntok/tokenizer.py
+++ b/syntok/tokenizer.py
@@ -221,7 +221,7 @@ class Tokenizer:
yield Token(prefix, word[remainder:mo.start() - 1], offset + remainder)
prefix = ""
- yield Token(prefix, "not" if self.replace_not_contraction else 'n' + mo.group(0), offset + mo.start())
+ yield Token(prefix, "not" if self.replace_not_contraction else 'n' + mo.group(0), offset + mo.start() - 1)
return ""
yield Token(prefix, word[remainder:mo.start()], offset + remainder)
| Bug in not-contraction handling code
Hi,
Thanks for the great library! I think I ran into a weird edge-case wrt not-contraction handling code. If I use the following example:
```python
from syntok.tokenizer import Tokenizer
tok = Tokenizer(replace_not_contraction=False)
tok.split("n't")
```
The output is `[<Token '' : "n't" @ 1>]`. Something is going wrong in the offset calculation there, that 1 should be a 0... The real example this came from is a sentence in the AIDA dataset, `" Falling share prices in New York do n't hurt Mexico as long as it happens gradually , as earlier this week`.
I see the same with "don't": `[<Token '' : 'do' @ 0>, <Token '' : "n't" @ 3>]`, that 3 should be 2 no?
Would love to hear your thoughts, not sure how to fix this neatly yet. | fnl/syntok | diff --git a/syntok/tokenizer_test.py b/syntok/tokenizer_test.py
index e40a032..dbb3cbe 100644
--- a/syntok/tokenizer_test.py
+++ b/syntok/tokenizer_test.py
@@ -91,6 +91,23 @@ class TestTokenizer(TestCase):
self.assertListEqual(s(result), ["\U0001F64C", ".", "A"])
self.assertListEqual([t.offset for t in result], [0, 1, 2]) # requires Py3.3+
+ def test_apostrophe_offset_without_replace_not_contraction(self):
+ # NOTE: in this case nothing is replaced, so the offsets should remain identical
+ # to those in the original text
+ text = "don't"
+ self.tokenizer = Tokenizer(replace_not_contraction=False)
+ result = self.tokenizer.split(text)
+ self.assertListEqual([t.offset for t in result], [0, 2])
+
+ def test_apostrophe_offset_with_replace_not_contraction(self):
+ # NOTE: in this case, "n't" is replaced with "not", so a space is introduced.
+ # e.g. "don't" -> "do not", "can't" -> "can not"
+ text = "don't"
+ self.tokenizer = Tokenizer(replace_not_contraction=True)
+ result = self.tokenizer.split(text)
+ self.assertListEqual([t.offset for t in result], [0, 2])
+ self.assertListEqual([t.value for t in result], ["do", "not"])
+
class TestToText(TestCase):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 1.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y python3-dev"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup==1.2.2
flake8==7.2.0
iniconfig==2.1.0
mccabe==0.7.0
mypy==1.15.0
mypy-extensions==1.0.0
packaging==24.2
pluggy==1.5.0
pycodestyle==2.13.0
pyflakes==3.3.1
pytest==8.3.5
regex==2024.11.6
-e git+https://github.com/fnl/syntok.git@10ee9b1525a513ae0fb08762b91beb24a26389ca#egg=syntok
tomli==2.2.1
typing_extensions==4.13.0
| name: syntok
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- exceptiongroup==1.2.2
- flake8==7.2.0
- iniconfig==2.1.0
- mccabe==0.7.0
- mypy==1.15.0
- mypy-extensions==1.0.0
- packaging==24.2
- pluggy==1.5.0
- pycodestyle==2.13.0
- pyflakes==3.3.1
- pytest==8.3.5
- regex==2024.11.6
- tomli==2.2.1
- typing-extensions==4.13.0
prefix: /opt/conda/envs/syntok
| [
"syntok/tokenizer_test.py::TestTokenizer::test_apostrophe_offset_with_replace_not_contraction",
"syntok/tokenizer_test.py::TestTokenizer::test_apostrophe_offset_without_replace_not_contraction"
] | [] | [
"syntok/tokenizer_test.py::TestTokenizer::test_apostrophes",
"syntok/tokenizer_test.py::TestTokenizer::test_clean_text",
"syntok/tokenizer_test.py::TestTokenizer::test_clean_text_Unicode",
"syntok/tokenizer_test.py::TestTokenizer::test_emit_dash",
"syntok/tokenizer_test.py::TestTokenizer::test_emit_underscore",
"syntok/tokenizer_test.py::TestTokenizer::test_hyphens",
"syntok/tokenizer_test.py::TestTokenizer::test_inner_ellipsis",
"syntok/tokenizer_test.py::TestTokenizer::test_lines",
"syntok/tokenizer_test.py::TestTokenizer::test_nonword_high_prefix",
"syntok/tokenizer_test.py::TestTokenizer::test_nonword_prefix",
"syntok/tokenizer_test.py::TestTokenizer::test_spacing_prefix",
"syntok/tokenizer_test.py::TestTokenizer::test_split_camel_case",
"syntok/tokenizer_test.py::TestTokenizer::test_split_dot",
"syntok/tokenizer_test.py::TestToText::test_lines",
"syntok/tokenizer_test.py::TestToText::test_lines_emit_and_do_not_replace"
] | [] | MIT License | 11,835 | 189 | [
"syntok/tokenizer.py"
] |
encode__starlette-1377 | d81545c71a7988cfd57c613be02f4661449c0793 | 2021-12-17 14:32:49 | 70971eac55e5c8821d9e6af5fcf7bb995cc10570 | aminalaee: @euri10 For example in Nginx [docs](http://nginx.org/en/docs/http/ngx_http_core_module.html#disable_symlinks) this is the default behaviour it makes sense to break outside of the directory, only if following symlinks.
if I'm not mistaken that's also the case in Django, but I need to double check.
Kludex: Please do not merge until 0.19.1 is released. This should be up on 0.20.0.
aminalaee: @Kludex Can we merge this now?
Kludex: correct me if I'm wrong, but this PR changes the API from `str` to `Path`, and allows staticfiles to follow symlinks outside directory. Right? - just for the release notes
aminalaee: > correct me if I'm wrong, but this PR changes the API from `str` to `Path`, and allows staticfiles to follow symlinks outside directory. Right? - just for the release notes
@Kludex
- About "following symlinks" the answer is yes.
- About "changing API from str to Path" it's a bit tricky. we are changing some methods like `get_response` and `lookup_path` but I'm not sure if they are the API here. The main entry to `Staticfiles` is not changed, but in some cases people might depend on the changed methods, which is not common, and it might break for them. So a note might be useful.
| diff --git a/starlette/staticfiles.py b/starlette/staticfiles.py
index d09630f..da10a39 100644
--- a/starlette/staticfiles.py
+++ b/starlette/staticfiles.py
@@ -3,6 +3,7 @@ import os
import stat
import typing
from email.utils import parsedate
+from pathlib import Path
import anyio
@@ -51,7 +52,7 @@ class StaticFiles:
self.all_directories = self.get_directories(directory, packages)
self.html = html
self.config_checked = False
- if check_dir and directory is not None and not os.path.isdir(directory):
+ if check_dir and directory is not None and not Path(directory).is_dir():
raise RuntimeError(f"Directory '{directory}' does not exist")
def get_directories(
@@ -77,11 +78,9 @@ class StaticFiles:
spec = importlib.util.find_spec(package)
assert spec is not None, f"Package {package!r} could not be found."
assert spec.origin is not None, f"Package {package!r} could not be found."
- package_directory = os.path.normpath(
- os.path.join(spec.origin, "..", statics_dir)
- )
- assert os.path.isdir(
- package_directory
+ package_directory = Path(spec.origin).joinpath("..", statics_dir).resolve()
+ assert (
+ package_directory.is_dir()
), f"Directory '{statics_dir!r}' in package {package!r} could not be found."
directories.append(package_directory)
@@ -101,14 +100,14 @@ class StaticFiles:
response = await self.get_response(path, scope)
await response(scope, receive, send)
- def get_path(self, scope: Scope) -> str:
+ def get_path(self, scope: Scope) -> Path:
"""
Given the ASGI scope, return the `path` string to serve up,
with OS specific path separators, and any '..', '.' components removed.
"""
- return os.path.normpath(os.path.join(*scope["path"].split("/")))
+ return Path(*scope["path"].split("/"))
- async def get_response(self, path: str, scope: Scope) -> Response:
+ async def get_response(self, path: Path, scope: Scope) -> Response:
"""
Returns an HTTP response, given the incoming path, method and request headers.
"""
@@ -131,7 +130,7 @@ class StaticFiles:
elif stat_result and stat.S_ISDIR(stat_result.st_mode) and self.html:
# We're in HTML mode, and have got a directory URL.
# Check if we have 'index.html' file to serve.
- index_path = os.path.join(path, "index.html")
+ index_path = path.joinpath("index.html")
full_path, stat_result = await anyio.to_thread.run_sync(
self.lookup_path, index_path
)
@@ -158,20 +157,25 @@ class StaticFiles:
raise HTTPException(status_code=404)
def lookup_path(
- self, path: str
- ) -> typing.Tuple[str, typing.Optional[os.stat_result]]:
+ self, path: Path
+ ) -> typing.Tuple[Path, typing.Optional[os.stat_result]]:
for directory in self.all_directories:
- full_path = os.path.realpath(os.path.join(directory, path))
- directory = os.path.realpath(directory)
- if os.path.commonprefix([full_path, directory]) != directory:
- # Don't allow misbehaving clients to break out of the static files
- # directory.
- continue
+ original_path = Path(directory).joinpath(path)
+ full_path = original_path.resolve()
+ directory = Path(directory).resolve()
try:
- return full_path, os.stat(full_path)
+ stat_result = os.lstat(original_path)
+ full_path.relative_to(directory)
+ return full_path, stat_result
+ except ValueError:
+ # Allow clients to break out of the static files directory
+ # if following symlinks.
+ if stat.S_ISLNK(stat_result.st_mode):
+ stat_result = os.lstat(full_path)
+ return full_path, stat_result
except (FileNotFoundError, NotADirectoryError):
continue
- return "", None
+ return Path(), None
def file_response(
self,
| StaticFiles middleware doesn't follow symlinks
### Checklist
- [x] The bug is reproducible against the latest release and/or `master`.
- [x] There are no similar issues or pull requests to fix it yet.
### Describe the bug
The StaticFiles middleware is checking the `os.realpath` of a file and returning a 404 for symlinks that lead outside the static directory.
### To reproduce
1. create a minimal app with a staticfiles middleware
1. put a symlink in your static directory. the link's target must be above the static directory.
1. you'll get a 404
### Expected behavior
Support symlinks in static directory.
The use case for symlinks in static is to target frontend assets that are being generated in file-watch mode.
### Actual behavior
404.
### Debugging material
It's happening here:
https://github.com/encode/starlette/blob/b95acea973c20eea3e7cbbca42d09b1f5d4a3412/starlette/staticfiles.py#L147-L149
### Environment
- OS: linux
- Python version: 3.7.5
- Starlette version: 0.13.8
### Additional context
I'm happy to post a PR for this if useful, ideally adding a bool param to the StaticFiles middleware that allows symlinks. | encode/starlette | diff --git a/tests/test_staticfiles.py b/tests/test_staticfiles.py
index 7d13a05..53f3ea9 100644
--- a/tests/test_staticfiles.py
+++ b/tests/test_staticfiles.py
@@ -166,8 +166,8 @@ def test_staticfiles_prevents_breaking_out_of_directory(tmpdir):
directory = os.path.join(tmpdir, "foo")
os.mkdir(directory)
- path = os.path.join(tmpdir, "example.txt")
- with open(path, "w") as file:
+ file_path = os.path.join(tmpdir, "example.txt")
+ with open(file_path, "w") as file:
file.write("outside root dir")
app = StaticFiles(directory=directory)
@@ -441,3 +441,28 @@ def test_staticfiles_unhandled_os_error_returns_500(
response = client.get("/example.txt")
assert response.status_code == 500
assert response.text == "Internal Server Error"
+
+
+def test_staticfiles_follows_symlinks_to_break_out_of_dir(
+ tmp_path: pathlib.Path, test_client_factory
+):
+ statics_path = tmp_path.joinpath("statics")
+ statics_path.mkdir()
+
+ symlink_path = tmp_path.joinpath("symlink")
+ symlink_path.mkdir()
+
+ symlink_file_path = symlink_path.joinpath("index.html")
+ with open(symlink_file_path, "w") as file:
+ file.write("<h1>Hello</h1>")
+
+ statics_file_path = statics_path.joinpath("index.html")
+ statics_file_path.symlink_to(symlink_file_path)
+
+ app = StaticFiles(directory=statics_path)
+ client = test_client_factory(app)
+
+ response = client.get("/index.html")
+ assert response.url == "http://testserver/index.html"
+ assert response.status_code == 200
+ assert response.text == "<h1>Hello</h1>"
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 0.20 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[full]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest pytest-cov pytest-xdist pytest-mock pytest-asyncio",
"pytest"
],
"pre_install": null,
"python": "3.7",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aiosqlite==0.19.0
anyio==3.7.1
async-generator==1.10
attrs==24.2.0
autoflake==1.4
black==22.3.0
bleach==6.0.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
click==8.1.8
coverage==6.2
cryptography==44.0.2
databases==0.5.5
docutils==0.20.1
exceptiongroup==1.2.2
execnet==2.0.2
flake8==3.9.2
ghp-import==2.1.0
greenlet==3.1.1
idna==3.10
importlib-metadata==6.7.0
importlib-resources==5.12.0
iniconfig==2.0.0
isort==5.10.1
itsdangerous==2.1.2
jaraco.classes==3.2.3
jeepney==0.9.0
Jinja2==3.1.6
keyring==24.1.1
Markdown==3.4.4
markdown-it-py==2.2.0
MarkupSafe==2.1.5
mccabe==0.6.1
mdurl==0.1.2
mergedeep==1.3.4
mkautodoc==0.1.0
mkdocs==1.3.0
mkdocs-material==8.2.8
mkdocs-material-extensions==1.2
more-itertools==9.1.0
mypy==0.950
mypy-extensions==1.0.0
outcome==1.3.0.post0
packaging==24.0
pathspec==0.11.2
pkginfo==1.10.0
platformdirs==4.0.0
pluggy==1.2.0
py==1.11.0
pycodestyle==2.7.0
pycparser==2.21
pyflakes==2.3.1
Pygments==2.17.2
pymdown-extensions==10.2.1
pytest==7.1.2
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
python-multipart==0.0.8
PyYAML==6.0.1
pyyaml_env_tag==0.1
readme-renderer==37.3
requests==2.31.0
requests-toolbelt==1.0.0
rfc3986==2.0.0
rich==13.8.1
SecretStorage==3.3.3
six==1.17.0
sniffio==1.3.1
sortedcontainers==2.4.0
SQLAlchemy==1.4.54
-e git+https://github.com/encode/starlette.git@d81545c71a7988cfd57c613be02f4661449c0793#egg=starlette
tomli==2.0.1
trio==0.19.0
twine==4.0.0
typed-ast==1.5.5
types-contextvars==2.4.5
types-dataclasses==0.6.5
types-PyYAML==6.0.4
types-requests==2.26.3
typing_extensions==4.7.1
urllib3==2.0.7
watchdog==3.0.0
webencodings==0.5.1
zipp==3.15.0
| name: starlette
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=22.3.1=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- aiosqlite==0.19.0
- anyio==3.7.1
- async-generator==1.10
- attrs==24.2.0
- autoflake==1.4
- black==22.3.0
- bleach==6.0.0
- cffi==1.15.1
- charset-normalizer==3.4.1
- click==8.1.8
- coverage==6.2
- cryptography==44.0.2
- databases==0.5.5
- docutils==0.20.1
- exceptiongroup==1.2.2
- execnet==2.0.2
- flake8==3.9.2
- ghp-import==2.1.0
- greenlet==3.1.1
- idna==3.10
- importlib-metadata==6.7.0
- importlib-resources==5.12.0
- iniconfig==2.0.0
- isort==5.10.1
- itsdangerous==2.1.2
- jaraco-classes==3.2.3
- jeepney==0.9.0
- jinja2==3.1.6
- keyring==24.1.1
- markdown==3.4.4
- markdown-it-py==2.2.0
- markupsafe==2.1.5
- mccabe==0.6.1
- mdurl==0.1.2
- mergedeep==1.3.4
- mkautodoc==0.1.0
- mkdocs==1.3.0
- mkdocs-material==8.2.8
- mkdocs-material-extensions==1.2
- more-itertools==9.1.0
- mypy==0.950
- mypy-extensions==1.0.0
- outcome==1.3.0.post0
- packaging==24.0
- pathspec==0.11.2
- pkginfo==1.10.0
- platformdirs==4.0.0
- pluggy==1.2.0
- py==1.11.0
- pycodestyle==2.7.0
- pycparser==2.21
- pyflakes==2.3.1
- pygments==2.17.2
- pymdown-extensions==10.2.1
- pytest==7.1.2
- pytest-asyncio==0.21.2
- pytest-cov==4.1.0
- pytest-mock==3.11.1
- pytest-xdist==3.5.0
- python-dateutil==2.9.0.post0
- python-multipart==0.0.8
- pyyaml==6.0.1
- pyyaml-env-tag==0.1
- readme-renderer==37.3
- requests==2.31.0
- requests-toolbelt==1.0.0
- rfc3986==2.0.0
- rich==13.8.1
- secretstorage==3.3.3
- six==1.17.0
- sniffio==1.3.1
- sortedcontainers==2.4.0
- sqlalchemy==1.4.54
- tomli==2.0.1
- trio==0.19.0
- twine==4.0.0
- typed-ast==1.5.5
- types-contextvars==2.4.5
- types-dataclasses==0.6.5
- types-pyyaml==6.0.4
- types-requests==2.26.3
- typing-extensions==4.7.1
- urllib3==2.0.7
- watchdog==3.0.0
- webencodings==0.5.1
- wheel==0.37.1
- zipp==3.15.0
prefix: /opt/conda/envs/starlette
| [
"tests/test_staticfiles.py::test_staticfiles_follows_symlinks_to_break_out_of_dir[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_follows_symlinks_to_break_out_of_dir[trio]"
] | [
"tests/test_staticfiles.py::test_staticfiles_head_with_middleware[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_head_with_middleware[trio]",
"tests/test_staticfiles.py::test_staticfiles_never_read_file_for_head_method[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_never_read_file_for_head_method[trio]",
"tests/test_staticfiles.py::test_staticfiles_with_invalid_dir_permissions_returns_401[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_with_invalid_dir_permissions_returns_401[trio]"
] | [
"tests/test_staticfiles.py::test_staticfiles[asyncio]",
"tests/test_staticfiles.py::test_staticfiles[trio]",
"tests/test_staticfiles.py::test_staticfiles_with_pathlib[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_with_pathlib[trio]",
"tests/test_staticfiles.py::test_staticfiles_with_package[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_with_package[trio]",
"tests/test_staticfiles.py::test_staticfiles_post[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_post[trio]",
"tests/test_staticfiles.py::test_staticfiles_with_directory_returns_404[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_with_directory_returns_404[trio]",
"tests/test_staticfiles.py::test_staticfiles_with_missing_file_returns_404[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_with_missing_file_returns_404[trio]",
"tests/test_staticfiles.py::test_staticfiles_instantiated_with_missing_directory",
"tests/test_staticfiles.py::test_staticfiles_configured_with_missing_directory[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_configured_with_missing_directory[trio]",
"tests/test_staticfiles.py::test_staticfiles_configured_with_file_instead_of_directory[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_configured_with_file_instead_of_directory[trio]",
"tests/test_staticfiles.py::test_staticfiles_config_check_occurs_only_once[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_config_check_occurs_only_once[trio]",
"tests/test_staticfiles.py::test_staticfiles_prevents_breaking_out_of_directory",
"tests/test_staticfiles.py::test_staticfiles_304_with_etag_match[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_304_with_etag_match[trio]",
"tests/test_staticfiles.py::test_staticfiles_304_with_last_modified_compare_last_req[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_304_with_last_modified_compare_last_req[trio]",
"tests/test_staticfiles.py::test_staticfiles_html_normal[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_html_normal[trio]",
"tests/test_staticfiles.py::test_staticfiles_html_without_index[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_html_without_index[trio]",
"tests/test_staticfiles.py::test_staticfiles_html_without_404[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_html_without_404[trio]",
"tests/test_staticfiles.py::test_staticfiles_html_only_files[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_html_only_files[trio]",
"tests/test_staticfiles.py::test_staticfiles_cache_invalidation_for_deleted_file_html_mode[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_cache_invalidation_for_deleted_file_html_mode[trio]",
"tests/test_staticfiles.py::test_staticfiles_with_missing_dir_returns_404[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_with_missing_dir_returns_404[trio]",
"tests/test_staticfiles.py::test_staticfiles_access_file_as_dir_returns_404[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_access_file_as_dir_returns_404[trio]",
"tests/test_staticfiles.py::test_staticfiles_unhandled_os_error_returns_500[asyncio]",
"tests/test_staticfiles.py::test_staticfiles_unhandled_os_error_returns_500[trio]"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,836 | 996 | [
"starlette/staticfiles.py"
] |
learningequality__kolibri-8950 | 121a67267c35023bfc3350d411a3a06356bb8bd5 | 2021-12-17 18:11:00 | 2c5f7222244a529455f8b57e74b08c7cad72409e | diff --git a/kolibri/core/tasks/job.py b/kolibri/core/tasks/job.py
index 766601a856..233c17094a 100644
--- a/kolibri/core/tasks/job.py
+++ b/kolibri/core/tasks/job.py
@@ -249,6 +249,8 @@ class Job(object):
raise ReferenceError(
"storage is not defined on this job, cannot update progress"
)
+ self.progress = progress
+ self.total_progress = total_progress
self.storage.update_job_progress(self.job_id, progress, total_progress)
def check_for_cancel(self):
@@ -268,6 +270,7 @@ class Job(object):
raise ReferenceError(
"storage is not defined on this job, cannot save as cancellable"
)
+ self.cancellable = cancellable
self.storage.save_job_as_cancellable(self.job_id, cancellable=cancellable)
@property
| Wrong progress on channel update
### Observed behavior
While trying to update ASB channel on kolibridemo, I went through the wizard that showed me the version "changelog" then when I started update task I saw it jump to 100% progress right away:
<img width="786" alt="shows as 100pct right away" src="https://user-images.githubusercontent.com/163966/77856401-d20fc900-71c4-11ea-8cd1-c27d6fd72a66.png">
### Expected behavior
Progress bar steadily growing from 0 to 100%.
### User-facing consequences
Confusing since UI says 100% but task is still running.
### Errors and logs
From the netowrk tab, I saw polling of the [task api url](https://kolibridemo.learningequality.org/api/tasks/tasks/?1585503395967=1585503395967) with the following response:
```json
[
{
"status": "COMPLETED",
"exception": "None",
"cancellable": false,
"traceback": "",
"percentage": 0,
"id": "0a0a6712ad624b7ea563a220e4d3a16e"
},
{
"status": "COMPLETED",
"exception": "None",
"cancellable": false,
"traceback": "",
"percentage": 0,
"id": "ec68f2bf7e354406a20f4d981ae36945"
},
{
"status": "RUNNING",
"exception": "None",
"started_by_username": "admin",
"new_version": 24,
"node_ids": [
"529175b4246e525e8d709c66e5c4982c",
"a2cd0fded0245abba2075b4ec226fd7d",
"a6dbf2bf66155fc0afe256a891ad001d",
"a1f99346ef2854368f28085ca04e17be",
">>>>>> 6000+ more rows go here (redacted for brevity..... LOTS A JSON) <<<<<<<<<<<<<<<<<<<<",
"9e8b227b665c50ad9ec95521654e41c5",
"cc0695941b3654468fefdbdb396d07ae",
"b5a13b940a5e5407a32901875a548917"
],
"cancellable": true,
"traceback": "",
"baseurl": "https://studio.learningequality.org",
"exclude_node_ids": null,
"started_by": "8b4c6655776a9ab94f560c5748803a93",
"channel_id": "f9d3e0e46ea25789bbed672ff6a399ed",
"percentage": 1,
"peer_id": null,
"type": "UPDATECHANNEL",
"id": "2927be07345d44119e67bdebf666e1c9",
"channel_name": "African Storybook"
}
]
```
I'm not sure what the COMPLETED tasks are, but the `UPDATECHANNEL` channel task percentage shouldn't be 1.0.
Also the `"node_ids"` was a huge list of 6000+ rows, which seems weird to be including in the status progress polling, but did not cause any noticeable slowdown. It's just text.
### Steps to reproduce
- Given Kolibri with channel vN installed
- Publish v(N+1) of the channel on Studio with changed files
- Go through the Kolibri update channel wizard (should result in similar list of node_ids to update for all the changed files)
### Context
- https://kolibridemo.learningequality.org/
- Kolibri 0.13.1
- Chrome | learningequality/kolibri | diff --git a/kolibri/core/tasks/test/test_job.py b/kolibri/core/tasks/test/test_job.py
index 692d84459f..39937231a3 100644
--- a/kolibri/core/tasks/test/test_job.py
+++ b/kolibri/core/tasks/test/test_job.py
@@ -7,7 +7,7 @@ from kolibri.core.tasks.job import RegisteredJob
class JobTest(TestCase):
def setUp(self):
- self.job = Job(id)
+ self.job = Job(id, track_progress=True)
self.job.storage = mock.MagicMock()
def test_job_save_as_cancellable(self):
@@ -18,6 +18,23 @@ class JobTest(TestCase):
self.job.job_id, cancellable=cancellable
)
+ def test_job_save_as_cancellable_sets_cancellable(self):
+ cancellable = not self.job.cancellable
+
+ self.job.save_as_cancellable(cancellable=cancellable)
+ self.assertEqual(self.job.cancellable, cancellable)
+
+ def test_job_update_progress_saves_progress_to_storage(self):
+ self.job.update_progress(0.5, 1.5)
+ self.job.storage.update_job_progress.assert_called_once_with(
+ self.job.job_id, 0.5, 1.5
+ )
+
+ def test_job_update_progress_sets_progress(self):
+ self.job.update_progress(0.5, 1.5)
+ self.assertEqual(self.job.progress, 0.5)
+ self.assertEqual(self.job.total_progress, 1.5)
+
def test_job_save_as_cancellable__skip(self):
cancellable = self.job.cancellable
self.job.save_as_cancellable(cancellable=cancellable)
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 1
},
"num_modified_files": 1
} | 0.16 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"mock"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt",
"requirements/dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aspy.yaml==1.3.0
asttokens==3.0.0
certifi==2025.1.31
cfgv==3.4.0
chardet==3.0.4
cheroot==8.5.2
Click==7.0
colorlog==3.2.0
configobj==5.0.6
coreapi==2.3.3
coreschema==0.0.4
decorator==5.2.1
diskcache==4.1.0
distlib==0.3.9
Django==1.11.29
django-debug-panel==0.8.3
django-debug-toolbar==1.9.1
django-filter==1.1.0
django-ipware==1.1.6
django-js-asset==1.2.3
django-js-reverse==0.9.1
django-mptt==0.9.1
django-redis-cache==2.0.0
djangorestframework==3.9.1
drf-yasg==1.17.1
exceptiongroup==1.2.2
executing==2.2.0
filelock==3.18.0
flake8==3.8.3
future==0.16.0
futures==3.1.1
html5lib==1.0.1
identify==2.6.9
idna==2.8
ifaddr==0.2.0
ifcfg==0.21
importlib_metadata==8.6.1
inflect==7.3.0
inflection==0.5.1
iniconfig==2.1.0
ipdb==0.13.2
ipython==8.18.1
itypes==1.2.0
jaraco.functools==4.1.0
jedi==0.19.2
Jinja2==3.1.6
jsonfield==2.0.2
-e git+https://github.com/learningequality/kolibri.git@121a67267c35023bfc3350d411a3a06356bb8bd5#egg=kolibri
le-utils==0.1.34
MagicBus==4.1.2
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mccabe==0.6.1
mock==5.2.0
morango==0.6.6
more-itertools==5.0.0
nodeenv==1.3.3
packaging==24.2
parso==0.8.4
pexpect==4.9.0
platformdirs==4.3.7
pluggy==1.5.0
pre-commit==1.15.1
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pure_eval==0.2.3
py==1.11.0
pyasn1==0.6.1
pycodestyle==2.6.0
pycountry==17.5.14
pyflakes==2.2.0
Pygments==2.19.1
pytest==8.3.5
python-dateutil==2.7.5
pytz==2020.5
PyYAML==6.0.2
redis==3.2.1
requests==2.21.0
requests-toolbelt==0.8.0
rsa==3.4.2
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
semver==2.8.1
six==1.14.0
sqlacodegen==2.1.0
SQLAlchemy==1.3.17
sqlparse==0.5.3
stack-data==0.6.3
tabulate==0.8.2
toml==0.10.2
tomli==2.2.1
tox==3.1.3
traitlets==5.14.3
typeguard==4.4.2
typing_extensions==4.13.0
tzlocal==2.1
uritemplate==4.1.1
urllib3==1.24.3
virtualenv==20.29.3
wcwidth==0.2.13
webencodings==0.5.1
whitenoise==4.1.4
zeroconf-py2compat==0.19.15
zipp==3.21.0
| name: kolibri
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- aspy-yaml==1.3.0
- asttokens==3.0.0
- certifi==2025.1.31
- cfgv==3.4.0
- chardet==3.0.4
- cheroot==8.5.2
- click==7.0
- colorlog==3.2.0
- configobj==5.0.6
- coreapi==2.3.3
- coreschema==0.0.4
- decorator==5.2.1
- diskcache==4.1.0
- distlib==0.3.9
- django==1.11.29
- django-debug-panel==0.8.3
- django-debug-toolbar==1.9.1
- django-filter==1.1.0
- django-ipware==1.1.6
- django-js-asset==1.2.3
- django-js-reverse==0.9.1
- django-mptt==0.9.1
- django-redis-cache==2.0.0
- djangorestframework==3.9.1
- drf-yasg==1.17.1
- exceptiongroup==1.2.2
- executing==2.2.0
- filelock==3.18.0
- flake8==3.8.3
- future==0.16.0
- futures==3.1.1
- html5lib==1.0.1
- identify==2.6.9
- idna==2.8
- ifaddr==0.2.0
- ifcfg==0.21
- importlib-metadata==8.6.1
- inflect==7.3.0
- inflection==0.5.1
- iniconfig==2.1.0
- ipdb==0.13.2
- ipython==8.18.1
- itypes==1.2.0
- jaraco-functools==4.1.0
- jedi==0.19.2
- jinja2==3.1.6
- jsonfield==2.0.2
- le-utils==0.1.34
- magicbus==4.1.2
- markupsafe==3.0.2
- matplotlib-inline==0.1.7
- mccabe==0.6.1
- mock==5.2.0
- morango==0.6.6
- more-itertools==5.0.0
- nodeenv==1.3.3
- packaging==24.2
- parso==0.8.4
- pexpect==4.9.0
- platformdirs==4.3.7
- pluggy==1.5.0
- pre-commit==1.15.1
- prompt-toolkit==3.0.50
- ptyprocess==0.7.0
- pure-eval==0.2.3
- py==1.11.0
- pyasn1==0.6.1
- pycodestyle==2.6.0
- pycountry==17.5.14
- pyflakes==2.2.0
- pygments==2.19.1
- pytest==8.3.5
- python-dateutil==2.7.5
- pytz==2020.5
- pyyaml==6.0.2
- redis==3.2.1
- requests==2.21.0
- requests-toolbelt==0.8.0
- rsa==3.4.2
- ruamel-yaml==0.18.10
- ruamel-yaml-clib==0.2.12
- semver==2.8.1
- six==1.14.0
- sqlacodegen==2.1.0
- sqlalchemy==1.3.17
- sqlparse==0.5.3
- stack-data==0.6.3
- tabulate==0.8.2
- toml==0.10.2
- tomli==2.2.1
- tox==3.1.3
- traitlets==5.14.3
- typeguard==4.4.2
- typing-extensions==4.13.0
- tzlocal==2.1
- uritemplate==4.1.1
- urllib3==1.24.3
- virtualenv==20.29.3
- wcwidth==0.2.13
- webencodings==0.5.1
- whitenoise==4.1.4
- zeroconf-py2compat==0.19.15
- zipp==3.21.0
prefix: /opt/conda/envs/kolibri
| [
"kolibri/core/tasks/test/test_job.py::JobTest::test_job_save_as_cancellable_sets_cancellable",
"kolibri/core/tasks/test/test_job.py::JobTest::test_job_update_progress_sets_progress"
] | [] | [
"kolibri/core/tasks/test/test_job.py::JobTest::test_job_save_as_cancellable",
"kolibri/core/tasks/test/test_job.py::JobTest::test_job_save_as_cancellable__no_storage",
"kolibri/core/tasks/test/test_job.py::JobTest::test_job_save_as_cancellable__skip",
"kolibri/core/tasks/test/test_job.py::JobTest::test_job_update_progress_saves_progress_to_storage",
"kolibri/core/tasks/test/test_job.py::TestRegisteredJob::test__ready_job",
"kolibri/core/tasks/test/test_job.py::TestRegisteredJob::test_constructor_sets_required_params",
"kolibri/core/tasks/test/test_job.py::TestRegisteredJob::test_enqueue",
"kolibri/core/tasks/test/test_job.py::TestRegisteredJob::test_enqueue_at",
"kolibri/core/tasks/test/test_job.py::TestRegisteredJob::test_enqueue_in"
] | [] | MIT License | 11,838 | 221 | [
"kolibri/core/tasks/job.py"
] |
|
bridgecrewio__checkov-2125 | 7fe3f47c300447dfdcc969fb2536e5d961312d42 | 2021-12-18 18:36:35 | 13e67f317a1cc7e514cc3eaf19ed81a01c72bf00 | diff --git a/checkov/arm/checks/resource/AzureInstancePassword.py b/checkov/arm/checks/resource/AzureInstancePassword.py
index 27c9ca372..ac7586c9c 100644
--- a/checkov/arm/checks/resource/AzureInstancePassword.py
+++ b/checkov/arm/checks/resource/AzureInstancePassword.py
@@ -1,16 +1,18 @@
+from typing import Any, Dict
+
+from checkov.arm.base_resource_value_check import BaseResourceValueCheck
from checkov.common.models.enums import CheckResult, CheckCategories
-from checkov.arm.base_resource_check import BaseResourceCheck
-class AzureInstancePassword(BaseResourceCheck):
- def __init__(self):
+class AzureInstancePassword(BaseResourceValueCheck):
+ def __init__(self) -> None:
name = "Ensure Azure Instance does not use basic authentication(Use SSH Key Instead)"
id = "CKV_AZURE_1"
- supported_resources = ['Microsoft.Compute/virtualMachines']
+ supported_resources = ("Microsoft.Compute/virtualMachines",)
categories = [CheckCategories.GENERAL_SECURITY]
super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
- def scan_resource_conf(self, conf):
+ def scan_resource_conf(self, conf: Dict[str, Any]) -> CheckResult:
properties = conf.get("properties")
if isinstance(properties, dict):
storage_profile = properties.get("storageProfile")
@@ -20,13 +22,15 @@ class AzureInstancePassword(BaseResourceCheck):
publisher = image_reference.get("publisher")
if publisher and "windows" in publisher.lower():
# This check is not relevant to Windows systems
- return CheckResult.PASSED
-
- os_profile = properties.get("osProfile")
- if isinstance(os_profile, dict):
- linux_conf = os_profile.get("linuxConfiguration")
- if isinstance(linux_conf, dict) and linux_conf.get("disablePasswordAuthentication"):
- return CheckResult.PASSED
- return CheckResult.FAILED
+ return CheckResult.UNKNOWN
+
+ return super().scan_resource_conf(conf)
+
+ def get_inspected_key(self) -> str:
+ return "properties/osProfile/linuxConfiguration/disablePasswordAuthentication"
+
+ def get_expected_value(self) -> Any:
+ return True
+
check = AzureInstancePassword()
diff --git a/checkov/arm/checks/resource/AzureScaleSetPassword.py b/checkov/arm/checks/resource/AzureScaleSetPassword.py
new file mode 100644
index 000000000..e5c46321f
--- /dev/null
+++ b/checkov/arm/checks/resource/AzureScaleSetPassword.py
@@ -0,0 +1,38 @@
+from typing import Dict, Any
+
+from checkov.arm.base_resource_value_check import BaseResourceValueCheck
+from checkov.common.models.enums import CheckResult, CheckCategories
+
+
+class AzureScaleSetPassword(BaseResourceValueCheck):
+ def __init__(self) -> None:
+ name = "Ensure Azure linux scale set does not use basic authentication(Use SSH Key Instead)"
+ id = "CKV_AZURE_49"
+ supported_resources = ("Microsoft.Compute/virtualMachineScaleSets",)
+ categories = [CheckCategories.GENERAL_SECURITY]
+ super().__init__(name=name, id=id, categories=categories, supported_resources=supported_resources)
+
+ def scan_resource_conf(self, conf: Dict[str, Any]) -> CheckResult:
+ properties = conf.get("properties")
+ if isinstance(properties, dict):
+ vm_profile = properties.get("virtualMachineProfile")
+ if isinstance(vm_profile, dict):
+ storage_profile = vm_profile.get("storageProfile")
+ if isinstance(storage_profile, dict):
+ image_reference = storage_profile.get("imageReference")
+ if isinstance(image_reference, dict):
+ publisher = image_reference.get("publisher")
+ if publisher and "windows" in publisher.lower():
+ # This check is not relevant to Windows systems
+ return CheckResult.UNKNOWN
+
+ return super().scan_resource_conf(conf)
+
+ def get_inspected_key(self) -> str:
+ return "properties/virtualMachineProfile/osProfile/linuxConfiguration/disablePasswordAuthentication"
+
+ def get_expected_value(self) -> Any:
+ return True
+
+
+check = AzureScaleSetPassword()
| Add a check for AzureInstancePassword specific to scale sets
Currently AzureInstancePassword scans for virtual instance but not scale sets. Either extend the existing check to also check scale sets or create a new check for scale sets only.
https://docs.microsoft.com/en-us/azure/templates/microsoft.compute/2019-12-01/virtualmachinescalesets
https://www.terraform.io/docs/providers/azurerm/r/virtual_machine_scale_set.html
https://www.terraform.io/docs/providers/azurerm/r/linux_virtual_machine_scale_set.html
| bridgecrewio/checkov | diff --git a/tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-FAILED.json b/tests/arm/checks/resource/example_AzureInstancePassword/FAILED.json
similarity index 99%
rename from tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-FAILED.json
rename to tests/arm/checks/resource/example_AzureInstancePassword/FAILED.json
index 11c2ce3bc..2f750cff0 100644
--- a/tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-FAILED.json
+++ b/tests/arm/checks/resource/example_AzureInstancePassword/FAILED.json
@@ -205,7 +205,7 @@
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-03-01",
- "name": "[parameters('vmName')]",
+ "name": "default",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]"
diff --git a/tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-PASSED2.json b/tests/arm/checks/resource/example_AzureInstancePassword/PASSED.json
similarity index 99%
rename from tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-PASSED2.json
rename to tests/arm/checks/resource/example_AzureInstancePassword/PASSED.json
index 21dd170b7..aceec3ae2 100644
--- a/tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-PASSED2.json
+++ b/tests/arm/checks/resource/example_AzureInstancePassword/PASSED.json
@@ -183,7 +183,7 @@
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2019-03-01",
- "name": "[parameters('vmName')]",
+ "name": "enabled",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces/', variables('networkInterfaceName'))]"
diff --git a/tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-PASSED.json b/tests/arm/checks/resource/example_AzureInstancePassword/UNKNOWN.json
similarity index 99%
rename from tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-PASSED.json
rename to tests/arm/checks/resource/example_AzureInstancePassword/UNKNOWN.json
index e898eb088..bbd2e2c0d 100644
--- a/tests/arm/checks/resource/example_AzureInstancePassword/azureInstancePassword-PASSED.json
+++ b/tests/arm/checks/resource/example_AzureInstancePassword/UNKNOWN.json
@@ -167,7 +167,7 @@
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2018-10-01",
- "name": "[variables('vmName')]",
+ "name": "windows",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
diff --git a/tests/arm/checks/resource/example_AzureScaleSetPassword/FAILED.json b/tests/arm/checks/resource/example_AzureScaleSetPassword/FAILED.json
new file mode 100644
index 000000000..792ef8f99
--- /dev/null
+++ b/tests/arm/checks/resource/example_AzureScaleSetPassword/FAILED.json
@@ -0,0 +1,42 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [
+ {
+ "type": "Microsoft.Compute/virtualMachineScaleSets",
+ "name": "default",
+ "location": "East US 2",
+ "apiVersion": "2021-07-01",
+ "zones": [
+ "1"
+ ],
+ "sku": {
+ "name": "Standard_A1",
+ "capacity": "2"
+ },
+ "properties": {
+ "virtualMachineProfile": {
+ "storageProfile": {
+ "osDisk": {
+ "caching": "ReadWrite",
+ "createOption": "FromImage"
+ },
+ "imageReference": {
+ "publisher": "Canonical",
+ "offer": "UbuntuServer",
+ "sku": "16.04-LTS",
+ "version": "latest"
+ }
+ },
+ "osProfile": {
+ "linuxConfiguration": {
+ "computerNamePrefix": "myvmss",
+ "adminUsername": "azureuser",
+ "adminPassword": "P@ssw0rd!"
+ }
+ }
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/arm/checks/resource/example_AzureScaleSetPassword/PASSED.json b/tests/arm/checks/resource/example_AzureScaleSetPassword/PASSED.json
new file mode 100644
index 000000000..5616d5dc2
--- /dev/null
+++ b/tests/arm/checks/resource/example_AzureScaleSetPassword/PASSED.json
@@ -0,0 +1,48 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [
+ {
+ "type": "Microsoft.Compute/virtualMachineScaleSets",
+ "name": "enabled",
+ "location": "East US 2",
+ "apiVersion": "2021-07-01",
+ "zones": [
+ "1"
+ ],
+ "sku": {
+ "name": "Standard_A1",
+ "capacity": "2"
+ },
+ "properties": {
+ "virtualMachineProfile": {
+ "storageProfile": {
+ "osDisk": {
+ "caching": "ReadWrite",
+ "createOption": "FromImage"
+ },
+ "imageReference": {
+ "publisher": "Canonical",
+ "offer": "UbuntuServer",
+ "sku": "16.04-LTS",
+ "version": "latest"
+ }
+ },
+ "osProfile": {
+ "linuxConfiguration": {
+ "disablePasswordAuthentication": true,
+ "ssh": {
+ "publicKeys": [
+ {
+ "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",
+ "keyData": "[parameters('adminPasswordOrKey')]"
+ }
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/arm/checks/resource/example_AzureScaleSetPassword/UNKNOWN.json b/tests/arm/checks/resource/example_AzureScaleSetPassword/UNKNOWN.json
new file mode 100644
index 000000000..6289484d2
--- /dev/null
+++ b/tests/arm/checks/resource/example_AzureScaleSetPassword/UNKNOWN.json
@@ -0,0 +1,40 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "resources": [
+ {
+ "type": "Microsoft.Compute/virtualMachineScaleSets",
+ "name": "windows",
+ "location": "East US 2",
+ "apiVersion": "2021-07-01",
+ "zones": [
+ "1"
+ ],
+ "sku": {
+ "name": "Standard_A1",
+ "capacity": "2"
+ },
+ "properties": {
+ "virtualMachineProfile": {
+ "storageProfile": {
+ "osDisk": {
+ "caching": "ReadWrite",
+ "createOption": "FromImage"
+ },
+ "imageReference": {
+ "publisher": "MicrosoftWindowsServer",
+ "offer": "WindowsServer",
+ "sku": "2019-Datacenter",
+ "version": "latest"
+ }
+ },
+ "osProfile": {
+ "computerNamePrefix": "myvmss",
+ "adminUsername": "azureuser",
+ "adminPassword": "P@ssw0rd!"
+ }
+ }
+ }
+ }
+ ]
+}
diff --git a/tests/arm/checks/resource/test_AzureInstancePassword.py b/tests/arm/checks/resource/test_AzureInstancePassword.py
index db1d44001..55d5183bf 100644
--- a/tests/arm/checks/resource/test_AzureInstancePassword.py
+++ b/tests/arm/checks/resource/test_AzureInstancePassword.py
@@ -1,5 +1,5 @@
-import os
import unittest
+from pathlib import Path
from checkov.arm.checks.resource.AzureInstancePassword import check
from checkov.arm.runner import Runner
@@ -7,20 +7,34 @@ from checkov.runner_filter import RunnerFilter
class TestAzureInstancePassword(unittest.TestCase):
-
def test_summary(self):
- runner = Runner()
- current_dir = os.path.dirname(os.path.realpath(__file__))
+ # given
+ test_files_dir = Path(__file__).parent / "example_AzureInstancePassword"
+
+ # when
+ report = Runner().run(root_folder=str(test_files_dir), runner_filter=RunnerFilter(checks=[check.id]))
- test_files_dir = current_dir + "/example_AzureInstancePassword"
- report = runner.run(root_folder=test_files_dir,runner_filter=RunnerFilter(checks=[check.id]))
+ # then
summary = report.get_summary()
- self.assertEqual(summary['passed'], 2)
- self.assertEqual(summary['failed'], 1)
- self.assertEqual(summary['skipped'], 0)
- self.assertEqual(summary['parsing_errors'], 0)
+ passing_resources = {
+ "Microsoft.Compute/virtualMachines.enabled",
+ }
+ failing_resources = {
+ "Microsoft.Compute/virtualMachines.default",
+ }
+
+ passed_check_resources = {c.resource for c in report.passed_checks}
+ failed_check_resources = {c.resource for c in report.failed_checks}
+
+ self.assertEqual(summary["passed"], 1)
+ self.assertEqual(summary["failed"], 1)
+ self.assertEqual(summary["skipped"], 0)
+ self.assertEqual(summary["parsing_errors"], 0)
+
+ self.assertEqual(passing_resources, passed_check_resources)
+ self.assertEqual(failing_resources, failed_check_resources)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
diff --git a/tests/arm/checks/resource/test_AzureScaleSetPassword.py b/tests/arm/checks/resource/test_AzureScaleSetPassword.py
new file mode 100644
index 000000000..fdd6c2a9a
--- /dev/null
+++ b/tests/arm/checks/resource/test_AzureScaleSetPassword.py
@@ -0,0 +1,41 @@
+import unittest
+from pathlib import Path
+
+from checkov.arm.checks.resource.AzureScaleSetPassword import check
+from checkov.arm.runner import Runner
+from checkov.runner_filter import RunnerFilter
+
+
+class TestAzureScaleSetPassword(unittest.TestCase):
+ def test_summary(self):
+ # given
+ test_files_dir = Path(__file__).parent / "example_AzureScaleSetPassword"
+
+ # when
+ report = Runner().run(root_folder=str(test_files_dir), runner_filter=RunnerFilter(checks=[check.id]))
+
+ # then
+ summary = report.get_summary()
+
+ passing_resources = {
+ "Microsoft.Compute/virtualMachineScaleSets.enabled",
+ }
+ failing_resources = {
+ "Microsoft.Compute/virtualMachineScaleSets.default",
+ }
+
+ passed_check_resources = {c.resource for c in report.passed_checks}
+ failed_check_resources = {c.resource for c in report.failed_checks}
+
+ self.assertEqual(summary["passed"], 1)
+ self.assertEqual(summary["failed"], 1)
+ self.assertEqual(summary["skipped"], 0)
+ self.assertEqual(summary["parsing_errors"], 0)
+ self.assertEqual(summary["resource_count"], 3) # 1 unknown
+
+ self.assertEqual(passing_resources, passed_check_resources)
+ self.assertEqual(failing_resources, failed_check_resources)
+
+
+if __name__ == "__main__":
+ unittest.main()
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_added_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 1
},
"num_modified_files": 1
} | 2.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip3 install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": null,
"python": "3.7",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aiodns==3.2.0
aiohttp==3.8.6
aiomultiprocess==0.9.0
aiosignal==1.3.1
async-timeout==4.0.3
asynctest==0.13.0
attrs @ file:///croot/attrs_1668696182826/work
bc-python-hcl2==0.3.51
beautifulsoup4==4.13.3
boolean.py==4.0
boto3==1.33.13
botocore==1.33.13
cached-property==1.5.2
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
-e git+https://github.com/bridgecrewio/checkov.git@7fe3f47c300447dfdcc969fb2536e5d961312d42#egg=checkov
click==8.1.8
click-option-group==0.5.7
cloudsplaining==0.6.3
colorama==0.4.6
ConfigArgParse==1.7
coverage==7.2.7
cyclonedx-python-lib==4.2.3
deep-merge==0.0.4
defusedxml==0.7.1
detect-secrets==1.5.0
docker==6.1.3
dockerfile-parse==2.0.1
dpath==1.5.0
execnet==2.0.2
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
frozenlist==1.3.3
gitdb==4.0.12
GitPython==3.1.44
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
importlib-resources==5.12.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.1.6
jmespath==1.0.1
junit-xml==1.9
lark==1.1.9
license-expression==30.2.0
Markdown==3.4.4
MarkupSafe==2.1.5
multidict==6.0.5
networkx==2.6.3
packageurl-python==0.15.6
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
policy-sentry==0.12.15
policyuniverse==1.5.1.20231109
py @ file:///opt/conda/conda-bld/py_1644396412707/work
py-serializable==0.11.1
pycares==4.3.0
pycparser==2.21
pytest==7.1.2
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
PyYAML==6.0.1
requests==2.31.0
s3transfer==0.8.2
schema==0.7.7
semantic-version==2.10.0
six==1.17.0
smmap==5.0.2
sortedcontainers==2.4.0
soupsieve==2.4.1
tabulate==0.9.0
termcolor==2.3.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
tqdm==4.67.1
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
update-checker==0.18.0
urllib3==1.26.20
websocket-client==1.6.1
yarl==1.9.4
zipp @ file:///croot/zipp_1672387121353/work
| name: checkov
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- attrs=22.1.0=py37h06a4308_0
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- flit-core=3.6.0=pyhd3eb1b0_0
- importlib-metadata=4.11.3=py37h06a4308_0
- importlib_metadata=4.11.3=hd3eb1b0_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- packaging=22.0=py37h06a4308_0
- pip=22.3.1=py37h06a4308_0
- pluggy=1.0.0=py37h06a4308_1
- py=1.11.0=pyhd3eb1b0_0
- pytest=7.1.2=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py37h06a4308_0
- typing_extensions=4.4.0=py37h06a4308_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zipp=3.11.0=py37h06a4308_0
- zlib=1.2.13=h5eee18b_1
- pip:
- aiodns==3.2.0
- aiohttp==3.8.6
- aiomultiprocess==0.9.0
- aiosignal==1.3.1
- async-timeout==4.0.3
- asynctest==0.13.0
- bc-python-hcl2==0.3.51
- beautifulsoup4==4.13.3
- boolean-py==4.0
- boto3==1.33.13
- botocore==1.33.13
- cached-property==1.5.2
- cachetools==5.5.2
- cffi==1.15.1
- charset-normalizer==3.4.1
- click==8.1.8
- click-option-group==0.5.7
- cloudsplaining==0.6.3
- colorama==0.4.6
- configargparse==1.7
- coverage==7.2.7
- cyclonedx-python-lib==4.2.3
- deep-merge==0.0.4
- defusedxml==0.7.1
- detect-secrets==1.5.0
- docker==6.1.3
- dockerfile-parse==2.0.1
- dpath==1.5.0
- execnet==2.0.2
- frozenlist==1.3.3
- gitdb==4.0.12
- gitpython==3.1.44
- idna==3.10
- importlib-resources==5.12.0
- jinja2==3.1.6
- jmespath==1.0.1
- junit-xml==1.9
- lark==1.1.9
- license-expression==30.2.0
- markdown==3.4.4
- markupsafe==2.1.5
- multidict==6.0.5
- networkx==2.6.3
- packageurl-python==0.15.6
- policy-sentry==0.12.15
- policyuniverse==1.5.1.20231109
- py-serializable==0.11.1
- pycares==4.3.0
- pycparser==2.21
- pytest-asyncio==0.21.2
- pytest-cov==4.1.0
- pytest-mock==3.11.1
- pytest-xdist==3.5.0
- python-dateutil==2.9.0.post0
- pyyaml==6.0.1
- requests==2.31.0
- s3transfer==0.8.2
- schema==0.7.7
- semantic-version==2.10.0
- six==1.17.0
- smmap==5.0.2
- sortedcontainers==2.4.0
- soupsieve==2.4.1
- tabulate==0.9.0
- termcolor==2.3.0
- tqdm==4.67.1
- update-checker==0.18.0
- urllib3==1.26.20
- websocket-client==1.6.1
- yarl==1.9.4
prefix: /opt/conda/envs/checkov
| [
"tests/arm/checks/resource/test_AzureScaleSetPassword.py::TestAzureScaleSetPassword::test_summary",
"tests/arm/checks/resource/test_AzureInstancePassword.py::TestAzureInstancePassword::test_summary"
] | [] | [] | [] | Apache License 2.0 | 11,844 | 976 | [
"checkov/arm/checks/resource/AzureInstancePassword.py"
] |
|
Dorthu__openapi3-57 | ab4065a8cefac09253b3709121ad5b8b9241fb5a | 2021-12-19 19:59:05 | 063fe45b19d9e6f4e9b5f2dc10321072dd0695ec | diff --git a/openapi3/object_base.py b/openapi3/object_base.py
index b3e0a0d..9932822 100644
--- a/openapi3/object_base.py
+++ b/openapi3/object_base.py
@@ -217,75 +217,76 @@ class ObjectBase(object):
self._accessed_members.append(field)
ret = self.raw_element.get(field, None)
+ if ret is None:
+ return None
try:
- if ret is not None:
- if not isinstance(object_types, list):
- # maybe don't accept not-lists
- object_types = [object_types]
-
- if '*' in object_types and len(object_types) != 1:
- raise ValueError("Fields that accept any type must not specify any other types!")
-
- # if yaml loads a value that includes a unicode character in python2,
- # that value will come in as a ``unicode`` type instead of a ``str``.
- # For the purposes of this library, those are the same thing, so in
- # python2 only, we'll include ``unicode`` for any element that
- # accepts ``str`` types.
- if IS_PYTHON_2:
- if str in object_types:
- object_types += [unicode]
-
-
- if is_list:
- if not isinstance(ret, list):
- raise SpecError('Expected {}.{} to be a list of [{}], got {}'.format(
- self.get_path, field, ','.join([str(c) for c in object_types]),
- type(ret)),
- path=self.path,
- element=self)
- ret = self.parse_list(ret, object_types, field)
- elif is_map:
- if not isinstance(ret, dict):
- raise SpecError('Expected {}.{} to be a Map of string: [{}], got {}'.format(
- self.get_path, field, ','.join([str(c) for c in object_types]),
- type(ret)),
- path=self.path,
- element=self)
- ret = Map(self.path + [field], ret, object_types, self._root)
- else:
- accepts_string = str in object_types
- found_type = False
-
- for t in object_types:
- if t == "*":
- found_type = True
- break
+ if not isinstance(object_types, list):
+ # maybe don't accept not-lists
+ object_types = [object_types]
+
+ if '*' in object_types and len(object_types) != 1:
+ raise ValueError("Fields that accept any type must not specify any other types!")
+
+ # if yaml loads a value that includes a unicode character in python2,
+ # that value will come in as a ``unicode`` type instead of a ``str``.
+ # For the purposes of this library, those are the same thing, so in
+ # python2 only, we'll include ``unicode`` for any element that
+ # accepts ``str`` types.
+ if IS_PYTHON_2:
+ if str in object_types:
+ object_types += [unicode]
+
+
+ if is_list:
+ if not isinstance(ret, list):
+ raise SpecError('Expected {}.{} to be a list of [{}], got {}'.format(
+ self.get_path, field, ','.join([str(c) for c in object_types]),
+ type(ret)),
+ path=self.path,
+ element=self)
+ ret = self.parse_list(ret, object_types, field)
+ elif is_map:
+ if not isinstance(ret, dict):
+ raise SpecError('Expected {}.{} to be a Map of string: [{}], got {}'.format(
+ self.get_path, field, ','.join([str(c) for c in object_types]),
+ type(ret)),
+ path=self.path,
+ element=self)
+ ret = Map(self.path + [field], ret, object_types, self._root)
+ else:
+ accepts_string = str in object_types
+ found_type = False
+
+ for t in object_types:
+ if t == "*":
+ found_type = True
+ break
- if t == str:
- # try to parse everything else first
- continue
-
- if isinstance(t, str):
- # we were given the name of a subclass of ObjectBase,
- # attempt to parse ret as that type
- python_type = ObjectBase.get_object_type(t)
-
- if python_type.can_parse(ret):
- ret = python_type(self.path + [field], ret, self._root)
- found_type = True
- break
- elif isinstance(ret, t):
- # it's already the type we need
+ if t == str:
+ # try to parse everything else first
+ continue
+
+ if isinstance(t, str):
+ # we were given the name of a subclass of ObjectBase,
+ # attempt to parse ret as that type
+ python_type = ObjectBase.get_object_type(t)
+
+ if python_type.can_parse(ret):
+ ret = python_type(self.path + [field], ret, self._root)
found_type = True
break
+ elif isinstance(ret, t):
+ # it's already the type we need
+ found_type = True
+ break
- if not found_type:
- if accepts_string and isinstance(ret, str):
- found_type = True
+ if not found_type:
+ if accepts_string and isinstance(ret, str):
+ found_type = True
- if not found_type:
- raise_on_unknown_type(self, field, object_types, ret)
+ if not found_type:
+ raise_on_unknown_type(self, field, object_types, ret)
except SpecError as e:
if self._root.validation_mode:
self._root.log_spec_error(e)
diff --git a/openapi3/openapi.py b/openapi3/openapi.py
index c84a8f7..81e4aba 100644
--- a/openapi3/openapi.py
+++ b/openapi3/openapi.py
@@ -64,6 +64,12 @@ class OpenAPI(ObjectBase):
TODO - this should support more than just HTTP Auth
"""
+
+ # authentication is optional and can be disabled
+ if security_scheme is None:
+ self._security = None
+ return
+
if security_scheme not in self.components.securitySchemes:
raise ValueError('{} does not accept security scheme {}'.format(
self.info.title, security_scheme))
diff --git a/openapi3/paths.py b/openapi3/paths.py
index f4cae87..2c69a19 100644
--- a/openapi3/paths.py
+++ b/openapi3/paths.py
@@ -186,6 +186,9 @@ class Operation(ObjectBase):
# apiKey in query header data
self._request.headers[ss.name] = value
+ if ss.in_ == 'cookie':
+ self._request.cookies ={ss.name:value}
+
def _request_handle_parameters(self, parameters={}):
# Parameters
path_parameters = {}
@@ -356,17 +359,22 @@ class SecurityRequirement(ObjectBase):
def _parse_data(self):
"""
"""
- # these only ever have one key
- self.name = [c for c in self.raw_element.keys()][0]
- self.types = self._get(self.name, str, is_list=True)
+ # usually these only ever have one key
+ if len(self.raw_element.keys()) == 1:
+ self.name = [c for c in self.raw_element.keys()][0]
+ self.types = self._get(self.name, str, is_list=True)
+ elif len(self.raw_element.keys()) == 0:
+ # optional
+ self.name = self.types = None
+
@classmethod
def can_parse(cls, dct):
"""
This needs to ignore can_parse since the objects it's parsing are not
- regular - they must always have only one key though.
+ regular - they must always have only one key though or be empty for Optional Security Requirements
"""
- return len(dct.keys()) == 1 and isinstance([c for c in dct.values()][0], list)
+ return len(dct.keys()) == 1 and isinstance([c for c in dct.values()][0], list) or len(dct.keys()) == 0
def __getstate__(self):
return {self.name: self.types}
diff --git a/openapi3/schemas.py b/openapi3/schemas.py
index 7fc64bf..0fcb94b 100644
--- a/openapi3/schemas.py
+++ b/openapi3/schemas.py
@@ -116,10 +116,7 @@ class Schema(ObjectBase):
# TODO - perhaps assert that the type of data matches the type we
# expected
return data
- elif self.type == "array":
- return [self.items.get_type()(i, self.items) for i in data]
- else:
- return self.get_type()(data, self)
+ return self.get_type()(data, self)
def get_request_type(self):
"""
| openapi3.errors.SpecError: Could not parse paths./api/v1/auth/login/.post.security.2, expected to be one of [['SecurityRequirement']]
Python test client:
```python
import yaml
import requests
from openapi3 import OpenAPI
url = 'http://localhost/schema_openapi/'
response = requests.get(url, allow_redirects=True)
specifications = yaml.safe_load(response.content)
print(specifications)
api = OpenAPI(specifications)
print(dir(api))
```
Schema (localhost/schema_openapi/):
```yaml
openapi: 3.0.3
info:
title: ''
version: 0.0.0
paths:
/api/v1/auth/login/:
post:
operationId: api_v1_auth_login_create
description: |-
Check the credentials and return the REST Token
if the credentials are valid and authenticated.
Calls Django Auth login method to register User ID
in Django session framework
Accept the following POST parameters: username, password
Return the REST Framework Token Object's key.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/LoginRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
- {}
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Login'
description: ''
/api/v1/auth/logout/:
get:
operationId: api_v1_auth_logout_retrieve
description: |-
Calls Django logout method and delete the Token object
assigned to the current User object.
Accepts/Returns nothing.
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
- {}
responses:
'200':
description: No response body
post:
operationId: api_v1_auth_logout_create
description: |-
Calls Django logout method and delete the Token object
assigned to the current User object.
Accepts/Returns nothing.
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
- {}
responses:
'200':
description: No response body
/api/v1/auth/password/change/:
post:
operationId: api_v1_auth_password_change_create
description: |-
Calls Django Auth SetPasswordForm save method.
Accepts the following POST parameters: new_password1, new_password2
Returns the success/fail message.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordChangeRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordChange'
description: ''
/api/v1/auth/password/reset/:
post:
operationId: api_v1_auth_password_reset_create
description: |-
Calls Django Auth PasswordResetForm save method.
Accepts the following POST parameters: email
Returns the success/fail message.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordResetRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
- {}
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordReset'
description: ''
/api/v1/auth/password/reset/confirm/:
post:
operationId: api_v1_auth_password_reset_confirm_create
description: |-
Password reset e-mail link is confirmed, therefore
this resets the user's password.
Accepts the following POST parameters: token, uid,
new_password1, new_password2
Returns the success/fail message.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordResetConfirmRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
- {}
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/PasswordResetConfirm'
description: ''
/api/v1/auth/user/:
get:
operationId: api_v1_auth_user_retrieve
description: |-
Reads and updates UserModel fields
Accepts GET, PUT, PATCH methods.
Default accepted fields: username, first_name, last_name
Default display fields: pk, username, email, first_name, last_name
Read-only fields: pk, email
Returns UserModel fields.
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetails'
description: ''
put:
operationId: api_v1_auth_user_update
description: |-
Reads and updates UserModel fields
Accepts GET, PUT, PATCH methods.
Default accepted fields: username, first_name, last_name
Default display fields: pk, username, email, first_name, last_name
Read-only fields: pk, email
Returns UserModel fields.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetailsRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetails'
description: ''
patch:
operationId: api_v1_auth_user_partial_update
description: |-
Reads and updates UserModel fields
Accepts GET, PUT, PATCH methods.
Default accepted fields: username, first_name, last_name
Default display fields: pk, username, email, first_name, last_name
Read-only fields: pk, email
Returns UserModel fields.
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetailsRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/UserDetails'
description: ''
/api/v1/pages/:
get:
operationId: api_v1_pages_list
description: ''
parameters:
- in: query
name: content
schema:
type: string
- in: query
name: created
schema:
type: string
format: date-time
- in: query
name: id
schema:
type: integer
- in: query
name: order
schema:
type: array
items:
type: string
enum:
- -id
- -order
- -title
- id
- order
- title
description: Ordenamiento
explode: false
style: form
- in: query
name: title
schema:
type: string
- in: query
name: updated
schema:
type: string
format: date-time
- in: query
name: user
schema:
type: integer
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Page'
description: ''
post:
operationId: api_v1_pages_create
description: ''
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PageRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/Page'
description: ''
/api/v1/pages/{id}/:
get:
operationId: api_v1_pages_retrieve
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this página.
required: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Page'
description: ''
put:
operationId: api_v1_pages_update
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this página.
required: true
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PageRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Page'
description: ''
patch:
operationId: api_v1_pages_partial_update
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this página.
required: true
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/PageRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Page'
description: ''
delete:
operationId: api_v1_pages_destroy
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this página.
required: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'204':
description: No response body
/api/v1/stocks/:
get:
operationId: api_v1_stocks_list
description: ''
parameters:
- in: query
name: created
schema:
type: string
format: date-time
- in: query
name: id
schema:
type: integer
- in: query
name: name
schema:
type: string
- in: query
name: order
schema:
type: array
items:
type: string
enum:
- -name
- -price
- name
- price
description: Ordenamiento
explode: false
style: form
- in: query
name: price
schema:
type: number
format: float
- in: query
name: update
schema:
type: string
format: date-time
- in: query
name: user
schema:
type: integer
nullable: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Stock'
description: ''
post:
operationId: api_v1_stocks_create
description: ''
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/StockRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/Stock'
description: ''
/api/v1/stocks/{id}/:
get:
operationId: api_v1_stocks_retrieve
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this stock.
required: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Stock'
description: ''
put:
operationId: api_v1_stocks_update
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this stock.
required: true
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/StockRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Stock'
description: ''
patch:
operationId: api_v1_stocks_partial_update
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this stock.
required: true
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/StockRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Stock'
description: ''
delete:
operationId: api_v1_stocks_destroy
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this stock.
required: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'204':
description: No response body
/api/v1/temperature/:
get:
operationId: api_v1_temperature_list
description: ''
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Temperature'
description: ''
post:
operationId: api_v1_temperature_create
description: ''
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TemperatureRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'201':
content:
application/json:
schema:
$ref: '#/components/schemas/Temperature'
description: ''
/api/v1/temperature/{id}/:
get:
operationId: api_v1_temperature_retrieve
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this temperature.
required: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Temperature'
description: ''
put:
operationId: api_v1_temperature_update
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this temperature.
required: true
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TemperatureRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Temperature'
description: ''
patch:
operationId: api_v1_temperature_partial_update
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this temperature.
required: true
tags:
- api
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/TemperatureRequest'
required: true
security:
- cookieAuth: []
- tokenAuth: []
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/Temperature'
description: ''
delete:
operationId: api_v1_temperature_destroy
description: ''
parameters:
- in: path
name: id
schema:
type: integer
description: A unique integer value identifying this temperature.
required: true
tags:
- api
security:
- cookieAuth: []
- tokenAuth: []
responses:
'204':
description: No response body
/schema_openapi/:
get:
operationId: schema_openapi_retrieve
description: |-
OpenApi3 schema for this API. Format can be selected via content negotiation.
- YAML: application/vnd.oai.openapi
- JSON: application/vnd.oai.openapi+json
parameters:
- in: query
name: format
schema:
type: string
enum:
- json
- yaml
- in: query
name: lang
schema:
type: string
enum:
- af
- ar
- ast
- az
- be
- bg
- bn
- br
- bs
- ca
- cs
- cy
- da
- de
- dsb
- el
- en
- en-au
- en-gb
- eo
- es
- es-ar
- es-co
- es-mx
- es-ni
- es-ve
- et
- eu
- fa
- fi
- fr
- fy
- ga
- gd
- gl
- he
- hi
- hr
- hsb
- hu
- hy
- ia
- id
- io
- is
- it
- ja
- ka
- kab
- kk
- km
- kn
- ko
- lb
- lt
- lv
- mk
- ml
- mn
- mr
- my
- nb
- ne
- nl
- nn
- os
- pa
- pl
- pt
- pt-br
- ro
- ru
- sk
- sl
- sq
- sr
- sr-latn
- sv
- sw
- ta
- te
- th
- tr
- tt
- udm
- uk
- ur
- uz
- vi
- zh-hans
- zh-hant
tags:
- schema_openapi
security:
- cookieAuth: []
- tokenAuth: []
- {}
responses:
'200':
content:
application/vnd.oai.openapi:
schema:
type: object
additionalProperties: {}
application/yaml:
schema:
type: object
additionalProperties: {}
application/vnd.oai.openapi+json:
schema:
type: object
additionalProperties: {}
application/json:
schema:
type: object
additionalProperties: {}
description: ''
components:
schemas:
Login:
type: object
properties:
username:
type: string
email:
type: string
format: email
password:
type: string
required:
- password
LoginRequest:
type: object
properties:
username:
type: string
email:
type: string
format: email
password:
type: string
required:
- password
Page:
type: object
properties:
id:
type: integer
readOnly: true
title:
type: string
maxLength: 200
content:
type: string
order:
type: integer
maximum: 32767
minimum: -32768
created:
type: string
format: date-time
readOnly: true
updated:
type: string
format: date-time
readOnly: true
user:
type: integer
required:
- content
- created
- id
- title
- updated
- user
PageRequest:
type: object
properties:
title:
type: string
maxLength: 200
content:
type: string
order:
type: integer
maximum: 32767
minimum: -32768
user:
type: integer
required:
- content
- title
- user
PasswordChange:
type: object
properties:
new_password1:
type: string
maxLength: 128
new_password2:
type: string
maxLength: 128
required:
- new_password1
- new_password2
PasswordChangeRequest:
type: object
properties:
new_password1:
type: string
maxLength: 128
new_password2:
type: string
maxLength: 128
required:
- new_password1
- new_password2
PasswordReset:
type: object
description: Serializer for requesting a password reset e-mail.
properties:
email:
type: string
format: email
required:
- email
PasswordResetConfirm:
type: object
description: Serializer for requesting a password reset e-mail.
properties:
new_password1:
type: string
maxLength: 128
new_password2:
type: string
maxLength: 128
uid:
type: string
token:
type: string
required:
- new_password1
- new_password2
- token
- uid
PasswordResetConfirmRequest:
type: object
description: Serializer for requesting a password reset e-mail.
properties:
new_password1:
type: string
maxLength: 128
new_password2:
type: string
maxLength: 128
uid:
type: string
token:
type: string
required:
- new_password1
- new_password2
- token
- uid
PasswordResetRequest:
type: object
description: Serializer for requesting a password reset e-mail.
properties:
email:
type: string
format: email
required:
- email
Stock:
type: object
properties:
id:
type: integer
readOnly: true
name:
type: string
maxLength: 128
price:
type: number
format: float
created:
type: string
format: date-time
readOnly: true
update:
type: string
format: date-time
readOnly: true
user:
type: integer
nullable: true
required:
- created
- id
- name
- price
- update
StockRequest:
type: object
properties:
name:
type: string
maxLength: 128
price:
type: number
format: float
user:
type: integer
nullable: true
required:
- name
- price
Temperature:
type: object
properties:
time:
type: string
format: date-time
temperature:
type: number
format: float
required:
- temperature
TemperatureRequest:
type: object
properties:
time:
type: string
format: date-time
temperature:
type: number
format: float
required:
- temperature
UserDetails:
type: object
description: User model w/o password
properties:
pk:
type: integer
readOnly: true
username:
type: string
description: 'Requerido. 150 carácteres como máximo. Únicamente letras,
dígitos y @/./+/-/_ '
pattern: ^[\w.@+-]+$
maxLength: 150
email:
type: string
format: email
readOnly: true
first_name:
type: string
maxLength: 30
last_name:
type: string
maxLength: 150
required:
- email
- pk
- username
UserDetailsRequest:
type: object
description: User model w/o password
properties:
username:
type: string
description: 'Requerido. 150 carácteres como máximo. Únicamente letras,
dígitos y @/./+/-/_ '
pattern: ^[\w.@+-]+$
maxLength: 150
first_name:
type: string
maxLength: 30
last_name:
type: string
maxLength: 150
required:
- username
securitySchemes:
cookieAuth:
type: apiKey
in: cookie
name: Session
tokenAuth:
type: apiKey
in: header
name: Authorization
description: Token-based authentication with required prefix "Token"
```
Exception result:
```
Traceback (most recent call last):
File "E:/dev/django_test/chat/client/client_drf.py", line 9, in <module>
api = OpenAPI(specifications)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\openapi.py", line 44, in __init__
super(OpenAPI, self).__init__([], raw_document, self)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 56, in __init__
self._parse_data()
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\openapi.py", line 134, in _parse_data
self.paths = self._get('paths', ['Path'], is_map=True)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 193, in _get
ret = Map(self.path + [field], ret, object_types, self._root)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 516, in __init__
dct[k] = t(path + [k], v, self._root)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 56, in __init__
self._parse_data()
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\paths.py", line 36, in _parse_data
self.post = self._get('post', 'Operation')
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 209, in _get
ret = python_type(self.path + [field], ret, self._root)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 56, in __init__
self._parse_data()
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\paths.py", line 103, in _parse_data
self.security = self._get('security', ['SecurityRequirement'], is_list=True)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 185, in _get
ret = self.parse_list(ret, object_types, field)
File "C:\ProgramData\Miniconda3\envs\django_test3\lib\site-packages\openapi3\object_base.py", line 378, in parse_list
raise SpecError('Could not parse {}.{}, expected to be one of [{}]'.format(
openapi3.errors.SpecError: Could not parse paths./api/v1/auth/login/.post.security.2, expected to be one of [['SecurityRequirement']]
```
The schema is generated with drf-spectacular, ¿maybe is a generation problem?
Thanks.
Greats. Ricardo.
| Dorthu/openapi3 | diff --git a/tests/conftest.py b/tests/conftest.py
index 5f4711d..29e9003 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -136,3 +136,10 @@ def with_broken_links():
Provides a spec with broken links defined
"""
yield _get_parsed_yaml("with-broken-links.yaml")
+
[email protected]
+def with_securityparameters():
+ """
+ Provides a spec with security parameters
+ """
+ yield _get_parsed_yaml("with-securityparameters.yaml")
diff --git a/tests/fixtures/with-securityparameters.yaml b/tests/fixtures/with-securityparameters.yaml
new file mode 100644
index 0000000..a77befa
--- /dev/null
+++ b/tests/fixtures/with-securityparameters.yaml
@@ -0,0 +1,88 @@
+openapi: 3.0.3
+info:
+ title: ''
+ version: 0.0.0
+servers:
+ - url: http://127.0.0.1/api
+
+security:
+ - {}
+ - cookieAuth: []
+
+paths:
+ /api/v1/auth/info/:
+ get:
+ operationId: api_v1_auth_login_info
+ responses:
+ '200':
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Login'
+ description: ''
+
+ /api/v1/auth/login/:
+ post:
+ operationId: api_v1_auth_login_create
+ description: |-
+ Check the credentials and return the REST Token
+ if the credentials are valid and authenticated.
+ Calls Django Auth login method to register User ID
+ in Django session framework
+
+ Accept the following POST parameters: username, password
+ Return the REST Framework Token Object's key.
+ tags:
+ - api
+ requestBody:
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/LoginRequest'
+ required: true
+ responses:
+ '200':
+ content:
+ application/json:
+ schema:
+ $ref: '#/components/schemas/Login'
+ description: ''
+ security:
+ - cookieAuth: []
+ - tokenAuth: []
+ - paramAuth: []
+ - basicAuth: []
+ - digestAuth: []
+ - bearerAuth: []
+ - {}
+
+components:
+ schemas:
+ Login:
+ type: string
+ LoginRequest:
+ type: string
+ securitySchemes:
+ cookieAuth:
+ type: apiKey
+ in: cookie
+ name: Session
+ tokenAuth:
+ type: apiKey
+ in: header
+ name: Authorization
+ description: Token-based authentication with required prefix "Token"
+ paramAuth:
+ type: apiKey
+ in: query
+ name: auth
+ basicAuth:
+ type: http
+ scheme: basic
+ digestAuth:
+ type: http
+ scheme: digest
+ bearerAuth:
+ type: http
+ scheme: bearer
+
diff --git a/tests/parsing_test.py b/tests/parsing_test.py
index 85a646b..3637c44 100644
--- a/tests/parsing_test.py
+++ b/tests/parsing_test.py
@@ -111,3 +111,9 @@ def test_parsing_broken_links(with_broken_links):
"operationId and operationRef are mutually exclusive, only one of them is allowed",
"operationId and operationRef are mutually exclusive, one of them must be specified",
]) == sorted(error_strs)
+
+
+def test_securityparameters(with_securityparameters):
+ spec = OpenAPI(with_securityparameters, validate=True)
+ errors = spec.errors()
+ assert len(errors) == 0
diff --git a/tests/path_test.py b/tests/path_test.py
index a320e82..26510e4 100644
--- a/tests/path_test.py
+++ b/tests/path_test.py
@@ -1,7 +1,14 @@
"""
This file tests that paths are parsed and populated correctly
"""
+import base64
+import uuid
+
+from unittest.mock import patch, MagicMock
+from urllib.parse import urlparse
+
import pytest
+import requests.auth
from openapi3 import OpenAPI
from openapi3.schemas import Schema
@@ -88,3 +95,62 @@ def test_operation_populated(petstore_expanded_spec):
assert con2.schema is not None
# again, test ref resolution elsewhere
assert type(con2.schema) == Schema
+
+
+def test_securityparameters(with_securityparameters):
+ api = OpenAPI(with_securityparameters)
+ r = patch("requests.sessions.Session.send")
+
+ auth=str(uuid.uuid4())
+
+ # global security
+ api.authenticate('cookieAuth', auth)
+ resp = MagicMock(status_code=200, headers={"Content-Type":"application/json"})
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+
+
+ # path
+ api.authenticate('tokenAuth', auth)
+ resp = MagicMock(status_code=200, headers={"Content-Type": "application/json"})
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+ assert r.call_args.args[0].headers['Authorization'] == auth
+
+ api.authenticate('paramAuth', auth)
+ resp = MagicMock(status_code=200, headers={"Content-Type": "application/json"})
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+
+ parsed_url = urlparse(r.call_args.args[0].url)
+ parsed_url.query == auth
+
+ api.authenticate('cookieAuth', auth)
+ resp = MagicMock(status_code=200, headers={"Content-Type":"application/json"}, json=lambda: [])
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+ assert r.call_args.args[0].headers["Cookie"] == "Session=%s" % (auth,)
+
+ api.authenticate('basicAuth', (auth, auth))
+ resp = MagicMock(status_code=200, headers={"Content-Type":"application/json"}, json=lambda: [])
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+ r.call_args.args[0].headers["Authorization"].split(" ")[1] == base64.b64encode((auth + ':' + auth).encode()).decode()
+
+ api.authenticate('digestAuth', (auth,auth))
+ resp = MagicMock(status_code=200, headers={"Content-Type":"application/json"}, json=lambda: [])
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+ assert requests.auth.HTTPDigestAuth.handle_401 == r.call_args.args[0].hooks["response"][0].__func__
+
+ api.authenticate('bearerAuth', auth)
+ resp = MagicMock(status_code=200, headers={"Content-Type":"application/json"}, json=lambda: [])
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+ assert r.call_args.args[0].headers["Authorization"] == "Bearer %s" % (auth,)
+
+ api.authenticate(None, None)
+ resp = MagicMock(status_code=200, headers={"Content-Type":"application/json"})
+ with patch("requests.sessions.Session.send", return_value=resp) as r:
+ api.call_api_v1_auth_login_create(data={}, parameters={})
+ api.call_api_v1_auth_login_create(data={}, parameters={})
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 3
},
"num_modified_files": 4
} | 1.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | certifi==2025.1.31
charset-normalizer==3.4.1
exceptiongroup==1.2.2
idna==3.10
iniconfig==2.1.0
-e git+https://github.com/Dorthu/openapi3.git@ab4065a8cefac09253b3709121ad5b8b9241fb5a#egg=openapi3
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
PyYAML==6.0.2
requests==2.32.3
tomli==2.2.1
urllib3==2.3.0
| name: openapi3
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- certifi==2025.1.31
- charset-normalizer==3.4.1
- exceptiongroup==1.2.2
- idna==3.10
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- pyyaml==6.0.2
- requests==2.32.3
- tomli==2.2.1
- urllib3==2.3.0
prefix: /opt/conda/envs/openapi3
| [
"tests/parsing_test.py::test_securityparameters",
"tests/path_test.py::test_securityparameters"
] | [] | [
"tests/parsing_test.py::test_parse_from_yaml",
"tests/parsing_test.py::test_parsing_fails",
"tests/parsing_test.py::test_parsing_broken_refernece",
"tests/parsing_test.py::test_parsing_wrong_parameter_name",
"tests/parsing_test.py::test_parsing_dupe_operation_id",
"tests/parsing_test.py::test_parsing_parameter_name_with_underscores",
"tests/parsing_test.py::test_object_example",
"tests/parsing_test.py::test_parsing_float_validation",
"tests/parsing_test.py::test_parsing_with_links",
"tests/parsing_test.py::test_parsing_broken_links",
"tests/path_test.py::test_paths_exist",
"tests/path_test.py::test_operations_exist",
"tests/path_test.py::test_operation_populated"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,847 | 2,083 | [
"openapi3/object_base.py",
"openapi3/openapi.py",
"openapi3/paths.py",
"openapi3/schemas.py"
] |
|
Unidata__MetPy-2271 | 4f1e6bb18d0a16a421292dfbd21d03ed983a7952 | 2021-12-21 00:36:21 | 2d89707ba57a5bd8395bd673ce0828a7db3a1fd9 | diff --git a/src/metpy/interpolate/points.py b/src/metpy/interpolate/points.py
index aab9f9c5d7..a68c7d4b7b 100644
--- a/src/metpy/interpolate/points.py
+++ b/src/metpy/interpolate/points.py
@@ -3,6 +3,7 @@
# SPDX-License-Identifier: BSD-3-Clause
"""Interpolate data valid at one set of points to another in multiple dimensions."""
+import functools
import logging
import numpy as np
@@ -11,6 +12,7 @@ from scipy.spatial import cKDTree, ConvexHull, Delaunay, qhull
from . import geometry, tools
from ..package_tools import Exporter
+from ..units import units
exporter = Exporter(globals())
@@ -193,19 +195,21 @@ def natural_neighbor_to_points(points, values, xi):
"""
tri = Delaunay(points)
-
members, circumcenters = geometry.find_natural_neighbors(tri, xi)
- img = np.empty(shape=(xi.shape[0]), dtype=values.dtype)
- img.fill(np.nan)
-
- for ind, (grid, neighbors) in enumerate(members.items()):
+ if hasattr(values, 'units'):
+ org_units = values.units
+ values = values.magnitude
+ else:
+ org_units = None
- if len(neighbors) > 0:
+ img = np.asarray([natural_neighbor_point(*np.array(points).transpose(),
+ values, xi[grid], tri, neighbors, circumcenters)
+ if len(neighbors) > 0 else np.nan
+ for grid, neighbors in members.items()])
- points_transposed = np.array(points).transpose()
- img[ind] = natural_neighbor_point(points_transposed[0], points_transposed[1],
- values, xi[grid], tri, neighbors, circumcenters)
+ if org_units:
+ img = units.Quantity(img, org_units)
return img
@@ -216,7 +220,7 @@ def inverse_distance_to_points(points, values, xi, r, gamma=None, kappa=None, mi
r"""Generate an inverse distance weighting interpolation to the given points.
Values are assigned to the given interpolation points based on either [Cressman1959]_ or
- [Barnes1964]_. The Barnes implementation used here based on [Koch1983]_.
+ [Barnes1964]_. The Barnes implementation used here is based on [Koch1983]_.
Parameters
----------
@@ -227,8 +231,7 @@ def inverse_distance_to_points(points, values, xi, r, gamma=None, kappa=None, mi
xi: array_like, shape (M, 2)
Points to interpolate the data onto.
r: float
- Radius from grid center, within which observations
- are considered and weighted.
+ Radius from grid center, within which observations are considered and weighted.
gamma: float
Adjustable smoothing parameter for the barnes interpolation. Default None.
kappa: float
@@ -250,27 +253,28 @@ def inverse_distance_to_points(points, values, xi, r, gamma=None, kappa=None, mi
inverse_distance_to_grid
"""
- obs_tree = cKDTree(points)
+ if kind == 'cressman':
+ interp_func = functools.partial(cressman_point, radius=r)
+ elif kind == 'barnes':
+ interp_func = functools.partial(barnes_point, kappa=kappa, gamma=gamma)
+ else:
+ raise ValueError(f'{kind} interpolation not supported.')
+ obs_tree = cKDTree(points)
indices = obs_tree.query_ball_point(xi, r=r)
- img = np.empty(shape=(xi.shape[0]), dtype=values.dtype)
- img.fill(np.nan)
-
- for idx, (matches, grid) in enumerate(zip(indices, xi)):
- if len(matches) >= min_neighbors:
-
- x1, y1 = obs_tree.data[matches].T
- values_subset = values[matches]
- dists = geometry.dist_2(grid[0], grid[1], x1, y1)
+ if hasattr(values, 'units'):
+ org_units = values.units
+ values = values.magnitude
+ else:
+ org_units = None
- if kind == 'cressman':
- img[idx] = cressman_point(dists, values_subset, r)
- elif kind == 'barnes':
- img[idx] = barnes_point(dists, values_subset, kappa, gamma)
+ img = np.asarray([interp_func(geometry.dist_2(*grid, *obs_tree.data[matches].T),
+ values[matches]) if len(matches) >= min_neighbors else np.nan
+ for matches, grid in zip(indices, xi)])
- else:
- raise ValueError(f'{kind} interpolation not supported.')
+ if org_units:
+ img = units.Quantity(img, org_units)
return img
@@ -312,7 +316,7 @@ def interpolate_to_points(points, values, xi, interp_type='linear', minimum_neig
gamma: float
Adjustable smoothing parameter for the barnes interpolation. Default 0.25.
kappa_star: float
- Response parameter for barnes interpolation, specified nondimensionally
+ Response parameter for barnes interpolation, specified non-dimensionally
in terms of the Nyquist. Default 5.052
search_radius: float
A search radius to use for the Barnes and Cressman interpolation schemes.
@@ -343,13 +347,24 @@ def interpolate_to_points(points, values, xi, interp_type='linear', minimum_neig
"""
# If this is a type that `griddata` handles, hand it along to `griddata`
if interp_type in ['linear', 'nearest', 'cubic']:
- return griddata(points, values, xi, method=interp_type)
+ if hasattr(values, 'units'):
+ org_units = values.units
+ values = values.magnitude
+ else:
+ org_units = None
+
+ ret = griddata(points, values, xi, method=interp_type)
+
+ if org_units:
+ ret = units.Quantity(ret, org_units)
+
+ return ret
# If this is natural neighbor, hand it along to `natural_neighbor`
elif interp_type == 'natural_neighbor':
return natural_neighbor_to_points(points, values, xi)
- # If this is Barnes/Cressman, determine search_radios and hand it along to
+ # If this is Barnes/Cressman, determine search_radius and hand it along to
# `inverse_distance`
elif interp_type in ['cressman', 'barnes']:
ave_spacing = tools.average_spacing(points)
@@ -368,14 +383,25 @@ def interpolate_to_points(points, values, xi, interp_type='linear', minimum_neig
# If this is radial basis function, make the interpolator and apply it
elif interp_type == 'rbf':
-
points_transposed = np.array(points).transpose()
xi_transposed = np.array(xi).transpose()
+
+ if hasattr(values, 'units'):
+ org_units = values.units
+ values = values.magnitude
+ else:
+ org_units = None
+
rbfi = Rbf(points_transposed[0], points_transposed[1], values, function=rbf_func,
smooth=rbf_smooth)
- return rbfi(xi_transposed[0], xi_transposed[1])
+ ret = rbfi(xi_transposed[0], xi_transposed[1])
+
+ if org_units:
+ ret = units.Quantity(ret, org_units)
+
+ return ret
else:
- raise ValueError('Interpolation option not available. '
+ raise ValueError(f'Interpolation option {interp_type} not available. '
'Try: linear, nearest, cubic, natural_neighbor, '
'barnes, cressman, rbf')
diff --git a/src/metpy/io/metar.py b/src/metpy/io/metar.py
index 6c19248e06..53fea540cb 100644
--- a/src/metpy/io/metar.py
+++ b/src/metpy/io/metar.py
@@ -11,7 +11,7 @@ import warnings
import numpy as np
import pandas as pd
-from ._metar_parser.metar_parser import parse, ParseError, TreeNode
+from ._metar_parser.metar_parser import parse, ParseError
from ._tools import open_as_needed
from .station_data import station_info
from ..package_tools import Exporter
@@ -61,23 +61,6 @@ col_units = {'station_id': None,
'current_wx3_symbol': None}
-def _tree_repr_(self):
- """Produce string representation of a TreeNodex object."""
- rep = self.__class__.__name__ + '('
- args = []
- for key, value in self.__dict__.items():
- if key == 'elements':
- continue
- args.append(key + '=' + repr(value))
- dict_str = ', '.join(args) + ')'
- rep += dict_str
- return rep
-
-
-# Monkey patch to improve debugging
-TreeNode.__repr__ = _tree_repr_
-
-
@exporter.export
def parse_metar_to_dataframe(metar_text, *, year=None, month=None):
"""Parse a single METAR report into a Pandas DataFrame.
| Support units in `inverse_distance_to_points`
Currently `inverse_distance_to_points` chokes when given `values` having units because it does:
https://github.com/Unidata/MetPy/blob/749cf07ec2d15e644f822e45796bd5b20dc3dd7c/src/metpy/interpolate/points.py#L257-L258
This means when calling `interpolate_to_grid` using either Cressman or Barnes, you get a nasty traceback:
```pytb
---------------------------------------------------------------------------
DimensionalityError Traceback (most recent call last)
~/miniconda3/envs/py39/lib/python3.9/site-packages/pint/quantity.py in __float__(self)
896 return float(self._convert_magnitude_not_inplace(UnitsContainer()))
--> 897 raise DimensionalityError(self._units, "dimensionless")
898
DimensionalityError: Cannot convert from 'kelvin' to 'dimensionless'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
/var/folders/r8/bhrhn4m56lgdckj491rm6_w40000gp/T/ipykernel_52617/3693995647.py in <module>
1 grdx = 25000
----> 2 thgridx,thgridy,theta = interpolate_to_grid(x_masked,y_masked, potemp,interp_type='barnes', kappa_star=10, gamma=0.5,hres=grdx)
3
4 print(np.shape(thgridx))
5 print(np.unique(theta))
~/repos/metpy/src/metpy/pandas.py in wrapper(*args, **kwargs)
19 kwargs = {name: (v.values if isinstance(v, pd.Series) else v)
20 for name, v in kwargs.items()}
---> 21 return func(*args, **kwargs)
22 return wrapper
~/repos/metpy/src/metpy/interpolate/grid.py in interpolate_to_grid(x, y, z, interp_type, hres, minimum_neighbors, gamma, kappa_star, search_radius, rbf_func, rbf_smooth, boundary_coords)
298 points_obs = np.array(list(zip(x, y)))
299 points_grid = generate_grid_coords(grid_x, grid_y)
--> 300 img = interpolate_to_points(points_obs, z, points_grid, interp_type=interp_type,
301 minimum_neighbors=minimum_neighbors, gamma=gamma,
302 kappa_star=kappa_star, search_radius=search_radius,
~/repos/metpy/src/metpy/interpolate/points.py in interpolate_to_points(points, values, xi, interp_type, minimum_neighbors, gamma, kappa_star, search_radius, rbf_func, rbf_smooth)
363 else:
364 kappa = tools.calc_kappa(ave_spacing, kappa_star)
--> 365 return inverse_distance_to_points(points, values, xi, search_radius, gamma, kappa,
366 min_neighbors=minimum_neighbors,
367 kind=interp_type)
~/repos/metpy/src/metpy/interpolate/points.py in inverse_distance_to_points(points, values, xi, r, gamma, kappa, min_neighbors, kind)
268 img[idx] = cressman_point(dists, values_subset, r)
269 elif kind == 'barnes':
--> 270 img[idx] = barnes_point(dists, values_subset, kappa, gamma)
271
272 else:
ValueError: setting an array element with a sequence.
```
as is seen in [this Stack Overflow question](https://stackoverflow.com/questions/70248893/interpolate-to-grid-returns-all-nans).
This is a pretty bad incompatibility in our API. | Unidata/MetPy | diff --git a/tests/interpolate/test_grid.py b/tests/interpolate/test_grid.py
index f59fa91542..a2a621a7fe 100644
--- a/tests/interpolate/test_grid.py
+++ b/tests/interpolate/test_grid.py
@@ -7,7 +7,6 @@
import logging
import numpy as np
-from numpy.testing import assert_array_almost_equal
import pytest
from metpy.cbook import get_test_data
@@ -15,6 +14,8 @@ from metpy.interpolate.grid import (generate_grid, generate_grid_coords, get_bou
get_xy_range, get_xy_steps, interpolate_to_grid,
interpolate_to_isosurface, inverse_distance_to_grid,
natural_neighbor_to_grid)
+from metpy.testing import assert_array_almost_equal
+from metpy.units import units
logging.getLogger('metpy.interpolate.grid').setLevel(logging.ERROR)
@@ -233,9 +234,10 @@ def test_interpolate_to_isosurface():
assert_array_almost_equal(truth, dt_theta)
[email protected]('assume_units', [None, 'mbar'])
@pytest.mark.parametrize('method', interp_methods)
@pytest.mark.parametrize('boundary_coords', boundary_types)
-def test_interpolate_to_grid(method, test_coords, boundary_coords):
+def test_interpolate_to_grid(method, assume_units, test_coords, boundary_coords):
r"""Test main grid interpolation function."""
xp, yp = test_coords
@@ -257,11 +259,14 @@ def test_interpolate_to_grid(method, test_coords, boundary_coords):
if boundary_coords is not None:
extra_kw['boundary_coords'] = boundary_coords
- _, _, img = interpolate_to_grid(xp, yp, z, hres=10, interp_type=method, **extra_kw)
-
with get_test_data(f'{method}_test.npz') as fobj:
truth = np.load(fobj)['img']
+ if assume_units:
+ z = units.Quantity(z, assume_units)
+ truth = units.Quantity(truth, assume_units)
+
+ _, _, img = interpolate_to_grid(xp, yp, z, hres=10, interp_type=method, **extra_kw)
assert_array_almost_equal(truth, img)
diff --git a/tests/interpolate/test_points.py b/tests/interpolate/test_points.py
index 73bc566c04..beb0ac4906 100644
--- a/tests/interpolate/test_points.py
+++ b/tests/interpolate/test_points.py
@@ -7,7 +7,6 @@
import logging
import numpy as np
-from numpy.testing import assert_almost_equal, assert_array_almost_equal
import pytest
from scipy.spatial import cKDTree, Delaunay
@@ -16,6 +15,8 @@ from metpy.interpolate import (interpolate_to_points, inverse_distance_to_points
natural_neighbor_to_points)
from metpy.interpolate.geometry import dist_2, find_natural_neighbors
from metpy.interpolate.points import barnes_point, cressman_point, natural_neighbor_point
+from metpy.testing import assert_almost_equal, assert_array_almost_equal
+from metpy.units import units
logging.getLogger('metpy.interpolate.points').setLevel(logging.ERROR)
@@ -51,7 +52,7 @@ def test_nn_point(test_data):
members, tri_info = find_natural_neighbors(tri,
list(zip(sim_gridx, sim_gridy)))
- val = natural_neighbor_point(xp, yp, z, [sim_gridx[0], sim_gridy[0]],
+ val = natural_neighbor_point(xp, yp, z, (sim_gridx[0], sim_gridy[0]),
tri, members[0], tri_info)
truth = 1.009
@@ -108,43 +109,51 @@ def test_natural_neighbor_to_points(test_data, test_points):
assert_array_almost_equal(truth, img)
-interp_methods = ['cressman', 'barnes', 'shouldraise']
+def test_inverse_distance_to_points_invalid(test_data, test_points):
+ """Test that inverse_distance_to_points raises when given an invalid method."""
+ xp, yp, z = test_data
+ obs_points = np.vstack([xp, yp]).transpose()
+ with pytest.raises(ValueError):
+ inverse_distance_to_points(obs_points, z, test_points, kind='shouldraise', r=40)
[email protected]('method', interp_methods)
-def test_inverse_distance_to_points(method, test_data, test_points):
- r"""Test inverse distance interpolation to grid function."""
[email protected]('assume_units', [None, 'mbar'])
[email protected]('method', ['cressman', 'barnes'])
+def test_inverse_distance_to_points(method, assume_units, test_data, test_points):
+ r"""Test inverse distance interpolation to points function."""
xp, yp, z = test_data
obs_points = np.vstack([xp, yp]).transpose()
- extra_kw = {}
- if method == 'shouldraise':
- extra_kw['r'] = 40
- with pytest.raises(ValueError):
- inverse_distance_to_points(
- obs_points, z, test_points, kind=method, **extra_kw)
- else:
- test_file = ''
- if method == 'cressman':
- extra_kw['r'] = 20
- extra_kw['min_neighbors'] = 1
- test_file = 'cressman_r20_mn1.npz'
- elif method == 'barnes':
- extra_kw['r'] = 40
- extra_kw['kappa'] = 100
- test_file = 'barnes_r40_k100.npz'
+ extra_kw, test_file = {'cressman': ({'r': 20, 'min_neighbors': 1}, 'cressman_r20_mn1.npz'),
+ 'barnes': ({'r': 40, 'kappa': 100}, 'barnes_r40_k100.npz')}[method]
+
+ with get_test_data(test_file) as fobj:
+ truth = np.load(fobj)['img'].reshape(-1)
+
+ if assume_units:
+ z = units.Quantity(z, assume_units)
+ truth = units.Quantity(truth, assume_units)
+
+ img = inverse_distance_to_points(obs_points, z, test_points, kind=method, **extra_kw)
+ assert_array_almost_equal(truth, img)
+
- img = inverse_distance_to_points(obs_points, z, test_points, kind=method, **extra_kw)
+def test_interpolate_to_points_invalid(test_data):
+ """Test that interpolate_to_points raises when given an invalid method."""
+ xp, yp, z = test_data
+ obs_points = np.vstack([xp, yp]).transpose() * 10
- with get_test_data(test_file) as fobj:
- truth = np.load(fobj)['img'].reshape(-1)
+ with get_test_data('interpolation_test_points.npz') as fobj:
+ test_points = np.load(fobj)['points']
- assert_array_almost_equal(truth, img)
+ with pytest.raises(ValueError):
+ interpolate_to_points(obs_points, z, test_points, interp_type='shouldraise')
[email protected]('assume_units', [None, 'mbar'])
@pytest.mark.parametrize('method', ['natural_neighbor', 'cressman', 'barnes', 'linear',
- 'nearest', 'rbf', 'shouldraise', 'cubic'])
-def test_interpolate_to_points(method, test_data):
+ 'nearest', 'rbf', 'cubic'])
+def test_interpolate_to_points(method, assume_units, test_data):
r"""Test main grid interpolation function."""
xp, yp, z = test_data
obs_points = np.vstack([xp, yp]).transpose() * 10
@@ -152,23 +161,19 @@ def test_interpolate_to_points(method, test_data):
with get_test_data('interpolation_test_points.npz') as fobj:
test_points = np.load(fobj)['points']
- extra_kw = {}
if method == 'cressman':
- extra_kw['search_radius'] = 200
- extra_kw['minimum_neighbors'] = 1
+ extra_kw = {'search_radius': 200, 'minimum_neighbors': 1}
elif method == 'barnes':
- extra_kw['search_radius'] = 400
- extra_kw['minimum_neighbors'] = 1
- extra_kw['gamma'] = 1
- elif method == 'shouldraise':
- with pytest.raises(ValueError):
- interpolate_to_points(
- obs_points, z, test_points, interp_type=method, **extra_kw)
- return
-
- img = interpolate_to_points(obs_points, z, test_points, interp_type=method, **extra_kw)
+ extra_kw = {'search_radius': 400, 'minimum_neighbors': 1, 'gamma': 1}
+ else:
+ extra_kw = {}
with get_test_data(f'{method}_test.npz') as fobj:
truth = np.load(fobj)['img'].reshape(-1)
+ if assume_units:
+ z = units.Quantity(z, assume_units)
+ truth = units.Quantity(truth, assume_units)
+
+ img = interpolate_to_points(obs_points, z, test_points, interp_type=method, **extra_kw)
assert_array_almost_equal(truth, img)
diff --git a/tests/io/test_metar.py b/tests/io/test_metar.py
index b2896ab82e..ec342e5631 100644
--- a/tests/io/test_metar.py
+++ b/tests/io/test_metar.py
@@ -10,7 +10,6 @@ import pytest
from metpy.cbook import get_test_data
from metpy.io import parse_metar_file, parse_metar_to_dataframe
-from metpy.io._metar_parser.metar_parser import parse
from metpy.io.metar import Metar, parse_metar
from metpy.units import units
@@ -353,29 +352,3 @@ def test_parse_no_pint_objects_in_df():
for df in (parse_metar_file(input_file), parse_metar_to_dataframe(metar_str)):
for column in df:
assert not isinstance(df[column][0], units.Quantity)
-
-
-def test_repr():
- """Test that the TreeNode string representation works."""
- str1 = 'KSMQ 201953Z AUTO VRB05KT 10SM CLR 03/M10 A3026'
- tree = parse(str1)
- rep = repr(tree)
- assert rep == ("TreeNode1(text='KSMQ 201953Z AUTO VRB05KT 10SM CLR 03/M10 A3026', "
- "offset=0, metar=TreeNode(text='', offset=0), "
- "siteid=TreeNode(text='KSMQ', offset=0), "
- "datetime=TreeNode2(text=' 201953Z', offset=4, "
- "sep=TreeNode(text=' ', offset=4)), "
- "auto=TreeNode(text=' AUTO', offset=12), "
- "wind=TreeNode4(text=' VRB05KT', offset=17, "
- "wind_dir=TreeNode(text='VRB', offset=18), "
- "wind_spd=TreeNode(text='05', offset=21), "
- "gust=TreeNode(text='', offset=23)), "
- "vis=TreeNode6(text=' 10SM', offset=25, "
- "sep=TreeNode(text=' ', offset=25)), run=TreeNode(text='', offset=30), "
- "curwx=TreeNode(text='', offset=30), "
- "skyc=TreeNode(text=' CLR', offset=30), "
- "temp_dewp=TreeNode13(text=' 03/M10', offset=34, "
- "sep=TreeNode(text=' ', offset=34), temp=TreeNode(text='03', offset=35), "
- "dewp=TreeNode(text='M10', offset=38)), "
- "altim=TreeNode(text=' A3026', offset=41), "
- "remarks=TreeNode(text='', offset=47), end=TreeNode(text='', offset=47))")
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 2
} | 1.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"ci/requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | appdirs==1.4.4
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.8.0
cycler==0.12.1
exceptiongroup==1.2.2
execnet==2.1.1
fonttools==4.56.0
idna==3.10
importlib-metadata==4.10.0
importlib-resources==5.4.0
iniconfig==2.1.0
kiwisolver==1.4.7
matplotlib==3.5.1
-e git+https://github.com/Unidata/MetPy.git@4f1e6bb18d0a16a421292dfbd21d03ed983a7952#egg=MetPy
numpy==1.21.4
packaging==24.2
pandas==1.3.5
pillow==11.1.0
Pint==0.18
pluggy==1.5.0
pooch==1.5.2
pyparsing==3.2.3
pyproj==3.2.1
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.32.3
scipy==1.7.3
six==1.17.0
tomli==2.2.1
traitlets==5.1.1
typing_extensions==4.13.0
urllib3==2.3.0
xarray==0.20.2
zipp==3.21.0
| name: MetPy
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- appdirs==1.4.4
- certifi==2025.1.31
- charset-normalizer==3.4.1
- coverage==7.8.0
- cycler==0.12.1
- exceptiongroup==1.2.2
- execnet==2.1.1
- fonttools==4.56.0
- idna==3.10
- importlib-metadata==4.10.0
- importlib-resources==5.4.0
- iniconfig==2.1.0
- kiwisolver==1.4.7
- matplotlib==3.5.1
- metpy==1.1.0.post377+g4f1e6bb18d
- numpy==1.21.4
- packaging==24.2
- pandas==1.3.5
- pillow==11.1.0
- pint==0.18
- pluggy==1.5.0
- pooch==1.5.2
- pyparsing==3.2.3
- pyproj==3.2.1
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- pytz==2025.2
- requests==2.32.3
- scipy==1.7.3
- six==1.17.0
- tomli==2.2.1
- traitlets==5.1.1
- typing-extensions==4.13.0
- urllib3==2.3.0
- xarray==0.20.2
- zipp==3.21.0
prefix: /opt/conda/envs/MetPy
| [
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-natural_neighbor-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-cressman-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-barnes-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-linear-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-nearest-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-rbf-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-cubic-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-natural_neighbor-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-cressman-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-barnes-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-linear-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-nearest-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-rbf-mbar]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-cubic-mbar]",
"tests/interpolate/test_points.py::test_inverse_distance_to_points[cressman-mbar]",
"tests/interpolate/test_points.py::test_inverse_distance_to_points[barnes-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[natural_neighbor-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[cressman-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[barnes-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[linear-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[nearest-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[rbf-mbar]",
"tests/interpolate/test_points.py::test_interpolate_to_points[cubic-mbar]"
] | [] | [
"tests/interpolate/test_grid.py::test_get_boundary_coords",
"tests/interpolate/test_grid.py::test_get_xy_steps",
"tests/interpolate/test_grid.py::test_get_xy_range",
"tests/interpolate/test_grid.py::test_generate_grid",
"tests/interpolate/test_grid.py::test_generate_grid_coords",
"tests/interpolate/test_grid.py::test_natural_neighbor_to_grid",
"tests/interpolate/test_grid.py::test_inverse_distance_to_grid[cressman]",
"tests/interpolate/test_grid.py::test_inverse_distance_to_grid[barnes]",
"tests/interpolate/test_grid.py::test_interpolate_to_isosurface",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-natural_neighbor-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-cressman-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-barnes-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-linear-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-nearest-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-rbf-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[boundary_coords0-cubic-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-natural_neighbor-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-cressman-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-barnes-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-linear-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-nearest-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-rbf-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_grid[None-cubic-None]",
"tests/interpolate/test_grid.py::test_interpolate_to_isosurface_from_below",
"tests/interpolate/test_points.py::test_nn_point",
"tests/interpolate/test_points.py::test_cressman_point",
"tests/interpolate/test_points.py::test_barnes_point",
"tests/interpolate/test_points.py::test_natural_neighbor_to_points",
"tests/interpolate/test_points.py::test_inverse_distance_to_points_invalid",
"tests/interpolate/test_points.py::test_inverse_distance_to_points[cressman-None]",
"tests/interpolate/test_points.py::test_inverse_distance_to_points[barnes-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points_invalid",
"tests/interpolate/test_points.py::test_interpolate_to_points[natural_neighbor-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points[cressman-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points[barnes-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points[linear-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points[nearest-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points[rbf-None]",
"tests/interpolate/test_points.py::test_interpolate_to_points[cubic-None]",
"tests/io/test_metar.py::test_metar_parser[missing",
"tests/io/test_metar.py::test_metar_parser[BKN]",
"tests/io/test_metar.py::test_metar_parser[FEW]",
"tests/io/test_metar.py::test_metar_parser[current",
"tests/io/test_metar.py::test_metar_parser[smoke]",
"tests/io/test_metar.py::test_metar_parser[CAVOK]",
"tests/io/test_metar.py::test_metar_parser[vis",
"tests/io/test_metar.py::test_metar_parser[vertical",
"tests/io/test_metar.py::test_metar_parser[BCFG]",
"tests/io/test_metar.py::test_metar_parser[-DZ]",
"tests/io/test_metar.py::test_metar_parser[sky",
"tests/io/test_metar.py::test_metar_parser[5",
"tests/io/test_metar.py::test_metar_parser[-FZUP]",
"tests/io/test_metar.py::test_metar_parser[VV",
"tests/io/test_metar.py::test_metar_parser[COR",
"tests/io/test_metar.py::test_metar_parser[M1/4SM",
"tests/io/test_metar.py::test_metar_parser[variable",
"tests/io/test_metar.py::test_metar_parser[runway",
"tests/io/test_metar.py::test_metar_parser[odd",
"tests/io/test_metar.py::test_metar_parser[IC]",
"tests/io/test_metar.py::test_metar_parser[NSW]",
"tests/io/test_metar.py::test_metar_parser[swapped",
"tests/io/test_metar.py::test_metar_parser[space",
"tests/io/test_metar.py::test_date_time_given",
"tests/io/test_metar.py::test_parse_metar_df_positional_datetime_failure",
"tests/io/test_metar.py::test_parse_metar_to_dataframe",
"tests/io/test_metar.py::test_parse_file",
"tests/io/test_metar.py::test_parse_file_positional_datetime_failure",
"tests/io/test_metar.py::test_parse_file_bad_encoding",
"tests/io/test_metar.py::test_parse_file_object",
"tests/io/test_metar.py::test_parse_no_pint_objects_in_df"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,860 | 2,173 | [
"src/metpy/interpolate/points.py",
"src/metpy/io/metar.py"
] |
|
Unidata__MetPy-2272 | f636fa70088a9631098902664747e4f5036fa2ed | 2021-12-21 03:00:46 | 394fc195e3b72fd88d7cf4c1afe862588004e433 | dopplershift: @jthielen What do you think of this?
jthielen: Overall, this looks good to me! After testing out various permutations of MetPy (before and after this change), pint-xarray, and cf-xarray, this indeed looks like the best approach we can practically take for compatibility.
One corner case I discovered: if you import cf-xarray's registry (which defines a new registry and sets it with `pint.set_application_registry`), previously defined `Quantity`s start failing some of MetPy's internal `isinstance(thing, units.Quantity)` checks. For example, while contrived, this demonstrates the issue
```python
import xarray as xr
import pint_xarray
from metpy.units import units
data_pre = xr.DataArray([3, 5, 7] * units('m/s'))
print(data_pre.pint.units, data_pre.metpy.units)
import cf_xarray.units
data_post = xr.DataArray([3, 5, 7] * units('m/s'))
print(data_pre.pint.units, data_pre.metpy.units)
print(data_post.pint.units, data_post.metpy.units)
```
```
meter / second meter / second
meter / second dimensionless
meter / second meter / second
```
This should be fixable by https://github.com/jthielen/MetPy/commit/6f4c090fe32faa5e217605ec0b8e1d9be4cb165f (comparing against pint's top-level `Quantity` rather than our imported registry's `Quantity`). While we definitely can't expect to fully support mixed registries (given that Pint itself usually doesn't), by changing these checks, we can fix errors like "`u` requires "[speed]" but given "dimensionless" that would show up in situations like this and https://github.com/Unidata/MetPy/issues/2672. | diff --git a/src/metpy/interpolate/slices.py b/src/metpy/interpolate/slices.py
index 9ac27ed1ff..50bd70f54e 100644
--- a/src/metpy/interpolate/slices.py
+++ b/src/metpy/interpolate/slices.py
@@ -7,7 +7,7 @@ import numpy as np
import xarray as xr
from ..package_tools import Exporter
-from ..units import units
+from ..units import is_quantity, units
from ..xarray import check_axis
exporter = Exporter(globals())
@@ -57,10 +57,7 @@ def interpolate_to_slice(data, points, interp_type='linear'):
data_sliced.coords['index'] = range(len(points))
# Bug in xarray: interp strips units
- if (
- isinstance(data.data, units.Quantity)
- and not isinstance(data_sliced.data, units.Quantity)
- ):
+ if is_quantity(data.data) and not is_quantity(data_sliced.data):
data_sliced.data = units.Quantity(data_sliced.data, data.data.units)
return data_sliced
diff --git a/src/metpy/units.py b/src/metpy/units.py
index cddf9161f6..253f2dbbcc 100644
--- a/src/metpy/units.py
+++ b/src/metpy/units.py
@@ -15,6 +15,7 @@ units : :class:`pint.UnitRegistry`
import this registry and use it to grab units.
"""
+import contextlib
import functools
from inspect import Parameter, signature
import logging
@@ -37,38 +38,55 @@ _base_unit_of_dimensionality = {
'[speed]': 'm s**-1'
}
-# Create registry, with preprocessors for UDUNITS-style powers (m2 s-2) and percent signs
-units = pint.UnitRegistry(
- autoconvert_offset_to_baseunit=True,
- preprocessors=[
- functools.partial(
- re.sub,
- r'(?<=[A-Za-z\)])(?![A-Za-z\)])(?<![0-9\-][eE])(?<![0-9\-])(?=[0-9\-])',
- '**'
- ),
- lambda string: string.replace('%', 'percent')
- ]
-)
-
-# Capture v0.10 NEP 18 warning on first creation
-with warnings.catch_warnings():
- warnings.simplefilter('ignore')
- units.Quantity([])
-
-# Add a percent unit
-units.define('percent = 0.01 = %')
-
-# Define commonly encountered units not defined by pint
-units.define('degrees_north = degree = degrees_N = degreesN = degree_north = degree_N '
- '= degreeN')
-units.define('degrees_east = degree = degrees_E = degreesE = degree_east = degree_E = degreeE')
-
-# Alias geopotential meters (gpm) to just meters
-units.define('@alias meter = gpm')
+
+def _fix_udunits_powers(string):
+ """Replace UDUNITS-style powers (m2 s-2) with exponent symbols (m**2 s**-2)."""
+ return _UDUNIT_POWER.sub('**', string)
+
+
+# Fix UDUNITS-style powers and percent signs
+_UDUNIT_POWER = re.compile(r'(?<=[A-Za-z\)])(?![A-Za-z\)])'
+ r'(?<![0-9\-][eE])(?<![0-9\-])(?=[0-9\-])')
+_unit_preprocessors = [_fix_udunits_powers, lambda string: string.replace('%', 'percent')]
+
+
+def setup_registry(reg):
+ """Set up a given registry with MetPy's default tweaks and settings."""
+ reg.autoconvert_offset_to_baseunit = True
+
+ # For Pint 0.18.0, need to deal with the fact that the wrapper isn't forwarding on setting
+ # the attribute.
+ with contextlib.suppress(AttributeError):
+ reg.get().autoconvert_offset_to_baseunit = True
+
+ for pre in _unit_preprocessors:
+ if pre not in reg.preprocessors:
+ reg.preprocessors.append(pre)
+
+ # Add a percent unit
+ reg.define('percent = 0.01 = %')
+
+ # Define commonly encountered units not defined by pint
+ reg.define('degrees_north = degree = degrees_N = degreesN = degree_north = degree_N '
+ '= degreeN')
+ reg.define('degrees_east = degree = degrees_E = degreesE = degree_east = degree_E '
+ '= degreeE')
+
+ # Alias geopotential meters (gpm) to just meters
+ reg.define('@alias meter = gpm')
+
+ # Enable pint's built-in matplotlib support
+ reg.setup_matplotlib()
+
+ return reg
+
+
+# Make our modifications using pint's application registry--which allows us to better
+# interoperate with other libraries using Pint.
+units = setup_registry(pint.get_application_registry())
# Silence UnitStrippedWarning
-if hasattr(pint, 'UnitStrippedWarning'):
- warnings.simplefilter('ignore', category=pint.UnitStrippedWarning)
+warnings.simplefilter('ignore', category=pint.UnitStrippedWarning)
def pandas_dataframe_to_unit_arrays(df, column_units=None):
@@ -106,6 +124,11 @@ def pandas_dataframe_to_unit_arrays(df, column_units=None):
return res
+def is_quantity(*args):
+ """Check whether an instance is a quantity."""
+ return all(isinstance(a, pint.Quantity) for a in args)
+
+
def concatenate(arrs, axis=0):
r"""Concatenate multiple values into a new quantity.
@@ -371,9 +394,3 @@ def process_units(
return wrapper
return dec
-
-
-# Enable pint's built-in matplotlib support
-units.setup_matplotlib()
-
-del pint
diff --git a/src/metpy/xarray.py b/src/metpy/xarray.py
index d9d0cb7edf..598dad5aa8 100644
--- a/src/metpy/xarray.py
+++ b/src/metpy/xarray.py
@@ -28,7 +28,8 @@ from pyproj import CRS, Proj
import xarray as xr
from ._vendor.xarray import either_dict_or_kwargs, expanded_indexer, is_dict_like
-from .units import _mutate_arguments, DimensionalityError, UndefinedUnitError, units
+from .units import (_mutate_arguments, DimensionalityError, is_quantity, UndefinedUnitError,
+ units)
__all__ = ('MetPyDataArrayAccessor', 'MetPyDatasetAccessor', 'grid_deltas_from_dataarray')
metpy_axes = ['time', 'vertical', 'y', 'latitude', 'x', 'longitude']
@@ -130,7 +131,7 @@ class MetPyDataArrayAccessor:
@property
def units(self):
"""Return the units of this DataArray as a `pint.Unit`."""
- if isinstance(self._data_array.variable._data, units.Quantity):
+ if is_quantity(self._data_array.variable._data):
return self._data_array.variable._data.units
else:
return units.parse_units(self._data_array.attrs.get('units', 'dimensionless'))
@@ -138,7 +139,7 @@ class MetPyDataArrayAccessor:
@property
def magnitude(self):
"""Return the magnitude of the data values of this DataArray (i.e., without units)."""
- if isinstance(self._data_array.data, units.Quantity):
+ if is_quantity(self._data_array.data):
return self._data_array.data.magnitude
else:
return self._data_array.data
@@ -153,7 +154,7 @@ class MetPyDataArrayAccessor:
will be loaded into memory by this operation. Do not utilize on moderate- to
large-sized remote datasets before subsetting!
"""
- if isinstance(self._data_array.data, units.Quantity):
+ if is_quantity(self._data_array.data):
return self._data_array.data
else:
return units.Quantity(self._data_array.data, self.units)
@@ -222,7 +223,7 @@ class MetPyDataArrayAccessor:
subsetting!
"""
if (
- not isinstance(self._data_array.data, units.Quantity)
+ not is_quantity(self._data_array.data)
and np.issubdtype(self._data_array.data.dtype, np.number)
):
# Only quantify if not already quantified and is quantifiable
@@ -235,7 +236,7 @@ class MetPyDataArrayAccessor:
def dequantify(self):
"""Return a new DataArray with the data as magnitude and the units as an attribute."""
- if isinstance(self._data_array.data, units.Quantity):
+ if is_quantity(self._data_array.data):
# Only dequantify if quantified
dequantified_dataarray = self._data_array.copy(
data=self._data_array.data.magnitude
@@ -1277,7 +1278,7 @@ def _wrap_output_like_matching_units(result, match):
return result if output_xarray else result.metpy.unit_array
else:
result = (
- result.to(match_units) if isinstance(result, units.Quantity)
+ result.to(match_units) if is_quantity(result)
else units.Quantity(result, match_units)
)
return (
@@ -1293,10 +1294,8 @@ def _wrap_output_like_not_matching_units(result, match):
return result if output_xarray else result.metpy.unit_array
# Determine if need to upcast to Quantity
if (
- not isinstance(result, units.Quantity)
- and (
- isinstance(match, units.Quantity)
- or (output_xarray and isinstance(match.data, units.Quantity))
+ not is_quantity(result) and (
+ is_quantity(match) or (output_xarray and is_quantity(match.data))
)
):
result = units.Quantity(result)
| Improve setup of pint UnitRegistry
There are now functions for `set_application_registry()` and `get_application_registry()`, so we should really look at using those for a registry. This would allow us to play nicely with other libraries/applications using pint, such as xarray-pint. Questions:
* We currently add our own units and loosen the temperature unit rules. What do we do about this?
* Should we modify existing registries?
* Should we ever set the application registry? | Unidata/MetPy | diff --git a/tests/calc/test_thermo.py b/tests/calc/test_thermo.py
index 1766b91bb2..37d868b851 100644
--- a/tests/calc/test_thermo.py
+++ b/tests/calc/test_thermo.py
@@ -35,7 +35,7 @@ from metpy.calc import (brunt_vaisala_frequency, brunt_vaisala_frequency_squared
virtual_temperature, wet_bulb_temperature)
from metpy.calc.thermo import _find_append_zero_crossings
from metpy.testing import assert_almost_equal, assert_array_almost_equal, assert_nan
-from metpy.units import masked_array, units
+from metpy.units import is_quantity, masked_array, units
def test_relative_humidity_from_dewpoint():
@@ -632,7 +632,7 @@ def test_equivalent_potential_temperature_masked():
np.ma.array([311.18586, 313.51781, 315.93971], mask=[False, True, False]),
units.kelvin
)
- assert isinstance(ept, units.Quantity)
+ assert is_quantity(ept)
assert isinstance(ept.m, np.ma.MaskedArray)
assert_array_almost_equal(ept, expected, 3)
@@ -656,7 +656,7 @@ def test_saturation_equivalent_potential_temperature_masked():
np.ma.array([335.02750, 338.95813, 343.08740]),
units.kelvin
)
- assert isinstance(s_ept, units.Quantity)
+ assert is_quantity(s_ept)
assert isinstance(s_ept.m, np.ma.MaskedArray)
assert_array_almost_equal(s_ept, expected, 3)
diff --git a/tests/io/test_metar.py b/tests/io/test_metar.py
index 026a5385ad..341fb27e76 100644
--- a/tests/io/test_metar.py
+++ b/tests/io/test_metar.py
@@ -12,7 +12,7 @@ from metpy.cbook import get_test_data
from metpy.io import parse_metar_file, parse_metar_to_dataframe
from metpy.io._metar_parser.metar_parser import parse
from metpy.io.metar import Metar, parse_metar
-from metpy.units import units
+from metpy.units import is_quantity, units
@pytest.mark.parametrize(['metar', 'truth'], [
@@ -365,7 +365,7 @@ def test_parse_no_pint_objects_in_df():
for df in (parse_metar_file(input_file), parse_metar_to_dataframe(metar_str)):
for column in df:
- assert not isinstance(df[column][0], units.Quantity)
+ assert not is_quantity(df[column][0])
def test_repr():
diff --git a/tests/test_xarray.py b/tests/test_xarray.py
index 0805501739..8f336eab3e 100644
--- a/tests/test_xarray.py
+++ b/tests/test_xarray.py
@@ -13,7 +13,7 @@ import xarray as xr
from metpy.plots.mapping import CFProjection
from metpy.testing import (assert_almost_equal, assert_array_almost_equal, assert_array_equal,
get_test_data)
-from metpy.units import DimensionalityError, units
+from metpy.units import DimensionalityError, is_quantity, units
from metpy.xarray import (add_grid_arguments_from_xarray, add_vertical_dim_from_xarray,
check_axis, check_matching_coordinates, grid_deltas_from_dataarray,
preprocess_and_wrap)
@@ -102,7 +102,7 @@ def test_geodetic(test_var, ccrs):
def test_unit_array(test_var):
"""Test unit handling through the accessor."""
arr = test_var.metpy.unit_array
- assert isinstance(arr, units.Quantity)
+ assert is_quantity(arr)
assert arr.units == units.kelvin
@@ -177,7 +177,7 @@ def test_quantify(test_ds_generic):
"""Test quantify method for converting data to Quantity."""
original = test_ds_generic['test'].values
result = test_ds_generic['test'].metpy.quantify()
- assert isinstance(result.data, units.Quantity)
+ assert is_quantity(result.data)
assert result.data.units == units.kelvin
assert 'units' not in result.attrs
np.testing.assert_array_almost_equal(result.data, units.Quantity(original))
@@ -197,7 +197,7 @@ def test_dequantify():
def test_dataset_quantify(test_ds_generic):
"""Test quantify method for converting data to Quantity on Datasets."""
result = test_ds_generic.metpy.quantify()
- assert isinstance(result['test'].data, units.Quantity)
+ assert is_quantity(result['test'].data)
assert result['test'].data.units == units.kelvin
assert 'units' not in result['test'].attrs
np.testing.assert_array_almost_equal(
@@ -1365,7 +1365,7 @@ def test_preprocess_and_wrap_with_variable():
assert isinstance(result_12, xr.DataArray)
xr.testing.assert_identical(func(data1, data2), expected_12)
- assert isinstance(result_21, units.Quantity)
+ assert is_quantity(result_21)
assert_array_equal(func(data2, data1), expected_21)
diff --git a/tests/units/test_units.py b/tests/units/test_units.py
index 68cac4fa33..ac99827c86 100644
--- a/tests/units/test_units.py
+++ b/tests/units/test_units.py
@@ -9,7 +9,8 @@ import pandas as pd
import pytest
from metpy.testing import assert_array_almost_equal, assert_array_equal, assert_nan
-from metpy.units import check_units, concatenate, pandas_dataframe_to_unit_arrays, units
+from metpy.units import (check_units, concatenate, is_quantity,
+ pandas_dataframe_to_unit_arrays, units)
def test_concatenate():
@@ -177,6 +178,18 @@ def test_added_degrees_units():
assert units('degrees_east').to_base_units().units == units.radian
+def test_is_quantity():
+ """Test is_quantity properly works."""
+ assert is_quantity(1 * units.m)
+ assert not is_quantity(np.array([1]))
+
+
+def test_is_quantity_multiple():
+ """Test is_quantity with multiple inputs."""
+ assert is_quantity(1 * units.m, np.array([4.]) * units.degree)
+ assert not is_quantity(1 * units.second, np.array([5., 2.]))
+
+
def test_gpm_unit():
"""Test that the gpm unit does alias to meters."""
x = 1 * units('gpm')
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 3
},
"num_modified_files": 3
} | 1.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"ci/requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | appdirs==1.4.4
certifi==2025.1.31
charset-normalizer==3.4.1
contourpy==1.3.0
coverage==7.8.0
cycler==0.12.1
exceptiongroup==1.2.2
execnet==2.1.1
fonttools==4.56.0
idna==3.10
importlib-resources==5.9.0
iniconfig==2.1.0
kiwisolver==1.4.7
matplotlib==3.6.0
-e git+https://github.com/Unidata/MetPy.git@f636fa70088a9631098902664747e4f5036fa2ed#egg=MetPy
numpy==1.23.3
packaging==24.2
pandas==1.5.0
pillow==11.1.0
Pint==0.19.2
pluggy==1.5.0
pooch==1.6.0
pyparsing==3.2.3
pyproj==3.4.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pytz==2025.2
requests==2.32.3
scipy==1.9.1
six==1.17.0
tomli==2.2.1
traitlets==5.4.0
typing_extensions==4.13.0
urllib3==2.3.0
xarray==2022.6.0
zipp==3.21.0
| name: MetPy
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- appdirs==1.4.4
- certifi==2025.1.31
- charset-normalizer==3.4.1
- contourpy==1.3.0
- coverage==7.8.0
- cycler==0.12.1
- exceptiongroup==1.2.2
- execnet==2.1.1
- fonttools==4.56.0
- idna==3.10
- importlib-resources==5.9.0
- iniconfig==2.1.0
- kiwisolver==1.4.7
- matplotlib==3.6.0
- metpy==1.3.0.post341+gf636fa7008
- numpy==1.23.3
- packaging==24.2
- pandas==1.5.0
- pillow==11.1.0
- pint==0.19.2
- pluggy==1.5.0
- pooch==1.6.0
- pyparsing==3.2.3
- pyproj==3.4.0
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- pytz==2025.2
- requests==2.32.3
- scipy==1.9.1
- six==1.17.0
- tomli==2.2.1
- traitlets==5.4.0
- typing-extensions==4.13.0
- urllib3==2.3.0
- xarray==2022.6.0
- zipp==3.21.0
prefix: /opt/conda/envs/MetPy
| [
"tests/calc/test_thermo.py::test_relative_humidity_from_dewpoint",
"tests/calc/test_thermo.py::test_relative_humidity_from_dewpoint_with_f",
"tests/calc/test_thermo.py::test_relative_humidity_from_dewpoint_xarray",
"tests/calc/test_thermo.py::test_exner_function",
"tests/calc/test_thermo.py::test_potential_temperature",
"tests/calc/test_thermo.py::test_temperature_from_potential_temperature",
"tests/calc/test_thermo.py::test_pot_temp_scalar",
"tests/calc/test_thermo.py::test_pot_temp_fahrenheit",
"tests/calc/test_thermo.py::test_pot_temp_inhg",
"tests/calc/test_thermo.py::test_dry_lapse",
"tests/calc/test_thermo.py::test_dry_lapse_2_levels",
"tests/calc/test_thermo.py::test_moist_lapse[degF]",
"tests/calc/test_thermo.py::test_moist_lapse[degC]",
"tests/calc/test_thermo.py::test_moist_lapse[K]",
"tests/calc/test_thermo.py::test_moist_lapse_ref_pressure",
"tests/calc/test_thermo.py::test_moist_lapse_multiple_temps",
"tests/calc/test_thermo.py::test_moist_lapse_scalar",
"tests/calc/test_thermo.py::test_moist_lapse_close_start",
"tests/calc/test_thermo.py::test_moist_lapse_uniform",
"tests/calc/test_thermo.py::test_moist_lapse_nan_temp",
"tests/calc/test_thermo.py::test_moist_lapse_nan_ref_press",
"tests/calc/test_thermo.py::test_moist_lapse_downwards",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[0-1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[0--1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[1-1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[1--1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[2-1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[2--1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[3-1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[3--1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[4-1]",
"tests/calc/test_thermo.py::test_moist_lapse_starting_points[4--1]",
"tests/calc/test_thermo.py::test_parcel_profile",
"tests/calc/test_thermo.py::test_parcel_profile_lcl",
"tests/calc/test_thermo.py::test_parcel_profile_lcl_not_monotonic",
"tests/calc/test_thermo.py::test_parcel_profile_with_lcl_as_dataset",
"tests/calc/test_thermo.py::test_parcel_profile_saturated",
"tests/calc/test_thermo.py::test_sat_vapor_pressure",
"tests/calc/test_thermo.py::test_sat_vapor_pressure_scalar",
"tests/calc/test_thermo.py::test_sat_vapor_pressure_fahrenheit",
"tests/calc/test_thermo.py::test_basic_dewpoint_from_relative_humidity",
"tests/calc/test_thermo.py::test_scalar_dewpoint_from_relative_humidity",
"tests/calc/test_thermo.py::test_percent_dewpoint_from_relative_humidity",
"tests/calc/test_thermo.py::test_warning_dewpoint_from_relative_humidity",
"tests/calc/test_thermo.py::test_dewpoint",
"tests/calc/test_thermo.py::test_dewpoint_weird_units",
"tests/calc/test_thermo.py::test_mixing_ratio",
"tests/calc/test_thermo.py::test_vapor_pressure",
"tests/calc/test_thermo.py::test_lcl",
"tests/calc/test_thermo.py::test_lcl_kelvin",
"tests/calc/test_thermo.py::test_lcl_convergence",
"tests/calc/test_thermo.py::test_lcl_nans",
"tests/calc/test_thermo.py::test_lfc_basic",
"tests/calc/test_thermo.py::test_lfc_kelvin",
"tests/calc/test_thermo.py::test_lfc_ml",
"tests/calc/test_thermo.py::test_lfc_ml2",
"tests/calc/test_thermo.py::test_lfc_intersection",
"tests/calc/test_thermo.py::test_no_lfc",
"tests/calc/test_thermo.py::test_lfc_inversion",
"tests/calc/test_thermo.py::test_lfc_equals_lcl",
"tests/calc/test_thermo.py::test_sensitive_sounding",
"tests/calc/test_thermo.py::test_lfc_sfc_precision",
"tests/calc/test_thermo.py::test_lfc_pos_area_below_lcl",
"tests/calc/test_thermo.py::test_saturation_mixing_ratio",
"tests/calc/test_thermo.py::test_saturation_mixing_ratio_with_xarray",
"tests/calc/test_thermo.py::test_equivalent_potential_temperature",
"tests/calc/test_thermo.py::test_equivalent_potential_temperature_masked",
"tests/calc/test_thermo.py::test_saturation_equivalent_potential_temperature",
"tests/calc/test_thermo.py::test_saturation_equivalent_potential_temperature_masked",
"tests/calc/test_thermo.py::test_virtual_temperature",
"tests/calc/test_thermo.py::test_virtual_potential_temperature",
"tests/calc/test_thermo.py::test_density",
"tests/calc/test_thermo.py::test_el",
"tests/calc/test_thermo.py::test_el_kelvin",
"tests/calc/test_thermo.py::test_el_ml",
"tests/calc/test_thermo.py::test_no_el",
"tests/calc/test_thermo.py::test_no_el_multi_crossing",
"tests/calc/test_thermo.py::test_lfc_and_el_below_lcl",
"tests/calc/test_thermo.py::test_el_lfc_equals_lcl",
"tests/calc/test_thermo.py::test_el_small_surface_instability",
"tests/calc/test_thermo.py::test_no_el_parcel_colder",
"tests/calc/test_thermo.py::test_el_below_lcl",
"tests/calc/test_thermo.py::test_wet_psychrometric_vapor_pressure",
"tests/calc/test_thermo.py::test_wet_psychrometric_rh",
"tests/calc/test_thermo.py::test_wet_psychrometric_rh_kwargs",
"tests/calc/test_thermo.py::test_mixing_ratio_from_relative_humidity",
"tests/calc/test_thermo.py::test_rh_mixing_ratio",
"tests/calc/test_thermo.py::test_mixing_ratio_from_specific_humidity",
"tests/calc/test_thermo.py::test_mixing_ratio_from_specific_humidity_no_units",
"tests/calc/test_thermo.py::test_specific_humidity_from_mixing_ratio",
"tests/calc/test_thermo.py::test_specific_humidity_from_mixing_ratio_no_units",
"tests/calc/test_thermo.py::test_rh_specific_humidity",
"tests/calc/test_thermo.py::test_cape_cin",
"tests/calc/test_thermo.py::test_cape_cin_no_el",
"tests/calc/test_thermo.py::test_cape_cin_no_lfc",
"tests/calc/test_thermo.py::test_find_append_zero_crossings",
"tests/calc/test_thermo.py::test_most_unstable_parcel",
"tests/calc/test_thermo.py::test_isentropic_pressure",
"tests/calc/test_thermo.py::test_isentropic_pressure_masked_column",
"tests/calc/test_thermo.py::test_isentropic_pressure_p_increase",
"tests/calc/test_thermo.py::test_isentropic_pressure_additional_args",
"tests/calc/test_thermo.py::test_isentropic_pressure_tmp_out",
"tests/calc/test_thermo.py::test_isentropic_pressure_p_increase_rh_out",
"tests/calc/test_thermo.py::test_isentropic_pressure_interp",
"tests/calc/test_thermo.py::test_isentropic_pressure_addition_args_interp",
"tests/calc/test_thermo.py::test_isentropic_pressure_tmp_out_interp",
"tests/calc/test_thermo.py::test_isentropic_pressure_data_bounds_error",
"tests/calc/test_thermo.py::test_isentropic_pressure_4d",
"tests/calc/test_thermo.py::test_isentropic_interpolation_dataarray",
"tests/calc/test_thermo.py::test_isentropic_interpolation_as_dataset",
"tests/calc/test_thermo.py::test_surface_based_cape_cin[Quantity]",
"tests/calc/test_thermo.py::test_surface_based_cape_cin[masked_array]",
"tests/calc/test_thermo.py::test_surface_based_cape_cin_with_xarray",
"tests/calc/test_thermo.py::test_profile_with_nans",
"tests/calc/test_thermo.py::test_most_unstable_cape_cin_surface",
"tests/calc/test_thermo.py::test_most_unstable_cape_cin",
"tests/calc/test_thermo.py::test_mixed_parcel",
"tests/calc/test_thermo.py::test_mixed_layer_cape_cin",
"tests/calc/test_thermo.py::test_mixed_layer",
"tests/calc/test_thermo.py::test_dry_static_energy",
"tests/calc/test_thermo.py::test_moist_static_energy",
"tests/calc/test_thermo.py::test_thickness_hydrostatic",
"tests/calc/test_thermo.py::test_thickness_hydrostatic_subset",
"tests/calc/test_thermo.py::test_thickness_hydrostatic_isothermal",
"tests/calc/test_thermo.py::test_thickness_hydrostatic_isothermal_subset",
"tests/calc/test_thermo.py::test_thickness_hydrostatic_from_relative_humidity",
"tests/calc/test_thermo.py::test_mixing_ratio_dimensions",
"tests/calc/test_thermo.py::test_saturation_mixing_ratio_dimensions",
"tests/calc/test_thermo.py::test_mixing_ratio_from_rh_dimensions",
"tests/calc/test_thermo.py::test_brunt_vaisala_frequency_squared",
"tests/calc/test_thermo.py::test_brunt_vaisala_frequency",
"tests/calc/test_thermo.py::test_brunt_vaisala_period",
"tests/calc/test_thermo.py::test_wet_bulb_temperature[degF]",
"tests/calc/test_thermo.py::test_wet_bulb_temperature[degC]",
"tests/calc/test_thermo.py::test_wet_bulb_temperature[K]",
"tests/calc/test_thermo.py::test_wet_bulb_temperature_saturated",
"tests/calc/test_thermo.py::test_wet_bulb_temperature_numpy_scalars",
"tests/calc/test_thermo.py::test_wet_bulb_temperature_1d",
"tests/calc/test_thermo.py::test_wet_bulb_temperature_2d",
"tests/calc/test_thermo.py::test_wet_bulb_nan[degF]",
"tests/calc/test_thermo.py::test_wet_bulb_nan[degC]",
"tests/calc/test_thermo.py::test_wet_bulb_nan[K]",
"tests/calc/test_thermo.py::test_static_stability_adiabatic",
"tests/calc/test_thermo.py::test_static_stability_cross_section",
"tests/calc/test_thermo.py::test_dewpoint_specific_humidity",
"tests/calc/test_thermo.py::test_dewpoint_specific_humidity_old_signature",
"tests/calc/test_thermo.py::test_lfc_not_below_lcl",
"tests/calc/test_thermo.py::test_multiple_lfcs_simple",
"tests/calc/test_thermo.py::test_multiple_lfs_wide",
"tests/calc/test_thermo.py::test_invalid_which",
"tests/calc/test_thermo.py::test_multiple_els_simple",
"tests/calc/test_thermo.py::test_multiple_el_wide",
"tests/calc/test_thermo.py::test_muliple_el_most_cape",
"tests/calc/test_thermo.py::test_muliple_lfc_most_cape",
"tests/calc/test_thermo.py::test_el_lfc_most_cape_bottom",
"tests/calc/test_thermo.py::test_cape_cin_top_el_lfc",
"tests/calc/test_thermo.py::test_cape_cin_bottom_el_lfc",
"tests/calc/test_thermo.py::test_cape_cin_wide_el_lfc",
"tests/calc/test_thermo.py::test_cape_cin_custom_profile",
"tests/calc/test_thermo.py::test_parcel_profile_below_lcl",
"tests/calc/test_thermo.py::test_vertical_velocity_pressure_dry_air",
"tests/calc/test_thermo.py::test_vertical_velocity_dry_air",
"tests/calc/test_thermo.py::test_vertical_velocity_pressure_moist_air",
"tests/calc/test_thermo.py::test_vertical_velocity_moist_air",
"tests/calc/test_thermo.py::test_specific_humidity_from_dewpoint",
"tests/calc/test_thermo.py::test_lcl_convergence_issue",
"tests/calc/test_thermo.py::test_cape_cin_value_error",
"tests/calc/test_thermo.py::test_lcl_grid_surface_lcls",
"tests/calc/test_thermo.py::test_lifted_index",
"tests/calc/test_thermo.py::test_lifted_index_500hpa_missing",
"tests/calc/test_thermo.py::test_k_index",
"tests/calc/test_thermo.py::test_gradient_richardson_number",
"tests/calc/test_thermo.py::test_gradient_richardson_number_with_xarray",
"tests/calc/test_thermo.py::test_showalter_index",
"tests/calc/test_thermo.py::test_total_totals_index",
"tests/calc/test_thermo.py::test_vertical_totals",
"tests/calc/test_thermo.py::test_cross_totals",
"tests/calc/test_thermo.py::test_parcel_profile_drop_duplicates",
"tests/calc/test_thermo.py::test_parcel_profile_with_lcl_as_dataset_duplicates",
"tests/calc/test_thermo.py::test_sweat_index",
"tests/io/test_metar.py::test_metar_parser[missing",
"tests/io/test_metar.py::test_metar_parser[BKN]",
"tests/io/test_metar.py::test_metar_parser[FEW]",
"tests/io/test_metar.py::test_metar_parser[current",
"tests/io/test_metar.py::test_metar_parser[smoke]",
"tests/io/test_metar.py::test_metar_parser[CAVOK]",
"tests/io/test_metar.py::test_metar_parser[vis",
"tests/io/test_metar.py::test_metar_parser[vertical",
"tests/io/test_metar.py::test_metar_parser[BCFG]",
"tests/io/test_metar.py::test_metar_parser[-DZ]",
"tests/io/test_metar.py::test_metar_parser[sky",
"tests/io/test_metar.py::test_metar_parser[5",
"tests/io/test_metar.py::test_metar_parser[-FZUP]",
"tests/io/test_metar.py::test_metar_parser[VV",
"tests/io/test_metar.py::test_metar_parser[COR",
"tests/io/test_metar.py::test_metar_parser[M1/4SM",
"tests/io/test_metar.py::test_metar_parser[variable",
"tests/io/test_metar.py::test_metar_parser[runway",
"tests/io/test_metar.py::test_metar_parser[odd",
"tests/io/test_metar.py::test_metar_parser[IC]",
"tests/io/test_metar.py::test_metar_parser[NSW]",
"tests/io/test_metar.py::test_metar_parser[swapped",
"tests/io/test_metar.py::test_metar_parser[space",
"tests/io/test_metar.py::test_metar_parser[truncated",
"tests/io/test_metar.py::test_date_time_given",
"tests/io/test_metar.py::test_parse_metar_df_positional_datetime_failure",
"tests/io/test_metar.py::test_parse_metar_to_dataframe",
"tests/io/test_metar.py::test_parse_file",
"tests/io/test_metar.py::test_parse_file_positional_datetime_failure",
"tests/io/test_metar.py::test_parse_file_bad_encoding",
"tests/io/test_metar.py::test_parse_file_object",
"tests/io/test_metar.py::test_parse_no_pint_objects_in_df",
"tests/io/test_metar.py::test_repr",
"tests/test_xarray.py::test_pyproj_projection",
"tests/test_xarray.py::test_no_projection",
"tests/test_xarray.py::test_unit_array",
"tests/test_xarray.py::test_units",
"tests/test_xarray.py::test_units_data",
"tests/test_xarray.py::test_magnitude_with_quantity",
"tests/test_xarray.py::test_magnitude_without_quantity",
"tests/test_xarray.py::test_convert_units",
"tests/test_xarray.py::test_convert_to_base_units",
"tests/test_xarray.py::test_convert_coordinate_units",
"tests/test_xarray.py::test_quantify",
"tests/test_xarray.py::test_dequantify",
"tests/test_xarray.py::test_dataset_quantify",
"tests/test_xarray.py::test_dataset_dequantify",
"tests/test_xarray.py::test_radian_projection_coords",
"tests/test_xarray.py::test_missing_grid_mapping_valid",
"tests/test_xarray.py::test_missing_grid_mapping_invalid",
"tests/test_xarray.py::test_missing_grid_mapping_var",
"tests/test_xarray.py::test_parsecf_crs",
"tests/test_xarray.py::test_parsecf_existing_scalar_crs",
"tests/test_xarray.py::test_parsecf_existing_vector_crs",
"tests/test_xarray.py::test_preprocess_and_wrap_only_preprocessing",
"tests/test_xarray.py::test_coordinates_basic_by_method",
"tests/test_xarray.py::test_coordinates_basic_by_property",
"tests/test_xarray.py::test_coordinates_specified_by_name_with_dataset",
"tests/test_xarray.py::test_coordinates_specified_by_dataarray_with_dataset",
"tests/test_xarray.py::test_missing_coordinate_type",
"tests/test_xarray.py::test_assign_coordinates_not_overwrite",
"tests/test_xarray.py::test_resolve_axis_conflict_lonlat_and_xy",
"tests/test_xarray.py::test_resolve_axis_conflict_double_lonlat",
"tests/test_xarray.py::test_resolve_axis_conflict_double_xy",
"tests/test_xarray.py::test_resolve_axis_conflict_double_x_with_single_dim",
"tests/test_xarray.py::test_resolve_axis_conflict_double_vertical",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple0]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple1]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple2]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple3]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple4]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple5]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple6]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple7]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple8]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple9]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple10]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple11]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple12]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple13]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple14]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple15]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple16]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple17]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple18]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple19]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple20]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple21]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple22]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple23]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple24]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple25]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple26]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple27]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple28]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple29]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple30]",
"tests/test_xarray.py::test_check_axis_criterion_match[test_tuple31]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple0]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple1]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple2]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple3]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple4]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple5]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple6]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple7]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple8]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple9]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple10]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple11]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple12]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple13]",
"tests/test_xarray.py::test_check_axis_unit_match[test_tuple14]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple0]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple1]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple2]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple3]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple4]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple5]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple6]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple7]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple8]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple9]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple10]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple11]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple12]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple13]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple14]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple15]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple16]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple17]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple18]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple19]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple20]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple21]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple22]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple23]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple24]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple25]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple26]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple27]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple28]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple29]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple30]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple31]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple32]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple33]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple34]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple35]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple36]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple37]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple38]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple39]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple40]",
"tests/test_xarray.py::test_check_axis_regular_expression_match[test_tuple41]",
"tests/test_xarray.py::test_narr_example_variable_without_grid_mapping",
"tests/test_xarray.py::test_coordinates_identical_true",
"tests/test_xarray.py::test_coordinates_identical_false_number_of_coords",
"tests/test_xarray.py::test_coordinates_identical_false_coords_mismatch",
"tests/test_xarray.py::test_check_matching_coordinates",
"tests/test_xarray.py::test_find_axis_name_integer",
"tests/test_xarray.py::test_find_axis_name_axis_type",
"tests/test_xarray.py::test_find_axis_name_dim_coord_name",
"tests/test_xarray.py::test_find_axis_name_bad_identifier",
"tests/test_xarray.py::test_find_axis_number_integer",
"tests/test_xarray.py::test_find_axis_number_axis_type",
"tests/test_xarray.py::test_find_axis_number_dim_coord_number",
"tests/test_xarray.py::test_find_axis_number_bad_identifier",
"tests/test_xarray.py::test_cf_parse_with_grid_mapping",
"tests/test_xarray.py::test_data_array_loc_get_with_units",
"tests/test_xarray.py::test_data_array_loc_set_with_units",
"tests/test_xarray.py::test_data_array_loc_with_ellipsis",
"tests/test_xarray.py::test_data_array_loc_non_tuple",
"tests/test_xarray.py::test_data_array_loc_too_many_indices",
"tests/test_xarray.py::test_data_array_sel_dict_with_units",
"tests/test_xarray.py::test_data_array_sel_kwargs_with_units",
"tests/test_xarray.py::test_dataset_loc_with_units",
"tests/test_xarray.py::test_dataset_sel_kwargs_with_units",
"tests/test_xarray.py::test_dataset_sel_non_dict_pos_arg",
"tests/test_xarray.py::test_dataset_sel_mixed_dict_and_kwarg",
"tests/test_xarray.py::test_dataset_loc_without_dict",
"tests/test_xarray.py::test_dataset_parse_cf_keep_attrs",
"tests/test_xarray.py::test_check_axis_with_bad_unit",
"tests/test_xarray.py::test_dataset_parse_cf_varname_list",
"tests/test_xarray.py::test_coordinate_identification_shared_but_not_equal_coords",
"tests/test_xarray.py::test_one_dimensional_lat_lon",
"tests/test_xarray.py::test_auxilary_lat_lon_with_xy",
"tests/test_xarray.py::test_auxilary_lat_lon_without_xy",
"tests/test_xarray.py::test_auxilary_lat_lon_without_xy_as_xy",
"tests/test_xarray.py::test_assign_crs_error_with_both_attrs",
"tests/test_xarray.py::test_assign_crs_error_with_neither_attrs",
"tests/test_xarray.py::test_assign_latitude_longitude_no_horizontal",
"tests/test_xarray.py::test_assign_y_x_no_horizontal",
"tests/test_xarray.py::test_assign_latitude_longitude_basic_dataarray",
"tests/test_xarray.py::test_assign_latitude_longitude_error_existing_dataarray",
"tests/test_xarray.py::test_assign_latitude_longitude_force_existing_dataarray",
"tests/test_xarray.py::test_assign_latitude_longitude_basic_dataset",
"tests/test_xarray.py::test_assign_y_x_basic_dataarray",
"tests/test_xarray.py::test_assign_y_x_error_existing_dataarray",
"tests/test_xarray.py::test_assign_y_x_force_existing_dataarray",
"tests/test_xarray.py::test_assign_y_x_dataarray_outside_tolerance",
"tests/test_xarray.py::test_assign_y_x_dataarray_transposed",
"tests/test_xarray.py::test_assign_y_x_dataset_assumed_order",
"tests/test_xarray.py::test_assign_y_x_error_existing_dataset",
"tests/test_xarray.py::test_update_attribute_dictionary",
"tests/test_xarray.py::test_update_attribute_callable",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test0-other0-False-expected0]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test1-other1-True-expected1]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test2-other2-False-expected2]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test3-other3-True-expected3]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test4-other4-False-expected4]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test5-other5-True-expected5]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test6-other6-False-expected6]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test7-other7-True-expected7]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test8-other8-False-expected8]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test9-other9-True-expected9]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test10-other10-False-expected10]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test11-other11-False-expected11]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test12-other12-True-expected12]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test13-other13-False-expected13]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg[test14-other14-True-expected14]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg_raising_dimensionality_error[test0-other0]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg_raising_dimensionality_error[test1-other1]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg_raising_dimensionality_error[test2-other2]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg_raising_dimensionality_error[test3-other3]",
"tests/test_xarray.py::test_wrap_with_wrap_like_kwarg_raising_dimensionality_error[test4-other4]",
"tests/test_xarray.py::test_wrap_with_argument_kwarg",
"tests/test_xarray.py::test_preprocess_and_wrap_with_broadcasting",
"tests/test_xarray.py::test_preprocess_and_wrap_broadcasting_error",
"tests/test_xarray.py::test_preprocess_and_wrap_with_to_magnitude",
"tests/test_xarray.py::test_preprocess_and_wrap_with_variable",
"tests/test_xarray.py::test_grid_deltas_from_dataarray_lonlat",
"tests/test_xarray.py::test_grid_deltas_from_dataarray_xy",
"tests/test_xarray.py::test_grid_deltas_from_dataarray_nominal_lonlat",
"tests/test_xarray.py::test_grid_deltas_from_dataarray_lonlat_assumed_order",
"tests/test_xarray.py::test_grid_deltas_from_dataarray_invalid_kind",
"tests/test_xarray.py::test_add_grid_arguments_from_dataarray",
"tests/test_xarray.py::test_add_vertical_dim_from_xarray",
"tests/units/test_units.py::test_concatenate",
"tests/units/test_units.py::test_concatenate_masked",
"tests/units/test_units.py::test_axhline",
"tests/units/test_units.py::test_axvline",
"tests/units/test_units.py::test_good_units[some",
"tests/units/test_units.py::test_good_units[all",
"tests/units/test_units.py::test_bad[one",
"tests/units/test_units.py::test_bad[all",
"tests/units/test_units.py::test_bad[mixed",
"tests/units/test_units.py::test_bad_masked_array[some",
"tests/units/test_units.py::test_bad_masked_array[all",
"tests/units/test_units.py::test_pandas_units_simple",
"tests/units/test_units.py::test_pandas_units_on_dataframe",
"tests/units/test_units.py::test_pandas_units_on_dataframe_not_all_with_units",
"tests/units/test_units.py::test_pandas_units_no_units_given",
"tests/units/test_units.py::test_added_degrees_units",
"tests/units/test_units.py::test_is_quantity",
"tests/units/test_units.py::test_is_quantity_multiple",
"tests/units/test_units.py::test_gpm_unit",
"tests/units/test_units.py::test_assert_nan",
"tests/units/test_units.py::test_assert_nan_checks_units",
"tests/units/test_units.py::test_percent_units",
"tests/units/test_units.py::test_udunits_power_syntax[m",
"tests/units/test_units.py::test_udunits_power_syntax[m2",
"tests/units/test_units.py::test_udunits_power_syntax[kg(-1)-pint_unit2]",
"tests/units/test_units.py::test_udunits_power_syntax[kg-1-pint_unit3]",
"tests/units/test_units.py::test_udunits_power_syntax[W",
"tests/units/test_units.py::test_udunits_power_syntax[(W",
"tests/units/test_units.py::test_udunits_power_syntax[(J"
] | [
"tests/test_xarray.py::test_units_percent",
"tests/test_xarray.py::test_time_deltas"
] | [] | [] | BSD 3-Clause "New" or "Revised" License | 11,861 | 2,251 | [
"src/metpy/interpolate/slices.py",
"src/metpy/units.py",
"src/metpy/xarray.py"
] |
IKNL__vantage6-85 | a5b1d13084046d2621a0394719792f17e1712ac9 | 2021-12-21 15:13:42 | a5b1d13084046d2621a0394719792f17e1712ac9 | diff --git a/vantage6/cli/configuration_wizard.py b/vantage6/cli/configuration_wizard.py
index cc30ac9..df35d74 100644
--- a/vantage6/cli/configuration_wizard.py
+++ b/vantage6/cli/configuration_wizard.py
@@ -75,6 +75,14 @@ def node_configuration_questionaire(dirs, instance_name):
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL",
"NOTSET"]).ask()
+ is_add_vpn = q.confirm(
+ "Do you want to connect to a VPN server?", default=False).ask()
+ if is_add_vpn:
+ config['vpn_subnet'] = q.text(
+ message="Subnet of the VPN server you want to connect to:",
+ default='10.76.0.0/16'
+ ).ask()
+
config["logging"] = {
"level": res,
"file": f"{instance_name}.log",
@@ -148,6 +156,44 @@ def server_configuration_questionaire(dirs, instance_name):
choices=["DEBUG", "INFO", "WARNING", "ERROR",
"CRITICAL", "NOTSET"]).ask()
+ is_add_vpn = q.confirm(
+ "Do you want to add a VPN server?", default=False).ask()
+ if is_add_vpn:
+ vpn_config = q.prompt([
+ {
+ "type": "text",
+ "name": "url",
+ "message": "VPN server URL:",
+ },
+ {
+ "type": "text",
+ "name": "portal_username",
+ "message": "VPN portal username:",
+ },
+ {
+ "type": "password",
+ "name": "portal_userpass",
+ "message": "VPN portal password:",
+ },
+ {
+ "type": "text",
+ "name": "client_id",
+ "message": "VPN client username:",
+ },
+ {
+ "type": "password",
+ "name": "client_secret",
+ "message": "VPN client password:",
+ },
+ {
+ "type": "text",
+ "name": "redirect_url",
+ "message": "Redirect url (should be local address of server)",
+ "default": "http://localhost"
+ }
+ ])
+ config['vpn_server'] = vpn_config
+
config["logging"] = {
"level": res,
"file": f"{instance_name}.log",
diff --git a/vantage6/cli/server.py b/vantage6/cli/server.py
index 71a9902..e61a0fb 100644
--- a/vantage6/cli/server.py
+++ b/vantage6/cli/server.py
@@ -314,7 +314,6 @@ def cli_server_files(ctx):
default=DEFAULT_SERVER_SYSTEM_FOLDERS)
def cli_server_new(name, environment, system_folders):
"""Create new configuration."""
-
if not name:
name = q.text("Please enter a configuration-name:").ask()
name_new = name.replace(" ", "-")
| Extend CLI to support VPN configuration
The CLI does not allow to configure the VPN server. This needs to be added to the following commands:
- [x] `vserver new`
- [x] `vserver-local new`
- [x] `vnode new`
- [x] `vnode-local new` | IKNL/vantage6 | diff --git a/tests/test_wizard.py b/tests/test_wizard.py
index 6efd496..7682cc2 100644
--- a/tests/test_wizard.py
+++ b/tests/test_wizard.py
@@ -12,6 +12,7 @@ from vantage6.cli.configuration_wizard import (
module_path = "vantage6.cli.configuration_wizard"
+
class WizardTest(unittest.TestCase):
@staticmethod
@@ -33,12 +34,12 @@ class WizardTest(unittest.TestCase):
with patch(f"{module_path}.q") as q:
q.prompt.side_effect = self.prompts
- q.confirm.return_value.ask.side_effect = [True, False]
+ q.confirm.return_value.ask.side_effect = [True, False, True]
dirs = MagicMock(data="/")
config = node_configuration_questionaire(dirs, "iknl")
keys = ["api_key", "server_url", "port", "api_path", "task_dir",
- "databases", "logging", "encryption"]
+ "databases", "logging", "encryption", "vpn_subnet"]
for key in keys:
self.assertIn(key, config)
@@ -46,12 +47,13 @@ class WizardTest(unittest.TestCase):
with patch(f"{module_path}.q") as q:
q.prompt.side_effect = self.prompts
- q.confirm.return_value.ask.side_effect = [True]
+ q.confirm.return_value.ask.side_effect = [True, True]
config = server_configuration_questionaire("", "vantage6")
keys = ["description", "ip", "port", "api_path", "uri",
- "allow_drop_all", "jwt_secret_key", "logging"]
+ "allow_drop_all", "jwt_secret_key", "logging",
+ "vpn_server"]
for key in keys:
self.assertIn(key, config)
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 3
},
"num_modified_files": 2
} | 3.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | appdirs==1.4.3
backcall==0.2.0
certifi==2025.1.31
cffi==1.17.1
chardet==3.0.4
charset-normalizer==3.4.1
click==8.0.3
colorama==0.4.3
contextlib2==0.5.5
coverage==4.5.4
cryptography==2.8
decorator==5.2.1
docker==4.2.0
exceptiongroup==1.2.2
idna==2.10
iniconfig==2.1.0
ipython==7.13.0
isodate==0.7.2
jedi==0.19.2
numpy==2.0.2
packaging==24.2
pandas==1.5.3
parso==0.8.4
pexpect==4.9.0
pickleshare==0.7.5
pluggy==1.5.0
prompt_toolkit==3.0.50
ptyprocess==0.7.0
pycparser==2.22
pyfiglet==0.8.post1
Pygments==2.19.1
PyJWT==1.7.1
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.8.1
pytz==2025.2
PyYAML==5.3.1
questionary==1.5.2
rdflib==7.1.4
requests==2.23.0
schema==0.7.1
six==1.17.0
SPARQLWrapper==1.8.5
SQLAlchemy==1.3.15
termcolor==1.1.0
tomli==2.2.1
traitlets==5.14.3
urllib3==1.25.11
-e git+https://github.com/IKNL/vantage6.git@a5b1d13084046d2621a0394719792f17e1712ac9#egg=vantage6
vantage6-client==3.0.0b7
vantage6-common==3.0.0b7
wcwidth==0.2.13
websocket-client==1.8.0
| name: vantage6
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- appdirs==1.4.3
- backcall==0.2.0
- certifi==2025.1.31
- cffi==1.17.1
- chardet==3.0.4
- charset-normalizer==3.4.1
- click==8.0.3
- colorama==0.4.3
- contextlib2==0.5.5
- coverage==4.5.4
- cryptography==2.8
- decorator==5.2.1
- docker==4.2.0
- exceptiongroup==1.2.2
- idna==2.10
- iniconfig==2.1.0
- ipython==7.13.0
- isodate==0.7.2
- jedi==0.19.2
- numpy==2.0.2
- packaging==24.2
- pandas==1.5.3
- parso==0.8.4
- pexpect==4.9.0
- pickleshare==0.7.5
- pluggy==1.5.0
- prompt-toolkit==3.0.50
- ptyprocess==0.7.0
- pycparser==2.22
- pyfiglet==0.8.post1
- pygments==2.19.1
- pyjwt==1.7.1
- pyparsing==3.2.3
- pytest==8.3.5
- python-dateutil==2.8.1
- pytz==2025.2
- pyyaml==5.3.1
- questionary==1.5.2
- rdflib==7.1.4
- requests==2.23.0
- schema==0.7.1
- six==1.17.0
- sparqlwrapper==1.8.5
- sqlalchemy==1.3.15
- termcolor==1.1.0
- tomli==2.2.1
- traitlets==5.14.3
- urllib3==1.25.11
- vantage6-client==3.0.0b7
- vantage6-common==3.0.0b7
- wcwidth==0.2.13
- websocket-client==1.8.0
prefix: /opt/conda/envs/vantage6
| [
"tests/test_wizard.py::WizardTest::test_node_wizard",
"tests/test_wizard.py::WizardTest::test_server_wizard"
] | [] | [
"tests/test_wizard.py::WizardTest::test_configuration_wizard_interface",
"tests/test_wizard.py::WizardTest::test_select_configuration"
] | [] | Apache License 2.0 | 11,862 | 711 | [
"vantage6/cli/configuration_wizard.py",
"vantage6/cli/server.py"
] |
|
sdispater__pendulum-593 | 8012a7e8600c2348f1978eebb22fdd2535a8cca9 | 2021-12-21 19:41:50 | df88b0e451732fb11267c8cbd38cc811dfcac094 | diff --git a/pendulum/duration.py b/pendulum/duration.py
index 45df13d..47a6a38 100644
--- a/pendulum/duration.py
+++ b/pendulum/duration.py
@@ -23,6 +23,10 @@ def _divide_and_round(a, b):
# Based on the reference implementation for divmod_near
# in Objects/longobject.c.
q, r = divmod(a, b)
+
+ if isinstance(q, float):
+ q = int(q)
+
# round up if either r / b > 0.5, or r / b == 0.5 and q is odd.
# The expression r / b > 0.5 is equivalent to 2 * r > b if b is
# positive, 2 * r < b if b negative.
| Error dividing duration by float
<!--
Hi there! Thank you for discovering and submitting an issue.
Before you submit this; let's make sure of a few things.
Please make sure the following boxes are ticked if they are correct.
If not, please try and fulfill these first.
-->
<!-- Checked checkbox should look like this: [x] -->
- [x] I am on the [latest](https://github.com/sdispater/pendulum/releases/latest) Pendulum version.
- [x] I have searched the [issues](https://github.com/sdispater/pendulum/issues) of this repo and believe that this is not a duplicate.
<!--
Once those are done, if you're able to fill in the following list with your information,
it'd be very helpful to whoever handles the issue.
-->
- **OS version and name**: Windows 10, version 20H2
- **Pendulum version**: 2.1.2
## Issue
<!-- Now feel free to write your issue, but please be descriptive! Thanks again 🙌 ❤️ -->
In pendulum:
```python
import pendulum
d = pendulum.duration(hours=4, minutes=5)
d / 1.1
```
It gives the following error:
```python
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\lib\site-packages\pendulum\duration.py", line 396, in __truediv__
months=_divide_and_round(self._months, other),
File "C:\Python\lib\site-packages\pendulum\duration.py", line 66, in __new__
raise ValueError("Float year and months are not supported")
ValueError: Float year and months are not supported
```
Using datetime.timedelta:
```python
from datetime import timedelta
t = timedelta(seconds=4*3600+5*60)
t / 1.1
# datetime.timedelta(seconds=13363, microseconds=636364)
```
It doesn't raise any error. Both objects represent the same amount of time:
```python
from datetime import timedelta
import pendulum
d = pendulum.duration(hours=4, minutes=5)
t = timedelta(seconds=4*3600+5*60)
assert d.as_timedelta() == t
``` | sdispater/pendulum | diff --git a/tests/duration/test_arithmetic.py b/tests/duration/test_arithmetic.py
index fad38b6..0f3283a 100644
--- a/tests/duration/test_arithmetic.py
+++ b/tests/duration/test_arithmetic.py
@@ -38,12 +38,24 @@ def test_divide():
assert isinstance(mul, pendulum.Duration)
assert_duration(mul, 0, 0, 0, 1, 0, 0, 17, 761111)
+ it = pendulum.duration(days=2, seconds=35, microseconds=522222)
+ mul = it / 1.1
+
+ assert isinstance(mul, pendulum.Duration)
+ assert_duration(mul, 0, 0, 0, 1, 19, 38, 43, 202020)
+
it = pendulum.duration(years=2, months=4, days=2, seconds=35, microseconds=522222)
mul = it / 2
assert isinstance(mul, pendulum.Duration)
assert_duration(mul, 1, 2, 0, 1, 0, 0, 17, 761111)
+ it = pendulum.duration(years=2, months=4, days=2, seconds=35, microseconds=522222)
+ mul = it / 2.0
+
+ assert isinstance(mul, pendulum.Duration)
+ assert_duration(mul, 1, 2, 0, 1, 0, 0, 17, 761111)
+
def test_floor_divide():
it = pendulum.duration(days=2, seconds=34, microseconds=522222)
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 2.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
iniconfig==2.1.0
packaging==24.2
-e git+https://github.com/sdispater/pendulum.git@8012a7e8600c2348f1978eebb22fdd2535a8cca9#egg=pendulum
pluggy==1.5.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
pytzdata==2020.1
six==1.17.0
tomli==2.2.1
typing_extensions==4.13.0
| name: pendulum
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- coverage==7.8.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- iniconfig==2.1.0
- packaging==24.2
- pendulum==2.1.1
- pluggy==1.5.0
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- pytzdata==2020.1
- six==1.17.0
- tomli==2.2.1
- typing-extensions==4.13.0
prefix: /opt/conda/envs/pendulum
| [
"tests/duration/test_arithmetic.py::test_divide"
] | [] | [
"tests/duration/test_arithmetic.py::test_multiply",
"tests/duration/test_arithmetic.py::test_floor_divide"
] | [] | MIT License | 11,864 | 199 | [
"pendulum/duration.py"
] |
|
CS-SI__eodag-380 | 6e6e6890a52ac8ad4d0f989f41a726b35d9cf5d8 | 2021-12-22 16:01:32 | d9f16f411fdf5eb6ad752f984782dd06ed882dc8 | diff --git a/eodag/api/core.py b/eodag/api/core.py
index 0ce2f7fe..7d5d039b 100644
--- a/eodag/api/core.py
+++ b/eodag/api/core.py
@@ -17,6 +17,7 @@
# limitations under the License.
import logging
import os
+import re
import shutil
from operator import itemgetter
@@ -1055,6 +1056,31 @@ class EODataAccessGateway(object):
# be returned as a search result if there was no search extent (because we
# will not try to do an intersection)
for eo_product in res:
+ # if product_type is not defined, try to guess using properties
+ if eo_product.product_type is None:
+ pattern = re.compile(r"[^\w,]+")
+ try:
+ guesses = self.guess_product_type(
+ **{
+ # k:str(v) for k,v in eo_product.properties.items()
+ k: pattern.sub("", str(v).upper())
+ for k, v in eo_product.properties.items()
+ if k
+ in [
+ "instrument",
+ "platform",
+ "platformSerialIdentifier",
+ "processingLevel",
+ "sensorType",
+ "keywords",
+ ]
+ and v is not None
+ }
+ )
+ except NoMatchingProductType:
+ pass
+ else:
+ eo_product.product_type = guesses[0]
if eo_product.search_intersection is not None:
download_plugin = self._plugins_manager.get_download_plugin(
eo_product
| prevent mixed results between earth_search and earth_search_cog
See #362 .
@GriffinBabe pointed out that if we omit to specify the product type when searching on `earth_search_cog`, we get also results from `earth_search` that cannot be downloaded with the wrong download plugin:
```py
from eodag import EODataAccessGateway
dag = EODataAccessGateway()
dag.set_preferred_provider("earth_search_cog")
# Here I forget to specify which productType I am looking for
cog_products, _ = dag.search()
path = dag.download(cog_products[0])
```
Raises
```
requests.exceptions.InvalidSchema: No connection adapters were found for 's3://sentinel-s2-l2a/tiles/42/F/UK/2021/11/23/0/qi/L2A_PVI.jp2'
```
To prevent this, we'd have to:
- [ ] only accept `S2_MSI_L2A_COG` product type with `earth_search_cog`
- [ ] filter out `S2_MSI_L2A_COG` product type with `earth_search`
| CS-SI/eodag | diff --git a/tests/integration/test_search_stac_static.py b/tests/integration/test_search_stac_static.py
index ee3483b0..71a31b4c 100644
--- a/tests/integration/test_search_stac_static.py
+++ b/tests/integration/test_search_stac_static.py
@@ -83,8 +83,8 @@ class TestSearchStacStatic(unittest.TestCase):
self.assertIsInstance(items, SearchResult)
self.assertEqual(len(items), self.child_cat_len)
self.assertEqual(items[0].provider, self.stac_provider)
- # if no product_type is provided, product_type is None
- self.assertIsNone(items[0].product_type)
+ # if no product_type is provided, product_type should be guessed from properties
+ self.assertEqual(items[0].product_type, "S2_MSI_L1C")
def test_search_stac_static_load_root_not_recursive(self):
"""load_stac_items from root must provide an empty list when no recursive"""
@@ -120,8 +120,8 @@ class TestSearchStacStatic(unittest.TestCase):
self.assertIsInstance(item, SearchResult)
self.assertEqual(len(item), 1)
self.assertEqual(item[0].provider, self.stac_provider)
- # if no product_type is provided, product_type is None
- self.assertIsNone(item[0].product_type)
+ # if no product_type is provided, product_type should be guessed from properties
+ self.assertEqual(item[0].product_type, "S2_MSI_L1C")
def test_search_stac_static_load_item_updated_provider(self):
"""load_stac_items from a single item using updated provider"""
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 1
},
"num_modified_files": 1
} | 2.3 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y make pandoc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
backports.tarfile==1.2.0
blinker==1.9.0
boto3==1.37.23
botocore==1.37.23
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.4.1
click==8.1.8
colorama==0.4.6
coverage==7.8.0
cryptography==44.0.2
distlib==0.3.9
docutils==0.21.2
-e git+https://github.com/CS-SI/eodag.git@6e6e6890a52ac8ad4d0f989f41a726b35d9cf5d8#egg=eodag
exceptiongroup==1.2.2
Faker==37.1.0
filelock==3.18.0
flake8==7.2.0
flasgger==0.9.7.1
Flask==3.1.0
geojson==3.2.0
id==1.5.0
identify==2.6.9
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
itsdangerous==2.2.0
jaraco.classes==3.4.0
jaraco.context==6.0.1
jaraco.functools==4.1.0
jeepney==0.9.0
Jinja2==3.1.6
jmespath==1.0.1
jsonpath-ng==1.7.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
keyring==25.6.0
lxml==5.3.1
Markdown==3.7
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mccabe==0.7.0
mdurl==0.1.2
mistune==3.1.3
more-itertools==10.6.0
moto==5.1.2
nh3==0.2.21
nodeenv==1.9.1
nose==1.3.7
numpy==2.0.2
OWSLib==0.31.0
packaging==24.2
pandas==2.2.3
platformdirs==4.3.7
pluggy==1.5.0
ply==3.11
pre_commit==4.2.0
pycodestyle==2.13.0
pycparser==2.22
pyflakes==3.3.1
Pygments==2.19.1
pyproj==3.6.1
pyproject-api==1.9.0
pyshp==2.3.1
pystac==1.10.1
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.2
readme_renderer==44.0
referencing==0.36.2
requests==2.32.3
requests-futures==1.0.2
requests-toolbelt==1.0.0
responses==0.25.7
rfc3986==2.0.0
rich==14.0.0
rpds-py==0.24.0
s3transfer==0.11.4
SecretStorage==3.3.3
shapely==2.0.7
six==1.17.0
tomli==2.2.1
tox==4.25.0
tqdm==4.67.1
twine==6.1.0
typing_extensions==4.13.0
tzdata==2025.2
urllib3==1.26.20
usgs==0.3.5
virtualenv==20.29.3
Werkzeug==3.1.3
Whoosh==2.7.4
xarray==2024.7.0
xmltodict==0.14.2
zipp==3.21.0
| name: eodag
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- backports-tarfile==1.2.0
- blinker==1.9.0
- boto3==1.37.23
- botocore==1.37.23
- cachetools==5.5.2
- certifi==2025.1.31
- cffi==1.17.1
- cfgv==3.4.0
- chardet==5.2.0
- charset-normalizer==3.4.1
- click==8.1.8
- colorama==0.4.6
- coverage==7.8.0
- cryptography==44.0.2
- distlib==0.3.9
- docutils==0.21.2
- exceptiongroup==1.2.2
- faker==37.1.0
- filelock==3.18.0
- flake8==7.2.0
- flasgger==0.9.7.1
- flask==3.1.0
- geojson==3.2.0
- id==1.5.0
- identify==2.6.9
- idna==3.10
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- itsdangerous==2.2.0
- jaraco-classes==3.4.0
- jaraco-context==6.0.1
- jaraco-functools==4.1.0
- jeepney==0.9.0
- jinja2==3.1.6
- jmespath==1.0.1
- jsonpath-ng==1.7.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- keyring==25.6.0
- lxml==5.3.1
- markdown==3.7
- markdown-it-py==3.0.0
- markupsafe==3.0.2
- mccabe==0.7.0
- mdurl==0.1.2
- mistune==3.1.3
- more-itertools==10.6.0
- moto==5.1.2
- nh3==0.2.21
- nodeenv==1.9.1
- nose==1.3.7
- numpy==2.0.2
- owslib==0.31.0
- packaging==24.2
- pandas==2.2.3
- platformdirs==4.3.7
- pluggy==1.5.0
- ply==3.11
- pre-commit==4.2.0
- pycodestyle==2.13.0
- pycparser==2.22
- pyflakes==3.3.1
- pygments==2.19.1
- pyproj==3.6.1
- pyproject-api==1.9.0
- pyshp==2.3.1
- pystac==1.10.1
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pyyaml==6.0.2
- readme-renderer==44.0
- referencing==0.36.2
- requests==2.32.3
- requests-futures==1.0.2
- requests-toolbelt==1.0.0
- responses==0.25.7
- rfc3986==2.0.0
- rich==14.0.0
- rpds-py==0.24.0
- s3transfer==0.11.4
- secretstorage==3.3.3
- shapely==2.0.7
- six==1.17.0
- tomli==2.2.1
- tox==4.25.0
- tqdm==4.67.1
- twine==6.1.0
- typing-extensions==4.13.0
- tzdata==2025.2
- urllib3==1.26.20
- usgs==0.3.5
- virtualenv==20.29.3
- werkzeug==3.1.3
- whoosh==2.7.4
- xarray==2024.7.0
- xmltodict==0.14.2
- zipp==3.21.0
prefix: /opt/conda/envs/eodag
| [
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_load_child",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_load_item"
] | [] | [
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_by_cloudcover",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_by_date",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_by_geom",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_by_property",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_crunch_filter_date",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_crunch_filter_lastest_by_name",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_crunch_filter_overlap",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_crunch_filter_property",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_load_item_updated_provider",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_load_root_not_recursive",
"tests/integration/test_search_stac_static.py::TestSearchStacStatic::test_search_stac_static_load_root_recursive"
] | [] | Apache License 2.0 | 11,869 | 367 | [
"eodag/api/core.py"
] |
|
fatiando__verde-357 | e5675dd442459c36a97ed8690305676f777cb75f | 2021-12-23 16:40:07 | 0a4478ad8bfaa5ca80753b09b37417cc1935624e | diff --git a/doc/gallery_src/checkerboard.py b/doc/gallery_src/checkerboard.py
index c17a832..277e0ac 100644
--- a/doc/gallery_src/checkerboard.py
+++ b/doc/gallery_src/checkerboard.py
@@ -9,8 +9,8 @@ Checkerboard function
=====================
The :class:`verde.synthetic.CheckerBoard` class generates synthetic data in a
-checkerboard pattern. It has the same data generation methods that most
-gridders have: predict, grid, scatter, and profile.
+checkerboard pattern. It has different data generation methods, some of which
+are shared with most other gridders: predict, grid, profile, and scatter.
"""
import matplotlib.pyplot as plt
diff --git a/doc/gallery_src/cubic_gridder.py b/doc/gallery_src/cubic_gridder.py
index cec5d2d..7b388c5 100644
--- a/doc/gallery_src/cubic_gridder.py
+++ b/doc/gallery_src/cubic_gridder.py
@@ -87,5 +87,5 @@ plt.colorbar(pc).set_label("meters")
ax.plot(*coordinates, ".k", markersize=0.1, transform=crs)
# Use an utility function to setup the tick labels and the land feature
vd.datasets.setup_baja_bathymetry_map(ax)
-ax.set_title("Linear gridding of bathymetry")
+ax.set_title("Cubic gridding of bathymetry")
plt.show()
diff --git a/verde/base/base_classes.py b/verde/base/base_classes.py
index fa74970..30414da 100644
--- a/verde/base/base_classes.py
+++ b/verde/base/base_classes.py
@@ -531,6 +531,12 @@ class BaseGridder(BaseEstimator):
dimensions and the data field(s) in the output
:class:`pandas.DataFrame`. Default names are provided.
+ .. warning::
+
+ The ``scatter`` method is deprecated and will be removed in Verde
+ 2.0.0. Use :func:`verde.scatter_points` and the ``predict`` method
+ instead.
+
Parameters
----------
region : list = [W, E, S, N]
@@ -570,6 +576,12 @@ class BaseGridder(BaseEstimator):
The interpolated values on a random set of points.
"""
+ warnings.warn(
+ "The 'scatter' method is deprecated and will be removed in Verde "
+ "2.0.0. Use 'verde.scatter_points' and the 'predict' method "
+ "instead.",
+ FutureWarning,
+ )
dims = self._get_dims(dims)
region = get_instance_region(self, region)
coordinates = scatter_points(region, size, random_state=random_state, **kwargs)
diff --git a/verde/scipygridder.py b/verde/scipygridder.py
index 4295e08..88eb3b4 100644
--- a/verde/scipygridder.py
+++ b/verde/scipygridder.py
@@ -124,7 +124,7 @@ class Linear(_BaseScipyGridder):
rescale : bool
If ``True``, rescale the data coordinates to [0, 1] range before
interpolation. Useful when coordinates vary greatly in scale. Default
- is ``True``.
+ is ``False``.
Attributes
----------
@@ -137,7 +137,7 @@ class Linear(_BaseScipyGridder):
"""
- def __init__(self, rescale=True):
+ def __init__(self, rescale=False):
super().__init__()
self.rescale = rescale
@@ -161,7 +161,7 @@ class Cubic(_BaseScipyGridder):
rescale : bool
If ``True``, rescale the data coordinates to [0, 1] range before
interpolation. Useful when coordinates vary greatly in scale. Default
- is ``True``.
+ is ``False``.
Attributes
----------
@@ -174,7 +174,7 @@ class Cubic(_BaseScipyGridder):
"""
- def __init__(self, rescale=True):
+ def __init__(self, rescale=False):
super().__init__()
self.rescale = rescale
diff --git a/verde/synthetic.py b/verde/synthetic.py
index 762e996..3303c06 100644
--- a/verde/synthetic.py
+++ b/verde/synthetic.py
@@ -5,9 +5,12 @@
# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
#
import numpy as np
+import pandas as pd
from .base import BaseGridder
-from .coordinates import check_region
+from .base.base_classes import get_instance_region, project_coordinates
+from .base.utils import check_data
+from .coordinates import check_region, scatter_points
class CheckerBoard(BaseGridder):
@@ -113,3 +116,82 @@ class CheckerBoard(BaseGridder):
* np.cos((2 * np.pi / self.w_north_) * northing)
)
return data
+
+ def scatter(
+ self,
+ region=None,
+ size=300,
+ random_state=0,
+ dims=None,
+ data_names=None,
+ projection=None,
+ **kwargs,
+ ):
+ """
+ Generate values on a random scatter of points.
+
+ Point coordinates are generated by :func:`verde.scatter_points`. Other
+ arguments for this function can be passed as extra keyword arguments
+ (``kwargs``) to this method.
+
+ By default, the region specified when creating the class instance will
+ be used if ``region=None``.
+
+ Use the *dims* and *data_names* arguments to set custom names for the
+ dimensions and the data field(s) in the output
+ :class:`pandas.DataFrame`. Default names are provided.
+
+ Parameters
+ ----------
+ region : list = [W, E, S, N]
+ The west, east, south, and north boundaries of a given region.
+ size : int
+ The number of points to generate.
+ random_state : numpy.random.RandomState or an int seed
+ A random number generator used to define the state of the random
+ permutations. Use a fixed seed to make sure computations are
+ reproducible. Use ``None`` to choose a seed automatically
+ (resulting in different numbers with each run).
+ dims : list or None
+ The names of the northing and easting data dimensions,
+ respectively, in the output dataframe. Default is determined from
+ the ``dims`` attribute of the class. Must be defined in the
+ following order: northing dimension, easting dimension.
+ **NOTE: This is an exception to the "easting" then
+ "northing" pattern but is required for compatibility with xarray.**
+ data_names : str, list or None
+ The name(s) of the data variables in the output dataframe. Defaults
+ to ``'scalars'`` for scalar data,
+ ``['east_component', 'north_component']`` for 2D vector data, and
+ ``['east_component', 'north_component', 'vertical_component']`` for
+ 3D vector data.
+ projection : callable or None
+ If not None, then should be a callable object
+ ``projection(easting, northing) -> (proj_easting, proj_northing)``
+ that takes in easting and northing coordinate arrays and returns
+ projected northing and easting coordinate arrays. This function
+ will be used to project the generated scatter coordinates before
+ passing them into ``predict``. For example, you can use this to
+ generate a geographic scatter from a Cartesian gridder.
+
+ Returns
+ -------
+ table : pandas.DataFrame
+ The interpolated values on a random set of points.
+
+ """
+ dims = self._get_dims(dims)
+ region = get_instance_region(self, region)
+ coordinates = scatter_points(region, size, random_state=random_state, **kwargs)
+ if projection is None:
+ data = check_data(self.predict(coordinates))
+ else:
+ data = check_data(
+ self.predict(project_coordinates(coordinates, projection))
+ )
+ data_names = self._get_data_names(data, data_names)
+ columns = [(dims[0], coordinates[1]), (dims[1], coordinates[0])]
+ extra_coords_names = self._get_extra_coords_names(coordinates)
+ columns.extend(zip(extra_coords_names, coordinates[2:]))
+ columns.extend(zip(data_names, data))
+ return pd.DataFrame(dict(columns), columns=[c[0] for c in columns])
| Deprecate BaseGridder.scatter
**Description of the desired feature**
The `BaseGridder.scatter` enables every Verde gridder class to predict values on a random set of scattered points making use of the `verde.scatter_points()` function. This method doesn't have too many use cases, and even if we want to predict on a set of scattered points, we can do so by combining `verde.scatter_points()` and the `BaseGridder.predict` method, while building the resulting `pandas.DataFrame` can be done manually without too much effort.
Taking this into account, I think it would be better to deprecate it, so we can make maintenance, testing and inheritance much easier. For ensuring backward compatibility, we should deprecate it after Verde v2.0.0 and add a DeprecationWarning meanwhile.
**Are you willing to help implement and maintain this feature?** Yes, but I would leave it to anyone interested in tackling this down.
<!--
Every feature we add is code that we will have to maintain and keep updated.
This takes a lot of effort. If you are willing to be involved in the project
and help maintain your feature, it will make it easier for us to accept it.
-->
| fatiando/verde | diff --git a/verde/tests/test_base.py b/verde/tests/test_base.py
index 45fa26e..0f55ca3 100644
--- a/verde/tests/test_base.py
+++ b/verde/tests/test_base.py
@@ -150,7 +150,8 @@ def test_basegridder():
# Grid on profile
prof = grd.profile((0, -10), (10, -10), 30)
# Grid on scatter
- scat = grd.scatter(region=region, size=1000, random_state=0)
+ with pytest.warns(FutureWarning):
+ scat = grd.scatter(region=region, size=1000, random_state=0)
for grid in grids:
npt.assert_allclose(grid.scalars.values, data_true)
diff --git a/verde/tests/test_synthetic.py b/verde/tests/test_synthetic.py
new file mode 100644
index 0000000..5f4bd1f
--- /dev/null
+++ b/verde/tests/test_synthetic.py
@@ -0,0 +1,33 @@
+# Copyright (c) 2017 The Verde Developers.
+# Distributed under the terms of the BSD 3-Clause License.
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# This code is part of the Fatiando a Terra project (https://www.fatiando.org)
+#
+"""
+Test the synthetic data generation functions and classes.
+"""
+import numpy.testing as npt
+
+from ..synthetic import CheckerBoard
+
+
+def test_checkerboard_scatter_projection():
+ "Test generating scattered points when passing in a projection"
+
+ # Lets say the projection is doubling the coordinates
+ def proj(lon, lat, inverse=False):
+ "Project from the new coordinates to the original"
+ if inverse:
+ return (lon / 2, lat / 2)
+ return (lon * 2, lat * 2)
+
+ region = (0, 10, -10, -5)
+ region_proj = (0, 5, -5, -2.5)
+ checker = CheckerBoard(region=region)
+ checker_proj = CheckerBoard(region=region_proj)
+ scatter = checker.scatter(region, 1000, random_state=0, projection=proj)
+ scatter_proj = checker_proj.scatter(region, 1000, random_state=0)
+ npt.assert_allclose(scatter.scalars, scatter_proj.scalars)
+ npt.assert_allclose(scatter.easting, scatter_proj.easting)
+ npt.assert_allclose(scatter.northing, scatter_proj.northing)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 3
},
"num_modified_files": 5
} | 1.7 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": true,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster @ file:///home/conda/feedstock_root/build_artifacts/alabaster_1704848697227/work
astor @ file:///home/conda/feedstock_root/build_artifacts/astor_1733838630785/work
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1733250440834/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1741918516150/work
babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1738490167835/work
backports.tarfile @ file:///home/conda/feedstock_root/build_artifacts/backports.tarfile_1733325779670/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1738740337718/work
black @ file:///home/conda/feedstock_root/build_artifacts/black-recipe_1742502760723/work
bleach @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_bleach_1737382993/work
bokeh @ file:///home/conda/feedstock_root/build_artifacts/bokeh_1660586590972/work
Bottleneck @ file:///home/conda/feedstock_root/build_artifacts/bottleneck_1649629657082/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work
build @ file:///croot/build_1692303725845/work
Cartopy @ file:///home/conda/feedstock_root/build_artifacts/cartopy_1646828090471/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1739515848642/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1636046050867/work
cftime @ file:///home/conda/feedstock_root/build_artifacts/cftime_1649636873066/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1735929714516/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1734858813237/work
cloudpickle @ file:///home/conda/feedstock_root/build_artifacts/cloudpickle_1736947526808/work
cmarkgfm @ file:///home/conda/feedstock_root/build_artifacts/cmarkgfm_1649209326886/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1733218098505/work
coverage @ file:///home/conda/feedstock_root/build_artifacts/coverage_1743381221492/work
cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1652967019182/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1733332471406/work
cytoolz==0.11.2
dask @ file:///home/conda/feedstock_root/build_artifacts/dask-core_1677707033352/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1740384970518/work
distributed @ file:///home/conda/feedstock_root/build_artifacts/distributed_1677711074949/work
docutils @ file:///home/conda/feedstock_root/build_artifacts/docutils_1733996309550/work
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1733569351617/work
flake8 @ file:///home/conda/feedstock_root/build_artifacts/flake8_1739898391164/work
flake8-bugbear @ file:///home/conda/feedstock_root/build_artifacts/flake8-bugbear_1734116211316/work
flake8-builtins @ file:///home/conda/feedstock_root/build_artifacts/flake8-builtins_1736204556749/work
flake8-mutable @ file:///home/conda/feedstock_root/build_artifacts/flake8-mutable_1736796633754/work
flake8-rst-docstrings @ file:///home/conda/feedstock_root/build_artifacts/flake8-rst-docstrings_1735327526708/work
flake8-unused-arguments==0.0.13
flake8_functions @ file:///home/conda/feedstock_root/build_artifacts/flake8-functions_1736111074576/work
flake8_simplify @ file:///home/conda/feedstock_root/build_artifacts/flake8-simplify_1736208576303/work
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1651017726246/work
fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1743361113926/work
GDAL==3.4.2
h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1738578511449/work
hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1737618293087/work
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1737618333194/work
id @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_id_1737528654/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
imagesize @ file:///home/conda/feedstock_root/build_artifacts/imagesize_1656939531508/work
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1737420181517/work
importlib_resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1736252299705/work
iniconfig @ file:///home/conda/feedstock_root/build_artifacts/iniconfig_1733223141826/work
ipython @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_ipython_1741457802/work
isort @ file:///home/conda/feedstock_root/build_artifacts/isort_1740643408806/work
jaraco.classes @ file:///home/conda/feedstock_root/build_artifacts/jaraco.classes_1733325873251/work
jaraco.context @ file:///home/conda/feedstock_root/build_artifacts/jaraco.context_1733382590553/work
jaraco.functools @ file:///home/conda/feedstock_root/build_artifacts/jaraco.functools_1733746366381/work
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1733300866624/work
jeepney @ file:///home/conda/feedstock_root/build_artifacts/jeepney_1740828240267/work
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1741263328855/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1733736026804/work
keyring @ file:///home/conda/feedstock_root/build_artifacts/keyring_1735210185992/work
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1648854394530/work
llvmlite==0.39.1
locket @ file:///home/conda/feedstock_root/build_artifacts/locket_1650660393415/work
lz4 @ file:///home/conda/feedstock_root/build_artifacts/lz4_1652795530538/work
markdown-it-py @ file:///home/conda/feedstock_root/build_artifacts/markdown-it-py_1733250460757/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737547956/work
matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1651609453931/work
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1733416936468/work
mccabe @ file:///home/conda/feedstock_root/build_artifacts/mccabe_1733216466933/work
mdurl @ file:///home/conda/feedstock_root/build_artifacts/mdurl_1733255585584/work
more-itertools @ file:///home/conda/feedstock_root/build_artifacts/more-itertools_1736883817510/work
mr_proper @ file:///home/conda/feedstock_root/build_artifacts/mr-proper_1735835586314/work
msgpack @ file:///home/conda/feedstock_root/build_artifacts/msgpack-python_1648745999384/work
munkres==1.1.4
mypy_extensions @ file:///home/conda/feedstock_root/build_artifacts/mypy_extensions_1733230897951/work
netCDF4 @ file:///croot/netcdf4_1673455456943/work
numba @ file:///croot/numba_1670258325998/work
numexpr @ file:///home/conda/feedstock_root/build_artifacts/numexpr_1649636754757/work
numpy @ file:///croot/numpy_and_numpy_base_1672336185480/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas==1.5.3
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1733271261340/work
partd @ file:///home/conda/feedstock_root/build_artifacts/partd_1715026491486/work
pathspec @ file:///home/conda/feedstock_root/build_artifacts/pathspec_1733233363808/work
pep8-naming @ file:///home/conda/feedstock_root/build_artifacts/pep8-naming_1734558393712/work
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1733301927746/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1733327343728/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1652814985504/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_platformdirs_1742485085/work
pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1733222765875/work
pooch @ file:///home/conda/feedstock_root/build_artifacts/pooch_1733421311631/work
prompt_toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1737453357274/work
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1653089181607/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1733302279685/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl#sha256=92c32ff62b5fd8cf325bec5ab90d7be3d2a8ca8c8a3813ff487a8d2002630d1f
pure_eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1733569405015/work
pycodestyle @ file:///home/conda/feedstock_root/build_artifacts/pycodestyle_1733216196861/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
pydata-sphinx-theme==0.8.1
pyflakes @ file:///home/conda/feedstock_root/build_artifacts/pyflakes_1733216066937/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1736243443484/work
pygmt @ file:///home/conda/feedstock_root/build_artifacts/pygmt_1649702621464/work
pykdtree @ file:///home/conda/feedstock_root/build_artifacts/pykdtree_1649628939751/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1743089729650/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1650803092830/work
pyproject_hooks @ file:///home/conda/feedstock_root/build_artifacts/pyproject_hooks_1733710025763/work
PyQt5==5.15.4
PyQt5-sip==12.9.0
pyshp @ file:///home/conda/feedstock_root/build_artifacts/pyshp_1733821528126/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
pytest @ file:///home/conda/feedstock_root/build_artifacts/pytest_1740946542080/work
pytest-cov @ file:///home/conda/feedstock_root/build_artifacts/pytest-cov_1733223023082/work
pytest-mpl @ file:///home/conda/feedstock_root/build_artifacts/pytest-mpl_1734116536345/work
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1742920838005/work
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1648757090803/work
readme-renderer @ file:///home/conda/feedstock_root/build_artifacts/readme_renderer_1692429229234/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
requests-toolbelt @ file:///home/conda/feedstock_root/build_artifacts/requests-toolbelt_1733734787568/work
restructuredtext_lint @ file:///home/conda/feedstock_root/build_artifacts/restructuredtext_lint_1735335051365/work
rfc3986 @ file:///home/conda/feedstock_root/build_artifacts/rfc3986_1733921695259/work
rich @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_rich_1743371105/work/dist
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1652976692230/work
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1653073872310/work
SecretStorage @ file:///home/conda/feedstock_root/build_artifacts/secretstorage_1725915608929/work
Shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1651793120853/work
sip @ file:///home/conda/feedstock_root/build_artifacts/sip_1646101165171/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
snowballstemmer @ file:///home/conda/feedstock_root/build_artifacts/snowballstemmer_1637143057757/work
sortedcontainers @ file:///home/conda/feedstock_root/build_artifacts/sortedcontainers_1738440353519/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1693929250441/work
Sphinx @ file:///home/conda/feedstock_root/build_artifacts/sphinx_1648404928645/work
sphinx-book-theme==0.3.3
sphinx-copybutton @ file:///home/conda/feedstock_root/build_artifacts/sphinx-copybutton_1734572975006/work
sphinx-gallery @ file:///home/conda/feedstock_root/build_artifacts/sphinx-gallery_1636773292501/work
sphinx_design @ file:///home/conda/feedstock_root/build_artifacts/sphinx-design_1650527944719/work
sphinxcontrib-applehelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-applehelp_1674487779667/work
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-htmlhelp_1675256494457/work
sphinxcontrib-jsmath @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-jsmath_1733753744933/work
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-serializinghtml_1649380998999/work
stack_data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1733569443808/work
stdlib-list @ file:///home/conda/feedstock_root/build_artifacts/stdlib-list_1739903779003/work
tblib @ file:///home/conda/feedstock_root/build_artifacts/tblib_1733842374544/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1741878222898/work
toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1734091811753/work
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1733256695513/work
toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1733736030883/work
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1648827254365/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1733367359838/work
twine @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_twine_1737553658/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_typing_extensions_1743201626/work
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1649111910890/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1734859416348/work
-e git+https://github.com/fatiando/verde.git@e5675dd442459c36a97ed8690305676f777cb75f#egg=verde
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1733231326287/work
webencodings @ file:///home/conda/feedstock_root/build_artifacts/webencodings_1733236011802/work
xarray @ file:///home/conda/feedstock_root/build_artifacts/xarray_1711742149839/work
zict @ file:///home/conda/feedstock_root/build_artifacts/zict_1733261551178/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work
zstandard @ file:///croot/zstandard_1677013143055/work
| name: verde
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- alabaster=0.7.16=pyhd8ed1ab_0
- alsa-lib=1.2.3.2=h166bdaf_0
- astor=0.8.1=pyhd8ed1ab_1
- asttokens=3.0.0=pyhd8ed1ab_1
- attr=2.5.1=h166bdaf_0
- attrs=25.3.0=pyh71513ae_0
- babel=2.17.0=pyhd8ed1ab_0
- backports=1.0=pyhd8ed1ab_5
- backports.tarfile=1.2.0=pyhd8ed1ab_1
- beautifulsoup4=4.13.3=pyha770c72_0
- black=25.1.0=pyha5154f8_0
- blas=1.1=openblas
- bleach=6.2.0=pyh29332c3_4
- blosc=1.21.1=h83bc5f7_3
- bokeh=2.4.3=pyhd8ed1ab_3
- boost-cpp=1.74.0=h6cacc03_7
- bottleneck=1.3.4=py310hde88566_1
- brotli=1.0.9=h166bdaf_7
- brotli-bin=1.0.9=h166bdaf_7
- brotli-python=1.0.9=py310hd8f1fbe_7
- build=0.10.0=py310h06a4308_0
- bzip2=1.0.8=h7f98852_4
- c-ares=1.18.1=h7f98852_0
- ca-certificates=2025.2.25=h06a4308_0
- cairo=1.16.0=ha12eb4b_1010
- cartopy=0.20.2=py310hb89acbc_4
- certifi=2025.1.31=pyhd8ed1ab_0
- cffi=1.15.0=py310h0fdd8cc_0
- cfitsio=4.1.0=hd9d235c_0
- cftime=1.6.0=py310hde88566_1
- charset-normalizer=3.4.1=pyhd8ed1ab_0
- click=8.1.8=pyh707e725_0
- cloudpickle=3.1.1=pyhd8ed1ab_0
- cmarkgfm=0.8.0=py310h5764c6d_1
- colorama=0.4.6=pyhd8ed1ab_1
- coverage=7.8.0=pyhe1237c8_0
- cryptography=37.0.2=py310h597c629_0
- curl=7.83.1=h7bff187_0
- cycler=0.12.1=pyhd8ed1ab_1
- cytoolz=0.11.2=py310h5764c6d_2
- dask=2023.3.0=pyhd8ed1ab_0
- dask-core=2023.3.0=pyhd8ed1ab_0
- dbus=1.13.6=h5008d03_3
- dcw-gmt=2.2.0=ha770c72_0
- decorator=5.2.1=pyhd8ed1ab_0
- distributed=2023.3.0=pyhd8ed1ab_0
- docutils=0.17.1=py310hff52083_7
- exceptiongroup=1.2.2=pyhd8ed1ab_1
- executing=2.1.0=pyhd8ed1ab_1
- expat=2.4.8=h27087fc_0
- fftw=3.3.10=nompi_h77c792f_102
- flake8=7.1.2=pyhd8ed1ab_0
- flake8-bugbear=24.12.12=pyhd8ed1ab_0
- flake8-builtins=2.5.0=pyhd8ed1ab_1
- flake8-functions=0.0.8=pyhd8ed1ab_2
- flake8-mutable=1.2.0=pyhd8ed1ab_2
- flake8-rst-docstrings=0.3.0=pyhd8ed1ab_1
- flake8-simplify=0.21.0=pyhd8ed1ab_1
- font-ttf-dejavu-sans-mono=2.37=hab24e00_0
- font-ttf-inconsolata=3.000=h77eed37_0
- font-ttf-source-code-pro=2.038=h77eed37_0
- font-ttf-ubuntu=0.83=h77eed37_3
- fontconfig=2.14.0=h8e229c2_0
- fonts-conda-ecosystem=1=0
- fonts-conda-forge=1=0
- fonttools=4.33.3=py310h5764c6d_0
- freetype=2.10.4=h0708190_1
- freexl=1.0.6=h7f98852_0
- fsspec=2025.3.1=pyhd8ed1ab_0
- geos=3.10.2=h9c3ff4c_0
- geotiff=1.7.1=h509b78c_1
- gettext=0.19.8.1=h73d1719_1008
- ghostscript=9.54.0=h27087fc_2
- giflib=5.2.1=h36c2ea0_2
- gmt=6.3.0=h793420d_4
- gshhg-gmt=2.3.7=ha770c72_1003
- gst-plugins-base=1.18.5=hf529b03_3
- gstreamer=1.20.2=hd4edc92_1
- h2=4.2.0=pyhd8ed1ab_0
- hdf4=4.2.15=h10796ff_3
- hdf5=1.12.1=nompi_h2386368_104
- hpack=4.1.0=pyhd8ed1ab_0
- hyperframe=6.1.0=pyhd8ed1ab_0
- icu=69.1=h9c3ff4c_0
- id=1.5.0=pyh29332c3_0
- idna=3.10=pyhd8ed1ab_1
- imagesize=1.4.1=pyhd8ed1ab_0
- importlib-metadata=8.6.1=pyha770c72_0
- importlib_resources=6.5.2=pyhd8ed1ab_0
- iniconfig=2.0.0=pyhd8ed1ab_1
- ipython=8.34.0=pyh907856f_0
- isort=6.0.1=pyhd8ed1ab_0
- jack=1.9.18=hfd4fe87_1001
- jaraco.classes=3.4.0=pyhd8ed1ab_2
- jaraco.context=6.0.1=pyhd8ed1ab_0
- jaraco.functools=4.1.0=pyhd8ed1ab_0
- jbig=2.1=h7f98852_2003
- jedi=0.19.2=pyhd8ed1ab_1
- jeepney=0.9.0=pyhd8ed1ab_0
- jinja2=3.1.6=pyhd8ed1ab_0
- joblib=1.4.2=pyhd8ed1ab_1
- jpeg=9e=h166bdaf_1
- json-c=0.15=h98cffda_0
- kealib=1.4.14=h87e4c3c_3
- keyring=25.6.0=pyha804496_0
- keyutils=1.6.1=h166bdaf_0
- kiwisolver=1.4.2=py310hbf28c38_1
- krb5=1.19.3=h3790be6_0
- lcms2=2.12=hddcbb42_0
- ld_impl_linux-64=2.40=h12ee557_0
- lerc=3.0=h9c3ff4c_0
- libblas=3.9.0=15_linux64_openblas
- libbrotlicommon=1.0.9=h166bdaf_7
- libbrotlidec=1.0.9=h166bdaf_7
- libbrotlienc=1.0.9=h166bdaf_7
- libcap=2.51=h166bdaf_1
- libcblas=3.9.0=15_linux64_openblas
- libclang=13.0.1=default_hc23dcda_0
- libcups=2.3.3=hf5a7f15_1
- libcurl=7.83.1=h7bff187_0
- libdap4=3.20.6=hd7c4107_2
- libdb=6.2.32=h9c3ff4c_0
- libdeflate=1.10=h7f98852_0
- libedit=3.1.20191231=he28a2e2_2
- libev=4.33=h516909a_1
- libevent=2.1.10=h9b69904_4
- libffi=3.4.4=h6a678d5_1
- libflac=1.3.4=h27087fc_0
- libgcc-ng=11.2.0=h1234567_1
- libgdal=3.4.2=hd724a2d_4
- libgfortran-ng=13.2.0=h69a702a_0
- libgfortran5=13.2.0=ha4646dd_0
- libglib=2.70.2=h174f98d_4
- libgomp=11.2.0=h1234567_1
- libiconv=1.17=h166bdaf_0
- libkml=1.3.0=h238a007_1014
- liblapack=3.9.0=15_linux64_openblas
- libllvm11=11.1.0=hf817b99_3
- libllvm13=13.0.1=hf817b99_2
- libnetcdf=4.8.1=nompi_h329d8a1_102
- libnghttp2=1.47.0=h727a467_0
- libnsl=2.0.0=h7f98852_0
- libogg=1.3.4=h7f98852_1
- libopenblas=0.3.20=pthreads_h78a6416_0
- libopus=1.3.1=h7f98852_1
- libpng=1.6.37=h21135ba_2
- libpq=14.2=hd57d9b9_0
- librttopo=1.1.0=hf69c175_9
- libsndfile=1.0.31=h9c3ff4c_1
- libspatialite=5.0.1=ha867d66_15
- libssh2=1.10.0=ha56f1ee_2
- libstdcxx-ng=11.2.0=h1234567_1
- libtiff=4.3.0=h542a066_3
- libtool=2.4.6=h9c3ff4c_1008
- libuuid=2.32.1=h7f98852_1000
- libvorbis=1.3.7=h9c3ff4c_0
- libwebp=1.2.2=h3452ae3_0
- libwebp-base=1.2.2=h7f98852_1
- libxcb=1.13=h7f98852_1004
- libxkbcommon=1.0.3=he3ba5ed_0
- libxml2=2.9.12=h885dcf4_1
- libzip=1.8.0=h4de3113_1
- libzlib=1.2.11=h166bdaf_1014
- llvmlite=0.39.1=py310he621ea3_0
- locket=1.0.0=pyhd8ed1ab_0
- lz4=4.0.0=py310h5d5e884_2
- lz4-c=1.9.3=h9c3ff4c_1
- markdown-it-py=3.0.0=pyhd8ed1ab_1
- markupsafe=2.1.1=py310h5764c6d_1
- matplotlib=3.5.2=py310hff52083_1
- matplotlib-base=3.5.2=py310h5701ce4_0
- matplotlib-inline=0.1.7=pyhd8ed1ab_1
- mccabe=0.7.0=pyhd8ed1ab_1
- mdurl=0.1.2=pyhd8ed1ab_1
- more-itertools=10.6.0=pyhd8ed1ab_0
- mr-proper=0.0.7=pyhd8ed1ab_1
- msgpack-python=1.0.3=py310hbf28c38_1
- munkres=1.1.4=pyh9f0ad1d_0
- mypy_extensions=1.0.0=pyha770c72_1
- mysql-common=8.0.29=haf5c9bc_1
- mysql-libs=8.0.29=h28c427c_1
- ncurses=6.4=h6a678d5_0
- netcdf4=1.6.2=py310h6d89c78_0
- nomkl=1.0=h5ca1d4c_0
- nspr=4.32=h9c3ff4c_1
- nss=3.77=h2350873_0
- numba=0.56.4=py310h1128e8f_0
- numexpr=2.8.0=py310hf05e7a9_102
- numpy=1.23.5=py310hac523dd_0
- numpy-base=1.23.5=py310h375b286_0
- openblas=0.3.20=pthreads_h320a7e8_0
- openjpeg=2.5.0=h7d73246_0
- openssl=1.1.1o=h166bdaf_0
- packaging=24.2=pyhd8ed1ab_2
- pandas=1.5.3=py310h1128e8f_0
- parso=0.8.4=pyhd8ed1ab_1
- partd=1.4.2=pyhd8ed1ab_0
- pathspec=0.12.1=pyhd8ed1ab_1
- pcre=8.45=h9c3ff4c_0
- pep8-naming=0.14.1=pyhd8ed1ab_1
- pexpect=4.9.0=pyhd8ed1ab_1
- pickleshare=0.7.5=pyhd8ed1ab_1004
- pillow=9.1.1=py310he619898_0
- pip=25.0.1=pyh8b19718_0
- pixman=0.40.0=h36c2ea0_0
- platformdirs=4.3.7=pyh29332c3_0
- pluggy=1.5.0=pyhd8ed1ab_1
- pooch=1.8.2=pyhd8ed1ab_1
- poppler=22.01.0=h1434ded_2
- poppler-data=0.4.12=hd8ed1ab_0
- postgresql=14.2=h2510834_0
- proj=9.0.0=h93bde94_1
- prompt-toolkit=3.0.50=pyha770c72_0
- psutil=5.9.1=py310h5764c6d_0
- pthread-stubs=0.4=h36c2ea0_1001
- ptyprocess=0.7.0=pyhd8ed1ab_1
- pulseaudio=14.0=hb166930_4
- pure_eval=0.2.3=pyhd8ed1ab_1
- pycodestyle=2.12.1=pyhd8ed1ab_1
- pycparser=2.22=pyh29332c3_1
- pydata-sphinx-theme=0.8.1=pyhd8ed1ab_0
- pyflakes=3.2.0=pyhd8ed1ab_1
- pygments=2.19.1=pyhd8ed1ab_0
- pygmt=0.6.1=pyhd8ed1ab_0
- pykdtree=1.3.4=py310hde88566_3
- pyparsing=3.2.3=pyhd8ed1ab_1
- pyproj=3.3.1=py310h9bf108f_0
- pyproject_hooks=1.2.0=pyhd8ed1ab_1
- pyqt=5.15.4=py310hd8f1fbe_0
- pyqt5-sip=12.9.0=py310hd8f1fbe_0
- pyshp=2.3.1=pyhd8ed1ab_1
- pysocks=1.7.1=pyha55dd90_7
- pytest=8.3.5=pyhd8ed1ab_0
- pytest-cov=6.0.0=pyhd8ed1ab_1
- pytest-mpl=0.17.0=pyhd8ed1ab_1
- python=3.10.0=h62f1059_3_cpython
- python-dateutil=2.9.0.post0=pyhff2d567_1
- python_abi=3.10=5_cp310
- pytz=2025.2=pyhd8ed1ab_0
- pyyaml=6.0=py310h5764c6d_4
- qt-main=5.15.2=hdf1cb14_3
- readline=8.2=h5eee18b_0
- readme_renderer=41.0=pyhd8ed1ab_0
- requests=2.32.3=pyhd8ed1ab_1
- requests-toolbelt=1.0.0=pyhd8ed1ab_1
- restructuredtext_lint=1.4.0=pyhd8ed1ab_1
- rfc3986=2.0.0=pyhd8ed1ab_1
- rich=14.0.0=pyh29332c3_0
- scikit-learn=1.1.1=py310hffb9edd_0
- scipy=1.8.1=py310h7612f91_0
- secretstorage=3.3.3=py310hff52083_3
- setuptools=75.8.2=pyhff2d567_0
- shapely=1.8.2=py310hb974679_1
- sip=6.5.1=py310h122e73d_2
- six=1.17.0=pyhd8ed1ab_0
- snappy=1.1.9=hbd366e4_1
- snowballstemmer=2.2.0=pyhd8ed1ab_0
- sortedcontainers=2.4.0=pyhd8ed1ab_1
- soupsieve=2.5=pyhd8ed1ab_1
- sphinx=4.5.0=pyh6c4a22f_0
- sphinx-book-theme=0.3.3=pyhd8ed1ab_0
- sphinx-copybutton=0.5.2=pyhd8ed1ab_1
- sphinx-design=0.1.0=pyhd8ed1ab_0
- sphinx-gallery=0.10.1=pyhd8ed1ab_0
- sphinxcontrib-applehelp=1.0.4=pyhd8ed1ab_0
- sphinxcontrib-devhelp=1.0.2=py_0
- sphinxcontrib-htmlhelp=2.0.1=pyhd8ed1ab_0
- sphinxcontrib-jsmath=1.0.1=pyhd8ed1ab_1
- sphinxcontrib-qthelp=1.0.3=py_0
- sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_2
- sqlite=3.38.5=h4ff8645_0
- stack_data=0.6.3=pyhd8ed1ab_1
- stdlib-list=0.11.1=pyhd8ed1ab_0
- tbb=2021.5.0=h924138e_1
- tblib=3.0.0=pyhd8ed1ab_1
- threadpoolctl=3.6.0=pyhecae5ae_0
- tiledb=2.7.2=h1e4a385_0
- tk=8.6.12=h27826a3_0
- toml=0.10.2=pyhd8ed1ab_1
- tomli=2.2.1=pyhd8ed1ab_1
- toolz=1.0.0=pyhd8ed1ab_1
- tornado=6.1=py310h5764c6d_3
- traitlets=5.14.3=pyhd8ed1ab_1
- twine=6.1.0=pyh29332c3_0
- typing-extensions=4.13.0=h9fa5a19_1
- typing_extensions=4.13.0=pyh29332c3_1
- tzcode=2022a=h166bdaf_0
- tzdata=2025a=h04d1e81_0
- unicodedata2=14.0.0=py310h5764c6d_1
- urllib3=2.3.0=pyhd8ed1ab_0
- wcwidth=0.2.13=pyhd8ed1ab_1
- webencodings=0.5.1=pyhd8ed1ab_3
- wheel=0.45.1=pyhd8ed1ab_1
- xarray=2024.3.0=pyhd8ed1ab_0
- xerces-c=3.2.3=h8ce2273_4
- xorg-kbproto=1.0.7=h7f98852_1002
- xorg-libice=1.0.10=h7f98852_0
- xorg-libsm=1.2.3=hd9c2040_1000
- xorg-libx11=1.7.2=h7f98852_0
- xorg-libxau=1.0.9=h7f98852_0
- xorg-libxdmcp=1.1.3=h7f98852_0
- xorg-libxext=1.3.4=h7f98852_1
- xorg-libxrender=0.9.10=h7f98852_1003
- xorg-renderproto=0.11.1=h7f98852_1002
- xorg-xextproto=7.3.0=h7f98852_1002
- xorg-xproto=7.0.31=h7f98852_1007
- xz=5.6.4=h5eee18b_1
- yaml=0.2.5=h7f98852_2
- zict=3.0.0=pyhd8ed1ab_1
- zipp=3.21.0=pyhd8ed1ab_1
- zlib=1.2.11=h166bdaf_1014
- zstandard=0.19.0=py310h5eee18b_0
- zstd=1.5.2=h8a70e8d_1
- pip:
- flake8-unused-arguments==0.0.13
- gdal==3.4.2
- verde==1.7.0.post16+ge5675dd
prefix: /opt/conda/envs/verde
| [
"verde/tests/test_base.py::test_basegridder"
] | [] | [
"verde/tests/test_base.py::test_check_coordinates",
"verde/tests/test_base.py::test_get_dims",
"verde/tests/test_base.py::test_get_data_names",
"verde/tests/test_base.py::test_get_data_names_fails",
"verde/tests/test_base.py::test_get_instance_region",
"verde/tests/test_base.py::test_basegridder_data_names",
"verde/tests/test_base.py::test_basegridder_projection",
"verde/tests/test_base.py::test_basegridder_extra_coords",
"verde/tests/test_base.py::test_basegridder_projection_multiple_coordinates",
"verde/tests/test_base.py::test_basegridder_grid_invalid_arguments",
"verde/tests/test_base.py::test_check_fit_input",
"verde/tests/test_base.py::test_check_fit_input_fails_coordinates",
"verde/tests/test_base.py::test_check_fit_input_fails_weights",
"verde/tests/test_base.py::test_baseblockedcrossvalidator_n_splits",
"verde/tests/test_base.py::test_baseblockedcrossvalidator_fails_spacing_shape",
"verde/tests/test_base.py::test_baseblockedcrossvalidator_fails_data_shape",
"verde/tests/test_base.py::test_least_squares_copy_jacobian",
"verde/tests/test_synthetic.py::test_checkerboard_scatter_projection"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,878 | 2,042 | [
"doc/gallery_src/checkerboard.py",
"doc/gallery_src/cubic_gridder.py",
"verde/base/base_classes.py",
"verde/scipygridder.py",
"verde/synthetic.py"
] |
|
RDFLib__rdflib-1530 | 43d86224382d64fba2e5e17acedea1704631e097 | 2021-12-25 12:23:13 | 05dced203f7db28470255ce847db6b38d05a2663 | diff --git a/rdflib/extras/infixowl.py b/rdflib/extras/infixowl.py
index c6a5d2ad..c81297f2 100644
--- a/rdflib/extras/infixowl.py
+++ b/rdflib/extras/infixowl.py
@@ -39,26 +39,26 @@ We can then access the rdfs:subClassOf relationships
This can also be used against already populated graphs:
->>> owlGraph = Graph().parse(str(OWL)) #doctest: +SKIP
->>> namespace_manager.bind('owl', OWL, override=False) #doctest: +SKIP
->>> owlGraph.namespace_manager = namespace_manager #doctest: +SKIP
->>> list(Class(OWL.Class, graph=owlGraph).subClassOf) #doctest: +SKIP
+>>> owlGraph = Graph().parse(str(OWL))
+>>> namespace_manager.bind('owl', OWL, override=False)
+>>> owlGraph.namespace_manager = namespace_manager
+>>> list(Class(OWL.Class, graph=owlGraph).subClassOf)
[Class: rdfs:Class ]
Operators are also available. For instance we can add ex:Opera to the extension
of the ex:CreativeWork class via the '+=' operator
->>> a #doctest: +SKIP
+>>> a
Class: ex:Opera SubClassOf: ex:MusicalWork
>>> b = Class(exNs.CreativeWork, graph=g)
>>> b += a
->>> print(sorted(a.subClassOf, key=lambda c:c.identifier)) #doctest: +SKIP
+>>> print(sorted(a.subClassOf, key=lambda c:c.identifier))
[Class: ex:CreativeWork , Class: ex:MusicalWork ]
And we can then remove it from the extension as well
>>> b -= a
->>> a #doctest: +SKIP
+>>> a
Class: ex:Opera SubClassOf: ex:MusicalWork
Boolean class constructions can also be created with Python operators.
@@ -66,21 +66,21 @@ For example, The | operator can be used to construct a class consisting of a
owl:unionOf the operands:
>>> c = a | b | Class(exNs.Work, graph=g)
->>> c #doctest: +SKIP
+>>> c
( ex:Opera OR ex:CreativeWork OR ex:Work )
Boolean class expressions can also be operated as lists (using python list
operators)
>>> del c[c.index(Class(exNs.Work, graph=g))]
->>> c #doctest: +SKIP
+>>> c
( ex:Opera OR ex:CreativeWork )
The '&' operator can be used to construct class intersection:
>>> woman = Class(exNs.Female, graph=g) & Class(exNs.Human, graph=g)
>>> woman.identifier = exNs.Woman
->>> woman #doctest: +SKIP
+>>> woman
( ex:Female AND ex:Human )
>>> len(woman)
2
@@ -88,20 +88,20 @@ The '&' operator can be used to construct class intersection:
Enumerated classes can also be manipulated
>>> contList = [Class(exNs.Africa, graph=g), Class(exNs.NorthAmerica, graph=g)]
->>> EnumeratedClass(members=contList, graph=g) #doctest: +SKIP
+>>> EnumeratedClass(members=contList, graph=g)
{ ex:Africa ex:NorthAmerica }
owl:Restrictions can also be instantiated:
->>> Restriction(exNs.hasParent, graph=g, allValuesFrom=exNs.Human) #doctest: +SKIP
+>>> Restriction(exNs.hasParent, graph=g, allValuesFrom=exNs.Human)
( ex:hasParent ONLY ex:Human )
Restrictions can also be created using Manchester OWL syntax in 'colloquial'
Python
->>> exNs.hasParent | some | Class(exNs.Physician, graph=g) #doctest: +SKIP
+>>> exNs.hasParent << some >> Class(exNs.Physician, graph=g)
( ex:hasParent SOME ex:Physician )
->>> Property(exNs.hasParent,graph=g) | max | Literal(1) #doctest: +SKIP
+>>> Property(exNs.hasParent,graph=g) << max >> Literal(1)
( ex:hasParent MAX 1 )
>>> print(g.serialize(format='pretty-xml')) #doctest: +SKIP
@@ -161,6 +161,7 @@ __all__ = [
"generateQName",
"GetIdentifiedClasses",
"Individual",
+ "Infix",
"MalformedClass",
"manchesterSyntax",
"Ontology",
@@ -195,6 +196,12 @@ class Infix:
def __rshift__(self, other):
return self.function(other)
+ def __rmatmul__(self, other):
+ return Infix(lambda x, self=self, other=other: self.function(other, x))
+
+ def __matmul__(self, other):
+ return self.function(other)
+
def __call__(self, value1, value2):
return self.function(value1, value2)
@@ -422,7 +429,7 @@ class Individual(object):
"""
>>> g = Graph()
>>> b=Individual(OWL.Restriction,g)
- >>> b.type = RDF.Resource
+ >>> b.type = RDFS.Resource
>>> len(list(b.type))
1
>>> del b.type
@@ -773,32 +780,32 @@ def DeepClassClear(classToPrune):
>>> classD = Class(EX.D)
>>> classE = Class(EX.E)
>>> classF = Class(EX.F)
- >>> anonClass = EX.someProp | some | classD #doctest: +SKIP
- >>> classF += anonClass #doctest: +SKIP
- >>> list(anonClass.subClassOf) #doctest: +SKIP
+ >>> anonClass = EX.someProp << some >> classD
+ >>> classF += anonClass
+ >>> list(anonClass.subClassOf)
[Class: ex:F ]
- >>> classA = classE | classF | anonClass #doctest: +SKIP
- >>> classB += classA #doctest: +SKIP
- >>> classA.equivalentClass = [Class()] #doctest: +SKIP
- >>> classB.subClassOf = [EX.someProp | some | classC] #doctest: +SKIP
- >>> classA #doctest: +SKIP
+ >>> classA = classE | classF | anonClass
+ >>> classB += classA
+ >>> classA.equivalentClass = [Class()]
+ >>> classB.subClassOf = [EX.someProp << some >> classC]
+ >>> classA
( ex:E OR ex:F OR ( ex:someProp SOME ex:D ) )
- >>> DeepClassClear(classA) #doctest: +SKIP
- >>> classA #doctest: +SKIP
+ >>> DeepClassClear(classA)
+ >>> classA
( )
- >>> list(anonClass.subClassOf) #doctest: +SKIP
+ >>> list(anonClass.subClassOf)
[]
- >>> classB #doctest: +SKIP
+ >>> classB
Class: ex:B SubClassOf: ( ex:someProp SOME ex:C )
- >>> otherClass = classD | anonClass #doctest: +SKIP
- >>> otherClass #doctest: +SKIP
+ >>> otherClass = classD | anonClass
+ >>> otherClass
( ex:D OR ( ex:someProp SOME ex:D ) )
- >>> DeepClassClear(otherClass) #doctest: +SKIP
- >>> otherClass #doctest: +SKIP
+ >>> DeepClassClear(otherClass)
+ >>> otherClass
( )
- >>> otherClass.delete() #doctest: +SKIP
- >>> list(g.triples((otherClass.identifier, None, None))) #doctest: +SKIP
+ >>> otherClass.delete()
+ >>> list(g.triples((otherClass.identifier, None, None)))
[]
"""
@@ -1157,15 +1164,15 @@ class Class(AnnotatableTerms):
>>> sister = Class(exNs.Sister)
>>> sibling = brother | sister
>>> sibling.identifier = exNs.Sibling
- >>> sibling #doctest: +SKIP
+ >>> sibling
( ex:Brother OR ex:Sister )
- >>> first(brother.parents) #doctest: +SKIP
+ >>> first(brother.parents)
Class: ex:Sibling EquivalentTo: ( ex:Brother OR ex:Sister )
>>> parent = Class(exNs.Parent)
>>> male = Class(exNs.Male)
>>> father = parent & male
>>> father.identifier = exNs.Father
- >>> list(father.parents) #doctest: +SKIP
+ >>> list(father.parents)
[Class: ex:Parent , Class: ex:Male ]
"""
@@ -1393,8 +1400,8 @@ class EnumeratedClass(OWLRDFListProxy, Class):
{ ex:chime ex:uche ex:ejike }
>>> col = Collection(g, first(
... g.objects(predicate=OWL.oneOf, subject=ogbujiBros.identifier)))
- >>> [g.qname(item) for item in col]
- [u'ex:chime', u'ex:uche', u'ex:ejike']
+ >>> sorted([g.qname(item) for item in col])
+ ['ex:chime', 'ex:ejike', 'ex:uche']
>>> print(g.serialize(format='n3')) #doctest: +SKIP
@prefix ex: <http://example.com/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@@ -1649,7 +1656,7 @@ class Restriction(Class):
(maxCardinality, OWL.maxCardinality),
(minCardinality, OWL.minCardinality),
]
- validRestrProps = [(i, oTerm) for (i, oTerm) in restrTypes if i]
+ validRestrProps = [(i, oTerm) for (i, oTerm) in restrTypes if i is not None]
assert len(validRestrProps)
restrictionRange, restrictionType = validRestrProps.pop()
self.restrictionType = restrictionType
@@ -1681,7 +1688,7 @@ class Restriction(Class):
>>> prop = Property(EX.someProp, baseType=OWL.DatatypeProperty)
>>> restr1 = (Property(
... EX.someProp,
- ... baseType=OWL.DatatypeProperty)) | some | (Class(EX.Foo))
+ ... baseType=OWL.DatatypeProperty)) << some >> (Class(EX.Foo))
>>> restr1 #doctest: +SKIP
( ex:someProp SOME ex:Foo )
>>> restr1.serialize(g2)
@@ -2087,7 +2094,7 @@ class Property(AnnotatableTerms):
)
rt = "\n".join([expr for expr in rt if expr])
rt += "\n)"
- return str(rt).encode("utf-8")
+ return rt
def _get_subPropertyOf(self):
for anc in self.graph.objects(
| infixowl cardinality - 0
`owl.Restriction(property,graph=graph,cardinality=Literal(0))
`Raises an error.
`assert len(validRestrProps)`
When cardinality value is given as 0.
This comes from:
```
validRestrProps = [(i, oTerm) for (i, oTerm) in restrTypes if i]
assert len(validRestrProps)
```
I believe this is an oversight as if i == 0 returns False.
However, I believe cardinality: 0 is valid.
| RDFLib/rdflib | diff --git a/test/test_infixowl.py b/test/test_infixowl.py
new file mode 100644
index 00000000..80f956a7
--- /dev/null
+++ b/test/test_infixowl.py
@@ -0,0 +1,419 @@
+from rdflib import BNode, Graph, Literal, Namespace, RDFS, OWL, XSD
+from rdflib.namespace import NamespaceManager
+from rdflib.util import first
+from rdflib.extras.infixowl import (
+ BooleanClass,
+ Class,
+ Collection,
+ DeepClassClear,
+ Individual,
+ some,
+ EnumeratedClass,
+ Property,
+ Restriction,
+ max,
+)
+
+
+def test_infix_owl_example1():
+
+ exNs = Namespace("http://example.com/")
+
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", exNs, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+ g = Graph()
+ g.namespace_manager = namespace_manager
+
+ Individual.factoryGraph = g
+ classD = Class(exNs.D)
+ anonClass = exNs.someProp << some >> classD
+
+ assert str(anonClass) == "( ex:someProp SOME ex:D )"
+
+ a = Class(exNs.Opera, graph=g)
+
+ # Now we can assert rdfs:subClassOf and owl:equivalentClass relationships
+ # (in the underlying graph) with other classes using the 'subClassOf'
+ # and 'equivalentClass' descriptors which can be set to a list
+ # of objects for the corresponding predicates.
+
+ a.subClassOf = [exNs.MusicalWork]
+
+ # We can then access the rdfs:subClassOf relationships
+
+ assert str(list(a.subClassOf)) == "[Class: ex:MusicalWork ]"
+ # [Class: ex:MusicalWork ]
+
+ # This can also be used against already populated graphs:
+
+ owlGraph = Graph().parse(str(OWL))
+ namespace_manager.bind("owl", OWL, override=False)
+ owlGraph.namespace_manager = namespace_manager
+ assert (
+ str(list(Class(OWL.Class, graph=owlGraph).subClassOf))
+ == "[Class: rdfs:Class ]"
+ )
+
+ # Operators are also available. For instance we can add ex:Opera to the extension
+ # of the ex:CreativeWork class via the '+=' operator
+
+ assert str(a) == "Class: ex:Opera SubClassOf: ex:MusicalWork"
+ b = Class(exNs.CreativeWork, graph=g)
+ b += a
+ assert (
+ str(sorted(a.subClassOf, key=lambda c: c.identifier))
+ == "[Class: ex:CreativeWork , Class: ex:MusicalWork ]"
+ )
+
+ # And we can then remove it from the extension as well
+
+ b -= a
+ assert str(a) == "Class: ex:Opera SubClassOf: ex:MusicalWork"
+
+ # Boolean class constructions can also be created with Python operators.
+ # For example, The | operator can be used to construct a class consisting of a
+ # owl:unionOf the operands:
+
+ c = a | b | Class(exNs.Work, graph=g)
+ assert str(c) == "( ex:Opera OR ex:CreativeWork OR ex:Work )"
+
+ # Boolean class expressions can also be operated as lists (using python list
+ # operators)
+
+ del c[c.index(Class(exNs.Work, graph=g))]
+ assert str(c) == "( ex:Opera OR ex:CreativeWork )"
+
+ # The '&' operator can be used to construct class intersection:
+
+ woman = Class(exNs.Female, graph=g) & Class(exNs.Human, graph=g)
+ woman.identifier = exNs.Woman
+ assert str(woman) == "( ex:Female AND ex:Human )"
+ assert len(woman) == 2
+
+ # Enumerated classes can also be manipulated
+
+ contList = [Class(exNs.Africa, graph=g), Class(exNs.NorthAmerica, graph=g)]
+ assert (
+ str(EnumeratedClass(members=contList, graph=g))
+ == "{ ex:Africa ex:NorthAmerica }"
+ )
+
+ # owl:Restrictions can also be instantiated:
+
+ assert (
+ str(Restriction(exNs.hasParent, graph=g, allValuesFrom=exNs.Human))
+ == "( ex:hasParent ONLY ex:Human )"
+ )
+
+ # Restrictions can also be created using Manchester OWL syntax in 'colloquial'
+ # Python
+ assert (
+ str(exNs.hasParent << some >> Class(exNs.Physician, graph=g))
+ == "( ex:hasParent SOME ex:Physician )"
+ )
+
+ Property(exNs.hasParent, graph=g) << max >> Literal(1)
+ assert (
+ str(Property(exNs.hasParent, graph=g) << max >> Literal(1))
+ == "( ex:hasParent MAX 1 )"
+ )
+
+
+def test_infixowl_deepclassclear():
+ EX = Namespace("http://example.com/")
+
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", EX, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+
+ g = Graph()
+ g.namespace_manager = namespace_manager
+ Individual.factoryGraph = g
+
+ classB = Class(EX.B)
+ classC = Class(EX.C)
+ classD = Class(EX.D)
+ classE = Class(EX.E)
+ classF = Class(EX.F)
+
+ anonClass = EX.someProp << some >> classD
+
+ assert str(anonClass) == "( ex:someProp SOME ex:D )"
+ assert str(classF) == "Class: ex:F "
+
+ classF += anonClass
+
+ assert str(list(anonClass.subClassOf)) == "[Class: ex:F ]"
+
+ classA = classE | classF | anonClass
+ classB += classA
+ classA.equivalentClass = [Class()]
+ classB.subClassOf = [EX.someProp << some >> classC]
+
+ assert str(classA) == "( ex:E OR ex:F OR ( ex:someProp SOME ex:D ) )"
+
+ DeepClassClear(classA)
+ assert str(classA) == "( )"
+
+ assert list(anonClass.subClassOf) == []
+
+ assert str(classB) == "Class: ex:B SubClassOf: ( ex:someProp SOME ex:C )"
+
+ otherClass = classD | anonClass
+
+ assert str(otherClass) == "( ex:D OR ( ex:someProp SOME ex:D ) )"
+
+ DeepClassClear(otherClass)
+ assert str(otherClass) == "( )"
+
+ otherClass.delete()
+ assert list(g.triples((otherClass.identifier, None, None))) == []
+
+
+def test_infixowl_individual_type():
+ g = Graph()
+ b = Individual(OWL.Restriction, g)
+ b.type = RDFS.Resource
+ assert len(list(b.type)) == 1
+
+ del b.type
+ assert len(list(b.type)) == 0
+
+
+def test_infixowl_individual_label():
+ g = Graph()
+ b = Individual(OWL.Restriction, g)
+ b.label = Literal("boo")
+
+ assert len(list(b.label)) == 3
+
+ del b.label
+ assert hasattr(b, "label") is False
+
+
+def test_infixowl_class_hash():
+ b = Class(OWL.Restriction)
+ c = Class(OWL.Restriction)
+ assert len(set([b, c])) == 1
+
+
+def test_infixowl_class_and():
+ # Construct an anonymous class description consisting of the
+ # intersection of this class and 'other' and return it
+
+ exNs = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", exNs, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+ g = Graph()
+ g.namespace_manager = namespace_manager
+
+ # Chaining 3 intersections
+
+ female = Class(exNs.Female, graph=g)
+ human = Class(exNs.Human, graph=g)
+ youngPerson = Class(exNs.YoungPerson, graph=g)
+ youngWoman = female & human & youngPerson
+
+ assert str(youngWoman) == "ex:YoungPerson THAT ( ex:Female AND ex:Human )"
+
+ assert isinstance(youngWoman, BooleanClass) is True
+ assert isinstance(youngWoman.identifier, BNode) is True
+
+
+def test_infix_owl_class_getparents():
+ # computed attributes that returns a generator over taxonomic 'parents'
+ # by disjunction, conjunction, and subsumption
+
+ exNs = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", exNs, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+ g = Graph()
+ g.namespace_manager = namespace_manager
+ Individual.factoryGraph = g
+ brother = Class(exNs.Brother)
+ sister = Class(exNs.Sister)
+ sibling = brother | sister
+ sibling.identifier = exNs.Sibling
+ assert len(sibling) == 2
+
+ assert str(sibling) == "( ex:Brother OR ex:Sister )"
+
+ assert (
+ str(first(brother.parents))
+ == "Class: ex:Sibling EquivalentTo: ( ex:Brother OR ex:Sister )"
+ )
+ parent = Class(exNs.Parent)
+ male = Class(exNs.Male)
+ father = parent & male
+ father.identifier = exNs.Father
+ assert len(list(father.parents)) == 2
+ assert str(list(father.parents)) == "[Class: ex:Parent , Class: ex:Male ]"
+
+
+def test_infixowl_enumeratedclass():
+ exNs = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", exNs, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+ g = Graph()
+ g.namespace_manager = namespace_manager
+ Individual.factoryGraph = g
+
+ ogbujiBros = EnumeratedClass(
+ exNs.ogbujicBros, members=[exNs.chime, exNs.uche, exNs.ejike]
+ )
+ assert str(ogbujiBros) == "{ ex:chime ex:uche ex:ejike }"
+
+ col = Collection(
+ g, first(g.objects(predicate=OWL.oneOf, subject=ogbujiBros.identifier))
+ )
+ assert (
+ str(sorted([g.qname(item) for item in col]))
+ == "['ex:chime', 'ex:ejike', 'ex:uche']"
+ )
+ # logger.debug(g.serialize(format="pretty-xml"))
+
+ assert str(g.serialize(format="n3")) == str(
+ "@prefix ex: <http://example.com/> .\n"
+ "@prefix owl: <http://www.w3.org/2002/07/owl#> .\n"
+ "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"
+ "\n"
+ "ex:ogbujicBros a owl:Class ;\n"
+ " owl:oneOf ( ex:chime ex:uche ex:ejike ) .\n"
+ "\nex:chime a owl:Class .\n"
+ "\nex:ejike a owl:Class .\n"
+ "\nex:uche a owl:Class .\n"
+ "\n"
+ )
+
+
+def test_infixowl_booleanclassextenthelper():
+ testGraph = Graph()
+ Individual.factoryGraph = testGraph
+ EX = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", EX, override=False)
+ testGraph.namespace_manager = namespace_manager
+
+ fire = Class(EX.Fire)
+ water = Class(EX.Water)
+
+ testClass = BooleanClass(members=[fire, water])
+ assert str(testClass) == "( ex:Fire AND ex:Water )"
+
+ testClass2 = BooleanClass(operator=OWL.unionOf, members=[fire, water])
+ assert str(testClass2) == "( ex:Fire OR ex:Water )"
+
+
+def test_infixowl_changeoperator():
+ # Converts a unionOf / intersectionOf class expression into one
+ # that instead uses the given operator
+
+ testGraph = Graph()
+ Individual.factoryGraph = testGraph
+ EX = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", EX, override=False)
+ testGraph.namespace_manager = namespace_manager
+ fire = Class(EX.Fire)
+ water = Class(EX.Water)
+ testClass = BooleanClass(members=[fire, water])
+
+ assert str(testClass) == "( ex:Fire AND ex:Water )"
+
+ testClass.changeOperator(OWL.unionOf)
+ assert repr(testClass) == "( ex:Fire OR ex:Water )"
+
+ try:
+ testClass.changeOperator(OWL.unionOf)
+ except Exception as e:
+ assert str(e) == "The new operator is already being used!"
+
+
+def test_infixowl_serialization():
+ g1 = Graph()
+ g2 = Graph()
+
+ EX = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(g1)
+ namespace_manager.bind("ex", EX, override=False)
+ namespace_manager = NamespaceManager(g2)
+ namespace_manager.bind("ex", EX, override=False)
+
+ # Individual.factoryGraph = g1
+
+ prop = Property(EX.someProp, baseType=OWL.DatatypeProperty)
+
+ restr1 = prop << some >> (Class(EX.Foo))
+
+ assert str(restr1) == "( ex:someProp SOME ex:Foo )"
+
+ assert (
+ str(list(Property(EX.someProp, baseType=None).type))
+ == "[rdflib.term.URIRef('http://www.w3.org/2002/07/owl#DatatypeProperty')]"
+ )
+
+
+def test_cardinality_zero():
+
+ graph = Graph()
+ EX = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(graph)
+ namespace_manager.bind("ex", EX, override=False)
+ prop = Property(EX.someProp, baseType=OWL.DatatypeProperty)
+ Restriction(
+ prop, graph=graph, cardinality=Literal(0, datatype=XSD.nonNegativeInteger)
+ )
+
+
+def test_lshift_rlshift_delimiters():
+ EX = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", EX, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+ g = Graph()
+ g.namespace_manager = namespace_manager
+ Individual.factoryGraph = g
+ classB = Class(EX.B)
+ classC = Class(EX.C)
+ classD = Class(EX.D)
+ classE = Class(EX.E)
+ classF = Class(EX.F)
+
+ anonClass = EX.someProp << some >> classD
+ classF += anonClass
+ assert str(list(anonClass.subClassOf)) == "[Class: ex:F ]"
+
+ classA = classE | classF | anonClass
+ classB += classA
+ classA.equivalentClass = [Class()]
+ classB.subClassOf = [EX.someProp << some >> classC]
+ assert str(classA) == "( ex:E OR ex:F OR ( ex:someProp SOME ex:D ) )"
+
+
+def test_matmul_rmatmul_delimiters():
+ EX = Namespace("http://example.com/")
+ namespace_manager = NamespaceManager(Graph())
+ namespace_manager.bind("ex", EX, override=False)
+ namespace_manager.bind("owl", OWL, override=False)
+ g = Graph()
+ g.namespace_manager = namespace_manager
+ Individual.factoryGraph = g
+ classB = Class(EX.B)
+ classC = Class(EX.C)
+ classD = Class(EX.D)
+ classE = Class(EX.E)
+ classF = Class(EX.F)
+
+ anonClass = EX.someProp @ some @ classD
+ classF += anonClass
+ assert str(list(anonClass.subClassOf)) == "[Class: ex:F ]"
+
+ classA = classE | classF | anonClass
+ classB += classA
+ classA.equivalentClass = [Class()]
+ classB.subClassOf = [EX.someProp @ some @ classC]
+ assert str(classA) == "( ex:E OR ex:F OR ( ex:someProp SOME ex:D ) )"
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 6.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-subtests"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
coverage==7.8.0
exceptiongroup==1.2.2
html5lib==1.1
iniconfig==2.1.0
isodate==0.7.2
packaging==24.2
pluggy==1.5.0
pyparsing==3.2.3
pytest==8.3.5
pytest-cov==6.0.0
pytest-subtests==0.14.1
-e git+https://github.com/RDFLib/rdflib.git@43d86224382d64fba2e5e17acedea1704631e097#egg=rdflib
six==1.17.0
tomli==2.2.1
webencodings==0.5.1
| name: rdflib
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- html5lib==1.1
- iniconfig==2.1.0
- isodate==0.7.2
- packaging==24.2
- pluggy==1.5.0
- pyparsing==3.2.3
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-subtests==0.14.1
- six==1.17.0
- tomli==2.2.1
- webencodings==0.5.1
prefix: /opt/conda/envs/rdflib
| [
"test/test_infixowl.py::test_cardinality_zero",
"test/test_infixowl.py::test_matmul_rmatmul_delimiters"
] | [] | [
"test/test_infixowl.py::test_infix_owl_example1",
"test/test_infixowl.py::test_infixowl_deepclassclear",
"test/test_infixowl.py::test_infixowl_individual_type",
"test/test_infixowl.py::test_infixowl_individual_label",
"test/test_infixowl.py::test_infixowl_class_hash",
"test/test_infixowl.py::test_infixowl_class_and",
"test/test_infixowl.py::test_infix_owl_class_getparents",
"test/test_infixowl.py::test_infixowl_enumeratedclass",
"test/test_infixowl.py::test_infixowl_booleanclassextenthelper",
"test/test_infixowl.py::test_infixowl_changeoperator",
"test/test_infixowl.py::test_infixowl_serialization",
"test/test_infixowl.py::test_lshift_rlshift_delimiters"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,885 | 2,566 | [
"rdflib/extras/infixowl.py"
] |
|
PyCQA__pyflakes-668 | 4dcd92e45efeb0615ba1c96d45241a037d30abe0 | 2021-12-25 18:12:24 | 7d6479e46f8f3e9607c9ef7975cc892db023d413 | diff --git a/pyflakes/checker.py b/pyflakes/checker.py
index 56fc3ca..89c9d0a 100644
--- a/pyflakes/checker.py
+++ b/pyflakes/checker.py
@@ -588,7 +588,7 @@ class FunctionScope(Scope):
self.returnValue = None # First non-empty return
self.isGenerator = False # Detect a generator
- def unusedAssignments(self):
+ def unused_assignments(self):
"""
Return a generator for the assignments which have not been used.
"""
@@ -600,6 +600,14 @@ class FunctionScope(Scope):
isinstance(binding, Assignment)):
yield name, binding
+ def unused_annotations(self):
+ """
+ Return a generator for the annotations which have not been used.
+ """
+ for name, binding in self.items():
+ if not binding.used and isinstance(binding, Annotation):
+ yield name, binding
+
class GeneratorScope(Scope):
pass
@@ -1156,6 +1164,7 @@ class Checker:
binding = scope.get(name, None)
if isinstance(binding, Annotation) and not self._in_postponed_annotation:
+ scope[name].used = True
continue
if name == 'print' and isinstance(binding, Builtin):
@@ -2084,13 +2093,22 @@ class Checker:
self.handleChildren(node, omit=['decorator_list', 'returns'])
- def checkUnusedAssignments():
+ def check_unused_assignments():
"""
Check to see if any assignments have not been used.
"""
- for name, binding in self.scope.unusedAssignments():
+ for name, binding in self.scope.unused_assignments():
self.report(messages.UnusedVariable, binding.source, name)
- self.deferAssignment(checkUnusedAssignments)
+
+ def check_unused_annotations():
+ """
+ Check to see if any annotations have not been used.
+ """
+ for name, binding in self.scope.unused_annotations():
+ self.report(messages.UnusedAnnotation, binding.source, name)
+
+ self.deferAssignment(check_unused_assignments)
+ self.deferAssignment(check_unused_annotations)
self.popScope()
diff --git a/pyflakes/messages.py b/pyflakes/messages.py
index 37c4432..c2246cf 100644
--- a/pyflakes/messages.py
+++ b/pyflakes/messages.py
@@ -156,6 +156,18 @@ class UnusedVariable(Message):
self.message_args = (names,)
+class UnusedAnnotation(Message):
+ """
+ Indicates that a variable has been explicitly annotated to but not actually
+ used.
+ """
+ message = 'local variable %r is annotated but never used'
+
+ def __init__(self, filename, loc, names):
+ Message.__init__(self, filename, loc)
+ self.message_args = (names,)
+
+
class ReturnOutsideFunction(Message):
"""
Indicates a return statement outside of a function/method.
| Is an unused variable annotation able to be detected?
Given this sample file:
```python
def foo():
a = 10
b: str
return 1
foo()
```
It correctly gives an error about the variable `a`: `test.py:2:5 local variable 'a' is assigned to but never used`
It would be nice if an error could be given about `b` as well since it is also never used. I'm not sure if this is a bug report or a feature request, but I just wasn't sure if this was possible. | PyCQA/pyflakes | diff --git a/pyflakes/test/test_type_annotations.py b/pyflakes/test/test_type_annotations.py
index d881205..2ad9f45 100644
--- a/pyflakes/test/test_type_annotations.py
+++ b/pyflakes/test/test_type_annotations.py
@@ -174,7 +174,7 @@ class TestTypeAnnotations(TestCase):
def f():
name: str
age: int
- ''')
+ ''', m.UnusedAnnotation, m.UnusedAnnotation)
self.flakes('''
def f():
name: str = 'Bob'
@@ -190,7 +190,7 @@ class TestTypeAnnotations(TestCase):
from typing import Any
def f():
a: Any
- ''')
+ ''', m.UnusedAnnotation)
self.flakes('''
foo: not_a_real_type
''', m.UndefinedName)
@@ -356,11 +356,10 @@ class TestTypeAnnotations(TestCase):
class Cls:
y: int
''')
- # TODO: this should print a UnusedVariable message
self.flakes('''
def f():
x: int
- ''')
+ ''', m.UnusedAnnotation)
# This should only print one UnusedVariable message
self.flakes('''
def f():
@@ -368,6 +367,12 @@ class TestTypeAnnotations(TestCase):
x = 3
''', m.UnusedVariable)
+ def test_unassigned_annotation_is_undefined(self):
+ self.flakes('''
+ name: str
+ print(name)
+ ''', m.UndefinedName)
+
def test_annotated_async_def(self):
self.flakes('''
class c: pass
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 3
},
"num_modified_files": 2
} | 2.5 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"flake8",
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
flake8==7.2.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
mccabe==0.7.0
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pycodestyle==2.13.0
-e git+https://github.com/PyCQA/pyflakes.git@4dcd92e45efeb0615ba1c96d45241a037d30abe0#egg=pyflakes
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
| name: pyflakes
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- flake8==7.2.0
- mccabe==0.7.0
- pycodestyle==2.13.0
prefix: /opt/conda/envs/pyflakes
| [
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_unused_annotation",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_variable_annotations"
] | [] | [
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_TypeAlias_annotations",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_aliased_import",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_annotated_async_def",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_annotated_type_typing_missing_forward_type",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_annotated_type_typing_missing_forward_type_multiple_args",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_annotated_type_typing_with_string_args",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_annotated_type_typing_with_string_args_in_union",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_annotating_an_import",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_deferred_twice_annotation",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_idomiatic_typing_guards",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_literal_type_some_other_module",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_literal_type_typing",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_literal_type_typing_extensions",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_literal_union_type_typing",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_namedtypes_classes",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_nested_partially_quoted_type_assignment",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_not_a_typing_overload",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_overload_in_class",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_overload_with_multiple_decorators",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_partial_string_annotations_with_future_annotations",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_partially_quoted_type_annotation",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_partially_quoted_type_assignment",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_positional_only_argument_annotations",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_postponed_annotations",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_quoted_TypeVar_bound",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_quoted_TypeVar_constraints",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_quoted_type_cast",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_quoted_type_cast_renamed_import",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_return_annotation_is_class_scope_variable",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_return_annotation_is_function_body_variable",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsAdditionalComment",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsAssignedToPreviousNode",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsFullSignature",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsFullSignatureWithDocstring",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsInvalidDoesNotMarkAsUsed",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsMarkImportsAsUsed",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsNoWhitespaceAnnotation",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsStarArgs",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsSyntaxError",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeCommentsSyntaxErrorCorrectLine",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeIgnore",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeIgnoreBogus",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typeIgnoreBogusUnicode",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_type_annotation_clobbers_all",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_type_cast_literal_str_to_str",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typednames_correct_forward_ref",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typingExtensionsOverload",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typingOverload",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typingOverloadAsync",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_typing_guard_for_protocol",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_unassigned_annotation_is_undefined",
"pyflakes/test/test_type_annotations.py::TestTypeAnnotations::test_variable_annotation_references_self_name_undefined"
] | [] | MIT License | 11,886 | 698 | [
"pyflakes/checker.py",
"pyflakes/messages.py"
] |
|
arrow-py__arrow-1079 | a2ebb7e20b4897ee7b7bf4676a5ac3e6c0f27f47 | 2021-12-26 07:32:00 | 998b33b2ad6e5420e05c82f04faa3f3c4f3fceee | codecov[bot]: # [Codecov](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py) Report
> Merging [#1079](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py) (e2c232f) into [master](https://codecov.io/gh/arrow-py/arrow/commit/a2ebb7e20b4897ee7b7bf4676a5ac3e6c0f27f47?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py) (a2ebb7e) will **not change** coverage.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py)
```diff
@@ Coverage Diff @@
## master #1079 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2237 2238 +1
Branches 439 439
=========================================
+ Hits 2237 2238 +1
```
| [Impacted Files](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py) | Coverage Δ | |
|---|---|---|
| [arrow/constants.py](https://codecov.io/gh/arrow-py/arrow/pull/1079/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py#diff-YXJyb3cvY29uc3RhbnRzLnB5) | `100.00% <ø> (ø)` | |
| [arrow/locales.py](https://codecov.io/gh/arrow-py/arrow/pull/1079/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py#diff-YXJyb3cvbG9jYWxlcy5weQ==) | `100.00% <ø> (ø)` | |
| [arrow/arrow.py](https://codecov.io/gh/arrow-py/arrow/pull/1079/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py#diff-YXJyb3cvYXJyb3cucHk=) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py). Last update [a2ebb7e...e2c232f](https://codecov.io/gh/arrow-py/arrow/pull/1079?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arrow-py).
| diff --git a/arrow/constants.py b/arrow/constants.py
index d26bc0d..1189d07 100644
--- a/arrow/constants.py
+++ b/arrow/constants.py
@@ -110,6 +110,10 @@ DEHUMANIZE_LOCALES = {
"da-dk",
"ml",
"hi",
+ "cs",
+ "cs-cz",
+ "sk",
+ "sk-sk",
"fa",
"fa-ir",
"mr",
diff --git a/arrow/locales.py b/arrow/locales.py
index 6b1627e..ddbecb7 100644
--- a/arrow/locales.py
+++ b/arrow/locales.py
@@ -3067,44 +3067,51 @@ class CzechLocale(Locale):
timeframes: ClassVar[Mapping[TimeFrameLiteral, Union[str, Mapping[str, str]]]] = {
"now": "Teď",
- "second": {"past": "vteřina", "future": "vteřina", "zero": "vteřina"},
+ "second": {"past": "vteřina", "future": "vteřina"},
"seconds": {
+ "zero": "vteřina",
"past": "{0} sekundami",
"future-singular": "{0} sekundy",
"future-paucal": "{0} sekund",
},
- "minute": {"past": "minutou", "future": "minutu", "zero": "{0} minut"},
+ "minute": {"past": "minutou", "future": "minutu"},
"minutes": {
+ "zero": "{0} minut",
"past": "{0} minutami",
"future-singular": "{0} minuty",
"future-paucal": "{0} minut",
},
- "hour": {"past": "hodinou", "future": "hodinu", "zero": "{0} hodin"},
+ "hour": {"past": "hodinou", "future": "hodinu"},
"hours": {
+ "zero": "{0} hodin",
"past": "{0} hodinami",
"future-singular": "{0} hodiny",
"future-paucal": "{0} hodin",
},
- "day": {"past": "dnem", "future": "den", "zero": "{0} dnů"},
+ "day": {"past": "dnem", "future": "den"},
"days": {
+ "zero": "{0} dnů",
"past": "{0} dny",
"future-singular": "{0} dny",
"future-paucal": "{0} dnů",
},
- "week": {"past": "týdnem", "future": "týden", "zero": "{0} týdnů"},
+ "week": {"past": "týdnem", "future": "týden"},
"weeks": {
+ "zero": "{0} týdnů",
"past": "{0} týdny",
"future-singular": "{0} týdny",
"future-paucal": "{0} týdnů",
},
- "month": {"past": "měsícem", "future": "měsíc", "zero": "{0} měsíců"},
+ "month": {"past": "měsícem", "future": "měsíc"},
"months": {
+ "zero": "{0} měsíců",
"past": "{0} měsíci",
"future-singular": "{0} měsíce",
"future-paucal": "{0} měsíců",
},
- "year": {"past": "rokem", "future": "rok", "zero": "{0} let"},
+ "year": {"past": "rokem", "future": "rok"},
"years": {
+ "zero": "{0} let",
"past": "{0} lety",
"future-singular": "{0} roky",
"future-paucal": "{0} let",
@@ -3190,44 +3197,51 @@ class SlovakLocale(Locale):
timeframes: ClassVar[Mapping[TimeFrameLiteral, Union[str, Mapping[str, str]]]] = {
"now": "Teraz",
- "second": {"past": "sekundou", "future": "sekundu", "zero": "{0} sekúnd"},
+ "second": {"past": "sekundou", "future": "sekundu"},
"seconds": {
+ "zero": "{0} sekúnd",
"past": "{0} sekundami",
"future-singular": "{0} sekundy",
"future-paucal": "{0} sekúnd",
},
- "minute": {"past": "minútou", "future": "minútu", "zero": "{0} minút"},
+ "minute": {"past": "minútou", "future": "minútu"},
"minutes": {
+ "zero": "{0} minút",
"past": "{0} minútami",
"future-singular": "{0} minúty",
"future-paucal": "{0} minút",
},
- "hour": {"past": "hodinou", "future": "hodinu", "zero": "{0} hodín"},
+ "hour": {"past": "hodinou", "future": "hodinu"},
"hours": {
+ "zero": "{0} hodín",
"past": "{0} hodinami",
"future-singular": "{0} hodiny",
"future-paucal": "{0} hodín",
},
- "day": {"past": "dňom", "future": "deň", "zero": "{0} dní"},
+ "day": {"past": "dňom", "future": "deň"},
"days": {
+ "zero": "{0} dní",
"past": "{0} dňami",
"future-singular": "{0} dni",
"future-paucal": "{0} dní",
},
- "week": {"past": "týždňom", "future": "týždeň", "zero": "{0} týždňov"},
+ "week": {"past": "týždňom", "future": "týždeň"},
"weeks": {
+ "zero": "{0} týždňov",
"past": "{0} týždňami",
"future-singular": "{0} týždne",
"future-paucal": "{0} týždňov",
},
- "month": {"past": "mesiacom", "future": "mesiac", "zero": "{0} mesiacov"},
+ "month": {"past": "mesiacom", "future": "mesiac"},
"months": {
+ "zero": "{0} mesiacov",
"past": "{0} mesiacmi",
"future-singular": "{0} mesiace",
"future-paucal": "{0} mesiacov",
},
- "year": {"past": "rokom", "future": "rok", "zero": "{0} rokov"},
+ "year": {"past": "rokom", "future": "rok"},
"years": {
+ "zero": "{0} rokov",
"past": "{0} rokmi",
"future-singular": "{0} roky",
"future-paucal": "{0} rokov",
| Czech/Slovak Locales Humanize Error When Zero Delta
<!--
Thanks for taking the time to submit this bug report.
Please provide us with a detailed description of the bug and a bit of information about your system.
-->
## Issue Description
The Czech and Slovak locales fail when using Humanize on a delta of zero. See the following example below.
```python
arw = arrow.Arrow(2000, 2, 18, 1, 50, 30)
past = arw.shift(minutes=0, days=-1)
past_string = past.humanize(
arw, locale='cs', granularity=["minute", "day"]
)
```
I suspect this is due to the fact that typically humanize when it sees a zero delta, defaults to the plural timeframe (i.e second vs seconds). This causes an issue for these locales since the "zero" string for a timeframe is located in the non-plural timeframe unit within the timeframe object.
## System Info
- 🖥 **OS name and version**: macOS 10.15.7 <!-- Replace with OS name and version (e.g. macOS 10.15.7). -->
- 🐍 **Python version**: 3.9.6 <!-- Replace with Python version (e.g. Python 3.8.5). -->
- 🏹 **Arrow version**: 1.2.1 <!-- Replace with Arrow version. Run arrow.__version__ to find out! -->
| arrow-py/arrow | diff --git a/tests/test_arrow.py b/tests/test_arrow.py
index a2f0881..60f3a64 100644
--- a/tests/test_arrow.py
+++ b/tests/test_arrow.py
@@ -2410,6 +2410,10 @@ def locale_list_no_weeks() -> List[str]:
"da-dk",
"ml",
"hi",
+ "cs",
+ "cs-cz",
+ "sk",
+ "sk-sk",
"fa",
"fa-ir",
"mr",
@@ -2511,6 +2515,10 @@ def locale_list_with_weeks() -> List[str]:
"pt",
"pt-pt",
"pt-br",
+ "cs",
+ "cs-cz",
+ "sk",
+ "sk-sk",
"tl",
"tl-ph",
"vi",
@@ -2954,6 +2962,34 @@ class TestArrowDehumanize:
assert arw.dehumanize(past_string, locale=lang) == past
assert arw.dehumanize(future_string, locale=lang) == future
+ def test_czech_slovak(self):
+
+ # Relevant units for Slavic locale plural logic
+ units = [
+ 0,
+ 1,
+ 2,
+ 5,
+ ]
+
+ # Only need to test on seconds as logic holds for all slavic plural units
+ for lang in ["cs"]:
+ for unit in units:
+ arw = arrow.Arrow(2000, 2, 18, 1, 50, 30)
+
+ past = arw.shift(minutes=-1 * unit, days=-1)
+ future = arw.shift(minutes=unit, days=1)
+
+ past_string = past.humanize(
+ arw, locale=lang, granularity=["minute", "day"]
+ )
+ future_string = future.humanize(
+ arw, locale=lang, granularity=["minute", "day"]
+ )
+
+ assert arw.dehumanize(past_string, locale=lang) == past
+ assert arw.dehumanize(future_string, locale=lang) == future
+
class TestArrowIsBetween:
def test_start_before_end(self):
diff --git a/tests/test_locales.py b/tests/test_locales.py
index 54f99ef..54536c0 100644
--- a/tests/test_locales.py
+++ b/tests/test_locales.py
@@ -613,8 +613,8 @@ class TestCzechLocale:
# Second(s)
assert self.locale._format_timeframe("second", -1) == "vteřina"
- assert self.locale._format_timeframe("second", 0) == "vteřina"
assert self.locale._format_timeframe("second", 1) == "vteřina"
+ assert self.locale._format_timeframe("seconds", 0) == "vteřina"
assert self.locale._format_timeframe("seconds", -2) == "2 sekundami"
assert self.locale._format_timeframe("seconds", -5) == "5 sekundami"
assert self.locale._format_timeframe("seconds", 2) == "2 sekundy"
@@ -622,8 +622,8 @@ class TestCzechLocale:
# Minute(s)
assert self.locale._format_timeframe("minute", -1) == "minutou"
- assert self.locale._format_timeframe("minute", 0) == "0 minut"
assert self.locale._format_timeframe("minute", 1) == "minutu"
+ assert self.locale._format_timeframe("minutes", 0) == "0 minut"
assert self.locale._format_timeframe("minutes", -2) == "2 minutami"
assert self.locale._format_timeframe("minutes", -5) == "5 minutami"
assert self.locale._format_timeframe("minutes", 2) == "2 minuty"
@@ -631,8 +631,8 @@ class TestCzechLocale:
# Hour(s)
assert self.locale._format_timeframe("hour", -1) == "hodinou"
- assert self.locale._format_timeframe("hour", 0) == "0 hodin"
assert self.locale._format_timeframe("hour", 1) == "hodinu"
+ assert self.locale._format_timeframe("hours", 0) == "0 hodin"
assert self.locale._format_timeframe("hours", -2) == "2 hodinami"
assert self.locale._format_timeframe("hours", -5) == "5 hodinami"
assert self.locale._format_timeframe("hours", 2) == "2 hodiny"
@@ -640,8 +640,8 @@ class TestCzechLocale:
# Day(s)
assert self.locale._format_timeframe("day", -1) == "dnem"
- assert self.locale._format_timeframe("day", 0) == "0 dnů"
assert self.locale._format_timeframe("day", 1) == "den"
+ assert self.locale._format_timeframe("days", 0) == "0 dnů"
assert self.locale._format_timeframe("days", -2) == "2 dny"
assert self.locale._format_timeframe("days", -5) == "5 dny"
assert self.locale._format_timeframe("days", 2) == "2 dny"
@@ -649,8 +649,8 @@ class TestCzechLocale:
# Weeks(s)
assert self.locale._format_timeframe("week", -1) == "týdnem"
- assert self.locale._format_timeframe("week", 0) == "0 týdnů"
assert self.locale._format_timeframe("week", 1) == "týden"
+ assert self.locale._format_timeframe("weeks", 0) == "0 týdnů"
assert self.locale._format_timeframe("weeks", -2) == "2 týdny"
assert self.locale._format_timeframe("weeks", -5) == "5 týdny"
assert self.locale._format_timeframe("weeks", 2) == "2 týdny"
@@ -658,8 +658,8 @@ class TestCzechLocale:
# Month(s)
assert self.locale._format_timeframe("month", -1) == "měsícem"
- assert self.locale._format_timeframe("month", 0) == "0 měsíců"
assert self.locale._format_timeframe("month", 1) == "měsíc"
+ assert self.locale._format_timeframe("months", 0) == "0 měsíců"
assert self.locale._format_timeframe("months", -2) == "2 měsíci"
assert self.locale._format_timeframe("months", -5) == "5 měsíci"
assert self.locale._format_timeframe("months", 2) == "2 měsíce"
@@ -667,8 +667,8 @@ class TestCzechLocale:
# Year(s)
assert self.locale._format_timeframe("year", -1) == "rokem"
- assert self.locale._format_timeframe("year", 0) == "0 let"
assert self.locale._format_timeframe("year", 1) == "rok"
+ assert self.locale._format_timeframe("years", 0) == "0 let"
assert self.locale._format_timeframe("years", -2) == "2 lety"
assert self.locale._format_timeframe("years", -5) == "5 lety"
assert self.locale._format_timeframe("years", 2) == "2 roky"
@@ -697,7 +697,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("seconds", -5) == "5 sekundami"
assert self.locale._format_timeframe("seconds", -2) == "2 sekundami"
assert self.locale._format_timeframe("second", -1) == "sekundou"
- assert self.locale._format_timeframe("second", 0) == "0 sekúnd"
+ assert self.locale._format_timeframe("seconds", 0) == "0 sekúnd"
assert self.locale._format_timeframe("second", 1) == "sekundu"
assert self.locale._format_timeframe("seconds", 2) == "2 sekundy"
assert self.locale._format_timeframe("seconds", 5) == "5 sekúnd"
@@ -705,7 +705,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("minutes", -5) == "5 minútami"
assert self.locale._format_timeframe("minutes", -2) == "2 minútami"
assert self.locale._format_timeframe("minute", -1) == "minútou"
- assert self.locale._format_timeframe("minute", 0) == "0 minút"
+ assert self.locale._format_timeframe("minutes", 0) == "0 minút"
assert self.locale._format_timeframe("minute", 1) == "minútu"
assert self.locale._format_timeframe("minutes", 2) == "2 minúty"
assert self.locale._format_timeframe("minutes", 5) == "5 minút"
@@ -713,7 +713,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("hours", -5) == "5 hodinami"
assert self.locale._format_timeframe("hours", -2) == "2 hodinami"
assert self.locale._format_timeframe("hour", -1) == "hodinou"
- assert self.locale._format_timeframe("hour", 0) == "0 hodín"
+ assert self.locale._format_timeframe("hours", 0) == "0 hodín"
assert self.locale._format_timeframe("hour", 1) == "hodinu"
assert self.locale._format_timeframe("hours", 2) == "2 hodiny"
assert self.locale._format_timeframe("hours", 5) == "5 hodín"
@@ -721,7 +721,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("days", -5) == "5 dňami"
assert self.locale._format_timeframe("days", -2) == "2 dňami"
assert self.locale._format_timeframe("day", -1) == "dňom"
- assert self.locale._format_timeframe("day", 0) == "0 dní"
+ assert self.locale._format_timeframe("days", 0) == "0 dní"
assert self.locale._format_timeframe("day", 1) == "deň"
assert self.locale._format_timeframe("days", 2) == "2 dni"
assert self.locale._format_timeframe("days", 5) == "5 dní"
@@ -729,7 +729,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("weeks", -5) == "5 týždňami"
assert self.locale._format_timeframe("weeks", -2) == "2 týždňami"
assert self.locale._format_timeframe("week", -1) == "týždňom"
- assert self.locale._format_timeframe("week", 0) == "0 týždňov"
+ assert self.locale._format_timeframe("weeks", 0) == "0 týždňov"
assert self.locale._format_timeframe("week", 1) == "týždeň"
assert self.locale._format_timeframe("weeks", 2) == "2 týždne"
assert self.locale._format_timeframe("weeks", 5) == "5 týždňov"
@@ -737,7 +737,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("months", -5) == "5 mesiacmi"
assert self.locale._format_timeframe("months", -2) == "2 mesiacmi"
assert self.locale._format_timeframe("month", -1) == "mesiacom"
- assert self.locale._format_timeframe("month", 0) == "0 mesiacov"
+ assert self.locale._format_timeframe("months", 0) == "0 mesiacov"
assert self.locale._format_timeframe("month", 1) == "mesiac"
assert self.locale._format_timeframe("months", 2) == "2 mesiace"
assert self.locale._format_timeframe("months", 5) == "5 mesiacov"
@@ -745,7 +745,7 @@ class TestSlovakLocale:
assert self.locale._format_timeframe("years", -5) == "5 rokmi"
assert self.locale._format_timeframe("years", -2) == "2 rokmi"
assert self.locale._format_timeframe("year", -1) == "rokom"
- assert self.locale._format_timeframe("year", 0) == "0 rokov"
+ assert self.locale._format_timeframe("years", 0) == "0 rokov"
assert self.locale._format_timeframe("year", 1) == "rok"
assert self.locale._format_timeframe("years", 2) == "2 roky"
assert self.locale._format_timeframe("years", 5) == "5 rokov"
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 2
} | 1.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest pytest-cov pytest-mock",
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
-e git+https://github.com/arrow-py/arrow.git@a2ebb7e20b4897ee7b7bf4676a5ac3e6c0f27f47#egg=arrow
attrs==25.3.0
babel==2.17.0
certifi==2025.1.31
cfgv==3.4.0
charset-normalizer==3.4.1
coverage==7.8.0
dateparser==1.2.0
distlib==0.3.9
docutils==0.17.1
filelock==3.18.0
identify==2.6.9
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
MarkupSafe==3.0.2
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
pre-commit==2.21.0
py==1.11.0
Pygments==2.19.1
pytest==6.2.5
pytest-cov==3.0.0
pytest-mock==3.14.0
python-dateutil==2.9.0.post0
pytz==2021.1
PyYAML==6.0.2
regex==2024.11.6
requests==2.32.3
simplejson==3.20.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==4.5.0
sphinx-autodoc-typehints==1.19.1
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
toml==0.10.2
tomli==2.2.1
tzlocal==5.3.1
urllib3==2.3.0
virtualenv==20.29.3
zipp==3.21.0
| name: arrow
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- attrs==25.3.0
- babel==2.17.0
- certifi==2025.1.31
- cfgv==3.4.0
- charset-normalizer==3.4.1
- coverage==7.8.0
- dateparser==1.2.0
- distlib==0.3.9
- docutils==0.17.1
- filelock==3.18.0
- identify==2.6.9
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markupsafe==3.0.2
- nodeenv==1.9.1
- packaging==24.2
- platformdirs==4.3.7
- pluggy==1.5.0
- pre-commit==2.21.0
- py==1.11.0
- pygments==2.19.1
- pytest==6.2.5
- pytest-cov==3.0.0
- pytest-mock==3.14.0
- python-dateutil==2.9.0.post0
- pytz==2021.1
- pyyaml==6.0.2
- regex==2024.11.6
- requests==2.32.3
- simplejson==3.20.1
- six==1.17.0
- snowballstemmer==2.2.0
- sphinx==4.5.0
- sphinx-autodoc-typehints==1.19.1
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- toml==0.10.2
- tomli==2.2.1
- tzlocal==5.3.1
- urllib3==2.3.0
- virtualenv==20.29.3
- zipp==3.21.0
prefix: /opt/conda/envs/arrow
| [
"tests/test_arrow.py::TestArrowDehumanize::test_now",
"tests/test_arrow.py::TestArrowDehumanize::test_seconds",
"tests/test_arrow.py::TestArrowDehumanize::test_minute",
"tests/test_arrow.py::TestArrowDehumanize::test_minutes",
"tests/test_arrow.py::TestArrowDehumanize::test_hour",
"tests/test_arrow.py::TestArrowDehumanize::test_hours",
"tests/test_arrow.py::TestArrowDehumanize::test_week",
"tests/test_arrow.py::TestArrowDehumanize::test_weeks",
"tests/test_arrow.py::TestArrowDehumanize::test_year",
"tests/test_arrow.py::TestArrowDehumanize::test_years",
"tests/test_arrow.py::TestArrowDehumanize::test_gt_than_10_years",
"tests/test_arrow.py::TestArrowDehumanize::test_mixed_granularity",
"tests/test_arrow.py::TestArrowDehumanize::test_mixed_granularity_hours",
"tests/test_arrow.py::TestArrowDehumanize::test_mixed_granularity_day",
"tests/test_arrow.py::TestArrowDehumanize::test_mixed_granularity_day_hour",
"tests/test_arrow.py::TestArrowDehumanize::test_czech_slovak",
"tests/test_locales.py::TestCzechLocale::test_format_timeframe",
"tests/test_locales.py::TestSlovakLocale::test_format_timeframe"
] | [] | [
"tests/test_arrow.py::TestTestArrowInit::test_init_bad_input",
"tests/test_arrow.py::TestTestArrowInit::test_init",
"tests/test_arrow.py::TestTestArrowInit::test_init_pytz_timezone",
"tests/test_arrow.py::TestTestArrowInit::test_init_with_fold",
"tests/test_arrow.py::TestTestArrowFactory::test_now",
"tests/test_arrow.py::TestTestArrowFactory::test_utcnow",
"tests/test_arrow.py::TestTestArrowFactory::test_fromtimestamp",
"tests/test_arrow.py::TestTestArrowFactory::test_utcfromtimestamp",
"tests/test_arrow.py::TestTestArrowFactory::test_fromdatetime",
"tests/test_arrow.py::TestTestArrowFactory::test_fromdatetime_dt_tzinfo",
"tests/test_arrow.py::TestTestArrowFactory::test_fromdatetime_tzinfo_arg",
"tests/test_arrow.py::TestTestArrowFactory::test_fromdate",
"tests/test_arrow.py::TestTestArrowFactory::test_strptime",
"tests/test_arrow.py::TestTestArrowFactory::test_fromordinal",
"tests/test_arrow.py::TestTestArrowRepresentation::test_repr",
"tests/test_arrow.py::TestTestArrowRepresentation::test_str",
"tests/test_arrow.py::TestTestArrowRepresentation::test_hash",
"tests/test_arrow.py::TestTestArrowRepresentation::test_format",
"tests/test_arrow.py::TestTestArrowRepresentation::test_bare_format",
"tests/test_arrow.py::TestTestArrowRepresentation::test_format_no_format_string",
"tests/test_arrow.py::TestTestArrowRepresentation::test_clone",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_base",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_week",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_quarter",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_dt_value",
"tests/test_arrow.py::TestArrowAttribute::test_tzinfo",
"tests/test_arrow.py::TestArrowAttribute::test_naive",
"tests/test_arrow.py::TestArrowAttribute::test_timestamp",
"tests/test_arrow.py::TestArrowAttribute::test_int_timestamp",
"tests/test_arrow.py::TestArrowAttribute::test_float_timestamp",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_fold",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_ambiguous",
"tests/test_arrow.py::TestArrowAttribute::test_getattr_imaginary",
"tests/test_arrow.py::TestArrowComparison::test_eq",
"tests/test_arrow.py::TestArrowComparison::test_ne",
"tests/test_arrow.py::TestArrowComparison::test_gt",
"tests/test_arrow.py::TestArrowComparison::test_ge",
"tests/test_arrow.py::TestArrowComparison::test_lt",
"tests/test_arrow.py::TestArrowComparison::test_le",
"tests/test_arrow.py::TestArrowMath::test_add_timedelta",
"tests/test_arrow.py::TestArrowMath::test_add_other",
"tests/test_arrow.py::TestArrowMath::test_radd",
"tests/test_arrow.py::TestArrowMath::test_sub_timedelta",
"tests/test_arrow.py::TestArrowMath::test_sub_datetime",
"tests/test_arrow.py::TestArrowMath::test_sub_arrow",
"tests/test_arrow.py::TestArrowMath::test_sub_other",
"tests/test_arrow.py::TestArrowMath::test_rsub_datetime",
"tests/test_arrow.py::TestArrowMath::test_rsub_other",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_date",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_time",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_timetz",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_astimezone",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_utcoffset",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_dst",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_timetuple",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_utctimetuple",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_toordinal",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_weekday",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_isoweekday",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_isocalendar",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_isoformat",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_isoformat_timespec",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_simplejson",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_ctime",
"tests/test_arrow.py::TestArrowDatetimeInterface::test_strftime",
"tests/test_arrow.py::TestArrowFalsePositiveDst::test_dst",
"tests/test_arrow.py::TestArrowConversion::test_to",
"tests/test_arrow.py::TestArrowConversion::test_to_pacific_then_utc",
"tests/test_arrow.py::TestArrowConversion::test_to_amsterdam_then_utc",
"tests/test_arrow.py::TestArrowConversion::test_to_israel_same_offset",
"tests/test_arrow.py::TestArrowConversion::test_anchorage_dst",
"tests/test_arrow.py::TestArrowConversion::test_chicago_fall",
"tests/test_arrow.py::TestArrowConversion::test_toronto_gap",
"tests/test_arrow.py::TestArrowConversion::test_sydney_gap",
"tests/test_arrow.py::TestArrowPickling::test_pickle_and_unpickle",
"tests/test_arrow.py::TestArrowReplace::test_not_attr",
"tests/test_arrow.py::TestArrowReplace::test_replace",
"tests/test_arrow.py::TestArrowReplace::test_replace_tzinfo",
"tests/test_arrow.py::TestArrowReplace::test_replace_fold",
"tests/test_arrow.py::TestArrowReplace::test_replace_fold_and_other",
"tests/test_arrow.py::TestArrowReplace::test_replace_week",
"tests/test_arrow.py::TestArrowReplace::test_replace_quarter",
"tests/test_arrow.py::TestArrowReplace::test_replace_quarter_and_fold",
"tests/test_arrow.py::TestArrowReplace::test_replace_other_kwargs",
"tests/test_arrow.py::TestArrowShift::test_not_attr",
"tests/test_arrow.py::TestArrowShift::test_shift",
"tests/test_arrow.py::TestArrowShift::test_shift_negative",
"tests/test_arrow.py::TestArrowShift::test_shift_quarters_bug",
"tests/test_arrow.py::TestArrowShift::test_shift_positive_imaginary",
"tests/test_arrow.py::TestArrowShift::test_shift_negative_imaginary",
"tests/test_arrow.py::TestArrowShift::test_shift_kiritimati",
"tests/test_arrow.py::TestArrowRange::test_year",
"tests/test_arrow.py::TestArrowRange::test_quarter",
"tests/test_arrow.py::TestArrowRange::test_month",
"tests/test_arrow.py::TestArrowRange::test_week",
"tests/test_arrow.py::TestArrowRange::test_day",
"tests/test_arrow.py::TestArrowRange::test_hour",
"tests/test_arrow.py::TestArrowRange::test_minute",
"tests/test_arrow.py::TestArrowRange::test_second",
"tests/test_arrow.py::TestArrowRange::test_arrow",
"tests/test_arrow.py::TestArrowRange::test_naive_tz",
"tests/test_arrow.py::TestArrowRange::test_aware_same_tz",
"tests/test_arrow.py::TestArrowRange::test_aware_different_tz",
"tests/test_arrow.py::TestArrowRange::test_aware_tz",
"tests/test_arrow.py::TestArrowRange::test_imaginary",
"tests/test_arrow.py::TestArrowRange::test_unsupported",
"tests/test_arrow.py::TestArrowRange::test_range_over_months_ending_on_different_days",
"tests/test_arrow.py::TestArrowRange::test_range_over_quarter_months_ending_on_different_days",
"tests/test_arrow.py::TestArrowRange::test_range_over_year_maintains_end_date_across_leap_year",
"tests/test_arrow.py::TestArrowSpanRange::test_year",
"tests/test_arrow.py::TestArrowSpanRange::test_quarter",
"tests/test_arrow.py::TestArrowSpanRange::test_month",
"tests/test_arrow.py::TestArrowSpanRange::test_week",
"tests/test_arrow.py::TestArrowSpanRange::test_day",
"tests/test_arrow.py::TestArrowSpanRange::test_days",
"tests/test_arrow.py::TestArrowSpanRange::test_hour",
"tests/test_arrow.py::TestArrowSpanRange::test_minute",
"tests/test_arrow.py::TestArrowSpanRange::test_second",
"tests/test_arrow.py::TestArrowSpanRange::test_naive_tz",
"tests/test_arrow.py::TestArrowSpanRange::test_aware_same_tz",
"tests/test_arrow.py::TestArrowSpanRange::test_aware_different_tz",
"tests/test_arrow.py::TestArrowSpanRange::test_aware_tz",
"tests/test_arrow.py::TestArrowSpanRange::test_bounds_param_is_passed",
"tests/test_arrow.py::TestArrowSpanRange::test_exact_bound_exclude",
"tests/test_arrow.py::TestArrowSpanRange::test_exact_floor_equals_end",
"tests/test_arrow.py::TestArrowSpanRange::test_exact_bound_include",
"tests/test_arrow.py::TestArrowSpanRange::test_small_interval_exact_open_bounds",
"tests/test_arrow.py::TestArrowInterval::test_incorrect_input",
"tests/test_arrow.py::TestArrowInterval::test_correct",
"tests/test_arrow.py::TestArrowInterval::test_bounds_param_is_passed",
"tests/test_arrow.py::TestArrowInterval::test_exact",
"tests/test_arrow.py::TestArrowSpan::test_span_attribute",
"tests/test_arrow.py::TestArrowSpan::test_span_year",
"tests/test_arrow.py::TestArrowSpan::test_span_quarter",
"tests/test_arrow.py::TestArrowSpan::test_span_quarter_count",
"tests/test_arrow.py::TestArrowSpan::test_span_year_count",
"tests/test_arrow.py::TestArrowSpan::test_span_month",
"tests/test_arrow.py::TestArrowSpan::test_span_week",
"tests/test_arrow.py::TestArrowSpan::test_span_day",
"tests/test_arrow.py::TestArrowSpan::test_span_hour",
"tests/test_arrow.py::TestArrowSpan::test_span_minute",
"tests/test_arrow.py::TestArrowSpan::test_span_second",
"tests/test_arrow.py::TestArrowSpan::test_span_microsecond",
"tests/test_arrow.py::TestArrowSpan::test_floor",
"tests/test_arrow.py::TestArrowSpan::test_span_inclusive_inclusive",
"tests/test_arrow.py::TestArrowSpan::test_span_exclusive_inclusive",
"tests/test_arrow.py::TestArrowSpan::test_span_exclusive_exclusive",
"tests/test_arrow.py::TestArrowSpan::test_bounds_are_validated",
"tests/test_arrow.py::TestArrowSpan::test_exact",
"tests/test_arrow.py::TestArrowSpan::test_exact_inclusive_inclusive",
"tests/test_arrow.py::TestArrowSpan::test_exact_exclusive_inclusive",
"tests/test_arrow.py::TestArrowSpan::test_exact_exclusive_exclusive",
"tests/test_arrow.py::TestArrowSpan::test_all_parameters_specified",
"tests/test_arrow.py::TestArrowHumanize::test_granularity",
"tests/test_arrow.py::TestArrowHumanize::test_multiple_granularity",
"tests/test_arrow.py::TestArrowHumanize::test_seconds",
"tests/test_arrow.py::TestArrowHumanize::test_minute",
"tests/test_arrow.py::TestArrowHumanize::test_minutes",
"tests/test_arrow.py::TestArrowHumanize::test_hour",
"tests/test_arrow.py::TestArrowHumanize::test_hours",
"tests/test_arrow.py::TestArrowHumanize::test_day",
"tests/test_arrow.py::TestArrowHumanize::test_days",
"tests/test_arrow.py::TestArrowHumanize::test_week",
"tests/test_arrow.py::TestArrowHumanize::test_weeks",
"tests/test_arrow.py::TestArrowHumanize::test_month_plus_4_days",
"tests/test_arrow.py::TestArrowHumanize::test_year",
"tests/test_arrow.py::TestArrowHumanize::test_years",
"tests/test_arrow.py::TestArrowHumanize::test_arrow",
"tests/test_arrow.py::TestArrowHumanize::test_datetime_tzinfo",
"tests/test_arrow.py::TestArrowHumanize::test_other",
"tests/test_arrow.py::TestArrowHumanize::test_invalid_locale",
"tests/test_arrow.py::TestArrowHumanize::test_none",
"tests/test_arrow.py::TestArrowHumanize::test_week_limit",
"tests/test_arrow.py::TestArrowHumanize::test_untranslated_granularity",
"tests/test_arrow.py::TestArrowHumanize::test_empty_granularity_list",
"tests/test_arrow.py::TestArrowHumanize::test_no_floats",
"tests/test_arrow.py::TestArrowHumanize::test_no_floats_multi_gran",
"tests/test_arrow.py::TestArrowHumanizeTestsWithLocale::test_now",
"tests/test_arrow.py::TestArrowHumanizeTestsWithLocale::test_seconds",
"tests/test_arrow.py::TestArrowHumanizeTestsWithLocale::test_years",
"tests/test_arrow.py::TestArrowDehumanize::test_unsupported_locale",
"tests/test_arrow.py::TestArrowDehumanize::test_normalized_locale",
"tests/test_arrow.py::TestArrowDehumanize::test_require_relative_unit",
"tests/test_arrow.py::TestArrowDehumanize::test_scrambled_input",
"tests/test_arrow.py::TestArrowDehumanize::test_no_units_modified",
"tests/test_arrow.py::TestArrowDehumanize::test_slavic_locales",
"tests/test_arrow.py::TestArrowIsBetween::test_start_before_end",
"tests/test_arrow.py::TestArrowIsBetween::test_exclusive_exclusive_bounds",
"tests/test_arrow.py::TestArrowIsBetween::test_exclusive_exclusive_bounds_same_date",
"tests/test_arrow.py::TestArrowIsBetween::test_inclusive_exclusive_bounds",
"tests/test_arrow.py::TestArrowIsBetween::test_exclusive_inclusive_bounds",
"tests/test_arrow.py::TestArrowIsBetween::test_inclusive_inclusive_bounds_same_date",
"tests/test_arrow.py::TestArrowIsBetween::test_inclusive_inclusive_bounds_target_before_start",
"tests/test_arrow.py::TestArrowIsBetween::test_type_error_exception",
"tests/test_arrow.py::TestArrowIsBetween::test_value_error_exception",
"tests/test_arrow.py::TestArrowUtil::test_get_datetime",
"tests/test_arrow.py::TestArrowUtil::test_get_tzinfo",
"tests/test_arrow.py::TestArrowUtil::test_get_iteration_params",
"tests/test_locales.py::TestLocaleValidation::test_locale_validation",
"tests/test_locales.py::TestLocaleValidation::test_locale_name_validation",
"tests/test_locales.py::TestLocaleValidation::test_duplicated_locale_name",
"tests/test_locales.py::TestModule::test_get_locale",
"tests/test_locales.py::TestModule::test_get_locale_by_class_name",
"tests/test_locales.py::TestModule::test_locales",
"tests/test_locales.py::TestCustomLocale::test_custom_locale_subclass",
"tests/test_locales.py::TestEnglishLocale::test_describe",
"tests/test_locales.py::TestEnglishLocale::test_format_timeframe",
"tests/test_locales.py::TestEnglishLocale::test_format_relative_now",
"tests/test_locales.py::TestEnglishLocale::test_format_relative_past",
"tests/test_locales.py::TestEnglishLocale::test_format_relative_future",
"tests/test_locales.py::TestEnglishLocale::test_ordinal_number",
"tests/test_locales.py::TestEnglishLocale::test_meridian_invalid_token",
"tests/test_locales.py::TestItalianLocale::test_ordinal_number",
"tests/test_locales.py::TestSpanishLocale::test_ordinal_number",
"tests/test_locales.py::TestSpanishLocale::test_format_timeframe",
"tests/test_locales.py::TestFrenchLocale::test_ordinal_number",
"tests/test_locales.py::TestFrenchLocale::test_month_abbreviation",
"tests/test_locales.py::TestFrenchCanadianLocale::test_month_abbreviation",
"tests/test_locales.py::TestRussianLocale::test_singles_timeframe",
"tests/test_locales.py::TestRussianLocale::test_singles_relative",
"tests/test_locales.py::TestRussianLocale::test_plurals_timeframe",
"tests/test_locales.py::TestRussianLocale::test_plurals_relative",
"tests/test_locales.py::TestRussianLocale::test_plurals2",
"tests/test_locales.py::TestPolishLocale::test_plurals",
"tests/test_locales.py::TestIcelandicLocale::test_format_timeframe",
"tests/test_locales.py::TestMalayalamLocale::test_format_timeframe",
"tests/test_locales.py::TestMalayalamLocale::test_format_relative_now",
"tests/test_locales.py::TestMalayalamLocale::test_format_relative_past",
"tests/test_locales.py::TestMalayalamLocale::test_format_relative_future",
"tests/test_locales.py::TestMalteseLocale::test_format_timeframe",
"tests/test_locales.py::TestMalteseLocale::test_weekday",
"tests/test_locales.py::TestHindiLocale::test_format_timeframe",
"tests/test_locales.py::TestHindiLocale::test_format_relative_now",
"tests/test_locales.py::TestHindiLocale::test_format_relative_past",
"tests/test_locales.py::TestHindiLocale::test_format_relative_future",
"tests/test_locales.py::TestCzechLocale::test_format_relative_now",
"tests/test_locales.py::TestCzechLocale::test_format_relative_future",
"tests/test_locales.py::TestCzechLocale::test_format_relative_past",
"tests/test_locales.py::TestSlovakLocale::test_format_relative_now",
"tests/test_locales.py::TestSlovakLocale::test_format_relative_future",
"tests/test_locales.py::TestSlovakLocale::test_format_relative_past",
"tests/test_locales.py::TestBulgarianLocale::test_plurals2",
"tests/test_locales.py::TestMacedonianLocale::test_singles_mk",
"tests/test_locales.py::TestMacedonianLocale::test_meridians_mk",
"tests/test_locales.py::TestMacedonianLocale::test_describe_mk",
"tests/test_locales.py::TestMacedonianLocale::test_relative_mk",
"tests/test_locales.py::TestMacedonianLocale::test_plurals_mk",
"tests/test_locales.py::TestMacedonianLocale::test_multi_describe_mk",
"tests/test_locales.py::TestHebrewLocale::test_couple_of_timeframe",
"tests/test_locales.py::TestHebrewLocale::test_describe_multi",
"tests/test_locales.py::TestAzerbaijaniLocale::test_singles_mk",
"tests/test_locales.py::TestAzerbaijaniLocale::test_describe_mk",
"tests/test_locales.py::TestAzerbaijaniLocale::test_relative_mk",
"tests/test_locales.py::TestAzerbaijaniLocale::test_plurals_mk",
"tests/test_locales.py::TestMarathiLocale::test_dateCoreFunctionality",
"tests/test_locales.py::TestMarathiLocale::test_format_timeframe",
"tests/test_locales.py::TestMarathiLocale::test_format_relative_now",
"tests/test_locales.py::TestMarathiLocale::test_format_relative_past",
"tests/test_locales.py::TestMarathiLocale::test_format_relative_future",
"tests/test_locales.py::TestMarathiLocale::test_ordinal_number",
"tests/test_locales.py::TestFinnishLocale::test_format_timeframe",
"tests/test_locales.py::TestFinnishLocale::test_format_relative_now",
"tests/test_locales.py::TestFinnishLocale::test_format_relative_past",
"tests/test_locales.py::TestFinnishLocale::test_format_relative_future",
"tests/test_locales.py::TestFinnishLocale::test_ordinal_number",
"tests/test_locales.py::TestGermanLocale::test_ordinal_number",
"tests/test_locales.py::TestGermanLocale::test_define",
"tests/test_locales.py::TestGermanLocale::test_weekday",
"tests/test_locales.py::TestHungarianLocale::test_format_timeframe",
"tests/test_locales.py::TestEsperantoLocale::test_format_timeframe",
"tests/test_locales.py::TestEsperantoLocale::test_ordinal_number",
"tests/test_locales.py::TestThaiLocale::test_year_full",
"tests/test_locales.py::TestThaiLocale::test_year_abbreviation",
"tests/test_locales.py::TestThaiLocale::test_format_relative_now",
"tests/test_locales.py::TestThaiLocale::test_format_relative_past",
"tests/test_locales.py::TestThaiLocale::test_format_relative_future",
"tests/test_locales.py::TestBengaliLocale::test_ordinal_number",
"tests/test_locales.py::TestRomanianLocale::test_timeframes",
"tests/test_locales.py::TestRomanianLocale::test_relative_timeframes",
"tests/test_locales.py::TestArabicLocale::test_timeframes",
"tests/test_locales.py::TestNepaliLocale::test_format_timeframe",
"tests/test_locales.py::TestNepaliLocale::test_format_relative_now",
"tests/test_locales.py::TestNepaliLocale::test_format_relative_future",
"tests/test_locales.py::TestNepaliLocale::test_format_relative_past",
"tests/test_locales.py::TestIndonesianLocale::test_timeframes",
"tests/test_locales.py::TestIndonesianLocale::test_format_relative_now",
"tests/test_locales.py::TestIndonesianLocale::test_format_relative_past",
"tests/test_locales.py::TestIndonesianLocale::test_format_relative_future",
"tests/test_locales.py::TestTagalogLocale::test_singles_tl",
"tests/test_locales.py::TestTagalogLocale::test_meridians_tl",
"tests/test_locales.py::TestTagalogLocale::test_describe_tl",
"tests/test_locales.py::TestTagalogLocale::test_relative_tl",
"tests/test_locales.py::TestTagalogLocale::test_plurals_tl",
"tests/test_locales.py::TestTagalogLocale::test_multi_describe_tl",
"tests/test_locales.py::TestTagalogLocale::test_ordinal_number_tl",
"tests/test_locales.py::TestCroatianLocale::test_format_timeframe",
"tests/test_locales.py::TestCroatianLocale::test_weekday",
"tests/test_locales.py::TestSerbianLocale::test_format_timeframe",
"tests/test_locales.py::TestSerbianLocale::test_weekday",
"tests/test_locales.py::TestLatinLocale::test_format_timeframe",
"tests/test_locales.py::TestLatinLocale::test_weekday",
"tests/test_locales.py::TestLithuanianLocale::test_format_timeframe",
"tests/test_locales.py::TestLithuanianLocale::test_weekday",
"tests/test_locales.py::TestMalayLocale::test_format_timeframe",
"tests/test_locales.py::TestMalayLocale::test_weekday",
"tests/test_locales.py::TestSamiLocale::test_format_timeframe",
"tests/test_locales.py::TestSamiLocale::test_weekday",
"tests/test_locales.py::TestZuluLocale::test_format_timeframe",
"tests/test_locales.py::TestZuluLocale::test_weekday",
"tests/test_locales.py::TestAlbanianLocale::test_format_timeframe",
"tests/test_locales.py::TestAlbanianLocale::test_weekday_and_month",
"tests/test_locales.py::TestUrduLocale::test_format_timeframe",
"tests/test_locales.py::TestUrduLocale::test_weekday_and_month",
"tests/test_locales.py::TestEstonianLocale::test_format_timeframe",
"tests/test_locales.py::TestPortugueseLocale::test_format_timeframe",
"tests/test_locales.py::TestLatvianLocale::test_format_timeframe",
"tests/test_locales.py::TestLatvianLocale::test_weekday",
"tests/test_locales.py::TestBrazilianPortugueseLocale::test_format_timeframe",
"tests/test_locales.py::TestHongKongLocale::test_format_timeframe",
"tests/test_locales.py::TestChineseTWLocale::test_format_timeframe",
"tests/test_locales.py::TestChineseCNLocale::test_format_timeframe",
"tests/test_locales.py::TestSwahiliLocale::test_format_timeframe",
"tests/test_locales.py::TestSwahiliLocale::test_format_relative_now",
"tests/test_locales.py::TestSwahiliLocale::test_format_relative_past",
"tests/test_locales.py::TestSwahiliLocale::test_format_relative_future",
"tests/test_locales.py::TestKoreanLocale::test_format_timeframe",
"tests/test_locales.py::TestKoreanLocale::test_format_relative",
"tests/test_locales.py::TestKoreanLocale::test_ordinal_number",
"tests/test_locales.py::TestJapaneseLocale::test_format_timeframe",
"tests/test_locales.py::TestSwedishLocale::test_plurals",
"tests/test_locales.py::TestOdiaLocale::test_ordinal_number",
"tests/test_locales.py::TestOdiaLocale::test_format_timeframe",
"tests/test_locales.py::TestOdiaLocale::test_format_relative_now",
"tests/test_locales.py::TestOdiaLocale::test_format_relative_past",
"tests/test_locales.py::TestOdiaLocale::test_format_relative_future",
"tests/test_locales.py::TestTurkishLocale::test_singles_mk",
"tests/test_locales.py::TestTurkishLocale::test_meridians_mk",
"tests/test_locales.py::TestTurkishLocale::test_describe_mk",
"tests/test_locales.py::TestTurkishLocale::test_relative_mk",
"tests/test_locales.py::TestTurkishLocale::test_plurals_mk",
"tests/test_locales.py::TestLuxembourgishLocale::test_ordinal_number",
"tests/test_locales.py::TestLuxembourgishLocale::test_define",
"tests/test_locales.py::TestLuxembourgishLocale::test_weekday",
"tests/test_locales.py::TestTamilLocale::test_format_timeframe",
"tests/test_locales.py::TestTamilLocale::test_ordinal_number",
"tests/test_locales.py::TestTamilLocale::test_format_relative_now",
"tests/test_locales.py::TestTamilLocale::test_format_relative_past",
"tests/test_locales.py::TestTamilLocale::test_format_relative_future",
"tests/test_locales.py::TestTamilLocale::test_weekday",
"tests/test_locales.py::TestSinhalaLocale::test_format_timeframe",
"tests/test_locales.py::TestSinhalaLocale::test_describe_si",
"tests/test_locales.py::TestSinhalaLocale::test_format_relative_now",
"tests/test_locales.py::TestSinhalaLocale::test_format_relative_future",
"tests/test_locales.py::TestSinhalaLocale::test_format_relative_past",
"tests/test_locales.py::TestSinhalaLocale::test_weekday",
"tests/test_locales.py::TestKazakhLocale::test_singles_mk",
"tests/test_locales.py::TestKazakhLocale::test_describe_mk",
"tests/test_locales.py::TestKazakhLocale::test_relative_mk",
"tests/test_locales.py::TestKazakhLocale::test_plurals_mk"
] | [] | Apache License 2.0 | 11,887 | 1,805 | [
"arrow/constants.py",
"arrow/locales.py"
] |
pydicom__pydicom-1555 | 9db89e1d8f5e82dc617f9c8cbf303fe23a0632b9 | 2021-12-29 08:49:15 | 0fa18d2a2179c92efc22200ed6b3689e66cecf92 | pep8speaks: Hello @scaramallion! Thanks for opening this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:
* In the file [`pydicom/valuerep.py`](https://github.com/pydicom/pydicom/blob/621cafd5439839fee58449b1c1dbd209b8bbc400/pydicom/valuerep.py):
> [Line 58:80](https://github.com/pydicom/pydicom/blob/621cafd5439839fee58449b1c1dbd209b8bbc400/pydicom/valuerep.py#L58): [E501](https://duckduckgo.com/?q=pep8%20E501) line too long (88 > 79 characters)
codecov[bot]: # [Codecov](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) Report
> Merging [#1555](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) (621cafd) into [master](https://codecov.io/gh/pydicom/pydicom/commit/9db89e1d8f5e82dc617f9c8cbf303fe23a0632b9?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) (9db89e1) will **not change** coverage.
> The diff coverage is `100.00%`.
> :exclamation: Current head 621cafd differs from pull request most recent head ed9003f. Consider uploading reports for the commit ed9003f to get more accurate results
[](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom)
```diff
@@ Coverage Diff @@
## master #1555 +/- ##
=======================================
Coverage 97.42% 97.42%
=======================================
Files 66 66
Lines 10185 10185
=======================================
Hits 9923 9923
Misses 262 262
```
| [Impacted Files](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) | Coverage Δ | |
|---|---|---|
| [pydicom/dataset.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9kYXRhc2V0LnB5) | `99.06% <100.00%> (ø)` | |
| [pydicom/encoders/base.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9lbmNvZGVycy9iYXNlLnB5) | `100.00% <100.00%> (ø)` | |
| [pydicom/filebase.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9maWxlYmFzZS5weQ==) | `97.58% <100.00%> (ø)` | |
| [pydicom/fileset.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9maWxlc2V0LnB5) | `100.00% <100.00%> (ø)` | |
| [pydicom/filewriter.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9maWxld3JpdGVyLnB5) | `97.79% <100.00%> (ø)` | |
| [pydicom/pixel\_data\_handlers/util.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9waXhlbF9kYXRhX2hhbmRsZXJzL3V0aWwucHk=) | `100.00% <100.00%> (ø)` | |
| [pydicom/valuerep.py](https://codecov.io/gh/pydicom/pydicom/pull/1555/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS92YWx1ZXJlcC5weQ==) | `99.20% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom). Last update [9db89e1...ed9003f](https://codecov.io/gh/pydicom/pydicom/pull/1555?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom).
| diff --git a/pydicom/dataset.py b/pydicom/dataset.py
index 3b80942db..a4a212157 100644
--- a/pydicom/dataset.py
+++ b/pydicom/dataset.py
@@ -1488,7 +1488,7 @@ class Dataset:
possible_handlers = [
hh for hh in pydicom.config.pixel_data_handlers
if hh is not None
- and hh.supports_transfer_syntax(ts) # type: ignore[attr-defined]
+ and hh.supports_transfer_syntax(ts)
]
# No handlers support the transfer syntax
@@ -1504,7 +1504,7 @@ class Dataset:
# dependencies met
available_handlers = [
hh for hh in possible_handlers
- if hh.is_available() # type: ignore[attr-defined]
+ if hh.is_available()
]
# There are handlers that support the transfer syntax but none of them
@@ -1518,13 +1518,13 @@ class Dataset:
)
pkg_msg = []
for hh in possible_handlers:
- hh_deps = hh.DEPENDENCIES # type: ignore[attr-defined]
+ hh_deps = hh.DEPENDENCIES
# Missing packages
missing = [dd for dd in hh_deps if have_package(dd) is None]
# Package names
names = [hh_deps[name][1] for name in missing]
pkg_msg.append(
- f"{hh.HANDLER_NAME} " # type: ignore[attr-defined]
+ f"{hh.HANDLER_NAME} "
f"(req. {', '.join(names)})"
)
@@ -1819,7 +1819,7 @@ class Dataset:
available_handlers = [
hh for hh in overlay_data_handlers
- if hh.is_available() # type: ignore[attr-defined]
+ if hh.is_available()
]
if not available_handlers:
# For each of the handlers we want to find which
@@ -1830,13 +1830,13 @@ class Dataset:
)
pkg_msg = []
for hh in overlay_data_handlers:
- hh_deps = hh.DEPENDENCIES # type: ignore[attr-defined]
+ hh_deps = hh.DEPENDENCIES
# Missing packages
missing = [dd for dd in hh_deps if have_package(dd) is None]
# Package names
names = [hh_deps[name][1] for name in missing]
pkg_msg.append(
- f"{hh.HANDLER_NAME} " # type: ignore[attr-defined]
+ f"{hh.HANDLER_NAME} "
f"(req. {', '.join(names)})"
)
@@ -1846,7 +1846,7 @@ class Dataset:
for handler in available_handlers:
try:
# Use the handler to get an ndarray of the pixel data
- func = handler.get_overlay_array # type: ignore[attr-defined]
+ func = handler.get_overlay_array
return cast("numpy.ndarray", func(self, group))
except Exception as exc:
logger.debug(
diff --git a/pydicom/encoders/base.py b/pydicom/encoders/base.py
index 44044b10b..d41fda43b 100644
--- a/pydicom/encoders/base.py
+++ b/pydicom/encoders/base.py
@@ -84,11 +84,11 @@ class Encoder:
module = import_module(import_path[0])
# `is_available(UID)` is required for plugins
- if module.is_available(self.UID): # type: ignore[attr-defined]
+ if module.is_available(self.UID):
self._available[label] = getattr(module, import_path[1])
else:
# `ENCODER_DEPENDENCIES[UID]` is required for plugins
- deps = module.ENCODER_DEPENDENCIES # type: ignore[attr-defined]
+ deps = module.ENCODER_DEPENDENCIES
self._unavailable[label] = deps[self.UID]
@staticmethod
diff --git a/pydicom/filebase.py b/pydicom/filebase.py
index cec6bdcc0..9ac039045 100644
--- a/pydicom/filebase.py
+++ b/pydicom/filebase.py
@@ -182,15 +182,15 @@ class DicomFileLike(DicomIO):
self.close = file_like_obj.close
self.name: str = getattr(file_like_obj, 'name', '<no filename>')
- def no_write(self, bytes_read: bytes) -> None:
+ def no_write(self, bytes_read: bytes) -> int:
"""Used for file-like objects where no write is available"""
raise IOError("This DicomFileLike object has no write() method")
- def no_read(self, bytes_read: Optional[int] = None) -> None:
+ def no_read(self, size: int = -1) -> bytes:
"""Used for file-like objects where no read is available"""
raise IOError("This DicomFileLike object has no read() method")
- def no_seek(self, offset: int, from_what: int = 0) -> None:
+ def no_seek(self, offset: int, whence: int = 0) -> int:
"""Used for file-like objects where no seek is available"""
raise IOError("This DicomFileLike object has no seek() method")
diff --git a/pydicom/fileset.py b/pydicom/fileset.py
index 436e1e903..a831318f3 100644
--- a/pydicom/fileset.py
+++ b/pydicom/fileset.py
@@ -2865,10 +2865,10 @@ _FOUR_LEVEL_SOP_CLASSES = {
def _single_level_record_type(ds: Dataset) -> str:
"""Return a single-level *Directory Record Type* for `ds`."""
- sop_class = getattr(ds, "SOPClassUID", None)
+ sop_class = cast(Optional[UID], getattr(ds, "SOPClassUID", None))
try:
- return _SINGLE_LEVEL_SOP_CLASSES[sop_class]
+ return _SINGLE_LEVEL_SOP_CLASSES[sop_class] # type: ignore[index]
except KeyError:
return "PATIENT"
@@ -2888,9 +2888,9 @@ def _four_level_record_type(ds: Dataset) -> str:
if "RTPlanLabel" in ds:
return "RT PLAN"
- sop_class = getattr(ds, "SOPClassUID", None)
+ sop_class = cast(Optional[UID], getattr(ds, "SOPClassUID", None))
try:
- return _FOUR_LEVEL_SOP_CLASSES[sop_class]
+ return _FOUR_LEVEL_SOP_CLASSES[sop_class] # type: ignore[index]
except KeyError:
return "IMAGE"
diff --git a/pydicom/filewriter.py b/pydicom/filewriter.py
index ab164a61b..2a9bdee73 100644
--- a/pydicom/filewriter.py
+++ b/pydicom/filewriter.py
@@ -1000,6 +1000,7 @@ def dcmwrite(
Write a DICOM file from a dataset that was read in with ``dcmread()``.
``save_as()`` wraps ``dcmwrite()``.
"""
+ tsyntax: Optional[UID]
# Ensure is_little_endian and is_implicit_VR are set
if None in (dataset.is_little_endian, dataset.is_implicit_VR):
@@ -1090,7 +1091,7 @@ def dcmwrite(
fp.write(preamble)
fp.write(b'DICM')
- tsyntax: Optional[UID] = None # type: ignore[no-redef]
+ tsyntax = None
if dataset.file_meta: # May be an empty Dataset
# If we want to `write_like_original`, don't enforce_standard
write_file_meta_info(
diff --git a/pydicom/pixel_data_handlers/util.py b/pydicom/pixel_data_handlers/util.py
index b5f79bfc1..fe08752a8 100644
--- a/pydicom/pixel_data_handlers/util.py
+++ b/pydicom/pixel_data_handlers/util.py
@@ -244,7 +244,7 @@ def apply_modality_lut(arr: "np.ndarray", ds: "Dataset") -> "np.ndarray":
* DICOM Standard, Part 4, :dcm:`Annex N.2.1.1
<part04/sect_N.2.html#sect_N.2.1.1>`
"""
- if 'ModalityLUTSequence' in ds:
+ if ds.get("ModalityLUTSequence"):
item = cast(List["Dataset"], ds.ModalityLUTSequence)[0]
nr_entries = cast(List[int], item.LUTDescriptor)[0] or 2**16
first_map = cast(List[int], item.LUTDescriptor)[1]
@@ -342,7 +342,7 @@ def apply_voi_lut(
<part04/sect_N.2.html#sect_N.2.1.1>`
"""
valid_voi = False
- if 'VOILUTSequence' in ds:
+ if ds.get('VOILUTSequence'):
ds.VOILUTSequence = cast(List["Dataset"], ds.VOILUTSequence)
valid_voi = None not in [
ds.VOILUTSequence[0].get('LUTDescriptor', None),
@@ -408,7 +408,7 @@ def apply_voi(
* DICOM Standard, Part 4, :dcm:`Annex N.2.1.1
<part04/sect_N.2.html#sect_N.2.1.1>`
"""
- if "VOILUTSequence" not in ds:
+ if not ds.get('VOILUTSequence'):
return arr
if not np.issubdtype(arr.dtype, np.integer):
@@ -529,7 +529,7 @@ def apply_windowing(
ds.BitsStored = cast(int, ds.BitsStored)
y_min: float
y_max: float
- if 'ModalityLUTSequence' in ds:
+ if ds.get('ModalityLUTSequence'):
# Unsigned - see PS3.3 C.11.1.1.1
y_min = 0
item = cast(List["Dataset"], ds.ModalityLUTSequence)[0]
diff --git a/pydicom/valuerep.py b/pydicom/valuerep.py
index aac1d4612..cc0c1a986 100644
--- a/pydicom/valuerep.py
+++ b/pydicom/valuerep.py
@@ -55,7 +55,10 @@ class _DateTimeBase:
def __setstate__(self, state: Dict[str, Any]) -> None:
self.__dict__.update(state)
- def __reduce_ex__(self, protocol: int) -> Tuple[Any, ...]:
+ def __reduce_ex__( # type: ignore[override]
+ self, protocol: int
+ ) -> Tuple[Any, ...]:
+ # Python 3.8 - protocol: SupportsIndex (added in 3.8)
# datetime.time, and datetime.datetime return Tuple[Any, ...]
# datetime.date doesn't define __reduce_ex__
reduce_ex = cast(Tuple[Any, ...], super().__reduce_ex__(protocol))
@@ -324,17 +327,17 @@ class TM(_DateTimeBase, datetime.time):
if match.group('ms'):
microsecond = int(match.group('ms').rstrip().ljust(6, '0'))
- return super().__new__( # type: ignore[call-arg, no-any-return]
+ return super().__new__(
cls, hour, minute, second, microsecond
)
if isinstance(val, datetime.time):
- return super().__new__( # type: ignore[call-arg, no-any-return]
+ return super().__new__(
cls, val.hour, val.minute, val.second, val.microsecond
)
try:
- return super().__new__( # type: ignore[call-arg, no-any-return]
+ return super().__new__(
cls, *args, **kwargs
)
except Exception as exc:
@@ -925,7 +928,7 @@ class PersonName:
if len(args) and args[0] is None:
return None
- return cast("PersonName", super().__new__(cls))
+ return super().__new__(cls)
def __init__(
self,
| Converting Dicom image to Png
**Describe the issue**
hi, i am trying to convert Dicom image to png but in case of some particular file i am getting this "list out of range error".
**Expected behavior**
dicom image converted to png pne
**Steps To Reproduce**
How to reproduce the issue. Please include:
1. A minimum working code sample
```
from pydicom import dcmread
def read_xray(path, voi_lut = True, fix_monochrome = True):
dicom = dcmread(path, force=True)
# VOI LUT (if available by DICOM device) is used to transform raw DICOM data to "human-friendly" view
if voi_lut:
data = apply_voi_lut(dicom.pixel_array, dicom)
else:
data = dicom.pixel_array
# depending on this value, X-ray may look inverted - fix that:
if fix_monochrome and dicom.PhotometricInterpretation == "MONOCHROME1":
data = np.amax(data) - data
data = data - np.min(data)
data = data / np.max(data)
data = (data * 255).astype(np.uint8)
return data
img = read_xray('/content/a.5545da1153f57ff8425be6f4bc712c090e7e22efff194da525210c84aba2a947.dcm')
plt.figure(figsize = (12,12))
plt.imshow(img)
```
2. The traceback (if one occurred)
```
IndexError Traceback (most recent call last)
<ipython-input-13-6e53d7d16b90> in <module>()
19 return data
20
---> 21 img = read_xray('/content/a.5545da1153f57ff8425be6f4bc712c090e7e22efff194da525210c84aba2a947.dcm')
22 plt.figure(figsize = (12,12))
23 plt.imshow(img)
2 frames
/usr/local/lib/python3.7/dist-packages/pydicom/multival.py in __getitem__(self, index)
93 self, index: Union[slice, int]
94 ) -> Union[MutableSequence[_ItemType], _ItemType]:
---> 95 return self._list[index]
96
97 def insert(self, position: int, val: _T) -> None:
IndexError: list index out of range
```
3. Which of the following packages are available and their versions:
* Numpy : latest as of 29th dec
* Pillow : latest as of 29th dec
* JPEG-LS : latest as of 29th dec
* GDCM : latest as of 29th dec
4. The anonymized DICOM dataset (if possible).
image link : https://drive.google.com/file/d/1j13XTTPCLX-8e7FE--1n5Staxz7GGNWm/view?usp=sharing
**Your environment**
If you're using **pydicom 2 or later**, please use the `pydicom.env_info`
module to gather information about your environment and paste it in the issue:
```bash
$ python -m pydicom.env_info
```
For **pydicom 1.x**, please run the following code snippet and paste the
output.
```python
import platform, sys, pydicom
print(platform.platform(),
"\nPython", sys.version,
"\npydicom", pydicom.__version__)
```
| pydicom/pydicom | diff --git a/pydicom/tests/test_handler_util.py b/pydicom/tests/test_handler_util.py
index e5357017d..89566be44 100644
--- a/pydicom/tests/test_handler_util.py
+++ b/pydicom/tests/test_handler_util.py
@@ -890,6 +890,10 @@ class TestNumpy_ModalityLUT:
out = apply_modality_lut(arr, ds)
assert arr is out
+ ds.ModalityLUTSequence = []
+ out = apply_modality_lut(arr, ds)
+ assert arr is out
+
def test_lutdata_ow(self):
"""Test LUT Data with VR OW."""
ds = dcmread(MOD_16_SEQ)
@@ -1839,6 +1843,10 @@ class TestNumpy_ApplyWindowing:
out = apply_windowing(arr, ds)
assert [-128, -127, -1, 0, 1, 126, 127] == out.tolist()
+ ds.ModalityLUTSequence = []
+ out = apply_windowing(arr, ds)
+ assert [-128, -127, -1, 0, 1, 126, 127] == out.tolist()
+
def test_rescale_empty(self):
"""Test RescaleSlope and RescaleIntercept being empty."""
ds = dcmread(WIN_12_1F)
@@ -2051,6 +2059,11 @@ class TestNumpy_ApplyVOI:
out = apply_voi(arr, ds)
assert [-128, -127, -1, 0, 1, 126, 127] == out.tolist()
+ ds.VOILUTSequence = []
+ out = apply_voi(arr, ds)
+ assert [-128, -127, -1, 0, 1, 126, 127] == out.tolist()
+
+
def test_voi_lutdata_ow(self):
"""Test LUT Data with VR OW."""
ds = Dataset()
@@ -2072,6 +2085,7 @@ class TestNumpy_ApplyVOI:
@pytest.mark.skipif(not HAVE_NP, reason="Numpy is not available")
class TestNumpy_ApplyVOILUT:
+ """Tests for util.apply_voi_lut()"""
def test_unchanged(self):
"""Test input array is unchanged if no VOI LUT"""
ds = Dataset()
@@ -2082,6 +2096,10 @@ class TestNumpy_ApplyVOILUT:
out = apply_voi_lut(arr, ds)
assert [-128, -127, -1, 0, 1, 126, 127] == out.tolist()
+ ds.VOILUTSequence = []
+ out = apply_voi_lut(arr, ds)
+ assert [-128, -127, -1, 0, 1, 126, 127] == out.tolist()
+
def test_only_windowing(self):
"""Test only windowing operation elements present."""
ds = Dataset()
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 7
} | 2.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"numpy>=1.16.0",
"pytest",
"pytest-cov"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pluggy==1.5.0
-e git+https://github.com/pydicom/pydicom.git@9db89e1d8f5e82dc617f9c8cbf303fe23a0632b9#egg=pydicom
pytest==8.3.5
pytest-cov==6.0.0
tomli==2.2.1
| name: pydicom
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- coverage==7.8.0
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- numpy==2.0.2
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- pytest-cov==6.0.0
- tomli==2.2.1
prefix: /opt/conda/envs/pydicom
| [
"pydicom/tests/test_handler_util.py::TestNumpy_ModalityLUT::test_unchanged",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_unchanged",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOILUT::test_unchanged"
] | [
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_unknown_pixel_representation_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_unknown_bits_allocated_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_unsupported_dtypes",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[1-0-False-uint8]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[1-1-False-uint8]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[8-0-False-uint8]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[8-1-False-int8]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[16-0-False-uint16]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[16-1-False-int16]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[32-0-False-uint32]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[32-1-False-int32]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[32-0-True-float32]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_supported_dtypes[64-0-True-float64]",
"pydicom/tests/test_handler_util.py::TestNumpy_PixelDtype::test_byte_swapping",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_reference_1frame_1sample",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_reference_1frame_3sample",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_reference_2frame_1sample",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_reference_2frame_3sample",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_1frame_1sample",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_1frame_3sample_0conf",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_1frame_3sample_1conf",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_2frame_1sample",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_2frame_3sample_0conf",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_2frame_3sample_1conf",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_compressed_syntaxes_0conf",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_compressed_syntaxes_1conf",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_uncompressed_syntaxes",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_invalid_nr_frames_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_invalid_samples_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ReshapePixelArray::test_invalid_planar_conf_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_palette_unavailable_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_first_map_negative",
"pydicom/tests/test_handler_util.py::TestGetNrFrames::test_missing",
"pydicom/tests/test_handler_util.py::TestGetNrFrames::test_existing"
] | [
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_unknown_current_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_unknown_desired_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_current_is_desired[RGB-RGB]",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_current_is_desired[YBR_FULL-YBR_FULL]",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_current_is_desired[YBR_FULL-YBR_FULL_422]",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_current_is_desired[YBR_FULL_422-YBR_FULL_422]",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_current_is_desired[YBR_FULL_422-YBR_FULL]",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_rgb_ybr_rgb_single_frame",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_rgb_ybr_rgb_multi_frame",
"pydicom/tests/test_handler_util.py::TestNumpy_ConvertColourSpace::test_frame_by_frame",
"pydicom/tests/test_handler_util.py::TestNumpy_DtypeCorrectedForEndianness::test_byte_swapping",
"pydicom/tests/test_handler_util.py::TestNumpy_DtypeCorrectedForEndianness::test_no_endian_raises",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape0-1-length0]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape1-1-length1]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape2-1-length2]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape3-1-length3]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape4-1-length4]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape5-1-length5]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape6-1-length6]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape7-1-length7]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape8-1-length8]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape9-8-length9]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape10-8-length10]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape11-8-length11]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape12-8-length12]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape13-8-length13]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape14-8-length14]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape15-16-length15]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape16-16-length16]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape17-16-length17]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape18-16-length18]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape19-16-length19]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape20-32-length20]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape21-32-length21]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape22-32-length22]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape23-32-length23]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape24-32-length24]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape25-1-length25]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape26-1-length26]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape27-1-length27]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape28-1-length28]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape29-1-length29]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape30-1-length30]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape31-1-length31]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape32-1-length32]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape33-1-length33]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape34-8-length34]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape35-8-length35]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape36-8-length36]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape37-8-length37]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape38-8-length38]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape39-8-length39]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape40-16-length40]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape41-16-length41]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape42-16-length42]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape43-32-length43]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape44-32-length44]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape45-32-length45]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape46-1-length46]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape47-1-length47]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape48-1-length48]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape49-1-length49]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape50-1-length50]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape51-1-length51]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape52-1-length52]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape53-1-length53]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape54-1-length54]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape55-8-length55]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape56-8-length56]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape57-8-length57]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape58-16-length58]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape59-16-length59]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape60-16-length60]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape61-32-length61]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape62-32-length62]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_bytes[shape63-32-length63]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape0-1-length0]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape1-1-length1]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape2-1-length2]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape3-1-length3]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape4-1-length4]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape5-1-length5]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape6-1-length6]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape7-1-length7]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape8-1-length8]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape9-8-length9]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape10-8-length10]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape11-8-length11]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape12-8-length12]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape13-8-length13]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape14-8-length14]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape15-16-length15]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape16-16-length16]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape17-16-length17]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape18-16-length18]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape19-16-length19]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape20-32-length20]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape21-32-length21]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape22-32-length22]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape23-32-length23]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape24-32-length24]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape25-1-length25]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape26-1-length26]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape27-1-length27]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape28-1-length28]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape29-1-length29]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape30-1-length30]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape31-1-length31]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape32-1-length32]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape33-1-length33]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape34-8-length34]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape35-8-length35]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape36-8-length36]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape37-8-length37]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape38-8-length38]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape39-8-length39]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape40-16-length40]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape41-16-length41]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape42-16-length42]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape43-32-length43]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape44-32-length44]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape45-32-length45]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape46-1-length46]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape47-1-length47]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape48-1-length48]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape49-1-length49]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape50-1-length50]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape51-1-length51]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape52-1-length52]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape53-1-length53]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape54-1-length54]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape55-8-length55]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape56-8-length56]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape57-8-length57]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape58-16-length58]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape59-16-length59]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape60-16-length60]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape61-32-length61]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape62-32-length62]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_in_pixels[shape63-32-length63]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape0-1-length0]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape1-1-length1]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape2-1-length2]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape3-1-length3]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape4-1-length4]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape5-1-length5]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape6-1-length6]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape7-1-length7]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape8-1-length8]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape9-8-length9]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape10-8-length10]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape11-8-length11]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape12-8-length12]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape13-8-length13]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape14-8-length14]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape15-16-length15]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape16-16-length16]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape17-16-length17]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape18-16-length18]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape19-16-length19]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape20-32-length20]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape21-32-length21]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape22-32-length22]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape23-32-length23]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape24-32-length24]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape25-1-length25]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape26-1-length26]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape27-1-length27]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape28-1-length28]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape29-1-length29]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape30-1-length30]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape31-1-length31]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape32-1-length32]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape33-1-length33]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape34-8-length34]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape35-8-length35]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape36-8-length36]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape37-8-length37]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape38-8-length38]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape39-8-length39]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape40-16-length40]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape41-16-length41]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape42-16-length42]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape43-32-length43]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape44-32-length44]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape45-32-length45]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape46-1-length46]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape47-1-length47]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape48-1-length48]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape49-1-length49]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape50-1-length50]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape51-1-length51]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape52-1-length52]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape53-1-length53]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape54-1-length54]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape55-8-length55]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape56-8-length56]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape57-8-length57]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape58-16-length58]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape59-16-length59]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape60-16-length60]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape61-32-length61]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape62-32-length62]",
"pydicom/tests/test_handler_util.py::TestGetExpectedLength::test_length_ybr_422[shape63-32-length63]",
"pydicom/tests/test_handler_util.py::TestNumpy_ModalityLUT::test_slope_intercept",
"pydicom/tests/test_handler_util.py::TestNumpy_ModalityLUT::test_lut_sequence",
"pydicom/tests/test_handler_util.py::TestNumpy_ModalityLUT::test_lut_sequence_zero_entries",
"pydicom/tests/test_handler_util.py::TestNumpy_ModalityLUT::test_lutdata_ow",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_neither_ds_nor_palette_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_palette_unknown_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_supplemental_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_invalid_bit_depth_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_invalid_lut_bit_depth_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_unequal_lut_length_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_no_palette_color",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_uint08_16",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_uint08_16_2frame",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_uint16_16_segmented_litle",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_uint16_16_segmented_big",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_16_allocated_8_entries",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_alpha",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_well_known_palette",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_first_map_positive",
"pydicom/tests/test_handler_util.py::TestNumpy_PaletteColor::test_unchanged",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_discrete",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_linear",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_indirect_08",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_indirect_16",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_palettes_spring",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_palettes_summer",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_palettes_fall",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_palettes_winter",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_first_linear_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_first_indirect_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ExpandSegmentedLUT::test_unknown_opcode_raises",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_single_view",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_multi_view",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_uint8",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_uint16",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_uint32",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_int8",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_int16",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_int32",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_multi_frame",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_rescale",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_modality_lut",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_bad_photometric_interp",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_bad_parameters",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_window_bad_index",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_unchanged",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyWindowing::test_rescale_empty",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_single_view",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_multi_view",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_multi_frame",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_zero_entries",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_uint8",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_uint16",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_int8",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_int16",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_bad_depth",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_uint16_array_float",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOI::test_voi_lutdata_ow",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOILUT::test_only_windowing",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOILUT::test_only_voi",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOILUT::test_voi_windowing",
"pydicom/tests/test_handler_util.py::TestNumpy_ApplyVOILUT::test_voi_windowing_empty",
"pydicom/tests/test_handler_util.py::TestGetJ2KParameters::test_precision",
"pydicom/tests/test_handler_util.py::TestGetJ2KParameters::test_not_j2k",
"pydicom/tests/test_handler_util.py::TestGetJ2KParameters::test_no_siz",
"pydicom/tests/test_handler_util.py::TestGetJ2KParameters::test_short_bytestream",
"pydicom/tests/test_handler_util.py::TestGetNrFrames::test_none"
] | [] | MIT License | 11,899 | 2,925 | [
"pydicom/dataset.py",
"pydicom/encoders/base.py",
"pydicom/filebase.py",
"pydicom/fileset.py",
"pydicom/filewriter.py",
"pydicom/pixel_data_handlers/util.py",
"pydicom/valuerep.py"
] |
mkdocs__mkdocs-2733 | 91923f507aa54db94ba34559c96532bf274eca0a | 2021-12-29 16:04:29 | f725e225adf9b6cfab45042e44637f137f56d1bd | ofek: @oprypin Hello! Can you please take a look at this? | diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py
index 9f615ca9..7c0db7c5 100644
--- a/mkdocs/config/config_options.py
+++ b/mkdocs/config/config_options.py
@@ -354,12 +354,8 @@ class RepoURL(URL):
edit_uri = ''
# ensure a well-formed edit_uri
- if edit_uri:
- if not edit_uri.startswith(('?', '#')) \
- and not config['repo_url'].endswith('/'):
- config['repo_url'] += '/'
- if not edit_uri.endswith('/'):
- edit_uri += '/'
+ if edit_uri and not edit_uri.endswith('/'):
+ edit_uri += '/'
config['edit_uri'] = edit_uri
diff --git a/mkdocs/structure/pages.py b/mkdocs/structure/pages.py
index 951d3a88..db50ddb2 100644
--- a/mkdocs/structure/pages.py
+++ b/mkdocs/structure/pages.py
@@ -104,6 +104,9 @@ class Page:
def _set_edit_url(self, repo_url, edit_uri):
if repo_url and edit_uri:
src_path = self.file.src_path.replace('\\', '/')
+ # Ensure urljoin behavior is correct
+ if not edit_uri.startswith(('?', '#')) and not repo_url.endswith('/'):
+ repo_url += '/'
self.edit_url = urljoin(repo_url, edit_uri + src_path)
else:
self.edit_url = None
| Defining `edit_uri` as anything other than an empty string modifies the `repo_url`
### Description
Defining `edit_uri` as anything other than an empty string adds a forward slash to the `repo_url` link for the button on the top right
### Expected behavior
The `repo_url` link for the button on the top right is what is defined in config
### Versions
- Python: `3.8.1`
- MkDocs: `1.2.3`
### System information
- Operating system: Windows 10
- Browser: Chrome | mkdocs/mkdocs | diff --git a/mkdocs/tests/config/config_options_tests.py b/mkdocs/tests/config/config_options_tests.py
index db01ba78..e344aec3 100644
--- a/mkdocs/tests/config/config_options_tests.py
+++ b/mkdocs/tests/config/config_options_tests.py
@@ -323,6 +323,7 @@ class RepoURLTest(unittest.TestCase):
config = {'repo_url': "https://github.com/mkdocs/mkdocs"}
option.post_validation(config, 'repo_url')
self.assertEqual(config['edit_uri'], 'edit/master/docs/')
+ self.assertEqual(config['repo_url'], "https://github.com/mkdocs/mkdocs")
def test_edit_uri_bitbucket(self):
@@ -330,6 +331,7 @@ class RepoURLTest(unittest.TestCase):
config = {'repo_url': "https://bitbucket.org/gutworth/six/"}
option.post_validation(config, 'repo_url')
self.assertEqual(config['edit_uri'], 'src/default/docs/')
+ self.assertEqual(config['repo_url'], "https://bitbucket.org/gutworth/six/")
def test_edit_uri_gitlab(self):
@@ -344,6 +346,7 @@ class RepoURLTest(unittest.TestCase):
config = {'repo_url': "https://launchpad.net/python-tuskarclient"}
option.post_validation(config, 'repo_url')
self.assertEqual(config.get('edit_uri'), '')
+ self.assertEqual(config['repo_url'], "https://launchpad.net/python-tuskarclient")
def test_repo_name_custom_and_empty_edit_uri(self):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 2
} | 1.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements/project.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | babel==2.17.0
click==8.1.8
coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
ghp-import==2.1.0
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
Markdown==3.7
MarkupSafe==3.0.2
mdx-gh-links==0.4
mergedeep==1.3.4
-e git+https://github.com/mkdocs/mkdocs.git@91923f507aa54db94ba34559c96532bf274eca0a#egg=mkdocs
mkdocs-get-deps==0.2.0
mkdocs-redirects==1.2.2
packaging==24.2
pathspec==0.12.1
platformdirs==4.3.7
pluggy==1.5.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
PyYAML==6.0.2
pyyaml_env_tag==0.1
six==1.17.0
tomli==2.2.1
typing_extensions==4.13.0
watchdog==6.0.0
zipp==3.21.0
| name: mkdocs
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- babel==2.17.0
- click==8.1.8
- coverage==7.8.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- ghp-import==2.1.0
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markdown==3.7
- markupsafe==3.0.2
- mdx-gh-links==0.4
- mergedeep==1.3.4
- mkdocs-get-deps==0.2.0
- mkdocs-redirects==1.2.2
- packaging==24.2
- pathspec==0.12.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- pyyaml==6.0.2
- pyyaml-env-tag==0.1
- six==1.17.0
- tomli==2.2.1
- typing-extensions==4.13.0
- watchdog==6.0.0
- zipp==3.21.0
prefix: /opt/conda/envs/mkdocs
| [
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_edit_uri_github"
] | [
"mkdocs/tests/config/config_options_tests.py::ListOfPathsTest::test_paths_localized_to_config"
] | [
"mkdocs/tests/config/config_options_tests.py::OptionallyRequiredTest::test_default",
"mkdocs/tests/config/config_options_tests.py::OptionallyRequiredTest::test_empty",
"mkdocs/tests/config/config_options_tests.py::OptionallyRequiredTest::test_replace_default",
"mkdocs/tests/config/config_options_tests.py::OptionallyRequiredTest::test_required",
"mkdocs/tests/config/config_options_tests.py::OptionallyRequiredTest::test_required_no_default",
"mkdocs/tests/config/config_options_tests.py::TypeTest::test_length",
"mkdocs/tests/config/config_options_tests.py::TypeTest::test_multiple_types",
"mkdocs/tests/config/config_options_tests.py::TypeTest::test_single_type",
"mkdocs/tests/config/config_options_tests.py::ChoiceTest::test_invalid_choice",
"mkdocs/tests/config/config_options_tests.py::ChoiceTest::test_invalid_choices",
"mkdocs/tests/config/config_options_tests.py::ChoiceTest::test_valid_choice",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_message",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_move",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_move_complex",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_move_existing",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_move_invalid",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_simple",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_with_invalid_type",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_with_type",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_deprecated_option_with_type_undefined",
"mkdocs/tests/config/config_options_tests.py::DeprecatedTest::test_removed_option",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_default_address",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_IPv6_address",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_address_format",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_address_missing_port",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_address_port",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_address_range",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_address_type",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_invalid_leading_zeros",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_named_address",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_unsupported_IPv6_address",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_unsupported_address",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_valid_IPv6_address",
"mkdocs/tests/config/config_options_tests.py::IpAddressTest::test_valid_address",
"mkdocs/tests/config/config_options_tests.py::URLTest::test_invalid_type",
"mkdocs/tests/config/config_options_tests.py::URLTest::test_invalid_url",
"mkdocs/tests/config/config_options_tests.py::URLTest::test_valid_url",
"mkdocs/tests/config/config_options_tests.py::URLTest::test_valid_url_is_dir",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_edit_uri_bitbucket",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_edit_uri_custom",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_edit_uri_gitlab",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_repo_name_bitbucket",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_repo_name_custom",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_repo_name_custom_and_empty_edit_uri",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_repo_name_github",
"mkdocs/tests/config/config_options_tests.py::RepoURLTest::test_repo_name_gitlab",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_config_dir_prepended",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_dir_bad_encoding_fails",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_dir_filesystemencoding",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_dir_is_config_dir_fails",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_dir_unicode",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_file",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_incorrect_type_attribute_error",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_incorrect_type_type_error",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_missing_dir",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_missing_dir_but_required",
"mkdocs/tests/config/config_options_tests.py::DirTest::test_valid_dir",
"mkdocs/tests/config/config_options_tests.py::ListOfPathsTest::test_empty_list",
"mkdocs/tests/config/config_options_tests.py::ListOfPathsTest::test_file",
"mkdocs/tests/config/config_options_tests.py::ListOfPathsTest::test_missing_path",
"mkdocs/tests/config/config_options_tests.py::ListOfPathsTest::test_non_list",
"mkdocs/tests/config/config_options_tests.py::ListOfPathsTest::test_valid_path",
"mkdocs/tests/config/config_options_tests.py::SiteDirTest::test_common_prefix",
"mkdocs/tests/config/config_options_tests.py::SiteDirTest::test_doc_dir_in_site_dir",
"mkdocs/tests/config/config_options_tests.py::SiteDirTest::test_site_dir_in_docs_dir",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_post_validation_inexisting_custom_dir",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_post_validation_locale",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_post_validation_locale_invalid_type",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_post_validation_locale_none",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_post_validation_none_theme_name_and_missing_custom_dir",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_as_complex_config",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_as_simple_config",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_as_string",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_config_missing_name",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_default",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_invalid_type",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_theme_name_is_none",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_uninstalled_theme_as_config",
"mkdocs/tests/config/config_options_tests.py::ThemeTest::test_uninstalled_theme_as_string",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_children_config_int",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_children_config_none",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_children_empty_dict",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_children_oversized_dict",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_item_int",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_item_none",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_nested_list",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_type_dict",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_invalid_type_int",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_normal_nav",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_old_format",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_provided_dict",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_provided_empty",
"mkdocs/tests/config/config_options_tests.py::NavTest::test_warns_for_dict",
"mkdocs/tests/config/config_options_tests.py::PrivateTest::test_defined",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_builtins",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_builtins_config",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_configkey",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_dict_of_dicts",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_duplicates",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_invalid_config_item",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_invalid_config_option",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_invalid_dict_item",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_list_dicts",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_mixed_list",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_none",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_not_list",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_simple_list",
"mkdocs/tests/config/config_options_tests.py::MarkdownExtensionsTest::test_unknown_extension"
] | [] | BSD 2-Clause "Simplified" License | 11,900 | 359 | [
"mkdocs/config/config_options.py",
"mkdocs/structure/pages.py"
] |
asottile__pyupgrade-584 | 234e07160f1d6a171b1100de7046a92d4866e0ba | 2021-12-30 16:36:19 | 234e07160f1d6a171b1100de7046a92d4866e0ba | diff --git a/pyupgrade/_plugins/six_calls.py b/pyupgrade/_plugins/six_calls.py
index 90c4ee3..ac58fd5 100644
--- a/pyupgrade/_plugins/six_calls.py
+++ b/pyupgrade/_plugins/six_calls.py
@@ -172,13 +172,21 @@ def visit_Call(
('reraise',),
)
):
- if len(node.args) == 2 and not has_starargs(node):
+ if (
+ len(node.args) == 2 and
+ not node.keywords and
+ not has_starargs(node)
+ ):
func = functools.partial(
find_and_replace_call,
template=RERAISE_2_TMPL,
)
yield ast_to_offset(node), func
- elif len(node.args) == 3 and not has_starargs(node):
+ elif (
+ len(node.args) == 3 and
+ not node.keywords and
+ not has_starargs(node)
+ ):
func = functools.partial(
find_and_replace_call,
template=RERAISE_3_TMPL,
@@ -186,6 +194,7 @@ def visit_Call(
yield ast_to_offset(node), func
elif (
len(node.args) == 1 and
+ not node.keywords and
isinstance(node.args[0], ast.Starred) and
isinstance(node.args[0].value, ast.Call) and
is_name_attr(
| Incorrect rewrite of six.reraise with traceback as keyword argument
Reduced from real code in Launchpad:
```
$ cat t.py
import sys
from six import reraise
exc_info = sys.exc_info()
reraise(exc_info[0], exc_info[1], tb=exc_info[2])
$ pyupgrade --py3-plus t.py
Rewriting t.py
$ cat t.py
import sys
from six import reraise
exc_info = sys.exc_info()
raise exc_info[1].with_traceback(None)
```
pyupgrade has missed the keyword argument here; this should instead be rewritten to `raise exc_info[1].with_traceback(exc_info[2])`.
(In fact in Python 3 this can end up just being a plain `raise`: the original code was more complicated and had a second possible exception being raised and handled between `sys.exc_info()` and `reraise()`, which in Python 2 would have caused plain `raise` to raise the second exception, but the exception scoping changes in Python 3 mean that a plain `raise` will do the right thing. I don't expect pyupgrade to do that sort of analysis, though.) | asottile/pyupgrade | diff --git a/tests/features/six_test.py b/tests/features/six_test.py
index e1f6cd8..4ea3f5b 100644
--- a/tests/features/six_test.py
+++ b/tests/features/six_test.py
@@ -24,6 +24,7 @@ from pyupgrade._main import _fix_plugins
'class C(six.with_metaclass(Meta, B), D): pass',
# cannot determine args to rewrite them
'six.reraise(*err)', 'six.u(*a)',
+ 'six.reraise(a, b, tb=c)',
'class C(six.with_metaclass(*a)): pass',
'@six.add_metaclass(*a)\n'
'class C: pass\n',
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 2.30 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
packaging==24.2
pluggy==1.5.0
pytest==8.3.5
-e git+https://github.com/asottile/pyupgrade.git@234e07160f1d6a171b1100de7046a92d4866e0ba#egg=pyupgrade
tokenize_rt==6.1.0
tomli==2.2.1
| name: pyupgrade
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- tokenize-rt==6.1.0
- tomli==2.2.1
prefix: /opt/conda/envs/pyupgrade
| [
"tests/features/six_test.py::test_fix_six_noop[six.reraise(a,"
] | [] | [
"tests/features/six_test.py::test_fix_six_noop[x",
"tests/features/six_test.py::test_fix_six_noop[from",
"tests/features/six_test.py::test_fix_six_noop[a[0]()]",
"tests/features/six_test.py::test_fix_six_noop[@mydec\\nclass",
"tests/features/six_test.py::test_fix_six_noop[print(six.raise_from(exc,",
"tests/features/six_test.py::test_fix_six_noop[class",
"tests/features/six_test.py::test_fix_six_noop[six.reraise(*err)]",
"tests/features/six_test.py::test_fix_six_noop[six.u(*a)]",
"tests/features/six_test.py::test_fix_six_noop[@six.add_metaclass(*a)\\nclass",
"tests/features/six_test.py::test_fix_six_noop[next()]",
"tests/features/six_test.py::test_fix_six_noop[traceback.format_exc(*sys.exc_info())]",
"tests/features/six_test.py::test_fix_six_noop[wrong",
"tests/features/six_test.py::test_fix_six_noop[ignore",
"tests/features/six_test.py::test_fix_six[six.byte2int(b\"f\")-b\"f\"[0]]",
"tests/features/six_test.py::test_fix_six[six.get_unbound_function(meth)\\n-meth\\n]",
"tests/features/six_test.py::test_fix_six[from",
"tests/features/six_test.py::test_fix_six[six.indexbytes(bs,",
"tests/features/six_test.py::test_fix_six[six.assertCountEqual(\\n",
"tests/features/six_test.py::test_fix_six[weird",
"tests/features/six_test.py::test_fix_six[six.raise_from(exc,",
"tests/features/six_test.py::test_fix_six[six",
"tests/features/six_test.py::test_fix_six[six.reraise(tp,",
"tests/features/six_test.py::test_fix_six[six.reraise(*sys.exc_info())\\n-raise\\n]",
"tests/features/six_test.py::test_fix_six[six.reraise(\\n",
"tests/features/six_test.py::test_fix_six[class",
"tests/features/six_test.py::test_fix_six[elide",
"tests/features/six_test.py::test_fix_six[with_metaclass",
"tests/features/six_test.py::test_fix_six[basic",
"tests/features/six_test.py::test_fix_six[add_metaclass,",
"tests/features/six_test.py::test_fix_six[six.itervalues]",
"tests/features/six_test.py::test_fix_six[six.itervalues",
"tests/features/six_test.py::test_fix_six[needs",
"tests/features/six_test.py::test_fix_six[no",
"tests/features/six_test.py::test_fix_six[multiline",
"tests/features/six_test.py::test_fix_six_py38_plus[needs",
"tests/features/six_test.py::test_fix_base_classes[import",
"tests/features/six_test.py::test_fix_base_classes[from",
"tests/features/six_test.py::test_fix_base_classes[class"
] | [] | MIT License | 11,911 | 332 | [
"pyupgrade/_plugins/six_calls.py"
] |
|
pydicom__pydicom-1562 | e1a035a88fe36d466579b2f3940bde5b8b1bc84d | 2021-12-30 20:52:59 | 0fa18d2a2179c92efc22200ed6b3689e66cecf92 | codecov[bot]: # [Codecov](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) Report
> Merging [#1562](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) (c05ddb7) into [master](https://codecov.io/gh/pydicom/pydicom/commit/1447dd5f91768cf28d29ee28f0b978678805c97b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) (1447dd5) will **decrease** coverage by `0.00%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom)
```diff
@@ Coverage Diff @@
## master #1562 +/- ##
==========================================
- Coverage 97.42% 97.42% -0.01%
==========================================
Files 66 66
Lines 10185 10183 -2
==========================================
- Hits 9923 9921 -2
Misses 262 262
```
| [Impacted Files](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom) | Coverage Δ | |
|---|---|---|
| [pydicom/datadict.py](https://codecov.io/gh/pydicom/pydicom/pull/1562/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom#diff-cHlkaWNvbS9kYXRhZGljdC5weQ==) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom). Last update [1447dd5...c05ddb7](https://codecov.io/gh/pydicom/pydicom/pull/1562?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pydicom).
scaramallion: Yeah, I'll change it now
pep8speaks: Hello @scaramallion! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:
* In the file [`pydicom/datadict.py`](https://github.com/pydicom/pydicom/blob/3a5f1ddeeb6b92538c4106c6446858ecea974f06/pydicom/datadict.py):
> [Line 427:5](https://github.com/pydicom/pydicom/blob/3a5f1ddeeb6b92538c4106c6446858ecea974f06/pydicom/datadict.py#L427): [E722](https://duckduckgo.com/?q=pep8%20E722) do not use bare 'except'
| diff --git a/pydicom/datadict.py b/pydicom/datadict.py
index 99201be13..0457ed91a 100644
--- a/pydicom/datadict.py
+++ b/pydicom/datadict.py
@@ -249,9 +249,10 @@ def get_entry(tag: TagType) -> Tuple[str, str, str, str, str]:
Parameters
----------
- tag : int
- The tag for the element whose entry is to be retrieved. Only entries
- in the official DICOM dictionary will be checked, not entries in the
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose entry is to be retrieved, in any of the
+ forms accepted by :func:`~pydicom.tag.Tag`. Only entries in the
+ official DICOM dictionary will be checked, not entries in the
private dictionary.
Returns
@@ -292,8 +293,9 @@ def dictionary_is_retired(tag: TagType) -> bool:
Parameters
----------
- tag : int
- The tag for the element whose retirement status is being checked.
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose retirement status is being checked, in
+ any of the forms accepted by :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -306,9 +308,7 @@ def dictionary_is_retired(tag: TagType) -> bool:
KeyError
If the tag is not present in the DICOM data dictionary.
"""
- if 'retired' in get_entry(tag)[3].lower():
- return True
- return False
+ return 'retired' in get_entry(tag)[3].lower()
def dictionary_VR(tag: TagType) -> str:
@@ -318,9 +318,9 @@ def dictionary_VR(tag: TagType) -> str:
Parameters
----------
- tag : int
+ tag : int or str or Tuple[int, int]
The tag for the element whose value representation (VR) is being
- retrieved.
+ retrieved, in any of the forms accepted by :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -342,9 +342,9 @@ def dictionary_VM(tag: TagType) -> str:
Parameters
----------
- tag : int
+ tag : int or str or Tuple[int, int]
The tag for the element whose value multiplicity (VM) is being
- retrieved.
+ retrieved, in any of the forms accepted by :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -366,8 +366,9 @@ def dictionary_description(tag: TagType) -> str:
Parameters
----------
- tag : int
- The tag for the element whose description is being retrieved.
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose description is being retrieved, in any
+ of the forms accepted by :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -389,8 +390,9 @@ def dictionary_keyword(tag: TagType) -> str:
Parameters
----------
- tag : int
- The tag for the element whose keyword is being retrieved.
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose keyword is being retrieved, in any of
+ the forms accepted by :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -410,8 +412,9 @@ def dictionary_has_tag(tag: TagType) -> bool:
Parameters
----------
- tag : int
- The tag to check.
+ tag : int or str or Tuple[int, int]
+ The tag to check, in any of the forms accepted by
+ :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -419,7 +422,10 @@ def dictionary_has_tag(tag: TagType) -> bool:
``True`` if the tag corresponds to an element present in the official
DICOM data dictionary, ``False`` otherwise.
"""
- return (tag in DicomDictionary)
+ try:
+ return Tag(tag) in DicomDictionary
+ except Exception:
+ return False
def keyword_for_tag(tag: TagType) -> str:
@@ -427,8 +433,9 @@ def keyword_for_tag(tag: TagType) -> str:
Parameters
----------
- tag : int
- The tag for the element whose keyword is being retrieved.
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose keyword is being retrieved, in any of
+ the forms accepted by :func:`~pydicom.tag.Tag`.
Returns
-------
@@ -514,9 +521,10 @@ def get_private_entry(
Parameters
----------
- tag : int
- The tag for the element whose entry is to be retrieved. Only entries
- in the private dictionary will be checked.
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose entry is to be retrieved, in any of the
+ forms accepted by :func:`~pydicom.tag.Tag`. Only entries in the
+ private dictionary will be checked.
private_creator : str
The name of the private creator.
@@ -574,9 +582,9 @@ def private_dictionary_VR(tag: TagType, private_creator: str) -> str:
Parameters
----------
- tag : int
+ tag : int or str or Tuple[int, int]
The tag for the element whose value representation (VR) is being
- retrieved.
+ retrieved, in any of the forms accepted by :func:`~pydicom.tag.Tag`.
private_creator : str
The name of the private creator.
@@ -598,9 +606,9 @@ def private_dictionary_VM(tag: TagType, private_creator: str) -> str:
Parameters
----------
- tag : int
+ tag : int or str or Tuple[int, int]
The tag for the element whose value multiplicity (VM) is being
- retrieved.
+ retrieved, in any of the forms accepted by :func:`~pydicom.tag.Tag`.
private_creator : str
The name of the private creator.
@@ -622,8 +630,9 @@ def private_dictionary_description(tag: TagType, private_creator: str) -> str:
Parameters
----------
- tag : int
- The tag for the element whose description is being retrieved.
+ tag : int or str or Tuple[int, int]
+ The tag for the element whose description is being retrieved, in any
+ of the forms accepted by :func:`~pydicom.tag.Tag`.
private_creator : str
The name of the private createor.
| Revise the type annotation for pydicom.datadict.dictionary_has_tag()
**Describe the bug**
The documentation of [`pydicom.datadict.dictionary_has_tag()`](https://pydicom.github.io/pydicom/dev/reference/generated/pydicom.datadict.dictionary_has_tag.html#pydicom.datadict.dictionary_has_tag) suggests that a query using keywords (instead of a tag integer) would work:
```python
pydicom.datadict.dictionary_has_tag(tag: Union[int, str, Tuple[int, int], pydicom.tag.BaseTag]) -> bool
```
However, the function only accepts integer arguments.
```python
from pydicom.datadict import dictionary_has_tag, keyword_dict
dictionary_has_tag("PixelData")
# Returns False
dictionary_has_tag(keyword_dict["PixelData"])
# Returns True
```
(The problem may apply to other functions as well...)
**Expected behavior**
Following the docs, `dictionary_has_tag("PixelData")` should return True.
It would be nice, if the flexible conversion of tags from names or hex-tuples (as the type annotation suggests) would also be possible for this function.
**Your environment**
```text
module | version
------ | -------
platform | macOS-10.14.6-x86_64-i386-64bit
Python | 3.9.0 (v3.9.0:9cf6752276, Oct 5 2020, 11:29:23) [Clang 6.0 (clang-600.0.57)]
pydicom | 2.2.2
gdcm | _module not found_
jpeg_ls | _module not found_
numpy | 1.20.1
PIL | 8.0.1
pylibjpeg | _module not found_
openjpeg | _module not found_
libjpeg | _module not found_
```
| pydicom/pydicom | diff --git a/pydicom/tests/test_dictionary.py b/pydicom/tests/test_dictionary.py
index 30af2de7e..77b6bb36b 100644
--- a/pydicom/tests/test_dictionary.py
+++ b/pydicom/tests/test_dictionary.py
@@ -30,6 +30,8 @@ class TestDict:
"""Test dictionary_has_tag"""
assert dictionary_has_tag(0x00100010)
assert not dictionary_has_tag(0x11110010)
+ assert dictionary_has_tag("PatientName")
+ assert not dictionary_has_tag("PatientMane")
def test_repeater_has_tag(self):
"""Test repeater_has_tag"""
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 2.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"numpy>=1.16.0",
"pytest",
"pytest-cov"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | coverage==7.8.0
exceptiongroup==1.2.2
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pluggy==1.5.0
-e git+https://github.com/pydicom/pydicom.git@e1a035a88fe36d466579b2f3940bde5b8b1bc84d#egg=pydicom
pytest==8.3.5
pytest-cov==6.0.0
tomli==2.2.1
| name: pydicom
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- coverage==7.8.0
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- numpy==2.0.2
- packaging==24.2
- pluggy==1.5.0
- pytest==8.3.5
- pytest-cov==6.0.0
- tomli==2.2.1
prefix: /opt/conda/envs/pydicom
| [
"pydicom/tests/test_dictionary.py::TestDict::test_dict_has_tag"
] | [] | [
"pydicom/tests/test_dictionary.py::TestDict::test_tag_not_found",
"pydicom/tests/test_dictionary.py::TestDict::test_repeaters",
"pydicom/tests/test_dictionary.py::TestDict::test_repeater_has_tag",
"pydicom/tests/test_dictionary.py::TestDict::test_repeater_has_keyword",
"pydicom/tests/test_dictionary.py::TestDict::test_get_private_entry",
"pydicom/tests/test_dictionary.py::TestDict::test_add_entry",
"pydicom/tests/test_dictionary.py::TestDict::test_add_entry_raises_for_private_tag",
"pydicom/tests/test_dictionary.py::TestDict::test_add_entries",
"pydicom/tests/test_dictionary.py::TestDict::test_add_entries_raises_for_private_tags",
"pydicom/tests/test_dictionary.py::TestDict::test_add_private_entry",
"pydicom/tests/test_dictionary.py::TestDict::test_add_private_entry_raises_for_non_private_tag",
"pydicom/tests/test_dictionary.py::TestDict::test_add_private_entries",
"pydicom/tests/test_dictionary.py::TestDict::test_add_private_entries_raises_for_non_private_tags",
"pydicom/tests/test_dictionary.py::TestDict::test_dictionary_VM",
"pydicom/tests/test_dictionary.py::TestDict::test_private_dict_VR",
"pydicom/tests/test_dictionary.py::TestDict::test_private_dict_VM"
] | [] | MIT License | 11,913 | 1,590 | [
"pydicom/datadict.py"
] |
bridgecrewio__checkov-2167 | 808f3e95d3c6de42e70de5a3789bfef386077573 | 2022-01-01 22:36:16 | 13e67f317a1cc7e514cc3eaf19ed81a01c72bf00 | diff --git a/checkov/common/bridgecrew/platform_integration.py b/checkov/common/bridgecrew/platform_integration.py
index 66e6f4508..c036a1942 100644
--- a/checkov/common/bridgecrew/platform_integration.py
+++ b/checkov/common/bridgecrew/platform_integration.py
@@ -7,7 +7,7 @@ from concurrent import futures
from json import JSONDecodeError
from os import path
from time import sleep
-from typing import Optional
+from typing import Optional, Dict
import boto3
import dpath.util
@@ -346,17 +346,17 @@ class BcPlatformIntegration(object):
self.get_checkov_mapping_metadata()
return self.guidelines
- def get_id_mapping(self) -> dict:
+ def get_id_mapping(self) -> Dict[str, str]:
if not self.bc_id_mapping:
self.get_checkov_mapping_metadata()
return self.bc_id_mapping
- def get_ckv_to_bc_id_mapping(self) -> dict:
+ def get_ckv_to_bc_id_mapping(self) -> Dict[str, str]:
if not self.ckv_to_bc_id_mapping:
self.get_checkov_mapping_metadata()
return self.ckv_to_bc_id_mapping
- def get_checkov_mapping_metadata(self) -> Optional[dict]:
+ def get_checkov_mapping_metadata(self) -> None:
if self.bc_skip_mapping is True:
logging.debug("Skipped mapping API call")
self.ckv_to_bc_id_mapping = {}
diff --git a/checkov/terraform/context_parsers/base_parser.py b/checkov/terraform/context_parsers/base_parser.py
index e7f2af088..bfa36283a 100644
--- a/checkov/terraform/context_parsers/base_parser.py
+++ b/checkov/terraform/context_parsers/base_parser.py
@@ -22,6 +22,7 @@ class BaseContextParser(ABC):
tf_file_path: Optional[Path] = None
file_lines: List[Tuple[int, str]] = []
filtered_lines: List[Tuple[int, str]] = []
+ filtered_line_numbers: List[int] = []
context: Dict[str, Any] = {}
def __init__(self, definition_type: str) -> None:
@@ -60,18 +61,19 @@ class BaseContextParser(ABC):
def _filter_file_lines(self) -> List[Tuple[int, str]]:
parsed_file_lines = [(ind, self._trim_whitespaces_linebreaks(line)) for (ind, line) in self.file_lines]
self.filtered_lines = [(ind, line) for (ind, line) in parsed_file_lines if line]
+ self.filtered_line_numbers = [ind for ind, _ in self.filtered_lines]
return self.filtered_lines
def _read_file_lines(self) -> List[Tuple[int, str]]:
- with (open(self.tf_file, "r")) as file:
+ with open(self.tf_file, "r") as file:
file.seek(0)
- file_lines = [(ind + 1, line) for (ind, line) in list(enumerate(file.readlines()))]
+ file_lines = [(ind + 1, line) for ind, line in enumerate(file.readlines())]
return file_lines
@staticmethod
def is_optional_comment_line(line: str) -> bool:
- line_without_whitespace = "".join(line.split())
- return 'checkov:skip=' in line_without_whitespace or 'bridgecrew:skip=' in line_without_whitespace
+ line_without_whitespace = line.replace(" ", "")
+ return "checkov:skip=" in line_without_whitespace or "bridgecrew:skip=" in line_without_whitespace
def _collect_skip_comments(self, definition_blocks: List[Dict[str, Any]]) -> Dict[str, Any]:
"""
@@ -82,10 +84,6 @@ class BaseContextParser(ABC):
bc_id_mapping = bc_integration.get_id_mapping()
ckv_to_bc_id_mapping = bc_integration.get_ckv_to_bc_id_mapping()
parsed_file_lines = self.filtered_lines
- optional_comment_lines = [
- line for line in parsed_file_lines
- if self.is_optional_comment_line(line[1])
- ]
comments = [
(
line_num,
@@ -94,7 +92,8 @@ class BaseContextParser(ABC):
"suppress_comment": match.group(3)[1:] if match.group(3) else "No comment provided",
},
)
- for (line_num, x) in optional_comment_lines
+ for (line_num, x) in parsed_file_lines
+ if self.is_optional_comment_line(x)
for match in [re.search(COMMENT_REGEX, x)]
if match
]
@@ -125,26 +124,26 @@ class BaseContextParser(ABC):
return self.context
def _compute_definition_end_line(self, start_line_num: int) -> int:
- """ Given the code block's start line, compute the block's end line
+ """Given the code block's start line, compute the block's end line
:param start_line_num: code block's first line number (the signature line)
:return: the code block's last line number
"""
parsed_file_lines = self.filtered_lines
- start_line_idx = [line_num for (line_num, _) in parsed_file_lines].index(start_line_num)
+ start_line_idx = self.filtered_line_numbers.index(start_line_num)
i = 0
end_line_num = 0
for (line_num, line) in islice(parsed_file_lines, start_line_idx, None):
if OPEN_CURLY in line:
- i = i + 1
+ i += line.count(OPEN_CURLY)
if CLOSE_CURLY in line:
- i = i - 1
+ i -= line.count(CLOSE_CURLY)
if i == 0:
end_line_num = line_num
break
return end_line_num
def run(
- self, tf_file: str, definition_blocks: List[Dict[str, Any]], collect_skip_comments: bool = True
+ self, tf_file: str, definition_blocks: List[Dict[str, Any]], collect_skip_comments: bool = True
) -> Dict[str, Any]:
# TF files for loaded modules have this formation: <file>[<referrer>#<index>]
# Chop off everything after the file name for our purposes here
@@ -165,10 +164,10 @@ class BaseContextParser(ABC):
return self.definition_type
@staticmethod
- def _clean_line(line: str):
- res = line.replace('"', ' ')
+ def _clean_line(line: str) -> str:
+ res = line.replace('"', " ")
if '"{' in res:
- res = res.split('{')[0]
+ res = res.split("{")[0]
return res
def enrich_definition_block(self, definition_blocks: List[Dict[str, Any]]) -> Dict[str, Any]:
@@ -193,7 +192,7 @@ class BaseContextParser(ABC):
dpath.new(self.context, entity_context_path + ["start_line"], start_line)
dpath.new(self.context, entity_context_path + ["end_line"], end_line)
dpath.new(
- self.context, entity_context_path + ["code_lines"], self.file_lines[start_line - 1: end_line]
+ self.context, entity_context_path + ["code_lines"], self.file_lines[start_line - 1 : end_line]
)
potential_block_start_lines.remove((line_num, line))
break
| Unable to skip CKV_AWS_130
**Describe the bug**
I have a two-tier network infrastructure template written in terraform which basically sets up a VPC network. In there, I have a public subnet block which has parameter `map_public_ip_on_launch` set to **true**. Even after adding `#checkov:skip=CKV_AWS_130:Public IP required in public subnet` within the resource check still fails. I do have other check skips but just the `CKV_AWS_130` is failing
**To Reproduce**
Steps to reproduce the behavior:
1. Create an aws subnet resource block
2. Add the skip statement
3. Test it and see the error
**Expected behavior**
It should be shown as skipped check
**Screenshots**
<img width="723" alt="Screenshot 2021-04-29 at 9 08 22 PM" src="https://user-images.githubusercontent.com/34170345/116578775-60f29600-a92f-11eb-83cb-aedc04daf72c.png">
<img width="610" alt="Screenshot 2021-04-29 at 9 08 34 PM" src="https://user-images.githubusercontent.com/34170345/116578819-69e36780-a92f-11eb-8868-213a2e183b45.png">
**Desktop (please complete the following information):**
- OS: MacOS Big Sur
- Checkov Version: 2.0.84
**Additional context**
Add any other context about the problem here (e.g. code snippets).
| bridgecrewio/checkov | diff --git a/tests/terraform/context_parsers/test_base_parser.py b/tests/terraform/context_parsers/test_base_parser.py
index bc3f56d5d..00b715cfc 100644
--- a/tests/terraform/context_parsers/test_base_parser.py
+++ b/tests/terraform/context_parsers/test_base_parser.py
@@ -4,28 +4,41 @@ import unittest
from checkov.terraform.context_parsers.registry import parser_registry
from tests.terraform.context_parsers.mock_context_parser import MockContextParser
-mock_tf_file = os.path.dirname(os.path.realpath(__file__)) + '/mock_tf_files/mock.tf'
-mock_definition = (mock_tf_file, {'mock': [
- {
- 'mock_type': {
- 'mock_name': {
- 'value': [
- 'mock_value']}}}
-]})
+mock_tf_file = os.path.dirname(os.path.realpath(__file__)) + "/mock_tf_files/mock.tf"
+mock_definition = (mock_tf_file, {"mock": [{"mock_type": {"mock_name": {"value": ["mock_value"]}}}]})
class TestBaseParser(unittest.TestCase):
-
def test_enrich_definition_block(self):
mock_parser = MockContextParser()
parser_registry.register(mock_parser)
definition_context = parser_registry.enrich_definitions_context(mock_definition)
- skipped_checks = definition_context[mock_tf_file]['mock']['mock_type']['mock_name'].get('skipped_checks')
+ skipped_checks = definition_context[mock_tf_file]["mock"]["mock_type"]["mock_name"].get("skipped_checks")
self.assertIsNotNone(skipped_checks)
self.assertEqual(len(skipped_checks), 3)
# Ensure checkov IDs are mapped to BC IDs
- self.assertEqual(skipped_checks[2]['id'], 'CKV_AWS_15')
+ self.assertEqual(skipped_checks[2]["id"], "CKV_AWS_15")
+
+ def test__compute_definition_end_line_with_multi_curly_brackets(self):
+ # given
+ mock_parser = MockContextParser()
+ mock_parser.filtered_lines = [
+ (1, '#data "aws_iam_policy_document" "null" {}'),
+ (3, 'resource "aws_subnet" "pub_sub" {'),
+ (4, "tags = merge({"),
+ (5, 'Name = "${var.network_name}-pub-sub-${element(var.azs, count.index)}"'),
+ (6, 'Tier = "public"'),
+ (7, '}, var.tags, var.add_eks_tags ? { "kubernetes.io/role/elb" : "1" } : {})'),
+ (8, "}"),
+ ]
+ mock_parser.filtered_line_numbers = [1, 3, 4, 5, 6, 7, 8]
+
+ # when
+ end_line_num = mock_parser._compute_definition_end_line(3)
+
+ # then
+ self.assertEqual(8, end_line_num)
-if __name__ == '__main__':
+if __name__ == "__main__":
unittest.main()
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 2
} | 2.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip3 install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio"
],
"pre_install": null,
"python": "3.7",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aiodns==3.2.0
aiohttp==3.8.6
aiomultiprocess==0.9.0
aiosignal==1.3.1
argcomplete==3.1.2
async-timeout==4.0.3
asynctest==0.13.0
attrs @ file:///croot/attrs_1668696182826/work
bc-python-hcl2==0.3.51
beautifulsoup4==4.13.3
boolean.py==4.0
boto3==1.33.13
botocore==1.33.13
cached-property==1.5.2
cachetools==5.5.2
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
-e git+https://github.com/bridgecrewio/checkov.git@808f3e95d3c6de42e70de5a3789bfef386077573#egg=checkov
click==8.1.8
click-option-group==0.5.7
cloudsplaining==0.6.3
colorama==0.4.6
ConfigArgParse==1.7
coverage==7.2.7
cyclonedx-python-lib==4.2.3
deep-merge==0.0.4
defusedxml==0.7.1
detect-secrets==1.5.0
docker==6.1.3
dockerfile-parse==2.0.1
dpath==1.5.0
execnet==2.0.2
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
frozenlist==1.3.3
gitdb==4.0.12
GitPython==3.1.44
idna==3.10
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1648562407465/work
importlib-resources==5.12.0
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
Jinja2==3.1.6
jmespath==1.0.1
junit-xml==1.9
lark==1.1.9
license-expression==30.2.0
Markdown==3.4.4
MarkupSafe==2.1.5
multidict==6.0.5
networkx==2.6.3
packageurl-python==0.15.6
packaging @ file:///croot/packaging_1671697413597/work
pluggy @ file:///tmp/build/80754af9/pluggy_1648042572264/work
policy-sentry==0.12.15
policyuniverse==1.5.1.20231109
py @ file:///opt/conda/conda-bld/py_1644396412707/work
py-serializable==0.11.1
pycares==4.3.0
pycparser==2.21
pytest==7.1.2
pytest-asyncio==0.21.2
pytest-cov==4.1.0
pytest-mock==3.11.1
pytest-xdist==3.5.0
python-dateutil==2.9.0.post0
PyYAML==6.0.1
requests==2.31.0
s3transfer==0.8.2
schema==0.7.7
semantic-version==2.10.0
six==1.17.0
smmap==5.0.2
sortedcontainers==2.4.0
soupsieve==2.4.1
tabulate==0.9.0
termcolor==2.3.0
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
tqdm==4.67.1
typing_extensions @ file:///croot/typing_extensions_1669924550328/work
update-checker==0.18.0
urllib3==1.26.20
websocket-client==1.6.1
yarl==1.9.4
zipp @ file:///croot/zipp_1672387121353/work
| name: checkov
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- attrs=22.1.0=py37h06a4308_0
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- flit-core=3.6.0=pyhd3eb1b0_0
- importlib-metadata=4.11.3=py37h06a4308_0
- importlib_metadata=4.11.3=hd3eb1b0_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- packaging=22.0=py37h06a4308_0
- pip=22.3.1=py37h06a4308_0
- pluggy=1.0.0=py37h06a4308_1
- py=1.11.0=pyhd3eb1b0_0
- pytest=7.1.2=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py37h06a4308_0
- typing_extensions=4.4.0=py37h06a4308_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zipp=3.11.0=py37h06a4308_0
- zlib=1.2.13=h5eee18b_1
- pip:
- aiodns==3.2.0
- aiohttp==3.8.6
- aiomultiprocess==0.9.0
- aiosignal==1.3.1
- argcomplete==3.1.2
- async-timeout==4.0.3
- asynctest==0.13.0
- bc-python-hcl2==0.3.51
- beautifulsoup4==4.13.3
- boolean-py==4.0
- boto3==1.33.13
- botocore==1.33.13
- cached-property==1.5.2
- cachetools==5.5.2
- cffi==1.15.1
- charset-normalizer==3.4.1
- click==8.1.8
- click-option-group==0.5.7
- cloudsplaining==0.6.3
- colorama==0.4.6
- configargparse==1.7
- coverage==7.2.7
- cyclonedx-python-lib==4.2.3
- deep-merge==0.0.4
- defusedxml==0.7.1
- detect-secrets==1.5.0
- docker==6.1.3
- dockerfile-parse==2.0.1
- dpath==1.5.0
- execnet==2.0.2
- frozenlist==1.3.3
- gitdb==4.0.12
- gitpython==3.1.44
- idna==3.10
- importlib-resources==5.12.0
- jinja2==3.1.6
- jmespath==1.0.1
- junit-xml==1.9
- lark==1.1.9
- license-expression==30.2.0
- markdown==3.4.4
- markupsafe==2.1.5
- multidict==6.0.5
- networkx==2.6.3
- packageurl-python==0.15.6
- policy-sentry==0.12.15
- policyuniverse==1.5.1.20231109
- py-serializable==0.11.1
- pycares==4.3.0
- pycparser==2.21
- pytest-asyncio==0.21.2
- pytest-cov==4.1.0
- pytest-mock==3.11.1
- pytest-xdist==3.5.0
- python-dateutil==2.9.0.post0
- pyyaml==6.0.1
- requests==2.31.0
- s3transfer==0.8.2
- schema==0.7.7
- semantic-version==2.10.0
- six==1.17.0
- smmap==5.0.2
- sortedcontainers==2.4.0
- soupsieve==2.4.1
- tabulate==0.9.0
- termcolor==2.3.0
- tqdm==4.67.1
- update-checker==0.18.0
- urllib3==1.26.20
- websocket-client==1.6.1
- yarl==1.9.4
prefix: /opt/conda/envs/checkov
| [
"tests/terraform/context_parsers/test_base_parser.py::TestBaseParser::test__compute_definition_end_line_with_multi_curly_brackets"
] | [] | [
"tests/terraform/context_parsers/test_base_parser.py::TestBaseParser::test_enrich_definition_block"
] | [] | Apache License 2.0 | 11,920 | 1,692 | [
"checkov/common/bridgecrew/platform_integration.py",
"checkov/terraform/context_parsers/base_parser.py"
] |
|
geopandas__geopandas-2289 | 831108dcb369517e311cd0ee3821db1f2fb7122d | 2022-01-05 02:24:28 | be647ab7e54880278cba374cc77075afd33b25a5 | diff --git a/geopandas/_compat.py b/geopandas/_compat.py
index e5ac045d..000db2a6 100644
--- a/geopandas/_compat.py
+++ b/geopandas/_compat.py
@@ -19,6 +19,7 @@ PANDAS_GE_10 = str(pd.__version__) >= LooseVersion("1.0.0")
PANDAS_GE_11 = str(pd.__version__) >= LooseVersion("1.1.0")
PANDAS_GE_115 = str(pd.__version__) >= LooseVersion("1.1.5")
PANDAS_GE_12 = str(pd.__version__) >= LooseVersion("1.2.0")
+PANDAS_GE_14 = str(pd.__version__) >= LooseVersion("1.4.0")
# -----------------------------------------------------------------------------
| TST: test_value_counts breaking against pandas latest
Recent CI builds on 38-dev.yaml are all failing due to geopandas/tests/test_pandas_methods.py::test_value_counts, which fails with the output:
```
______________________________ test_value_counts _______________________________
3536
[gw0] linux -- Python 3.8.12 /usr/share/miniconda3/envs/test/bin/python
3537
3538
def test_value_counts():
3539
# each object is considered unique
3540
s = GeoSeries([Point(0, 0), Point(1, 1), Point(0, 0)])
3541
res = s.value_counts()
3542
with compat.ignore_shapely2_warnings():
3543
exp = pd.Series([2, 1], index=[Point(0, 0), Point(1, 1)])
3544
> assert_series_equal(res, exp)
3545
3546
geopandas/tests/test_pandas_methods.py:454:
3547
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
3548
3549
left = Index([POINT (0 0), POINT (1 1)], dtype='geometry')
3550
right = Index([POINT (0 0), POINT (1 1)], dtype='object'), obj = 'Series.index'
3551
3552
def _check_types(left, right, obj="Index") -> None:
3553
if not exact:
3554
return
3555
3556
assert_class_equal(left, right, exact=exact, obj=obj)
3557
> assert_attr_equal("inferred_type", left, right, obj=obj)
3558
E AssertionError: Series.index are different
3559
E
3560
E Attribute "inferred_type" are different
3561
E [left]: unknown-array
3562
E [right]: mixed
```
It looks like this pandas change (https://github.com/pandas-dev/pandas/pull/43930) to allow storing extension arrays in the index (that is, not just casting everything to `object`) is responsible. | geopandas/geopandas | diff --git a/geopandas/tests/test_pandas_methods.py b/geopandas/tests/test_pandas_methods.py
index 709ad3da..ed080af4 100644
--- a/geopandas/tests/test_pandas_methods.py
+++ b/geopandas/tests/test_pandas_methods.py
@@ -445,33 +445,44 @@ def test_unique():
assert_array_equal(s.unique(), exp)
+def pd14_compat_index(index):
+ if compat.PANDAS_GE_14:
+ return from_shapely(index)
+ else:
+ return index
+
+
def test_value_counts():
# each object is considered unique
s = GeoSeries([Point(0, 0), Point(1, 1), Point(0, 0)])
res = s.value_counts()
with compat.ignore_shapely2_warnings():
- exp = pd.Series([2, 1], index=[Point(0, 0), Point(1, 1)])
+ exp = pd.Series([2, 1], index=pd14_compat_index([Point(0, 0), Point(1, 1)]))
assert_series_equal(res, exp)
# Check crs doesn't make a difference - note it is not kept in output index anyway
s2 = GeoSeries([Point(0, 0), Point(1, 1), Point(0, 0)], crs="EPSG:4326")
res2 = s2.value_counts()
assert_series_equal(res2, exp)
+ if compat.PANDAS_GE_14:
+ # TODO should/ can we fix CRS being lost
+ assert s2.value_counts().index.array.crs is None
# check mixed geometry
s3 = GeoSeries([Point(0, 0), LineString([[1, 1], [2, 2]]), Point(0, 0)])
res3 = s3.value_counts()
+ index = pd14_compat_index([Point(0, 0), LineString([[1, 1], [2, 2]])])
with compat.ignore_shapely2_warnings():
- exp3 = pd.Series([2, 1], index=[Point(0, 0), LineString([[1, 1], [2, 2]])])
+ exp3 = pd.Series([2, 1], index=index)
assert_series_equal(res3, exp3)
# check None is handled
s4 = GeoSeries([Point(0, 0), None, Point(0, 0)])
res4 = s4.value_counts(dropna=True)
with compat.ignore_shapely2_warnings():
- exp4_dropna = pd.Series([2], index=[Point(0, 0)])
+ exp4_dropna = pd.Series([2], index=pd14_compat_index([Point(0, 0)]))
assert_series_equal(res4, exp4_dropna)
with compat.ignore_shapely2_warnings():
- exp4_keepna = pd.Series([2, 1], index=[Point(0, 0), None])
+ exp4_keepna = pd.Series([2, 1], index=pd14_compat_index([Point(0, 0), None]))
res4_keepna = s4.value_counts(dropna=False)
assert_series_equal(res4_keepna, exp4_keepna)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 2
},
"num_modified_files": 1
} | 0.10 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": true,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | affine @ file:///home/conda/feedstock_root/build_artifacts/affine_1733762038348/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1741918516150/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1738740337718/work
branca @ file:///home/conda/feedstock_root/build_artifacts/branca_1734433375112/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work
Cartopy @ file:///home/conda/feedstock_root/build_artifacts/cartopy_1634173743840/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1739515848642/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1636046055389/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1735929714516/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1734858813237/work
click-plugins @ file:///home/conda/feedstock_root/build_artifacts/click-plugins_1733731077999/work
cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1733749956636/work
contextily @ file:///home/conda/feedstock_root/build_artifacts/contextily_1734596167382/work
contourpy @ file:///home/conda/feedstock_root/build_artifacts/contourpy_1652954513473/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1733332471406/work
exceptiongroup==1.2.2
Fiona==1.8.20
folium @ file:///home/conda/feedstock_root/build_artifacts/folium_1740766619747/work
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1651017733844/work
GDAL==3.3.2
geographiclib @ file:///home/conda/feedstock_root/build_artifacts/geographiclib_1734342349249/work
-e git+https://github.com/geopandas/geopandas.git@831108dcb369517e311cd0ee3821db1f2fb7122d#egg=geopandas
geoplot @ file:///home/conda/feedstock_root/build_artifacts/geoplot_1736335046714/work
geopy @ file:///home/conda/feedstock_root/build_artifacts/geopy_1734341931581/work
h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1738578511449/work
hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1737618293087/work
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1737618333194/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
importlib_resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1736252299705/work
iniconfig==2.1.0
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1741263328855/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1733736026804/work
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1648854392795/work
libpysal @ file:///home/conda/feedstock_root/build_artifacts/libpysal_1668782270408/work
mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1733731066416/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737556467/work
matplotlib @ file:///croot/matplotlib-suite_1713336378214/work
mercantile @ file:///home/conda/feedstock_root/build_artifacts/mercantile_1734075348980/work
munch @ file:///home/conda/feedstock_root/build_artifacts/munch_1734441240299/work
munkres==1.1.4
networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1697694336581/work
numpy @ file:///croot/numpy_and_numpy_base_1708638617955/work/dist/numpy-1.26.4-cp39-cp39-linux_x86_64.whl#sha256=b69ac3eb7538c5a224df429dc49031914fb977825ee007f2c77a13f7aa6cd769
olefile @ file:///home/conda/feedstock_root/build_artifacts/olefile_1734769783178/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas==1.4.2
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1630696601414/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_platformdirs_1742485085/work
pluggy==1.5.0
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
pyepsg @ file:///home/conda/feedstock_root/build_artifacts/pyepsg_1736256455081/work
pygeos @ file:///home/conda/feedstock_root/build_artifacts/pygeos_1629724761140/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1633060559349/work
PyQt5==5.12.3
PyQt5_sip==4.19.18
PyQtChart==5.12
PyQtWebEngine==5.12.1
pyshp @ file:///home/conda/feedstock_root/build_artifacts/pyshp_1733821528126/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
pytest==8.3.5
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1742920838005/work
rasterio @ file:///home/conda/feedstock_root/build_artifacts/rasterio_1634058359641/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
rtree @ file:///home/conda/feedstock_root/build_artifacts/rtree_1741378561624/work
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1652976687386/work
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1653073865807/work
seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-split_1733730015268/work
Shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1635194355088/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
snuggs @ file:///home/conda/feedstock_root/build_artifacts/snuggs_1733818638588/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1693929250441/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1741878222898/work
tomli==2.2.1
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1648827245914/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_typing_extensions_1743201626/work
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1649111919389/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1734859416348/work
xyzservices @ file:///home/conda/feedstock_root/build_artifacts/xyzservices_1737234886776/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work
zstandard @ file:///croot/zstandard_1677013143055/work
| name: geopandas
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- affine=2.4.0=pyhd8ed1ab_1
- alsa-lib=1.2.3.2=h166bdaf_0
- attrs=25.3.0=pyh71513ae_0
- beautifulsoup4=4.13.3=pyha770c72_0
- blas=1.1=openblas
- boost-cpp=1.74.0=h312852a_4
- branca=0.8.1=pyhd8ed1ab_0
- brotli=1.0.9=h166bdaf_7
- brotli-bin=1.0.9=h166bdaf_7
- brotli-python=1.0.9=py39h5a03fae_7
- bzip2=1.0.8=h7f98852_4
- c-ares=1.18.1=h7f98852_0
- ca-certificates=2025.2.25=h06a4308_0
- cairo=1.16.0=h6cf1ce9_1008
- cartopy=0.20.1=py39ha48bd0d_1
- certifi=2025.1.31=pyhd8ed1ab_0
- cffi=1.15.0=py39h4bc2ebd_0
- cfitsio=3.470=hb418390_7
- charset-normalizer=3.4.1=pyhd8ed1ab_0
- click=8.1.8=pyh707e725_0
- click-plugins=1.1.1=pyhd8ed1ab_1
- cligj=0.7.2=pyhd8ed1ab_2
- contextily=1.6.2=pyhd8ed1ab_1
- contourpy=1.0.2=py39hf939315_2
- curl=7.79.1=h2574ce0_1
- cycler=0.12.1=pyhd8ed1ab_1
- dbus=1.13.6=h48d8840_2
- expat=2.4.8=h27087fc_0
- fiona=1.8.20=py39h427c1bf_2
- folium=0.19.5=pyhd8ed1ab_0
- font-ttf-dejavu-sans-mono=2.37=hab24e00_0
- font-ttf-inconsolata=3.000=h77eed37_0
- font-ttf-source-code-pro=2.038=h77eed37_0
- font-ttf-ubuntu=0.83=h77eed37_3
- fontconfig=2.14.0=h8e229c2_0
- fonts-conda-ecosystem=1=0
- fonts-conda-forge=1=0
- fonttools=4.33.3=py39hb9d737c_0
- freetype=2.10.4=h0708190_1
- freexl=1.0.6=h7f98852_0
- gdal=3.3.2=py39h218ed2d_4
- geographiclib=2.0=pyhd8ed1ab_1
- geoplot=0.5.1=pyhd8ed1ab_1
- geopy=2.4.1=pyhd8ed1ab_2
- geos=3.9.1=h9c3ff4c_2
- geotiff=1.7.0=hcfb7246_3
- gettext=0.19.8.1=h73d1719_1008
- giflib=5.2.1=h36c2ea0_2
- glib=2.68.4=h9c3ff4c_1
- glib-tools=2.68.4=h9c3ff4c_1
- gst-plugins-base=1.18.5=hf529b03_0
- gstreamer=1.18.5=h76c114f_0
- h2=4.2.0=pyhd8ed1ab_0
- hdf4=4.2.15=h10796ff_3
- hdf5=1.12.1=nompi_h2750804_100
- hpack=4.1.0=pyhd8ed1ab_0
- hyperframe=6.1.0=pyhd8ed1ab_0
- icu=68.2=h9c3ff4c_0
- idna=3.10=pyhd8ed1ab_1
- importlib_resources=6.5.2=pyhd8ed1ab_0
- jbig=2.1=h7f98852_2003
- jinja2=3.1.6=pyhd8ed1ab_0
- joblib=1.4.2=pyhd8ed1ab_1
- jpeg=9e=h166bdaf_1
- json-c=0.15=h98cffda_0
- kealib=1.4.14=h87e4c3c_3
- keyutils=1.6.1=h166bdaf_0
- kiwisolver=1.4.2=py39hf939315_1
- krb5=1.19.3=h3790be6_0
- lcms2=2.12=hddcbb42_0
- ld_impl_linux-64=2.40=h12ee557_0
- lerc=2.2.1=h9c3ff4c_0
- libblas=3.9.0=16_linux64_openblas
- libbrotlicommon=1.0.9=h166bdaf_7
- libbrotlidec=1.0.9=h166bdaf_7
- libbrotlienc=1.0.9=h166bdaf_7
- libcblas=3.9.0=16_linux64_openblas
- libclang=11.1.0=default_ha53f305_1
- libcurl=7.79.1=h2574ce0_1
- libdap4=3.20.6=hd7c4107_2
- libdeflate=1.7=h7f98852_5
- libedit=3.1.20191231=he28a2e2_2
- libev=4.33=h516909a_1
- libevent=2.1.10=h9b69904_4
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgdal=3.3.2=h9c9eb65_4
- libgfortran=3.0.0=1
- libgfortran-ng=13.2.0=h69a702a_0
- libgfortran5=13.2.0=ha4646dd_0
- libglib=2.68.4=h174f98d_1
- libgomp=11.2.0=h1234567_1
- libiconv=1.17=h166bdaf_0
- libkml=1.3.0=h238a007_1014
- liblapack=3.9.0=16_linux64_openblas
- libllvm11=11.1.0=hf817b99_2
- libnetcdf=4.8.1=nompi_hb3fd0d9_101
- libnghttp2=1.43.0=h812cca2_1
- libnsl=2.0.0=h7f98852_0
- libogg=1.3.4=h7f98852_1
- libopenblas=0.3.21=h043d6bf_0
- libopus=1.3.1=h7f98852_1
- libpng=1.6.37=h21135ba_2
- libpq=13.3=hd57d9b9_0
- libpysal=4.7.0=pyhd8ed1ab_0
- librttopo=1.1.0=h1185371_6
- libspatialindex=1.9.3=h9c3ff4c_4
- libspatialite=5.0.1=h8796b1e_9
- libssh2=1.10.0=ha56f1ee_2
- libstdcxx-ng=11.2.0=h1234567_1
- libtiff=4.3.0=hf544144_1
- libuuid=2.32.1=h7f98852_1000
- libvorbis=1.3.7=h9c3ff4c_0
- libwebp-base=1.2.2=h7f98852_1
- libxcb=1.13=h7f98852_1004
- libxkbcommon=1.0.3=he3ba5ed_0
- libxml2=2.9.12=h72842e0_0
- libzip=1.8.0=h4de3113_1
- lz4-c=1.9.3=h9c3ff4c_1
- mapclassify=2.8.1=pyhd8ed1ab_1
- markupsafe=2.1.1=py39hb9d737c_1
- matplotlib=3.8.4=py39hf3d152e_2
- matplotlib-base=3.8.4=py39h1128e8f_0
- mercantile=1.2.1=pyhd8ed1ab_1
- munch=4.0.0=pyhd8ed1ab_1
- munkres=1.1.4=pyh9f0ad1d_0
- mysql-common=8.0.25=ha770c72_2
- mysql-libs=8.0.25=hfa10184_2
- ncurses=6.4=h6a678d5_0
- networkx=3.2=pyhd8ed1ab_0
- nspr=4.32=h9c3ff4c_1
- nss=3.69=hb5efdd6_1
- numpy=1.26.4=py39heeff2f4_0
- numpy-base=1.26.4=py39h8a23956_0
- olefile=0.47=pyhd8ed1ab_1
- openblas=0.3.4=ha44fe06_0
- openjpeg=2.4.0=hb52868f_1
- openssl=1.1.1o=h166bdaf_0
- packaging=24.2=pyhd8ed1ab_2
- pandas=1.4.2=py39h1832856_1
- pcre=8.45=h9c3ff4c_0
- pillow=8.3.2=py39ha612740_0
- pip=25.0=py39h06a4308_0
- pixman=0.40.0=h36c2ea0_0
- platformdirs=4.3.7=pyh29332c3_0
- poppler=21.09.0=ha39eefc_3
- poppler-data=0.4.12=hd8ed1ab_0
- postgresql=13.3=h2510834_0
- proj=8.1.1=h277dcde_2
- pthread-stubs=0.4=h36c2ea0_1001
- pycparser=2.22=pyh29332c3_1
- pyepsg=0.4.0=pyhd8ed1ab_1
- pygeos=0.10.2=py39ha61afbd_0
- pyparsing=3.0.9=pyhd8ed1ab_0
- pyproj=3.2.1=py39ha81a305_2
- pyqt=5.12.3=py39hf3d152e_8
- pyqt-impl=5.12.3=py39hde8b62d_8
- pyqt5-sip=4.19.18=py39he80948d_8
- pyqtchart=5.12=py39h0fcd23e_8
- pyqtwebengine=5.12.1=py39h0fcd23e_8
- pyshp=2.3.1=pyhd8ed1ab_1
- pysocks=1.7.1=pyha55dd90_7
- python=3.9.7=hb7a2778_3_cpython
- python-dateutil=2.9.0.post0=pyhff2d567_1
- python_abi=3.9=5_cp39
- pytz=2025.2=pyhd8ed1ab_0
- qt=5.12.9=hda022c4_4
- rasterio=1.2.10=py39hb37810a_0
- readline=8.2=h5eee18b_0
- requests=2.32.3=pyhd8ed1ab_1
- rtree=1.4.0=pyh11ca60a_1
- scikit-learn=1.1.1=py39h4037b75_0
- scipy=1.8.1=py39he49c0e8_0
- seaborn-base=0.13.2=pyhd8ed1ab_3
- setuptools=75.8.0=py39h06a4308_0
- shapely=1.8.0=py39ha61afbd_0
- six=1.17.0=pyhd8ed1ab_0
- snuggs=1.4.7=pyhd8ed1ab_2
- soupsieve=2.5=pyhd8ed1ab_1
- sqlite=3.45.3=h5eee18b_0
- threadpoolctl=3.6.0=pyhecae5ae_0
- tiledb=2.3.4=he87e0bf_0
- tk=8.6.14=h39e8969_0
- tornado=6.1=py39hb9d737c_3
- typing-extensions=4.13.0=h9fa5a19_1
- typing_extensions=4.13.0=pyh29332c3_1
- tzcode=2022a=h166bdaf_0
- tzdata=2025a=h04d1e81_0
- unicodedata2=14.0.0=py39hb9d737c_1
- urllib3=2.3.0=pyhd8ed1ab_0
- wheel=0.45.1=py39h06a4308_0
- xerces-c=3.2.3=h9d8b166_3
- xorg-kbproto=1.0.7=h7f98852_1002
- xorg-libice=1.0.10=h7f98852_0
- xorg-libsm=1.2.3=hd9c2040_1000
- xorg-libx11=1.7.2=h7f98852_0
- xorg-libxau=1.0.9=h7f98852_0
- xorg-libxdmcp=1.1.3=h7f98852_0
- xorg-libxext=1.3.4=h7f98852_1
- xorg-libxrender=0.9.10=h7f98852_1003
- xorg-renderproto=0.11.1=h7f98852_1002
- xorg-xextproto=7.3.0=h7f98852_1002
- xorg-xproto=7.0.31=h7f98852_1007
- xyzservices=2025.1.0=pyhd8ed1ab_0
- xz=5.6.4=h5eee18b_1
- zipp=3.21.0=pyhd8ed1ab_1
- zlib=1.2.13=h5eee18b_1
- zstandard=0.19.0=py39h5eee18b_0
- zstd=1.5.0=ha95c52a_0
- pip:
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- pluggy==1.5.0
- pytest==8.3.5
- tomli==2.2.1
prefix: /opt/conda/envs/geopandas
| [
"geopandas/tests/test_pandas_methods.py::test_value_counts"
] | [] | [
"geopandas/tests/test_pandas_methods.py::test_repr",
"geopandas/tests/test_pandas_methods.py::test_repr_boxed_display_precision",
"geopandas/tests/test_pandas_methods.py::test_repr_all_missing",
"geopandas/tests/test_pandas_methods.py::test_repr_empty",
"geopandas/tests/test_pandas_methods.py::test_indexing",
"geopandas/tests/test_pandas_methods.py::test_reindex",
"geopandas/tests/test_pandas_methods.py::test_take",
"geopandas/tests/test_pandas_methods.py::test_take_empty",
"geopandas/tests/test_pandas_methods.py::test_assignment",
"geopandas/tests/test_pandas_methods.py::test_assign",
"geopandas/tests/test_pandas_methods.py::test_astype",
"geopandas/tests/test_pandas_methods.py::test_astype_invalid_geodataframe",
"geopandas/tests/test_pandas_methods.py::test_convert_dtypes",
"geopandas/tests/test_pandas_methods.py::test_to_csv",
"geopandas/tests/test_pandas_methods.py::test_numerical_operations",
"geopandas/tests/test_pandas_methods.py::test_where",
"geopandas/tests/test_pandas_methods.py::test_select_dtypes",
"geopandas/tests/test_pandas_methods.py::test_equals",
"geopandas/tests/test_pandas_methods.py::test_fillna",
"geopandas/tests/test_pandas_methods.py::test_dropna",
"geopandas/tests/test_pandas_methods.py::test_isna[None]",
"geopandas/tests/test_pandas_methods.py::test_isna[nan]",
"geopandas/tests/test_pandas_methods.py::test_any_all",
"geopandas/tests/test_pandas_methods.py::test_unique",
"geopandas/tests/test_pandas_methods.py::test_groupby",
"geopandas/tests/test_pandas_methods.py::test_groupby_groups",
"geopandas/tests/test_pandas_methods.py::test_apply",
"geopandas/tests/test_pandas_methods.py::test_apply_loc_len1",
"geopandas/tests/test_pandas_methods.py::test_apply_convert_dtypes_keyword",
"geopandas/tests/test_pandas_methods.py::test_apply_no_geometry_result[None]",
"geopandas/tests/test_pandas_methods.py::test_apply_no_geometry_result[EPSG:4326]",
"geopandas/tests/test_pandas_methods.py::test_apply_preserves_geom_col_name",
"geopandas/tests/test_pandas_methods.py::test_preserve_attrs",
"geopandas/tests/test_pandas_methods.py::test_preserve_flags"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,930 | 192 | [
"geopandas/_compat.py"
] |
|
dr-prodigy__python-holidays-586 | f1ec50378e8fe537b6803cc0156bd064bb258a1d | 2022-01-05 09:59:26 | 940b6b807588c0cc835b1966a229175b00eb3f75 | diff --git a/holidays/countries/angola.py b/holidays/countries/angola.py
index c911b8ec..7bbf7b9e 100644
--- a/holidays/countries/angola.py
+++ b/holidays/countries/angola.py
@@ -17,8 +17,8 @@ from dateutil.easter import easter
from dateutil.relativedelta import relativedelta as rd
-from holidays.constants import TUE, THU, SUN
-from holidays.constants import FEB, MAR, APR, MAY, SEP, NOV, DEC
+from holidays.constants import MON, TUE, THU, SUN
+from holidays.constants import JAN, FEB, MAR, APR, MAY, SEP, NOV, DEC
from holidays.holiday_base import HolidayBase
@@ -30,7 +30,7 @@ class Angola(HolidayBase):
# https://www.timeanddate.com/holidays/angola/
HolidayBase.__init__(self, **kwargs)
- def _populate(self, year):
+ def _populate(self, year: int) -> None:
# Observed since 1975
# TODO do more research on history of Angolan holidays
@@ -41,7 +41,12 @@ class Angola(HolidayBase):
self[date(year, SEP, 17)] = "Dia do Herói Nacional"
if year > 1974:
- self[date(year, 1, 1)] = "Ano novo"
+ self[date(year, JAN, 1)] = "Ano novo"
+ # Since 2018, if the following year's New Year's Day falls on a
+ # Tuesday, the 31st of the current year is also a holiday.
+ if year >= 2018:
+ if self.observed and date(year, DEC, 31).weekday() == MON:
+ self[date(year, DEC, 31)] = "Ano novo (Day off)"
e = easter(year)
good_friday = e - rd(days=2)
@@ -74,7 +79,7 @@ class Angola(HolidayBase):
if k.weekday() == SUN:
pass
if self.observed and year > 2017:
- if k.weekday() == TUE:
+ if k.weekday() == TUE and k != date(year, JAN, 1):
self[k - rd(days=1)] = v + " (Day off)"
elif k.weekday() == THU:
self[k + rd(days=1)] = v + " (Day off)"
diff --git a/holidays/countries/azerbaijan.py b/holidays/countries/azerbaijan.py
index b3526873..a4f792fe 100644
--- a/holidays/countries/azerbaijan.py
+++ b/holidays/countries/azerbaijan.py
@@ -13,7 +13,8 @@
from datetime import date
from dateutil.relativedelta import relativedelta as rd
-from holidays.constants import JAN, MAR, MAY, JUN, NOV, DEC, SAT, SUN
+from holidays.constants import SAT, SUN
+from holidays.constants import JAN, MAR, MAY, JUN, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase
from holidays.utils import _islamic_to_gre
@@ -32,10 +33,12 @@ class Azerbaijan(HolidayBase):
def _add_observed(self, holiday: date) -> None:
if self.observed and holiday.weekday() in (SAT, SUN):
next_monday = holiday + rd(days=7 - holiday.weekday())
- if not self.get(next_monday, None):
+ if next_monday.year == holiday.year and not self.get(
+ next_monday, None
+ ):
self[next_monday] = self[holiday] + OBSERVED_SUFFIX
- def _populate(self, year):
+ def _populate(self, year: int) -> None:
# 1st of Jan
self[date(year, JAN, 1)] = "New Year's Day"
@@ -85,17 +88,30 @@ class Azerbaijan(HolidayBase):
date(year, DEC, 31)
] = "International Solidarity Day of Azerbaijanis"
self._add_observed(date(year, DEC, 31))
+ # If the prior year's International Solidarity Day of Azerbaijanis
+ # falls on a Saturday or Monday, the 1st Monday of the current year is
+ # also a holiday.
+ if self.observed and date(year - 1, DEC, 31).weekday() == SUN:
+ self[date(year, JAN, 1)] = (
+ "International Solidarity Day of Azerbaijanis"
+ + OBSERVED_SUFFIX
+ )
+ elif self.observed and date(year - 1, DEC, 31).weekday() == SAT:
+ self[date(year, JAN, 2)] = (
+ "International Solidarity Day of Azerbaijanis"
+ + OBSERVED_SUFFIX
+ )
# Ramadan
# Date of observance is announced yearly, This is an estimate.
- hol_date = _islamic_to_gre(year, 10, 1)[0]
+ hol_date = _islamic_to_gre(year, OCT, 1)[0]
self[hol_date] = "Ramadan"
self[hol_date + rd(days=1)] = "Ramadan"
self._add_observed(hol_date + rd(days=1))
# Festival of the Sacrifice
# Date of observance is announced yearly, This is an estimate.
- hol_date = _islamic_to_gre(year, 12, 10)[0]
+ hol_date = _islamic_to_gre(year, DEC, 10)[0]
self[hol_date] = "Festival of the Sacrifice"
self[hol_date + rd(days=1)] = "Festival of the Sacrifice"
self._add_observed(hol_date + rd(days=1))
diff --git a/holidays/countries/botswana.py b/holidays/countries/botswana.py
index 7c3dc93a..8edeeb81 100644
--- a/holidays/countries/botswana.py
+++ b/holidays/countries/botswana.py
@@ -103,8 +103,9 @@ class Botswana(HolidayBase):
if " (Observed)" not in i:
self[k + rd(days=1)] = i.lstrip() + " (Observed)"
- # Once off ad-hoc holidays
- self[date(2019, JUL, 2)] = "Public Holiday"
+ # Once off ad-hoc holiday.
+ if year == 2019:
+ self[date(year, JUL, 2)] = "Public Holiday"
class BW(Botswana):
diff --git a/holidays/countries/canada.py b/holidays/countries/canada.py
index 0b01c365..66360849 100644
--- a/holidays/countries/canada.py
+++ b/holidays/countries/canada.py
@@ -63,15 +63,8 @@ class Canada(HolidayBase):
self[date(year, JAN, 1)] = name
if self.observed and date(year, JAN, 1).weekday() == SUN:
self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)"
- elif self.observed and date(year, JAN, 1).weekday() == SAT:
- # Add Dec 31st from the previous year without triggering
- # the entire year to be added
- expand = self.expand
- self.expand = False
- self[date(year, JAN, 1) + rd(days=-1)] = name + " (Observed)"
- self.expand = expand
- # The next year's observed New Year's Day can be in this year
- # when it falls on a Friday (Jan 1st is a Saturday)
+ # The following year's observed New Year's Day can be in this year
+ # when it falls on a Friday (Jan 1st is a Saturday).
if self.observed and date(year, DEC, 31).weekday() == FRI:
self[date(year, DEC, 31)] = name + " (Observed)"
diff --git a/holidays/countries/hungary.py b/holidays/countries/hungary.py
index 91e72170..fa9f03ac 100644
--- a/holidays/countries/hungary.py
+++ b/holidays/countries/hungary.py
@@ -37,9 +37,14 @@ class Hungary(HolidayBase):
def __init__(self, **kwargs):
HolidayBase.__init__(self, **kwargs)
- def _populate(self, year):
+ def _populate(self, year: int) -> None:
# New years
self._add_with_observed_day_off(date(year, JAN, 1), "Újév", since=2014)
+ # Since 2014, the last day of the year is an observed day off if New
+ # Year's Day falls on a Tuesday.
+ if year >= 2104:
+ if self.observed and date(year, DEC, 31).weekday() == MON:
+ self[date(year, DEC, 31)] = "Újév előtti pihenőnap"
# National Day
if 1945 <= year <= 1950 or 1989 <= year:
@@ -140,14 +145,23 @@ class Hungary(HolidayBase):
self[date(year, DEC, 31)] = "Szilveszter"
def _add_with_observed_day_off(
- self, day, desc, since=2010, before=True, after=True
- ):
+ self,
+ day: date,
+ desc: str,
+ since: int = 2010,
+ before: bool = True,
+ after: bool = True,
+ ) -> None:
# Swapped days off were in place earlier but
# I haven't found official record yet.
self[day] = desc
# TODO: should it be a separate flag?
if self.observed and since <= day.year:
- if day.weekday() == TUE and before:
+ if (
+ day.weekday() == TUE
+ and before
+ and not (day.month == JAN and day.day == 1)
+ ):
self[day - rd(days=1)] = desc + " előtti pihenőnap"
elif day.weekday() == THU and after:
self[day + rd(days=1)] = desc + " utáni pihenőnap"
diff --git a/holidays/countries/israel.py b/holidays/countries/israel.py
index a793c91c..aa5d3371 100644
--- a/holidays/countries/israel.py
+++ b/holidays/countries/israel.py
@@ -39,8 +39,7 @@ class Israel(HolidayBase):
def _populate(self, year):
# Passover
name = "Passover I"
- year, month, day = passover(year, eve=True)
- passover_start_dt = date(year, month, day)
+ passover_start_dt = date(*passover(year, eve=True))
self[passover_start_dt] = name + " - Eve"
self[passover_start_dt + rd(days=1)] = name
@@ -54,61 +53,62 @@ class Israel(HolidayBase):
# Memorial Day
name = "Memorial Day"
- year, month, day = gregorian.from_jd(
- hebrew.to_jd_gregorianyear(year, hebrew.IYYAR, 3)
+ memorial_day_dt = date(
+ *gregorian.from_jd(
+ hebrew.to_jd_gregorianyear(year, hebrew.IYYAR, 3)
+ )
)
- self[date(year, month, day) + rd(days=1)] = name
+ self[memorial_day_dt + rd(days=1)] = name
observed_delta = 0
if self.observed:
- day_in_week = date(year, month, day).weekday()
+ day_in_week = memorial_day_dt.weekday()
if day_in_week in (2, 3):
observed_delta = -(day_in_week - 1)
elif 2004 <= year and day_in_week == 5:
observed_delta = 1
if observed_delta != 0:
- self[date(year, month, day) + rd(days=observed_delta + 1)] = (
+ self[memorial_day_dt + rd(days=observed_delta + 1)] = (
name + " (Observed)"
)
# Independence Day
name = "Independence Day"
- self[date(year, month, day) + rd(days=2)] = name
+ self[memorial_day_dt + rd(days=2)] = name
if self.observed and observed_delta != 0:
- self[date(year, month, day) + rd(days=observed_delta + 2)] = (
+ self[memorial_day_dt + rd(days=observed_delta + 2)] = (
name + " (Observed)"
)
# Lag Baomer
name = "Lag B'Omer"
- year, month, day = lag_baomer(year, eve=False)
- self[date(year, month, day)] = name
+ lag_baomer_dt = date(*lag_baomer(year, eve=False))
+ self[lag_baomer_dt] = name
# Shavuot
name = "Shavuot"
- year, month, day = shavuot(year, eve=True)
- self[date(year, month, day)] = name + " - Eve"
- self[date(year, month, day) + rd(days=1)] = name
+ shavuot_dt = date(*shavuot(year, eve=True))
+ self[shavuot_dt] = name + " - Eve"
+ self[shavuot_dt + rd(days=1)] = name
# Rosh Hashana
name = "Rosh Hashanah"
- year, month, day = rosh_hashanah(year, eve=True)
- self[date(year, month, day)] = name + " - Eve"
- self[date(year, month, day) + rd(days=1)] = name
- self[date(year, month, day) + rd(days=2)] = name
+ rosh_hashanah_dt = date(*rosh_hashanah(year, eve=True))
+ self[rosh_hashanah_dt] = name + " - Eve"
+ self[rosh_hashanah_dt + rd(days=1)] = name
+ self[rosh_hashanah_dt + rd(days=2)] = name
# Yom Kippur
name = "Yom Kippur"
- year, month, day = yom_kippur(year, eve=True)
- self[date(year, month, day)] = name + " - Eve"
- self[date(year, month, day) + rd(days=1)] = name
+ yom_kippur_dt = date(*yom_kippur(year, eve=True))
+ self[yom_kippur_dt] = name + " - Eve"
+ self[yom_kippur_dt + rd(days=1)] = name
# Sukkot
name = "Sukkot I"
- year, month, day = sukkot(year, eve=True)
- sukkot_start_dt = date(year, month, day)
+ sukkot_start_dt = date(*sukkot(year, eve=True))
self[sukkot_start_dt] = name + " - Eve"
self[sukkot_start_dt + rd(days=1)] = name
@@ -122,16 +122,24 @@ class Israel(HolidayBase):
# Hanukkah
name = "Hanukkah"
- year, month, day = hanukkah(year, eve=False)
+ hk_start_date = date(*hanukkah(year, eve=False))
+ for offset in range(8):
+ hk_date = hk_start_date + rd(days=offset)
+ if hk_date.year == year:
+ self[hk_date] = name
+ # Some o prior's year Hannukah may fall in current year.
+ hk_start_date = date(*hanukkah(year - 1, eve=False))
for offset in range(8):
- self[date(year, month, day) + rd(days=offset)] = name
+ hk_date = hk_start_date + rd(days=offset)
+ if hk_date.year == year:
+ self[hk_date] = name
# Purim
name = "Purim"
- year, month, day = purim(year, eve=True)
- self[date(year, month, day)] = name + " - Eve"
- self[date(year, month, day) + rd(days=1)] = name
- self[date(year, month, day) + rd(days=2)] = "Shushan Purim"
+ purim_date = date(*purim(year, eve=True))
+ self[purim_date] = name + " - Eve"
+ self[purim_date + rd(days=1)] = name
+ self[purim_date + rd(days=2)] = "Shushan Purim"
class IL(Israel):
diff --git a/holidays/countries/taiwan.py b/holidays/countries/taiwan.py
index 3816324c..d7eeb5f6 100644
--- a/holidays/countries/taiwan.py
+++ b/holidays/countries/taiwan.py
@@ -28,8 +28,8 @@ class Taiwan(HolidayBase):
country = "TW"
def __init__(self, **kwargs):
- HolidayBase.__init__(self, **kwargs)
self.cnls = _ChineseLuniSolar()
+ HolidayBase.__init__(self, **kwargs)
def _populate(self, year):
# New Year's Day
diff --git a/holidays/countries/united_states.py b/holidays/countries/united_states.py
index 9eacdbc6..fb8aefc7 100644
--- a/holidays/countries/united_states.py
+++ b/holidays/countries/united_states.py
@@ -110,15 +110,8 @@ class UnitedStates(HolidayBase):
self[date(year, JAN, 1)] = name
if self.observed and date(year, JAN, 1).weekday() == SUN:
self[date(year, JAN, 1) + rd(days=+1)] = name + " (Observed)"
- elif self.observed and date(year, JAN, 1).weekday() == SAT:
- # Add Dec 31st from the previous year without triggering
- # the entire year to be added
- expand = self.expand
- self.expand = False
- self[date(year, JAN, 1) + rd(days=-1)] = name + " (Observed)"
- self.expand = expand
- # The next year's observed New Year's Day can be in this year
- # when it falls on a Friday (Jan 1st is a Saturday)
+ # The following year's observed New Year's Day can be in this year
+ # when it falls on a Friday (Jan 1st is a Saturday).
if self.observed and date(year, DEC, 31).weekday() == FRI:
self[date(year, DEC, 31)] = name + " (Observed)"
| US Holidays Error: dictionary changed during iteration when passing years to holidays.US constructor
Attempting to use code to get US holidays for specific years. This code works for some countries but not US (nor Canada)
```
import holidays
import numpy as np
print(holidays.__version__)
years = np.array([2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021])
x = holidays.US(years=years)
```
This code works when I try different countries: FR, GB, RU, DE, ES, CZ, AU, JP, CN, IN
This syntax **fails** to return results for the countries: US, CA
This syntax for passing numpy arrays I found in a ticket with a CZ example. (https://github.com/dr-prodigy/python-holidays/pull/528).
I am running on Databricks runtime 10.0. The holidays version is 0.11.3.1 as you see below.
The output I got was for US (or CA) is:
```
0.11.3.1
Out[41]:
RuntimeError: dictionary changed size during iteration
```
Example output when I use another country, such as AU is:
```
0.11.3.1
Out[42]: {datetime.date(2016, 1, 1): "New Year's Day",
datetime.date(2016, 1, 26): 'Australia Day',
datetime.date(2016, 3, 25): 'Good Friday',
datetime.date(2016, 3, 28): 'Easter Monday',
datetime.date(2016, 4, 25): 'Anzac Day',
datetime.date(2016, 12, 25): 'Christmas Day',
datetime.date(2016, 12, 27): 'Christmas Day (Observed)',
datetime.date(2016, 12, 26): 'Boxing Day',
datetime.date(2017, 1, 1): "New Year's Day",
datetime.date(2017, 1, 2): "New Year's Day (Observed)",
...
``` | dr-prodigy/python-holidays | diff --git a/test/test_holiday_base.py b/test/test_holiday_base.py
index 509ae262..8a87d2de 100644
--- a/test/test_holiday_base.py
+++ b/test/test_holiday_base.py
@@ -409,7 +409,7 @@ class TestArgs(unittest.TestCase):
self.assertIn(2013, self.holidays.years)
self.assertNotIn(2014, self.holidays.years)
self.assertIn(2015, self.holidays.years)
- self.assertIn(date(2021, 12, 31), holidays.US(years=[2022]).keys())
+ self.assertIn(date(2021, 12, 31), holidays.US(years=[2021]).keys())
self.holidays = holidays.US(years=2015)
self.assertNotIn(2014, self.holidays.years)
self.assertIn(2015, self.holidays.years)
@@ -541,3 +541,56 @@ class TestCountryHoliday(unittest.TestCase):
def test_exceptions(self):
self.assertRaises((KeyError), lambda: holidays.CountryHoliday("XXXX"))
+
+
+class TestAllInSameYear(unittest.TestCase):
+ """Test that only holidays in the year(s) requested are returned."""
+
+ country: str
+ hol: datetime
+ year: int
+
+ def setUp(self):
+ self.countries = holidays.list_supported_countries()
+
+ def tearDown(self):
+ """https://stackoverflow.com/questions/4414234/"""
+
+ def list2reason(exc_list):
+ if exc_list and exc_list[-1][0] is self:
+ return exc_list[-1][1]
+
+ result = self.defaultTestResult()
+ self._feedErrorsToResult(result, self._outcome.errors)
+ error = list2reason(result.errors)
+ failure = list2reason(result.failures)
+ text = error if error else failure
+ if text:
+ print(
+ f"{text.splitlines()[-1]} in country {self.country}: "
+ f"holiday {self.hol} returned for year {self.year}"
+ )
+ print(
+ holidays.country_holidays(
+ self.country, prov=None, state=None, years=[self.year]
+ ).get_list(self.hol)
+ )
+
+ def test_all_countries(self):
+ """
+ Only holidays in the year(s) requested should be returned. This
+ ensures that we avoid triggering a "RuntimeError: dictionary changed
+ size during iteration" error.
+
+ Here we test all countries for the 12-year period starting ten years
+ ago and ending 2 years from now.
+ """
+ for self.country in self.countries:
+ for self.year in range(
+ date.today().year - 10, date.today().year + 3
+ ):
+ hols = holidays.country_holidays(
+ self.country, prov=None, state=None, years=[self.year]
+ )
+ for self.hol in hols:
+ assert self.hol.year == self.year
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_many_modified_files",
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 8
} | .0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements_dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
babel==2.17.0
certifi==2025.1.31
cfgv==3.4.0
charset-normalizer==3.4.1
convertdate==2.4.0
coverage==7.8.0
distlib==0.3.9
docutils==0.21.2
exceptiongroup==1.2.2
filelock==3.18.0
flake8==7.2.0
hijri-converter==2.3.1
-e git+https://github.com/dr-prodigy/python-holidays.git@f1ec50378e8fe537b6803cc0156bd064bb258a1d#egg=holidays
identify==2.6.9
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
korean-lunar-calendar==0.3.1
MarkupSafe==3.0.2
mccabe==0.7.0
nodeenv==1.9.1
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
pre_commit==4.2.0
pycodestyle==2.13.0
pyflakes==3.3.2
Pygments==2.19.1
PyMeeus==0.5.12
pytest==8.3.5
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
six==1.17.0
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tomli==2.2.1
urllib3==2.3.0
virtualenv==20.29.3
zipp==3.21.0
| name: python-holidays
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- certifi==2025.1.31
- cfgv==3.4.0
- charset-normalizer==3.4.1
- convertdate==2.4.0
- coverage==7.8.0
- distlib==0.3.9
- docutils==0.21.2
- exceptiongroup==1.2.2
- filelock==3.18.0
- flake8==7.2.0
- hijri-converter==2.3.1
- holidays==0.12.1
- identify==2.6.9
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- korean-lunar-calendar==0.3.1
- markupsafe==3.0.2
- mccabe==0.7.0
- nodeenv==1.9.1
- packaging==24.2
- platformdirs==4.3.7
- pluggy==1.5.0
- pre-commit==4.2.0
- pycodestyle==2.13.0
- pyflakes==3.3.2
- pygments==2.19.1
- pymeeus==0.5.12
- pytest==8.3.5
- pytest-cov==6.0.0
- python-dateutil==2.9.0.post0
- pyyaml==6.0.2
- requests==2.32.3
- six==1.17.0
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- tomli==2.2.1
- urllib3==2.3.0
- virtualenv==20.29.3
- zipp==3.21.0
prefix: /opt/conda/envs/python-holidays
| [
"test/test_holiday_base.py::TestAllInSameYear::test_all_countries"
] | [] | [
"test/test_holiday_base.py::TestBasics::test_add",
"test/test_holiday_base.py::TestBasics::test_append",
"test/test_holiday_base.py::TestBasics::test_contains",
"test/test_holiday_base.py::TestBasics::test_eq_ne",
"test/test_holiday_base.py::TestBasics::test_get",
"test/test_holiday_base.py::TestBasics::test_get_list",
"test/test_holiday_base.py::TestBasics::test_get_named",
"test/test_holiday_base.py::TestBasics::test_getitem",
"test/test_holiday_base.py::TestBasics::test_inheritance",
"test/test_holiday_base.py::TestBasics::test_list_supported_countries",
"test/test_holiday_base.py::TestBasics::test_pop",
"test/test_holiday_base.py::TestBasics::test_pop_named",
"test/test_holiday_base.py::TestBasics::test_radd",
"test/test_holiday_base.py::TestBasics::test_setitem",
"test/test_holiday_base.py::TestBasics::test_update",
"test/test_holiday_base.py::TestArgs::test_country",
"test/test_holiday_base.py::TestArgs::test_expand",
"test/test_holiday_base.py::TestArgs::test_observed",
"test/test_holiday_base.py::TestArgs::test_serialization",
"test/test_holiday_base.py::TestArgs::test_years",
"test/test_holiday_base.py::TestKeyTransforms::test_dates",
"test/test_holiday_base.py::TestKeyTransforms::test_datetimes",
"test/test_holiday_base.py::TestKeyTransforms::test_exceptions",
"test/test_holiday_base.py::TestKeyTransforms::test_strings",
"test/test_holiday_base.py::TestKeyTransforms::test_timestamp",
"test/test_holiday_base.py::TestCountryHoliday::test_country",
"test/test_holiday_base.py::TestCountryHoliday::test_country_province",
"test/test_holiday_base.py::TestCountryHoliday::test_country_single_year",
"test/test_holiday_base.py::TestCountryHoliday::test_country_state",
"test/test_holiday_base.py::TestCountryHoliday::test_country_years",
"test/test_holiday_base.py::TestCountryHoliday::test_exceptions"
] | [] | MIT License | 11,934 | 4,570 | [
"holidays/countries/angola.py",
"holidays/countries/azerbaijan.py",
"holidays/countries/botswana.py",
"holidays/countries/canada.py",
"holidays/countries/hungary.py",
"holidays/countries/israel.py",
"holidays/countries/taiwan.py",
"holidays/countries/united_states.py"
] |
|
pysal__momepy-330 | d836424aaac5b4c0baa734517e8a46adb54a6b1d | 2022-01-05 16:53:05 | 9d6ac866e0fea55f4ee8e2244031fb917c276642 | diff --git a/momepy/shape.py b/momepy/shape.py
index 717465d..9da9928 100644
--- a/momepy/shape.py
+++ b/momepy/shape.py
@@ -32,12 +32,34 @@ __all__ = [
]
+def _form_factor(height, geometry, area=None, perimeter=None, volume=None):
+ """helper for FormFactor"""
+ if area is None:
+ area = geometry.area
+ if perimeter is None:
+ perimeter = geometry.length
+ if volume is None:
+ volume = area * height
+
+ surface = (perimeter * height) + area
+ zeros = volume == 0
+ res = np.empty(len(geometry))
+ res[zeros] = np.nan
+ res[~zeros] = surface[~zeros] / (volume[~zeros] ** (2 / 3))
+ return res
+
+
class FormFactor:
"""
Calculates form factor of each object in given GeoDataFrame.
.. math::
- area \\over {volume^{2 \\over 3}}
+ surface \\over {volume^{2 \\over 3}}
+
+ where
+
+ .. math::
+ surface = (perimeter * height) + area
Adapted from :cite:`bourdic2012`.
@@ -78,7 +100,11 @@ class FormFactor:
"""
- def __init__(self, gdf, volumes, areas=None):
+ def __init__(self, gdf, volumes, areas=None, heights=None):
+ if heights is None:
+ raise ValueError("`heights` cannot be None.")
+ # TODO: this shouldn't be needed but it would be a breaking change now.
+ # remove during the functional refactor
self.gdf = gdf
gdf = gdf.copy()
@@ -92,11 +118,19 @@ class FormFactor:
gdf["mm_a"] = areas
areas = "mm_a"
self.areas = gdf[areas]
- zeros = gdf[volumes] == 0
- res = np.empty(len(gdf))
- res[zeros] = 0
- res[~zeros] = gdf[areas][~zeros] / (gdf[volumes][~zeros] ** (2 / 3))
- self.series = pd.Series(res, index=gdf.index)
+
+ if isinstance(heights, str):
+ heights = gdf[heights]
+
+ self.series = pd.Series(
+ _form_factor(
+ height=np.asarray(heights),
+ geometry=gdf.geometry,
+ area=self.areas,
+ volume=self.volumes,
+ ),
+ index=gdf.index,
+ )
class FractalDimension:
| BUG: FormFactor uses incorrect formula
I just realised that `FormFactor` is using an incorrect formula.
The formula in the original paper by Bourdic et al says `S/(V^2/3)` where `S` is surface. However, I have implemented it as `A/(V^2/3)`, where `A` is an area of a polygon, not the theoretical surface of the whole building.
I think we should fix this with `S` defined as `perimeter * height + area`.
I'll try to get it done today and cut the 0.6.0 release to have it ready for the PySAL meta release later this month. | pysal/momepy | diff --git a/tests/test_shape.py b/tests/test_shape.py
index e431dd1..f116d93 100644
--- a/tests/test_shape.py
+++ b/tests/test_shape.py
@@ -20,21 +20,19 @@ class TestShape:
self.df_buildings["volume"] = mm.Volume(self.df_buildings, "height").series
def test_FormFactor(self):
- self.df_buildings["ff"] = mm.FormFactor(self.df_buildings, "volume").series
- check = (self.df_buildings.geometry[0].area) / (
- self.df_buildings.volume[0] ** (2 / 3)
- )
- assert self.df_buildings["ff"][0] == check
+ self.df_buildings["ff"] = mm.FormFactor(
+ self.df_buildings, "volume", heights="height"
+ ).series
+ check = 5.4486362624193
+ assert self.df_buildings["ff"].mean() == approx(check)
self.df_buildings["ff"] = mm.FormFactor(
self.df_buildings,
mm.Volume(self.df_buildings, "height").series,
areas=self.df_buildings.geometry.area,
+ heights=self.df_buildings["height"],
).series
- check = (self.df_buildings.geometry[0].area) / (
- self.df_buildings.volume[0] ** (2 / 3)
- )
- assert self.df_buildings["ff"][0] == check
+ assert self.df_buildings["ff"].mean() == approx(check)
def test_FractalDimension(self):
self.df_buildings["fd"] = mm.FractalDimension(self.df_buildings).series
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 0
},
"num_modified_files": 1
} | 0.5 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.10",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | affine @ file:///home/conda/feedstock_root/build_artifacts/affine_1733762038348/work
anyio @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_anyio_1742243108/work
argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1733311059102/work
argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1725356557095/work
arrow @ file:///home/conda/feedstock_root/build_artifacts/arrow_1733584251875/work
asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1733250440834/work
async-lru @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_async-lru_1742153708/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1741918516150/work
babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1738490167835/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1738740337718/work
bleach @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_bleach_1737382993/work
branca @ file:///home/conda/feedstock_root/build_artifacts/branca_1734433375112/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1725267488082/work
cached-property @ file:///home/conda/feedstock_root/build_artifacts/cached_property_1615209429212/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1739515848642/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1725560520483/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1735929714516/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1734858813237/work
click-plugins @ file:///home/conda/feedstock_root/build_artifacts/click-plugins_1733731077999/work
cligj @ file:///home/conda/feedstock_root/build_artifacts/cligj_1733749956636/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1733218098505/work
comm @ file:///home/conda/feedstock_root/build_artifacts/comm_1733502965406/work
contourpy @ file:///home/conda/feedstock_root/build_artifacts/contourpy_1731428322366/work
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1733332471406/work
debugpy @ file:///home/conda/feedstock_root/build_artifacts/debugpy_1741148395697/work
decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1740384970518/work
defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work
descartes @ file:///home/conda/feedstock_root/build_artifacts/descartes_1734602598660/work
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1733569351617/work
fastjsonschema @ file:///home/conda/feedstock_root/build_artifacts/python-fastjsonschema_1733235979760/work/dist
folium @ file:///home/conda/feedstock_root/build_artifacts/folium_1740766619747/work
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1738940303262/work
fqdn @ file:///home/conda/feedstock_root/build_artifacts/fqdn_1733327382592/work/dist
geopandas @ file:///home/conda/feedstock_root/build_artifacts/geopandas_1734346029138/work
h11 @ file:///home/conda/feedstock_root/build_artifacts/h11_1733327467879/work
h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1738578511449/work
hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1737618293087/work
httpcore @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_httpcore_1731707562/work
httpx @ file:///home/conda/feedstock_root/build_artifacts/httpx_1733663348460/work
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1737618333194/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
importlib_metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1737420181517/work
importlib_resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1736252299705/work
inequality @ file:///home/conda/feedstock_root/build_artifacts/inequality_1738179721853/work
iniconfig==2.1.0
ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1719845459717/work
ipython @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_ipython_1741457802/work
ipywidgets @ file:///home/conda/feedstock_root/build_artifacts/ipywidgets_1733493556527/work
isoduration @ file:///home/conda/feedstock_root/build_artifacts/isoduration_1733493628631/work/dist
jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1733300866624/work
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1741263328855/work
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1733736026804/work
json5 @ file:///home/conda/feedstock_root/build_artifacts/json5_1733272076743/work
jsonpointer @ file:///home/conda/feedstock_root/build_artifacts/jsonpointer_1725302897999/work
jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema_1733472696581/work
jsonschema-specifications @ file:///tmp/tmpk0f344m9/src
jupyter @ file:///home/conda/feedstock_root/build_artifacts/jupyter_1733818543322/work
jupyter-console @ file:///home/conda/feedstock_root/build_artifacts/jupyter_console_1733817997778/work
jupyter-events @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_jupyter_events_1738765986/work
jupyter-lsp @ file:///home/conda/feedstock_root/build_artifacts/jupyter-lsp-meta_1733492907176/work/jupyter-lsp
jupyter_client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1733440914442/work
jupyter_core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1727163409502/work
jupyter_server @ file:///home/conda/feedstock_root/build_artifacts/jupyter_server_1734702637701/work
jupyter_server_terminals @ file:///home/conda/feedstock_root/build_artifacts/jupyter_server_terminals_1733427956852/work
jupyterlab @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_1741964057182/work
jupyterlab_pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1733328101776/work
jupyterlab_server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1733599573484/work
jupyterlab_widgets @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_widgets_1733428046021/work
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1725459213453/work
libpysal @ file:///home/conda/feedstock_root/build_artifacts/libpysal_1734433669370/work
mapclassify @ file:///home/conda/feedstock_root/build_artifacts/mapclassify_1733731066416/work
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1733219680183/work
matplotlib==3.9.1
matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1733416936468/work
mistune @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_mistune_1742402716/work
-e git+https://github.com/pysal/momepy.git@d836424aaac5b4c0baa734517e8a46adb54a6b1d#egg=momepy
munkres==1.1.4
nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1734628800805/work
nbconvert @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_nbconvert-core_1738067871/work
nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1733402752141/work
nest_asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1733325553580/work
networkx @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_networkx_1731521053/work
notebook @ file:///home/conda/feedstock_root/build_artifacts/notebook_1741968175534/work
notebook_shim @ file:///home/conda/feedstock_root/build_artifacts/notebook-shim_1733408315203/work
numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1707225380409/work/dist/numpy-1.26.4-cp310-cp310-linux_x86_64.whl#sha256=51131fd8fc130cd168aecaf1bc0ea85f92e8ffebf211772ceb16ac2e7f10d7ca
osmnx @ file:///home/conda/feedstock_root/build_artifacts/osmnx_1743172660704/work
overrides @ file:///home/conda/feedstock_root/build_artifacts/overrides_1734587627321/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pandas @ file:///home/conda/feedstock_root/build_artifacts/pandas_1726878398774/work
pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work
parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1733271261340/work
pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1733301927746/work
pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1733327343728/work
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1688255837355/work
pkgutil_resolve_name @ file:///home/conda/feedstock_root/build_artifacts/pkgutil-resolve-name_1733344503739/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_platformdirs_1742485085/work
pluggy==1.5.0
ply @ file:///home/conda/feedstock_root/build_artifacts/ply_1733239724146/work
prometheus_client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1733327310477/work
prompt_toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1737453357274/work
psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1740663128538/work
ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1733302279685/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl#sha256=92c32ff62b5fd8cf325bec5ab90d7be3d2a8ca8c8a3813ff487a8d2002630d1f
pure_eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1733569405015/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
pygeos @ file:///home/conda/feedstock_root/build_artifacts/pygeos_1679088644875/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1736243443484/work
pyogrio @ file:///croot/pyogrio_1741107161422/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1743089729650/work
pyproj @ file:///home/conda/feedstock_root/build_artifacts/pyproj_1695265002392/work
PyQt5==5.15.9
PyQt5-sip==12.12.2
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
pytest==8.3.5
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1733215673016/work
python-json-logger @ file:///home/conda/feedstock_root/build_artifacts/python-json-logger_1677079630776/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1706886791323/work
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1737454647378/work
pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1741805149626/work
rasterio @ file:///croot/rasterio_1740069178893/work
referencing @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_referencing_1737836872/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
rfc3339_validator @ file:///home/conda/feedstock_root/build_artifacts/rfc3339-validator_1733599910982/work
rfc3986-validator @ file:///home/conda/feedstock_root/build_artifacts/rfc3986-validator_1598024191506/work
rio-vrt @ file:///home/conda/feedstock_root/build_artifacts/rio-vrt_1734898616182/work
rpds-py @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_rpds-py_1743037662/work
rtree @ file:///home/conda/feedstock_root/build_artifacts/rtree_1741378561624/work
scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1736496756180/work/dist/scikit_learn-1.6.1-cp310-cp310-linux_x86_64.whl#sha256=8b3481924bda36bf9a85c5f500f48e43e1178ead014b2d2ecf10f7b9b49935b4
scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy-split_1739790642651/work/dist/scipy-1.15.2-cp310-cp310-linux_x86_64.whl#sha256=9e52bad6c3294d1a5b04a13632118ca2157130603c6c018c2d710162b223b27e
Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1733322040660/work
shapely @ file:///home/conda/feedstock_root/build_artifacts/shapely_1679081540669/work
sip @ file:///home/conda/feedstock_root/build_artifacts/sip_1697300428978/work
six @ file:///home/conda/feedstock_root/build_artifacts/six_1733380938961/work
sniffio @ file:///home/conda/feedstock_root/build_artifacts/sniffio_1733244044561/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1693929250441/work
stack_data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1733569443808/work
terminado @ file:///home/conda/feedstock_root/build_artifacts/terminado_1710262609923/work
threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1741878222898/work
tinycss2 @ file:///home/conda/feedstock_root/build_artifacts/tinycss2_1729802851396/work
toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1734091811753/work
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1733256695513/work
tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1732615898999/work
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1735661334605/work
traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1733367359838/work
types-python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/types-python-dateutil_1733612335562/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_typing_extensions_1743201626/work
typing_utils @ file:///home/conda/feedstock_root/build_artifacts/typing_utils_1733331286120/work
tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1742745135198/work
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1736692496989/work
uri-template @ file:///home/conda/feedstock_root/build_artifacts/uri-template_1733323593477/work/dist
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1734859416348/work
wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1733231326287/work
webcolors @ file:///home/conda/feedstock_root/build_artifacts/webcolors_1733359735138/work
webencodings @ file:///home/conda/feedstock_root/build_artifacts/webencodings_1733236011802/work
websocket-client @ file:///home/conda/feedstock_root/build_artifacts/websocket-client_1733157342724/work
widgetsnbextension @ file:///home/conda/feedstock_root/build_artifacts/widgetsnbextension_1733128559935/work
xyzservices @ file:///home/conda/feedstock_root/build_artifacts/xyzservices_1737234886776/work
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1732827521216/work
zstandard==0.23.0
| name: momepy
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=conda_forge
- _openmp_mutex=4.5=2_gnu
- affine=2.4.0=pyhd8ed1ab_1
- alsa-lib=1.2.9=hd590300_0
- anyio=4.9.0=pyh29332c3_0
- argon2-cffi=23.1.0=pyhd8ed1ab_1
- argon2-cffi-bindings=21.2.0=py310ha75aee5_5
- arrow=1.3.0=pyhd8ed1ab_1
- asttokens=3.0.0=pyhd8ed1ab_1
- async-lru=2.0.5=pyh29332c3_0
- attr=2.5.1=h166bdaf_1
- attrs=25.3.0=pyh71513ae_0
- aws-c-auth=0.7.4=h1083cbe_2
- aws-c-cal=0.6.2=h09139f6_2
- aws-c-common=0.9.3=hd590300_0
- aws-c-compression=0.2.17=h184a658_3
- aws-c-event-stream=0.3.2=h6fea174_2
- aws-c-http=0.7.13=hb59894b_2
- aws-c-io=0.13.33=h161b759_0
- aws-c-mqtt=0.9.7=h55cd26b_0
- aws-c-s3=0.3.17=hfb4bb88_4
- aws-c-sdkutils=0.1.12=h184a658_2
- aws-checksums=0.1.17=h184a658_2
- aws-crt-cpp=0.24.2=ha28989d_2
- aws-sdk-cpp=1.10.57=hec69fbc_24
- babel=2.17.0=pyhd8ed1ab_0
- beautifulsoup4=4.13.3=pyha770c72_0
- bleach=6.2.0=pyh29332c3_4
- bleach-with-css=6.2.0=h82add2a_4
- blosc=1.21.6=hef167b5_0
- boost-cpp=1.78.0=h6582d0a_3
- branca=0.8.1=pyhd8ed1ab_0
- brotli=1.1.0=hb9d3cd8_2
- brotli-bin=1.1.0=hb9d3cd8_2
- brotli-python=1.1.0=py310hf71b8c6_2
- bzip2=1.0.8=h4bc722e_7
- c-ares=1.34.4=hb9d3cd8_0
- ca-certificates=2025.1.31=hbcca054_0
- cached-property=1.5.2=hd8ed1ab_1
- cached_property=1.5.2=pyha770c72_1
- cairo=1.16.0=hbbf8b49_1016
- certifi=2025.1.31=pyhd8ed1ab_0
- cffi=1.17.1=py310h8deb56e_0
- cfitsio=4.2.0=hd9d235c_0
- charset-normalizer=3.4.1=pyhd8ed1ab_0
- click=8.1.8=pyh707e725_0
- click-plugins=1.1.1=pyhd8ed1ab_1
- cligj=0.7.2=pyhd8ed1ab_2
- colorama=0.4.6=pyhd8ed1ab_1
- comm=0.2.2=pyhd8ed1ab_1
- contourpy=1.3.1=py310h3788b33_0
- curl=8.4.0=hca28451_0
- cycler=0.12.1=pyhd8ed1ab_1
- dbus=1.13.6=h5008d03_3
- debugpy=1.8.13=py310hf71b8c6_0
- decorator=5.2.1=pyhd8ed1ab_0
- defusedxml=0.7.1=pyhd8ed1ab_0
- descartes=1.1.0=pyhd8ed1ab_5
- exceptiongroup=1.2.2=pyhd8ed1ab_1
- executing=2.1.0=pyhd8ed1ab_1
- expat=2.6.4=h5888daf_0
- folium=0.19.5=pyhd8ed1ab_0
- font-ttf-dejavu-sans-mono=2.37=hab24e00_0
- font-ttf-inconsolata=3.000=h77eed37_0
- font-ttf-source-code-pro=2.038=h77eed37_0
- font-ttf-ubuntu=0.83=h77eed37_3
- fontconfig=2.15.0=h7e30c49_1
- fonts-conda-ecosystem=1=0
- fonts-conda-forge=1=0
- fonttools=4.56.0=py310h89163eb_0
- fqdn=1.5.1=pyhd8ed1ab_1
- freetype=2.13.3=h48d6fc4_0
- freexl=1.0.6=h166bdaf_1
- geopandas=1.0.1=pyhd8ed1ab_3
- geopandas-base=1.0.1=pyha770c72_3
- geos=3.11.2=hcb278e6_0
- geotiff=1.7.1=h22adcc9_11
- gettext=0.23.1=h5888daf_0
- gettext-tools=0.23.1=h5888daf_0
- giflib=5.2.2=hd590300_0
- glib=2.78.1=hfc55251_0
- glib-tools=2.78.1=hfc55251_0
- graphite2=1.3.13=h59595ed_1003
- gst-plugins-base=1.22.5=hf7dbed1_0
- gstreamer=1.22.5=h98fc4e7_0
- h11=0.14.0=pyhd8ed1ab_1
- h2=4.2.0=pyhd8ed1ab_0
- harfbuzz=7.3.0=hdb3a94d_0
- hdf4=4.2.15=h501b40f_6
- hdf5=1.14.1=nompi_h4f84152_100
- hpack=4.1.0=pyhd8ed1ab_0
- httpcore=1.0.7=pyh29332c3_1
- httpx=0.28.1=pyhd8ed1ab_0
- hyperframe=6.1.0=pyhd8ed1ab_0
- icu=72.1=hcb278e6_0
- idna=3.10=pyhd8ed1ab_1
- importlib-metadata=8.6.1=pyha770c72_0
- importlib_resources=6.5.2=pyhd8ed1ab_0
- inequality=1.1.1=pyhd8ed1ab_0
- ipykernel=6.29.5=pyh3099207_0
- ipython=8.34.0=pyh907856f_0
- ipywidgets=8.1.5=pyhd8ed1ab_1
- isoduration=20.11.0=pyhd8ed1ab_1
- jedi=0.19.2=pyhd8ed1ab_1
- jinja2=3.1.6=pyhd8ed1ab_0
- joblib=1.4.2=pyhd8ed1ab_1
- json-c=0.16=hc379101_0
- json5=0.10.0=pyhd8ed1ab_1
- jsonpointer=3.0.0=py310hff52083_1
- jsonschema=4.23.0=pyhd8ed1ab_1
- jsonschema-specifications=2024.10.1=pyhd8ed1ab_1
- jsonschema-with-format-nongpl=4.23.0=hd8ed1ab_1
- jupyter=1.1.1=pyhd8ed1ab_1
- jupyter-lsp=2.2.5=pyhd8ed1ab_1
- jupyter_client=8.6.3=pyhd8ed1ab_1
- jupyter_console=6.6.3=pyhd8ed1ab_1
- jupyter_core=5.7.2=pyh31011fe_1
- jupyter_events=0.12.0=pyh29332c3_0
- jupyter_server=2.15.0=pyhd8ed1ab_0
- jupyter_server_terminals=0.5.3=pyhd8ed1ab_1
- jupyterlab=4.3.6=pyhd8ed1ab_0
- jupyterlab_pygments=0.3.0=pyhd8ed1ab_2
- jupyterlab_server=2.27.3=pyhd8ed1ab_1
- jupyterlab_widgets=3.0.13=pyhd8ed1ab_1
- kealib=1.5.1=h3e6883b_4
- kiwisolver=1.4.7=py310h3788b33_0
- krb5=1.21.3=h143b758_0
- lame=3.100=h166bdaf_1003
- lcms2=2.15=haa2dc70_1
- ld_impl_linux-64=2.43=h712a8e2_4
- lerc=4.0.0=h27087fc_0
- libaec=1.1.3=h59595ed_0
- libasprintf=0.23.1=h8e693c7_0
- libasprintf-devel=0.23.1=h8e693c7_0
- libblas=3.9.0=31_h59b9bed_openblas
- libbrotlicommon=1.1.0=hb9d3cd8_2
- libbrotlidec=1.1.0=hb9d3cd8_2
- libbrotlienc=1.1.0=hb9d3cd8_2
- libcap=2.71=h39aace5_0
- libcblas=3.9.0=31_he106b2a_openblas
- libclang=15.0.7=default_h127d8a8_5
- libclang13=15.0.7=default_h5d6823c_5
- libcups=2.3.3=h4637d8d_4
- libcurl=8.4.0=hca28451_0
- libdeflate=1.18=h0b41bf4_0
- libedit=3.1.20250104=pl5321h7949ede_0
- libev=4.33=hd590300_2
- libevent=2.1.12=hf998b51_1
- libexpat=2.6.4=h5888daf_0
- libffi=3.4.6=h2dba641_0
- libflac=1.4.3=h59595ed_0
- libgcc=14.2.0=h767d61c_2
- libgcc-ng=14.2.0=h69a702a_2
- libgcrypt-lib=1.11.0=hb9d3cd8_2
- libgdal=3.6.4=hd54c316_5
- libgettextpo=0.23.1=h5888daf_0
- libgettextpo-devel=0.23.1=h5888daf_0
- libgfortran=14.2.0=h69a702a_2
- libgfortran-ng=14.2.0=h69a702a_2
- libgfortran5=14.2.0=hf1ad2bd_2
- libglib=2.78.1=hebfc3b9_0
- libgomp=14.2.0=h767d61c_2
- libgpg-error=1.51=hbd13f7d_1
- libiconv=1.18=h4ce23a2_1
- libjpeg-turbo=2.1.5.1=hd590300_1
- libkml=1.3.0=hf539b9f_1021
- liblapack=3.9.0=31_h7ac8fdf_openblas
- libllvm15=15.0.7=h5cf9203_3
- liblzma=5.6.4=hb9d3cd8_0
- liblzma-devel=5.6.4=hb9d3cd8_0
- libnetcdf=4.9.2=nompi_h7e745eb_109
- libnghttp2=1.58.0=h47da74e_0
- libnsl=2.0.1=hd590300_0
- libogg=1.3.5=h4ab18f5_0
- libopenblas=0.3.29=pthreads_h94d23a6_0
- libopus=1.3.1=h7f98852_1
- libpng=1.6.47=h943b412_0
- libpq=15.4=hfc447b1_2
- libpysal=4.12.1=pyhd8ed1ab_1
- librttopo=1.1.0=h0d5128d_13
- libsndfile=1.2.2=hc60ed4a_1
- libsodium=1.0.20=h4ab18f5_0
- libspatialindex=2.1.0=he57a185_0
- libspatialite=5.0.1=hca56755_27
- libsqlite=3.49.1=hee588c1_2
- libssh2=1.11.0=h0841786_0
- libstdcxx=14.2.0=h8f9b012_2
- libstdcxx-ng=14.2.0=h4852527_2
- libsystemd0=256.9=h2774228_0
- libtiff=4.5.1=h8b53f26_1
- libuuid=2.38.1=h0b41bf4_0
- libvorbis=1.3.7=h9c3ff4c_0
- libwebp-base=1.5.0=h851e524_0
- libxcb=1.15=h0b41bf4_0
- libxkbcommon=1.6.0=h5d7e998_0
- libxml2=2.11.5=h0d562d8_0
- libzip=1.10.1=h2629f0a_3
- libzlib=1.3.1=hb9d3cd8_2
- lz4-c=1.9.4=hcb278e6_0
- mapclassify=2.8.1=pyhd8ed1ab_1
- markupsafe=3.0.2=py310h89163eb_1
- matplotlib=3.9.1=py310hff52083_1
- matplotlib-base=3.9.1=py310hf02ac8c_2
- matplotlib-inline=0.1.7=pyhd8ed1ab_1
- mistune=3.1.3=pyh29332c3_0
- mpg123=1.32.9=hc50e24c_0
- munkres=1.1.4=pyh9f0ad1d_0
- mysql-common=8.0.33=hf1915f5_6
- mysql-libs=8.0.33=hca2cd23_6
- nbclient=0.10.2=pyhd8ed1ab_0
- nbconvert-core=7.16.6=pyh29332c3_0
- nbformat=5.10.4=pyhd8ed1ab_1
- ncurses=6.5=h2d0b736_3
- nest-asyncio=1.6.0=pyhd8ed1ab_1
- networkx=3.4.2=pyh267e887_2
- notebook=7.3.3=pyhd8ed1ab_0
- notebook-shim=0.2.4=pyhd8ed1ab_1
- nspr=4.36=h5888daf_0
- nss=3.110=h159eef7_0
- numpy=1.26.4=py310hb13e2d6_0
- openjpeg=2.5.0=hfec8fc6_2
- openssl=3.1.8=h7b32b05_0
- osmnx=2.0.2=ha770c72_1
- osmnx-base=2.0.2=pyhd8ed1ab_1
- overrides=7.7.0=pyhd8ed1ab_1
- packaging=24.2=pyhd8ed1ab_2
- pandas=2.2.3=py310h5eaa309_1
- pandocfilters=1.5.0=pyhd8ed1ab_0
- parso=0.8.4=pyhd8ed1ab_1
- pcre2=10.40=hc3806b6_0
- pexpect=4.9.0=pyhd8ed1ab_1
- pickleshare=0.7.5=pyhd8ed1ab_1004
- pillow=10.0.0=py310h582fbeb_0
- pip=25.0.1=pyh8b19718_0
- pixman=0.44.2=h29eaf8c_0
- pkgutil-resolve-name=1.3.10=pyhd8ed1ab_2
- platformdirs=4.3.7=pyh29332c3_0
- ply=3.11=pyhd8ed1ab_3
- poppler=23.05.0=hd18248d_1
- poppler-data=0.4.12=hd8ed1ab_0
- postgresql=15.4=h8972f4a_2
- proj=9.2.1=ha643af7_0
- prometheus_client=0.21.1=pyhd8ed1ab_0
- prompt-toolkit=3.0.50=pyha770c72_0
- prompt_toolkit=3.0.50=hd8ed1ab_0
- psutil=7.0.0=py310ha75aee5_0
- pthread-stubs=0.4=hb9d3cd8_1002
- ptyprocess=0.7.0=pyhd8ed1ab_1
- pulseaudio-client=16.1=hb77b528_5
- pure_eval=0.2.3=pyhd8ed1ab_1
- pycparser=2.22=pyh29332c3_1
- pygeos=0.14=py310h056c13c_1
- pygments=2.19.1=pyhd8ed1ab_0
- pyogrio=0.10.0=py310hb275d9d_0
- pyparsing=3.2.3=pyhd8ed1ab_1
- pyproj=3.6.1=py310h177c0e2_0
- pyqt=5.15.9=py310h04931ad_5
- pyqt5-sip=12.12.2=py310hc6cd4ac_5
- pysocks=1.7.1=pyha55dd90_7
- python=3.10.13=hd12c33a_0_cpython
- python-dateutil=2.9.0.post0=pyhff2d567_1
- python-fastjsonschema=2.21.1=pyhd8ed1ab_0
- python-json-logger=2.0.7=pyhd8ed1ab_0
- python-tzdata=2025.2=pyhd8ed1ab_0
- python_abi=3.10=5_cp310
- pytz=2024.1=pyhd8ed1ab_0
- pyyaml=6.0.2=py310h89163eb_2
- pyzmq=26.3.0=py310h71f11fc_0
- qhull=2020.2=h434a139_5
- qt-main=5.15.8=h7fe3ca9_15
- rasterio=1.4.3=py310h720536b_0
- readline=8.2=h8c095d6_2
- referencing=0.36.2=pyh29332c3_0
- requests=2.32.3=pyhd8ed1ab_1
- rfc3339-validator=0.1.4=pyhd8ed1ab_1
- rfc3986-validator=0.1.1=pyh9f0ad1d_0
- rio-vrt=0.3.1=pyhd8ed1ab_1
- rpds-py=0.24.0=py310hc1293b2_0
- rtree=1.4.0=pyh11ca60a_1
- s2n=1.3.54=h06160fa_0
- scikit-learn=1.6.1=py310h27f47ee_0
- scipy=1.15.2=py310h1d65ade_0
- send2trash=1.8.3=pyh0d859eb_1
- setuptools=75.8.2=pyhff2d567_0
- shapely=2.0.1=py310h056c13c_1
- sip=6.7.12=py310hc6cd4ac_0
- six=1.17.0=pyhd8ed1ab_0
- snappy=1.2.1=h8bd8927_1
- sniffio=1.3.1=pyhd8ed1ab_1
- soupsieve=2.5=pyhd8ed1ab_1
- sqlite=3.49.1=h9eae976_2
- stack_data=0.6.3=pyhd8ed1ab_1
- terminado=0.18.1=pyh0d859eb_0
- threadpoolctl=3.6.0=pyhecae5ae_0
- tiledb=2.13.2=hd532e3d_0
- tinycss2=1.4.0=pyhd8ed1ab_0
- tk=8.6.13=noxft_h4845f30_101
- toml=0.10.2=pyhd8ed1ab_1
- tomli=2.2.1=pyhd8ed1ab_1
- tornado=6.4.2=py310ha75aee5_0
- tqdm=4.67.1=pyhd8ed1ab_1
- traitlets=5.14.3=pyhd8ed1ab_1
- types-python-dateutil=2.9.0.20241206=pyhd8ed1ab_0
- typing-extensions=4.13.0=h9fa5a19_1
- typing_extensions=4.13.0=pyh29332c3_1
- typing_utils=0.1.0=pyhd8ed1ab_1
- tzcode=2025b=hb9d3cd8_0
- tzdata=2025b=h78e105d_0
- unicodedata2=16.0.0=py310ha75aee5_0
- uri-template=1.3.0=pyhd8ed1ab_1
- uriparser=0.9.8=hac33072_0
- urllib3=2.3.0=pyhd8ed1ab_0
- wcwidth=0.2.13=pyhd8ed1ab_1
- webcolors=24.11.1=pyhd8ed1ab_0
- webencodings=0.5.1=pyhd8ed1ab_3
- websocket-client=1.8.0=pyhd8ed1ab_1
- wheel=0.45.1=pyhd8ed1ab_1
- widgetsnbextension=4.0.13=pyhd8ed1ab_1
- xcb-util=0.4.0=hd590300_1
- xcb-util-image=0.4.0=h8ee46fc_1
- xcb-util-keysyms=0.4.0=h8ee46fc_1
- xcb-util-renderutil=0.3.9=hd590300_1
- xcb-util-wm=0.4.1=h8ee46fc_1
- xerces-c=3.2.4=h8d71039_2
- xkeyboard-config=2.42=h4ab18f5_0
- xorg-kbproto=1.0.7=hb9d3cd8_1003
- xorg-libice=1.1.2=hb9d3cd8_0
- xorg-libsm=1.2.6=he73a12e_0
- xorg-libx11=1.8.9=h8ee46fc_0
- xorg-libxau=1.0.12=hb9d3cd8_0
- xorg-libxdmcp=1.1.5=hb9d3cd8_0
- xorg-libxext=1.3.4=h0b41bf4_2
- xorg-libxrender=0.9.11=hd590300_0
- xorg-renderproto=0.11.1=hb9d3cd8_1003
- xorg-xextproto=7.3.0=hb9d3cd8_1004
- xorg-xf86vidmodeproto=2.3.1=hb9d3cd8_1005
- xorg-xproto=7.0.31=hb9d3cd8_1008
- xyzservices=2025.1.0=pyhd8ed1ab_0
- xz=5.6.4=hbcc6ac9_0
- xz-gpl-tools=5.6.4=hbcc6ac9_0
- xz-tools=5.6.4=hb9d3cd8_0
- yaml=0.2.5=h7f98852_2
- zeromq=4.3.5=h3b0a872_7
- zipp=3.21.0=pyhd8ed1ab_1
- zlib=1.3.1=hb9d3cd8_2
- zstandard=0.23.0=py310ha75aee5_1
- zstd=1.5.7=hb8e6e7a_2
- pip:
- iniconfig==2.1.0
- pluggy==1.5.0
- pytest==8.3.5
prefix: /opt/conda/envs/momepy
| [
"tests/test_shape.py::TestShape::test_FormFactor"
] | [
"tests/test_shape.py::TestShape::test_CourtyardIndex"
] | [
"tests/test_shape.py::TestShape::test_FractalDimension",
"tests/test_shape.py::TestShape::test_VolumeFacadeRatio",
"tests/test_shape.py::TestShape::test_CircularCompactness",
"tests/test_shape.py::TestShape::test_SquareCompactness",
"tests/test_shape.py::TestShape::test_Convexity",
"tests/test_shape.py::TestShape::test_Rectangularity",
"tests/test_shape.py::TestShape::test_ShapeIndex",
"tests/test_shape.py::TestShape::test_Corners",
"tests/test_shape.py::TestShape::test_Squareness",
"tests/test_shape.py::TestShape::test_EquivalentRectangularIndex",
"tests/test_shape.py::TestShape::test_Elongation",
"tests/test_shape.py::TestShape::test_CentroidCorners",
"tests/test_shape.py::TestShape::test_Linearity",
"tests/test_shape.py::TestShape::test_CompactnessWeightedAxis",
"tests/test_shape.py::TestShape::test__circle_area"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,936 | 645 | [
"momepy/shape.py"
] |
|
encode__starlette-1395 | 9d686a7125131fe026071d04e0d0e0a726e1afc5 | 2022-01-06 12:25:59 | 9d282a937c968b6b3068730af2c8967aec80b736 | tomchristie: Okay, so forgetting for a moment about `1xx`, `204`, `304`, here's a sensible set of test cases that I can think of wrt. setting `Content-Length`...
* `Response()` - Regular empty response. `Content-Length: 0` (`RedirectResponse` is a good real-world example of this case)
* `Response(content='...')` - Regular non-empty response. `Content-Length: x`
* `FileResponse(...)` - File response, unknown length. `Transfer-Encoding: chunked`.
* `FileResponse(..., stat_result=...)` - File response, known length. `Content-Length: x`
* `StreamingResponse(...)` - Streaming response, unknown length. `Transfer-Encoding: chunked`
* `StreamingResponse(..., headers={"Content-Length": "123"})` - Streaming response, known length. `Content-Length: x`
For `Transfer-Encoding: chunked` cases it's also potentially okay to just omit the header, since I *think* the ASGI server is responsible for adding that, but I've not fully verified that.
tomchristie: I've retitled this PR to be more representative of the change.
Kludex: Expressing the thoughts I've shared on Gitter here as well:
I need to be sure that the response class is not `StreamingResponse` or `FileResponse` before adding the `Content-Length: 0`, because those four cases are already being handled now (file response unknown size, file response known size, streaming response known size, and streaming response unknown size).
I don't have (or I can't see) any attribute I can check to be sure it's not a "Transfer-Encoding: chunked" on the at the `init_headers()` point.
I've added a conditional on the `Response.init_headers()` to check if the response class was one of those two before adding the `content-length: 0` headers... Can we do better?
Kludex: Updated the solution to check if body is present on the response. If it's not, then it doesn't add the `Content-Lenght: 0` headers.
Kludex: For future reference, some discussions about this PR can be retrieved on Gitter: https://gitter.im/encode/community?at=61d6e204526fb77b3166a445
Kludex: I've removed the period at the end to squash the commit.
Thanks @tomchristie :) | diff --git a/starlette/responses.py b/starlette/responses.py
index ffde4b9..da765cf 100644
--- a/starlette/responses.py
+++ b/starlette/responses.py
@@ -70,8 +70,8 @@ class Response:
populate_content_length = b"content-length" not in keys
populate_content_type = b"content-type" not in keys
- body = getattr(self, "body", b"")
- if body and populate_content_length:
+ body = getattr(self, "body", None)
+ if body is not None and populate_content_length:
content_length = str(len(body))
raw_headers.append((b"content-length", content_length.encode("latin-1")))
diff --git a/starlette/staticfiles.py b/starlette/staticfiles.py
index 76e4353..bd4d8bc 100644
--- a/starlette/staticfiles.py
+++ b/starlette/staticfiles.py
@@ -100,7 +100,7 @@ class StaticFiles:
def get_path(self, scope: Scope) -> str:
"""
Given the ASGI scope, return the `path` string to serve up,
- with OS specific path seperators, and any '..', '.' components removed.
+ with OS specific path separators, and any '..', '.' components removed.
"""
return os.path.normpath(os.path.join(*scope["path"].split("/")))
| Missing content-length header field in some responses
### Checklist
<!-- Please make sure you check all these items before submitting your bug report. -->
- [x] The bug is reproducible against the latest release and/or `master`.
- [x] There are no similar issues or pull requests to fix it yet.
### Describe the bug
The Content-Length header field is not set for cases where body is empty. In some cases this seems to not be according to the HTTP/1.1 spec and creates troubles when using for example traefik as a proxy in front of a starlette-based backend.
See this issue for details: https://github.com/traefik/traefik/issues/4456
Specifically, the final conclusion: https://github.com/traefik/traefik/issues/4456#issuecomment-593539169
### To reproduce
```python
>>> from starlette.responses import RedirectResponse
>>> RedirectResponse(url="/", status_code=302).headers
MutableHeaders({'location': '/'})
```
Header has not content-length field.
### Expected behavior
```python
>>> from starlette.responses import RedirectResponse
>>> RedirectResponse(url="/", status_code=302).headers
MutableHeaders({'content-length': '0', 'location': '/'})
```
I expect there to be a content-length field specifying zero length
### Actual behavior
```python
>>> from starlette.responses import RedirectResponse
>>> RedirectResponse(url="/", status_code=302).headers
MutableHeaders({'location': '/'})
```
Header has no content-length field.
### Debugging material
N/A
### Environment
- OS: Linux (WSL2)
- Python version: 3.8.2
- Starlette version: 0.13.6
### Additional context
This bug is probably also present for other type of responses (other status-codes). Last paragraph (in bold) from https://tools.ietf.org/html/rfc7230#section-3.3 is of interest:
> 3.3. Message Body
>
> The message body (if any) of an HTTP message is used to carry the
> payload body of that request or response. The message body is
> identical to the payload body unless a transfer coding has been
> applied, as described in Section 3.3.1.
>
> message-body = *OCTET
>
> The rules for when a message body is allowed in a message differ for
> requests and responses.
>
> The presence of a message body in a request is signaled by a
> Content-Length or Transfer-Encoding header field. Request message
> framing is independent of method semantics, even if the method does
> not define any use for a message body.
>
> The presence of a message body in a response depends on both the
> request method to which it is responding and the response status code
> (Section 3.1.2). Responses to the HEAD request method (Section 4.3.2
> of [RFC7231]) never include a message body because the associated
> response header fields (e.g., Transfer-Encoding, Content-Length,
> etc.), if present, indicate only what their values would have been if
> the request method had been GET (Section 4.3.1 of [RFC7231]). 2xx
> (Successful) responses to a CONNECT request method (Section 4.3.6 of
> [RFC7231]) switch to tunnel mode instead of having a message body.
> **All 1xx (Informational), 204 (No Content), and 304 (Not Modified)
> responses do not include a message body. All other responses do
> include a message body, although the body might be of zero length.** | encode/starlette | diff --git a/tests/test_responses.py b/tests/test_responses.py
index baba549..150fe47 100644
--- a/tests/test_responses.py
+++ b/tests/test_responses.py
@@ -13,6 +13,7 @@ from starlette.responses import (
Response,
StreamingResponse,
)
+from starlette.testclient import TestClient
def test_text_response(test_client_factory):
@@ -73,6 +74,20 @@ def test_quoting_redirect_response(test_client_factory):
assert response.url == "http://testserver/I%20%E2%99%A5%20Starlette/"
+def test_redirect_response_content_length_header(test_client_factory):
+ async def app(scope, receive, send):
+ if scope["path"] == "/":
+ response = Response("hello", media_type="text/plain") # pragma: nocover
+ else:
+ response = RedirectResponse("/")
+ await response(scope, receive, send)
+
+ client: TestClient = test_client_factory(app)
+ response = client.request("GET", "/redirect", allow_redirects=False)
+ assert response.url == "http://testserver/redirect"
+ assert response.headers["content-length"] == "0"
+
+
def test_streaming_response(test_client_factory):
filled_by_bg_task = ""
@@ -309,3 +324,45 @@ def test_head_method(test_client_factory):
client = test_client_factory(app)
response = client.head("/")
assert response.text == ""
+
+
+def test_empty_response(test_client_factory):
+ app = Response()
+ client: TestClient = test_client_factory(app)
+ response = client.get("/")
+ assert response.headers["content-length"] == "0"
+
+
+def test_non_empty_response(test_client_factory):
+ app = Response(content="hi")
+ client: TestClient = test_client_factory(app)
+ response = client.get("/")
+ assert response.headers["content-length"] == "2"
+
+
+def test_file_response_known_size(tmpdir, test_client_factory):
+ path = os.path.join(tmpdir, "xyz")
+ content = b"<file content>" * 1000
+ with open(path, "wb") as file:
+ file.write(content)
+
+ app = FileResponse(path=path, filename="example.png")
+ client: TestClient = test_client_factory(app)
+ response = client.get("/")
+ assert response.headers["content-length"] == str(len(content))
+
+
+def test_streaming_response_unknown_size(test_client_factory):
+ app = StreamingResponse(content=iter(["hello", "world"]))
+ client: TestClient = test_client_factory(app)
+ response = client.get("/")
+ assert "content-length" not in response.headers
+
+
+def test_streaming_response_known_size(test_client_factory):
+ app = StreamingResponse(
+ content=iter(["hello", "world"]), headers={"content-length": "10"}
+ )
+ client: TestClient = test_client_factory(app)
+ response = client.get("/")
+ assert response.headers["content-length"] == "10"
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 0.17 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[full]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.6",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | aiocontextvars==0.2.2
aiosqlite==0.17.0
anyio==3.6.2
async-generator==1.10
attrs==22.2.0
autoflake==1.4
black==21.12b0
bleach==4.1.0
certifi==2021.5.30
cffi==1.15.1
charset-normalizer==2.0.12
click==8.0.4
colorama==0.4.5
contextlib2==21.6.0
contextvars==2.4
coverage==6.2
cryptography==40.0.2
databases==0.5.3
dataclasses==0.8
docutils==0.18.1
flake8==4.0.1
ghp-import==2.1.0
greenlet==2.0.2
idna==3.10
immutables==0.19
importlib-metadata==4.2.0
importlib-resources==5.4.0
iniconfig==1.1.1
isort==5.10.1
itsdangerous==2.0.1
jeepney==0.7.1
Jinja2==3.0.3
keyring==23.4.1
Markdown==3.3.4
MarkupSafe==2.0.1
mccabe==0.6.1
mergedeep==1.3.4
mkautodoc==0.1.0
mkdocs==1.2.3
mkdocs-material==8.1.3
mkdocs-material-extensions==1.0.3
mypy==0.930
mypy-extensions==1.0.0
outcome==1.1.0
packaging==21.3
pathspec==0.9.0
pkginfo==1.10.0
platformdirs==2.4.0
pluggy==1.0.0
py==1.11.0
pycodestyle==2.8.0
pycparser==2.21
pyflakes==2.4.0
Pygments==2.14.0
pymdown-extensions==9.1
pyparsing==3.1.4
pytest==6.2.5
python-dateutil==2.9.0.post0
python-multipart==0.0.5
PyYAML==6.0.1
pyyaml_env_tag==0.1
readme-renderer==34.0
requests==2.27.1
requests-toolbelt==1.0.0
rfc3986==1.5.0
SecretStorage==3.3.3
six==1.17.0
sniffio==1.2.0
sortedcontainers==2.4.0
SQLAlchemy==1.4.54
-e git+https://github.com/encode/starlette.git@9d686a7125131fe026071d04e0d0e0a726e1afc5#egg=starlette
toml==0.10.2
tomli==1.2.3
tqdm==4.64.1
trio==0.19.0
twine==3.7.1
typed-ast==1.5.5
types-contextvars==2.4.0
types-dataclasses==0.6.2
types-PyYAML==6.0.1
types-requests==2.26.3
typing_extensions==4.1.1
urllib3==1.26.20
watchdog==2.3.1
webencodings==0.5.1
zipp==3.6.0
| name: starlette
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2021.5.30=py36h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.3=he6710b0_2
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=21.2.2=py36h06a4308_0
- python=3.6.13=h12debd9_1
- readline=8.2=h5eee18b_0
- setuptools=58.0.4=py36h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.37.1=pyhd3eb1b0_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- aiocontextvars==0.2.2
- aiosqlite==0.17.0
- anyio==3.6.2
- async-generator==1.10
- attrs==22.2.0
- autoflake==1.4
- black==21.12b0
- bleach==4.1.0
- cffi==1.15.1
- charset-normalizer==2.0.12
- click==8.0.4
- colorama==0.4.5
- contextlib2==21.6.0
- contextvars==2.4
- coverage==6.2
- cryptography==40.0.2
- databases==0.5.3
- dataclasses==0.8
- docutils==0.18.1
- flake8==4.0.1
- ghp-import==2.1.0
- greenlet==2.0.2
- idna==3.10
- immutables==0.19
- importlib-metadata==4.2.0
- importlib-resources==5.4.0
- iniconfig==1.1.1
- isort==5.10.1
- itsdangerous==2.0.1
- jeepney==0.7.1
- jinja2==3.0.3
- keyring==23.4.1
- markdown==3.3.4
- markupsafe==2.0.1
- mccabe==0.6.1
- mergedeep==1.3.4
- mkautodoc==0.1.0
- mkdocs==1.2.3
- mkdocs-material==8.1.3
- mkdocs-material-extensions==1.0.3
- mypy==0.930
- mypy-extensions==1.0.0
- outcome==1.1.0
- packaging==21.3
- pathspec==0.9.0
- pkginfo==1.10.0
- platformdirs==2.4.0
- pluggy==1.0.0
- py==1.11.0
- pycodestyle==2.8.0
- pycparser==2.21
- pyflakes==2.4.0
- pygments==2.14.0
- pymdown-extensions==9.1
- pyparsing==3.1.4
- pytest==6.2.5
- python-dateutil==2.9.0.post0
- python-multipart==0.0.5
- pyyaml==6.0.1
- pyyaml-env-tag==0.1
- readme-renderer==34.0
- requests==2.27.1
- requests-toolbelt==1.0.0
- rfc3986==1.5.0
- secretstorage==3.3.3
- six==1.17.0
- sniffio==1.2.0
- sortedcontainers==2.4.0
- sqlalchemy==1.4.54
- toml==0.10.2
- tomli==1.2.3
- tqdm==4.64.1
- trio==0.19.0
- twine==3.7.1
- typed-ast==1.5.5
- types-contextvars==2.4.0
- types-dataclasses==0.6.2
- types-pyyaml==6.0.1
- types-requests==2.26.3
- typing-extensions==4.1.1
- urllib3==1.26.20
- watchdog==2.3.1
- webencodings==0.5.1
- zipp==3.6.0
prefix: /opt/conda/envs/starlette
| [
"tests/test_responses.py::test_redirect_response_content_length_header[asyncio]",
"tests/test_responses.py::test_redirect_response_content_length_header[trio]",
"tests/test_responses.py::test_empty_response[asyncio]",
"tests/test_responses.py::test_empty_response[trio]"
] | [] | [
"tests/test_responses.py::test_text_response[asyncio]",
"tests/test_responses.py::test_text_response[trio]",
"tests/test_responses.py::test_bytes_response[asyncio]",
"tests/test_responses.py::test_bytes_response[trio]",
"tests/test_responses.py::test_json_none_response[asyncio]",
"tests/test_responses.py::test_json_none_response[trio]",
"tests/test_responses.py::test_redirect_response[asyncio]",
"tests/test_responses.py::test_redirect_response[trio]",
"tests/test_responses.py::test_quoting_redirect_response[asyncio]",
"tests/test_responses.py::test_quoting_redirect_response[trio]",
"tests/test_responses.py::test_streaming_response[asyncio]",
"tests/test_responses.py::test_streaming_response[trio]",
"tests/test_responses.py::test_streaming_response_custom_iterator[asyncio]",
"tests/test_responses.py::test_streaming_response_custom_iterator[trio]",
"tests/test_responses.py::test_streaming_response_custom_iterable[asyncio]",
"tests/test_responses.py::test_streaming_response_custom_iterable[trio]",
"tests/test_responses.py::test_sync_streaming_response[asyncio]",
"tests/test_responses.py::test_sync_streaming_response[trio]",
"tests/test_responses.py::test_response_headers[asyncio]",
"tests/test_responses.py::test_response_headers[trio]",
"tests/test_responses.py::test_response_phrase[asyncio]",
"tests/test_responses.py::test_response_phrase[trio]",
"tests/test_responses.py::test_file_response[asyncio]",
"tests/test_responses.py::test_file_response[trio]",
"tests/test_responses.py::test_file_response_with_directory_raises_error[asyncio]",
"tests/test_responses.py::test_file_response_with_directory_raises_error[trio]",
"tests/test_responses.py::test_file_response_with_missing_file_raises_error[asyncio]",
"tests/test_responses.py::test_file_response_with_missing_file_raises_error[trio]",
"tests/test_responses.py::test_file_response_with_chinese_filename[asyncio]",
"tests/test_responses.py::test_file_response_with_chinese_filename[trio]",
"tests/test_responses.py::test_set_cookie[asyncio]",
"tests/test_responses.py::test_set_cookie[trio]",
"tests/test_responses.py::test_delete_cookie[asyncio]",
"tests/test_responses.py::test_delete_cookie[trio]",
"tests/test_responses.py::test_populate_headers[asyncio]",
"tests/test_responses.py::test_populate_headers[trio]",
"tests/test_responses.py::test_head_method[asyncio]",
"tests/test_responses.py::test_head_method[trio]",
"tests/test_responses.py::test_non_empty_response[asyncio]",
"tests/test_responses.py::test_non_empty_response[trio]",
"tests/test_responses.py::test_file_response_known_size[asyncio]",
"tests/test_responses.py::test_file_response_known_size[trio]",
"tests/test_responses.py::test_streaming_response_unknown_size[asyncio]",
"tests/test_responses.py::test_streaming_response_unknown_size[trio]",
"tests/test_responses.py::test_streaming_response_known_size[asyncio]",
"tests/test_responses.py::test_streaming_response_known_size[trio]"
] | [] | BSD 3-Clause "New" or "Revised" License | 11,945 | 324 | [
"starlette/responses.py",
"starlette/staticfiles.py"
] |
pynamodb__PynamoDB-1013 | 62c60e22553c825c1a9dfa072aa8457e7cedea39 | 2022-01-06 18:02:20 | 5136edde90dade15f9b376edbfcd9f0ea7498171 | diff --git a/pynamodb/attributes.py b/pynamodb/attributes.py
index cfd9a39..7b116d2 100644
--- a/pynamodb/attributes.py
+++ b/pynamodb/attributes.py
@@ -143,17 +143,9 @@ class Attribute(Generic[_T]):
# Condition Expression Support
def __eq__(self, other: Any) -> 'Comparison': # type: ignore[override]
- if isinstance(other, MapAttribute) and other._is_attribute_container():
- return Path(self).__eq__(other)
- if other is None or isinstance(other, Attribute): # handle object identity comparison
- return self is other # type: ignore
return Path(self).__eq__(other)
def __ne__(self, other: Any) -> 'Comparison': # type: ignore[override]
- if isinstance(other, MapAttribute) and other._is_attribute_container():
- return Path(self).__ne__(other)
- if other is None or isinstance(other, Attribute): # handle object identity comparison
- return self is not other # type: ignore
return Path(self).__ne__(other)
def __lt__(self, other: Any) -> 'Comparison':
@@ -868,14 +860,34 @@ class MapAttribute(Attribute[Mapping[_KT, _VT]], AttributeContainer):
def __eq__(self, other: Any) -> 'Comparison': # type: ignore[override]
if self._is_attribute_container():
- return self is other # type: ignore
+ return NotImplemented
return Attribute.__eq__(self, other)
def __ne__(self, other: Any) -> 'Comparison': # type: ignore[override]
if self._is_attribute_container():
- return self is not other # type: ignore
+ return NotImplemented
return Attribute.__ne__(self, other)
+ def __lt__(self, other: Any) -> 'Comparison':
+ if self._is_attribute_container():
+ return NotImplemented
+ return Attribute.__lt__(self, other)
+
+ def __le__(self, other: Any) -> 'Comparison':
+ if self._is_attribute_container():
+ return NotImplemented
+ return Attribute.__le__(self, other)
+
+ def __gt__(self, other: Any) -> 'Comparison':
+ if self._is_attribute_container():
+ return NotImplemented
+ return Attribute.__gt__(self, other)
+
+ def __ge__(self, other: Any) -> 'Comparison':
+ if self._is_attribute_container():
+ return NotImplemented
+ return Attribute.__ge__(self, other)
+
def __iter__(self):
if self._is_attribute_container():
return iter(self.attribute_values)
| Some expressions require conversion to Path or else they won't work
Looks like doing something like this will result in a boolean result (instead of an pynamodb.expressions.condition.Comparison)
```
(RModel.base_price != RModel.res_price.amount)
```
The workaround is to use Path() like this
```
(Path(RModel.base_price) != Path(RModel.res_price.amount))
``` | pynamodb/PynamoDB | diff --git a/tests/test_expressions.py b/tests/test_expressions.py
index a683f6b..d9456e5 100644
--- a/tests/test_expressions.py
+++ b/tests/test_expressions.py
@@ -340,6 +340,18 @@ class ConditionExpressionTestCase(TestCase):
assert self.placeholder_names == {'foo': '#0'}
assert self.expression_attribute_values == {':0': {'M': {'bar': {'S': 'baz'}}}}
+ def test_map_comparison_rhs(self):
+ # Simulate initialization from inside an AttributeContainer
+ my_map_attribute = MapAttribute[str, str](attr_name='foo')
+ my_map_attribute._make_attribute()
+ my_map_attribute._update_attribute_paths(my_map_attribute.attr_name)
+
+ condition = MapAttribute(bar='baz') == my_map_attribute
+ expression = condition.serialize(self.placeholder_names, self.expression_attribute_values)
+ assert expression == "#0 = :0"
+ assert self.placeholder_names == {'foo': '#0'}
+ assert self.expression_attribute_values == {':0': {'M': {'bar': {'S': 'baz'}}}}
+
def test_list_comparison(self):
condition = ListAttribute(attr_name='foo') == ['bar', 'baz']
expression = condition.serialize(self.placeholder_names, self.expression_attribute_values)
@@ -409,6 +421,13 @@ class ConditionExpressionTestCase(TestCase):
with self.assertRaises(AttributeError):
_ = my_map_attribute['missing_attribute'] == 'baz'
+ def test_attribute_comparison(self):
+ condition = self.attribute == UnicodeAttribute(attr_name='bar')
+ expression = condition.serialize(self.placeholder_names, self.expression_attribute_values)
+ assert expression == "#0 = #1"
+ assert self.placeholder_names == {'foo': '#0', 'bar': '#1'}
+ assert self.expression_attribute_values == {}
+
class UpdateExpressionTestCase(TestCase):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 5.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[signals]",
"log_parser": "parse_log_pytest_v2",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"docs/requirements.txt"
],
"test_cmd": "pytest -xvs"
} | alabaster==0.7.16
babel==2.17.0
blinker==1.9.0
botocore==1.37.23
certifi==2025.1.31
charset-normalizer==3.4.1
docutils==0.21.2
exceptiongroup==1.2.2
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
jmespath==1.0.1
MarkupSafe==3.0.2
packaging==24.2
pluggy==1.5.0
Pygments==2.19.1
-e git+https://github.com/pynamodb/PynamoDB.git@62c60e22553c825c1a9dfa072aa8457e7cedea39#egg=pynamodb
pytest==8.3.5
python-dateutil==2.9.0.post0
requests==2.32.3
six==1.17.0
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-rtd-theme==0.4.3
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
tomli==2.2.1
urllib3==1.26.20
zipp==3.21.0
| name: PynamoDB
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- blinker==1.9.0
- botocore==1.37.23
- certifi==2025.1.31
- charset-normalizer==3.4.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- jmespath==1.0.1
- markupsafe==3.0.2
- packaging==24.2
- pluggy==1.5.0
- pygments==2.19.1
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- requests==2.32.3
- six==1.17.0
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinx-rtd-theme==0.4.3
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- tomli==2.2.1
- urllib3==1.26.20
- zipp==3.21.0
prefix: /opt/conda/envs/PynamoDB
| [
"tests/test_expressions.py::ConditionExpressionTestCase::test_attribute_comparison",
"tests/test_expressions.py::ConditionExpressionTestCase::test_begins_with",
"tests/test_expressions.py::ConditionExpressionTestCase::test_between",
"tests/test_expressions.py::ConditionExpressionTestCase::test_compound_logic",
"tests/test_expressions.py::ConditionExpressionTestCase::test_contains",
"tests/test_expressions.py::ConditionExpressionTestCase::test_contains_attribute",
"tests/test_expressions.py::ConditionExpressionTestCase::test_contains_list",
"tests/test_expressions.py::ConditionExpressionTestCase::test_contains_number_set",
"tests/test_expressions.py::ConditionExpressionTestCase::test_contains_string_set",
"tests/test_expressions.py::ConditionExpressionTestCase::test_does_not_exist",
"tests/test_expressions.py::ConditionExpressionTestCase::test_dotted_attribute_name",
"tests/test_expressions.py::ConditionExpressionTestCase::test_double_indexing",
"tests/test_expressions.py::ConditionExpressionTestCase::test_equal",
"tests/test_expressions.py::ConditionExpressionTestCase::test_exists",
"tests/test_expressions.py::ConditionExpressionTestCase::test_greater_than",
"tests/test_expressions.py::ConditionExpressionTestCase::test_greater_than_or_equal",
"tests/test_expressions.py::ConditionExpressionTestCase::test_in",
"tests/test_expressions.py::ConditionExpressionTestCase::test_indexing",
"tests/test_expressions.py::ConditionExpressionTestCase::test_invalid_and",
"tests/test_expressions.py::ConditionExpressionTestCase::test_invalid_indexing",
"tests/test_expressions.py::ConditionExpressionTestCase::test_invalid_or",
"tests/test_expressions.py::ConditionExpressionTestCase::test_invalid_rand",
"tests/test_expressions.py::ConditionExpressionTestCase::test_is_type",
"tests/test_expressions.py::ConditionExpressionTestCase::test_less_than",
"tests/test_expressions.py::ConditionExpressionTestCase::test_less_than_or_equal",
"tests/test_expressions.py::ConditionExpressionTestCase::test_list_comparison",
"tests/test_expressions.py::ConditionExpressionTestCase::test_map_attribute_dereference",
"tests/test_expressions.py::ConditionExpressionTestCase::test_map_attribute_dereference_via_indexing",
"tests/test_expressions.py::ConditionExpressionTestCase::test_map_attribute_dereference_via_indexing_missing_attribute",
"tests/test_expressions.py::ConditionExpressionTestCase::test_map_attribute_indexing",
"tests/test_expressions.py::ConditionExpressionTestCase::test_map_comparison",
"tests/test_expressions.py::ConditionExpressionTestCase::test_map_comparison_rhs",
"tests/test_expressions.py::ConditionExpressionTestCase::test_not",
"tests/test_expressions.py::ConditionExpressionTestCase::test_not_equal",
"tests/test_expressions.py::ConditionExpressionTestCase::test_or",
"tests/test_expressions.py::ConditionExpressionTestCase::test_rand",
"tests/test_expressions.py::ConditionExpressionTestCase::test_size",
"tests/test_expressions.py::ConditionExpressionTestCase::test_sizes",
"tests/test_expressions.py::ConditionExpressionTestCase::test_typed_list_indexing",
"tests/test_expressions.py::UpdateExpressionTestCase::test_add_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_add_action_list",
"tests/test_expressions.py::UpdateExpressionTestCase::test_add_action_serialized",
"tests/test_expressions.py::UpdateExpressionTestCase::test_add_action_set",
"tests/test_expressions.py::UpdateExpressionTestCase::test_append_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_conditional_set_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_decrement_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_decrement_action_value",
"tests/test_expressions.py::UpdateExpressionTestCase::test_delete_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_delete_action_non_set",
"tests/test_expressions.py::UpdateExpressionTestCase::test_delete_action_serialized",
"tests/test_expressions.py::UpdateExpressionTestCase::test_delete_action_set",
"tests/test_expressions.py::UpdateExpressionTestCase::test_increment_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_increment_action_value",
"tests/test_expressions.py::UpdateExpressionTestCase::test_prepend_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_remove_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_remove_action_list_element",
"tests/test_expressions.py::UpdateExpressionTestCase::test_set_action",
"tests/test_expressions.py::UpdateExpressionTestCase::test_set_action_attribute_container",
"tests/test_expressions.py::UpdateExpressionTestCase::test_update",
"tests/test_expressions.py::UpdateExpressionTestCase::test_update_empty",
"tests/test_expressions.py::UpdateExpressionTestCase::test_update_skips_empty_clauses"
] | [] | [
"tests/test_expressions.py::PathTestCase::test_attribute_name",
"tests/test_expressions.py::PathTestCase::test_document_path",
"tests/test_expressions.py::PathTestCase::test_index_attribute_name",
"tests/test_expressions.py::PathTestCase::test_index_document_path",
"tests/test_expressions.py::PathTestCase::test_index_invalid",
"tests/test_expressions.py::PathTestCase::test_index_map_attribute",
"tests/test_expressions.py::ActionTestCase::test_action",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_project_expression_with_attribute_names",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_project_expression_with_document_paths",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_projection_expression",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_projection_expression_invalid_attribute_raises",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_projection_expression_not_a_list",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_projection_expression_repeated_names",
"tests/test_expressions.py::ProjectionExpressionTestCase::test_create_projection_expression_with_attributes",
"tests/test_expressions.py::ConditionExpressionTestCase::test_and"
] | [] | MIT License | 11,947 | 621 | [
"pynamodb/attributes.py"
] |
|
mhostetter__galois-219 | a89fd868478949fe249ff5705d9acf6123441e3c | 2022-01-06 20:30:12 | d94c3b61dfb31127990d5811077e33861bc4953a | codecov[bot]: # [Codecov](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) Report
> Merging [#219](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) (2042edd) into [master](https://codecov.io/gh/mhostetter/galois/commit/a89fd868478949fe249ff5705d9acf6123441e3c?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) (a89fd86) will **increase** coverage by `0.04%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter)
```diff
@@ Coverage Diff @@
## master #219 +/- ##
==========================================
+ Coverage 92.87% 92.92% +0.04%
==========================================
Files 38 38
Lines 4366 4367 +1
==========================================
+ Hits 4055 4058 +3
+ Misses 311 309 -2
```
| [Impacted Files](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter) | Coverage Δ | |
|---|---|---|
| [galois/\_polys/\_factor.py](https://codecov.io/gh/mhostetter/galois/pull/219/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19wb2x5cy9fZmFjdG9yLnB5) | `98.33% <100.00%> (ø)` | |
| [galois/\_polys/\_poly.py](https://codecov.io/gh/mhostetter/galois/pull/219/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19wb2x5cy9fcG9seS5weQ==) | `94.14% <100.00%> (+0.01%)` | :arrow_up: |
| [galois/\_fields/\_array.py](https://codecov.io/gh/mhostetter/galois/pull/219/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19maWVsZHMvX2FycmF5LnB5) | `94.79% <0.00%> (+0.34%)` | :arrow_up: |
| [galois/\_fields/\_ufuncs.py](https://codecov.io/gh/mhostetter/galois/pull/219/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter#diff-Z2Fsb2lzL19maWVsZHMvX3VmdW5jcy5weQ==) | `89.24% <0.00%> (+0.63%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter). Last update [a89fd86...2042edd](https://codecov.io/gh/mhostetter/galois/pull/219?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Matt+Hostetter).
| diff --git a/galois/_polys/_factor.py b/galois/_polys/_factor.py
index 6d25fd82d..693e271ae 100644
--- a/galois/_polys/_factor.py
+++ b/galois/_polys/_factor.py
@@ -129,8 +129,8 @@ def square_free_factorization(poly):
# Step 2: Find all remaining factors (their multiplicities are divisible by p)
if d != one:
- degrees = [degree // p for degree in d.degrees]
- coeffs = d.coeffs ** (field.characteristic**(field.degree - 1)) # The inverse Frobenius automorphism of the coefficients
+ degrees = [degree // p for degree in d.nonzero_degrees]
+ coeffs = d.nonzero_coeffs ** (field.characteristic**(field.degree - 1)) # The inverse Frobenius automorphism of the coefficients
delta = Poly.Degrees(degrees, coeffs=coeffs, field=field) # The p-th root of d(x)
f, m = square_free_factorization(delta)
factors_.extend(f)
diff --git a/galois/_polys/_poly.py b/galois/_polys/_poly.py
index f0082ba15..55161b5e6 100644
--- a/galois/_polys/_poly.py
+++ b/galois/_polys/_poly.py
@@ -133,12 +133,13 @@ class Poly:
# Use the field of the coefficients
field = type(coeffs)
else:
- # Convert coefficients to the specified field (or GF2 if unspecified)
+ # Convert coefficients to the specified field (or GF2 if unspecified), taking into
+ # account negative coefficients
field = GF2 if field is None else field
- if isinstance(coeffs, np.ndarray):
- # Ensure coeffs is an iterable
- coeffs = coeffs.tolist()
- coeffs = field([int(-field(abs(c))) if c < 0 else c for c in coeffs])
+ coeffs = np.array(coeffs, dtype=field.dtypes[-1])
+ idxs = coeffs < 0
+ coeffs = field(np.abs(coeffs))
+ coeffs[idxs] *= -1
return coeffs, field
@@ -451,29 +452,31 @@ class Poly:
GF = galois.GF(2**8)
galois.Poly.Degrees([3,1,0], coeffs=[251,73,185], field=GF)
"""
- coeffs = [1,]*len(degrees) if coeffs is None else coeffs
if not isinstance(degrees, (list, tuple, np.ndarray)):
raise TypeError(f"Argument `degrees` must array-like, not {type(degrees)}.")
- if not isinstance(coeffs, (list, tuple, np.ndarray, FieldArray)):
+ if not isinstance(coeffs, (type(None), list, tuple, np.ndarray, FieldArray)):
raise TypeError(f"Argument `coeffs` must array-like, not {type(coeffs)}.")
if not isinstance(field, (type(None), FieldClass)):
- raise TypeError(f"Argument `field` must be a Galois field array class, not {field}.")
- if isinstance(degrees, (np.ndarray, FieldArray)) and not degrees.ndim <= 1:
+ raise TypeError(f"Argument `field` must be a Galois field array class, not {type(field)}.")
+
+ degrees = np.array(degrees, dtype=np.int64)
+ coeffs = [1,]*len(degrees) if coeffs is None else coeffs
+ coeffs, field = cls._convert_coeffs(coeffs, field)
+
+ if not degrees.ndim <= 1:
raise ValueError(f"Argument `degrees` can have dimension at most 1, not {degrees.ndim}.")
- if isinstance(coeffs, (np.ndarray, FieldArray)) and not coeffs.ndim <= 1:
- raise ValueError(f"Argument `coeffs` can have dimension at most 1, not {coeffs.ndim}.")
- if not all(degree >= 0 for degree in degrees):
+ if not degrees.size == np.unique(degrees).size:
+ raise ValueError(f"Argument `degrees` must have unique entries, not {degrees}.")
+ if not np.all(degrees >= 0):
raise ValueError(f"Argument `degrees` must have non-negative values, not {degrees}.")
- if not len(degrees) == len(coeffs):
- raise ValueError(f"Arguments `degrees` and `coeffs` must have the same length, not {len(degrees)} and {len(coeffs)}.")
-
+ if not coeffs.ndim <= 1:
+ raise ValueError(f"Argument `coeffs` can have dimension at most 1, not {coeffs.ndim}.")
+ if not degrees.size == coeffs.size:
+ raise ValueError(f"Arguments `degrees` and `coeffs` must have the same length, not {degrees.size} and {coeffs.size}.")
+ # No nonzero degrees means it's the zero polynomial
if len(degrees) == 0:
- degrees = [0]
- coeffs = [0]
- dtype = np.int64 if max(degrees) <= np.iinfo(np.int64).max else np.object_
- degrees = np.array(degrees, dtype=dtype)
- coeffs, field = cls._convert_coeffs(coeffs, field)
+ degrees, coeffs = np.array([0]), field([0])
if field is GF2:
if len(degrees) < SPARSE_VS_BINARY_POLY_FACTOR*max(degrees):
| `Poly.Degrees` with duplicate degrees produces incorrect polynomial
An issue was peripherally discovered in #212 where `Poly.Degrees` produces the wrong polynomial if duplicate degrees are provided.
```python
# Wrong answer
In [5]: galois.Poly.Degrees([256, 1, 1, 1, 0])
Out[5]: Poly(x^256 + x^2 + x + 1, GF(2))
In [6]: galois.Poly.Degrees([256, 1, 0])
Out[6]: Poly(x^256 + x + 1, GF(2))
```
The solution is to throw a `ValueError` if duplicates are passed in. | mhostetter/galois | diff --git a/tests/polys/test_constructors.py b/tests/polys/test_constructors.py
index c7146da19..15eaa3a58 100644
--- a/tests/polys/test_constructors.py
+++ b/tests/polys/test_constructors.py
@@ -180,12 +180,14 @@ def test_degrees_exceptions():
with pytest.raises(ValueError):
galois.Poly.Degrees(np.atleast_2d(degrees), coeffs=coeffs, field=GF)
+ with pytest.raises(ValueError):
+ galois.Poly.Degrees([5, 1, 1, 0], coeffs=[1, 2, 2, 1], field=GF)
+ with pytest.raises(ValueError):
+ galois.Poly.Degrees([5, -3, 0], coeffs=coeffs, field=GF)
with pytest.raises(ValueError):
galois.Poly.Degrees(degrees, coeffs=np.atleast_2d(coeffs), field=GF)
with pytest.raises(ValueError):
galois.Poly.Degrees([7] + degrees, coeffs=coeffs, field=GF)
- with pytest.raises(ValueError):
- galois.Poly.Degrees([5, -3, 0], coeffs=coeffs, field=GF)
@pytest.mark.parametrize("field", FIELDS)
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_issue_reference",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 2
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | astroid==3.3.9
coverage==7.8.0
dill==0.3.9
exceptiongroup==1.2.2
-e git+https://github.com/mhostetter/galois.git@a89fd868478949fe249ff5705d9acf6123441e3c#egg=galois
iniconfig==2.1.0
isort==6.0.1
llvmlite==0.37.0
mccabe==0.7.0
numba==0.54.1
numpy==1.20.3
packaging==24.2
platformdirs==4.3.7
pluggy==1.5.0
py-cpuinfo==9.0.0
pylint==3.3.6
pytest==8.3.5
pytest-benchmark==5.1.0
pytest-cov==6.0.0
tomli==2.2.1
tomlkit==0.13.2
typing_extensions==4.13.0
| name: galois
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- astroid==3.3.9
- coverage==7.8.0
- dill==0.3.9
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- isort==6.0.1
- llvmlite==0.37.0
- mccabe==0.7.0
- numba==0.54.1
- numpy==1.20.3
- packaging==24.2
- platformdirs==4.3.7
- pluggy==1.5.0
- py-cpuinfo==9.0.0
- pylint==3.3.6
- pytest==8.3.5
- pytest-benchmark==5.1.0
- pytest-cov==6.0.0
- tomli==2.2.1
- tomlkit==0.13.2
- typing-extensions==4.13.0
prefix: /opt/conda/envs/galois
| [
"tests/polys/test_constructors.py::test_degrees_exceptions"
] | [] | [
"tests/polys/test_constructors.py::test_zero_exceptions",
"tests/polys/test_constructors.py::test_zero[GF2]",
"tests/polys/test_constructors.py::test_zero[GF31]",
"tests/polys/test_constructors.py::test_zero[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_zero[GF2_8]",
"tests/polys/test_constructors.py::test_zero[GF2_100]",
"tests/polys/test_constructors.py::test_zero[GF7_3]",
"tests/polys/test_constructors.py::test_zero[GF109987_4]",
"tests/polys/test_constructors.py::test_one_exceptions",
"tests/polys/test_constructors.py::test_one[GF2]",
"tests/polys/test_constructors.py::test_one[GF31]",
"tests/polys/test_constructors.py::test_one[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_one[GF2_8]",
"tests/polys/test_constructors.py::test_one[GF2_100]",
"tests/polys/test_constructors.py::test_one[GF7_3]",
"tests/polys/test_constructors.py::test_one[GF109987_4]",
"tests/polys/test_constructors.py::test_identity_exceptions",
"tests/polys/test_constructors.py::test_identity[GF2]",
"tests/polys/test_constructors.py::test_identity[GF31]",
"tests/polys/test_constructors.py::test_identity[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_identity[GF2_8]",
"tests/polys/test_constructors.py::test_identity[GF2_100]",
"tests/polys/test_constructors.py::test_identity[GF7_3]",
"tests/polys/test_constructors.py::test_identity[GF109987_4]",
"tests/polys/test_constructors.py::test_random_exceptions",
"tests/polys/test_constructors.py::test_random[None-GF2]",
"tests/polys/test_constructors.py::test_random[None-GF31]",
"tests/polys/test_constructors.py::test_random[None-GF36893488147419103183]",
"tests/polys/test_constructors.py::test_random[None-GF2_8]",
"tests/polys/test_constructors.py::test_random[None-GF2_100]",
"tests/polys/test_constructors.py::test_random[None-GF7_3]",
"tests/polys/test_constructors.py::test_random[None-GF109987_4]",
"tests/polys/test_constructors.py::test_random[42-GF2]",
"tests/polys/test_constructors.py::test_random[42-GF31]",
"tests/polys/test_constructors.py::test_random[42-GF36893488147419103183]",
"tests/polys/test_constructors.py::test_random[42-GF2_8]",
"tests/polys/test_constructors.py::test_random[42-GF2_100]",
"tests/polys/test_constructors.py::test_random[42-GF7_3]",
"tests/polys/test_constructors.py::test_random[42-GF109987_4]",
"tests/polys/test_constructors.py::test_random[seed2-GF2]",
"tests/polys/test_constructors.py::test_random[seed2-GF31]",
"tests/polys/test_constructors.py::test_random[seed2-GF36893488147419103183]",
"tests/polys/test_constructors.py::test_random[seed2-GF2_8]",
"tests/polys/test_constructors.py::test_random[seed2-GF2_100]",
"tests/polys/test_constructors.py::test_random[seed2-GF7_3]",
"tests/polys/test_constructors.py::test_random[seed2-GF109987_4]",
"tests/polys/test_constructors.py::test_random[seed3-GF2]",
"tests/polys/test_constructors.py::test_random[seed3-GF31]",
"tests/polys/test_constructors.py::test_random[seed3-GF36893488147419103183]",
"tests/polys/test_constructors.py::test_random[seed3-GF2_8]",
"tests/polys/test_constructors.py::test_random[seed3-GF2_100]",
"tests/polys/test_constructors.py::test_random[seed3-GF7_3]",
"tests/polys/test_constructors.py::test_random[seed3-GF109987_4]",
"tests/polys/test_constructors.py::test_random[seed4-GF2]",
"tests/polys/test_constructors.py::test_random[seed4-GF31]",
"tests/polys/test_constructors.py::test_random[seed4-GF36893488147419103183]",
"tests/polys/test_constructors.py::test_random[seed4-GF2_8]",
"tests/polys/test_constructors.py::test_random[seed4-GF2_100]",
"tests/polys/test_constructors.py::test_random[seed4-GF7_3]",
"tests/polys/test_constructors.py::test_random[seed4-GF109987_4]",
"tests/polys/test_constructors.py::test_integer_exceptions",
"tests/polys/test_constructors.py::test_integer[GF2]",
"tests/polys/test_constructors.py::test_integer[GF31]",
"tests/polys/test_constructors.py::test_integer[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_integer[GF2_8]",
"tests/polys/test_constructors.py::test_integer[GF2_100]",
"tests/polys/test_constructors.py::test_integer[GF7_3]",
"tests/polys/test_constructors.py::test_integer[GF109987_4]",
"tests/polys/test_constructors.py::test_string_exceptions",
"tests/polys/test_constructors.py::test_string[GF2]",
"tests/polys/test_constructors.py::test_string[GF31]",
"tests/polys/test_constructors.py::test_string[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_string[GF2_8]",
"tests/polys/test_constructors.py::test_string[GF2_100]",
"tests/polys/test_constructors.py::test_string[GF7_3]",
"tests/polys/test_constructors.py::test_string[GF109987_4]",
"tests/polys/test_constructors.py::test_string_large",
"tests/polys/test_constructors.py::test_degrees[GF2]",
"tests/polys/test_constructors.py::test_degrees[GF31]",
"tests/polys/test_constructors.py::test_degrees[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_degrees[GF2_8]",
"tests/polys/test_constructors.py::test_degrees[GF2_100]",
"tests/polys/test_constructors.py::test_degrees[GF7_3]",
"tests/polys/test_constructors.py::test_degrees[GF109987_4]",
"tests/polys/test_constructors.py::test_degrees_empty[GF2]",
"tests/polys/test_constructors.py::test_degrees_empty[GF31]",
"tests/polys/test_constructors.py::test_degrees_empty[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_degrees_empty[GF2_8]",
"tests/polys/test_constructors.py::test_degrees_empty[GF2_100]",
"tests/polys/test_constructors.py::test_degrees_empty[GF7_3]",
"tests/polys/test_constructors.py::test_degrees_empty[GF109987_4]",
"tests/polys/test_constructors.py::test_roots_exceptions",
"tests/polys/test_constructors.py::test_roots[GF2]",
"tests/polys/test_constructors.py::test_roots[GF31]",
"tests/polys/test_constructors.py::test_roots[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_roots[GF2_8]",
"tests/polys/test_constructors.py::test_roots[GF2_100]",
"tests/polys/test_constructors.py::test_roots[GF7_3]",
"tests/polys/test_constructors.py::test_roots[GF109987_4]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF2]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF31]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF36893488147419103183]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF2_8]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF2_100]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF7_3]",
"tests/polys/test_constructors.py::test_roots_with_multiplicity[GF109987_4]",
"tests/polys/test_constructors.py::test_roots_field_override"
] | [] | MIT License | 11,950 | 1,266 | [
"galois/_polys/_factor.py",
"galois/_polys/_poly.py"
] |
lux-org__lux-442 | 91e8e9885668bd42e1a125247a0d3166273b2a9a | 2022-01-06 21:51:50 | 4abee66efc9768671c1ca23a9ecd2115822341e5 | codecov[bot]: # [Codecov](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org) Report
> Merging [#442](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org) (7df184e) into [master](https://codecov.io/gh/lux-org/lux/commit/91e8e9885668bd42e1a125247a0d3166273b2a9a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org) (91e8e98) will **increase** coverage by `0.06%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org)
```diff
@@ Coverage Diff @@
## master #442 +/- ##
==========================================
+ Coverage 65.55% 65.62% +0.06%
==========================================
Files 55 55
Lines 4419 4422 +3
==========================================
+ Hits 2897 2902 +5
+ Misses 1522 1520 -2
```
| [Impacted Files](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org) | Coverage Δ | |
|---|---|---|
| [lux/executor/PandasExecutor.py](https://codecov.io/gh/lux-org/lux/pull/442/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org#diff-bHV4L2V4ZWN1dG9yL1BhbmRhc0V4ZWN1dG9yLnB5) | `89.84% <100.00%> (+0.09%)` | :arrow_up: |
| [lux/vislib/altair/ScatterChart.py](https://codecov.io/gh/lux-org/lux/pull/442/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org#diff-bHV4L3Zpc2xpYi9hbHRhaXIvU2NhdHRlckNoYXJ0LnB5) | `96.96% <0.00%> (+3.03%)` | :arrow_up: |
| [lux/vislib/altair/Heatmap.py](https://codecov.io/gh/lux-org/lux/pull/442/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org#diff-bHV4L3Zpc2xpYi9hbHRhaXIvSGVhdG1hcC5weQ==) | `96.55% <0.00%> (+3.44%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org). Last update [91e8e98...7df184e](https://codecov.io/gh/lux-org/lux/pull/442?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=lux-org).
| diff --git a/lux/executor/PandasExecutor.py b/lux/executor/PandasExecutor.py
index 30dfdf4..8d2314c 100644
--- a/lux/executor/PandasExecutor.py
+++ b/lux/executor/PandasExecutor.py
@@ -281,6 +281,8 @@ class PandasExecutor(Executor):
"""
import numpy as np
+ vis._vis_data = vis._vis_data.replace([np.inf, -np.inf], np.nan)
+
bin_attribute = [x for x in vis._inferred_intent if x.bin_size != 0][0]
bin_attr = bin_attribute.attribute
series = vis.data[bin_attr]
@@ -379,6 +381,10 @@ class PandasExecutor(Executor):
----------
vis : Vis
"""
+ import numpy as np
+
+ vis._vis_data = vis._vis_data.replace([np.inf, -np.inf], np.nan)
+
pd.reset_option("mode.chained_assignment")
with pd.option_context("mode.chained_assignment", None):
x_attr = vis.get_attr_by_channel("x")[0].attribute
| ValueError: cannot specify integer `bins` when input data contains infinity [BUG]
Trying to open a dataframe from a .csv that contains numpy.inf values fails with this error:
```
import lux, pandas
df = pandas.read_csv('filepath')
```
```
C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\IPython\core\formatters.py:918: UserWarning:
Unexpected error in rendering Lux widget and recommendations. Falling back to Pandas display.
Please report the following issue on Github: https://github.com/lux-org/lux/issues
C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\core\frame.py:632: UserWarning:Traceback (most recent call last):
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\core\frame.py", line 594, in _ipython_display_
self.maintain_recs()
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\core\frame.py", line 436, in maintain_recs
custom_action_collection = custom_actions(rec_df)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\action\custom.py", line 76, in custom_actions
recommendation = lux.config.actions[action_name].action(ldf)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\action\correlation.py", line 50, in correlation
vlist = VisList(intent, ldf)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\vis\VisList.py", line 43, in __init__
self.refresh_source(self._source)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\vis\VisList.py", line 336, in refresh_source
lux.config.executor.execute(self._collection, ldf, approx=approx)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\executor\PandasExecutor.py", line 146, in execute
PandasExecutor.execute_2D_binning(vis)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\lux\executor\PandasExecutor.py", line 387, in execute_2D_binning
vis._vis_data["xBin"] = pd.cut(vis._vis_data[x_attr], bins=lux.config.heatmap_bin_size)
File "C:\Users\???\anaconda\envs\base_up_to_date\lib\site-packages\pandas\core\reshape\tile.py", line 244, in cut
"cannot specify integer `bins` when input data contains infinity"
ValueError: cannot specify integer `bins` when input data contains infinity
``` | lux-org/lux | diff --git a/tests/test_pandas.py b/tests/test_pandas.py
index 6f3dea8..6bc23bb 100644
--- a/tests/test_pandas.py
+++ b/tests/test_pandas.py
@@ -15,6 +15,7 @@
from .context import lux
import pytest
import pandas as pd
+import numpy as np
def test_head_tail(global_var):
@@ -54,3 +55,21 @@ def test_convert_dtype(global_var):
cdf = df.convert_dtypes()
cdf._ipython_display_()
assert list(cdf.recommendation.keys()) == ["Correlation", "Distribution", "Occurrence"]
+
+
+def test_infs():
+ nrows = 100_000
+
+ # continuous
+ c1 = np.random.uniform(0, 1, size=nrows)
+ c1[2] = np.inf
+ c2 = np.random.uniform(0, 1, size=nrows)
+ c2[3] = np.inf
+
+ # discrete
+ d1 = np.random.randint(0, 2, size=nrows)
+ d2 = np.random.randint(0, 2, size=nrows)
+
+ df = pd.DataFrame({"c1": c1, "c2": c2, "d1": d1, "d2": d2})
+
+ df._ipython_display_()
| {
"commit_name": "head_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 0.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | altair==5.5.0
anyio==4.9.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==3.0.0
async-lru==2.0.5
attrs==25.3.0
autopep8==2.3.2
babel==2.17.0
beautifulsoup4==4.13.3
bleach==6.2.0
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
comm==0.2.2
contourpy==1.3.0
cycler==0.12.1
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
exceptiongroup==1.2.2
executing==2.2.0
fastjsonschema==2.21.1
fonttools==4.56.0
fqdn==1.5.1
h11==0.14.0
httpcore==1.0.7
httpx==0.28.1
idna==3.10
importlib_metadata==8.6.1
importlib_resources==6.5.2
iniconfig==2.1.0
ipykernel==6.29.5
ipython==8.18.1
ipywidgets==8.1.5
iso3166==2.1.1
isoduration==20.11.0
jedi==0.19.2
Jinja2==3.1.6
joblib==1.4.2
json5==0.10.0
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.15.0
jupyter_server_terminals==0.5.3
jupyterlab==4.3.6
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
jupyterlab_widgets==3.0.13
kiwisolver==1.4.7
-e git+https://github.com/lux-org/lux.git@91e8e9885668bd42e1a125247a0d3166273b2a9a#egg=lux_api
lux-widget==0.1.11
MarkupSafe==3.0.2
matplotlib==3.9.4
matplotlib-inline==0.1.7
mistune==3.1.3
narwhals==1.32.0
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
notebook==7.3.3
notebook_shim==0.2.4
numpy==2.0.2
overrides==7.7.0
packaging==24.2
pandas==2.2.3
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
pillow==11.1.0
platformdirs==4.3.7
pluggy==1.5.0
prometheus_client==0.21.1
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycodestyle==2.13.0
pycparser==2.22
Pygments==2.19.1
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
python-json-logger==3.3.0
pytz==2025.2
PyYAML==6.0.2
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.24.0
scikit-learn==1.6.1
scipy==1.13.1
Send2Trash==1.8.3
six==1.17.0
sniffio==1.3.1
soupsieve==2.6
stack-data==0.6.3
terminado==0.18.1
threadpoolctl==3.6.0
tinycss2==1.4.0
tomli==2.2.1
tornado==6.4.2
traitlets==5.14.3
types-python-dateutil==2.9.0.20241206
typing_extensions==4.13.0
tzdata==2025.2
uri-template==1.3.0
urllib3==2.3.0
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
widgetsnbextension==4.0.13
zipp==3.21.0
| name: lux
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- altair==5.5.0
- anyio==4.9.0
- argon2-cffi==23.1.0
- argon2-cffi-bindings==21.2.0
- arrow==1.3.0
- asttokens==3.0.0
- async-lru==2.0.5
- attrs==25.3.0
- autopep8==2.3.2
- babel==2.17.0
- beautifulsoup4==4.13.3
- bleach==6.2.0
- certifi==2025.1.31
- cffi==1.17.1
- charset-normalizer==3.4.1
- comm==0.2.2
- contourpy==1.3.0
- cycler==0.12.1
- debugpy==1.8.13
- decorator==5.2.1
- defusedxml==0.7.1
- exceptiongroup==1.2.2
- executing==2.2.0
- fastjsonschema==2.21.1
- fonttools==4.56.0
- fqdn==1.5.1
- h11==0.14.0
- httpcore==1.0.7
- httpx==0.28.1
- idna==3.10
- importlib-metadata==8.6.1
- importlib-resources==6.5.2
- iniconfig==2.1.0
- ipykernel==6.29.5
- ipython==8.18.1
- ipywidgets==8.1.5
- iso3166==2.1.1
- isoduration==20.11.0
- jedi==0.19.2
- jinja2==3.1.6
- joblib==1.4.2
- json5==0.10.0
- jsonpointer==3.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- jupyter-client==8.6.3
- jupyter-core==5.7.2
- jupyter-events==0.12.0
- jupyter-lsp==2.2.5
- jupyter-server==2.15.0
- jupyter-server-terminals==0.5.3
- jupyterlab==4.3.6
- jupyterlab-pygments==0.3.0
- jupyterlab-server==2.27.3
- jupyterlab-widgets==3.0.13
- kiwisolver==1.4.7
- lux-api==0.4.0
- lux-widget==0.1.11
- markupsafe==3.0.2
- matplotlib==3.9.4
- matplotlib-inline==0.1.7
- mistune==3.1.3
- narwhals==1.32.0
- nbclient==0.10.2
- nbconvert==7.16.6
- nbformat==5.10.4
- nest-asyncio==1.6.0
- notebook==7.3.3
- notebook-shim==0.2.4
- numpy==2.0.2
- overrides==7.7.0
- packaging==24.2
- pandas==2.2.3
- pandocfilters==1.5.1
- parso==0.8.4
- pexpect==4.9.0
- pillow==11.1.0
- platformdirs==4.3.7
- pluggy==1.5.0
- prometheus-client==0.21.1
- prompt-toolkit==3.0.50
- psutil==7.0.0
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pycodestyle==2.13.0
- pycparser==2.22
- pygments==2.19.1
- pyparsing==3.2.3
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- python-json-logger==3.3.0
- pytz==2025.2
- pyyaml==6.0.2
- pyzmq==26.3.0
- referencing==0.36.2
- requests==2.32.3
- rfc3339-validator==0.1.4
- rfc3986-validator==0.1.1
- rpds-py==0.24.0
- scikit-learn==1.6.1
- scipy==1.13.1
- send2trash==1.8.3
- six==1.17.0
- sniffio==1.3.1
- soupsieve==2.6
- stack-data==0.6.3
- terminado==0.18.1
- threadpoolctl==3.6.0
- tinycss2==1.4.0
- tomli==2.2.1
- tornado==6.4.2
- traitlets==5.14.3
- types-python-dateutil==2.9.0.20241206
- typing-extensions==4.13.0
- tzdata==2025.2
- uri-template==1.3.0
- urllib3==2.3.0
- wcwidth==0.2.13
- webcolors==24.11.1
- webencodings==0.5.1
- websocket-client==1.8.0
- widgetsnbextension==4.0.13
- zipp==3.21.0
prefix: /opt/conda/envs/lux
| [
"tests/test_pandas.py::test_infs"
] | [
"tests/test_pandas.py::test_groupby_describe"
] | [
"tests/test_pandas.py::test_head_tail",
"tests/test_pandas.py::test_describe",
"tests/test_pandas.py::test_convert_dtype"
] | [] | Apache License 2.0 | 11,953 | 263 | [
"lux/executor/PandasExecutor.py"
] |
jupyterhub__jupyterhub-3757 | a2ba55756d036e8007830fbb4b67665d2b30692c | 2022-01-07 13:19:56 | dcf21d53fd9e6c131a269550c0a46f08ca9df5bb | diff --git a/jupyterhub/apihandlers/auth.py b/jupyterhub/apihandlers/auth.py
index 4d63ec99..2ec2dec0 100644
--- a/jupyterhub/apihandlers/auth.py
+++ b/jupyterhub/apihandlers/auth.py
@@ -16,6 +16,7 @@ from tornado import web
from .. import orm
from .. import roles
from .. import scopes
+from ..utils import get_browser_protocol
from ..utils import token_authenticated
from .base import APIHandler
from .base import BaseHandler
@@ -115,7 +116,10 @@ class OAuthHandler:
# make absolute local redirects full URLs
# to satisfy oauthlib's absolute URI requirement
redirect_uri = (
- self.request.protocol + "://" + self.request.headers['Host'] + redirect_uri
+ get_browser_protocol(self.request)
+ + "://"
+ + self.request.host
+ + redirect_uri
)
parsed_url = urlparse(uri)
query_list = parse_qsl(parsed_url.query, keep_blank_values=True)
diff --git a/jupyterhub/apihandlers/base.py b/jupyterhub/apihandlers/base.py
index b107bf64..6cbb7659 100644
--- a/jupyterhub/apihandlers/base.py
+++ b/jupyterhub/apihandlers/base.py
@@ -14,6 +14,7 @@ from tornado import web
from .. import orm
from ..handlers import BaseHandler
+from ..utils import get_browser_protocol
from ..utils import isoformat
from ..utils import url_path_join
@@ -60,6 +61,8 @@ class APIHandler(BaseHandler):
"""
host_header = self.app.forwarded_host_header or "Host"
host = self.request.headers.get(host_header)
+ if host and "," in host:
+ host = host.split(",", 1)[0].strip()
referer = self.request.headers.get("Referer")
# If no header is provided, assume it comes from a script/curl.
@@ -71,7 +74,8 @@ class APIHandler(BaseHandler):
self.log.warning("Blocking API request with no referer")
return False
- proto = self.request.protocol
+ proto = get_browser_protocol(self.request)
+
full_host = f"{proto}://{host}{self.hub.base_url}"
host_url = urlparse(full_host)
referer_url = urlparse(referer)
diff --git a/jupyterhub/handlers/base.py b/jupyterhub/handlers/base.py
index ab37e21f..56cf1fa8 100644
--- a/jupyterhub/handlers/base.py
+++ b/jupyterhub/handlers/base.py
@@ -49,6 +49,7 @@ from ..spawner import LocalProcessSpawner
from ..user import User
from ..utils import AnyTimeoutError
from ..utils import get_accepted_mimetype
+from ..utils import get_browser_protocol
from ..utils import maybe_future
from ..utils import url_path_join
@@ -632,12 +633,10 @@ class BaseHandler(RequestHandler):
next_url = self.get_argument('next', default='')
# protect against some browsers' buggy handling of backslash as slash
next_url = next_url.replace('\\', '%5C')
- if (next_url + '/').startswith(
- (
- f'{self.request.protocol}://{self.request.host}/',
- f'//{self.request.host}/',
- )
- ) or (
+ proto = get_browser_protocol(self.request)
+ host = self.request.host
+
+ if (next_url + '/').startswith((f'{proto}://{host}/', f'//{host}/',)) or (
self.subdomain_host
and urlparse(next_url).netloc
and ("." + urlparse(next_url).netloc).endswith(
diff --git a/jupyterhub/services/auth.py b/jupyterhub/services/auth.py
index a08049a3..9315564d 100644
--- a/jupyterhub/services/auth.py
+++ b/jupyterhub/services/auth.py
@@ -53,6 +53,7 @@ from traitlets import validate
from traitlets.config import SingletonConfigurable
from ..scopes import _intersect_expanded_scopes
+from ..utils import get_browser_protocol
from ..utils import url_path_join
@@ -772,7 +773,7 @@ class HubOAuth(HubAuth):
# OAuth that doesn't complete shouldn't linger too long.
'max_age': 600,
}
- if handler.request.protocol == 'https':
+ if get_browser_protocol(handler.request) == 'https':
kwargs['secure'] = True
# load user cookie overrides
kwargs.update(self.cookie_options)
@@ -812,7 +813,7 @@ class HubOAuth(HubAuth):
def set_cookie(self, handler, access_token):
"""Set a cookie recording OAuth result"""
kwargs = {'path': self.base_url, 'httponly': True}
- if handler.request.protocol == 'https':
+ if get_browser_protocol(handler.request) == 'https':
kwargs['secure'] = True
# load user cookie overrides
kwargs.update(self.cookie_options)
diff --git a/jupyterhub/utils.py b/jupyterhub/utils.py
index 60464d78..1fc4aa89 100644
--- a/jupyterhub/utils.py
+++ b/jupyterhub/utils.py
@@ -683,3 +683,44 @@ def catch_db_error(f):
return r
return catching
+
+
+def get_browser_protocol(request):
+ """Get the _protocol_ seen by the browser
+
+ Like tornado's _apply_xheaders,
+ but in the case of multiple proxy hops,
+ use the outermost value (what the browser likely sees)
+ instead of the innermost value,
+ which is the most trustworthy.
+
+ We care about what the browser sees,
+ not where the request actually came from,
+ so trusting possible spoofs is the right thing to do.
+ """
+ headers = request.headers
+ # first choice: Forwarded header
+ forwarded_header = headers.get("Forwarded")
+ if forwarded_header:
+ first_forwarded = forwarded_header.split(",", 1)[0].strip()
+ fields = {}
+ forwarded_dict = {}
+ for field in first_forwarded.split(";"):
+ key, _, value = field.partition("=")
+ fields[key.strip().lower()] = value.strip()
+ if "proto" in fields and fields["proto"].lower() in {"http", "https"}:
+ return fields["proto"].lower()
+ else:
+ app_log.warning(
+ f"Forwarded header present without protocol: {forwarded_header}"
+ )
+
+ # second choice: X-Scheme or X-Forwarded-Proto
+ proto_header = headers.get("X-Scheme", headers.get("X-Forwarded-Proto", None))
+ if proto_header:
+ proto_header = proto_header.split(",")[0].strip().lower()
+ if proto_header in {"http", "https"}:
+ return proto_header
+
+ # no forwarded headers
+ return request.protocol
| Empty Admin page when the hub is behind nginx proxy
<!-- Thank you for contributing. These HTML comments will not render in the issue, but you can delete them once you've read them if you prefer! -->
### Bug description
<!-- Use this section to clearly and concisely describe the bug. -->
Merry Christmas!
The Admin settings of jupyterhub v. 2.0.1 are not shown if the hub is behind a reverse nginx proxy.
The symptoms appear to be similar to #3711 except that they are now not caused by `base_url`.
#### Expected behaviour
<!-- Tell us what you thought would happen. -->
Admin page when the hub is accessed directly:
<img width="684" alt="Screenshot 2021-12-25 at 09 32 58" src="https://user-images.githubusercontent.com/2140361/147381008-67c6e49d-a583-47d0-aab2-bc1246976b1e.png">
#### Actual behaviour
<!-- Tell us what actually happens. -->
Admin page when the hub is accessed through a proxy:
<img width="683" alt="Screenshot 2021-12-25 at 09 34 48" src="https://user-images.githubusercontent.com/2140361/147381033-be241b38-db3f-410c-a439-2d4eb3f71f33.png">
This message looks suspicious (see the full log below):
```
jupyterhub_1 | [W 2021-12-25 08:58:25.156 JupyterHub base:89] Blocking Cross Origin API request. Referer: http://127.0.0.1:8080/hub/admin, Host: 127.0.0.1, Host URL: http://127.0.0.1/hub/
```
There is no problem with `jupyterhub/jupyterhub:1.5.0`
### How to reproduce
<!-- Use this section to describe the steps that a user would take to experience this bug. -->
1. Ensure the following directory structure:
```
.
├── docker-compose.yml
├── jupyterhub
│ ├── Dockerfile
│ └── jupyterhub_config.py
└── nginx
├── Dockerfile
└── nginx.conf
```
2. Ensure the following file contents:
- `docker-compose.yml`:
```
version: '3'
services:
nginx:
image: nginx
build: nginx
ports:
- 8080:80
jupyterhub:
image: jupyterhub
build: jupyterhub
expose:
- "8000"
```
- `jupyterhub/Dockerfile`:
```
FROM jupyterhub/jupyterhub:2.0.1
COPY jupyterhub_config.py /etc/jupyterhub/
CMD jupyterhub -f /etc/jupyterhub/jupyterhub_config.py --debug
```
- `jupyterhub/jupyterhub_config.py`:
```
c.Authenticator.admin_users = {'user'}
c.JupyterHub.authenticator_class = 'dummy'
```
- `nginx/Dockerfile`:
```
FROM nginx:1.21.4
COPY nginx.conf /etc/nginx/
```
- `nginx/nginx.conf` ([as documented](https://jupyterhub.readthedocs.io/en/stable/reference/config-proxy.html#nginx) but without ssl):
```
events {}
http {
server {
listen 0.0.0.0:80;
server_name localhost;
location / {
proxy_pass http://jupyterhub:8000/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# websocket headers
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header X-Scheme $scheme;
proxy_buffering off;
}
real_ip_header proxy_protocol;
set_real_ip_from 127.0.0.1;
}
}
```
3. Build containers:
`docker-compose build`
4. Start the containers:
`docker-compose up`
5. Visit the page: http://127.0.0.1:8080/hub/admin
6. Enter the user name `user`
### Your personal set up
<!--
Tell us a little about the system you're using.
Please include information about how you installed,
e.g. are you using a distribution such as zero-to-jupyterhub or the-littlest-jupyterhub.
-->
- OS: MacOS 12.1
- Version(s):
```
% docker --version
Docker version 20.10.11, build dea9396
% docker-compose --version
Docker Compose version v2.2.1
```
<details><summary>Logs</summary>
- docker-compose:
```
% docker-compose up
[+] Running 2/0
⠿ Container jupyterhub-test1_jupyterhub_1 Created 0.0s
⠿ Container jupyterhub-test1_nginx_1 Created 0.0s
Attaching to jupyterhub_1, nginx_1
nginx_1 | /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
nginx_1 | /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
nginx_1 | 10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
nginx_1 | /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
nginx_1 | /docker-entrypoint.sh: Configuration complete; ready for start up
jupyterhub_1 | [D 2021-12-25 08:58:14.902 JupyterHub application:731] Looking for /etc/jupyterhub/jupyterhub_config in /srv/jupyterhub
jupyterhub_1 | [D 2021-12-25 08:58:14.902 JupyterHub application:753] Loaded config file: /etc/jupyterhub/jupyterhub_config.py
jupyterhub_1 | [I 2021-12-25 08:58:14.912 JupyterHub app:2766] Running JupyterHub version 2.0.1
jupyterhub_1 | [I 2021-12-25 08:58:14.912 JupyterHub app:2796] Using Authenticator: jupyterhub.auth.DummyAuthenticator-2.0.1
jupyterhub_1 | [I 2021-12-25 08:58:14.912 JupyterHub app:2796] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-2.0.1
jupyterhub_1 | [I 2021-12-25 08:58:14.912 JupyterHub app:2796] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-2.0.1
jupyterhub_1 | [I 2021-12-25 08:58:14.924 JupyterHub app:1606] Loading cookie_secret from /srv/jupyterhub/jupyterhub_cookie_secret
jupyterhub_1 | [D 2021-12-25 08:58:14.930 JupyterHub app:1773] Connecting to db: sqlite:///jupyterhub.sqlite
jupyterhub_1 | [D 2021-12-25 08:58:14.959 JupyterHub orm:955] database schema version found: 833da8570507
jupyterhub_1 | [I 2021-12-25 08:58:15.017 JupyterHub proxy:496] Generating new CONFIGPROXY_AUTH_TOKEN
jupyterhub_1 | [D 2021-12-25 08:58:15.017 JupyterHub app:2019] Loading roles into database
jupyterhub_1 | [I 2021-12-25 08:58:15.035 JupyterHub app:1924] Not using allowed_users. Any authenticated user will be allowed.
jupyterhub_1 | [D 2021-12-25 08:58:15.042 JupyterHub app:2278] Purging expired APITokens
jupyterhub_1 | [D 2021-12-25 08:58:15.047 JupyterHub app:2278] Purging expired OAuthCodes
jupyterhub_1 | [D 2021-12-25 08:58:15.053 JupyterHub app:2111] Loading role assignments from config
jupyterhub_1 | [D 2021-12-25 08:58:15.076 JupyterHub app:2424] Initializing spawners
jupyterhub_1 | [D 2021-12-25 08:58:15.080 JupyterHub app:2555] Loaded users:
jupyterhub_1 |
jupyterhub_1 | [I 2021-12-25 08:58:15.081 JupyterHub app:2835] Initialized 0 spawners in 0.006 seconds
jupyterhub_1 | [W 2021-12-25 08:58:15.087 JupyterHub proxy:565] Found proxy pid file: /srv/jupyterhub/jupyterhub-proxy.pid
jupyterhub_1 | [W 2021-12-25 08:58:15.088 JupyterHub proxy:577] Proxy no longer running at pid=12
jupyterhub_1 | [D 2021-12-25 08:58:15.088 JupyterHub proxy:618] Removing proxy pid file jupyterhub-proxy.pid
jupyterhub_1 | [W 2021-12-25 08:58:15.090 JupyterHub proxy:687] Running JupyterHub without SSL. I hope there is SSL termination happening somewhere else...
jupyterhub_1 | [I 2021-12-25 08:58:15.090 JupyterHub proxy:691] Starting proxy @ http://:8000
jupyterhub_1 | [D 2021-12-25 08:58:15.090 JupyterHub proxy:692] Proxy cmd: ['configurable-http-proxy', '--ip', '', '--port', '8000', '--api-ip', '127.0.0.1', '--api-port', '8001', '--error-target', 'http://127.0.0.1:8081/hub/error']
jupyterhub_1 | [D 2021-12-25 08:58:15.098 JupyterHub proxy:610] Writing proxy pid file: jupyterhub-proxy.pid
jupyterhub_1 | 08:58:16.203 [ConfigProxy] info: Proxying http://*:8000 to (no default)
jupyterhub_1 | 08:58:16.210 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes
jupyterhub_1 | [D 2021-12-25 08:58:16.219 JupyterHub proxy:728] Proxy started and appears to be up
jupyterhub_1 | [D 2021-12-25 08:58:16.221 JupyterHub proxy:821] Proxy: Fetching GET http://127.0.0.1:8001/api/routes
jupyterhub_1 | 08:58:16.244 [ConfigProxy] info: 200 GET /api/routes
jupyterhub_1 | [I 2021-12-25 08:58:16.251 JupyterHub app:3084] Hub API listening on http://127.0.0.1:8081/hub/
jupyterhub_1 | [D 2021-12-25 08:58:16.252 JupyterHub proxy:343] Fetching routes to check
jupyterhub_1 | [D 2021-12-25 08:58:16.252 JupyterHub proxy:821] Proxy: Fetching GET http://127.0.0.1:8001/api/routes
jupyterhub_1 | 08:58:16.265 [ConfigProxy] info: 200 GET /api/routes
jupyterhub_1 | [D 2021-12-25 08:58:16.271 JupyterHub proxy:346] Checking routes
jupyterhub_1 | [I 2021-12-25 08:58:16.273 JupyterHub proxy:431] Adding route for Hub: / => http://127.0.0.1:8081
jupyterhub_1 | [D 2021-12-25 08:58:16.276 JupyterHub proxy:821] Proxy: Fetching POST http://127.0.0.1:8001/api/routes/
jupyterhub_1 | 08:58:16.282 [ConfigProxy] info: Adding route / -> http://127.0.0.1:8081
jupyterhub_1 | 08:58:16.287 [ConfigProxy] info: Route added / -> http://127.0.0.1:8081
jupyterhub_1 | 08:58:16.290 [ConfigProxy] info: 201 POST /api/routes/
jupyterhub_1 | [I 2021-12-25 08:58:16.293 JupyterHub app:3150] JupyterHub is now running at http://:8000
jupyterhub_1 | [D 2021-12-25 08:58:16.296 JupyterHub app:2759] It took 1.401 seconds for the Hub to start
jupyterhub_1 | [I 2021-12-25 08:58:17.444 JupyterHub log:189] 302 GET /hub/admin -> /hub/login?next=%2Fhub%2Fadmin (@172.20.0.1) 1.23ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:17 +0000] "GET /hub/admin HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [I 2021-12-25 08:58:17.534 JupyterHub log:189] 200 GET /hub/login?next=%2Fhub%2Fadmin (@172.20.0.1) 43.03ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:17 +0000] "GET /hub/login?next=%2Fhub%2Fadmin HTTP/1.1" 200 5473 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:17.563 JupyterHub log:189] 304 GET /hub/static/js/admin-react.js (@172.20.0.1) 1.67ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:17 +0000] "GET /hub/static/js/admin-react.js HTTP/1.1" 304 0 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:24.862 JupyterHub roles:449] Assigning default role to User user
jupyterhub_1 | [D 2021-12-25 08:58:24.875 JupyterHub base:557] Setting cookie jupyterhub-session-id: {'httponly': True, 'path': '/'}
jupyterhub_1 | [D 2021-12-25 08:58:24.876 JupyterHub base:561] Setting cookie for user: jupyterhub-hub-login
jupyterhub_1 | [D 2021-12-25 08:58:24.877 JupyterHub base:557] Setting cookie jupyterhub-hub-login: {'httponly': True, 'path': '/hub/'}
jupyterhub_1 | [I 2021-12-25 08:58:24.878 JupyterHub base:797] User logged in: user
jupyterhub_1 | [I 2021-12-25 08:58:24.884 JupyterHub log:189] 302 POST /hub/login?next=%2Fhub%2Fadmin -> /hub/admin ([email protected]) 30.40ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:24 +0000] "POST /hub/login?next=%2Fhub%2Fadmin HTTP/1.1" 302 0 "http://127.0.0.1:8080/hub/login?next=%2Fhub%2Fadmin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:24.937 JupyterHub scopes:488] Checking access via scope admin:users
jupyterhub_1 | [D 2021-12-25 08:58:24.937 JupyterHub scopes:386] Unrestricted access to /hub/admin via admin:users
jupyterhub_1 | [D 2021-12-25 08:58:24.937 JupyterHub scopes:488] Checking access via scope admin:servers
jupyterhub_1 | [D 2021-12-25 08:58:24.938 JupyterHub scopes:386] Unrestricted access to /hub/admin via admin:servers
jupyterhub_1 | [D 2021-12-25 08:58:24.954 JupyterHub user:347] Creating <class 'jupyterhub.spawner.LocalProcessSpawner'> for user:
jupyterhub_1 | [I 2021-12-25 08:58:24.963 JupyterHub log:189] 200 GET /hub/admin ([email protected]) 48.74ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:24 +0000] "GET /hub/admin HTTP/1.1" 200 5162 "http://127.0.0.1:8080/hub/login?next=%2Fhub%2Fadmin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /logo HTTP/1.1" 302 0 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [I 2021-12-25 08:58:25.021 JupyterHub log:189] 302 GET /logo -> /hub/logo (@172.20.0.1) 3.75ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/static/js/admin-react.js HTTP/1.1" 304 0 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:25.062 JupyterHub log:189] 304 GET /hub/static/js/admin-react.js (@172.20.0.1) 2.92ms
jupyterhub_1 | [D 2021-12-25 08:58:25.079 JupyterHub log:189] 200 GET /hub/logo (@172.20.0.1) 3.64ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/logo HTTP/1.1" 200 11453 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:25.142 JupyterHub log:189] 200 GET /hub/static/js/admin.js?v=20211225085815 (@172.20.0.1) 4.37ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/static/js/admin.js?v=20211225085815 HTTP/1.1" 200 8013 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [W 2021-12-25 08:58:25.156 JupyterHub base:89] Blocking Cross Origin API request. Referer: http://127.0.0.1:8080/hub/admin, Host: 127.0.0.1, Host URL: http://127.0.0.1/hub/
jupyterhub_1 | [D 2021-12-25 08:58:25.165 JupyterHub scopes:488] Checking access via scope list:groups
jupyterhub_1 | [D 2021-12-25 08:58:25.168 JupyterHub scopes:383] No access to /hub/api/groups via list:groups
jupyterhub_1 | [W 2021-12-25 08:58:25.169 JupyterHub scopes:496] Not authorizing access to /hub/api/groups. Requires any of [list:groups], not derived from scopes []
jupyterhub_1 | [W 2021-12-25 08:58:25.177 JupyterHub web:1787] 403 GET /hub/api/groups?offset=0&limit=50 (172.20.0.1): Action is not authorized with current scopes; requires any of [list:groups]
jupyterhub_1 | [W 2021-12-25 08:58:25.184 JupyterHub log:189] 403 GET /hub/api/groups?offset=0&limit=50 (@172.20.0.1) 40.88ms
jupyterhub_1 | [W 2021-12-25 08:58:25.190 JupyterHub base:89] Blocking Cross Origin API request. Referer: http://127.0.0.1:8080/hub/admin, Host: 127.0.0.1, Host URL: http://127.0.0.1/hub/
jupyterhub_1 | [D 2021-12-25 08:58:25.190 JupyterHub scopes:488] Checking access via scope list:users
jupyterhub_1 | [D 2021-12-25 08:58:25.190 JupyterHub scopes:383] No access to /hub/api/users via list:users
jupyterhub_1 | [W 2021-12-25 08:58:25.191 JupyterHub scopes:496] Not authorizing access to /hub/api/users. Requires any of [list:users], not derived from scopes []
jupyterhub_1 | [W 2021-12-25 08:58:25.191 JupyterHub web:1787] 403 GET /hub/api/users?offset=0&limit=50 (172.20.0.1): Action is not authorized with current scopes; requires any of [list:users]
jupyterhub_1 | [W 2021-12-25 08:58:25.192 JupyterHub log:189] 403 GET /hub/api/users?offset=0&limit=50 (@172.20.0.1) 43.34ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/api/groups?offset=0&limit=50 HTTP/1.1" 403 105 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/api/users?offset=0&limit=50 HTTP/1.1" 403 104 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:25.227 JupyterHub log:189] 200 GET /hub/static/js/jhapi.js?v=20211225085815 (@172.20.0.1) 2.09ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/static/js/jhapi.js?v=20211225085815 HTTP/1.1" 200 4446 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
jupyterhub_1 | [D 2021-12-25 08:58:25.236 JupyterHub log:189] 200 GET /hub/static/components/moment/moment.js?v=20211225085815 (@172.20.0.1) 10.13ms
jupyterhub_1 | [D 2021-12-25 08:58:25.243 JupyterHub log:189] 200 GET /hub/static/js/utils.js?v=20211225085815 (@172.20.0.1) 17.01ms
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/static/components/moment/moment.js?v=20211225085815 HTTP/1.1" 200 173902 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
nginx_1 | 172.20.0.1 - - [25/Dec/2021:08:58:25 +0000] "GET /hub/static/js/utils.js?v=20211225085815 HTTP/1.1" 200 4383 "http://127.0.0.1:8080/hub/admin" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.2 Safari/605.1.15"
```
- Errors in the browser console (Safari 15.2):
```
[Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (users, line 0)
[Error] Failed to load resource: the server responded with a status of 403 (Forbidden) (groups, line 0)
[Error] TypeError: undefined is not a function (near '...u.map...') — admin-react.js:2:28870
ri (admin-react.js:2:146088)
(anonymous function) (admin-react.js:2:148187)
co (admin-react.js:2:112238)
si (admin-react.js:2:149923)
Cu (admin-react.js:2:166325)
Cu
(anonymous function) (admin-react.js:2:194357)
xu (admin-react.js:2:163064)
du (admin-react.js:2:159263)
du
(anonymous function) (admin-react.js:2:108745)
(anonymous function) (admin-react.js:2:194357)
Va (admin-react.js:2:108691)
Ha (admin-react.js:2:108626)
pu (admin-react.js:2:159359)
notify (admin-react.js:2:919)
(anonymous function) (admin-react.js:2:494)
(anonymous function) (admin-react.js:2:569)
(anonymous function)
p (admin-react.js:2:52697)
promiseReactionJob
```
</details>
| jupyterhub/jupyterhub | diff --git a/jupyterhub/tests/test_api.py b/jupyterhub/tests/test_api.py
index 1b777c74..1397ea63 100644
--- a/jupyterhub/tests/test_api.py
+++ b/jupyterhub/tests/test_api.py
@@ -118,16 +118,39 @@ async def test_post_content_type(app, content_type, status):
("fake.example", {"netloc": "fake.example", "scheme": "https"}, {}, 403),
# explicit ports, match
("fake.example:81", {"netloc": "fake.example:81"}, {}, 200),
- # Test proxy defined headers taken into account by xheaders=True in
- # https://github.com/jupyterhub/jupyterhub/blob/2.0.1/jupyterhub/app.py#L3065
+ # Test proxy protocol defined headers taken into account by utils.get_browser_protocol
(
"fake.example",
{"netloc": "fake.example", "scheme": "https"},
- # note {"X-Forwarded-Proto": "https"} does not work
{'X-Scheme': 'https'},
200,
),
+ (
+ "fake.example",
+ {"netloc": "fake.example", "scheme": "https"},
+ {'X-Forwarded-Proto': 'https'},
+ 200,
+ ),
+ (
+ "fake.example",
+ {"netloc": "fake.example", "scheme": "https"},
+ {
+ 'Forwarded': 'host=fake.example;proto=https,for=1.2.34;proto=http',
+ 'X-Scheme': 'http',
+ },
+ 200,
+ ),
+ (
+ "fake.example",
+ {"netloc": "fake.example", "scheme": "https"},
+ {
+ 'Forwarded': 'host=fake.example;proto=http,for=1.2.34;proto=http',
+ 'X-Scheme': 'https',
+ },
+ 403,
+ ),
("fake.example", {"netloc": "fake.example"}, {'X-Scheme': 'https'}, 403),
+ ("fake.example", {"netloc": "fake.example"}, {'X-Scheme': 'https, http'}, 403),
],
)
async def test_cors_check(request, app, host, referer, extraheaders, status):
diff --git a/jupyterhub/tests/test_utils.py b/jupyterhub/tests/test_utils.py
index c75c9051..129bc0fa 100644
--- a/jupyterhub/tests/test_utils.py
+++ b/jupyterhub/tests/test_utils.py
@@ -2,12 +2,16 @@
import asyncio
import time
from concurrent.futures import ThreadPoolExecutor
+from unittest.mock import Mock
import pytest
from async_generator import aclosing
from tornado import gen
from tornado.concurrent import run_on_executor
+from tornado.httpserver import HTTPRequest
+from tornado.httputil import HTTPHeaders
+from .. import utils
from ..utils import iterate_until
@@ -88,3 +92,33 @@ async def test_tornado_coroutines():
# verify that tornado gen and executor methods return awaitables
assert (await t.on_executor()) == "executor"
assert (await t.tornado_coroutine()) == "gen.coroutine"
+
+
[email protected](
+ "forwarded, x_scheme, x_forwarded_proto, expected",
+ [
+ ("", "", "", "_attr_"),
+ ("for=1.2.3.4", "", "", "_attr_"),
+ ("for=1.2.3.4,proto=https", "", "", "_attr_"),
+ ("", "https", "http", "https"),
+ ("", "https, http", "", "https"),
+ ("", "https, http", "http", "https"),
+ ("proto=http ; for=1.2.3.4, proto=https", "https, http", "", "http"),
+ ("proto=invalid;for=1.2.3.4,proto=http", "https, http", "", "https"),
+ ("for=1.2.3.4,proto=http", "https, http", "", "https"),
+ ("", "invalid, http", "", "_attr_"),
+ ],
+)
+def test_browser_protocol(x_scheme, x_forwarded_proto, forwarded, expected):
+ request = Mock(spec=HTTPRequest)
+ request.protocol = "_attr_"
+ request.headers = HTTPHeaders()
+ if x_scheme:
+ request.headers["X-Scheme"] = x_scheme
+ if x_forwarded_proto:
+ request.headers["X-Forwarded-Proto"] = x_forwarded_proto
+ if forwarded:
+ request.headers["Forwarded"] = forwarded
+
+ proto = utils.get_browser_protocol(request)
+ assert proto == expected
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_issue_reference",
"has_media",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 5
} | 2.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"attrs>=17.4.0",
"beautifulsoup4",
"codecov",
"coverage",
"cryptography",
"html5lib",
"jupyterlab>=3",
"mock",
"pre-commit",
"pytest>=3.3",
"pytest-asyncio",
"pytest-cov",
"requests-mock",
"tbump",
"urllib3!=1.25.4,!=1.25.5",
"virtualenv",
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alembic==1.15.2
anyio==4.9.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
arrow==1.3.0
asttokens==3.0.0
async-generator==1.10
async-lru==2.0.5
attrs==25.3.0
babel==2.17.0
beautifulsoup4==4.13.3
bleach==6.2.0
certifi==2025.1.31
certipy==0.2.2
cffi==1.17.1
cfgv==3.4.0
charset-normalizer==3.4.1
cli-ui==0.19.0
codecov==2.1.13
colorama==0.4.6
comm==0.2.2
coverage==7.8.0
cryptography==44.0.2
debugpy==1.8.13
decorator==5.2.1
defusedxml==0.7.1
distlib==0.3.9
docopt==0.6.2
entrypoints==0.4
exceptiongroup==1.2.2
executing==2.2.0
fastjsonschema==2.21.1
filelock==3.18.0
fqdn==1.5.1
greenlet==3.1.1
h11==0.14.0
html5lib==1.1
httpcore==1.0.7
httpx==0.28.1
identify==2.6.9
idna==3.10
importlib_metadata==8.6.1
iniconfig==2.1.0
ipykernel==6.29.5
ipython==8.18.1
isoduration==20.11.0
jedi==0.19.2
Jinja2==3.1.6
json5==0.10.0
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
jupyter-events==0.12.0
jupyter-lsp==2.2.5
jupyter-telemetry==0.1.0
jupyter_client==8.6.3
jupyter_core==5.7.2
jupyter_server==2.15.0
jupyter_server_terminals==0.5.3
-e git+https://github.com/jupyterhub/jupyterhub.git@a2ba55756d036e8007830fbb4b67665d2b30692c#egg=jupyterhub
jupyterlab==4.3.6
jupyterlab_pygments==0.3.0
jupyterlab_server==2.27.3
Mako==1.3.9
MarkupSafe==3.0.2
matplotlib-inline==0.1.7
mistune==3.1.3
mock==5.2.0
nbclient==0.10.2
nbconvert==7.16.6
nbformat==5.10.4
nest-asyncio==1.6.0
nodeenv==1.9.1
notebook_shim==0.2.4
oauthlib==3.2.2
overrides==7.7.0
packaging==24.2
pamela==1.2.0
pandocfilters==1.5.1
parso==0.8.4
pexpect==4.9.0
platformdirs==4.3.7
pluggy==1.5.0
pre_commit==4.2.0
prometheus_client==0.21.1
prompt_toolkit==3.0.50
psutil==7.0.0
ptyprocess==0.7.0
pure_eval==0.2.3
pycparser==2.22
Pygments==2.19.1
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
python-dateutil==2.9.0.post0
python-json-logger==3.3.0
PyYAML==6.0.2
pyzmq==26.3.0
referencing==0.36.2
requests==2.32.3
requests-mock==1.12.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rpds-py==0.24.0
ruamel.yaml==0.18.10
ruamel.yaml.clib==0.2.12
schema==0.7.7
Send2Trash==1.8.3
six==1.17.0
sniffio==1.3.1
soupsieve==2.6
SQLAlchemy==2.0.40
stack-data==0.6.3
tabulate==0.9.0
tbump==6.11.0
terminado==0.18.1
tinycss2==1.4.0
tomli==2.2.1
tomlkit==0.11.8
tornado==6.4.2
traitlets==5.14.3
types-python-dateutil==2.9.0.20241206
typing_extensions==4.13.0
Unidecode==1.3.8
uri-template==1.3.0
urllib3==2.3.0
virtualenv==20.29.3
wcwidth==0.2.13
webcolors==24.11.1
webencodings==0.5.1
websocket-client==1.8.0
zipp==3.21.0
| name: jupyterhub
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alembic==1.15.2
- anyio==4.9.0
- argon2-cffi==23.1.0
- argon2-cffi-bindings==21.2.0
- arrow==1.3.0
- asttokens==3.0.0
- async-generator==1.10
- async-lru==2.0.5
- attrs==25.3.0
- babel==2.17.0
- beautifulsoup4==4.13.3
- bleach==6.2.0
- certifi==2025.1.31
- certipy==0.2.2
- cffi==1.17.1
- cfgv==3.4.0
- charset-normalizer==3.4.1
- cli-ui==0.19.0
- codecov==2.1.13
- colorama==0.4.6
- comm==0.2.2
- coverage==7.8.0
- cryptography==44.0.2
- debugpy==1.8.13
- decorator==5.2.1
- defusedxml==0.7.1
- distlib==0.3.9
- docopt==0.6.2
- entrypoints==0.4
- exceptiongroup==1.2.2
- executing==2.2.0
- fastjsonschema==2.21.1
- filelock==3.18.0
- fqdn==1.5.1
- greenlet==3.1.1
- h11==0.14.0
- html5lib==1.1
- httpcore==1.0.7
- httpx==0.28.1
- identify==2.6.9
- idna==3.10
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- ipykernel==6.29.5
- ipython==8.18.1
- isoduration==20.11.0
- jedi==0.19.2
- jinja2==3.1.6
- json5==0.10.0
- jsonpointer==3.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- jupyter-client==8.6.3
- jupyter-core==5.7.2
- jupyter-events==0.12.0
- jupyter-lsp==2.2.5
- jupyter-server==2.15.0
- jupyter-server-terminals==0.5.3
- jupyter-telemetry==0.1.0
- jupyterhub==2.1.0.dev0
- jupyterlab==4.3.6
- jupyterlab-pygments==0.3.0
- jupyterlab-server==2.27.3
- mako==1.3.9
- markupsafe==3.0.2
- matplotlib-inline==0.1.7
- mistune==3.1.3
- mock==5.2.0
- nbclient==0.10.2
- nbconvert==7.16.6
- nbformat==5.10.4
- nest-asyncio==1.6.0
- nodeenv==1.9.1
- notebook-shim==0.2.4
- oauthlib==3.2.2
- overrides==7.7.0
- packaging==24.2
- pamela==1.2.0
- pandocfilters==1.5.1
- parso==0.8.4
- pexpect==4.9.0
- platformdirs==4.3.7
- pluggy==1.5.0
- pre-commit==4.2.0
- prometheus-client==0.21.1
- prompt-toolkit==3.0.50
- psutil==7.0.0
- ptyprocess==0.7.0
- pure-eval==0.2.3
- pycparser==2.22
- pygments==2.19.1
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- python-dateutil==2.9.0.post0
- python-json-logger==3.3.0
- pyyaml==6.0.2
- pyzmq==26.3.0
- referencing==0.36.2
- requests==2.32.3
- requests-mock==1.12.1
- rfc3339-validator==0.1.4
- rfc3986-validator==0.1.1
- rpds-py==0.24.0
- ruamel-yaml==0.18.10
- ruamel-yaml-clib==0.2.12
- schema==0.7.7
- send2trash==1.8.3
- six==1.17.0
- sniffio==1.3.1
- soupsieve==2.6
- sqlalchemy==2.0.40
- stack-data==0.6.3
- tabulate==0.9.0
- tbump==6.11.0
- terminado==0.18.1
- tinycss2==1.4.0
- tomli==2.2.1
- tomlkit==0.11.8
- tornado==6.4.2
- traitlets==5.14.3
- types-python-dateutil==2.9.0.20241206
- typing-extensions==4.13.0
- unidecode==1.3.8
- uri-template==1.3.0
- urllib3==2.3.0
- virtualenv==20.29.3
- wcwidth==0.2.13
- webcolors==24.11.1
- webencodings==0.5.1
- websocket-client==1.8.0
- zipp==3.21.0
prefix: /opt/conda/envs/jupyterhub
| [
"jupyterhub/tests/test_utils.py::test_browser_protocol[---_attr_]",
"jupyterhub/tests/test_utils.py::test_browser_protocol[for=1.2.3.4---_attr_]",
"jupyterhub/tests/test_utils.py::test_browser_protocol[for=1.2.3.4,proto=https---_attr_]",
"jupyterhub/tests/test_utils.py::test_browser_protocol[-https-http-https]",
"jupyterhub/tests/test_utils.py::test_browser_protocol[-https,",
"jupyterhub/tests/test_utils.py::test_browser_protocol[proto=http",
"jupyterhub/tests/test_utils.py::test_browser_protocol[proto=invalid;for=1.2.3.4,proto=http-https,",
"jupyterhub/tests/test_utils.py::test_browser_protocol[for=1.2.3.4,proto=http-https,",
"jupyterhub/tests/test_utils.py::test_browser_protocol[-invalid,"
] | [] | [] | [] | BSD 3-Clause "New" or "Revised" License | 11,958 | 1,633 | [
"jupyterhub/apihandlers/auth.py",
"jupyterhub/apihandlers/base.py",
"jupyterhub/handlers/base.py",
"jupyterhub/services/auth.py",
"jupyterhub/utils.py"
] |
|
onicagroup__runway-1132 | a3174978c5053ac93d021390ed7990e10864f349 | 2022-01-07 17:29:20 | 888db421da760c7bf4915c29e351f24d97989c73 | codecov[bot]: # [Codecov](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) Report
> Merging [#1132](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) (21ff682) into [master](https://codecov.io/gh/onicagroup/runway/commit/a3174978c5053ac93d021390ed7990e10864f349?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) (a317497) will **not change** coverage.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup)
```diff
@@ Coverage Diff @@
## master #1132 +/- ##
=======================================
Coverage 89.48% 89.48%
=======================================
Files 247 247
Lines 15295 15295
=======================================
Hits 13686 13686
Misses 1609 1609
```
| [Impacted Files](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) | Coverage Δ | |
|---|---|---|
| [runway/core/providers/aws/\_response.py](https://codecov.io/gh/onicagroup/runway/pull/1132/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup#diff-cnVud2F5L2NvcmUvcHJvdmlkZXJzL2F3cy9fcmVzcG9uc2UucHk=) | `100.00% <100.00%> (ø)` | |
| [runway/core/providers/aws/s3/\_bucket.py](https://codecov.io/gh/onicagroup/runway/pull/1132/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup#diff-cnVud2F5L2NvcmUvcHJvdmlkZXJzL2F3cy9zMy9fYnVja2V0LnB5) | `100.00% <100.00%> (ø)` | |
------
[Continue to review full report at Codecov](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup). Last update [a317497...21ff682](https://codecov.io/gh/onicagroup/runway/pull/1132?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup).
| diff --git a/runway/core/providers/aws/_response.py b/runway/core/providers/aws/_response.py
index 8727a65d..687c7c2f 100644
--- a/runway/core/providers/aws/_response.py
+++ b/runway/core/providers/aws/_response.py
@@ -1,75 +1,64 @@
"""Base class for AWS responses."""
# pylint: disable=invalid-name
from http import HTTPStatus
-from typing import Any, Dict, Optional
+from typing import Any, Dict
+from pydantic import Field
-class ResponseError:
+from ....utils import BaseModel
+
+
+class ResponseError(BaseModel):
"""Analyse the response from AWS S3 HeadBucket API response.
- Attributes:
- code: A unique short code representing the error that was emitted.
- message: A longer human readable error message.
+ Keyword Args:
+ Code: A unique short code representing the error that was emitted.
+ Message: A longer human readable error message.
"""
- def __init__(self, *, Code: str = "", Message: str = "") -> None: # noqa
- """Instantiate class.
-
- Args:
- Code: A unique short code representing the error that was emitted.
- Message: A longer human readable error message.
+ code: str = Field(default="", alias="Code")
+ """A unique short code representing the error that was emitted."""
- """
- self.code = Code
- self.message = Message
+ message: str = Field(default="", alias="Message")
+ """A longer human readable error message."""
def __bool__(self) -> bool:
"""Implement evaluation of instances as a bool."""
return bool(self.code or self.message)
-class ResponseMetadata:
+class ResponseMetadata(BaseModel):
"""Analyse the response from AWS S3 HeadBucket API response.
- Attributes:
- host_id: Host ID data.
- https_headers: A map of response header keys and
- their respective values.
- http_status_code: The HTTP status code of the response (e.g., 200, 404).
- request_id: The unique request ID associated with the response.
+ Keyword Args:
+ HostId: Host ID data.
+ HTTPHeaders: A map of response header keys and their respective values.
+ HTTPStatusCode: The HTTP status code of the response (e.g., 200, 404).
+ RequestId: The unique request ID associated with the response.
Log this value when debugging requests for AWS support.
- retry_attempts: The number of retries that were attempted
- before the request was completed.
+ RetryAttempts: The number of retries that were attempted before the
+ request was completed.
+
+ """
+
+ host_id: str = Field(default="", alias="HostId")
+ """Host ID data."""
+
+ https_headers: Dict[str, Any] = Field(default={}, alias="HTTPHeaders")
+ """A map of response header keys and their respective values."""
+
+ http_status_code: int = Field(default=200, alias="HTTPStatusCode")
+ """he HTTP status code of the response (e.g., 200, 404)."""
+
+ request_id: str = Field(default="", alias="RequestId")
+ """The unique request ID associated with the response.
+ Log this value when debugging requests for AWS support.
"""
- def __init__(
- self,
- *,
- HostId: Optional[str] = None, # noqa
- HTTPHeaders: Optional[Dict[str, Any]] = None, # noqa
- HTTPStatusCode: int = 200, # noqa
- RequestId: Optional[str] = None, # noqa
- RetryAttempts: int = 0, # noqa
- ) -> None:
- """Instantiate class.
-
- Keyword Args:
- HostId: Host ID data.
- HTTPHeaders: A map of response header keys and their respective values.
- HTTPStatusCode: The HTTP status code of the response (e.g., 200, 404).
- RequestId: The unique request ID associated with the response.
- Log this value when debugging requests for AWS support.
- RetryAttempts: The number of retries that were attempted before the
- request was completed.
-
- """
- self.host_id = HostId
- self.https_headers = HTTPHeaders or {}
- self.http_status_code = HTTPStatusCode
- self.request_id = RequestId
- self.retry_attempts = RetryAttempts
+ retry_attempts: int = Field(default=0, alias="RetryAttempts")
+ """The number of retries that were attempted before the request was completed."""
@property
def forbidden(self) -> bool:
@@ -82,22 +71,19 @@ class ResponseMetadata:
return self.http_status_code == HTTPStatus.NOT_FOUND
-class BaseResponse:
+class BaseResponse(BaseModel):
"""Analyse the response from AWS S3 HeadBucket API response.
- Attributes:
- error: Information about a service or networking error.
- metadata: Information about the request.
+ Keyword Args:
+ Error: Information about a service or networking error.
+ ResponseMetadata: Information about the request.
"""
- def __init__(self, **kwargs: Any) -> None:
- """Instantiate class.
-
- Keyword Args:
- Error: Information about a service or networking error.
- ResponseMetadata: Information about the request.
+ error: ResponseError = Field(default=ResponseError(), alias="Error")
+ """Information about a service or networking error."""
- """
- self.error = ResponseError(**kwargs.pop("Error", {})) # type: ignore
- self.metadata = ResponseMetadata(**kwargs.pop("ResponseMetadata", {})) # type: ignore
+ metadata: ResponseMetadata = Field(
+ default=ResponseMetadata(), alias="ResponseMetadata"
+ )
+ """Information about the request."""
diff --git a/runway/core/providers/aws/s3/_bucket.py b/runway/core/providers/aws/s3/_bucket.py
index 4a69174a..fe0faffa 100644
--- a/runway/core/providers/aws/s3/_bucket.py
+++ b/runway/core/providers/aws/s3/_bucket.py
@@ -83,7 +83,7 @@ class Bucket(DelCachedPropMixin):
self.name,
exc_info=True,
)
- return BaseResponse(**err.response)
+ return BaseResponse.parse_obj(err.response)
@cached_property
def not_found(self) -> bool:
| [TODO] improve `runway.core.providers.aws._response.BaseResponse`
- use pydantic | onicagroup/runway | diff --git a/tests/unit/core/providers/aws/test_response.py b/tests/unit/core/providers/aws/test_response.py
index 1c2f86ef..703ebfa7 100644
--- a/tests/unit/core/providers/aws/test_response.py
+++ b/tests/unit/core/providers/aws/test_response.py
@@ -3,41 +3,29 @@
# pyright: basic
from __future__ import annotations
-from typing import TYPE_CHECKING
-
from runway.core.providers.aws import BaseResponse, ResponseError, ResponseMetadata
-if TYPE_CHECKING:
- from pytest_mock import MockerFixture
-
MODULE = "runway.core.providers.aws._response"
class TestBaseResponse:
"""Test runway.core.providers.aws._response.BaseResponse."""
- def test_init(self, mocker: MockerFixture) -> None:
+ def test_init(self) -> None:
"""Test init and the attributes it sets."""
- mock_error = mocker.patch(f"{MODULE}.ResponseError")
- mock_metadata = mocker.patch(f"{MODULE}.ResponseMetadata")
data = {"Error": {"Code": "something"}, "ResponseMetadata": {"HostId": "id"}}
response = BaseResponse(**data.copy())
- assert response.error == mock_error.return_value
- assert response.metadata == mock_metadata.return_value
- mock_error.assert_called_once_with(**data["Error"])
- mock_metadata.assert_called_once_with(**data["ResponseMetadata"])
+ assert isinstance(response.error, ResponseError)
+ assert response.error.code == data["Error"]["Code"]
+ assert isinstance(response.metadata, ResponseMetadata)
+ assert response.metadata.host_id == data["ResponseMetadata"]["HostId"]
- def test_init_default(self, mocker: MockerFixture) -> None:
+ def test_init_default(self) -> None:
"""Test init default values and the attributes it sets."""
- mock_error = mocker.patch(f"{MODULE}.ResponseError")
- mock_metadata = mocker.patch(f"{MODULE}.ResponseMetadata")
response = BaseResponse()
-
- assert response.error == mock_error.return_value
- assert response.metadata == mock_metadata.return_value
- mock_error.assert_called_once_with()
- mock_metadata.assert_called_once_with()
+ assert response.error == ResponseError()
+ assert response.metadata == ResponseMetadata()
class TestResponseError:
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 2
} | 2.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio",
"mock"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
awacs==2.5.0
aws-sam-translator==1.95.0
boto3==1.37.23
botocore==1.37.23
bracex==2.5.post1
certifi==2025.1.31
cffi==1.17.1
cfn-flip==1.3.0
cfn-lint==1.32.1
charset-normalizer==3.4.1
cli_exit_tools==1.2.7
click==8.1.8
coloredlogs==15.0
coverage==7.8.0
cryptography==44.0.2
docker==7.1.0
exceptiongroup==1.2.2
execnet==2.1.1
formic2==1.0.3
gitdb==4.0.12
GitPython==3.1.44
humanfriendly==10.0
idna==3.10
igittigitt==2.1.5
iniconfig==2.1.0
Jinja2==3.1.6
jmespath==1.0.1
jsonpatch==1.33
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
lark-parser==0.10.1
lib-detect-testenv==2.0.8
MarkupSafe==3.0.2
mock==5.2.0
mpmath==1.3.0
networkx==3.2.1
packaging==24.2
pathspec==0.12.1
pluggy==1.5.0
pycparser==2.22
pydantic==1.10.21
pyhcl==0.4.5
pyOpenSSL==25.0.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-hcl2==2.0.3
PyYAML==6.0.2
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
rpds-py==0.24.0
-e git+https://github.com/onicagroup/runway.git@a3174978c5053ac93d021390ed7990e10864f349#egg=runway
s3transfer==0.11.4
Send2Trash==1.8.3
six==1.17.0
smmap==5.0.2
sympy==1.13.3
tomli==2.2.1
troposphere==3.2.2
typing_extensions==4.13.0
urllib3==1.26.20
wcmatch==10.0
yamllint==1.37.0
| name: runway
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- awacs==2.5.0
- aws-sam-translator==1.95.0
- boto3==1.37.23
- botocore==1.37.23
- bracex==2.5.post1
- certifi==2025.1.31
- cffi==1.17.1
- cfn-flip==1.3.0
- cfn-lint==1.32.1
- charset-normalizer==3.4.1
- cli-exit-tools==1.2.7
- click==8.1.8
- coloredlogs==15.0
- coverage==7.8.0
- cryptography==44.0.2
- docker==7.1.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- formic2==1.0.3
- gitdb==4.0.12
- gitpython==3.1.44
- humanfriendly==10.0
- idna==3.10
- igittigitt==2.1.5
- iniconfig==2.1.0
- jinja2==3.1.6
- jmespath==1.0.1
- jsonpatch==1.33
- jsonpointer==3.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- lark-parser==0.10.1
- lib-detect-testenv==2.0.8
- markupsafe==3.0.2
- mock==5.2.0
- mpmath==1.3.0
- networkx==3.2.1
- packaging==24.2
- pathspec==0.12.1
- pluggy==1.5.0
- pycparser==2.22
- pydantic==1.10.21
- pyhcl==0.4.5
- pyopenssl==25.0.0
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- python-hcl2==2.0.3
- pyyaml==6.0.2
- referencing==0.36.2
- regex==2024.11.6
- requests==2.32.3
- rpds-py==0.24.0
- runway==2.0.0.dev0
- s3transfer==0.11.4
- send2trash==1.8.3
- six==1.17.0
- smmap==5.0.2
- sympy==1.13.3
- tomli==2.2.1
- troposphere==3.2.2
- typing-extensions==4.13.0
- urllib3==1.26.20
- wcmatch==10.0
- yamllint==1.37.0
prefix: /opt/conda/envs/runway
| [
"tests/unit/core/providers/aws/test_response.py::TestBaseResponse::test_init_default"
] | [] | [
"tests/unit/core/providers/aws/test_response.py::TestBaseResponse::test_init",
"tests/unit/core/providers/aws/test_response.py::TestResponseError::test_init",
"tests/unit/core/providers/aws/test_response.py::TestResponseError::test_init_defaults",
"tests/unit/core/providers/aws/test_response.py::TestResponseMetadata::test_forbidden",
"tests/unit/core/providers/aws/test_response.py::TestResponseMetadata::test_init",
"tests/unit/core/providers/aws/test_response.py::TestResponseMetadata::test_init_defaults",
"tests/unit/core/providers/aws/test_response.py::TestResponseMetadata::test_not_found"
] | [] | Apache License 2.0 | 11,960 | 1,483 | [
"runway/core/providers/aws/_response.py",
"runway/core/providers/aws/s3/_bucket.py"
] |
onicagroup__runway-1133 | 35e3fe7c4479d585c9d9a41d8848a22ef1840d68 | 2022-01-07 19:21:31 | 888db421da760c7bf4915c29e351f24d97989c73 | codecov[bot]: # [Codecov](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) Report
> Merging [#1133](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) (f17c568) into [master](https://codecov.io/gh/onicagroup/runway/commit/35e3fe7c4479d585c9d9a41d8848a22ef1840d68?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) (35e3fe7) will **decrease** coverage by `0.00%`.
> The diff coverage is `83.33%`.
[](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup)
```diff
@@ Coverage Diff @@
## master #1133 +/- ##
==========================================
- Coverage 89.48% 89.47% -0.01%
==========================================
Files 247 247
Lines 15295 15297 +2
==========================================
+ Hits 13686 13687 +1
- Misses 1609 1610 +1
```
| [Impacted Files](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) | Coverage Δ | |
|---|---|---|
| [runway/core/providers/aws/s3/\_bucket.py](https://codecov.io/gh/onicagroup/runway/pull/1133/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup#diff-cnVud2F5L2NvcmUvcHJvdmlkZXJzL2F3cy9zMy9fYnVja2V0LnB5) | `98.59% <83.33%> (-1.41%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup). Last update [35e3fe7...f17c568](https://codecov.io/gh/onicagroup/runway/pull/1133?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup).
| diff --git a/runway/core/providers/aws/s3/_bucket.py b/runway/core/providers/aws/s3/_bucket.py
index fe0faffa..d0f508b5 100644
--- a/runway/core/providers/aws/s3/_bucket.py
+++ b/runway/core/providers/aws/s3/_bucket.py
@@ -53,14 +53,10 @@ class Bucket(DelCachedPropMixin):
@property
def exists(self) -> bool:
- """Check whether the bucket exists.
+ """Check whether the bucket exists and is accessible."""
+ return not self.forbidden and not self.not_found
- Opposite of not_found.
-
- """
- return not self.not_found
-
- @cached_property
+ @property
def forbidden(self) -> bool:
"""Check whether access to the bucket is forbidden."""
return self.head.metadata.forbidden
@@ -85,7 +81,7 @@ class Bucket(DelCachedPropMixin):
)
return BaseResponse.parse_obj(err.response)
- @cached_property
+ @property
def not_found(self) -> bool:
"""Check whether the bucket exists."""
return self.head.metadata.not_found
@@ -120,7 +116,7 @@ class Bucket(DelCachedPropMixin):
{"LocationConstraint": self.client.meta.region_name}
)
LOGGER.debug("creating bucket: %s", json.dumps(kwargs))
- self._del_cached_property("forbidden", "not_found", "head")
+ self._del_cached_property("head")
return self.client.create_bucket(**kwargs)
def enable_versioning(self) -> None:
@@ -239,3 +235,7 @@ class Bucket(DelCachedPropMixin):
session=self.session,
src=self.format_bucket_path_uri(prefix=prefix),
).run()
+
+ def __bool__(self) -> bool:
+ """Implement evaluation of instances as a bool."""
+ return self.exists
| [TODO] add `_bool_` to `runway.core.providers.aws.s3._bucket.Bucket`
- `False` if `.forbidden` or `not .exists`
- `True` if `.exists`
- assess if `.exists` should be `False` if `forbidden`
| onicagroup/runway | diff --git a/tests/unit/core/providers/aws/s3/test_bucket.py b/tests/unit/core/providers/aws/s3/test_bucket.py
index 7df842ed..2a93dc29 100644
--- a/tests/unit/core/providers/aws/s3/test_bucket.py
+++ b/tests/unit/core/providers/aws/s3/test_bucket.py
@@ -7,6 +7,7 @@ import logging
from http import HTTPStatus
from typing import TYPE_CHECKING
+import pytest
from mock import MagicMock
from runway.core.providers.aws import BaseResponse
@@ -24,6 +25,31 @@ MODULE = "runway.core.providers.aws.s3._bucket"
class TestBucket:
"""Test runway.core.providers.aws.s3._bucket.Bucket."""
+ @pytest.mark.parametrize(
+ "forbidden, not_found, expected",
+ [
+ (False, False, True),
+ (False, True, False),
+ (True, False, False),
+ ],
+ )
+ def test___bool__(
+ self,
+ expected: bool,
+ forbidden: bool,
+ mocker: MockerFixture,
+ not_found: bool,
+ runway_context: MockRunwayContext,
+ ) -> None:
+ """Test __bool__."""
+ response = BaseResponse()
+ if forbidden:
+ response.metadata.http_status_code = HTTPStatus.FORBIDDEN
+ elif not_found:
+ response.metadata.http_status_code = HTTPStatus.NOT_FOUND
+ mocker.patch.object(Bucket, "head", response)
+ assert Bucket(runway_context, "test-bucket").exists is expected
+
def test_client(self) -> None:
"""Test client."""
mock_ctx = MagicMock()
@@ -170,37 +196,46 @@ class TestBucket:
'did not modify versioning policy for bucket "test-bucket"; already enabled'
) in caplog.messages
+ @pytest.mark.parametrize(
+ "forbidden, not_found, expected",
+ [
+ (False, False, True),
+ (False, True, False),
+ (True, False, False),
+ ],
+ )
def test_exists(
- self, mocker: MockerFixture, runway_context: MockRunwayContext
+ self,
+ expected: bool,
+ forbidden: bool,
+ mocker: MockerFixture,
+ not_found: bool,
+ runway_context: MockRunwayContext,
) -> None:
"""Test not_found."""
- mock_head = mocker.patch.object(Bucket, "head", spec=BaseResponse())
- bucket = Bucket(runway_context, "test-bucket")
-
- mock_head.metadata.not_found = True
- assert not bucket.exists # initial value
-
- mock_head.metadata.not_found = False
- assert not bucket.exists # cached value
- del bucket.not_found
-
- assert bucket.exists # updated value
-
+ response = BaseResponse()
+ if forbidden:
+ response.metadata.http_status_code = HTTPStatus.FORBIDDEN
+ elif not_found:
+ response.metadata.http_status_code = HTTPStatus.NOT_FOUND
+ mocker.patch.object(Bucket, "head", response)
+ assert Bucket(runway_context, "test-bucket").exists is expected
+
+ @pytest.mark.parametrize("forbidden, expected", [(True, True), (False, False)])
def test_forbidden(
- self, mocker: MockerFixture, runway_context: MockRunwayContext
+ self,
+ expected: bool,
+ forbidden: bool,
+ mocker: MockerFixture,
+ runway_context: MockRunwayContext,
) -> None:
"""Test forbidden."""
- mock_head = mocker.patch.object(Bucket, "head", spec=BaseResponse())
- bucket = Bucket(runway_context, "test-bucket")
-
- mock_head.metadata.forbidden = True
- assert bucket.forbidden # initial value
-
- mock_head.metadata.forbidden = False
- assert bucket.forbidden # cached value
- del bucket.forbidden
-
- assert not bucket.forbidden # updated value
+ response = BaseResponse()
+ response.metadata.http_status_code = (
+ HTTPStatus.FORBIDDEN if forbidden else HTTPStatus.OK
+ )
+ mocker.patch.object(Bucket, "head", response)
+ assert Bucket(runway_context, "test-bucket").forbidden is expected
def test_format_bucket_path_uri(self) -> None:
"""Test format_bucket_path_uri."""
@@ -266,21 +301,21 @@ class TestBucket:
stubber.assert_no_pending_responses()
assert "received an error from AWS S3" in "\n".join(caplog.messages)
+ @pytest.mark.parametrize("not_found, expected", [(True, True), (False, False)])
def test_not_found(
- self, mocker: MockerFixture, runway_context: MockRunwayContext
+ self,
+ expected: bool,
+ mocker: MockerFixture,
+ not_found: bool,
+ runway_context: MockRunwayContext,
) -> None:
"""Test not_found."""
- mock_head = mocker.patch.object(Bucket, "head", spec=BaseResponse())
- bucket = Bucket(runway_context, "test-bucket")
-
- mock_head.metadata.not_found = True
- assert bucket.not_found # initial value
-
- mock_head.metadata.not_found = False
- assert bucket.not_found # cached value
- del bucket.not_found
-
- assert not bucket.not_found # updated value
+ response = BaseResponse()
+ response.metadata.http_status_code = (
+ HTTPStatus.NOT_FOUND if not_found else HTTPStatus.OK
+ )
+ mocker.patch.object(Bucket, "head", response)
+ assert Bucket(runway_context, "test-bucket").not_found is expected
def test_sync_from_local(
self, mocker: MockerFixture, runway_context: MockRunwayContext
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 2.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio",
"mock"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
awacs==2.5.0
aws-sam-translator==1.95.0
boto3==1.37.23
botocore==1.37.23
bracex==2.5.post1
certifi==2025.1.31
cffi==1.17.1
cfn-flip==1.3.0
cfn-lint==1.32.1
charset-normalizer==3.4.1
cli_exit_tools==1.2.7
click==8.1.8
coloredlogs==15.0
coverage==7.8.0
cryptography==44.0.2
docker==7.1.0
exceptiongroup==1.2.2
execnet==2.1.1
formic2==1.0.3
gitdb==4.0.12
GitPython==3.1.44
humanfriendly==10.0
idna==3.10
igittigitt==2.1.5
iniconfig==2.1.0
Jinja2==3.1.6
jmespath==1.0.1
jsonpatch==1.33
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
lark-parser==0.10.1
lib-detect-testenv==2.0.8
MarkupSafe==3.0.2
mock==5.2.0
mpmath==1.3.0
networkx==3.2.1
packaging==24.2
pathspec==0.12.1
pluggy==1.5.0
pycparser==2.22
pydantic==1.10.21
pyhcl==0.4.5
pyOpenSSL==25.0.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-hcl2==2.0.3
PyYAML==6.0.2
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
rpds-py==0.24.0
-e git+https://github.com/onicagroup/runway.git@35e3fe7c4479d585c9d9a41d8848a22ef1840d68#egg=runway
s3transfer==0.11.4
Send2Trash==1.8.3
six==1.17.0
smmap==5.0.2
sympy==1.13.3
tomli==2.2.1
troposphere==3.2.2
typing_extensions==4.13.0
urllib3==1.26.20
wcmatch==10.0
yamllint==1.37.0
| name: runway
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- awacs==2.5.0
- aws-sam-translator==1.95.0
- boto3==1.37.23
- botocore==1.37.23
- bracex==2.5.post1
- certifi==2025.1.31
- cffi==1.17.1
- cfn-flip==1.3.0
- cfn-lint==1.32.1
- charset-normalizer==3.4.1
- cli-exit-tools==1.2.7
- click==8.1.8
- coloredlogs==15.0
- coverage==7.8.0
- cryptography==44.0.2
- docker==7.1.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- formic2==1.0.3
- gitdb==4.0.12
- gitpython==3.1.44
- humanfriendly==10.0
- idna==3.10
- igittigitt==2.1.5
- iniconfig==2.1.0
- jinja2==3.1.6
- jmespath==1.0.1
- jsonpatch==1.33
- jsonpointer==3.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- lark-parser==0.10.1
- lib-detect-testenv==2.0.8
- markupsafe==3.0.2
- mock==5.2.0
- mpmath==1.3.0
- networkx==3.2.1
- packaging==24.2
- pathspec==0.12.1
- pluggy==1.5.0
- pycparser==2.22
- pydantic==1.10.21
- pyhcl==0.4.5
- pyopenssl==25.0.0
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- python-hcl2==2.0.3
- pyyaml==6.0.2
- referencing==0.36.2
- regex==2024.11.6
- requests==2.32.3
- rpds-py==0.24.0
- runway==2.0.0.dev0
- s3transfer==0.11.4
- send2trash==1.8.3
- six==1.17.0
- smmap==5.0.2
- sympy==1.13.3
- tomli==2.2.1
- troposphere==3.2.2
- typing-extensions==4.13.0
- urllib3==1.26.20
- wcmatch==10.0
- yamllint==1.37.0
prefix: /opt/conda/envs/runway
| [
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test___bool__[True-False-False]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_exists[True-False-False]"
] | [] | [
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test___bool__[False-False-True]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test___bool__[False-True-False]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_client",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_create",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_create_exists",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_create_forbidden",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_create_us_west_2",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_enable_versioning",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_enable_versioning_skipped",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_exists[False-False-True]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_exists[False-True-False]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_forbidden[True-True]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_forbidden[False-False]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_format_bucket_path_uri",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_get_versioning",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_head",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_head_clienterror",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_not_found[True-True]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_not_found[False-False]",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_sync_from_local",
"tests/unit/core/providers/aws/s3/test_bucket.py::TestBucket::test_sync_to_local"
] | [] | Apache License 2.0 | 11,961 | 439 | [
"runway/core/providers/aws/s3/_bucket.py"
] |
pypa__auditwheel-367 | 68aad23937225a629d70cb4b3e224abd07f16f44 | 2022-01-07 22:20:14 | 73c9f17982cac73a48b92ecb8b770d73275b000b | codecov[bot]: # [Codecov](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa) Report
> Merging [#367](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa) (1dd0172) into [main](https://codecov.io/gh/pypa/auditwheel/commit/68aad23937225a629d70cb4b3e224abd07f16f44?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa) (68aad23) will **decrease** coverage by `1.41%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa)
```diff
@@ Coverage Diff @@
## main #367 +/- ##
==========================================
- Coverage 92.35% 90.93% -1.42%
==========================================
Files 23 23
Lines 1256 1258 +2
Branches 307 307
==========================================
- Hits 1160 1144 -16
- Misses 55 67 +12
- Partials 41 47 +6
```
| [Impacted Files](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa) | Coverage Δ | |
|---|---|---|
| [src/auditwheel/tools.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvdG9vbHMucHk=) | `93.93% <100.00%> (+0.18%)` | :arrow_up: |
| [src/auditwheel/main\_addtag.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvbWFpbl9hZGR0YWcucHk=) | `65.78% <0.00%> (-23.69%)` | :arrow_down: |
| [src/auditwheel/main.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvbWFpbi5weQ==) | `94.44% <0.00%> (-5.56%)` | :arrow_down: |
| [src/auditwheel/wheeltools.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvd2hlZWx0b29scy5weQ==) | `87.85% <0.00%> (-2.15%)` | :arrow_down: |
| [src/auditwheel/elfutils.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvZWxmdXRpbHMucHk=) | `93.06% <0.00%> (-1.99%)` | :arrow_down: |
| [src/auditwheel/policy/\_\_init\_\_.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvcG9saWN5L19faW5pdF9fLnB5) | `99.09% <0.00%> (-0.91%)` | :arrow_down: |
| [src/auditwheel/lddtree.py](https://codecov.io/gh/pypa/auditwheel/pull/367/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa#diff-c3JjL2F1ZGl0d2hlZWwvbGRkdHJlZS5weQ==) | `89.74% <0.00%> (-0.65%)` | :arrow_down: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa). Last update [68aad23...1dd0172](https://codecov.io/gh/pypa/auditwheel/pull/367?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pypa).
| diff --git a/src/auditwheel/tools.py b/src/auditwheel/tools.py
index ed8b514..bce72f2 100644
--- a/src/auditwheel/tools.py
+++ b/src/auditwheel/tools.py
@@ -70,19 +70,21 @@ def dir2zip(in_dir: str, zip_fname: str, date_time: Optional[datetime] = None) -
st = os.stat(in_dir)
date_time = datetime.fromtimestamp(st.st_mtime, tz=timezone.utc)
date_time_args = date_time.timetuple()[:6]
- with zipfile.ZipFile(zip_fname, "w", compression=zipfile.ZIP_DEFLATED) as z:
+ compression = zipfile.ZIP_DEFLATED
+ with zipfile.ZipFile(zip_fname, "w", compression=compression) as z:
for root, dirs, files in os.walk(in_dir):
for dir in dirs:
dname = os.path.join(root, dir)
out_dname = os.path.relpath(dname, in_dir) + "/"
- zinfo = zipfile.ZipInfo(out_dname, date_time=date_time_args)
- zinfo.external_attr = os.stat(dname).st_mode << 16
- z.writestr(zinfo, "")
+ zinfo = zipfile.ZipInfo.from_file(dname, out_dname)
+ zinfo.date_time = date_time_args
+ z.writestr(zinfo, b"")
for file in files:
fname = os.path.join(root, file)
out_fname = os.path.relpath(fname, in_dir)
- zinfo = zipfile.ZipInfo(out_fname, date_time=date_time_args)
- zinfo.external_attr = os.stat(fname).st_mode << 16
+ zinfo = zipfile.ZipInfo.from_file(fname, out_fname)
+ zinfo.date_time = date_time_args
+ zinfo.compress_type = compression
with open(fname, "rb") as fp:
z.writestr(zinfo, fp.read())
| auditwheel repair: whls not getting compressed for auditwheel 5.1.0 and above?
After upgrading to 5.1.0, we noticed that our wheels are not getting compressed, resulting in very large whls after running `auditwheel repair foo.whl`:
```
-rw-r--r-- 1 root root 104093514 Jan 7 01:54 accera-1.2.1.dev17-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.5.1.0.whl
```
auditwheel 5.0.0 was able to compress the whls by roughly 70%:
```
-rw-r--r-- 1 root root 35413658 Jan 7 01:44 accera-1.2.1.dev17-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.5.0.0.whl
```
The contents of both files are the same after unzipping, so the binaries themselves are unchanged but the whl does not seem to be compressed when using auditwheel 5.1.0 and above.
```shell
[root@9a0260dd545d wheelhouse]# ls -al accera-5.0.0/
total 101324
drwxr-xr-x 8 root root 4096 Jan 7 01:44 .
drwxr-xr-x 6 root root 4096 Jan 7 01:55 ..
-rw-r--r-- 1 root root 476 Jan 7 01:44 Constants.py
-rw-r--r-- 1 root root 3219 Jan 7 01:44 Debug.py
drwxr-xr-x 2 root root 4096 Jan 7 01:44 hat
-rw-r--r-- 1 root root 1035 Jan 7 01:44 __init__.py
drwxr-xr-x 2 root root 4096 Jan 7 01:44 lang
-rwxr-xr-x 1 root root 103664768 Jan 7 01:44 _lang_python.cpython-38-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 20883 Jan 7 01:44 Package.py
-rw-r--r-- 1 root root 1563 Jan 7 01:44 Parameter.py
drwxr-xr-x 2 root root 4096 Jan 7 01:44 samples
-rw-r--r-- 1 root root 9045 Jan 7 01:44 Targets.py
drwxr-xr-x 2 root root 4096 Jan 7 01:44 test
drwxr-xr-x 3 root root 4096 Jan 7 01:44 tools
drwxr-xr-x 2 root root 4096 Jan 7 01:44 tuning
-rw-r--r-- 1 root root 36 Jan 7 01:44 _version.py
[root@9a0260dd545d wheelhouse]# ls -al accera-5.1.0/
total 101324
drwxr-xr-x 8 root root 4096 Jan 7 01:54 .
drwxr-xr-x 6 root root 4096 Jan 7 01:55 ..
-rw-r--r-- 1 root root 476 Jan 7 01:54 Constants.py
-rw-r--r-- 1 root root 3219 Jan 7 01:54 Debug.py
drwxr-xr-x 2 root root 4096 Jan 7 01:54 hat
-rw-r--r-- 1 root root 1035 Jan 7 01:54 __init__.py
drwxr-xr-x 2 root root 4096 Jan 7 01:54 lang
-rwxr-xr-x 1 root root 103664768 Jan 7 01:54 _lang_python.cpython-38-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 20883 Jan 7 01:54 Package.py
-rw-r--r-- 1 root root 1563 Jan 7 01:54 Parameter.py
drwxr-xr-x 2 root root 4096 Jan 7 01:54 samples
-rw-r--r-- 1 root root 9045 Jan 7 01:54 Targets.py
drwxr-xr-x 2 root root 4096 Jan 7 01:54 test
drwxr-xr-x 3 root root 4096 Jan 7 01:54 tools
drwxr-xr-x 2 root root 4096 Jan 7 01:54 tuning
-rw-r--r-- 1 root root 36 Jan 7 01:54 _version.py
```
| pypa/auditwheel | diff --git a/tests/unit/test_tools.py b/tests/unit/test_tools.py
index dd2a086..ee79467 100644
--- a/tests/unit/test_tools.py
+++ b/tests/unit/test_tools.py
@@ -87,3 +87,14 @@ def test_zip2dir_round_trip_permissions(tmp_path):
dir2zip(str(tmp_path / "unzip1"), str(tmp_path / "tmp.zip"))
zip2dir(str(tmp_path / "tmp.zip"), str(extract_path))
_check_permissions(extract_path)
+
+
+def test_dir2zip_deflate(tmp_path):
+ buffer = b"\0" * 1024 * 1024
+ input_dir = tmp_path / "input_dir"
+ input_dir.mkdir()
+ input_file = input_dir / "zeros.bin"
+ input_file.write_bytes(buffer)
+ output_file = tmp_path / "ouput.zip"
+ dir2zip(str(input_dir), str(output_file))
+ assert output_file.stat().st_size < len(buffer) / 4
| {
"commit_name": "merge_commit",
"failed_lite_validators": [],
"has_test_patch": true,
"is_lite": true,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 0
},
"num_modified_files": 1
} | 5.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"numpy>=1.16.0",
"pandas>=1.0.0"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc patchelf make pkg-config"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/pypa/auditwheel.git@68aad23937225a629d70cb4b3e224abd07f16f44#egg=auditwheel
exceptiongroup==1.2.2
iniconfig==2.1.0
numpy==2.0.2
packaging==24.2
pandas==2.2.3
pluggy==1.5.0
pyelftools==0.32
pytest==8.3.5
python-dateutil==2.9.0.post0
pytz==2025.2
six==1.17.0
tomli==2.2.1
tzdata==2025.2
| name: auditwheel
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- auditwheel==5.1.1
- exceptiongroup==1.2.2
- iniconfig==2.1.0
- numpy==2.0.2
- packaging==24.2
- pandas==2.2.3
- pluggy==1.5.0
- pyelftools==0.32
- pytest==8.3.5
- python-dateutil==2.9.0.post0
- pytz==2025.2
- six==1.17.0
- tomli==2.2.1
- tzdata==2025.2
prefix: /opt/conda/envs/auditwheel
| [
"tests/unit/test_tools.py::test_dir2zip_deflate"
] | [] | [
"tests/unit/test_tools.py::test_environment_action[None-None-manylinux1]",
"tests/unit/test_tools.py::test_environment_action[None-manylinux2010-manylinux2010]",
"tests/unit/test_tools.py::test_environment_action[manylinux2010-None-manylinux2010]",
"tests/unit/test_tools.py::test_environment_action[manylinux2010-linux-linux]",
"tests/unit/test_tools.py::test_environment_action_invalid_env",
"tests/unit/test_tools.py::test_zip2dir_permissions",
"tests/unit/test_tools.py::test_zip2dir_round_trip_permissions"
] | [] | MIT License | 11,963 | 443 | [
"src/auditwheel/tools.py"
] |
mahmoud__boltons-298 | 270e974975984f662f998c8f6eb0ebebd964de82 | 2022-01-09 10:48:16 | 9420cfeb3b1eb270fad876d002bf92567e619b0c | mahmoud: Nice work, appreciate the tests! Also check out [hyperlink](https://github.com/python-hyper/hyperlink). It's a bit different, but might fit the bill in some cases. :) Thanks again! | diff --git a/boltons/urlutils.py b/boltons/urlutils.py
index 6016e8a..7462ed4 100644
--- a/boltons/urlutils.py
+++ b/boltons/urlutils.py
@@ -685,7 +685,8 @@ class URL(object):
if dest.path.startswith(u'/'): # absolute path
new_path_parts = list(dest.path_parts)
else: # relative path
- new_path_parts = self.path_parts[:-1] + dest.path_parts
+ new_path_parts = list(self.path_parts[:-1]) \
+ + list(dest.path_parts)
else:
new_path_parts = list(self.path_parts)
if not query_params:
| URL.navigate fails with path in base URL
The following and several permutations fail attempting to concatenate a `tuple` with a `list`:
```
URL('http://localhost').navigate('a').navigate('b')
```
Result:
```
...
else: # relative path
> new_path_parts = list(self.path_parts[:-1]) + dest.path_parts
E TypeError: can only concatenate list (not "tuple") to list
boltons/urlutils.py:657: TypeError
```
I am a little unclear about exactly what *should* happen when 'a' has a trailing slash or not, but enough cases fail that I know *something* is wrong.
I will follow shortly with a PR with a number of test cases, some of which I know are wrong, so I am hoping I can get some clarification about what the correct behavior *should* be.
This is not strictly an issue with chaining the `navigate` calls, but rather ambiguity of what should happen with the base URL lacks a trailing '/' and failures that result from that.
Env data:
platform darwin
Python 3.6.5 (built w/pyenv)
pytest-3.5.1 | mahmoud/boltons | diff --git a/tests/test_urlutils.py b/tests/test_urlutils.py
index a8e1539..2351899 100644
--- a/tests/test_urlutils.py
+++ b/tests/test_urlutils.py
@@ -313,6 +313,25 @@ def test_navigate():
assert navd.to_text() == _dest_text
[email protected](
+ ('expected', 'base', 'paths'), [
+ ('https://host/b', 'https://host', ('a', '/b', )),
+ ('https://host/b', 'https://host', ('a', 'b', )),
+ ('https://host/a/b', 'https://host', ('a/', 'b', )),
+ ('https://host/b', 'https://host', ('/a', 'b', )),
+ ('https://host/a/b', 'https://host/a/', (None, 'b', )),
+ ('https://host/b', 'https://host/a', (None, 'b', )),
+])
+def test_chained_navigate(expected, base, paths):
+ """Chained :meth:`navigate` calls produces correct results."""
+ url = URL(base)
+
+ for path in paths:
+ url = url.navigate(path)
+
+ assert expected == url.to_text()
+
+
# TODO: RFC3986 6.2.3 (not just for query add, either)
# def test_add_query():
# url = URL('http://www.example.com')
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 2,
"test_score": 0
},
"num_modified_files": 1
} | 21.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "pytest",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/mahmoud/boltons.git@270e974975984f662f998c8f6eb0ebebd964de82#egg=boltons
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
| name: boltons
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- exceptiongroup=1.2.0=py39h06a4308_0
- iniconfig=1.1.1=pyhd3eb1b0_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- packaging=24.2=py39h06a4308_0
- pip=25.0=py39h06a4308_0
- pluggy=1.5.0=py39h06a4308_0
- pytest=8.3.4=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tomli=2.0.1=py39h06a4308_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
prefix: /opt/conda/envs/boltons
| [
"tests/test_urlutils.py::test_chained_navigate[https://host/b-https://host-paths1]",
"tests/test_urlutils.py::test_chained_navigate[https://host/a/b-https://host-paths2]",
"tests/test_urlutils.py::test_chained_navigate[https://host/b-https://host-paths3]",
"tests/test_urlutils.py::test_chained_navigate[https://host/a/b-https://host/a/-paths4]",
"tests/test_urlutils.py::test_chained_navigate[https://host/b-https://host/a-paths5]"
] | [] | [
"tests/test_urlutils.py::test_regex[http://googlewebsite.com/e-shops.aspx]",
"tests/test_urlutils.py::test_roundtrip[http://googlewebsite.com/e-shops.aspx]",
"tests/test_urlutils.py::test_query_params[http://googlewebsite.com/e-shops.aspx]",
"tests/test_urlutils.py::test_regex[http://example.com:8080/search?q=123&business=Nothing%20Special]",
"tests/test_urlutils.py::test_roundtrip[http://example.com:8080/search?q=123&business=Nothing%20Special]",
"tests/test_urlutils.py::test_query_params[http://example.com:8080/search?q=123&business=Nothing%20Special]",
"tests/test_urlutils.py::test_regex[http://hatnote.com:9000?arg=1&arg=2&arg=3]",
"tests/test_urlutils.py::test_roundtrip[http://hatnote.com:9000?arg=1&arg=2&arg=3]",
"tests/test_urlutils.py::test_query_params[http://hatnote.com:9000?arg=1&arg=2&arg=3]",
"tests/test_urlutils.py::test_regex[https://xn--bcher-kva.ch]",
"tests/test_urlutils.py::test_roundtrip[https://xn--bcher-kva.ch]",
"tests/test_urlutils.py::test_query_params[https://xn--bcher-kva.ch]",
"tests/test_urlutils.py::test_regex[http://xn--ggbla1c4e.xn--ngbc5azd/]",
"tests/test_urlutils.py::test_roundtrip[http://xn--ggbla1c4e.xn--ngbc5azd/]",
"tests/test_urlutils.py::test_query_params[http://xn--ggbla1c4e.xn--ngbc5azd/]",
"tests/test_urlutils.py::test_regex[http://tools.ietf.org/html/rfc3986#section-3.4]",
"tests/test_urlutils.py::test_roundtrip[http://tools.ietf.org/html/rfc3986#section-3.4]",
"tests/test_urlutils.py::test_query_params[http://tools.ietf.org/html/rfc3986#section-3.4]",
"tests/test_urlutils.py::test_regex[http://wiki:[email protected]]",
"tests/test_urlutils.py::test_roundtrip[http://wiki:[email protected]]",
"tests/test_urlutils.py::test_query_params[http://wiki:[email protected]]",
"tests/test_urlutils.py::test_regex[ftp://ftp.rfc-editor.org/in-notes/tar/RFCs0001-0500.tar.gz]",
"tests/test_urlutils.py::test_roundtrip[ftp://ftp.rfc-editor.org/in-notes/tar/RFCs0001-0500.tar.gz]",
"tests/test_urlutils.py::test_query_params[ftp://ftp.rfc-editor.org/in-notes/tar/RFCs0001-0500.tar.gz]",
"tests/test_urlutils.py::test_regex[http://[1080:0:0:0:8:800:200C:417A]/index.html]",
"tests/test_urlutils.py::test_roundtrip[http://[1080:0:0:0:8:800:200C:417A]/index.html]",
"tests/test_urlutils.py::test_query_params[http://[1080:0:0:0:8:800:200C:417A]/index.html]",
"tests/test_urlutils.py::test_regex[ssh://192.0.2.16:2222/]",
"tests/test_urlutils.py::test_roundtrip[ssh://192.0.2.16:2222/]",
"tests/test_urlutils.py::test_query_params[ssh://192.0.2.16:2222/]",
"tests/test_urlutils.py::test_regex[https://[::101.45.75.219]:80/?hi=bye]",
"tests/test_urlutils.py::test_roundtrip[https://[::101.45.75.219]:80/?hi=bye]",
"tests/test_urlutils.py::test_query_params[https://[::101.45.75.219]:80/?hi=bye]",
"tests/test_urlutils.py::test_regex[ldap://[::192.9.5.5]/dc=example,dc=com??sub?(sn=Jensen)]",
"tests/test_urlutils.py::test_roundtrip[ldap://[::192.9.5.5]/dc=example,dc=com??sub?(sn=Jensen)]",
"tests/test_urlutils.py::test_query_params[ldap://[::192.9.5.5]/dc=example,dc=com??sub?(sn=Jensen)]",
"tests/test_urlutils.py::test_regex[mailto:[email protected][email protected]&body=hi%20http://wikipedia.org]",
"tests/test_urlutils.py::test_roundtrip[mailto:[email protected][email protected]&body=hi%20http://wikipedia.org]",
"tests/test_urlutils.py::test_query_params[mailto:[email protected][email protected]&body=hi%20http://wikipedia.org]",
"tests/test_urlutils.py::test_regex[news:alt.rec.motorcycle]",
"tests/test_urlutils.py::test_roundtrip[news:alt.rec.motorcycle]",
"tests/test_urlutils.py::test_query_params[news:alt.rec.motorcycle]",
"tests/test_urlutils.py::test_regex[tel:+1-800-867-5309]",
"tests/test_urlutils.py::test_roundtrip[tel:+1-800-867-5309]",
"tests/test_urlutils.py::test_query_params[tel:+1-800-867-5309]",
"tests/test_urlutils.py::test_regex[urn:oasis:member:A00024:x]",
"tests/test_urlutils.py::test_roundtrip[urn:oasis:member:A00024:x]",
"tests/test_urlutils.py::test_query_params[urn:oasis:member:A00024:x]",
"tests/test_urlutils.py::test_regex[magnet:?xt=urn:btih:1a42b9e04e122b97a5254e3df77ab3c4b7da725f&dn=Puppy%20Linux%20precise-5.7.1.iso&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.publicbt.com:80&tr=udp://tracker.istole.it:6969&tr=udp://tracker.ccc.de:80&tr=udp://open.demonii.com:1337]",
"tests/test_urlutils.py::test_roundtrip[magnet:?xt=urn:btih:1a42b9e04e122b97a5254e3df77ab3c4b7da725f&dn=Puppy%20Linux%20precise-5.7.1.iso&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.publicbt.com:80&tr=udp://tracker.istole.it:6969&tr=udp://tracker.ccc.de:80&tr=udp://open.demonii.com:1337]",
"tests/test_urlutils.py::test_query_params[magnet:?xt=urn:btih:1a42b9e04e122b97a5254e3df77ab3c4b7da725f&dn=Puppy%20Linux%20precise-5.7.1.iso&tr=udp://tracker.openbittorrent.com:80&tr=udp://tracker.publicbt.com:80&tr=udp://tracker.istole.it:6969&tr=udp://tracker.ccc.de:80&tr=udp://open.demonii.com:1337]",
"tests/test_urlutils.py::test_regex[http://localhost]",
"tests/test_urlutils.py::test_roundtrip[http://localhost]",
"tests/test_urlutils.py::test_query_params[http://localhost]",
"tests/test_urlutils.py::test_regex[http://localhost/]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/]",
"tests/test_urlutils.py::test_query_params[http://localhost/]",
"tests/test_urlutils.py::test_regex[http://localhost/foo]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo]",
"tests/test_urlutils.py::test_regex[http://localhost/foo/]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo/]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo/]",
"tests/test_urlutils.py::test_regex[http://localhost/foo!!bar/]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo!!bar/]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo!!bar/]",
"tests/test_urlutils.py::test_regex[http://localhost/foo%20bar/]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo%20bar/]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo%20bar/]",
"tests/test_urlutils.py::test_regex[http://localhost/foo%2Fbar/]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo%2Fbar/]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo%2Fbar/]",
"tests/test_urlutils.py::test_regex[http://localhost/foo?n]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo?n]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo?n]",
"tests/test_urlutils.py::test_regex[http://localhost/foo?n=v]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo?n=v]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo?n=v]",
"tests/test_urlutils.py::test_regex[http://localhost/foo?n=/a/b]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/foo?n=/a/b]",
"tests/test_urlutils.py::test_query_params[http://localhost/foo?n=/a/b]",
"tests/test_urlutils.py::test_regex[http://example.com/foo!@$bar?b!@z=123]",
"tests/test_urlutils.py::test_roundtrip[http://example.com/foo!@$bar?b!@z=123]",
"tests/test_urlutils.py::test_query_params[http://example.com/foo!@$bar?b!@z=123]",
"tests/test_urlutils.py::test_regex[http://localhost/asd?a=asd%20sdf/345]",
"tests/test_urlutils.py::test_roundtrip[http://localhost/asd?a=asd%20sdf/345]",
"tests/test_urlutils.py::test_query_params[http://localhost/asd?a=asd%20sdf/345]",
"tests/test_urlutils.py::test_regex[http://(%2525)/(%2525)?(%2525)&(%2525)=(%2525)#(%2525)]",
"tests/test_urlutils.py::test_roundtrip[http://(%2525)/(%2525)?(%2525)&(%2525)=(%2525)#(%2525)]",
"tests/test_urlutils.py::test_query_params[http://(%2525)/(%2525)?(%2525)&(%2525)=(%2525)#(%2525)]",
"tests/test_urlutils.py::test_regex[http://(%C3%A9)/(%C3%A9)?(%C3%A9)&(%C3%A9)=(%C3%A9)#(%C3%A9)]",
"tests/test_urlutils.py::test_roundtrip[http://(%C3%A9)/(%C3%A9)?(%C3%A9)&(%C3%A9)=(%C3%A9)#(%C3%A9)]",
"tests/test_urlutils.py::test_query_params[http://(%C3%A9)/(%C3%A9)?(%C3%A9)&(%C3%A9)=(%C3%A9)#(%C3%A9)]",
"tests/test_urlutils.py::test_basic",
"tests/test_urlutils.py::test_utf8_url",
"tests/test_urlutils.py::test_idna",
"tests/test_urlutils.py::test_iri_query",
"tests/test_urlutils.py::test_iri_path",
"tests/test_urlutils.py::test_url_copy",
"tests/test_urlutils.py::test_invalid_port",
"tests/test_urlutils.py::test_invalid_ipv6",
"tests/test_urlutils.py::test_parse_url",
"tests/test_urlutils.py::test_parse_equals_in_qp_value",
"tests/test_urlutils.py::test_identical_equal",
"tests/test_urlutils.py::test_equal",
"tests/test_urlutils.py::test_not_equal",
"tests/test_urlutils.py::test_userinfo",
"tests/test_urlutils.py::test_quoted_userinfo",
"tests/test_urlutils.py::test_mailto",
"tests/test_urlutils.py::test_rel_navigate",
"tests/test_urlutils.py::test_navigate",
"tests/test_urlutils.py::test_chained_navigate[https://host/b-https://host-paths0]",
"tests/test_urlutils.py::test_self_normalize",
"tests/test_urlutils.py::test_normalize_with_case",
"tests/test_urlutils.py::test_netloc_slashes",
"tests/test_urlutils.py::test_find_all_links_basic",
"tests/test_urlutils.py::test_find_all_links",
"tests/test_urlutils.py::test_unicodey",
"tests/test_urlutils.py::test_str_repr"
] | [] | BSD License | 11,970 | 167 | [
"boltons/urlutils.py"
] |
onicagroup__runway-1144 | d315e6514fb86c217aa5bc4c3763ca163597f7eb | 2022-01-10 15:21:00 | 888db421da760c7bf4915c29e351f24d97989c73 | codecov[bot]: # [Codecov](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) Report
> Merging [#1144](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) (c7d5a22) into [master](https://codecov.io/gh/onicagroup/runway/commit/d315e6514fb86c217aa5bc4c3763ca163597f7eb?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) (d315e65) will **increase** coverage by `0.00%`.
> The diff coverage is `100.00%`.
[](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup)
```diff
@@ Coverage Diff @@
## master #1144 +/- ##
=======================================
Coverage 89.47% 89.47%
=======================================
Files 247 247
Lines 15297 15301 +4
=======================================
+ Hits 13687 13691 +4
Misses 1610 1610
```
| [Impacted Files](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup) | Coverage Δ | |
|---|---|---|
| [runway/module/staticsite/parameters/models.py](https://codecov.io/gh/onicagroup/runway/pull/1144/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup#diff-cnVud2F5L21vZHVsZS9zdGF0aWNzaXRlL3BhcmFtZXRlcnMvbW9kZWxzLnB5) | `100.00% <ø> (ø)` | |
| [runway/module/staticsite/handler.py](https://codecov.io/gh/onicagroup/runway/pull/1144/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup#diff-cnVud2F5L21vZHVsZS9zdGF0aWNzaXRlL2hhbmRsZXIucHk=) | `88.70% <100.00%> (+0.26%)` | :arrow_up: |
------
[Continue to review full report at Codecov](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup). Last update [d315e65...c7d5a22](https://codecov.io/gh/onicagroup/runway/pull/1144?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=onicagroup).
| diff --git a/runway/module/staticsite/handler.py b/runway/module/staticsite/handler.py
index 9dca8319..7b869ccd 100644
--- a/runway/module/staticsite/handler.py
+++ b/runway/module/staticsite/handler.py
@@ -12,6 +12,7 @@ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Union, cast
import yaml
from ..._logging import PrefixAdaptor
+from ...compat import cached_property
from ...utils import YamlDumper
from ..base import RunwayModule
from ..cloudformation import CloudFormation
@@ -80,6 +81,19 @@ class StaticSite(RunwayModule):
self._ensure_cloudfront_with_auth_at_edge()
self._ensure_correct_region_with_auth_at_edge()
+ @cached_property
+ def sanitized_name(self) -> str:
+ """Sanitized name safe to use in a CloudFormation Stack name.
+
+ Errors are usually caused here by a ``.`` in the name.
+ This unintelligently replaces ``.`` with ``-``.
+
+ If issues are still encountered, we can check against the regex of
+ ``(?=^.{1,128}$)^[a-zA-Z][-a-zA-Z0-9_]+$``.
+
+ """
+ return self.name.replace(".", "-").strip("-")
+
def deploy(self) -> None:
"""Create website CFN module and run CFNgin.deploy."""
if self.parameters:
@@ -182,7 +196,9 @@ class StaticSite(RunwayModule):
pre_destroy = [
{
- "args": {"bucket_name": f"${{rxref {self.name}-dependencies::{i}}}"},
+ "args": {
+ "bucket_name": f"${{rxref {self.sanitized_name}-dependencies::{i}}}"
+ },
"path": "runway.cfngin.hooks.cleanup_s3.purge_bucket",
"required": True,
}
@@ -197,7 +213,7 @@ class StaticSite(RunwayModule):
"args": {
"user_pool_arn": self.parameters.user_pool_arn,
"aliases": self.parameters.aliases,
- "stack_name": f"${{namespace}}-{self.name}-dependencies",
+ "stack_name": f"${{namespace}}-{self.sanitized_name}-dependencies",
},
"data_key": "aae_callback_url_retriever",
"path": "runway.cfngin.hooks.staticsite.auth_at_edge."
@@ -248,7 +264,7 @@ class StaticSite(RunwayModule):
"pre_destroy": pre_destroy,
"service_role": self.parameters.service_role,
"stacks": {
- f"{self.name}-dependencies": {
+ f"{self.sanitized_name}-dependencies": {
"class_path": "runway.blueprints.staticsite.dependencies.Dependencies",
"variables": self._get_dependencies_variables(),
}
@@ -277,8 +293,10 @@ class StaticSite(RunwayModule):
"""
# Default parameter name matches build_staticsite hook
if not self.options.source_hashing.parameter:
- self.options.source_hashing.parameter = f"${{namespace}}-{self.name}-hash"
- nonce_secret_param = f"${{namespace}}-{self.name}-nonce-secret"
+ self.options.source_hashing.parameter = (
+ f"${{namespace}}-{self.sanitized_name}-hash"
+ )
+ nonce_secret_param = f"${{namespace}}-{self.sanitized_name}-nonce-secret"
build_staticsite_args: Dict[str, Any] = {
# ensures yaml.safe_load will work by using JSON to convert objects
@@ -286,10 +304,10 @@ class StaticSite(RunwayModule):
}
build_staticsite_args[
"artifact_bucket_rxref_lookup"
- ] = f"{self.name}-dependencies::ArtifactsBucketName"
- build_staticsite_args["options"]["namespace"] = "${namespace}" # type: ignore
- build_staticsite_args["options"]["name"] = self.name # type: ignore
- build_staticsite_args["options"]["path"] = os.path.join( # type: ignore
+ ] = f"{self.sanitized_name}-dependencies::ArtifactsBucketName"
+ build_staticsite_args["options"]["namespace"] = "${namespace}"
+ build_staticsite_args["options"]["name"] = self.sanitized_name
+ build_staticsite_args["options"]["path"] = os.path.join(
os.path.realpath(self.ctx.env.root_dir), self.path
)
@@ -309,15 +327,15 @@ class StaticSite(RunwayModule):
post_deploy = [
{
"args": {
- "bucket_name": f"${{cfn ${{namespace}}-{self.name}.BucketName}}",
+ "bucket_name": f"${{cfn ${{namespace}}-{self.sanitized_name}.BucketName}}",
"cf_disabled": site_stack_variables["DisableCloudFront"],
- "distribution_domain": f"${{cfn ${{namespace}}-{self.name}."
+ "distribution_domain": f"${{cfn ${{namespace}}-{self.sanitized_name}."
"CFDistributionDomainName::default=undefined}",
- "distribution_id": f"${{cfn ${{namespace}}-{self.name}.CFDistributionId::"
- "default=undefined}",
+ "distribution_id": f"${{cfn ${{namespace}}-{self.sanitized_name}"
+ ".CFDistributionId::default=undefined}",
"extra_files": [i.dict() for i in self.options.extra_files],
- "website_url": f"${{cfn ${{namespace}}-{self.name}.BucketWebsiteURL::"
- "default=undefined}",
+ "website_url": f"${{cfn ${{namespace}}-{self.sanitized_name}"
+ ".BucketWebsiteURL::default=undefined}",
},
"path": "runway.cfngin.hooks.staticsite.upload_staticsite.sync",
"required": True,
@@ -326,7 +344,9 @@ class StaticSite(RunwayModule):
pre_destroy = [
{
- "args": {"bucket_name": f"${{rxref {self.name}::BucketName}}"},
+ "args": {
+ "bucket_name": f"${{rxref {self.sanitized_name}::BucketName}}"
+ },
"path": "runway.cfngin.hooks.cleanup_s3.purge_bucket",
"required": True,
}
@@ -335,7 +355,7 @@ class StaticSite(RunwayModule):
if self.parameters.rewrite_directory_index or self.parameters.auth_at_edge:
pre_destroy.append(
{
- "args": {"stack_relative_name": self.name},
+ "args": {"stack_relative_name": self.sanitized_name},
"path": "runway.cfngin.hooks.staticsite.cleanup.warn",
"required": False,
}
@@ -394,7 +414,7 @@ class StaticSite(RunwayModule):
"required": True,
"data_key": "client_updater",
"args": self._get_client_updater_variables(
- self.name, site_stack_variables
+ self.sanitized_name, site_stack_variables
),
},
)
@@ -418,7 +438,7 @@ class StaticSite(RunwayModule):
"pre_destroy": pre_destroy,
"service_role": self.parameters.service_role,
"stacks": {
- self.name: {
+ self.sanitized_name: {
"class_path": f"runway.blueprints.staticsite.{class_path}",
"variables": site_stack_variables,
}
@@ -450,7 +470,7 @@ class StaticSite(RunwayModule):
"cfngin_bucket": "",
"service_role": self.parameters.service_role,
"stacks": {
- f"{self.name}-cleanup": {
+ f"{self.sanitized_name}-cleanup": {
"template_path": os.path.join(
tempfile.gettempdir(), "thisfileisnotused.yaml"
),
@@ -489,7 +509,7 @@ class StaticSite(RunwayModule):
if self.parameters.enable_cf_logging:
site_stack_variables[
"LogBucketName"
- ] = f"${{rxref {self.name}-dependencies::AWSLogBucketName}}"
+ ] = f"${{rxref {self.sanitized_name}-dependencies::AWSLogBucketName}}"
if self.parameters.auth_at_edge:
self._ensure_auth_at_edge_requirements()
@@ -548,14 +568,14 @@ class StaticSite(RunwayModule):
if self.parameters.create_user_pool:
args[
"created_user_pool_id"
- ] = f"${{rxref {self.name}-dependencies::AuthAtEdgeUserPoolId}}"
+ ] = f"${{rxref {self.sanitized_name}-dependencies::AuthAtEdgeUserPoolId}}"
return args
def _get_domain_updater_variables(self) -> Dict[str, str]:
return {
- "client_id_output_lookup": f"{self.name}-dependencies::AuthAtEdgeClient",
- "client_id": f"${{rxref {self.name}-dependencies::AuthAtEdgeClient}}",
+ "client_id_output_lookup": f"{self.sanitized_name}-dependencies::AuthAtEdgeClient",
+ "client_id": f"${{rxref {self.sanitized_name}-dependencies::AuthAtEdgeClient}}",
}
def _get_lambda_config_variables(
@@ -565,8 +585,8 @@ class StaticSite(RunwayModule):
required_group: Optional[str] = None,
) -> Dict[str, Any]:
return {
- "client_id": f"${{rxref {self.name}-dependencies::AuthAtEdgeClient}}",
- "bucket": f"${{rxref {self.name}-dependencies::ArtifactsBucketName}}",
+ "client_id": f"${{rxref {self.sanitized_name}-dependencies::AuthAtEdgeClient}}",
+ "bucket": f"${{rxref {self.sanitized_name}-dependencies::ArtifactsBucketName}}",
"cookie_settings": site_stack_variables["CookieSettings"],
"http_headers": site_stack_variables["HttpHeaders"],
"nonce_signing_secret_param_name": nonce_secret_param,
@@ -584,7 +604,7 @@ class StaticSite(RunwayModule):
"alternate_domains": [
add_url_scheme(x) for x in site_stack_variables["Aliases"]
],
- "client_id": f"${{rxref {self.name}-dependencies::AuthAtEdgeClient}}",
+ "client_id": f"${{rxref {self.sanitized_name}-dependencies::AuthAtEdgeClient}}",
"distribution_domain": f"${{rxref {name}::CFDistributionDomainName}}",
"oauth_scopes": site_stack_variables["OAuthScopes"],
"redirect_path_sign_in": site_stack_variables["RedirectPathSignIn"],
diff --git a/runway/module/staticsite/parameters/models.py b/runway/module/staticsite/parameters/models.py
index d12ca762..7fce2969 100644
--- a/runway/module/staticsite/parameters/models.py
+++ b/runway/module/staticsite/parameters/models.py
@@ -65,7 +65,7 @@ class RunwayStaticSiteModuleParametersDataModel(ConfigProperty):
compress: Whether the CloudFront default cache behavior will automatically
compress certain files.
cookie_settings: The default cookie settings for retrieved tokens and
- generated nonce’s.
+ generated nonce's.
create_user_pool: Wether to create a User Pool for the Auth@Edge
configuration.
custom_error_responses: Define custom error responses.
@@ -75,8 +75,8 @@ class RunwayStaticSiteModuleParametersDataModel(ConfigProperty):
Lambda@Edge associations with their pre-build function versions.
namespace: The unique namespace for the deployment.
non_spa: Wether this site is a single page application (SPA).
- oauth_scopes: Scope is a mechanism in OAuth 2.0 to limit an application’s
- access to a user’s account.
+ oauth_scopes: Scope is a mechanism in OAuth 2.0 to limit an application's
+ access to a user's account.
redirect_path_auth_refresh: The path that a user is redirected to when
their authorization tokens have expired (1 hour).
redirect_path_sign_in: The path that a user is redirected to after sign-in.
| [TODO] static site: sanitize module name before using it as a stack name
If a module name contains a `.`, it is used in CFN stack names (where it is an invalid character).
regex: `(?=^.{1,128}$)^[a-zA-Z][-a-zA-Z0-9_]+$` | onicagroup/runway | diff --git a/tests/unit/module/staticsite/test_handler.py b/tests/unit/module/staticsite/test_handler.py
index 6501ad56..c65784ca 100644
--- a/tests/unit/module/staticsite/test_handler.py
+++ b/tests/unit/module/staticsite/test_handler.py
@@ -294,3 +294,24 @@ class TestStaticSite:
)
assert not obj.plan()
mock_setup_website_module.assert_called_once_with(command="plan")
+
+ @pytest.mark.parametrize(
+ "provided, expected", [("foo", "foo"), ("foo.bar", "foo-bar")]
+ )
+ def test_sanitized_name(
+ self,
+ expected: str,
+ provided: str,
+ runway_context: RunwayContext,
+ tmp_path: Path,
+ ) -> None:
+ """Test sanitized_name."""
+ assert (
+ StaticSite(
+ runway_context,
+ module_root=tmp_path,
+ name=provided,
+ parameters={"namespace": "test", "staticsite_auth_at_edge": False},
+ ).sanitized_name
+ == expected
+ )
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 2
} | 2.4 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-xdist",
"pytest-mock",
"pytest-asyncio",
"mock"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements/base.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | attrs==25.3.0
awacs==2.5.0
aws-sam-translator==1.95.0
boto3==1.37.23
botocore==1.37.23
bracex==2.5.post1
certifi==2025.1.31
cffi==1.17.1
cfn-flip==1.3.0
cfn-lint==1.32.1
charset-normalizer==3.4.1
cli_exit_tools==1.2.7
click==8.1.8
coloredlogs==15.0
coverage==7.8.0
cryptography==44.0.2
docker==7.1.0
exceptiongroup==1.2.2
execnet==2.1.1
formic2==1.0.3
gitdb==4.0.12
GitPython==3.1.44
humanfriendly==10.0
idna==3.10
igittigitt==2.1.5
iniconfig==2.1.0
Jinja2==3.1.6
jmespath==1.0.1
jsonpatch==1.33
jsonpointer==3.0.0
jsonschema==4.23.0
jsonschema-specifications==2024.10.1
lark-parser==0.10.1
lib-detect-testenv==2.0.8
MarkupSafe==3.0.2
mock==5.2.0
mpmath==1.3.0
networkx==3.2.1
packaging==24.2
pathspec==0.12.1
pluggy==1.5.0
pycparser==2.22
pydantic==1.10.21
pyhcl==0.4.5
pyOpenSSL==25.0.0
pytest==8.3.5
pytest-asyncio==0.26.0
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-xdist==3.6.1
python-dateutil==2.9.0.post0
python-hcl2==2.0.3
PyYAML==6.0.2
referencing==0.36.2
regex==2024.11.6
requests==2.32.3
rpds-py==0.24.0
-e git+https://github.com/onicagroup/runway.git@d315e6514fb86c217aa5bc4c3763ca163597f7eb#egg=runway
s3transfer==0.11.4
Send2Trash==1.8.3
six==1.17.0
smmap==5.0.2
sympy==1.13.3
tomli==2.2.1
troposphere==3.2.2
typing_extensions==4.13.0
urllib3==1.26.20
wcmatch==10.0
yamllint==1.37.0
| name: runway
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- attrs==25.3.0
- awacs==2.5.0
- aws-sam-translator==1.95.0
- boto3==1.37.23
- botocore==1.37.23
- bracex==2.5.post1
- certifi==2025.1.31
- cffi==1.17.1
- cfn-flip==1.3.0
- cfn-lint==1.32.1
- charset-normalizer==3.4.1
- cli-exit-tools==1.2.7
- click==8.1.8
- coloredlogs==15.0
- coverage==7.8.0
- cryptography==44.0.2
- docker==7.1.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- formic2==1.0.3
- gitdb==4.0.12
- gitpython==3.1.44
- humanfriendly==10.0
- idna==3.10
- igittigitt==2.1.5
- iniconfig==2.1.0
- jinja2==3.1.6
- jmespath==1.0.1
- jsonpatch==1.33
- jsonpointer==3.0.0
- jsonschema==4.23.0
- jsonschema-specifications==2024.10.1
- lark-parser==0.10.1
- lib-detect-testenv==2.0.8
- markupsafe==3.0.2
- mock==5.2.0
- mpmath==1.3.0
- networkx==3.2.1
- packaging==24.2
- pathspec==0.12.1
- pluggy==1.5.0
- pycparser==2.22
- pydantic==1.10.21
- pyhcl==0.4.5
- pyopenssl==25.0.0
- pytest==8.3.5
- pytest-asyncio==0.26.0
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-xdist==3.6.1
- python-dateutil==2.9.0.post0
- python-hcl2==2.0.3
- pyyaml==6.0.2
- referencing==0.36.2
- regex==2024.11.6
- requests==2.32.3
- rpds-py==0.24.0
- runway==2.0.0.dev0
- s3transfer==0.11.4
- send2trash==1.8.3
- six==1.17.0
- smmap==5.0.2
- sympy==1.13.3
- tomli==2.2.1
- troposphere==3.2.2
- typing-extensions==4.13.0
- urllib3==1.26.20
- wcmatch==10.0
- yamllint==1.37.0
prefix: /opt/conda/envs/runway
| [
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_sanitized_name[foo-foo]",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_sanitized_name[foo.bar-foo-bar]"
] | [] | [
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test___init__",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_create_cleanup_yaml",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_create_dependencies_yaml[parameters0-01]",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_create_dependencies_yaml[parameters1-02]",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_create_dependencies_yaml[parameters2-03]",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_create_staticsite_yaml[parameters0-01]",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_create_staticsite_yaml[parameters1-02]",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_deploy",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_destroy",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_ensure_auth_at_edge_requirements_exit",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_ensure_cloudfront_with_auth_at_edge_exit",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_ensure_correct_region_with_auth_at_edge_exit",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_ensure_valid_environment_config_exit",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_get_client_updater_variables",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_init",
"tests/unit/module/staticsite/test_handler.py::TestStaticSite::test_plan"
] | [] | Apache License 2.0 | 11,977 | 2,806 | [
"runway/module/staticsite/handler.py",
"runway/module/staticsite/parameters/models.py"
] |
asottile__babi-179 | c8fd9571dcc012e219cb3dbbc1dd4af4b2c33230 | 2022-01-12 22:42:22 | 961f9d0dfd4dc6c097572c4eed3c41398e67d2c3 | diff --git a/babi/file.py b/babi/file.py
index 0f3e9f2..9f618a3 100644
--- a/babi/file.py
+++ b/babi/file.py
@@ -465,6 +465,45 @@ class File:
self.buf.y = self.buf.file_y = pos
self.buf.x = 0
+ @action
+ def alt_up(self, margin: Margin) -> None:
+ if self.buf.y > 0:
+ offset = 1
+ while self.buf[self.buf.y - offset] == '':
+ offset += 1
+ if offset >= 2:
+ self.buf.y -= offset
+ self.buf.scroll_screen_if_needed(margin)
+ self.buf.x = 0
+ return
+ while (
+ self.buf[self.buf.y - offset - 1] != '' and
+ self.buf.y - offset - 1 >= 0
+ ):
+ offset += 1
+ self.buf.y -= offset
+ self.buf.scroll_screen_if_needed(margin)
+ self.buf.x = 0
+
+ @action
+ def alt_down(self, margin: Margin) -> None:
+ if self.buf.y < len(self.buf) - 1:
+ offset = 0
+ while self.buf[self.buf.y + offset] != '':
+ offset += 1
+ if offset > 1:
+ self.buf.y += offset - 1
+ self.buf.scroll_screen_if_needed(margin)
+ self.buf.x = 0
+ return
+ while self.buf[self.buf.y + offset] == '':
+ if self.buf.y + offset >= len(self.buf) - 1:
+ break
+ offset += 1
+ self.buf.y += offset
+ self.buf.scroll_screen_if_needed(margin)
+ self.buf.x = 0
+
# editing
@edit_action('backspace text', final=False)
@@ -757,6 +796,8 @@ class File:
b'kLFT5': ctrl_left,
b'kHOM5': ctrl_home,
b'kEND5': ctrl_end,
+ b'kUP3': alt_up,
+ b'kDN3': alt_down,
# editing
b'KEY_BACKSPACE': backspace,
b'KEY_DC': delete,
@@ -776,6 +817,8 @@ class File:
b'kLFT6': keep_selection(ctrl_left),
b'kHOM6': keep_selection(ctrl_home),
b'kEND6': keep_selection(ctrl_end),
+ b'kUP4': keep_selection(alt_up),
+ b'kDN4': keep_selection(alt_down),
}
@edit_action('text', final=False)
| Jump to paragraph - feature request
Hello. Is there a possibility that you can add a **jump to paragraph** feature, like in nano?
This is what I mean:

I achieve this by pressing <kbd>Ctrl</kbd> + <kbd>Arrow Up</kbd>/<kbd>Arrow Down</kbd> and I don't see this feature anywhere in babi.
Also, I got used to pressing <kbd>Ctrl</kbd> + <kbd>Backspace</kbd> in order to delete a whole word, just like in other text editors (not in nano). This feature is very handy, so would you mind adding this as well? | asottile/babi | diff --git a/tests/features/conftest.py b/tests/features/conftest.py
index 78b41c3..87ac27c 100644
--- a/tests/features/conftest.py
+++ b/tests/features/conftest.py
@@ -262,6 +262,8 @@ KEYS = [
Key('^Left', b'kLFT5', 545),
Key('^Home', b'kHOM5', 535),
Key('^End', b'kEND5', 530),
+ Key('M-Up', b'kUP3', 564),
+ Key('M-Down', b'kDN3', 523),
Key('M-Right', b'kRIT3', 558),
Key('M-Left', b'kLFT3', 543),
Key('S-Up', b'KEY_SR', curses.KEY_SR),
diff --git a/tests/features/movement_test.py b/tests/features/movement_test.py
index 083c802..0050cdb 100644
--- a/tests/features/movement_test.py
+++ b/tests/features/movement_test.py
@@ -440,3 +440,92 @@ def test_indentation_using_tabs(run, tmpdir):
h.await_cursor_position(x=4, y=2)
h.press('Up')
h.await_cursor_position(x=4, y=1)
+
+
+def test_goto_previous_paragraph(run, tmpdir):
+ src = '''\
+class A:
+ def __init__(self):
+ self._test = 1
+
+
+def another_test():
+ pass
+
+yet_another_test = None
+
+# comment
+'''
+ f = tmpdir.join('f')
+ f.write(src)
+
+ with run(str(f)) as h, and_exit(h):
+ h.press('^End')
+ h.await_cursor_position(x=0, y=12)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=11)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=9)
+
+ h.press('End')
+ h.await_cursor_position(x=23, y=9)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=7)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=6)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=3)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=1)
+
+ h.press('M-Up')
+ h.await_cursor_position(x=0, y=1)
+
+
+def test_goto_next_paragraph(run, tmpdir):
+ src = '''\
+class A:
+ def __init__(self):
+ self._test = 1
+
+
+def another_test():
+ pass
+
+yet_another_test = None
+
+# comment
+'''
+ f = tmpdir.join('f')
+ f.write(src)
+
+ with run(str(f)) as h, and_exit(h):
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=3)
+
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=6)
+
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=7)
+
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=9)
+
+ h.press('End')
+ h.await_cursor_position(x=23, y=9)
+
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=11)
+
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=12)
+
+ h.press('M-Down')
+ h.await_cursor_position(x=0, y=12)
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 1
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/asottile/babi.git@c8fd9571dcc012e219cb3dbbc1dd4af4b2c33230#egg=babi
babi_grammars==0.0.62
cffi==1.17.1
covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
hecate @ git+https://github.com/asottile/hecate@875567f2ca2a58220c4f1f70b0db9a79c018e2ae
identify==2.6.9
iniconfig==2.1.0
onigurumacffi==1.4.1
packaging==24.2
pluggy==1.5.0
pycparser==2.22
pytest==8.3.5
remote-pdb==2.1.0
tomli==2.2.1
| name: babi
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- babi-grammars==0.0.62
- cffi==1.17.1
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- hecate==0.1.0
- identify==2.6.9
- iniconfig==2.1.0
- onigurumacffi==1.4.1
- packaging==24.2
- pluggy==1.5.0
- pycparser==2.22
- pytest==8.3.5
- remote-pdb==2.1.0
- tomli==2.2.1
prefix: /opt/conda/envs/babi
| [
"tests/features/movement_test.py::test_goto_previous_paragraph[fake]",
"tests/features/movement_test.py::test_goto_next_paragraph[fake]"
] | [
"tests/features/movement_test.py::test_arrow_key_movement[tmux]",
"tests/features/movement_test.py::test_page_up_and_page_down[tmux-PageUp-PageDown]",
"tests/features/movement_test.py::test_page_up_and_page_down[tmux-^Y-^V]",
"tests/features/movement_test.py::test_page_up_and_page_down_x_0[tmux]",
"tests/features/movement_test.py::test_page_up_page_down_size_small_window[tmux]",
"tests/features/movement_test.py::test_ctrl_home[tmux]",
"tests/features/movement_test.py::test_ctrl_end[tmux]",
"tests/features/movement_test.py::test_ctrl_end_already_on_last_page[tmux]",
"tests/features/movement_test.py::test_scrolling_arrow_key_movement[tmux]",
"tests/features/movement_test.py::test_ctrl_down_beginning_of_file[tmux]",
"tests/features/movement_test.py::test_ctrl_up_moves_screen_up_one_line[tmux]",
"tests/features/movement_test.py::test_ctrl_up_at_beginning_of_file_does_nothing[tmux]",
"tests/features/movement_test.py::test_ctrl_up_at_bottom_of_screen[tmux]",
"tests/features/movement_test.py::test_ctrl_down_at_end_of_file[tmux]",
"tests/features/movement_test.py::test_ctrl_down_causing_cursor_movement_should_fix_x[tmux]",
"tests/features/movement_test.py::test_ctrl_up_causing_cursor_movement_should_fix_x[tmux]",
"tests/features/movement_test.py::test_end_key[tmux-End]",
"tests/features/movement_test.py::test_end_key[tmux-^E]",
"tests/features/movement_test.py::test_home_key[tmux-Home]",
"tests/features/movement_test.py::test_home_key[tmux-^A]",
"tests/features/movement_test.py::test_page_up_does_not_go_negative[tmux]",
"tests/features/movement_test.py::test_ctrl_right_jump_by_word[tmux]",
"tests/features/movement_test.py::test_ctrl_left_jump_by_word[tmux]",
"tests/features/movement_test.py::test_ctrl_right_triggering_scroll[tmux]",
"tests/features/movement_test.py::test_ctrl_left_triggering_scroll[tmux]",
"tests/features/movement_test.py::test_indentation_using_tabs[tmux]",
"tests/features/movement_test.py::test_goto_previous_paragraph[tmux]",
"tests/features/movement_test.py::test_goto_next_paragraph[tmux]"
] | [
"tests/features/movement_test.py::test_arrow_key_movement[fake]",
"tests/features/movement_test.py::test_page_up_and_page_down[fake-PageUp-PageDown]",
"tests/features/movement_test.py::test_page_up_and_page_down[fake-^Y-^V]",
"tests/features/movement_test.py::test_page_up_and_page_down_x_0[fake]",
"tests/features/movement_test.py::test_page_up_page_down_size_small_window[fake]",
"tests/features/movement_test.py::test_ctrl_home[fake]",
"tests/features/movement_test.py::test_ctrl_end[fake]",
"tests/features/movement_test.py::test_ctrl_end_already_on_last_page[fake]",
"tests/features/movement_test.py::test_scrolling_arrow_key_movement[fake]",
"tests/features/movement_test.py::test_ctrl_down_beginning_of_file[fake]",
"tests/features/movement_test.py::test_ctrl_up_moves_screen_up_one_line[fake]",
"tests/features/movement_test.py::test_ctrl_up_at_beginning_of_file_does_nothing[fake]",
"tests/features/movement_test.py::test_ctrl_up_at_bottom_of_screen[fake]",
"tests/features/movement_test.py::test_ctrl_down_at_end_of_file[fake]",
"tests/features/movement_test.py::test_ctrl_down_causing_cursor_movement_should_fix_x[fake]",
"tests/features/movement_test.py::test_ctrl_up_causing_cursor_movement_should_fix_x[fake]",
"tests/features/movement_test.py::test_end_key[fake-End]",
"tests/features/movement_test.py::test_end_key[fake-^E]",
"tests/features/movement_test.py::test_home_key[fake-Home]",
"tests/features/movement_test.py::test_home_key[fake-^A]",
"tests/features/movement_test.py::test_page_up_does_not_go_negative[fake]",
"tests/features/movement_test.py::test_ctrl_right_jump_by_word[fake]",
"tests/features/movement_test.py::test_ctrl_left_jump_by_word[fake]",
"tests/features/movement_test.py::test_ctrl_right_triggering_scroll[fake]",
"tests/features/movement_test.py::test_ctrl_left_triggering_scroll[fake]",
"tests/features/movement_test.py::test_indentation_using_tabs[fake]",
"tests/features/movement_test.py::test_sequence_handling[fake]"
] | [] | MIT License | 11,997 | 640 | [
"babi/file.py"
] |
|
google__cloud-forensics-utils-427 | c5f4d5edd525a702f7d953b4bc3a9ee62be53334 | 2022-01-13 04:08:22 | c5f4d5edd525a702f7d953b4bc3a9ee62be53334 | codecov-commenter: # [Codecov](https://codecov.io/gh/google/cloud-forensics-utils/pull/427?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> :exclamation: No coverage uploaded for pull request base (`main@c5f4d5e`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#section-missing-base-commit).
> The diff coverage is `n/a`.
[](https://codecov.io/gh/google/cloud-forensics-utils/pull/427?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
```diff
@@ Coverage Diff @@
## main #427 +/- ##
=======================================
Coverage ? 59.15%
=======================================
Files ? 49
Lines ? 4010
Branches ? 0
=======================================
Hits ? 2372
Misses ? 1638
Partials ? 0
```
| Flag | Coverage Δ | |
|---|---|---|
| nosetests | `59.15% <0.00%> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google#carryforward-flags-in-the-pull-request-comment) to find out more.
------
[Continue to review full report at Codecov](https://codecov.io/gh/google/cloud-forensics-utils/pull/427?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/google/cloud-forensics-utils/pull/427?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Last update [c5f4d5e...b25ac5c](https://codecov.io/gh/google/cloud-forensics-utils/pull/427?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
| diff --git a/libcloudforensics/providers/gcp/internal/cloudresourcemanager.py b/libcloudforensics/providers/gcp/internal/cloudresourcemanager.py
index 94016d2..d138df4 100644
--- a/libcloudforensics/providers/gcp/internal/cloudresourcemanager.py
+++ b/libcloudforensics/providers/gcp/internal/cloudresourcemanager.py
@@ -136,3 +136,31 @@ class GoogleCloudResourceManager:
response = common.ExecuteRequest(resource_client, 'delete', request)[0]
logger.info("Resource {0:s} was set for deletion.".format(name))
return response
+
+ def GetIamPolicy(self, name: str) -> Dict[str, Any]:
+ """Get IAM policy bindings for a resource.
+
+ Args:
+ name (str): a resource identifier in the format
+ resource_type/resource_number e.g. projects/123456789012 where
+ project_type is one of projects, folders or organizations.
+
+ Returns:
+ Dict[str, Any]: The policy bindings for the resource.
+
+ Raises:
+ TypeError: if an invalid resource type is provided.
+ """
+ resource_type = name.split('/')[0]
+ if resource_type not in self.RESOURCE_TYPES:
+ raise TypeError('Invalid resource type "{0:s}", resource must be one of '
+ '"projects", "folders" or "organizations" provided in the format '
+ '"resource_type/resource_number".'.format(name))
+ service = self.GrmApi()
+ resource_client = getattr(service, resource_type)()
+ request = {'resource': name}
+ # Safe to unpack
+ response = common.ExecuteRequest(
+ resource_client, 'getIamPolicy', request)[0]
+
+ return response
| Add projects.getIamPolicy to GCP cloudresourcemanager module
Will enable listing IAM bindings on GCP projects. API reference https://cloud.google.com/resource-manager/reference/rest/v3/projects/getIamPolicy | google/cloud-forensics-utils | diff --git a/tests/providers/gcp/gcp_mocks.py b/tests/providers/gcp/gcp_mocks.py
index 96fa871..056f016 100644
--- a/tests/providers/gcp/gcp_mocks.py
+++ b/tests/providers/gcp/gcp_mocks.py
@@ -955,3 +955,23 @@ MOCK_BIGQUERY_JOBS = {
"user_email": "[email protected]"
}]
}
+
+MOCK_IAM_POLICY = {
+ "version": 1,
+ "etag": "bm90X2V0YWc=",
+ "bindings": [
+ {
+ "role": "roles/cloudbuild.builds.builder",
+ "members": [
+ "serviceAccount:[email protected]"
+ ]
+ },
+ {
+ "role": "roles/owner",
+ "members": [
+ "serviceAccount:[email protected]",
+ "user:[email protected]"
+ ]
+ }
+ ]
+}
diff --git a/tests/providers/gcp/internal/test_cloudresourcemanager.py b/tests/providers/gcp/internal/test_cloudresourcemanager.py
index e005b60..7c3fefe 100644
--- a/tests/providers/gcp/internal/test_cloudresourcemanager.py
+++ b/tests/providers/gcp/internal/test_cloudresourcemanager.py
@@ -99,3 +99,34 @@ class GoogleCloudResourceManagerTest(unittest.TestCase):
'updateTime': '2020-01-01T00:00:00.000Z'
}
])
+
+ @typing.no_type_check
+ @mock.patch('libcloudforensics.providers.gcp.internal.common.ExecuteRequest')
+ @mock.patch('libcloudforensics.providers.gcp.internal.cloudresourcemanager.GoogleCloudResourceManager.GrmApi')
+ def testGetIamPolicy(self, mock_grm_api, mock_execute_request):
+ """Validates the GetIamPolicy function"""
+ mock_execute_request.return_value = [gcp_mocks.MOCK_IAM_POLICY]
+ mock_resource_client = mock_grm_api.return_value.projects.return_value
+ response = gcp_mocks.FAKE_CLOUD_RESOURCE_MANAGER.GetIamPolicy(
+ 'projects/000000000000')
+ mock_execute_request.assert_called_with(mock_resource_client,
+ 'getIamPolicy', {'resource': 'projects/000000000000'})
+ self.assertEqual(response, {
+ "version": 1,
+ "etag": "bm90X2V0YWc=",
+ "bindings": [
+ {
+ "role": "roles/cloudbuild.builds.builder",
+ "members": [
+ "serviceAccount:[email protected]"
+ ]
+ },
+ {
+ "role": "roles/owner",
+ "members": [
+ "serviceAccount:[email protected]",
+ "user:[email protected]"
+ ]
+ }
+ ]
+ })
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_short_problem_statement",
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 2
},
"num_modified_files": 1
} | 20211109 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"nose",
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y python3-pip"
],
"python": "3.7",
"reqs_path": [
"requirements.txt",
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | adal==1.2.7
alabaster==0.7.13
astroid==2.15.8
azure-common==1.1.28
azure-core==1.30.1
azure-identity==1.15.0
azure-mgmt-compute==23.1.0
azure-mgmt-core==1.4.0
azure-mgmt-monitor==6.0.2
azure-mgmt-network==25.2.0
azure-mgmt-resource==23.0.1
azure-mgmt-storage==21.1.0
azure-storage-blob==12.19.1
Babel==2.14.0
boto3==1.33.13
botocore==1.33.13
cachetools==4.2.4
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi==1.15.1
charset-normalizer==3.4.1
coverage==7.2.7
cryptography==44.0.2
dill==0.3.7
docutils==0.19
durationpy==0.9
ecdsa==0.19.1
exceptiongroup==1.2.2
google-api-core==2.10.2
google-api-python-client==2.166.0
google-auth==1.35.0
google-auth-httplib2==0.2.0
googleapis-common-protos==1.69.2
httplib2==0.22.0
idna==3.10
imagesize==1.4.1
importlib-metadata==6.7.0
iniconfig==2.0.0
isodate==0.7.2
isort==5.11.5
Jinja2==3.1.6
jmespath==1.0.1
kubernetes==32.0.1
lazy-object-proxy==1.9.0
-e git+https://github.com/google/cloud-forensics-utils.git@c5f4d5edd525a702f7d953b4bc3a9ee62be53334#egg=libcloudforensics
MarkupSafe==2.1.5
mccabe==0.7.0
mock==5.2.0
msal==1.32.0
msal-extensions==1.3.0
msrest==0.7.1
msrestazure==0.6.4.post1
mypy==1.4.1
mypy-extensions==1.0.0
netaddr==1.3.0
nose==1.3.7
oauthlib==3.2.2
packaging==24.0
platformdirs==4.0.0
pluggy==1.2.0
protobuf==4.24.4
pyasn1==0.5.1
pyasn1-modules==0.3.0
pycparser==2.21
pycryptodome==3.22.0
Pygments==2.17.2
PyJWT==1.7.1
pylint==2.17.7
pyparsing==3.1.4
pytest==7.4.4
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
requests==2.31.0
requests-oauthlib==2.0.0
rsa==4.9
s3transfer==0.8.2
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinx-autodoc-typehints==1.23.0
sphinx-rtd-theme==2.0.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sshpubkeys==3.3.1
tomli==2.0.1
tomlkit==0.12.5
typed-ast==1.5.5
types-mock==5.1.0.3
types-six==1.16.21.9
typing_extensions==4.7.1
uritemplate==4.1.1
urllib3==1.26.20
websocket-client==1.6.1
wrapt==1.16.0
yapf==0.43.0
zipp==3.15.0
| name: cloud-forensics-utils
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=22.3.1=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- adal==1.2.7
- alabaster==0.7.13
- astroid==2.15.8
- azure-common==1.1.28
- azure-core==1.30.1
- azure-identity==1.15.0
- azure-mgmt-compute==23.1.0
- azure-mgmt-core==1.4.0
- azure-mgmt-monitor==6.0.2
- azure-mgmt-network==25.2.0
- azure-mgmt-resource==23.0.1
- azure-mgmt-storage==21.1.0
- azure-storage-blob==12.19.1
- babel==2.14.0
- boto3==1.33.13
- botocore==1.33.13
- cachetools==4.2.4
- cffi==1.15.1
- charset-normalizer==3.4.1
- coverage==7.2.7
- cryptography==44.0.2
- dill==0.3.7
- docutils==0.19
- durationpy==0.9
- ecdsa==0.19.1
- exceptiongroup==1.2.2
- google-api-core==2.10.2
- google-api-python-client==2.166.0
- google-auth==1.35.0
- google-auth-httplib2==0.2.0
- googleapis-common-protos==1.69.2
- httplib2==0.22.0
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==6.7.0
- iniconfig==2.0.0
- isodate==0.7.2
- isort==5.11.5
- jinja2==3.1.6
- jmespath==1.0.1
- kubernetes==32.0.1
- lazy-object-proxy==1.9.0
- markupsafe==2.1.5
- mccabe==0.7.0
- mock==5.2.0
- msal==1.32.0
- msal-extensions==1.3.0
- msrest==0.7.1
- msrestazure==0.6.4.post1
- mypy==1.4.1
- mypy-extensions==1.0.0
- netaddr==1.3.0
- nose==1.3.7
- oauthlib==3.2.2
- packaging==24.0
- platformdirs==4.0.0
- pluggy==1.2.0
- protobuf==4.24.4
- pyasn1==0.5.1
- pyasn1-modules==0.3.0
- pycparser==2.21
- pycryptodome==3.22.0
- pygments==2.17.2
- pyjwt==1.7.1
- pylint==2.17.7
- pyparsing==3.1.4
- pytest==7.4.4
- python-dateutil==2.9.0.post0
- pytz==2025.2
- pyyaml==6.0.1
- requests==2.31.0
- requests-oauthlib==2.0.0
- rsa==4.9
- s3transfer==0.8.2
- six==1.17.0
- snowballstemmer==2.2.0
- sphinx==5.3.0
- sphinx-autodoc-typehints==1.23.0
- sphinx-rtd-theme==2.0.0
- sphinxcontrib-applehelp==1.0.2
- sphinxcontrib-devhelp==1.0.2
- sphinxcontrib-htmlhelp==2.0.0
- sphinxcontrib-jquery==4.1
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==1.0.3
- sphinxcontrib-serializinghtml==1.1.5
- sshpubkeys==3.3.1
- tomli==2.0.1
- tomlkit==0.12.5
- typed-ast==1.5.5
- types-mock==5.1.0.3
- types-six==1.16.21.9
- typing-extensions==4.7.1
- uritemplate==4.1.1
- urllib3==1.26.20
- websocket-client==1.6.1
- wrapt==1.16.0
- yapf==0.43.0
- zipp==3.15.0
prefix: /opt/conda/envs/cloud-forensics-utils
| [
"tests/providers/gcp/internal/test_cloudresourcemanager.py::GoogleCloudResourceManagerTest::testGetIamPolicy"
] | [] | [
"tests/providers/gcp/internal/test_cloudresourcemanager.py::GoogleCloudResourceManagerTest::testGetProjectAncestry",
"tests/providers/gcp/internal/test_cloudresourcemanager.py::GoogleCloudResourceManagerTest::testGetResource",
"tests/providers/gcp/internal/test_cloudresourcemanager.py::GoogleCloudResourceManagerTest::testGetResourceInvalidName"
] | [] | Apache License 2.0 | 11,999 | 410 | [
"libcloudforensics/providers/gcp/internal/cloudresourcemanager.py"
] |
python-pillow__Pillow-5972 | 83d369a347db2d1674e785200a2c648bd4191c5d | 2022-01-18 05:47:16 | a6a843e5482345ffcd6cb45a534a11e839fcef43 | diff --git a/src/PIL/Image.py b/src/PIL/Image.py
index 69089a290..302bd638e 100644
--- a/src/PIL/Image.py
+++ b/src/PIL/Image.py
@@ -1145,6 +1145,11 @@ class Image:
if box is None:
return self.copy()
+ if box[2] < box[0]:
+ raise ValueError("Coordinate 'right' is less than 'left'")
+ elif box[3] < box[1]:
+ raise ValueError("Coordinate 'lower' is less than 'upper'")
+
self.load()
return self._new(self._crop(self.im, box))
| Provide an error message when user gives incorrect arguments to Image.crop()
### What did you do?
I called `Image.crop()`, but I got confused about what the arguments are meant to be.
It's meant to be a `(left, upper, right, lower)`-tuple, but I supplied a `(left, upper, width, height)`-tuple instead. The error message I got was:
```
SystemError: tile cannot extend outside image
```
which took me a while to figure out, because all the crops looked like they were inside the image – I think possibly this is a side effect of `width` being lower than `left`, and `height` being lower than `upper`?
### What did you expect to happen?
I'd get an error message explaining my mistake.
Maybe the `crop()` function could throw an error like:
```
ValueError: crop bounds should be a (left, upper, right, lower)-tuple, but right=100 was less than left=50
```
because I don't think cropping ever makes sense if `right > left` and `lower > upper` aren't satisfied.
### What actually happened?
I got confused.
### What are your OS, Python and Pillow versions?
* OS: macOS 10.15.7
* Python: Python 3.9.9
* Pillow: Pillow==9.0.0
### Steps to reproduce
This is a 100×100 pixel image:
<img width="100" alt="gradient" src="https://user-images.githubusercontent.com/301220/149421173-a36f2aa2-3ad8-4556-8330-cce7cac68b81.png">
```python
from PIL import Image
im = Image.open("gradient.png")
print(im.size)
# What I think I'm doing:
# left=0, upper=0, width=25, height=25
#
# This works, because box[2] > box[0] and box[3] > box[1]
crop1 = im.crop(box=(0, 0, 25, 25))
crop1.save("crop1.png")
# What I think I'm doing:
# left=50, upper=50, width=25, height=25
#
# What I should actually have done:
# left=50, upper=50, right=75, upper=75
crop2 = im.crop(box=(50, 50, 25, 25))
crop2.save("crop2.png")
```
In case it's helpful, here's the full stack trace:
<details><summary>Stack trace</summary>
```
Traceback (most recent call last):
File "/Users/alexwlchan/Library/Python/3.9/lib/python/site-packages/PIL/ImageFile.py", line 495, in _save
fh = fp.fileno()
AttributeError: '_idat' object has no attribute 'fileno'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./example.py", line 19, in <module>
crop2.save("crop2.png")
File "/Users/alexwlchan/Library/Python/3.9/lib/python/site-packages/PIL/Image.py", line 2212, in save
save_handler(self, fp, filename)
File "/Users/alexwlchan/Library/Python/3.9/lib/python/site-packages/PIL/PngImagePlugin.py", line 1348, in _save
ImageFile._save(im, _idat(fp, chunk), [("zip", (0, 0) + im.size, 0, rawmode)])
File "/Users/alexwlchan/Library/Python/3.9/lib/python/site-packages/PIL/ImageFile.py", line 503, in _save
e.setimage(im.im, b)
SystemError: tile cannot extend outside image
```
</details> | python-pillow/Pillow | diff --git a/Tests/test_decompression_bomb.py b/Tests/test_decompression_bomb.py
index d918ef941..1778491ab 100644
--- a/Tests/test_decompression_bomb.py
+++ b/Tests/test_decompression_bomb.py
@@ -86,21 +86,12 @@ class TestDecompressionCrop:
pytest.warns(Image.DecompressionBombWarning, src.crop, box)
def test_crop_decompression_checks(self):
-
im = Image.new("RGB", (100, 100))
- good_values = ((-9999, -9999, -9990, -9990), (-999, -999, -990, -990))
-
- warning_values = ((-160, -160, 99, 99), (160, 160, -99, -99))
-
- error_values = ((-99909, -99990, 99999, 99999), (99909, 99990, -99999, -99999))
-
- for value in good_values:
+ for value in ((-9999, -9999, -9990, -9990), (-999, -999, -990, -990)):
assert im.crop(value).size == (9, 9)
- for value in warning_values:
- pytest.warns(Image.DecompressionBombWarning, im.crop, value)
+ pytest.warns(Image.DecompressionBombWarning, im.crop, (-160, -160, 99, 99))
- for value in error_values:
- with pytest.raises(Image.DecompressionBombError):
- im.crop(value)
+ with pytest.raises(Image.DecompressionBombError):
+ im.crop((-99909, -99990, 99999, 99999))
diff --git a/Tests/test_image_crop.py b/Tests/test_image_crop.py
index e2228758c..6574e6efd 100644
--- a/Tests/test_image_crop.py
+++ b/Tests/test_image_crop.py
@@ -47,16 +47,12 @@ def test_wide_crop():
assert crop(-25, 75, 25, 125) == (1875, 625)
-def test_negative_crop():
- # Check negative crop size (@PIL171)
-
- im = Image.new("L", (512, 512))
- im = im.crop((400, 400, 200, 200))
[email protected]("box", ((8, 2, 2, 8), (2, 8, 8, 2), (8, 8, 2, 2)))
+def test_negative_crop(box):
+ im = Image.new("RGB", (10, 10))
- assert im.size == (0, 0)
- assert len(im.getdata()) == 0
- with pytest.raises(IndexError):
- im.getdata()[0]
+ with pytest.raises(ValueError):
+ im.crop(box)
def test_crop_float():
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_media"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 1
},
"num_modified_files": 1
} | 9.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-timeout",
"pytest-reverse"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc libtiff-dev libjpeg-dev libopenjp2-7-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python3-tk libharfbuzz-dev libfribidi-dev libxcb1-dev"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster==0.7.16
babel==2.17.0
black==25.1.0
build==1.2.2.post1
certifi==2025.1.31
charset-normalizer==3.4.1
check-manifest==0.50
click==8.1.8
coverage==7.8.0
defusedxml==0.7.1
docutils==0.21.2
exceptiongroup==1.2.2
idna==3.10
imagesize==1.4.1
importlib_metadata==8.6.1
iniconfig==2.1.0
Jinja2==3.1.6
markdown2==2.5.3
MarkupSafe==3.0.2
mypy-extensions==1.0.0
olefile==0.47
packaging==24.2
pathspec==0.12.1
-e git+https://github.com/python-pillow/Pillow.git@83d369a347db2d1674e785200a2c648bd4191c5d#egg=Pillow
platformdirs==4.3.7
pluggy==1.5.0
Pygments==2.19.1
pyproject_hooks==1.2.0
pyroma==4.2
pytest==8.3.5
pytest-cov==6.0.0
pytest-reverse==1.8.0
pytest-timeout==2.3.1
requests==2.32.3
snowballstemmer==2.2.0
Sphinx==7.4.7
sphinx-copybutton==0.5.2
sphinx-issues==5.0.0
sphinx-removed-in==0.2.3
sphinx-rtd-theme==3.0.2
sphinxcontrib-applehelp==2.0.0
sphinxcontrib-devhelp==2.0.0
sphinxcontrib-htmlhelp==2.1.0
sphinxcontrib-jquery==4.1
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==2.0.0
sphinxcontrib-serializinghtml==2.0.0
sphinxext-opengraph==0.9.1
tomli==2.2.1
trove-classifiers==2025.3.19.19
typing_extensions==4.13.0
urllib3==2.3.0
zipp==3.21.0
| name: Pillow
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- alabaster==0.7.16
- babel==2.17.0
- black==25.1.0
- build==1.2.2.post1
- certifi==2025.1.31
- charset-normalizer==3.4.1
- check-manifest==0.50
- click==8.1.8
- coverage==7.8.0
- defusedxml==0.7.1
- docutils==0.21.2
- exceptiongroup==1.2.2
- idna==3.10
- imagesize==1.4.1
- importlib-metadata==8.6.1
- iniconfig==2.1.0
- jinja2==3.1.6
- markdown2==2.5.3
- markupsafe==3.0.2
- mypy-extensions==1.0.0
- olefile==0.47
- packaging==24.2
- pathspec==0.12.1
- platformdirs==4.3.7
- pluggy==1.5.0
- pygments==2.19.1
- pyproject-hooks==1.2.0
- pyroma==4.2
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-reverse==1.8.0
- pytest-timeout==2.3.1
- requests==2.32.3
- snowballstemmer==2.2.0
- sphinx==7.4.7
- sphinx-copybutton==0.5.2
- sphinx-issues==5.0.0
- sphinx-removed-in==0.2.3
- sphinx-rtd-theme==3.0.2
- sphinxcontrib-applehelp==2.0.0
- sphinxcontrib-devhelp==2.0.0
- sphinxcontrib-htmlhelp==2.1.0
- sphinxcontrib-jquery==4.1
- sphinxcontrib-jsmath==1.0.1
- sphinxcontrib-qthelp==2.0.0
- sphinxcontrib-serializinghtml==2.0.0
- sphinxext-opengraph==0.9.1
- tomli==2.2.1
- trove-classifiers==2025.3.19.19
- typing-extensions==4.13.0
- urllib3==2.3.0
- zipp==3.21.0
prefix: /opt/conda/envs/Pillow
| [
"Tests/test_image_crop.py::test_negative_crop[box0]",
"Tests/test_image_crop.py::test_negative_crop[box1]",
"Tests/test_image_crop.py::test_negative_crop[box2]"
] | [] | [
"Tests/test_decompression_bomb.py::TestDecompressionBomb::test_no_warning_small_file",
"Tests/test_decompression_bomb.py::TestDecompressionBomb::test_no_warning_no_limit",
"Tests/test_decompression_bomb.py::TestDecompressionBomb::test_warning",
"Tests/test_decompression_bomb.py::TestDecompressionBomb::test_exception",
"Tests/test_decompression_bomb.py::TestDecompressionBomb::test_exception_gif",
"Tests/test_decompression_bomb.py::TestDecompressionBomb::test_exception_bmp",
"Tests/test_decompression_bomb.py::TestDecompressionCrop::testEnlargeCrop",
"Tests/test_decompression_bomb.py::TestDecompressionCrop::test_crop_decompression_checks",
"Tests/test_image_crop.py::test_crop",
"Tests/test_image_crop.py::test_wide_crop",
"Tests/test_image_crop.py::test_crop_float",
"Tests/test_image_crop.py::test_crop_crash",
"Tests/test_image_crop.py::test_crop_zero"
] | [] | MIT-CMU License | 12,030 | 165 | [
"src/PIL/Image.py"
] |
|
fatiando__pooch-291 | 52240b98ffa6ab13c20d9e801443b435aee4d286 | 2022-01-18 23:12:28 | 408532acf885d48e0b0794425848b8dcb25e7ba2 | welcome[bot]: 💖 **Thank you for opening your first pull request in this repository!** 💖
A few things to keep in mind:
* [Authorship Guidelines](https://github.com/fatiando/community/blob/main/AUTHORSHIP.md): Our rules for giving you credit for your contributions, including authorship on publications and [Zenodo](https://zenodo.org/communities/fatiando) archives.
* [Code of Conduct](https://github.com/fatiando/community/blob/main/CODE_OF_CONDUCT.md): How we expect people to interact in our projects.
⭐ **No matter what, we are really grateful that you put in the effort to do this!** ⭐
| diff --git a/pooch/core.py b/pooch/core.py
index 6e29758..b9cb127 100644
--- a/pooch/core.py
+++ b/pooch/core.py
@@ -263,6 +263,7 @@ def create(
registry=None,
urls=None,
retry_if_failed=0,
+ allow_updates=True,
):
"""
Create a :class:`~pooch.Pooch` with sensible defaults to fetch data files.
@@ -327,6 +328,11 @@ def create(
attempted once (``retry_if_failed=0``). Initially, will wait for 1s
between retries and then increase the wait time by 1s with each retry
until a maximum of 10s.
+ allow_updates : bool or str
+ Whether existing files in local storage that have a hash mismatch with
+ the registry are allowed to update from the remote URL. If a string,
+ this is the name of an environment variable that should be checked
+ for the value. Defaults to ``True``.
Returns
-------
@@ -414,6 +420,8 @@ def create(
# to import at the same time (which would try to create the folder several
# times at once).
path = cache_location(path, env, version)
+ if isinstance(allow_updates, str):
+ allow_updates = os.environ.get(allow_updates, "true") != "false"
pup = Pooch(
path=path,
base_url=base_url,
@@ -457,10 +465,22 @@ class Pooch:
attempted once (``retry_if_failed=0``). Initially, will wait for 1s
between retries and then increase the wait time by 1s with each retry
until a maximum of 10s.
+ allow_updates : bool
+ Whether existing files in local storage that have a hash mismatch with
+ the registry are allowed to update from the remote URL. Defaults to
+ ``True``.
"""
- def __init__(self, path, base_url, registry=None, urls=None, retry_if_failed=0):
+ def __init__(
+ self,
+ path,
+ base_url,
+ registry=None,
+ urls=None,
+ retry_if_failed=0,
+ allow_updates=True,
+ ):
self.path = path
self.base_url = base_url
if registry is None:
@@ -470,6 +490,7 @@ class Pooch:
urls = dict()
self.urls = dict(urls)
self.retry_if_failed = retry_if_failed
+ self.allow_updates = allow_updates
@property
def abspath(self):
@@ -542,6 +563,11 @@ class Pooch:
known_hash = self.registry[fname]
action, verb = download_action(full_path, known_hash)
+ if action == "update" and not self.allow_updates:
+ raise ValueError(
+ f"{fname} needs to update {full_path} but updates are disallowed."
+ )
+
if action in ("download", "update"):
get_logger().info(
"%s file '%s' from '%s' to '%s'.",
| Local-only/strict mode
The problem I'm trying to solve is that for a CI build, if the PR is changing a file but neglects to update the hash in the registry, the behavior is to silently (with default logging) re-download the file from the remote source. If there are no other tests depending on the datafile (😱) then the PR passes CI, but will fail future builds (because the committed registry and datafile are out of sync).
Would there be any interest in adding a flag to disable updating the file? My hack right now is to (on my CI builds) set `base_url` to something like `'NODOWNLOAD:'`. This is both simply just terrible and also results in errors complaining about the URL protocol rather than the true source: the bad hash.
I'd be happy to take a shot at implementing, if someone can point me to what the best approach is for this here. | fatiando/pooch | diff --git a/pooch/tests/test_core.py b/pooch/tests/test_core.py
index 7000736..b1686a5 100644
--- a/pooch/tests/test_core.py
+++ b/pooch/tests/test_core.py
@@ -328,6 +328,26 @@ def test_pooch_update():
assert log_file.getvalue() == ""
+def test_pooch_update_disallowed():
+ "Test that disallowing updates works."
+ with TemporaryDirectory() as local_store:
+ path = Path(local_store)
+ # Create a dummy version of tiny-data.txt that is different from the
+ # one in the remote storage
+ true_path = str(path / "tiny-data.txt")
+ with open(true_path, "w") as fin:
+ fin.write("different data")
+ # Setup a pooch in a temp dir
+ pup = Pooch(
+ path=path,
+ base_url=BASEURL,
+ registry=REGISTRY,
+ allow_updates=False,
+ )
+ with pytest.raises(ValueError):
+ pup.fetch("tiny-data.txt")
+
+
@pytest.mark.network
def test_pooch_corrupted(data_dir_mirror):
"Raise an exception if the file hash doesn't match the registry"
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_many_hunks",
"has_pytest_match_arg"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 3,
"test_score": 2
},
"num_modified_files": 1
} | 1.5 | {
"env_vars": null,
"env_yml_path": [
"environment.yml"
],
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": true,
"packages": "environment.yml",
"pip_packages": [
"pytest"
],
"pre_install": null,
"python": "3.9",
"reqs_path": null,
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | alabaster @ file:///home/conda/feedstock_root/build_artifacts/alabaster_1704848697227/work
appdirs @ file:///home/conda/feedstock_root/build_artifacts/appdirs_1733753955715/work
astroid==2.3.3
babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1738490167835/work
beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1738740337718/work
black @ file:///home/conda/feedstock_root/build_artifacts/black-recipe_1742502760723/work
Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work
build @ file:///croot/build_1692303725845/work
certifi @ file:///home/conda/feedstock_root/build_artifacts/certifi_1739515848642/work/certifi
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1625835307225/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1735929714516/work
click @ file:///home/conda/feedstock_root/build_artifacts/click_1734858813237/work
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1733218098505/work
coverage @ file:///home/conda/feedstock_root/build_artifacts/coverage_1743381221492/work
cryptography @ file:///croot/cryptography_1677533068310/work
docutils @ file:///home/conda/feedstock_root/build_artifacts/docutils_1728488658717/work
exceptiongroup @ file:///home/conda/feedstock_root/build_artifacts/exceptiongroup_1733208806608/work
flake8 @ file:///home/conda/feedstock_root/build_artifacts/flake8_1739898391164/work
h2 @ file:///home/conda/feedstock_root/build_artifacts/h2_1738578511449/work
hpack @ file:///home/conda/feedstock_root/build_artifacts/hpack_1737618293087/work
hyperframe @ file:///home/conda/feedstock_root/build_artifacts/hyperframe_1737618333194/work
idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1733211830134/work
imagesize @ file:///home/conda/feedstock_root/build_artifacts/imagesize_1656939531508/work
iniconfig @ file:///home/conda/feedstock_root/build_artifacts/iniconfig_1733223141826/work
isort==4.3.21
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1741263328855/work
lazy-object-proxy==1.4.3
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737556467/work
mccabe==0.6.1
mypy_extensions @ file:///home/conda/feedstock_root/build_artifacts/mypy_extensions_1733230897951/work
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1733203243479/work
pathspec @ file:///home/conda/feedstock_root/build_artifacts/pathspec_1733233363808/work
platformdirs @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_platformdirs_1742485085/work
pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1733222765875/work
-e git+https://github.com/fatiando/pooch.git@52240b98ffa6ab13c20d9e801443b435aee4d286#egg=pooch
pycodestyle @ file:///home/conda/feedstock_root/build_artifacts/pycodestyle_1733216196861/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_pycparser_1733195786/work
pydata-sphinx-theme @ file:///home/conda/feedstock_root/build_artifacts/pydata-sphinx-theme_1611661536644/work
pyflakes @ file:///home/conda/feedstock_root/build_artifacts/pyflakes_1733216066937/work
pyftpdlib @ file:///home/conda/feedstock_root/build_artifacts/pyftpdlib_1735418972722/work
Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1736243443484/work
pylint==2.4.4
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1685514481738/work
pyproject_hooks @ file:///home/conda/feedstock_root/build_artifacts/pyproject_hooks_1733710025763/work
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1733217236728/work
pytest @ file:///home/conda/feedstock_root/build_artifacts/pytest_1740946542080/work
pytest-cov @ file:///home/conda/feedstock_root/build_artifacts/pytest-cov_1733223023082/work
pytest_localftpserver @ file:///home/conda/feedstock_root/build_artifacts/pytest-localftpserver_1716169007590/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1742920838005/work
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1648757097602/work
requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1733217035951/work
six==1.17.0
snowballstemmer @ file:///home/conda/feedstock_root/build_artifacts/snowballstemmer_1637143057757/work
soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1693929250441/work
Sphinx @ file:///home/conda/feedstock_root/build_artifacts/sphinx_1618149252333/work
sphinx-book-theme @ file:///home/conda/feedstock_root/build_artifacts/sphinx-book-theme_1615313578943/work
sphinx-panels @ file:///home/conda/feedstock_root/build_artifacts/sphinx-panels_1610566840677/work
sphinxcontrib-applehelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-applehelp_1674487779667/work
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-htmlhelp_1675256494457/work
sphinxcontrib-jsmath @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-jsmath_1733753744933/work
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml @ file:///home/conda/feedstock_root/build_artifacts/sphinxcontrib-serializinghtml_1649380998999/work
toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1734091811753/work
tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1733256695513/work
typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/bld/rattler-build_typing_extensions_1743201626/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1734859416348/work
wrapt==1.11.2
zstandard @ file:///croot/zstandard_1731356346222/work
| name: pooch
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- alabaster=0.7.16=pyhd8ed1ab_0
- appdirs=1.4.4=pyhd8ed1ab_1
- babel=2.17.0=pyhd8ed1ab_0
- beautifulsoup4=4.13.3=pyha770c72_0
- black=25.1.0=pyha5154f8_0
- brotli-python=1.0.9=py39h5a03fae_7
- build=0.10.0=py39h06a4308_0
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2025.1.31=pyhd8ed1ab_0
- cffi=1.14.6=py39he32792d_0
- charset-normalizer=3.4.1=pyhd8ed1ab_0
- click=8.1.8=pyh707e725_0
- colorama=0.4.6=pyhd8ed1ab_1
- coverage=7.8.0=pyhe1237c8_0
- cryptography=39.0.1=py39h9ce1e76_0
- docutils=0.16=py39hf3d152e_5
- exceptiongroup=1.2.2=pyhd8ed1ab_1
- flake8=7.1.2=pyhd8ed1ab_0
- h2=4.2.0=pyhd8ed1ab_0
- hpack=4.1.0=pyhd8ed1ab_0
- hyperframe=6.1.0=pyhd8ed1ab_0
- idna=3.10=pyhd8ed1ab_1
- imagesize=1.4.1=pyhd8ed1ab_0
- iniconfig=2.0.0=pyhd8ed1ab_1
- jinja2=3.1.6=pyhd8ed1ab_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.3=h58526e2_2
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- lz4-c=1.9.4=h6a678d5_1
- markupsafe=2.1.1=py39hb9d737c_1
- mypy_extensions=1.0.0=pyha770c72_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1o=h166bdaf_0
- packaging=24.2=pyhd8ed1ab_2
- pathspec=0.12.1=pyhd8ed1ab_1
- pip=25.0.1=pyh8b19718_0
- platformdirs=4.3.7=pyh29332c3_0
- pluggy=1.5.0=pyhd8ed1ab_1
- pycodestyle=2.12.1=pyhd8ed1ab_1
- pycparser=2.22=pyh29332c3_1
- pydata-sphinx-theme=0.4.3=pyhd8ed1ab_0
- pyflakes=3.2.0=pyhd8ed1ab_1
- pyftpdlib=1.5.10=pyhd8ed1ab_1
- pygments=2.19.1=pyhd8ed1ab_0
- pyopenssl=23.2.0=pyhd8ed1ab_1
- pyproject_hooks=1.2.0=pyhd8ed1ab_1
- pysocks=1.7.1=pyha55dd90_7
- pytest=8.3.5=pyhd8ed1ab_0
- pytest-cov=6.0.0=pyhd8ed1ab_1
- pytest-localftpserver=1.3.2=pyhd8ed1ab_0
- python=3.9.0=hffdb5ce_5_cpython
- python_abi=3.9=5_cp39
- pytz=2025.2=pyhd8ed1ab_0
- pyyaml=6.0=py39hb9d737c_4
- readline=8.2=h5eee18b_0
- requests=2.32.3=pyhd8ed1ab_1
- setuptools=75.8.0=py39h06a4308_0
- snowballstemmer=2.2.0=pyhd8ed1ab_0
- soupsieve=2.5=pyhd8ed1ab_1
- sphinx=3.5.4=pyh44b312d_0
- sphinx-book-theme=0.0.41=pyhd8ed1ab_0
- sphinx-panels=0.5.2=pyhd3deb0d_0
- sphinxcontrib-applehelp=1.0.4=pyhd8ed1ab_0
- sphinxcontrib-devhelp=1.0.2=py_0
- sphinxcontrib-htmlhelp=2.0.1=pyhd8ed1ab_0
- sphinxcontrib-jsmath=1.0.1=pyhd8ed1ab_1
- sphinxcontrib-qthelp=1.0.3=py_0
- sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_2
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- toml=0.10.2=pyhd8ed1ab_1
- tomli=2.2.1=pyhd8ed1ab_1
- typing-extensions=4.13.0=h9fa5a19_1
- typing_extensions=4.13.0=pyh29332c3_1
- tzdata=2025a=h04d1e81_0
- urllib3=2.3.0=pyhd8ed1ab_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- yaml=0.2.5=h7f98852_2
- zlib=1.2.13=h5eee18b_1
- zstandard=0.23.0=py39h2c38b39_1
- zstd=1.5.6=hc292b87_0
- pip:
- astroid==2.3.3
- isort==4.3.21
- lazy-object-proxy==1.4.3
- mccabe==0.6.1
- pooch==1.5.2.post11+g52240b9
- pylint==2.4.4
- six==1.17.0
- wrapt==1.11.2
prefix: /opt/conda/envs/pooch
| [
"pooch/tests/test_core.py::test_pooch_update_disallowed"
] | [
"pooch/tests/test_core.py::test_check_availability_on_ftp"
] | [
"pooch/tests/test_core.py::test_retrieve",
"pooch/tests/test_core.py::test_retrieve_fname",
"pooch/tests/test_core.py::test_retrieve_default_path",
"pooch/tests/test_core.py::test_pooch_local",
"pooch/tests/test_core.py::test_pooch_custom_url[https]",
"pooch/tests/test_core.py::test_pooch_custom_url[figshare]",
"pooch/tests/test_core.py::test_pooch_custom_url[zenodo]",
"pooch/tests/test_core.py::test_pooch_download[https]",
"pooch/tests/test_core.py::test_pooch_download[figshare]",
"pooch/tests/test_core.py::test_pooch_download[zenodo]",
"pooch/tests/test_core.py::test_pooch_download_retry_off_by_default",
"pooch/tests/test_core.py::test_pooch_download_retry",
"pooch/tests/test_core.py::test_pooch_download_retry_fails_eventually",
"pooch/tests/test_core.py::test_pooch_logging_level",
"pooch/tests/test_core.py::test_pooch_update",
"pooch/tests/test_core.py::test_pooch_corrupted",
"pooch/tests/test_core.py::test_pooch_file_not_in_registry",
"pooch/tests/test_core.py::test_pooch_load_registry",
"pooch/tests/test_core.py::test_pooch_load_registry_comments",
"pooch/tests/test_core.py::test_pooch_load_registry_fileobj",
"pooch/tests/test_core.py::test_pooch_load_registry_custom_url",
"pooch/tests/test_core.py::test_pooch_load_registry_invalid_line",
"pooch/tests/test_core.py::test_check_availability",
"pooch/tests/test_core.py::test_fetch_with_downloader",
"pooch/tests/test_core.py::test_invalid_hash_alg",
"pooch/tests/test_core.py::test_alternative_hashing_algorithms",
"pooch/tests/test_core.py::test_download_action",
"pooch/tests/test_core.py::test_stream_download[tiny-data.txt]",
"pooch/tests/test_core.py::test_stream_download[subdir/tiny-data.txt]"
] | [] | BSD License | 12,035 | 742 | [
"pooch/core.py"
] |
RDFLib__rdflib-1684 | d3f945380dfef7bbdbb34de92fa9909d42cd851a | 2022-01-23 00:46:39 | 05dced203f7db28470255ce847db6b38d05a2663 | aucampia: New tests
```console
$ .venv/bin/python3 -m pytest 'test/test_serializer.py::test_rdf_type' -rA --log-level DEBUG -vvv
============================================================================ test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /home/iwana/sw/d/github.com/iafork/rdflib/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/iwana/sw/d/github.com/iafork/rdflib, configfile: tox.ini
plugins: subtests-0.5.0, cov-3.0.0, monkeytype-1.1.0
collected 10 items
test/test_serializer.py::test_rdf_type[turtle-0-False] PASSED [ 10%]
test/test_serializer.py::test_rdf_type[turtle-1-True] PASSED [ 20%]
test/test_serializer.py::test_rdf_type[turtle-2-False] PASSED [ 30%]
test/test_serializer.py::test_rdf_type[n3-0-False] PASSED [ 40%]
test/test_serializer.py::test_rdf_type[n3-1-True] PASSED [ 50%]
test/test_serializer.py::test_rdf_type[n3-2-False] PASSED [ 60%]
test/test_serializer.py::test_rdf_type[trig-0-False] PASSED [ 70%]
test/test_serializer.py::test_rdf_type[trig-1-True] PASSED [ 80%]
test/test_serializer.py::test_rdf_type[trig-2-False] PASSED [ 90%]
test/test_serializer.py::test_rdf_type[trig-3-False] PASSED [100%]
================================================================================== PASSES ===================================================================================
_______________________________________________________________________ test_rdf_type[turtle-0-False] _______________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
rdf:type eg:pred eg:obj .
_______________________________________________________________________ test_rdf_type[turtle-1-True] ________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
eg:subj a eg:obj .
_______________________________________________________________________ test_rdf_type[turtle-2-False] _______________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
eg:subj eg:pred rdf:type .
_________________________________________________________________________ test_rdf_type[n3-0-False] _________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
rdf:type eg:pred eg:obj .
_________________________________________________________________________ test_rdf_type[n3-1-True] __________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
eg:subj a eg:obj .
_________________________________________________________________________ test_rdf_type[n3-2-False] _________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
eg:subj eg:pred rdf:type .
________________________________________________________________________ test_rdf_type[trig-0-False] ________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
eg:graph {
rdf:type eg:pred eg:obj .
}
________________________________________________________________________ test_rdf_type[trig-1-True] _________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
eg:graph {
eg:subj a eg:obj .
}
________________________________________________________________________ test_rdf_type[trig-2-False] ________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
eg:graph {
eg:subj eg:pred rdf:type .
}
________________________________________________________________________ test_rdf_type[trig-3-False] ________________________________________________________________________
----------------------------------------------------------------------------- Captured log call -----------------------------------------------------------------------------
INFO root:test_serializer.py:41 data = @prefix eg: <example:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
rdf:type {
eg:subj eg:pred eg:obj .
}
========================================================================== short test summary info ==========================================================================
PASSED test/test_serializer.py::test_rdf_type[turtle-0-False]
PASSED test/test_serializer.py::test_rdf_type[turtle-1-True]
PASSED test/test_serializer.py::test_rdf_type[turtle-2-False]
PASSED test/test_serializer.py::test_rdf_type[n3-0-False]
PASSED test/test_serializer.py::test_rdf_type[n3-1-True]
PASSED test/test_serializer.py::test_rdf_type[n3-2-False]
PASSED test/test_serializer.py::test_rdf_type[trig-0-False]
PASSED test/test_serializer.py::test_rdf_type[trig-1-True]
PASSED test/test_serializer.py::test_rdf_type[trig-2-False]
PASSED test/test_serializer.py::test_rdf_type[trig-3-False]
============================================================================ 10 passed in 0.09s =============================================================================
``` | diff --git a/rdflib/plugins/serializers/turtle.py b/rdflib/plugins/serializers/turtle.py
index a62c05c4..a8933a7e 100644
--- a/rdflib/plugins/serializers/turtle.py
+++ b/rdflib/plugins/serializers/turtle.py
@@ -257,7 +257,8 @@ class TurtleSerializer(RecursiveSerializer):
def preprocessTriple(self, triple):
super(TurtleSerializer, self).preprocessTriple(triple)
for i, node in enumerate(triple):
- if node in self.keywords:
+ if i == VERB and node in self.keywords:
+ # predicate is a keyword
continue
# Don't use generated prefixes for subjects and objects
self.getQName(node, gen_prefix=(i == VERB))
| rdf prefix is not emitted when saving to turtle when only rdf:type is used
whenusing rdflib 6.1.1 to convert the following jsonld to turtle:
```json
{
"slots": [
{
"name": "type",
"slot_uri": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
}
],
"@context": [
{
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"@vocab": "https://w3id.org/linkml/",
"slot_uri": {
"@type": "@id"
}
}
]
}
```
the turtle emitted is:
```turtle
@prefix : <https://w3id.org/linkml/> .
[] :slots [ :name "type" ;
:slot_uri rdf:type ] .
```
which is invalid, as it lacks a prefix declaration for rdf
The situation is resolved by either
- adding another node to the graph in the rdf namespace, other than rdf:type
- saving to a format like nt
This reproduces the error:
```python
JSONLD = """
{
"slots": [
{
"name": "type",
"slot_uri": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
}
],
"@context": [
{
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"@vocab": "https://w3id.org/linkml/",
"slot_uri": {
"@type": "@id"
}
}
]
}"""
from rdflib import Graph
graph = Graph()
graph.parse(data=JSONLD, format="json-ld", prefix=False)
ttl_str = graph.serialize(format='turtle')
print(ttl_str)
graph.parse(data=ttl_str, format="turtle")
```
This is in contrast to other libs, e.g. Jena, which will produce valid turtle:
```turtle
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
_:b0 <https://w3id.org/linkml/slots> _:b1 .
_:b1 <https://w3id.org/linkml/name> "type" ;
<https://w3id.org/linkml/slot_uri> rdf:type .
``` | RDFLib/rdflib | diff --git a/test/test_roundtrip.py b/test/test_roundtrip.py
index f65bd4e2..8589483c 100644
--- a/test/test_roundtrip.py
+++ b/test/test_roundtrip.py
@@ -138,22 +138,6 @@ XFAILS = {
reason="missing escaping: PCDATA invalid Char value 12 and 8",
raises=SAXParseException,
),
- ("n3", "rdf_prefix.jsonld"): pytest.mark.xfail(
- reason="missing 'rdf:' prefix",
- raises=BadSyntax,
- ),
- ("ttl", "rdf_prefix.jsonld"): pytest.mark.xfail(
- reason="missing 'rdf:' prefix",
- raises=BadSyntax,
- ),
- ("trig", "rdf_prefix.jsonld"): pytest.mark.xfail(
- reason="missing 'rdf:' prefix",
- raises=BadSyntax,
- ),
- ("turtle", "rdf_prefix.jsonld"): pytest.mark.xfail(
- reason="missing 'rdf:' prefix",
- raises=BadSyntax,
- ),
}
# This is for files which can only be represented properly in one format
diff --git a/test/test_serializer.py b/test/test_serializer.py
index a86f49f4..fb9cdc11 100644
--- a/test/test_serializer.py
+++ b/test/test_serializer.py
@@ -1,8 +1,53 @@
+import logging
import unittest
-from rdflib import Graph, URIRef, Literal
+from rdflib import RDF, Graph, Literal, Namespace, URIRef
from tempfile import TemporaryDirectory
from pathlib import Path, PurePath
+from typing import Tuple, cast
+
+import pytest
+import itertools
+
+from rdflib.graph import ConjunctiveGraph
+
+from .testutils import GraphHelper
+
+
[email protected](
+ "format, tuple_index, is_keyword",
+ [
+ (format, tuple_index, keyword)
+ for format, (tuple_index, keyword) in itertools.product(
+ ["turtle", "n3", "trig"],
+ [
+ (0, False),
+ (1, True),
+ (2, False),
+ ],
+ )
+ ]
+ + [("trig", 3, False)],
+)
+def test_rdf_type(format: str, tuple_index: int, is_keyword: bool) -> None:
+ NS = Namespace("example:")
+ graph = ConjunctiveGraph()
+ graph.bind("eg", NS)
+ nodes = [NS.subj, NS.pred, NS.obj, NS.graph]
+ nodes[tuple_index] = RDF.type
+ quad = cast(Tuple[URIRef, URIRef, URIRef, URIRef], tuple(nodes))
+ graph.add(quad)
+ data = graph.serialize(format=format)
+ logging.info("data = %s", data)
+ assert NS in data
+ if is_keyword:
+ assert str(RDF) not in data
+ else:
+ assert str(RDF) in data
+ parsed_graph = ConjunctiveGraph()
+ parsed_graph.parse(data=data, format=format)
+ GraphHelper.assert_triple_sets_equals(graph, parsed_graph)
+
class TestSerialize(unittest.TestCase):
def setUp(self) -> None:
@@ -56,7 +101,3 @@ class TestSerialize(unittest.TestCase):
graph_check = Graph()
graph_check.parse(source=tfpath, format="nt")
self.assertEqual(self.triple, next(iter(graph_check)))
-
-
-if __name__ == "__main__":
- unittest.main()
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 0,
"test_score": 1
},
"num_modified_files": 1
} | 6.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | coverage==7.8.0
exceptiongroup==1.2.2
html5lib==1.1
iniconfig==2.1.0
isodate==0.7.2
packaging==24.2
pluggy==1.5.0
pyparsing==3.2.3
pytest==8.3.5
pytest-cov==6.0.0
-e git+https://github.com/RDFLib/rdflib.git@d3f945380dfef7bbdbb34de92fa9909d42cd851a#egg=rdflib
six==1.17.0
tomli==2.2.1
webencodings==0.5.1
| name: rdflib
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- coverage==7.8.0
- exceptiongroup==1.2.2
- html5lib==1.1
- iniconfig==2.1.0
- isodate==0.7.2
- packaging==24.2
- pluggy==1.5.0
- pyparsing==3.2.3
- pytest==8.3.5
- pytest-cov==6.0.0
- six==1.17.0
- tomli==2.2.1
- webencodings==0.5.1
prefix: /opt/conda/envs/rdflib
| [
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_trig]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_ttl]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_n3]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_turtle]",
"test/test_serializer.py::test_rdf_type[turtle-0-False]",
"test/test_serializer.py::test_rdf_type[turtle-2-False]",
"test/test_serializer.py::test_rdf_type[n3-0-False]",
"test/test_serializer.py::test_rdf_type[n3-2-False]",
"test/test_serializer.py::test_rdf_type[trig-0-False]",
"test/test_serializer.py::test_rdf_type[trig-2-False]"
] | [] | [
"test/test_roundtrip.py::test_formats",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_xml]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_trig]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_ttl]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_nquads]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_n3]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_trix]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_nt]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_turtle]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_json-ld]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_nt11]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_ntriples]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-06.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_verbs-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_trailing-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_test.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-07.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-06.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_simple-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest09.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest08.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest07.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest06.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_rdflibtest01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_quote-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_qname-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_paths-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_more_literals.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_literals-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_lists-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-07.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-06.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_keywords-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_i18n-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-09.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-08.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-07.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_formulae-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_even_more_literals.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-05.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-04.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-03.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-02.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_dtlang-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_bnode-01.nt_nt_hext]",
"test/test_roundtrip.py::test_nt[roundtrip_anons-01.nt_nt_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_xml]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_trig]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_ttl]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_nquads]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_n3]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_trix]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_nt]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_turtle]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_json-ld]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_nt11]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-21.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-22.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_ntriples]",
"test/test_roundtrip.py::test_n3[roundtrip_strquot.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-28.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-27.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-26.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-23.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-22.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-20.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-19.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-18.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-17.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-16.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-15.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-14.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-13.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-12.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-11.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-09.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-07.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-06.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-05.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-04.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-03.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_rdf-test-02.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-31.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-30.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-29.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-28.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-26.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-24.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-23.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-21.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-20.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-19.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-18.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-17.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-16.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-15.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-14.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-13.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-12.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-11.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-10.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-09.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-08.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-07.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-06.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-05.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-04.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-03.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_n3-writer-test-01.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.rdf_xml_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_longString.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_listTest.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_issue156.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_example-ontology.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_example-misc.n3_n3_hext]",
"test/test_roundtrip.py::test_n3[roundtrip_example-just_a_class.n3_n3_hext]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_xml]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_xml]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_trig]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_trig]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_ttl]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_ttl]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_nquads]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_nquads]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_nquads]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_n3]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_n3]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_trix]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_trix]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_nt]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_nt]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_nt]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_turtle]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_turtle]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_json-ld]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_json-ld]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_json-ld]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_nt11]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_nt11]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_nt11]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_ntriples]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_ntriples]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_ntriples]",
"test/test_roundtrip.py::test_extra[roundtrip_special_chars.nt_ntriples_hext]",
"test/test_roundtrip.py::test_extra[roundtrip_xml_literal.rdf_xml_hext]",
"test/test_roundtrip.py::test_extra[roundtrip_rdf_prefix.jsonld_json-ld_hext]",
"test/test_serializer.py::test_rdf_type[turtle-1-True]",
"test/test_serializer.py::test_rdf_type[n3-1-True]",
"test/test_serializer.py::test_rdf_type[trig-1-True]",
"test/test_serializer.py::test_rdf_type[trig-3-False]",
"test/test_serializer.py::TestSerialize::test_serialize_to_fileurl",
"test/test_serializer.py::TestSerialize::test_serialize_to_neturl",
"test/test_serializer.py::TestSerialize::test_serialize_to_path",
"test/test_serializer.py::TestSerialize::test_serialize_to_purepath"
] | [] | BSD 3-Clause "New" or "Revised" License | 12,057 | 194 | [
"rdflib/plugins/serializers/turtle.py"
] |
asottile__babi-181 | 961f9d0dfd4dc6c097572c4eed3c41398e67d2c3 | 2022-01-23 11:17:09 | 961f9d0dfd4dc6c097572c4eed3c41398e67d2c3 | diff --git a/babi/screen.py b/babi/screen.py
index bca6656..80c6d7a 100644
--- a/babi/screen.py
+++ b/babi/screen.py
@@ -487,7 +487,6 @@ class Screen:
def save(self) -> PromptResult | None:
self.file.finalize_previous_action()
- # TODO: make directories if they don't exist
# TODO: maybe use mtime / stat as a shortcut for hashing below
# TODO: strip trailing whitespace?
# TODO: save atomically?
@@ -513,6 +512,7 @@ class Screen:
return PromptResult.CANCELLED
try:
+ os.makedirs(os.path.dirname(self.file.filename), exist_ok=True)
with open(
self.file.filename, 'w', encoding='UTF-8', newline='',
) as f:
| TODO: make directories if they don't exist
This issue is equivalent to the comment in `babi/screen.py` at line 490. I would like to work on this to resolve the TODO-comment. | asottile/babi | diff --git a/tests/features/save_test.py b/tests/features/save_test.py
index 78bcde8..5465a53 100644
--- a/tests/features/save_test.py
+++ b/tests/features/save_test.py
@@ -276,3 +276,17 @@ def test_vim_force_exit(run, tmpdir):
trigger_command_mode(h)
h.press_and_enter(':q!')
h.await_exit()
+
+
+def test_save_on_exit_with_not_existing_directory(run, tmpdir):
+ f = tmpdir.join('test/nested/dirs/f')
+ with run(str(f)) as fake_h:
+ fake_h.press('hello')
+ fake_h.await_text('hello')
+ fake_h.press('^X')
+ fake_h.await_text('file is modified - save [yes, no]?')
+ fake_h.press('y')
+ fake_h.await_text('enter filename: ')
+ fake_h.press('Enter')
+ fake_h.await_exit()
+ assert f.read() == 'hello\n'
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_short_problem_statement"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 0
},
"num_modified_files": 1
} | 0.0 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc tmux"
],
"python": "3.9",
"reqs_path": [
"requirements-dev.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/asottile/babi.git@961f9d0dfd4dc6c097572c4eed3c41398e67d2c3#egg=babi
babi_grammars==0.0.62
cffi==1.17.1
covdefaults==2.3.0
coverage==7.8.0
exceptiongroup==1.2.2
hecate @ git+https://github.com/asottile/hecate@875567f2ca2a58220c4f1f70b0db9a79c018e2ae
identify==2.6.9
iniconfig==2.1.0
onigurumacffi==1.4.1
packaging==24.2
pluggy==1.5.0
pycparser==2.22
pytest==8.3.5
remote-pdb==2.1.0
tomli==2.2.1
| name: babi
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- babi-grammars==0.0.62
- cffi==1.17.1
- covdefaults==2.3.0
- coverage==7.8.0
- exceptiongroup==1.2.2
- hecate==0.1.0
- identify==2.6.9
- iniconfig==2.1.0
- onigurumacffi==1.4.1
- packaging==24.2
- pluggy==1.5.0
- pycparser==2.22
- pytest==8.3.5
- remote-pdb==2.1.0
- tomli==2.2.1
prefix: /opt/conda/envs/babi
| [
"tests/features/save_test.py::test_save_on_exit_with_not_existing_directory[fake]",
"tests/features/save_test.py::test_save_on_exit_with_not_existing_directory[tmux]"
] | [
"tests/features/save_test.py::test_saving_file_permission_denied[fake]",
"tests/features/save_test.py::test_saving_file_permission_denied[tmux]",
"tests/features/save_test.py::test_save_on_exit_resize[tmux]"
] | [
"tests/features/save_test.py::test_mixed_newlines[fake]",
"tests/features/save_test.py::test_modify_file_with_windows_newlines[fake]",
"tests/features/save_test.py::test_saving_file_with_multiple_lines_at_end_maintains_those[fake]",
"tests/features/save_test.py::test_new_file[fake]",
"tests/features/save_test.py::test_not_a_file[fake]",
"tests/features/save_test.py::test_save_no_filename_specified[fake]",
"tests/features/save_test.py::test_save_no_filename_specified_cancel[fake-Enter]",
"tests/features/save_test.py::test_save_no_filename_specified_cancel[fake-^C]",
"tests/features/save_test.py::test_saving_file_on_disk_changes[fake]",
"tests/features/save_test.py::test_allows_saving_same_contents_as_modified_contents[fake]",
"tests/features/save_test.py::test_allows_saving_if_file_on_disk_does_not_change[fake]",
"tests/features/save_test.py::test_save_file_when_it_did_not_exist[fake]",
"tests/features/save_test.py::test_save_via_ctrl_o[fake]",
"tests/features/save_test.py::test_save_via_ctrl_o_set_filename[fake]",
"tests/features/save_test.py::test_save_via_ctrl_o_new_filename[fake]",
"tests/features/save_test.py::test_save_via_ctrl_o_cancelled[fake-^C]",
"tests/features/save_test.py::test_save_via_ctrl_o_cancelled[fake-Enter]",
"tests/features/save_test.py::test_save_via_ctrl_o_position[fake]",
"tests/features/save_test.py::test_save_on_exit_cancel_yn[fake]",
"tests/features/save_test.py::test_save_on_exit_cancel_filename[fake]",
"tests/features/save_test.py::test_save_on_exit[fake]",
"tests/features/save_test.py::test_save_on_exit_resize[fake]",
"tests/features/save_test.py::test_vim_save_on_exit_cancel_yn[fake]",
"tests/features/save_test.py::test_vim_save_on_exit[fake]",
"tests/features/save_test.py::test_vim_force_exit[fake]",
"tests/features/save_test.py::test_mixed_newlines[tmux]",
"tests/features/save_test.py::test_modify_file_with_windows_newlines[tmux]",
"tests/features/save_test.py::test_saving_file_with_multiple_lines_at_end_maintains_those[tmux]",
"tests/features/save_test.py::test_new_file[tmux]",
"tests/features/save_test.py::test_not_a_file[tmux]",
"tests/features/save_test.py::test_save_no_filename_specified[tmux]",
"tests/features/save_test.py::test_save_no_filename_specified_cancel[tmux-Enter]",
"tests/features/save_test.py::test_save_no_filename_specified_cancel[tmux-^C]",
"tests/features/save_test.py::test_saving_file_on_disk_changes[tmux]",
"tests/features/save_test.py::test_allows_saving_same_contents_as_modified_contents[tmux]",
"tests/features/save_test.py::test_allows_saving_if_file_on_disk_does_not_change[tmux]",
"tests/features/save_test.py::test_save_file_when_it_did_not_exist[tmux]",
"tests/features/save_test.py::test_save_via_ctrl_o[tmux]",
"tests/features/save_test.py::test_save_via_ctrl_o_set_filename[tmux]",
"tests/features/save_test.py::test_save_via_ctrl_o_new_filename[tmux]",
"tests/features/save_test.py::test_save_via_ctrl_o_cancelled[tmux-^C]",
"tests/features/save_test.py::test_save_via_ctrl_o_cancelled[tmux-Enter]",
"tests/features/save_test.py::test_save_via_ctrl_o_position[tmux]",
"tests/features/save_test.py::test_save_on_exit_cancel_yn[tmux]",
"tests/features/save_test.py::test_save_on_exit_cancel_filename[tmux]",
"tests/features/save_test.py::test_save_on_exit[tmux]",
"tests/features/save_test.py::test_vim_save_on_exit_cancel_yn[tmux]",
"tests/features/save_test.py::test_vim_save_on_exit[tmux]",
"tests/features/save_test.py::test_vim_force_exit[tmux]"
] | [] | MIT License | 12,059 | 202 | [
"babi/screen.py"
] |
|
GazzolaLab__PyElastica-47 | 0bcbb4427160a2e2404f795119ed61871424d21e | 2022-01-24 16:56:26 | f5db6ce3bad32c08faa851d8b948b649f8d7054f | diff --git a/elastica/timestepper/symplectic_steppers.py b/elastica/timestepper/symplectic_steppers.py
index c268abe..b87483b 100644
--- a/elastica/timestepper/symplectic_steppers.py
+++ b/elastica/timestepper/symplectic_steppers.py
@@ -1,6 +1,7 @@
__doc__ = """Symplectic time steppers and concepts for integrating the kinematic and dynamic equations of rod-like objects. """
import numpy as np
+import math
# from elastica._elastica_numba._timestepper._symplectic_steppers import (
# SymplecticStepperTag,
@@ -105,7 +106,7 @@ class _SystemCollectionStepper:
SystemCollection.constrain_values(time)
# Call back function, will call the user defined call back functions and store data
- SystemCollection.apply_callbacks(time, int(time / dt))
+ SystemCollection.apply_callbacks(time, round(time / dt))
# Zero out the external forces and torques
for system in SystemCollection._memory_blocks:
diff --git a/elastica/wrappers/base_system.py b/elastica/wrappers/base_system.py
index 392086f..c4396d4 100644
--- a/elastica/wrappers/base_system.py
+++ b/elastica/wrappers/base_system.py
@@ -131,6 +131,10 @@ class BaseSystemCollection(MutableSequence):
"""
+ # FIXME: This is probably the most bizarre way to collect the functions. It is definitely
+ # impressive and even surprising that it is working, but it is far from readable and maintainable.
+ # The code is difficult to debug, because the behavior is un-interpretable except during run-time.
+ # We need a lot more documentation on this part: clear explanation and reasoning.
def get_methods_from_feature_classes(method_name: str):
methods = [
[v for (k, v) in cls.__dict__.items() if k.endswith(method_name)]
@@ -146,7 +150,9 @@ class BaseSystemCollection(MutableSequence):
self._features_that_constrain_rates = get_methods_from_feature_classes(
"_constrain_rates"
)
- self._callback_features = get_methods_from_feature_classes("_callBack")
+ self._callback_features = get_methods_from_feature_classes(
+ "_callback_execution"
+ )
finalize_methods = get_methods_from_feature_classes("_finalize")
# construct memory block
diff --git a/elastica/wrappers/callbacks.py b/elastica/wrappers/callbacks.py
index d5d51d8..c476b18 100644
--- a/elastica/wrappers/callbacks.py
+++ b/elastica/wrappers/callbacks.py
@@ -16,12 +16,12 @@ class CallBacks:
Attributes
----------
- _callbacks: list
+ _callback_list: list
List of call back classes defined for rod-like objects.
"""
def __init__(self):
- self._callbacks = []
+ self._callback_list = []
super(CallBacks, self).__init__()
def collect_diagnostics(self, system):
@@ -43,7 +43,7 @@ class CallBacks:
# Create _Constraint object, cache it and return to user
_callbacks = _CallBack(sys_idx)
- self._callbacks.append(_callbacks)
+ self._callback_list.append(_callbacks)
return _callbacks
@@ -54,9 +54,9 @@ class CallBacks:
# dev : the first index stores the rod index to collect data.
# Technically we can use another array but it its one more book-keeping
# step. Being lazy, I put them both in the same array
- self._callbacks[:] = [
+ self._callback_list[:] = [
(callback.id(), callback(self._systems[callback.id()]))
- for callback in self._callbacks
+ for callback in self._callback_list
]
# Sort from lowest id to highest id for potentially better memory access
@@ -65,13 +65,12 @@ class CallBacks:
# [(0, MyCallBack), (1, MyVelocityCallBack), ... ]
# Thus using lambda we iterate over the list of tuples and use rod number (x[0])
# to sort callbacks.
- self._callbacks.sort(key=lambda x: x[0])
+ self._callback_list.sort(key=lambda x: x[0])
- self._callBack(time=0.0, current_step=0)
+ self._callback_execution(time=0.0, current_step=0)
- # TODO: same as above naming of _callBack function
- def _callBack(self, time, current_step: int, *args, **kwargs):
- for sys_id, callback in self._callbacks:
+ def _callback_execution(self, time, current_step: int, *args, **kwargs):
+ for sys_id, callback in self._callback_list:
callback.make_callback(
self._systems[sys_id], time, current_step, *args, **kwargs
)
@@ -97,6 +96,7 @@ class _CallBack:
Parameters
----------
sys_idx: int
+ rod object index
"""
self._sys_idx = sys_idx
self._callback_cls = None
@@ -112,10 +112,6 @@ class _CallBack:
----------
callback_cls: object
User defined callback class.
- *args
- Variable length argument list
- **kwargs
- Arbitrary keyword arguments.
Returns
-------
@@ -134,18 +130,8 @@ class _CallBack:
def id(self):
return self._sys_idx
- def __call__(self, *args, **kwargs):
- """Constructs a callback functions after checks
-
- Parameters
- ----------
- args
- kwargs
-
- Returns
- -------
-
- """
+ def __call__(self, *args, **kwargs) -> CallBackBaseClass:
+ """Constructs a callback functions after checks"""
if not self._callback_cls:
raise RuntimeError(
"No callback provided to act on rod id {0}"
| Current-step passed to callback is determined by floating point division.
<a href="https://github.com/skim0119"><img src="https://avatars.githubusercontent.com/u/3798023?v=4" align="left" width="96" height="96" hspace="10"></img></a> **Issue by [skim0119](https://github.com/skim0119)**
_Friday Dec 31, 2021 at 21:31 GMT_
_Originally opened as https://github.com/GazzolaLab/elastica-python/issues/116_
----
https://github.com/GazzolaLab/PyElastica/blob/d5c18c3750fa64681150c73124fd349f533f2c48/elastica/timestepper/symplectic_steppers.py#L108
During the operation `int(time/dt)`, we loose up to 1 step error. If user write the callback such that the data is recorded every 100 steps, some of the data will be recorded either 99 steps.
| GazzolaLab/PyElastica | diff --git a/tests/test_wrappers/test_base_system.py b/tests/test_wrappers/test_base_system.py
index cbd9288..4003801 100644
--- a/tests/test_wrappers/test_base_system.py
+++ b/tests/test_wrappers/test_base_system.py
@@ -203,7 +203,7 @@ class TestBaseSystemWithFeaturesUsingCosseratRod:
simulator_class.collect_diagnostics(rod).using(legal_callback)
simulator_class.finalize()
# After finalize check if the created callback object is instance of the class we have given.
- assert isinstance(simulator_class._callbacks[-1][-1], legal_callback)
+ assert isinstance(simulator_class._callback_list[-1][-1], legal_callback)
# TODO: this is a dummy test for apply_callbacks find a better way to test them
simulator_class.apply_callbacks(time=0, current_step=0)
diff --git a/tests/test_wrappers/test_callbacks.py b/tests/test_wrappers/test_callbacks.py
index 5e94ec9..02238bf 100644
--- a/tests/test_wrappers/test_callbacks.py
+++ b/tests/test_wrappers/test_callbacks.py
@@ -131,7 +131,7 @@ class TestCallBacksMixin:
scwc.append(mock_rod)
_mock_callback = scwc.collect_diagnostics(mock_rod)
- assert _mock_callback in scwc._callbacks
+ assert _mock_callback in scwc._callback_list
assert _mock_callback.__class__ == _CallBack
from elastica.callback_functions import CallBackBaseClass
@@ -165,7 +165,7 @@ class TestCallBacksMixin:
scwc._finalize()
- for (x, y) in scwc._callbacks:
+ for (x, y) in scwc._callback_list:
assert type(x) is int
assert type(y) is callback_cls
@@ -177,6 +177,6 @@ class TestCallBacksMixin:
# this is allowed to fail (not critical)
num = -np.inf
- for (x, _) in scwc._callbacks:
+ for (x, _) in scwc._callback_list:
assert num < x
num = x
| {
"commit_name": "head_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 2
},
"num_modified_files": 3
} | 0.2 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .[dev]",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"flake8",
"codecov",
"black",
"pylint"
],
"pre_install": [
"apt-get update",
"apt-get install -y gcc"
],
"python": "3.7",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | astroid==2.15.8
black==21.12b0
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
click==8.1.8
codecov==2.1.13
coverage==7.2.7
cycler==0.11.0
dill==0.3.7
exceptiongroup==1.2.2
flake8==3.8.3
fonttools==4.38.0
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
isort==5.11.5
kiwisolver==1.4.5
lazy-object-proxy==1.9.0
llvmlite==0.34.0
matplotlib==3.5.3
mccabe==0.6.1
mypy-extensions==1.0.0
numba==0.51.0
numpy==1.21.6
packaging==24.0
pathspec==0.11.2
Pillow==9.5.0
platformdirs==4.0.0
pluggy==1.2.0
pycodestyle==2.6.0
-e git+https://github.com/GazzolaLab/PyElastica.git@0bcbb4427160a2e2404f795119ed61871424d21e#egg=pyelastica
pyflakes==2.2.0
pylint==2.17.7
pyparsing==3.1.4
pytest==7.4.4
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
requests==2.31.0
scipy==1.7.3
six==1.17.0
tomli==1.2.3
tomlkit==0.12.5
tqdm==4.67.1
typed-ast==1.5.5
typing_extensions==4.7.1
urllib3==2.0.7
wrapt==1.16.0
zipp==3.15.0
| name: PyElastica
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- certifi=2022.12.7=py37h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=1.1.1w=h7f8727e_0
- pip=22.3.1=py37h06a4308_0
- python=3.7.16=h7a1cb2a_0
- readline=8.2=h5eee18b_0
- setuptools=65.6.3=py37h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- wheel=0.38.4=py37h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- astroid==2.15.8
- black==21.12b0
- charset-normalizer==3.4.1
- click==8.1.8
- codecov==2.1.13
- coverage==7.2.7
- cycler==0.11.0
- dill==0.3.7
- exceptiongroup==1.2.2
- flake8==3.8.3
- fonttools==4.38.0
- idna==3.10
- importlib-metadata==6.7.0
- iniconfig==2.0.0
- isort==5.11.5
- kiwisolver==1.4.5
- lazy-object-proxy==1.9.0
- llvmlite==0.34.0
- matplotlib==3.5.3
- mccabe==0.6.1
- mypy-extensions==1.0.0
- numba==0.51.0
- numpy==1.21.6
- packaging==24.0
- pathspec==0.11.2
- pillow==9.5.0
- platformdirs==4.0.0
- pluggy==1.2.0
- pycodestyle==2.6.0
- pyflakes==2.2.0
- pylint==2.17.7
- pyparsing==3.1.4
- pytest==7.4.4
- pytest-cov==4.1.0
- python-dateutil==2.9.0.post0
- requests==2.31.0
- scipy==1.7.3
- six==1.17.0
- tomli==1.2.3
- tomlkit==0.12.5
- tqdm==4.67.1
- typed-ast==1.5.5
- typing-extensions==4.7.1
- urllib3==2.0.7
- wrapt==1.16.0
- zipp==3.15.0
prefix: /opt/conda/envs/PyElastica
| [
"tests/test_wrappers/test_base_system.py::TestBaseSystemWithFeaturesUsingCosseratRod::test_callback[CallBackBaseClass]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_registers_and_returns_Callback[2]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_registers_and_returns_Callback[10]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_finalize_correctness[2]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_finalize_correctness[10]"
] | [] | [
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_check_type_with_illegal_type_throws[int]",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_check_type_with_illegal_type_throws[list]",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_check_type_with_illegal_type_throws[tuple]",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_len",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_getitem",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_setitem",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_insert",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_str",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_extend_allowed_types",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_extend_correctness",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_override_allowed_types",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_override_correctness",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_invalid_idx_in_get_sys_index_throws",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_unregistered_system_in_get_sys_index_throws",
"tests/test_wrappers/test_base_system.py::TestBaseSystemCollection::test_get_sys_index_returns_correct_idx",
"tests/test_wrappers/test_base_system.py::TestBaseSystemWithFeaturesUsingCosseratRod::test_constraint[FreeRod]",
"tests/test_wrappers/test_base_system.py::TestBaseSystemWithFeaturesUsingCosseratRod::test_forcing[NoForces]",
"tests/test_wrappers/test_callbacks.py::TestCallBacks::test_using_with_illegal_callback_throws_assertion_error[int]",
"tests/test_wrappers/test_callbacks.py::TestCallBacks::test_using_with_illegal_callback_throws_assertion_error[list]",
"tests/test_wrappers/test_callbacks.py::TestCallBacks::test_using_with_legal_constraint[CallBackBaseClass]",
"tests/test_wrappers/test_callbacks.py::TestCallBacks::test_using_with_legal_constraint[MyCallBack]",
"tests/test_wrappers/test_callbacks.py::TestCallBacks::test_id",
"tests/test_wrappers/test_callbacks.py::TestCallBacks::test_call_improper_args_throws",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_with_illegal_index_throws[2]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_with_illegal_index_throws[10]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_with_unregistered_system_throws[2]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_with_unregistered_system_throws[10]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_with_illegal_system_throws[2]",
"tests/test_wrappers/test_callbacks.py::TestCallBacksMixin::test_callback_with_illegal_system_throws[10]"
] | [] | MIT License | 12,069 | 1,449 | [
"elastica/timestepper/symplectic_steppers.py",
"elastica/wrappers/base_system.py",
"elastica/wrappers/callbacks.py"
] |
|
ansible__ansible-runner-976 | 996a00dd0cd449e129a693e53b73770a6de34e36 | 2022-01-24 20:14:37 | ec5997e9b1c995e6b0ea90fd53baafb58ec7908e | Shrews: The `copytree()` portion of code used for directory isolation does not seem to be covered by any tests. I'd like to add a test for that before merging this change. However, I discovered a bug in that bit of code that needs fixed before we can merge this (see issue #977). | diff --git a/ansible_runner/config/runner.py b/ansible_runner/config/runner.py
index 84852e1..9fb96bb 100644
--- a/ansible_runner/config/runner.py
+++ b/ansible_runner/config/runner.py
@@ -23,7 +23,7 @@ import shlex
import stat
import tempfile
import six
-import distutils.dir_util
+import shutil
from six import string_types, text_type
@@ -146,7 +146,7 @@ class RunnerConfig(BaseConfig):
if os.path.exists(self.project_dir):
output.debug("Copying directory tree from {} to {} for working directory isolation".format(self.project_dir,
self.directory_isolation_path))
- distutils.dir_util.copy_tree(self.project_dir, self.directory_isolation_path, preserve_symlinks=True)
+ shutil.copytree(self.project_dir, self.directory_isolation_path, symlinks=True)
self.prepare_inventory()
self.prepare_command()
diff --git a/ansible_runner/utils/__init__.py b/ansible_runner/utils/__init__.py
index 84b2b2a..f516db0 100644
--- a/ansible_runner/utils/__init__.py
+++ b/ansible_runner/utils/__init__.py
@@ -17,8 +17,6 @@ import codecs
import atexit
import signal
-from distutils.spawn import find_executable
-
from ansible_runner.exceptions import ConfigurationError
try:
@@ -474,7 +472,7 @@ def sanitize_json_response(data):
def get_executable_path(name):
- exec_path = find_executable(name)
+ exec_path = shutil.which(name)
if exec_path is None:
raise ConfigurationError(f"{name} command not found")
return exec_path
| Stop using `distutils`
It's deprecated. Python 3.10 raises a `DeprecationWarning` and Python 3.12 won't have it in the stdlib anymore.
Why fix it now and not wait for another 2 years when this will produce an `ImportError`? Because it's nice to solve such problems ahead of time and also since ansible-runner is a library, it also causes these warnings (_or even errors_ with pytest's [`filterwarning = error`] or [`python -Werror`] [^-W-python-option]) for the projects that have Python 3.10 in their test matrixes. In particular, it's been observed in ansible-navigator.
[`filterwarning = error`]: https://docs.pytest.org/en/6.2.x/reference.html#confval-filterwarnings
[`python -Werror`]: https://docs.python.org/dev/library/warnings.html#the-warnings-filter
[^-W-python-option]: Learn more at https://docs.python.org/dev/using/cmdline.html#cmdoption-W | ansible/ansible-runner | diff --git a/test/conftest.py b/test/conftest.py
index 07676da..5e786f4 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -1,6 +1,5 @@
import shutil
-from distutils.version import LooseVersion
from pathlib import Path
from ansible_runner import defaults
@@ -25,16 +24,6 @@ def change_save_path(tmp_path, mocker):
mocker.patch.object(defaults, 'AUTO_CREATE_DIR', str(tmp_path))
[email protected](scope='session')
-def is_pre_ansible28():
- try:
- if LooseVersion(pkg_resources.get_distribution('ansible').version) < LooseVersion('2.8'):
- return True
- except pkg_resources.DistributionNotFound:
- # ansible-base (e.g. ansible 2.10 and beyond) is not accessible in this way
- pass
-
-
@pytest.fixture(scope='session')
def is_pre_ansible211():
"""
@@ -51,12 +40,6 @@ def is_pre_ansible211():
return True
[email protected](scope='session')
-def skipif_pre_ansible28(is_pre_ansible28):
- if is_pre_ansible28:
- pytest.skip("Valid only on Ansible 2.8+")
-
-
@pytest.fixture(scope='session')
def skipif_pre_ansible211(is_pre_ansible211):
if is_pre_ansible211:
diff --git a/test/integration/test___main__.py b/test/integration/test___main__.py
index f65c307..3772fae 100644
--- a/test/integration/test___main__.py
+++ b/test/integration/test___main__.py
@@ -98,7 +98,7 @@ def test_cmdline_role_with_playbook_option():
assert exc == 1
-def test_cmdline_playbook(is_pre_ansible28, tmp_path):
+def test_cmdline_playbook(tmp_path):
private_data_dir = tmp_path
play = [{'hosts': 'all', 'tasks': [{'debug': {'msg': random_string()}}]}]
@@ -142,7 +142,7 @@ def test_cmdline_includes_one_option():
assert exc == 1
-def test_cmdline_cmdline_override(is_pre_ansible28, tmp_path):
+def test_cmdline_cmdline_override(tmp_path):
private_data_dir = tmp_path
play = [{'hosts': 'all', 'tasks': [{'debug': {'msg': random_string()}}]}]
diff --git a/test/integration/test_display_callback.py b/test/integration/test_display_callback.py
index 8fedc0d..24bc907 100644
--- a/test/integration/test_display_callback.py
+++ b/test/integration/test_display_callback.py
@@ -13,7 +13,7 @@ HERE = os.path.abspath(os.path.dirname(__file__))
@pytest.fixture()
-def executor(tmp_path, request, is_pre_ansible28):
+def executor(tmp_path, request):
private_data_dir = tmp_path / 'foo'
private_data_dir.mkdir()
@@ -176,7 +176,7 @@ def test_callback_plugin_no_log_filters(executor, playbook):
- uri: url=https://example.org url_username="PUBLIC" url_password="PRIVATE"
'''}, # noqa
])
-def test_callback_plugin_task_args_leak(executor, playbook, skipif_pre_ansible28):
+def test_callback_plugin_task_args_leak(executor, playbook):
executor.run()
events = list(executor.events)
assert events[0]['event'] == 'playbook_on_start'
@@ -213,7 +213,7 @@ def test_callback_plugin_task_args_leak(executor, playbook, skipif_pre_ansible28
- debug: msg="{{ command_register.results|map(attribute='stdout')|list }}"
'''}, # noqa
])
-def test_callback_plugin_censoring_does_not_overwrite(executor, playbook, skipif_pre_ansible28):
+def test_callback_plugin_censoring_does_not_overwrite(executor, playbook):
executor.run()
events = list(executor.events)
assert events[0]['event'] == 'playbook_on_start'
@@ -258,7 +258,7 @@ def test_callback_plugin_strips_task_environ_variables(executor, playbook):
foo: "bar"
'''}, # noqa
])
-def test_callback_plugin_saves_custom_stats(executor, playbook, skipif_pre_ansible28):
+def test_callback_plugin_saves_custom_stats(executor, playbook):
executor.run()
for event in executor.events:
event_data = event.get('event_data', {})
@@ -284,7 +284,7 @@ def test_callback_plugin_saves_custom_stats(executor, playbook, skipif_pre_ansib
- my_handler
'''}, # noqa
])
-def test_callback_plugin_records_notify_events(executor, playbook, skipif_pre_ansible28):
+def test_callback_plugin_records_notify_events(executor, playbook):
executor.run()
assert len(list(executor.events))
notify_events = [x for x in executor.events if x['event'] == 'playbook_on_notify']
@@ -308,7 +308,7 @@ def test_callback_plugin_records_notify_events(executor, playbook, skipif_pre_an
url_password: "{{ pw }}"
'''}, # noqa
])
-def test_module_level_no_log(executor, playbook, skipif_pre_ansible28):
+def test_module_level_no_log(executor, playbook):
# It's possible for `no_log=True` to be defined at the _module_ level,
# e.g., for the URI module password parameter
# This test ensures that we properly redact those
@@ -398,7 +398,7 @@ def test_output_when_given_non_playbook_script(tmp_path):
msg: "{{ ('F' * 150) | list }}"
'''}, # noqa
])
-def test_large_stdout_parsing_when_using_json_output(executor, playbook, skipif_pre_ansible28):
+def test_large_stdout_parsing_when_using_json_output(executor, playbook):
# When the json flag is used, it is possible to output more data than
# pexpect's maxread default of 2000 characters. As a result, if not
# handled properly, the stdout can end up being corrupted with partial
diff --git a/test/integration/test_events.py b/test/integration/test_events.py
index 2e0b4c1..e91fc35 100644
--- a/test/integration/test_events.py
+++ b/test/integration/test_events.py
@@ -1,8 +1,7 @@
import os
import json
-from distutils.spawn import find_executable
-
+import shutil
import pytest
from ansible_runner import defaults, run, run_async
@@ -10,7 +9,7 @@ from ansible_runner import defaults, run, run_async
@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('containerized', [True, False])
-def test_basic_events(containerized, is_pre_ansible28, runtime, tmp_path, is_run_async=False, g_facts=False):
+def test_basic_events(containerized, runtime, tmp_path, is_run_async=False, g_facts=False):
inventory = 'localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"'
@@ -56,11 +55,11 @@ def test_basic_events(containerized, is_pre_ansible28, runtime, tmp_path, is_run
@pytest.mark.test_all_runtimes
@pytest.mark.parametrize('containerized', [True, False])
-def test_async_events(containerized, is_pre_ansible28, runtime, tmp_path):
- test_basic_events(containerized, is_pre_ansible28, runtime, tmp_path, is_run_async=True, g_facts=True)
+def test_async_events(containerized, runtime, tmp_path):
+ test_basic_events(containerized, runtime, tmp_path, is_run_async=True, g_facts=True)
-def test_basic_serializeable(is_pre_ansible28, tmp_path):
+def test_basic_serializeable(tmp_path):
inv = 'localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"'
r = run(private_data_dir=str(tmp_path),
inventory=inv,
@@ -69,7 +68,7 @@ def test_basic_serializeable(is_pre_ansible28, tmp_path):
json.dumps(events)
-def test_event_omission(is_pre_ansible28, tmp_path):
+def test_event_omission(tmp_path):
inv = 'localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"'
r = run(private_data_dir=str(tmp_path),
inventory=inv,
@@ -86,7 +85,7 @@ def test_event_omission(is_pre_ansible28, tmp_path):
assert not any([x['event_data'] for x in events])
-def test_event_omission_except_failed(is_pre_ansible28, tmp_path):
+def test_event_omission_except_failed(tmp_path):
inv = 'localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"'
r = run(private_data_dir=str(tmp_path),
inventory=inv,
@@ -105,7 +104,7 @@ def test_event_omission_except_failed(is_pre_ansible28, tmp_path):
assert len(all_event_datas) == 1
-def test_runner_on_start(rc, skipif_pre_ansible28, tmp_path):
+def test_runner_on_start(rc, tmp_path):
r = run(private_data_dir=str(tmp_path),
inventory='localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"',
playbook=[{'hosts': 'all', 'gather_facts': False, 'tasks': [{'debug': {'msg': "test"}}]}])
@@ -114,9 +113,7 @@ def test_runner_on_start(rc, skipif_pre_ansible28, tmp_path):
assert len(start_events) == 1
-def test_playbook_on_stats_summary_fields(project_fixtures, is_pre_ansible28):
- if is_pre_ansible28:
- pytest.skip('Test is for post 2.8 status types.')
+def test_playbook_on_stats_summary_fields(project_fixtures):
private_data_dir = project_fixtures / 'host_status'
res = run(
@@ -147,9 +144,9 @@ def test_include_role_events(project_fixtures):
assert event_data['res']['msg'] == 'Hello world!'
[email protected](find_executable('cgexec') is None,
[email protected](shutil.which('cgexec') is None,
reason="cgexec not available")
-def test_profile_data(skipif_pre_ansible28, tmp_path):
+def test_profile_data(tmp_path):
try:
r = run(private_data_dir=str(tmp_path),
inventory='localhost ansible_connection=local ansible_python_interpreter="{{ ansible_playbook_python }}"',
diff --git a/test/unit/config/test_runner.py b/test/unit/config/test_runner.py
index 4bc0b5b..afefe81 100644
--- a/test/unit/config/test_runner.py
+++ b/test/unit/config/test_runner.py
@@ -223,7 +223,7 @@ def test_prepare_env_directory_isolation_from_settings(mocker, project_fixtures)
'''
# Mock away the things that would actually prepare the isolation directory.
mocker.patch('os.makedirs', return_value=True)
- copy_tree = mocker.patch('distutils.dir_util.copy_tree')
+ copy_tree = mocker.patch('shutil.copytree')
mkdtemp = mocker.patch('tempfile.mkdtemp')
mkdtemp.return_value = '/tmp/runner/runner_di_XYZ'
mocker.patch('ansible_runner.config.runner.RunnerConfig.build_process_isolation_temp_dir')
@@ -245,7 +245,7 @@ def test_prepare_env_directory_isolation_from_settings(mocker, project_fixtures)
mkdtemp.assert_called_once_with(prefix='runner_di_', dir='/tmp/runner')
# The project files should be copied to the isolation path.
- copy_tree.assert_called_once_with(rc.project_dir, rc.directory_isolation_path, preserve_symlinks=True)
+ copy_tree.assert_called_once_with(rc.project_dir, rc.directory_isolation_path, symlinks=True)
def test_prepare_inventory(mocker):
| {
"commit_name": "merge_commit",
"failed_lite_validators": [
"has_hyperlinks",
"has_many_modified_files",
"has_many_hunks"
],
"has_test_patch": true,
"is_lite": false,
"llm_score": {
"difficulty_score": 1,
"issue_text_score": 1,
"test_score": 3
},
"num_modified_files": 2
} | 2.1 | {
"env_vars": null,
"env_yml_path": null,
"install": "pip install -e .",
"log_parser": "parse_log_pytest",
"no_use_env": null,
"packages": "requirements.txt",
"pip_packages": [
"pytest",
"pytest-cov",
"pytest-mock",
"pytest-timeout",
"pytest-xdist"
],
"pre_install": null,
"python": "3.9",
"reqs_path": [
"requirements.txt"
],
"test_cmd": "pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning"
} | -e git+https://github.com/ansible/ansible-runner.git@996a00dd0cd449e129a693e53b73770a6de34e36#egg=ansible_runner
coverage==7.8.0
exceptiongroup==1.2.2
execnet==2.1.1
iniconfig==2.1.0
lockfile==0.12.2
packaging==24.2
pexpect==4.9.0
pluggy==1.5.0
ptyprocess==0.7.0
pytest==8.3.5
pytest-cov==6.0.0
pytest-mock==3.14.0
pytest-timeout==2.3.1
pytest-xdist==3.6.1
python-daemon==3.1.2
PyYAML==6.0.2
six==1.17.0
tomli==2.2.1
| name: ansible-runner
channels:
- defaults
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
- conda-forge
dependencies:
- _libgcc_mutex=0.1=main
- _openmp_mutex=5.1=1_gnu
- ca-certificates=2025.2.25=h06a4308_0
- ld_impl_linux-64=2.40=h12ee557_0
- libffi=3.4.4=h6a678d5_1
- libgcc-ng=11.2.0=h1234567_1
- libgomp=11.2.0=h1234567_1
- libstdcxx-ng=11.2.0=h1234567_1
- ncurses=6.4=h6a678d5_0
- openssl=3.0.16=h5eee18b_0
- pip=25.0=py39h06a4308_0
- python=3.9.21=he870216_1
- readline=8.2=h5eee18b_0
- setuptools=75.8.0=py39h06a4308_0
- sqlite=3.45.3=h5eee18b_0
- tk=8.6.14=h39e8969_0
- tzdata=2025a=h04d1e81_0
- wheel=0.45.1=py39h06a4308_0
- xz=5.6.4=h5eee18b_1
- zlib=1.2.13=h5eee18b_1
- pip:
- coverage==7.8.0
- exceptiongroup==1.2.2
- execnet==2.1.1
- iniconfig==2.1.0
- lockfile==0.12.2
- packaging==24.2
- pexpect==4.9.0
- pluggy==1.5.0
- ptyprocess==0.7.0
- pytest==8.3.5
- pytest-cov==6.0.0
- pytest-mock==3.14.0
- pytest-timeout==2.3.1
- pytest-xdist==3.6.1
- python-daemon==3.1.2
- pyyaml==6.0.2
- six==1.17.0
- tomli==2.2.1
prefix: /opt/conda/envs/ansible-runner
| [
"test/unit/config/test_runner.py::test_prepare_env_directory_isolation_from_settings"
] | [
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-helloworld.yml-playbook_on_task_start]",
"test/integration/test_display_callback.py::test_callback_plugin_saves_custom_stats[playbook0]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-results_included.yml-playbook_on_stats]",
"test/integration/test_events.py::test_include_role_events",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-results_included.yml-runner_on_ok]",
"test/integration/test_display_callback.py::test_large_stdout_parsing_when_using_json_output[playbook0]",
"test/integration/test_display_callback.py::test_output_when_given_invalid_playbook",
"test/integration/test_display_callback.py::test_callback_plugin_records_notify_events[playbook0]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-results_included.yml-playbook_on_play_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-helloworld.yml-runner_on_ok]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-results_included.yml-playbook_on_task_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-helloworld.yml-playbook_on_task_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-results_included.yml-playbook_on_stats]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-helloworld.yml-playbook_on_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-results_included.yml-playbook_on_play_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-results_included.yml-playbook_on_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-results_included.yml-playbook_on_start]",
"test/integration/test_events.py::test_playbook_on_stats_summary_fields",
"test/integration/test_events.py::test_runner_on_start",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-helloworld.yml-playbook_on_start]",
"test/integration/test_events.py::test_event_omission_except_failed",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-helloworld.yml-playbook_on_stats]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[local-callback-plugin-helloworld.yml-playbook_on_play_start]",
"test/integration/test___main__.py::test_cmdline_cmdline_override",
"test/integration/test___main__.py::test_cmdline_playbook",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-helloworld.yml-playbook_on_stats]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-results_included.yml-playbook_on_task_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-helloworld.yml-runner_on_ok]",
"test/integration/test_display_callback.py::test_callback_plugin_censoring_does_not_overwrite[playbook0]",
"test/integration/test_display_callback.py::test_module_level_no_log[playbook0]",
"test/integration/test_display_callback.py::test_callback_plugin_task_args_leak[playbook0]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-helloworld.yml-playbook_on_play_start]",
"test/integration/test_display_callback.py::test_callback_plugin_receives_events[no-callback-plugin-results_included.yml-runner_on_ok]"
] | [
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook3]",
"test/integration/test___main__.py::test_cmdline_includes_one_option",
"test/unit/config/test_runner.py::test_runner_config_with_artifact_dir",
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook0]",
"test/unit/config/test_runner.py::test_generate_ansible_command_with_cmdline_args[--tags",
"test/integration/test___main__.py::test_main_bad_private_data_dir",
"test/integration/test_events.py::test_basic_serializeable",
"test/integration/test___main__.py::test_cmdline_role_with_playbook_option",
"test/unit/config/test_runner.py::test_prepare_env_sshkey_defaults",
"test/unit/config/test_runner.py::test_prepare_env_settings_defaults",
"test/integration/test___main__.py::test_cmdline_playbook_hosts",
"test/unit/config/test_runner.py::test_runner_config_init_defaults",
"test/unit/config/test_runner.py::test_prepare_environment_pexpect_defaults",
"test/unit/config/test_runner.py::test_prepare_env_settings",
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook4]",
"test/unit/config/test_runner.py::test_prepare",
"test/unit/config/test_runner.py::test_prepare_env_ad_hoc_command",
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook1]",
"test/unit/config/test_runner.py::test_generate_ansible_command_with_cmdline_args[--limit",
"test/unit/config/test_runner.py::test_prepare_env_sshkey",
"test/unit/config/test_runner.py::test_prepare_env_defaults",
"test/unit/config/test_runner.py::test_generate_ansible_command_extra_vars[None-expected2]",
"test/unit/config/test_runner.py::test_process_isolation_executable_not_found[False]",
"test/unit/config/test_runner.py::test_generate_ansible_command_extra_vars[/tmp/extravars.yml-expected1]",
"test/unit/config/test_runner.py::test_prepare_env_extra_vars_defaults",
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook6]",
"test/unit/config/test_runner.py::test_wrap_args_with_ssh_agent_defaults",
"test/unit/config/test_runner.py::test_generate_ansible_command_with_dict_extravars",
"test/integration/test_display_callback.py::test_callback_plugin_strips_task_environ_variables[playbook0]",
"test/unit/config/test_runner.py::test_process_isolation_executable_not_found[True]",
"test/unit/config/test_runner.py::test_bwrap_process_isolation_defaults",
"test/integration/test___main__.py::test_cmdline_role[options3-expected_playbook3]",
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook5]",
"test/unit/config/test_runner.py::test_prepare_with_ssh_key",
"test/integration/test___main__.py::test_cmdline_role[options2-expected_playbook2]",
"test/unit/config/test_runner.py::test_runner_config_project_dir",
"test/integration/test___main__.py::test_cmdline_role[options1-expected_playbook1]",
"test/unit/config/test_runner.py::test_prepare_with_defaults",
"test/unit/config/test_runner.py::test_prepare_env_passwords",
"test/unit/config/test_runner.py::test_prepare_environment_vars_only_strings",
"test/unit/config/test_runner.py::test_runner_config_init_with_ident",
"test/integration/test___main__.py::test_cmdline_role[options0-expected_playbook0]",
"test/integration/test_events.py::test_event_omission",
"test/unit/config/test_runner.py::test_generate_ansible_command_extra_vars[extra_vars0-expected0]",
"test/unit/config/test_runner.py::test_generate_ansible_command",
"test/unit/config/test_runner.py::test_prepare_inventory",
"test/integration/test_display_callback.py::test_callback_plugin_no_log_filters[playbook2]",
"test/unit/config/test_runner.py::test_prepare_command_defaults",
"test/unit/config/test_runner.py::test_wrap_args_with_ssh_agent_silent",
"test/unit/config/test_runner.py::test_bwrap_process_isolation_and_directory_isolation",
"test/unit/config/test_runner.py::test_profiling_plugin_settings_with_custom_intervals",
"test/unit/config/test_runner.py::test_wrap_args_with_ssh_agent_with_auth",
"test/unit/config/test_runner.py::test_prepare_env_directory_isolation",
"test/unit/config/test_runner.py::test_generate_ansible_command_with_api_extravars",
"test/unit/config/test_runner.py::test_process_isolation_settings",
"test/unit/config/test_runner.py::test_container_volume_mounting_with_Z",
"test/integration/test_display_callback.py::test_output_when_given_non_playbook_script",
"test/unit/config/test_runner.py::test_profiling_plugin_settings"
] | [] | Apache License 2.0 | 12,070 | 401 | [
"ansible_runner/config/runner.py",
"ansible_runner/utils/__init__.py"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.