Dataset Viewer
Auto-converted to Parquet
instance_id
stringlengths
14
37
patch
stringlengths
296
33.9k
repo
stringlengths
10
32
base_commit
stringlengths
40
40
hints_text
stringlengths
0
45.1k
test_patch
stringlengths
377
33.2k
problem_statement
stringlengths
39
37.7k
version
stringclasses
1 value
FAIL_TO_PASS
sequencelengths
1
182
PASS_TO_PASS
sequencelengths
0
1.29k
created_at
stringlengths
25
25
__index_level_0__
int64
1.89k
4.12k
devopsspiral__KubeLibrary-124
diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b2f42..e8800dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## In progress + +## [0.8.1] - 2022-12-16 +### Added - Add proxy configuration fetched from `HTTP_PROXY` or `http_proxy` environment variable +### Fixed +Fix disabling cert validation [#124](https://github.com/devopsspiral/KubeLibrary/pull/124) + ## [0.8.0] - 2022-10-27 ### Added - Add function list_namespaced_stateful_set_by_pattern [#114](https://github.com/devopsspiral/KubeLibrary/pull/113) by [@siaomingjeng](https://github.com/siaomingjeng) diff --git a/src/KubeLibrary/KubeLibrary.py b/src/KubeLibrary/KubeLibrary.py index 3f73adc..ebff896 100755 --- a/src/KubeLibrary/KubeLibrary.py +++ b/src/KubeLibrary/KubeLibrary.py @@ -1,6 +1,5 @@ import json import re -import ssl import urllib3 from os import environ @@ -276,7 +275,7 @@ class KubeLibrary: def _add_api(self, reference, class_name): self.__dict__[reference] = class_name(self.api_client) if not self.cert_validation: - self.__dict__[reference].api_client.rest_client.pool_manager.connection_pool_kw['cert_reqs'] = ssl.CERT_NONE + self.__dict__[reference].api_client.configuration.verify_ssl = False def k8s_api_ping(self): """Performs GET on /api/v1/ for simple check of API availability. diff --git a/src/KubeLibrary/version.py b/src/KubeLibrary/version.py index 8675559..73baf8f 100644 --- a/src/KubeLibrary/version.py +++ b/src/KubeLibrary/version.py @@ -1,1 +1,1 @@ -version = "0.8.0" +version = "0.8.1"
devopsspiral/KubeLibrary
7f4037c283a38751f9a31160944a17e7b80ec97b
diff --git a/test/test_KubeLibrary.py b/test/test_KubeLibrary.py index b99291b..7cae67e 100644 --- a/test/test_KubeLibrary.py +++ b/test/test_KubeLibrary.py @@ -1,7 +1,6 @@ import json import mock import re -import ssl import unittest from KubeLibrary import KubeLibrary from KubeLibrary.exceptions import BearerTokenWithPrefixException @@ -306,7 +305,7 @@ class TestKubeLibrary(unittest.TestCase): kl = KubeLibrary(kube_config='test/resources/k3d', cert_validation=False) for api in TestKubeLibrary.apis: target = getattr(kl, api) - self.assertEqual(target.api_client.rest_client.pool_manager.connection_pool_kw['cert_reqs'], ssl.CERT_NONE) + self.assertEqual(target.api_client.configuration.verify_ssl, False) @responses.activate def test_KubeLibrary_inits_with_bearer_token(self):
certificate verify failed issue when using Get Namespaced Pod Exec When using the Get Namespaced Pod Exec keywork on a k8s cluster using a custom CA, the following error occurs : ``` ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get issuer certificate (_ssl.c:1129) ``` Other keywords (Read Namespaced Pod Status, List Namespaced Pod By Pattern ...) are working as expected. As a quick fix, I'm adding the following line in the _add_api method of the library : ``` def _add_api(self, reference, class_name): self.__dict__[reference] = class_name(self.api_client) if not self.cert_validation: self.__dict__[reference].api_client.rest_client.pool_manager.connection_pool_kw['cert_reqs'] = ssl.CERT_NONE self.__dict__[reference].api_client.configuration.verify_ssl = False ``` Am I missing something regarding the library configuration ? Versions : ``` KubeLibrary: 0.8.0 Python: 3.9.13 Kubernetes: 1.24 ``` KubeLibrary : ``` Library KubeLibrary kube_config=${KUBECONFIG_FILE} cert_validation=False KubeLibrary.Get Namespaced Pod Exec ... name=my-pod ... namespace=${namespace} ... argv_cmd=${command} ```
0.0
[ "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_deployment_by_pattern" ]
[ "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_dynamic_delete", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespace", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_inits_with_bearer_token", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_endpoints", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_daemon_set", "test/test_KubeLibrary.py::TestKubeLibrary::test_inits_all_api_clients", "test/test_KubeLibrary.py::TestKubeLibrary::test_assert_pod_has_annotations", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_secret_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_dynamic_create", "test/test_KubeLibrary.py::TestKubeLibrary::test_get_namespaced_exec_without_container", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_cron_job", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_ingress", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_service_account_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_horizontal_pod_autoscaler", "test/test_KubeLibrary.py::TestKubeLibrary::test_assert_container_has_env_vars", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_ingress", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_dynamic_replace", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_job_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_inits_with_context", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_daemon_set", "test/test_KubeLibrary.py::TestKubeLibrary::test_get_matching_pods_in_namespace", "test/test_KubeLibrary.py::TestKubeLibrary::test_get_namespaced_exec_not_argv_and_list", "test/test_KubeLibrary.py::TestKubeLibrary::test_get_configmaps_in_namespace", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_cluster_role_binding", "test/test_KubeLibrary.py::TestKubeLibrary::test_filter_containers_images", "test/test_KubeLibrary.py::TestKubeLibrary::test_filter_pods_containers_statuses_by_name", "test/test_KubeLibrary.py::TestKubeLibrary::test_evaluate_callable_from_k8s_client", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_persistent_volume_claim_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_dynamic_init", "test/test_KubeLibrary.py::TestKubeLibrary::test_get_kubelet_version", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_role_binding", "test/test_KubeLibrary.py::TestKubeLibrary::test_generate_alphanumeric_str", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_inits_from_kubeconfig", "test/test_KubeLibrary.py::TestKubeLibrary::test_assert_pod_has_labels", "test/test_KubeLibrary.py::TestKubeLibrary::test_filter_pods_containers_by_name", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_dynamic_patch", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_inits_with_bearer_token_with_ca_crt", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_role", "test/test_KubeLibrary.py::TestKubeLibrary::test_filter_containers_resources", "test/test_KubeLibrary.py::TestKubeLibrary::test_get_namespaced_exec_with_container", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_fails_for_wrong_context", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_stateful_set_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_persistent_volume_claim", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_horizontal_pod_autoscaler", "test/test_KubeLibrary.py::TestKubeLibrary::test_KubeLibrary_dynamic_get", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_service", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_service", "test/test_KubeLibrary.py::TestKubeLibrary::test_inits_with_bearer_token_raises_BearerTokenWithPrefixException", "test/test_KubeLibrary.py::TestKubeLibrary::test_read_namespaced_pod_status", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_replica_set_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_cron_job", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_namespaced_pod_by_pattern", "test/test_KubeLibrary.py::TestKubeLibrary::test_list_cluster_role" ]
2022-12-16 14:17:09+00:00
1,894
docker__docker-py-1390
diff --git a/docker/api/service.py b/docker/api/service.py index 0d8421ec..d2621e68 100644 --- a/docker/api/service.py +++ b/docker/api/service.py @@ -1,5 +1,6 @@ import warnings from .. import auth, errors, utils +from ..types import ServiceMode class ServiceApiMixin(object): @@ -18,8 +19,8 @@ class ServiceApiMixin(object): name (string): User-defined name for the service. Optional. labels (dict): A map of labels to associate with the service. Optional. - mode (string): Scheduling mode for the service (``replicated`` or - ``global``). Defaults to ``replicated``. + mode (ServiceMode): Scheduling mode for the service (replicated + or global). Defaults to replicated. update_config (UpdateConfig): Specification for the update strategy of the service. Default: ``None`` networks (:py:class:`list`): List of network names or IDs to attach @@ -49,6 +50,9 @@ class ServiceApiMixin(object): raise errors.DockerException( 'Missing mandatory Image key in ContainerSpec' ) + if mode and not isinstance(mode, dict): + mode = ServiceMode(mode) + registry, repo_name = auth.resolve_repository_name(image) auth_header = auth.get_config_header(self, registry) if auth_header: @@ -191,8 +195,8 @@ class ServiceApiMixin(object): name (string): New name for the service. Optional. labels (dict): A map of labels to associate with the service. Optional. - mode (string): Scheduling mode for the service (``replicated`` or - ``global``). Defaults to ``replicated``. + mode (ServiceMode): Scheduling mode for the service (replicated + or global). Defaults to replicated. update_config (UpdateConfig): Specification for the update strategy of the service. Default: ``None``. networks (:py:class:`list`): List of network names or IDs to attach @@ -222,6 +226,8 @@ class ServiceApiMixin(object): if labels is not None: data['Labels'] = labels if mode is not None: + if not isinstance(mode, dict): + mode = ServiceMode(mode) data['Mode'] = mode if task_template is not None: image = task_template.get('ContainerSpec', {}).get('Image', None) diff --git a/docker/types/__init__.py b/docker/types/__init__.py index 7230723e..8e2fc174 100644 --- a/docker/types/__init__.py +++ b/docker/types/__init__.py @@ -4,6 +4,6 @@ from .healthcheck import Healthcheck from .networks import EndpointConfig, IPAMConfig, IPAMPool, NetworkingConfig from .services import ( ContainerSpec, DriverConfig, EndpointSpec, Mount, Resources, RestartPolicy, - TaskTemplate, UpdateConfig + ServiceMode, TaskTemplate, UpdateConfig ) from .swarm import SwarmSpec, SwarmExternalCA diff --git a/docker/types/services.py b/docker/types/services.py index 6e1ad321..ec0fcb15 100644 --- a/docker/types/services.py +++ b/docker/types/services.py @@ -348,3 +348,38 @@ def convert_service_ports(ports): result.append(port_spec) return result + + +class ServiceMode(dict): + """ + Indicate whether a service should be deployed as a replicated or global + service, and associated parameters + + Args: + mode (string): Can be either ``replicated`` or ``global`` + replicas (int): Number of replicas. For replicated services only. + """ + def __init__(self, mode, replicas=None): + if mode not in ('replicated', 'global'): + raise errors.InvalidArgument( + 'mode must be either "replicated" or "global"' + ) + if mode != 'replicated' and replicas is not None: + raise errors.InvalidArgument( + 'replicas can only be used for replicated mode' + ) + self[mode] = {} + if replicas: + self[mode]['Replicas'] = replicas + + @property + def mode(self): + if 'global' in self: + return 'global' + return 'replicated' + + @property + def replicas(self): + if self.mode != 'replicated': + return None + return self['replicated'].get('Replicas') diff --git a/docs/api.rst b/docs/api.rst index 110b0a7f..b5c1e929 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -110,5 +110,6 @@ Configuration types .. autoclass:: Mount .. autoclass:: Resources .. autoclass:: RestartPolicy +.. autoclass:: ServiceMode .. autoclass:: TaskTemplate .. autoclass:: UpdateConfig
docker/docker-py
5f0b469a09421b0d6140661de9466af74ac3e9ec
diff --git a/tests/integration/api_service_test.py b/tests/integration/api_service_test.py index fc794002..77d7d28f 100644 --- a/tests/integration/api_service_test.py +++ b/tests/integration/api_service_test.py @@ -251,3 +251,31 @@ class ServiceTest(BaseAPIIntegrationTest): con_spec = svc_info['Spec']['TaskTemplate']['ContainerSpec'] assert 'Env' in con_spec assert con_spec['Env'] == ['DOCKER_PY_TEST=1'] + + def test_create_service_global_mode(self): + container_spec = docker.types.ContainerSpec( + 'busybox', ['echo', 'hello'] + ) + task_tmpl = docker.types.TaskTemplate(container_spec) + name = self.get_service_name() + svc_id = self.client.create_service( + task_tmpl, name=name, mode='global' + ) + svc_info = self.client.inspect_service(svc_id) + assert 'Mode' in svc_info['Spec'] + assert 'Global' in svc_info['Spec']['Mode'] + + def test_create_service_replicated_mode(self): + container_spec = docker.types.ContainerSpec( + 'busybox', ['echo', 'hello'] + ) + task_tmpl = docker.types.TaskTemplate(container_spec) + name = self.get_service_name() + svc_id = self.client.create_service( + task_tmpl, name=name, + mode=docker.types.ServiceMode('replicated', 5) + ) + svc_info = self.client.inspect_service(svc_id) + assert 'Mode' in svc_info['Spec'] + assert 'Replicated' in svc_info['Spec']['Mode'] + assert svc_info['Spec']['Mode']['Replicated'] == {'Replicas': 5} diff --git a/tests/unit/dockertypes_test.py b/tests/unit/dockertypes_test.py index d11e4f03..5c470ffa 100644 --- a/tests/unit/dockertypes_test.py +++ b/tests/unit/dockertypes_test.py @@ -7,7 +7,8 @@ import pytest from docker.constants import DEFAULT_DOCKER_API_VERSION from docker.errors import InvalidArgument, InvalidVersion from docker.types import ( - EndpointConfig, HostConfig, IPAMConfig, IPAMPool, LogConfig, Mount, Ulimit, + EndpointConfig, HostConfig, IPAMConfig, IPAMPool, LogConfig, Mount, + ServiceMode, Ulimit, ) try: @@ -260,7 +261,35 @@ class IPAMConfigTest(unittest.TestCase): }) -class TestMounts(unittest.TestCase): +class ServiceModeTest(unittest.TestCase): + def test_replicated_simple(self): + mode = ServiceMode('replicated') + assert mode == {'replicated': {}} + assert mode.mode == 'replicated' + assert mode.replicas is None + + def test_global_simple(self): + mode = ServiceMode('global') + assert mode == {'global': {}} + assert mode.mode == 'global' + assert mode.replicas is None + + def test_global_replicas_error(self): + with pytest.raises(InvalidArgument): + ServiceMode('global', 21) + + def test_replicated_replicas(self): + mode = ServiceMode('replicated', 21) + assert mode == {'replicated': {'Replicas': 21}} + assert mode.mode == 'replicated' + assert mode.replicas == 21 + + def test_invalid_mode(self): + with pytest.raises(InvalidArgument): + ServiceMode('foobar') + + +class MountTest(unittest.TestCase): def test_parse_mount_string_ro(self): mount = Mount.parse_mount_string("/foo/bar:/baz:ro") assert mount['Source'] == "/foo/bar"
Unable to create Service in `global` mode Attempting to create a service with `mode="global"` returns an error from the Docker API: ``` cannot unmarshal string into Go value of type swarm.ServiceMode ```
0.0
[ "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_invalid_cpu_cfs_types", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_invalid_mem_swappiness", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_no_options", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_no_options_newer_api_version", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_pid_mode", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_blkio_constraints", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_cpu_period", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_cpu_quota", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_dns_opt", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_isolation", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_kernel_memory", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_mem_reservation", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_oom_kill_disable", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_oom_score_adj", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_pids_limit", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_shm_size", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_shm_size_in_mb", "tests/unit/dockertypes_test.py::HostConfigTest::test_create_host_config_with_userns_mode", "tests/unit/dockertypes_test.py::UlimitTest::test_create_host_config_dict_ulimit", "tests/unit/dockertypes_test.py::UlimitTest::test_create_host_config_dict_ulimit_capitals", "tests/unit/dockertypes_test.py::UlimitTest::test_create_host_config_obj_ulimit", "tests/unit/dockertypes_test.py::UlimitTest::test_ulimit_invalid_type", "tests/unit/dockertypes_test.py::LogConfigTest::test_create_host_config_dict_logconfig", "tests/unit/dockertypes_test.py::LogConfigTest::test_create_host_config_obj_logconfig", "tests/unit/dockertypes_test.py::LogConfigTest::test_logconfig_invalid_config_type", "tests/unit/dockertypes_test.py::EndpointConfigTest::test_create_endpoint_config_with_aliases", "tests/unit/dockertypes_test.py::IPAMConfigTest::test_create_ipam_config", "tests/unit/dockertypes_test.py::ServiceModeTest::test_global_replicas_error", "tests/unit/dockertypes_test.py::ServiceModeTest::test_global_simple", "tests/unit/dockertypes_test.py::ServiceModeTest::test_invalid_mode", "tests/unit/dockertypes_test.py::ServiceModeTest::test_replicated_replicas", "tests/unit/dockertypes_test.py::ServiceModeTest::test_replicated_simple", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_bind", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_named_volume", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_string_invalid", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_string_no_source", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_string_ro", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_string_rw", "tests/unit/dockertypes_test.py::MountTest::test_parse_mount_string_short_form" ]
[]
2017-01-12 02:32:06+00:00
1,966
docker__docker-py-1710
diff --git a/README.md b/README.md index 747b98b2..3ff124d7 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ The latest stable version [is available on PyPI](https://pypi.python.org/pypi/do pip install docker +If you are intending to connect to a docker host via TLS, add `docker[tls]` to your requirements instead, or install with pip: + + pip install docker[tls] + ## Usage Connect to Docker using the default socket or the configuration in your environment: diff --git a/appveyor.yml b/appveyor.yml index 1fc67cc0..41cde625 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,7 +3,7 @@ version: '{branch}-{build}' install: - "SET PATH=C:\\Python27-x64;C:\\Python27-x64\\Scripts;%PATH%" - "python --version" - - "pip install tox==2.1.1 virtualenv==13.1.2" + - "pip install tox==2.7.0 virtualenv==15.1.0" # Build the binary after tests build: false diff --git a/docker/api/build.py b/docker/api/build.py index cbef4a8b..5d4e7720 100644 --- a/docker/api/build.py +++ b/docker/api/build.py @@ -274,7 +274,10 @@ class BuildApiMixin(object): self._auth_configs, registry ) else: - auth_data = self._auth_configs + auth_data = self._auth_configs.copy() + # See https://github.com/docker/docker-py/issues/1683 + if auth.INDEX_NAME in auth_data: + auth_data[auth.INDEX_URL] = auth_data[auth.INDEX_NAME] log.debug( 'Sending auth config ({0})'.format( diff --git a/docker/auth.py b/docker/auth.py index ec9c45b9..c3fb062e 100644 --- a/docker/auth.py +++ b/docker/auth.py @@ -10,7 +10,7 @@ from . import errors from .constants import IS_WINDOWS_PLATFORM INDEX_NAME = 'docker.io' -INDEX_URL = 'https://{0}/v1/'.format(INDEX_NAME) +INDEX_URL = 'https://index.{0}/v1/'.format(INDEX_NAME) DOCKER_CONFIG_FILENAME = os.path.join('.docker', 'config.json') LEGACY_DOCKER_CONFIG_FILENAME = '.dockercfg' TOKEN_USERNAME = '<token>' @@ -118,7 +118,7 @@ def _resolve_authconfig_credstore(authconfig, registry, credstore_name): if not registry or registry == INDEX_NAME: # The ecosystem is a little schizophrenic with index.docker.io VS # docker.io - in that case, it seems the full URL is necessary. - registry = 'https://index.docker.io/v1/' + registry = INDEX_URL log.debug("Looking for auth entry for {0}".format(repr(registry))) store = dockerpycreds.Store(credstore_name) try: diff --git a/docker/utils/build.py b/docker/utils/build.py index 79b72495..d4223e74 100644 --- a/docker/utils/build.py +++ b/docker/utils/build.py @@ -26,6 +26,7 @@ def exclude_paths(root, patterns, dockerfile=None): if dockerfile is None: dockerfile = 'Dockerfile' + patterns = [p.lstrip('/') for p in patterns] exceptions = [p for p in patterns if p.startswith('!')] include_patterns = [p[1:] for p in exceptions] diff --git a/requirements.txt b/requirements.txt index 37541312..f3c61e79 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,16 @@ -requests==2.11.1 -six>=1.4.0 -websocket-client==0.32.0 -backports.ssl_match_hostname>=3.5 ; python_version < '3.5' -ipaddress==1.0.16 ; python_version < '3.3' +appdirs==1.4.3 +asn1crypto==0.22.0 +backports.ssl-match-hostname==3.5.0.1 +cffi==1.10.0 +cryptography==1.9 docker-pycreds==0.2.1 +enum34==1.1.6 +idna==2.5 +ipaddress==1.0.18 +packaging==16.8 +pycparser==2.17 +pyOpenSSL==17.0.0 +pyparsing==2.2.0 +requests==2.14.2 +six==1.10.0 +websocket-client==0.40.0 diff --git a/setup.py b/setup.py index 31180d23..4a33c8df 100644 --- a/setup.py +++ b/setup.py @@ -35,6 +35,16 @@ extras_require = { # ssl_match_hostname to verify hosts match with certificates via # ServerAltname: https://pypi.python.org/pypi/backports.ssl_match_hostname ':python_version < "3.3"': 'ipaddress >= 1.0.16', + + # If using docker-py over TLS, highly recommend this option is + # pip-installed or pinned. + + # TODO: if pip installing both "requests" and "requests[security]", the + # extra package from the "security" option are not installed (see + # https://github.com/pypa/pip/issues/4391). Once that's fixed, instead of + # installing the extra dependencies, install the following instead: + # 'requests[security] >= 2.5.2, != 2.11.0, != 2.12.2' + 'tls': ['pyOpenSSL>=0.14', 'cryptography>=1.3.4', 'idna>=2.0.0'], } version = None
docker/docker-py
5e4a69bbdafef6f1036b733ce356c6692c65e775
diff --git a/tests/unit/utils_test.py b/tests/unit/utils_test.py index 7045d23c..4a391fac 100644 --- a/tests/unit/utils_test.py +++ b/tests/unit/utils_test.py @@ -768,6 +768,11 @@ class ExcludePathsTest(unittest.TestCase): self.all_paths - set(['foo/a.py']) ) + def test_single_subdir_single_filename_leading_slash(self): + assert self.exclude(['/foo/a.py']) == convert_paths( + self.all_paths - set(['foo/a.py']) + ) + def test_single_subdir_with_path_traversal(self): assert self.exclude(['foo/whoops/../a.py']) == convert_paths( self.all_paths - set(['foo/a.py'])
using private image in FROM during build is broken Example: ``` import docker from io import BytesIO dockerfile=""" FROM <some-private-image-on-docker-hub> CMD ["ls"] """ f = BytesIO(dockerfile.encode('utf-8')) client = docker.APIClient(version='auto') client.login(username='<user>', password='<pass>') for l in client.build(fileobj=f, rm=True, tag='test', stream=True, pull=True): print(l) ``` This example will error saying that it failed to find the image in FROM. If you add the full registry: ``` client = docker.APIClient(version='auto') client.login(username='<user>', password='<pass>', registry='https://index.docker.io/v1/') ``` It will succeed. If you leave off the trailing slash on the registry url, it will fail. python 3.5.2 docker-py 2.4.2
0.0
[ "tests/unit/utils_test.py::ExcludePathsTest::test_single_subdir_single_filename_leading_slash" ]
[ "tests/unit/utils_test.py::DecoratorsTest::test_update_headers", "tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_alternate_env", "tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_empty", "tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_no_cert_path", "tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_tls", "tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_tls_verify_false", "tests/unit/utils_test.py::KwargsFromEnvTest::test_kwargs_from_env_tls_verify_false_no_cert", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_compact", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_complete", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_empty", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_list", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_no_mode", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_unicode_bytes_input", "tests/unit/utils_test.py::ConverVolumeBindsTest::test_convert_volume_binds_unicode_unicode_input", "tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_commented_line", "tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_invalid_line", "tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_newline", "tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_proper", "tests/unit/utils_test.py::ParseEnvFileTest::test_parse_env_file_with_equals_character", "tests/unit/utils_test.py::ParseHostTest::test_parse_host", "tests/unit/utils_test.py::ParseHostTest::test_parse_host_empty_value", "tests/unit/utils_test.py::ParseHostTest::test_parse_host_tls", "tests/unit/utils_test.py::ParseHostTest::test_parse_host_tls_tcp_proto", "tests/unit/utils_test.py::ParseHostTest::test_parse_host_trailing_slash", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_image_no_tag", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_image_sha", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_image_tag", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_user_image_no_tag", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_index_user_image_tag", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_private_reg_image_no_tag", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_private_reg_image_sha", "tests/unit/utils_test.py::ParseRepositoryTagTest::test_private_reg_image_tag", "tests/unit/utils_test.py::ParseDeviceTest::test_dict", "tests/unit/utils_test.py::ParseDeviceTest::test_full_string_definition", "tests/unit/utils_test.py::ParseDeviceTest::test_hybrid_list", "tests/unit/utils_test.py::ParseDeviceTest::test_partial_string_definition", "tests/unit/utils_test.py::ParseDeviceTest::test_permissionless_string_definition", "tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_float", "tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_invalid", "tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_maxint", "tests/unit/utils_test.py::ParseBytesTest::test_parse_bytes_valid", "tests/unit/utils_test.py::UtilsTest::test_convert_filters", "tests/unit/utils_test.py::UtilsTest::test_decode_json_header", "tests/unit/utils_test.py::SplitCommandTest::test_split_command_with_unicode", "tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_matching_internal_port_ranges", "tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_matching_internal_ports", "tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_nonmatching_internal_port_ranges", "tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_nonmatching_internal_ports", "tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_one_port", "tests/unit/utils_test.py::PortsTest::test_build_port_bindings_with_port_range", "tests/unit/utils_test.py::PortsTest::test_host_only_with_colon", "tests/unit/utils_test.py::PortsTest::test_non_matching_length_port_ranges", "tests/unit/utils_test.py::PortsTest::test_port_and_range_invalid", "tests/unit/utils_test.py::PortsTest::test_port_only_with_colon", "tests/unit/utils_test.py::PortsTest::test_split_port_empty_string", "tests/unit/utils_test.py::PortsTest::test_split_port_invalid", "tests/unit/utils_test.py::PortsTest::test_split_port_no_host_port", "tests/unit/utils_test.py::PortsTest::test_split_port_non_string", "tests/unit/utils_test.py::PortsTest::test_split_port_random_port_range_with_host_port", "tests/unit/utils_test.py::PortsTest::test_split_port_range_no_host_port", "tests/unit/utils_test.py::PortsTest::test_split_port_range_with_host_ip_no_port", "tests/unit/utils_test.py::PortsTest::test_split_port_range_with_host_port", "tests/unit/utils_test.py::PortsTest::test_split_port_range_with_protocol", "tests/unit/utils_test.py::PortsTest::test_split_port_with_host_ip", "tests/unit/utils_test.py::PortsTest::test_split_port_with_host_ip_no_port", "tests/unit/utils_test.py::PortsTest::test_split_port_with_host_port", "tests/unit/utils_test.py::PortsTest::test_split_port_with_ipv6_address", "tests/unit/utils_test.py::PortsTest::test_split_port_with_protocol", "tests/unit/utils_test.py::PortsTest::test_with_no_container_port", "tests/unit/utils_test.py::ExcludePathsTest::test_directory", "tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_single_exception", "tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_subdir_exception", "tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_trailing_slash", "tests/unit/utils_test.py::ExcludePathsTest::test_directory_with_wildcard_exception", "tests/unit/utils_test.py::ExcludePathsTest::test_double_wildcard", "tests/unit/utils_test.py::ExcludePathsTest::test_exclude_custom_dockerfile", "tests/unit/utils_test.py::ExcludePathsTest::test_exclude_dockerfile_child", "tests/unit/utils_test.py::ExcludePathsTest::test_exclude_dockerfile_dockerignore", "tests/unit/utils_test.py::ExcludePathsTest::test_no_dupes", "tests/unit/utils_test.py::ExcludePathsTest::test_no_excludes", "tests/unit/utils_test.py::ExcludePathsTest::test_question_mark", "tests/unit/utils_test.py::ExcludePathsTest::test_single_and_double_wildcard", "tests/unit/utils_test.py::ExcludePathsTest::test_single_filename", "tests/unit/utils_test.py::ExcludePathsTest::test_single_filename_leading_dot_slash", "tests/unit/utils_test.py::ExcludePathsTest::test_single_filename_trailing_slash", "tests/unit/utils_test.py::ExcludePathsTest::test_single_subdir_single_filename", "tests/unit/utils_test.py::ExcludePathsTest::test_single_subdir_wildcard_filename", "tests/unit/utils_test.py::ExcludePathsTest::test_single_subdir_with_path_traversal", "tests/unit/utils_test.py::ExcludePathsTest::test_subdirectory", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_exclude", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_filename_end", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_filename_start", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_subdir_single_filename", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_subdir_wildcard_filename", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_with_exception", "tests/unit/utils_test.py::ExcludePathsTest::test_wildcard_with_wildcard_exception", "tests/unit/utils_test.py::TarTest::test_tar_socket_file", "tests/unit/utils_test.py::TarTest::test_tar_with_directory_symlinks", "tests/unit/utils_test.py::TarTest::test_tar_with_empty_directory", "tests/unit/utils_test.py::TarTest::test_tar_with_excludes", "tests/unit/utils_test.py::TarTest::test_tar_with_file_symlinks", "tests/unit/utils_test.py::ShouldCheckDirectoryTest::test_shoud_check_parent_directories_of_excluded", "tests/unit/utils_test.py::ShouldCheckDirectoryTest::test_should_check_directory_not_excluded", "tests/unit/utils_test.py::ShouldCheckDirectoryTest::test_should_check_excluded_directory_with_exceptions", "tests/unit/utils_test.py::ShouldCheckDirectoryTest::test_should_check_subdirectories_of_exceptions", "tests/unit/utils_test.py::ShouldCheckDirectoryTest::test_should_not_check_excluded_directories_with_no_exceptions", "tests/unit/utils_test.py::ShouldCheckDirectoryTest::test_should_not_check_siblings_of_exceptions", "tests/unit/utils_test.py::FormatEnvironmentTest::test_format_env_binary_unicode_value", "tests/unit/utils_test.py::FormatEnvironmentTest::test_format_env_no_value" ]
2017-08-15 22:39:49+00:00
1,969
dotpot__InAppPy-54
diff --git a/README.rst b/README.rst index 9ea1223..771796a 100644 --- a/README.rst +++ b/README.rst @@ -17,10 +17,11 @@ Table of contents 2. Installation 3. Google Play (`receipt` + `signature`) 4. Google Play (verification) -5. App Store (`receipt` + using optional `shared-secret`) -6. App Store Response (`validation_result` / `raw_response`) example -7. App Store, **asyncio** version (available in the inapppy.asyncio package) -8. Development +5. Google Play (verification with result) +6. App Store (`receipt` + using optional `shared-secret`) +7. App Store Response (`validation_result` / `raw_response`) example +8. App Store, **asyncio** version (available in the inapppy.asyncio package) +9. Development 1. Introduction @@ -88,7 +89,42 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S return response -5. App Store (validates `receipt` using optional `shared-secret` against iTunes service) +5. Google Play verification (with result) +========================================= +Alternative to `.verify` method, instead of raising an error result class will be returned. + +.. code:: python + + from inapppy import GooglePlayVerifier, errors + + + def google_validator(receipt): + """ + Accepts receipt, validates in Google. + """ + purchase_token = receipt['purchaseToken'] + product_sku = receipt['productId'] + verifier = GooglePlayVerifier( + GOOGLE_BUNDLE_ID, + GOOGLE_SERVICE_ACCOUNT_KEY_FILE, + ) + response = {'valid': False, 'transactions': []} + + result = verifier.verify_with_result( + purchase_token, + product_sku, + is_subscription=True + ) + + # result contains data + raw_response = result.raw_response + is_canceled = result.is_canceled + is_expired = result.is_expired + + return result + + +6. App Store (validates `receipt` using optional `shared-secret` against iTunes service) ======================================================================================== .. code:: python @@ -110,7 +146,7 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S -6. App Store Response (`validation_result` / `raw_response`) example +7. App Store Response (`validation_result` / `raw_response`) example ==================================================================== .. code:: json @@ -190,7 +226,7 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S } -7. App Store, asyncio version (available in the inapppy.asyncio package) +8. App Store, asyncio version (available in the inapppy.asyncio package) ======================================================================== .. code:: python @@ -213,7 +249,7 @@ In-app purchase validation library for `Apple AppStore` and `GooglePlay` (`App S -8. Development +9. Development ============== .. code:: bash diff --git a/inapppy/errors.py b/inapppy/errors.py index 6436945..bad7e22 100644 --- a/inapppy/errors.py +++ b/inapppy/errors.py @@ -18,5 +18,4 @@ class InAppPyValidationError(Exception): class GoogleError(InAppPyValidationError): - def __init__(self, message: str = None, raw_response: dict = None, *args, **kwargs): - super().__init__(message, raw_response, *args, **kwargs) + pass diff --git a/inapppy/googleplay.py b/inapppy/googleplay.py index 25a849c..eee64a8 100644 --- a/inapppy/googleplay.py +++ b/inapppy/googleplay.py @@ -72,6 +72,27 @@ class GooglePlayValidator: return False +class GoogleVerificationResult: + """Google verification result class.""" + + raw_response: dict = {} + is_expired: bool = False + is_canceled: bool = False + + def __init__(self, raw_response: dict, is_expired: bool, is_canceled: bool): + self.raw_response = raw_response + self.is_expired = is_expired + self.is_canceled = is_canceled + + def __repr__(self): + return ( + f"GoogleVerificationResult(" + f"raw_response={self.raw_response}, " + f"is_expired={self.is_expired}, " + f"is_canceled={self.is_canceled})" + ) + + class GooglePlayVerifier: def __init__(self, bundle_id: str, private_key_path: str, http_timeout: int = 15) -> None: """ @@ -159,3 +180,32 @@ class GooglePlayVerifier: raise GoogleError("Purchase cancelled", result) return result + + def verify_with_result( + self, purchase_token: str, product_sku: str, is_subscription: bool = False + ) -> GoogleVerificationResult: + """Verifies by returning verification result instead of raising an error, + basically it's and better alternative to verify method.""" + service = build("androidpublisher", "v3", http=self.http) + verification_result = GoogleVerificationResult({}, False, False) + + if is_subscription: + result = self.check_purchase_subscription(purchase_token, product_sku, service) + verification_result.raw_response = result + + cancel_reason = int(result.get("cancelReason", 0)) + if cancel_reason != 0: + verification_result.is_canceled = True + + ms_timestamp = result.get("expiryTimeMillis", 0) + if self._ms_timestamp_expired(ms_timestamp): + verification_result.is_expired = True + else: + result = self.check_purchase_product(purchase_token, product_sku, service) + verification_result.raw_response = result + + purchase_state = int(result.get("purchaseState", 1)) + if purchase_state != 0: + verification_result.is_canceled = True + + return verification_result
dotpot/InAppPy
662179362b679dbd3250cc759299bd454842b6dc
diff --git a/tests/test_google_verifier.py b/tests/test_google_verifier.py index 0e213a7..ed517e2 100644 --- a/tests/test_google_verifier.py +++ b/tests/test_google_verifier.py @@ -32,6 +32,48 @@ def test_google_verify_subscription(): verifier.verify("test-token", "test-product", is_subscription=True) +def test_google_verify_with_result_subscription(): + with patch.object(googleplay, "build", return_value=None): + with patch.object(googleplay.GooglePlayVerifier, "_authorize", return_value=None): + verifier = googleplay.GooglePlayVerifier("test-bundle-id", "private_key_path", 30) + + # expired + with patch.object(verifier, "check_purchase_subscription", return_value={"expiryTimeMillis": 666}): + result = verifier.verify_with_result("test-token", "test-product", is_subscription=True) + assert result.is_canceled is False + assert result.is_expired + assert result.raw_response == {"expiryTimeMillis": 666} + assert ( + str(result) == "GoogleVerificationResult(raw_response=" + "{'expiryTimeMillis': 666}, " + "is_expired=True, " + "is_canceled=False)" + ) + + # canceled + with patch.object(verifier, "check_purchase_subscription", return_value={"cancelReason": 666}): + result = verifier.verify_with_result("test-token", "test-product", is_subscription=True) + assert result.is_canceled + assert result.is_expired + assert result.raw_response == {"cancelReason": 666} + assert ( + str(result) == "GoogleVerificationResult(" + "raw_response={'cancelReason': 666}, " + "is_expired=True, " + "is_canceled=True)" + ) + + # norm + now = datetime.datetime.utcnow().timestamp() + exp_value = now * 1000 + 10 ** 10 + with patch.object(verifier, "check_purchase_subscription", return_value={"expiryTimeMillis": exp_value}): + result = verifier.verify_with_result("test-token", "test-product", is_subscription=True) + assert result.is_canceled is False + assert result.is_expired is False + assert result.raw_response == {"expiryTimeMillis": exp_value} + assert str(result) is not None + + def test_google_verify_product(): with patch.object(googleplay, "build", return_value=None): with patch.object(googleplay.GooglePlayVerifier, "_authorize", return_value=None): @@ -47,6 +89,33 @@ def test_google_verify_product(): verifier.verify("test-token", "test-product") +def test_google_verify_with_result_product(): + with patch.object(googleplay, "build", return_value=None): + with patch.object(googleplay.GooglePlayVerifier, "_authorize", return_value=None): + verifier = googleplay.GooglePlayVerifier("test-bundle-id", "private_key_path", 30) + + # purchase + with patch.object(verifier, "check_purchase_product", return_value={"purchaseState": 0}): + result = verifier.verify_with_result("test-token", "test-product") + assert result.is_canceled is False + assert result.is_expired is False + assert result.raw_response == {"purchaseState": 0} + assert str(result) is not None + + # cancelled + with patch.object(verifier, "check_purchase_product", return_value={"purchaseState": 1}): + result = verifier.verify_with_result("test-token", "test-product") + assert result.is_canceled + assert result.is_expired is False + assert result.raw_response == {"purchaseState": 1} + assert ( + str(result) == "GoogleVerificationResult(" + "raw_response={'purchaseState': 1}, " + "is_expired=False, " + "is_canceled=True)" + ) + + DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
cancelled android purchases do not get caught correctly in lines 109-110 of googleplay.py: ``` cancel_reason = int(result.get('cancelReason', 0)) if cancel_reason != 0: raise GoogleError('Subscription is canceled', result) ``` If we look at [the docs](https://developers.google.com/android-publisher/api-ref/purchases/subscriptions) we see that a value of `cancelReason = 0` also indicates cancellation by user. Therefore I do not understand what was the original intention of this snippet of code. If we look at the lines following this snippet: ``` ms_timestamp = result.get('expiryTimeMillis', 0) if self._ms_timestamp_expired(ms_timestamp): raise GoogleError('Subscription expired', result) else: result = self.check_purchase_product(purchase_token, product_sku, service) purchase_state = int(result.get('purchaseState', 1)) if purchase_state != 0: raise GoogleError('Purchase cancelled', result) ``` I think the general issue here is, that a subscription can be a) not cancelled and not expired b) cancelled and not expired c) cancelled and expired So even if we fixed the issue with the code above, we would have to rethink how we throw errors / catch google certificate expiry (see also #25). I suggest we remove the current mechanism of throwing errors an instead return some sort of datastructure containing: `raw_response`, `is_expired`, `is_cancelled`. That way we describe all 3 scenarios above. What do you think?
0.0
[ "tests/test_google_verifier.py::test_google_verify_with_result_subscription", "tests/test_google_verifier.py::test_google_verify_with_result_product" ]
[ "tests/test_google_verifier.py::test_google_verify_subscription", "tests/test_google_verifier.py::test_google_verify_product", "tests/test_google_verifier.py::test_bad_request_subscription", "tests/test_google_verifier.py::test_bad_request_product" ]
2019-07-25 13:24:02+00:00
1,979
drewkerrigan__nagios-http-json-62
diff --git a/check_http_json.py b/check_http_json.py index 6b74bd9..4781abd 100755 --- a/check_http_json.py +++ b/check_http_json.py @@ -225,9 +225,9 @@ class JsonRuleProcessor: if self.rules.value_separator: value_separator = self.rules.value_separator self.helper = JsonHelper(self.data, separator, value_separator) - debugPrint(rules_args.debug, "rules:%s" % rules_args) - debugPrint(rules_args.debug, "separator:%s" % separator) - debugPrint(rules_args.debug, "value_separator:%s" % value_separator) + debugPrint(rules_args.debug, "rules: %s" % rules_args) + debugPrint(rules_args.debug, "separator: %s" % separator) + debugPrint(rules_args.debug, "value_separator: %s" % value_separator) self.metric_list = self.expandKeys(self.rules.metric_list) self.key_threshold_warning = self.expandKeys( self.rules.key_threshold_warning) @@ -346,6 +346,8 @@ class JsonRuleProcessor: def checkCritical(self): failure = '' + if not self.data: + failure = " Empty JSON data." if self.key_threshold_critical is not None: failure += self.checkThresholds(self.key_threshold_critical) if self.key_value_list_critical is not None:
drewkerrigan/nagios-http-json
41279cad2cfdb58ee051db887ee94daea1f578f8
diff --git a/test/test_check_http_json.py b/test/test_check_http_json.py index 489213a..659e77c 100644 --- a/test/test_check_http_json.py +++ b/test/test_check_http_json.py @@ -256,7 +256,7 @@ class UtilTest(unittest.TestCase): # This should not throw a KeyError data = '{}' - self.check_data(rules.dash_q(['(0).Node,foobar', '(1).Node,missing']), data, WARNING_CODE) + self.check_data(rules.dash_q(['(0).Node,foobar', '(1).Node,missing']), data, CRITICAL_CODE) def test_subelem(self): @@ -274,3 +274,23 @@ class UtilTest(unittest.TestCase): self.check_data(rules.dash_E(['(*).capacity.value.too_deep']), data, CRITICAL_CODE) # Should not throw keyerror self.check_data(rules.dash_E(['foo']), data, CRITICAL_CODE) + + + def test_empty_key_value_array(self): + """ + https://github.com/drewkerrigan/nagios-http-json/issues/61 + """ + + rules = RulesHelper() + + # This should simply work + data = '[{"update_status": "finished"},{"update_status": "finished"}]' + self.check_data(rules.dash_q(['(*).update_status,finished']), data, OK_CODE) + + # This should warn us + data = '[{"update_status": "finished"},{"update_status": "failure"}]' + self.check_data(rules.dash_q(['(*).update_status,finished']), data, WARNING_CODE) + + # This should throw an error + data = '[]' + self.check_data(rules.dash_q(['(*).update_status,warn_me']), data, CRITICAL_CODE) diff --git a/test/test_main.py b/test/test_main.py index 47d77c7..a531af7 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -12,7 +12,7 @@ from check_http_json import main class MockResponse(): - def __init__(self, status_code=200, content='{}'): + def __init__(self, status_code=200, content='{"foo": "bar"}'): self.status_code = status_code self.content = content
Using --key-equals with an empty list returns OK Trying to monitor the GitLab mirror status of some projects through the API. Since I don't know how many mirrors exist for a particular project, I use the 'data for keys of all items in a list' notation. This works fine, but the check returns an OK status if the response is an empty list (`[]`). That would mean that if somebody accidentally removed all mirrors we would not be alerted. Equality check used: `-q "(*).update_status,finished"`
0.0
[ "test/test_check_http_json.py::UtilTest::test_array_with_missing_element", "test/test_check_http_json.py::UtilTest::test_empty_key_value_array" ]
[ "test/test_check_http_json.py::UtilTest::test_critical_thresholds", "test/test_check_http_json.py::UtilTest::test_equality", "test/test_check_http_json.py::UtilTest::test_equality_colon", "test/test_check_http_json.py::UtilTest::test_exists", "test/test_check_http_json.py::UtilTest::test_metrics", "test/test_check_http_json.py::UtilTest::test_non_equality", "test/test_check_http_json.py::UtilTest::test_separator", "test/test_check_http_json.py::UtilTest::test_subarrayelem_missing_elem", "test/test_check_http_json.py::UtilTest::test_subelem", "test/test_check_http_json.py::UtilTest::test_unknown", "test/test_check_http_json.py::UtilTest::test_warning_thresholds", "test/test_main.py::MainTest::test_main_version", "test/test_main.py::MainTest::test_main_with_http_error_no_json", "test/test_main.py::MainTest::test_main_with_http_error_valid_json", "test/test_main.py::MainTest::test_main_with_parse_error", "test/test_main.py::MainTest::test_main_with_ssl", "test/test_main.py::MainTest::test_main_with_url_error" ]
2020-06-27 06:01:13+00:00
1,998
dstl__Stone-Soup-215
diff --git a/stonesoup/metricgenerator/tracktotruthmetrics.py b/stonesoup/metricgenerator/tracktotruthmetrics.py index d076e4d2..0ac1edca 100644 --- a/stonesoup/metricgenerator/tracktotruthmetrics.py +++ b/stonesoup/metricgenerator/tracktotruthmetrics.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import datetime +import warnings from operator import attrgetter import numpy as np @@ -48,6 +49,16 @@ class SIAPMetrics(MetricGenerator): self.LS(manager)] return metrics + @staticmethod + def _warn_no_truth(manager): + if len(manager.groundtruth_paths) == 0: + warnings.warn("No truth to generate SIAP Metric", stacklevel=2) + + @staticmethod + def _warn_no_tracks(manager): + if len(manager.tracks) == 0: + warnings.warn("No tracks to generate SIAP Metric", stacklevel=2) + def C_single_time(self, manager, timestamp): r"""SIAP metric C at a specific time @@ -126,8 +137,12 @@ class SIAPMetrics(MetricGenerator): """ timestamps = manager.list_timestamps() - C = self._jt_sum(manager, timestamps) / self._j_sum( - manager, timestamps) + try: + C = self._jt_sum(manager, timestamps) / self._j_sum( + manager, timestamps) + except ZeroDivisionError: + self._warn_no_truth(manager) + C = 0 return TimeRangeMetric( title="SIAP C", value=C, @@ -165,8 +180,12 @@ class SIAPMetrics(MetricGenerator): """ timestamps = manager.list_timestamps() - A = self._na_sum(manager, timestamps) / self._jt_sum( - manager, timestamps) + try: + A = self._na_sum(manager, timestamps) / self._jt_sum(manager, timestamps) + except ZeroDivisionError: + self._warn_no_truth(manager) + self._warn_no_tracks(manager) + A = 0 return TimeRangeMetric( title="SIAP A", value=A, @@ -207,7 +226,11 @@ class SIAPMetrics(MetricGenerator): self._n_t(manager, timestamp) - self._na_t(manager, timestamp) for timestamp in timestamps) - S = numerator / self._n_sum(manager, timestamps) + try: + S = numerator / self._n_sum(manager, timestamps) + except ZeroDivisionError: + self._warn_no_tracks(manager) + S = 0 return TimeRangeMetric( title="SIAP S", value=S, @@ -234,6 +257,8 @@ class SIAPMetrics(MetricGenerator): r = self._r(manager) if r == 0: value = np.inf + self._warn_no_truth(manager) + self._warn_no_tracks(manager) else: value = 1 / r @@ -277,9 +302,14 @@ class SIAPMetrics(MetricGenerator): for truth in manager.groundtruth_paths) timestamps = manager.list_timestamps() + try: + LS = numerator / denominator + except ZeroDivisionError: + self._warn_no_truth(manager) + LS = 0 return TimeRangeMetric( title="SIAP LS", - value=numerator / denominator, + value=LS, time_range=TimeRange(min(timestamps), max(timestamps)), generator=self) @@ -571,7 +601,11 @@ class SIAPMetrics(MetricGenerator): for truth in manager.groundtruth_paths) denominator = sum(self._tt_j(manager, truth).total_seconds() for truth in manager.groundtruth_paths) - return numerator / denominator + try: + return numerator / denominator + except ZeroDivisionError: + # No truth or tracks + return 0 def _t_j(self, truth): """Total time truth exists for
dstl/Stone-Soup
1bf38717a65d21044480c1da4625be243c7d1b5a
diff --git a/stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py b/stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py index e7a3df90..6fc0c9ea 100644 --- a/stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py +++ b/stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py @@ -1,5 +1,7 @@ import datetime +import pytest + from ..tracktotruthmetrics import SIAPMetrics from ...types.association import TimeRangeAssociation, AssociationSet from ...types.track import Track @@ -271,7 +273,6 @@ def test_compute_metric(): track9 = Track( states=[State([[9]], timestamp=tstart + datetime.timedelta(seconds=i)) for i in range(35, 40)]) - manager.groundtruth_paths = truth manager.tracks = {track1, track2, track3, track4, track5, track6, track7, track8, track9} manager.groundtruth_paths = {truth} @@ -330,3 +331,77 @@ def test_compute_metric(): assert ls.time_range.start_timestamp == tstart assert ls.time_range.end_timestamp == tend assert ls.generator == generator + + +def test_no_truth_divide_by_zero(): + manager = SimpleManager() + generator = SIAPMetrics() + # Create truth, tracks and associations, same as test_nu_j + tstart = datetime.datetime.now() + track1 = Track( + states=[State([[1]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(3)]) + track2 = Track( + states=[State([[2]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(5, 10)]) + track3 = Track( + states=[State([[3]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(7, 15)]) + track4 = Track( + states=[State([[4]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(13, 20)]) + track5 = Track( + states=[State([[5]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(18, 28)]) + track6 = Track( + states=[State([[6]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(22, 26)]) + track7 = Track( + states=[State([[7]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(30, 40)]) + track8 = Track( + states=[State([[8]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(30, 35)]) + track9 = Track( + states=[State([[9]], timestamp=tstart + datetime.timedelta(seconds=i)) + for i in range(35, 40)]) + manager.tracks = {track1, track2, track3, track4, track5, track6, track7, + track8, track9} + manager.groundtruth_paths = set() + associations = {TimeRangeAssociation({track}, time_range=TimeRange( + start_timestamp=min([state.timestamp for state in track.states]), + end_timestamp=max([state.timestamp for state in track.states]))) + for track in manager.tracks} + manager.association_set = AssociationSet(associations) + + with pytest.warns(UserWarning) as warning: + metrics = generator.compute_metric(manager) + + assert warning[0].message.args[0] == "No truth to generate SIAP Metric" + + assert len(metrics) == 5 + + +def test_no_track_divide_by_zero(): + manager = SimpleManager() + generator = SIAPMetrics() + # Create truth, tracks and associations, same as test_nu_j + tstart = datetime.datetime.now() + truth = GroundTruthPath(states=[ + GroundTruthState([[1]], timestamp=tstart + datetime.timedelta( + seconds=i)) + for i in range(40)]) + manager.tracks = set() + manager.groundtruth_paths = {truth} + associations = {TimeRangeAssociation({truth}, time_range=TimeRange( + start_timestamp=min([state.timestamp for state in track.states]), + end_timestamp=max([state.timestamp for state in track.states]))) + for track in manager.tracks} + manager.association_set = AssociationSet(associations) + + with pytest.warns(UserWarning) as warning: + metrics = generator.compute_metric(manager) + + assert warning[0].message.args[0] == "No tracks to generate SIAP Metric" + + assert len(metrics) == 5
self.metric_manager.generate_metrics() : ZeroDivisionError: division by zero Probably my data, however FYI. ``` File "lib\_mot\mot.py", line 302, in run self.metrics_generate() File "lib\_mot\mot.py", line 253, in metrics_generate self.metrics = self.metric_manager.generate_metrics() File "C:\g\testapp\lib\lib\site-packages\stonesoup\metricgenerator\manager.py", line 87, in generate_metrics metric = generator.compute_metric(self) File "C:\g\testapp\lib\lib\site-packages\stonesoup\metricgenerator\tracktotruthmetrics.py", line 45, in compute_metric self.A_time_range(manager), File "C:\g\testapp\lib\lib\site-packages\stonesoup\metricgenerator\tracktotruthmetrics.py", line 169, in A_time_range manager, timestamps) ZeroDivisionError: division by zero ```
0.0
[ "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_no_truth_divide_by_zero", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_no_track_divide_by_zero" ]
[ "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_j_t", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_j_sum", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_jt", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test__na", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_n", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_tt_j", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_nu_j", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_t_j", "stonesoup/metricgenerator/tests/test_tracktotruthmetrics.py::test_compute_metric" ]
2020-05-06 10:02:57+00:00
2,010
duartegroup__autodE-105
diff --git a/autode/calculation.py b/autode/calculation.py index b1a7931..a0accc4 100644 --- a/autode/calculation.py +++ b/autode/calculation.py @@ -3,6 +3,7 @@ import os import hashlib import base64 from typing import Optional, List +from functools import wraps import autode.wrappers.keywords as kws import autode.exceptions as ex from autode.utils import cached_property @@ -23,6 +24,22 @@ def execute_calc(calc): return calc.execute_calculation() +def _requires_set_output_filename(func): + """Calculation method requiring the output filename to be set""" + + @wraps(func) + def wrapped_function(*args, **kwargs): + calc = args[0] + + if calc.output.filename is None: + raise ex.CouldNotGetProperty( + f'Could not get property from {calc.name}. ' + f'Has .run() been called?') + return func(*args, **kwargs) + + return wrapped_function + + class Calculation: def __init__(self, @@ -238,28 +255,29 @@ class Calculation: methods.add(f'{string}.\n') return None - def get_energy(self) -> Optional[PotentialEnergy]: + @_requires_set_output_filename + def get_energy(self) -> PotentialEnergy: """ - Total electronic potential energy + Total electronic potential energy from the final structure in the + calculation + ----------------------------------------------------------------------- Returns: (autode.values.PotentialEnergy | None): + + Raises: + (autode.exceptions.CouldNotGetProperty): """ logger.info(f'Getting energy from {self.output.filename}') if not self.terminated_normally: - logger.error('Calculation did not terminate normally. ' - 'Energy = None') - return None + logger.error(f'Calculation of {self.molecule} did not terminate ' + f'normally') + raise ex.CouldNotGetProperty(name='energy') - try: - return PotentialEnergy(self.method.get_energy(self), - method=self.method, - keywords=self.input.keywords) - - except ex.CouldNotGetProperty: - logger.warning('Could not get energy. Energy = None') - return None + return PotentialEnergy(self.method.get_energy(self), + method=self.method, + keywords=self.input.keywords) def optimisation_converged(self) -> bool: """ @@ -289,6 +307,7 @@ class Calculation: return self.method.optimisation_nearly_converged(self) + @_requires_set_output_filename def get_final_atoms(self) -> Atoms: """ Get the atoms from the final step of a geometry optimisation @@ -317,6 +336,7 @@ class Calculation: return atoms + @_requires_set_output_filename def get_atomic_charges(self) -> List[float]: """ Get the partial atomic charges from a calculation. The method used to @@ -338,6 +358,7 @@ class Calculation: return charges + @_requires_set_output_filename def get_gradients(self) -> Gradient: """ Get the gradient (dE/dr) with respect to atomic displacement from a @@ -357,6 +378,7 @@ class Calculation: return gradients + @_requires_set_output_filename def get_hessian(self) -> Hessian: """ Get the Hessian matrix (d^2E/dr^2) i.e. the matrix of second @@ -628,3 +650,7 @@ class CalculationInput: return self.additional_filenames return [self.filename] + self.additional_filenames + + + + diff --git a/autode/species/species.py b/autode/species/species.py index b8aa2bb..63d009c 100644 --- a/autode/species/species.py +++ b/autode/species/species.py @@ -1014,9 +1014,16 @@ class Species(AtomCollection): if calc is not None and calc.output.exists: self.atoms = calc.get_final_atoms() - self.energy = calc.get_energy() self.hessian = calc.get_hessian() + try: + self.energy = calc.get_energy() + + except CalculationException: + logger.warning(f'Failed to get the potential energy from ' + f'{calc.name} but not essential for thermo' + f'chemical calculation') + elif self.hessian is None or (calc is not None and not calc.output.exists): logger.info('Calculation did not exist or Hessian was None - ' 'calculating the Hessian') @@ -1074,13 +1081,7 @@ class Species(AtomCollection): keywords=keywords, n_cores=Config.n_cores if n_cores is None else n_cores) sp.run() - energy = sp.get_energy() - - if energy is None: - raise CalculationException("Failed to calculate a single point " - f"energy for {self}") - - self.energy = energy + self.energy = sp.get_energy() return None @work_in('conformers') diff --git a/autode/transition_states/base.py b/autode/transition_states/base.py index 51b943c..4956b08 100644 --- a/autode/transition_states/base.py +++ b/autode/transition_states/base.py @@ -295,7 +295,7 @@ class TSbase(Species, ABC): keywords=method.keywords.low_opt, reset_graph=True) - except ex.AtomsNotFound: + except ex.CalculationException: logger.error(f'Failed to optimise {mol.name} with ' f'{method}. Assuming no link') return False diff --git a/doc/changelog.rst b/doc/changelog.rst index 23ca780..a577f35 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -28,6 +28,8 @@ Usability improvements/Changes - Removes :code:`autode.KcalMol` and :code:`KjMol` and enables a reaction to be plotted using a string representation of the units. - Allows for keywords to be set using just a list or a string, rather than requiring a specific type - Changes :code:`autode.wrappers.keywords.Keyword.has_only_name` to a property +- Modifies :code:`autode.calculation.Calculation.get_energy` to raise an exception if the energy cannot be extracted +- Adds a runtime error if e.g. :code:`autode.calculation.Calculation.get_energy` is called on a calculation that has not been run Functionality improvements
duartegroup/autodE
421ceaad5d424055d4dbf5986ee213e505e0a615
diff --git a/tests/test_calculation.py b/tests/test_calculation.py index d115145..4bec1e7 100644 --- a/tests/test_calculation.py +++ b/tests/test_calculation.py @@ -28,12 +28,13 @@ def test_calc_class(): assert calc.method.name == 'xtb' assert len(calc.input.filenames) == 0 - assert calc.get_energy() is None + with pytest.raises(ex.CouldNotGetProperty): + _ = calc.get_energy() assert not calc.optimisation_converged() assert not calc.optimisation_nearly_converged() - with pytest.raises(ex.AtomsNotFound): + with pytest.raises(ex.CouldNotGetProperty): _ = calc.get_final_atoms() with pytest.raises(ex.CouldNotGetProperty): diff --git a/tests/test_gaussian_calc.py b/tests/test_gaussian_calc.py index 34729e1..bf64cea 100644 --- a/tests/test_gaussian_calc.py +++ b/tests/test_gaussian_calc.py @@ -10,8 +10,7 @@ from autode.wrappers import keywords as kwds from autode.wrappers.basis_sets import def2tzecp, def2tzvp from autode.wrappers.functionals import pbe0 from autode.wrappers.keywords import OptKeywords, SinglePointKeywords -from autode.exceptions import AtomsNotFound -from autode.exceptions import NoInputError +from autode.exceptions import AtomsNotFound, NoInputError, CalculationException from autode.point_charges import PointCharge from autode.atoms import Atom from . import testutils @@ -185,8 +184,10 @@ def test_bad_gauss_output(): calc.output_file_lines = [] calc.rev_output_file_lines = [] - assert calc.get_energy() is None - with pytest.raises(AtomsNotFound): + with pytest.raises(CalculationException): + _ = calc.get_energy() + + with pytest.raises(CalculationException): calc.get_final_atoms() with pytest.raises(NoInputError): diff --git a/tests/test_mopac_calc.py b/tests/test_mopac_calc.py index effa78c..0d97689 100644 --- a/tests/test_mopac_calc.py +++ b/tests/test_mopac_calc.py @@ -129,7 +129,10 @@ def test_bad_geometry(): calc.output.filename = 'h2_overlap_opt_mopac.out' assert not calc.terminated_normally - assert calc.get_energy() is None + + with pytest.raises(CouldNotGetProperty): + _ = calc.get_energy() + assert not calc.optimisation_converged() diff --git a/tests/test_orca_calc.py b/tests/test_orca_calc.py index f698071..4b0e162 100644 --- a/tests/test_orca_calc.py +++ b/tests/test_orca_calc.py @@ -9,6 +9,7 @@ from autode.species.molecule import Molecule from autode.input_output import xyz_file_to_atoms from autode.wrappers.keywords import SinglePointKeywords, OptKeywords from autode.wrappers.keywords import Functional, WFMethod, BasisSet +from autode.exceptions import CouldNotGetProperty from autode.solvent.solvents import ImplicitSolvent from autode.transition_states.transition_state import TransitionState from autode.transition_states.ts_guess import TSguess @@ -137,9 +138,11 @@ def test_bad_orca_output(): calc = Calculation(name='no_output', molecule=test_mol, method=method, keywords=opt_keywords) - assert calc.get_energy() is None - with pytest.raises(ex.AtomsNotFound): - calc.get_final_atoms() + with pytest.raises(CouldNotGetProperty): + _ = calc.get_energy() + + with pytest.raises(ex.CouldNotGetProperty): + _ = calc.get_final_atoms() with pytest.raises(ex.NoInputError): calc.execute_calculation() diff --git a/tests/test_xtb_calc.py b/tests/test_xtb_calc.py index 2974ac8..8e814fa 100644 --- a/tests/test_xtb_calc.py +++ b/tests/test_xtb_calc.py @@ -6,7 +6,7 @@ from autode.wrappers.XTB import XTB from autode.calculation import Calculation from autode.species.molecule import Molecule from autode.point_charges import PointCharge -from autode.exceptions import AtomsNotFound +from autode.exceptions import AtomsNotFound, CalculationException from autode.config import Config from . import testutils @@ -75,7 +75,9 @@ def test_energy_extract_no_energy(): calc.output.filename = 'h2_sp_xtb_no_energy.out' assert calc.terminated_normally - assert calc.get_energy() is None + + with pytest.raises(CalculationException): + _ = calc.get_energy() @testutils.work_in_zipped_dir(os.path.join(here, 'data', 'xtb.zip'))
Inconsistent Calculation behaviour **Possible API Improvement** Currently with a [Calculation](https://github.com/duartegroup/autodE/blob/6505d5bbbd1906f57e4102e13f177510f166bbed/autode/calculation.py#L61) `calc.get_energy()` returns None if a calculation failed but raises a `CalculationError` for e.g. `calc.get_gradients()`; this is not particularly consistent or user friendly. Having talked it over with @tristan-j-wood having properties (e.g. `calc.energy`) that are set after `calc.run()`, and may be None (after throwing a logging error), would be easier and more consistent with the rest of the API. Also having access to the calc.molecule properties directly e.g. ```python class Molecule: def __init__(self, x): self.x = x class Calculation: def __getattr__(self, item): if item in self.molecule.__dict__: return self.molecule.__dict__[item] return self.__dict__[item] def __init__(self, molecule): self.molecule = molecule if __name__ == '__main__': calc = Calculation(molecule=Molecule(x=1)) print(calc.x) # -> 1 calc.x = 2 print(calc.x) # -> 2 ``` would be more readable. Also should throw more useful exceptions if calculations are initialised but not run before getting a property.
0.0
[ "tests/test_calculation.py::test_calc_class", "tests/test_gaussian_calc.py::test_bad_gauss_output", "tests/test_mopac_calc.py::test_bad_geometry", "tests/test_orca_calc.py::test_bad_orca_output", "tests/test_xtb_calc.py::test_energy_extract_no_energy" ]
[ "tests/test_calculation.py::test_calc_copy", "tests/test_calculation.py::test_clear_output", "tests/test_calculation.py::test_distance_const_check", "tests/test_calculation.py::test_calc_string", "tests/test_calculation.py::test_fix_unique", "tests/test_calculation.py::test_solvent_get", "tests/test_calculation.py::test_input_gen", "tests/test_calculation.py::test_exec_not_avail_method", "tests/test_gaussian_calc.py::test_printing_ecp", "tests/test_gaussian_calc.py::test_add_opt_option", "tests/test_gaussian_calc.py::test_input_print_max_opt", "tests/test_gaussian_calc.py::test_get_gradients", "tests/test_gaussian_calc.py::test_gauss_opt_calc", "tests/test_gaussian_calc.py::test_gauss_optts_calc", "tests/test_gaussian_calc.py::test_fix_angle_error", "tests/test_gaussian_calc.py::test_constraints", "tests/test_gaussian_calc.py::test_single_atom_opt", "tests/test_gaussian_calc.py::test_point_charge_calc", "tests/test_gaussian_calc.py::test_external_basis_set_file", "tests/test_gaussian_calc.py::test_xtb_optts", "tests/test_mopac_calc.py::test_mopac_opt_calculation", "tests/test_mopac_calc.py::test_mopac_with_pc", "tests/test_mopac_calc.py::test_other_spin_states", "tests/test_mopac_calc.py::test_constrained_opt", "tests/test_mopac_calc.py::test_grad", "tests/test_mopac_calc.py::test_termination_short", "tests/test_mopac_calc.py::test_mopac_keywords", "tests/test_mopac_calc.py::test_get_version_no_output", "tests/test_mopac_calc.py::test_mopac_solvent_no_dielectric", "tests/test_orca_calc.py::test_orca_opt_calculation", "tests/test_orca_calc.py::test_calc_bad_mol", "tests/test_orca_calc.py::test_orca_optts_calculation", "tests/test_orca_calc.py::test_solvation", "tests/test_orca_calc.py::test_gradients", "tests/test_orca_calc.py::test_mp2_numerical_gradients", "tests/test_orca_calc.py::test_keyword_setting", "tests/test_orca_calc.py::test_hessian_extraction", "tests/test_orca_calc.py::test_other_input_block", "tests/test_xtb_calc.py::test_xtb_calculation", "tests/test_xtb_calc.py::test_point_charge", "tests/test_xtb_calc.py::test_gradients", "tests/test_xtb_calc.py::test_xtb_6_3_2", "tests/test_xtb_calc.py::test_xtb_6_1_old" ]
2022-01-19 09:22:10+00:00
2,011
duartegroup__autodE-140
diff --git a/autode/__init__.py b/autode/__init__.py index cb84893..e18739b 100644 --- a/autode/__init__.py +++ b/autode/__init__.py @@ -33,7 +33,7 @@ So, you want to bump the version.. make sure the following steps are followed - Merge when tests pass """ -__version__ = '1.2.2' +__version__ = '1.2.3' __all__ = [ diff --git a/autode/reactions/reaction.py b/autode/reactions/reaction.py index 9cc605f..63a0d99 100644 --- a/autode/reactions/reaction.py +++ b/autode/reactions/reaction.py @@ -75,6 +75,7 @@ class Reaction: self._check_solvent() self._check_balance() + self._check_names() def __str__(self): """Return a very short 6 character hash of the reaction, not guaranteed @@ -147,7 +148,7 @@ class Reaction: enthalpy=enthalpy) return None - def _check_balance(self): + def _check_balance(self) -> None: """Check that the number of atoms and charge balances between reactants and products. If they don't then raise excpetions """ @@ -170,7 +171,7 @@ class Reaction: self.charge = total(self.reacs, 'charge') return None - def _check_solvent(self): + def _check_solvent(self) -> None: """ Check that all the solvents are the same for reactants and products. If self.solvent is set then override the reactants and products @@ -207,7 +208,28 @@ class Reaction: f'{self.solvent.name}') return None - def _init_from_smiles(self, reaction_smiles): + def _check_names(self) -> None: + """ + Ensure there is no clashing names of reactants and products, which will + cause problems when conformers are generated and output is printed + """ + all_names = [mol.name for mol in self.reacs + self.prods] + + if len(set(all_names)) == len(all_names): # Everything is unique + return + + logger.warning('Names in reactants and products are not unique. ' + 'Adding prefixes') + + for i, reac in enumerate(self.reacs): + reac.name = f'r{i}_{reac.name}' + + for i, prod in enumerate(self.prods): + prod.name = f'p{i}_{prod.name}' + + return None + + def _init_from_smiles(self, reaction_smiles) -> None: """ Initialise from a SMILES string of the whole reaction e.g.:: @@ -237,7 +259,7 @@ class Reaction: return None - def _init_from_molecules(self, molecules): + def _init_from_molecules(self, molecules) -> None: """Set the reactants and products from a set of molecules""" self.reacs = [mol for mol in molecules @@ -248,7 +270,7 @@ class Reaction: return None - def _reasonable_components_with_energy(self): + def _reasonable_components_with_energy(self) -> None: """Generator for components of a reaction that have sensible geometries and also energies""" diff --git a/doc/changelog.rst b/doc/changelog.rst index ec75310..3449692 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -2,6 +2,18 @@ Changelog ========= +1.2.3 +-------- +---------- + +Bugfix release. + + +Bug Fixes +********* +- Fixes clashing names for a reaction initialised explicitly from molecules without defined names + + 1.2.2 -------- ---------- diff --git a/setup.py b/setup.py index 9c0e649..70729e8 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ extensions = [Extension('cconf_gen', ['autode/conformers/cconf_gen.pyx']), extra_link_args=["-std=c++11"])] setup(name='autode', - version='1.2.2', + version='1.2.3', packages=['autode', 'autode.conformers', 'autode.pes', @@ -44,5 +44,4 @@ setup(name='autode', url='https://github.com/duartegroup/autodE', license='MIT', author='Tom Young', - author_email='[email protected]', - description='Automated Reaction Profile Generation') + description='Automated reaction profile generation')
duartegroup/autodE
239d9fb8f18e9c2ad988757c4ebd0ea982d0e36f
diff --git a/tests/test_reaction_class.py b/tests/test_reaction_class.py index 2d2c023..5c10f57 100644 --- a/tests/test_reaction_class.py +++ b/tests/test_reaction_class.py @@ -464,3 +464,11 @@ def test_same_composition(): r3 = reaction.Reaction(Reactant(name='h2', atoms=[Atom('H', 1.0, 0.0, 0.0)]), Product(name='h2', atoms=[Atom('H', 1.0, 0.0, 0.0)])) assert not r1.has_identical_composition_as(r3) + + +def test_name_uniqueness(): + + rxn = reaction.Reaction(Reactant(smiles='CC[C]([H])[H]'), + Product(smiles='C[C]([H])C')) + + assert rxn.reacs[0].name != rxn.prods[0].name
Sum formulas as filenames lead to overwritten structures in isomerizations **Describe the bug** Hi there. In the output folder, file names are given as sum formulas. This creates issues as soon as we look into isomerizations. In the csv file there is no way of telling which of the identically labelled line is what. But much more problematic: both in "reactants_and_products" and in "output" only one set of calculations/one structure will get saved. A quick hotfix would be to check initally if several molecules of the same sum formula exist and add a "b" or a "_1" or something to all filenames. **To Reproduce** This will happen also in the example that is given in the Github manual. ``` import autode as ade ade.Config.n_cores = 8 r = ade.Reactant(name='reactant', smiles='CC[C]([H])[H]') p = ade.Product(name='product', smiles='C[C]([H])C') reaction = ade.Reaction(r, p, name='1-2_shift') reaction.calculate_reaction_profile() # creates 1-2_shift/ and saves profile ``` Expected behavior Saving all calculations and structures, ideally in a distinguishable fashion. Environment Operating System: CentOS-7 Python version: 3.9.10 autodE version: 1.2.1
0.0
[ "tests/test_reaction_class.py::test_name_uniqueness" ]
[ "tests/test_reaction_class.py::test_reaction_class", "tests/test_reaction_class.py::test_reactant_product_complexes", "tests/test_reaction_class.py::test_invalid_with_complexes", "tests/test_reaction_class.py::test_check_rearrangement", "tests/test_reaction_class.py::test_check_solvent", "tests/test_reaction_class.py::test_reaction_identical_reac_prods", "tests/test_reaction_class.py::test_swap_reacs_prods", "tests/test_reaction_class.py::test_bad_balance", "tests/test_reaction_class.py::test_calc_delta_e", "tests/test_reaction_class.py::test_from_smiles", "tests/test_reaction_class.py::test_single_points", "tests/test_reaction_class.py::test_free_energy_profile", "tests/test_reaction_class.py::test_barrierless_rearrangment", "tests/test_reaction_class.py::test_doc_example", "tests/test_reaction_class.py::test_barrierless_h_g", "tests/test_reaction_class.py::test_same_composition" ]
2022-05-18 14:39:11+00:00
2,012
duartegroup__autodE-185
diff --git a/autode/transition_states/ts_guess.py b/autode/transition_states/ts_guess.py index 97df5f5..3516d20 100644 --- a/autode/transition_states/ts_guess.py +++ b/autode/transition_states/ts_guess.py @@ -136,10 +136,13 @@ class TSguess(TSbase): (autode.transition_states.ts_guess.TSguess): TS guess """ - ts_guess = cls(atoms=species.atoms, - charge=species.charge, - mult=species.mult, - name=f'ts_guess_{species.name}') + ts_guess = cls( + atoms=species.atoms, + charge=species.charge, + mult=species.mult, + name=f'ts_guess_{species.name}', + solvent_name=None if species.solvent is None else species.solvent.name + ) return ts_guess
duartegroup/autodE
88a5fc08246de5c8034fedfb9d8a9376a2c8cea2
diff --git a/tests/test_ts/test_ts_guess.py b/tests/test_ts/test_ts_guess.py new file mode 100644 index 0000000..9f90d45 --- /dev/null +++ b/tests/test_ts/test_ts_guess.py @@ -0,0 +1,12 @@ +from autode.atoms import Atom +from autode.species.molecule import Molecule +from autode.transition_states.ts_guess import TSguess + + +def test_that_a_molecules_solvent_is_inherited(): + + mol = Molecule(atoms=[Atom("H")], mult=2, solvent_name="water") + assert mol.solvent.smiles == "O" + + ts_guess = TSguess.from_species(mol) + assert ts_guess.solvent.smiles == "O"
TSguess.from_species does not inherit solvent
0.0
[ "tests/test_ts/test_ts_guess.py::test_that_a_molecules_solvent_is_inherited" ]
[]
2022-10-17 17:44:05+00:00
2,013
duartegroup__autodE-213
diff --git a/autode/__init__.py b/autode/__init__.py index eff4ba3..0a1dd63 100644 --- a/autode/__init__.py +++ b/autode/__init__.py @@ -38,7 +38,7 @@ Bumping the version number requires following the release proceedure: - Merge when tests pass """ -__version__ = "1.3.3" +__version__ = "1.3.4" __all__ = [ diff --git a/autode/transition_states/templates.py b/autode/transition_states/templates.py index 3bea0e8..5bb77e1 100644 --- a/autode/transition_states/templates.py +++ b/autode/transition_states/templates.py @@ -38,6 +38,11 @@ def get_ts_template_folder_path(folder_path): logger.info("Folder path is not set – TS templates in the default path") + if Config.ts_template_folder_path == "": + raise ValueError( + "Cannot set ts_template_folder_path to an empty string" + ) + if Config.ts_template_folder_path is not None: logger.info("Configuration ts_template_folder_path is set") return Config.ts_template_folder_path diff --git a/doc/changelog.rst b/doc/changelog.rst index 8376c45..3097412 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -1,6 +1,26 @@ Changelog ========= +1.3.4 +-------- +---------- + +Feature additions. + +Usability improvements/Changes +****************************** +* Throw useful exception for invalid :code:`ade.Config.ts_template_folder_path` + + +Functionality improvements +************************** +- + +Bug Fixes +********* +- + + 1.3.3 -------- ---------- diff --git a/setup.py b/setup.py index b8206c6..ddfe8d1 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ extensions = [ setup( name="autode", - version="1.3.3", + version="1.3.4", python_requires=">3.7", packages=[ "autode",
duartegroup/autodE
e2b90c0750b2913f2a0df4d274ce58f232894bac
diff --git a/tests/test_config.py b/tests/test_config.py index a0791d2..338a22a 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -5,6 +5,7 @@ from autode.config import Config from autode.values import Allocation, Distance from autode.wrappers.keywords import KeywordsSet from autode.wrappers.keywords import Keywords +from autode.transition_states.templates import get_ts_template_folder_path def test_config(): @@ -76,3 +77,13 @@ def test_step_size_setter(): # Setting in Bohr should convert to angstroms _config.max_step_size = Distance(0.2, units="a0") assert np.isclose(_config.max_step_size.to("ang"), 0.1, atol=0.02) + + +def test_invalid_get_ts_template_folder_path(): + + Config.ts_template_folder_path = "" + + with pytest.raises(ValueError): + _ = get_ts_template_folder_path(None) + + Config.ts_template_folder_path = None
Throw useful exception if `ade.Config.ts_template_folder_path = ""`
0.0
[ "tests/test_config.py::test_invalid_get_ts_template_folder_path" ]
[ "tests/test_config.py::test_config", "tests/test_config.py::test_maxcore_setter", "tests/test_config.py::test_invalid_freq_scale_factor[-0.1]", "tests/test_config.py::test_invalid_freq_scale_factor[1.1]", "tests/test_config.py::test_invalid_freq_scale_factor[a", "tests/test_config.py::test_unknown_attr", "tests/test_config.py::test_step_size_setter" ]
2022-12-10 19:44:06+00:00
2,014
duartegroup__autodE-214
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5ca80c4..5ed79b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,4 +4,3 @@ repos: hooks: - id: black language_version: python3.9 - diff --git a/autode/__init__.py b/autode/__init__.py index 0a1dd63..5789c25 100644 --- a/autode/__init__.py +++ b/autode/__init__.py @@ -7,6 +7,7 @@ from autode import mol_graphs from autode import hessians from autode.reactions.reaction import Reaction from autode.reactions.multistep import MultiStepReaction +from autode.transition_states.transition_state import TransitionState from autode.atoms import Atom from autode.species.molecule import Reactant, Product, Molecule, Species from autode.species.complex import NCIComplex @@ -55,6 +56,7 @@ __all__ = [ "Reactant", "Product", "Molecule", + "TransitionState", "NCIComplex", "Config", "Calculation", diff --git a/autode/transition_states/base.py b/autode/transition_states/base.py index 6ce9b99..7011a6d 100644 --- a/autode/transition_states/base.py +++ b/autode/transition_states/base.py @@ -4,6 +4,7 @@ from typing import Optional import autode.exceptions as ex from autode.atoms import metals from autode.config import Config +from autode.geom import calc_rmsd from autode.constraints import DistanceConstraints from autode.log import logger from autode.methods import get_hmethod, get_lmethod @@ -74,8 +75,11 @@ class TSbase(Species, ABC): def __eq__(self, other): """Equality of this TS base to another""" - logger.warning("TSs types are not equal to any others") - return False + return ( + isinstance(other, TSbase) + and calc_rmsd(self.coordinates, other.coordinates) < 1e-6, + super().__eq__(other), + ) def _init_graph(self) -> None: """Set the molecular graph for this TS object from the reactant""" diff --git a/autode/transition_states/transition_state.py b/autode/transition_states/transition_state.py index 80a17fc..e42d844 100644 --- a/autode/transition_states/transition_state.py +++ b/autode/transition_states/transition_state.py @@ -3,6 +3,7 @@ from multiprocessing import Pool from autode.values import Frequency from autode.transition_states.base import displaced_species_along_mode from autode.transition_states.base import TSbase +from autode.transition_states.ts_guess import TSguess from autode.transition_states.templates import TStemplate from autode.input_output import atoms_to_xyz_file from autode.calculations import Calculation @@ -358,3 +359,20 @@ class TransitionState(TSbase): logger.info("Saved TS template") return None + + @classmethod + def from_species( + cls, species: "autode.species.Species" + ) -> "TransitionState": + """ + Generate a TS from a species. Note this does not set the bond rearrangement + thus mode checking will not work from this species. + + ----------------------------------------------------------------------- + Arguments: + species: + + Returns: + (autode.transition_states.transition_state.TransitionState): TS + """ + return cls(ts_guess=TSguess.from_species(species), bond_rearr=None) diff --git a/doc/changelog.rst b/doc/changelog.rst index 3097412..a56aa8f 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -14,7 +14,8 @@ Usability improvements/Changes Functionality improvements ************************** -- +- Adds :code:`ade.transition_states.TransitionState.from_species` method to construct transition states from a species or molecule + Bug Fixes *********
duartegroup/autodE
af3daeed187203b7f037d2c818d39d65b1c513a1
diff --git a/tests/test_ts/test_ts_template.py b/tests/test_ts/test_ts_template.py index ede99ad..f0443c6 100644 --- a/tests/test_ts/test_ts_template.py +++ b/tests/test_ts/test_ts_template.py @@ -5,6 +5,7 @@ from .. import testutils import pytest from autode.exceptions import TemplateLoadingFailed from autode.config import Config +from autode.species.molecule import Molecule from autode.bond_rearrangement import BondRearrangement from autode.species.complex import ReactantComplex, ProductComplex from autode.species.molecule import Reactant, Product @@ -238,3 +239,13 @@ def test_inactive_graph(): template.graph = ch3f.graph.copy() assert not template.graph_has_correct_structure() + + [email protected]_in_zipped_dir(os.path.join(here, "data", "ts_template.zip")) +def test_ts_from_species_is_same_as_from_ts_guess(): + + ts = TransitionState( + TSguess(atoms=xyz_file_to_atoms("vaskas_TS.xyz"), charge=0, mult=1) + ) + + assert TransitionState.from_species(Molecule("vaskas_TS.xyz")) == ts
Implement `ade.TransitionState.from_species()`
0.0
[ "tests/test_ts/test_ts_template.py::test_ts_from_species_is_same_as_from_ts_guess" ]
[ "tests/test_ts/test_ts_template.py::test_ts_template_save", "tests/test_ts/test_ts_template.py::test_ts_template", "tests/test_ts/test_ts_template.py::test_ts_template_with_scan", "tests/test_ts/test_ts_template.py::test_truncated_mol_graph_atom_types", "tests/test_ts/test_ts_template.py::test_ts_template_parse", "tests/test_ts/test_ts_template.py::test_ts_templates_find", "tests/test_ts/test_ts_template.py::test_inactive_graph" ]
2022-12-11 17:29:16+00:00
2,015
duartegroup__autodE-242
diff --git a/autode/values.py b/autode/values.py index dcf4c09..295444d 100644 --- a/autode/values.py +++ b/autode/values.py @@ -62,7 +62,7 @@ def _to(value: Union["Value", "ValueArray"], units: Union[Unit, str]): except StopIteration: raise TypeError( - f"No viable unit conversion from {value.units} " f"-> {units}" + f"No viable unit conversion from {value.units} -> {units}" ) # Convert to the base unit, then to the new units @@ -214,16 +214,22 @@ class Value(ABC, float): float(self) + self._other_same_units(other), units=self.units ) - def __mul__(self, other) -> "Value": + def __mul__(self, other) -> Union[float, "Value"]: """Multiply this value with another""" if isinstance(other, np.ndarray): return other * float(self) + if isinstance(other, Value): + logger.warning( + "Multiplying autode.Value returns a float with no units" + ) + return float(self) * self._other_same_units(other) + return self.__class__( float(self) * self._other_same_units(other), units=self.units ) - def __rmul__(self, other) -> "Value": + def __rmul__(self, other) -> Union[float, "Value"]: return self.__mul__(other) def __radd__(self, other) -> "Value": @@ -232,16 +238,19 @@ class Value(ABC, float): def __sub__(self, other) -> "Value": return self.__add__(-other) - def __floordiv__(self, other): - raise NotImplementedError( - "Integer division is not supported by " "autode.values.Value" - ) + def __floordiv__(self, other) -> Union[float, "Value"]: + x = float(self) // self._other_same_units(other) + if isinstance(other, Value): + return x - def __truediv__(self, other) -> "Value": - return self.__class__( - float(self) / float(self._other_same_units(other)), - units=self.units, - ) + return self.__class__(x, units=self.units) + + def __truediv__(self, other) -> Union[float, "Value"]: + x = float(self) / self._other_same_units(other) + if isinstance(other, Value): + return x + + return self.__class__(x, units=self.units) def __abs__(self) -> "Value": """Absolute value""" diff --git a/doc/changelog.rst b/doc/changelog.rst index ab9c69a..8303c13 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -19,6 +19,8 @@ Functionality improvements Bug Fixes ********* - Fixes :code:`ERROR` logging level being ignored from environment variable :code:`AUTODE_LOG_LEVEL` +- Fixes :code:`autode.values.Value` instances generating items with units on division, and throw a warning if multiplying + 1.3.4 --------
duartegroup/autodE
c37322ca5aafee0297c7aed3238d1dbad996f564
diff --git a/tests/test_value.py b/tests/test_value.py index 924939e..d2d23a0 100644 --- a/tests/test_value.py +++ b/tests/test_value.py @@ -266,3 +266,15 @@ def test_to_wrong_type(): with pytest.raises(Exception): _to(Tmp(), units="Å") + + +def test_div_mul_generate_floats(): + + e = PotentialEnergy(1.0) + assert isinstance(e / e, float) + assert isinstance(e // e, float) + + assert e // e == 1 + + # Note: this behaviour is not ideal. But it is better than having the wrong units + assert isinstance(e * e, float)
Division and multiplication of `autode.values.Value` creates wrong units **Describe the bug** <!-- A clear and concise description of what the bug is. --> Multiplication and division do not generate autode.values with the correct units. As a simple fix multiplication could return a float, given it's (potentially) an uncommon occurrence. **To Reproduce** <!-- Steps to reproduce the behaviour: code with output --> ```python >>> import autode as ade >>> e = ade.values.PotentialEnergy(1) >>> e Energy(1.0 Ha) >>> e * e Energy(1.0 Ha) >>> e / e Energy(1.0 Ha) >>> # Addition and subtraction are okay >>> e + e Energy(2.0 Ha) >>> e - e Energy(0.0 Ha) ``` **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> Division results in no units and multiplication Ha^2 **Environment** <!-- please complete the following information. --> - autodE version: 1.3.4
0.0
[ "tests/test_value.py::test_div_mul_generate_floats" ]
[ "tests/test_value.py::test_base_value", "tests/test_value.py::test_base_value_numpy_add", "tests/test_value.py::test_energy", "tests/test_value.py::test_energy_equality", "tests/test_value.py::test_enthalpy", "tests/test_value.py::test_free_energy", "tests/test_value.py::test_distance", "tests/test_value.py::test_angle", "tests/test_value.py::test_energies", "tests/test_value.py::test_freqs", "tests/test_value.py::test_mass", "tests/test_value.py::test_contrib_guidelines", "tests/test_value.py::test_gradient_norm", "tests/test_value.py::test_to_wrong_type" ]
2023-01-29 15:26:48+00:00
2,016
duartegroup__autodE-243
diff --git a/autode/hessians.py b/autode/hessians.py index b3f6149..4b8cc76 100644 --- a/autode/hessians.py +++ b/autode/hessians.py @@ -234,9 +234,9 @@ class Hessian(ValueArray): axis=np.newaxis, ) - return Hessian( - H / np.sqrt(np.outer(mass_array, mass_array)), units="J m^-2 kg^-1" - ) + return np.array( + H / np.sqrt(np.outer(mass_array, mass_array)) + ) # J Å^-2 kg^-1 @cached_property def _proj_mass_weighted(self) -> np.ndarray: diff --git a/autode/units.py b/autode/units.py index 8f18818..4b30a1d 100644 --- a/autode/units.py +++ b/autode/units.py @@ -211,15 +211,15 @@ kg_m_sq = CompositeUnit(kg, m, m, name="kg m^2") ha_per_ang = CompositeUnit( - ha, per=[ang], aliases=["ha Å-1", "ha Å^-1", "ha/ang"] + ha, per=[ang], aliases=["ha / Å", "ha Å-1", "ha Å^-1", "ha/ang"] ) ha_per_a0 = CompositeUnit( - ha, per=[a0], aliases=["ha a0-1", "ha a0^-1", "ha/bohr"] + ha, per=[a0], aliases=["ha / a0", "ha a0-1", "ha a0^-1", "ha/bohr"] ) ev_per_ang = CompositeUnit( - ev, per=[ang], aliases=["ha a0-1", "ev Å^-1", "ev/ang"] + ev, per=[ang], aliases=["ev / Å", "ev Å^-1", "ev/ang"] ) kcalmol_per_ang = CompositeUnit( diff --git a/autode/values.py b/autode/values.py index 295444d..77fc41c 100644 --- a/autode/values.py +++ b/autode/values.py @@ -37,9 +37,12 @@ from autode.units import ( ) -def _to(value: Union["Value", "ValueArray"], units: Union[Unit, str]): +def _to( + value: Union["Value", "ValueArray"], units: Union[Unit, str], inplace: bool +) -> Any: """ - Convert a value or value array to a new unit and return a copy + Convert a value or value array to a new unit and return a copy if + inplace=False --------------------------------------------------------------------------- Arguments: @@ -65,23 +68,26 @@ def _to(value: Union["Value", "ValueArray"], units: Union[Unit, str]): f"No viable unit conversion from {value.units} -> {units}" ) - # Convert to the base unit, then to the new units - c = float(units.conversion / value.units.conversion) - - if isinstance(value, Value): - return value.__class__(float(value) * c, units=units) - - elif isinstance(value, ValueArray): - value[:] = np.array(value, copy=True) * c - value.units = units - return value - - else: + if not (isinstance(value, Value) or isinstance(value, ValueArray)): raise ValueError( f"Cannot convert {value} to new units. Must be one of" f" Value of ValueArray" ) + if isinstance(value, Value) and inplace: + raise ValueError( + "Cannot modify a value inplace as floats are immutable" + ) + + # Convert to the base unit, then to the new units + c = float(units.conversion / value.units.conversion) + + new_value = value if inplace else value.copy() + new_value *= c + new_value.units = units + + return None if inplace else new_value + def _units_init(value, units: Union[Unit, str, None]): """Initialise the units of this value @@ -171,6 +177,11 @@ class Value(ABC, float): return other.to(self.units) + def _like_self_from_float(self, value: float) -> "Value": + new_value = self.__class__(value, units=self.units) + new_value.__dict__.update(self.__dict__) + return new_value + def __eq__(self, other) -> bool: """Equality of two values, which may be in different units""" @@ -210,8 +221,8 @@ class Value(ABC, float): if isinstance(other, np.ndarray): return other + float(self) - return self.__class__( - float(self) + self._other_same_units(other), units=self.units + return self._like_self_from_float( + float(self) + self._other_same_units(other) ) def __mul__(self, other) -> Union[float, "Value"]: @@ -225,8 +236,8 @@ class Value(ABC, float): ) return float(self) * self._other_same_units(other) - return self.__class__( - float(self) * self._other_same_units(other), units=self.units + return self._like_self_from_float( + float(self) * self._other_same_units(other) ) def __rmul__(self, other) -> Union[float, "Value"]: @@ -240,17 +251,11 @@ class Value(ABC, float): def __floordiv__(self, other) -> Union[float, "Value"]: x = float(self) // self._other_same_units(other) - if isinstance(other, Value): - return x - - return self.__class__(x, units=self.units) + return x if isinstance(other, Value) else self._like_self_from_float(x) def __truediv__(self, other) -> Union[float, "Value"]: x = float(self) / self._other_same_units(other) - if isinstance(other, Value): - return x - - return self.__class__(x, units=self.units) + return x if isinstance(other, Value) else self._like_self_from_float(x) def __abs__(self) -> "Value": """Absolute value""" @@ -269,7 +274,7 @@ class Value(ABC, float): Raises: (TypeError): """ - return _to(self, units) + return _to(self, units, inplace=False) class Energy(Value): @@ -652,7 +657,21 @@ class ValueArray(ABC, np.ndarray): Raises: (TypeError): """ - return _to(self, units) + return _to(self, units, inplace=False) + + def to_(self, units) -> None: + """ + Convert this array into a set of new units, inplace. This will not copy + the array + + ----------------------------------------------------------------------- + Returns: + (None) + + Raises: + (TypeError): + """ + _to(self, units, inplace=True) def __array_finalize__(self, obj): """See https://numpy.org/doc/stable/user/basics.subclassing.html""" diff --git a/doc/changelog.rst b/doc/changelog.rst index d6144a7..23be882 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -8,12 +8,12 @@ Changelog Usability improvements/Changes ****************************** -* +- :code:`autode.value.ValueArray.to()` now defaults to copying the object rather than inplace modification Functionality improvements ************************** -- +- Adds a :code:`to_` method to :code:`autode.value.ValueArray` for explicit inplace modification of the array Bug Fixes @@ -21,6 +21,8 @@ Bug Fixes - Fixes :code:`ERROR` logging level being ignored from environment variable :code:`AUTODE_LOG_LEVEL` - Fixes :code:`autode.values.Value` instances generating items with units on division, and throw a warning if multiplying - Fixes the printing of cartesian constraints in XTB input files, meaning they are no longer ignored +- Fixes :code:`Hessian` instances changing units when normal modes are calculated +- Fixes an incorrect alias for :code:`ev_per_ang` 1.3.4 @@ -32,7 +34,6 @@ Feature additions. Usability improvements/Changes ****************************** * Throw useful exception for invalid :code:`ade.Config.ts_template_folder_path` -* Adds the reaction temperature to the unique reaction hash Functionality improvements @@ -44,7 +45,7 @@ Functionality improvements Bug Fixes ********* -- +- Fixes calculation :code:`clean_up()` failing with a null filename 1.3.3
duartegroup/autodE
4276cabb57a7d8fddace6f95de43217c9a9fda3e
diff --git a/tests/test_hessian.py b/tests/test_hessian.py index c611c22..554a4c2 100644 --- a/tests/test_hessian.py +++ b/tests/test_hessian.py @@ -13,7 +13,7 @@ from autode.calculations import Calculation from autode.species import Molecule from autode.values import Frequency from autode.geom import calc_rmsd -from autode.units import wavenumber +from autode.units import wavenumber, ha_per_ang_sq from autode.exceptions import CalculationException from autode.wrappers.keywords import pbe0 from autode.transition_states.base import displaced_species_along_mode @@ -243,6 +243,7 @@ def assert_correct_co2_frequencies(hessian, expected=(666, 1415, 2517)): """Ensure the projected frequencies of CO2 are roughly right""" nu_1, nu_2, nu_3 = expected + print(hessian.frequencies_proj) assert sum(freq == 0.0 for freq in hessian.frequencies_proj) == 5 # Should have a degenerate bending mode for CO2 with ν = 666 cm-1 @@ -419,6 +420,7 @@ def test_hessian_modes(): h2o = Molecule("H2O_hess_orca.xyz") h2o.hessian = h2o_hessian_arr + assert h2o.hessian.units == ha_per_ang_sq # The structure is a minimum, thus there should be no imaginary frequencies assert h2o.imaginary_frequencies is None @@ -441,6 +443,9 @@ def test_hessian_modes(): vib_mode, h2o.hessian.normal_modes[6 + i], atol=0.1 ) or np.allclose(vib_mode, -h2o.hessian.normal_modes[6 + i], atol=0.1) + # Hessian units should be retained + assert h2o.hessian.units == ha_per_ang_sq + @testutils.work_in_zipped_dir(os.path.join(here, "data", "hessians.zip")) def test_proj_modes(): @@ -595,6 +600,8 @@ def test_nwchem_hessian_co2(): keywords=ade.HessianKeywords(), ) calc.set_output_filename("CO2_hess_nwchem.out") + print(co2.hessian) + print(co2.hessian._mass_weighted) assert_correct_co2_frequencies( hessian=co2.hessian, expected=(659.76, 1406.83, 2495.73) ) diff --git a/tests/test_value.py b/tests/test_value.py index d2d23a0..cf115e9 100644 --- a/tests/test_value.py +++ b/tests/test_value.py @@ -3,6 +3,7 @@ import numpy as np from autode.constants import Constants from autode.units import ha, kjmol, kcalmol, ev, ang, a0, nm, pm, m, rad, deg from autode.values import ( + _to, Value, Distance, MWDistance, @@ -278,3 +279,25 @@ def test_div_mul_generate_floats(): # Note: this behaviour is not ideal. But it is better than having the wrong units assert isinstance(e * e, float) + + +def test_operations_maintain_other_attrs(): + + e = Energy(1, estimated=True, units="eV") + assert e.is_estimated and e.units == ev + + e *= 2 + assert e.is_estimated and e.units == ev + + e /= 2 + assert e.is_estimated and e.units == ev + + a = e * 2 + assert a.is_estimated and e.units == ev + + +def test_inplace_value_modification_raises(): + + e = Energy(1, units="Ha") + with pytest.raises(ValueError): # floats are immutable + _to(e, units="eV", inplace=True) diff --git a/tests/test_values.py b/tests/test_values.py index cac6882..dd80591 100644 --- a/tests/test_values.py +++ b/tests/test_values.py @@ -106,4 +106,22 @@ class InvalidValue(float): def test_to_unsupported(): with pytest.raises(ValueError): - _ = _to(InvalidValue(), Unit()) + _ = _to(InvalidValue(), Unit(), inplace=True) + + +def test_inplace_modification(): + + x = Gradient([[1.0, 1.0, 1.0]], units="Ha / Å") + return_value = x.to_("eV / Å") + assert return_value is None + + assert not np.allclose(x, np.ones(shape=(1, 3))) + + +def test_copy_conversion(): + + x = Gradient([[1.0, 1.0, 1.0]], units="Ha / Å") + y = x.to("eV / Å") + + assert not np.allclose(x, y) + assert np.allclose(x, np.ones(shape=(1, 3)))
Using autodE in Interactive python shell causes unusual change in units Only seen from interactive python shell. ```python >>> import autode as ade >>> mol = ade.Molecule(smiles='CCO') >>> mol.calc_hessian(method=ade.methods.XTB(),n_cores=6) >>> mol.hessian.units Unit(Ha Å^-2) >>> mol.hessian. # pressing tab twice to get all visible attributes mol.hessian.T mol.hessian.min( mol.hessian.all( mol.hessian.n_tr mol.hessian.any( mol.hessian.n_v mol.hessian.argmax( mol.hessian.nbytes mol.hessian.argmin( mol.hessian.ndim ... # wall of text hidden >>> mol.hessian.units # units changed magically from Ha/ang^2 to Joule/ang^2? Unit(J ang^-2) ``` I have looked at the values in the Hessian and the units really do change. (i.e. the numbers change as well) I am not quite sure why this is happening. But it would be problematic if the units changed randomly in the middle of calculations. **Environment** - Operating System: MacOS 12.6 - Python version: Python 3.10 - autodE version: 1.3.4
0.0
[ "tests/test_hessian.py::test_hessian_modes", "tests/test_value.py::test_operations_maintain_other_attrs", "tests/test_value.py::test_inplace_value_modification_raises", "tests/test_values.py::test_to_unsupported", "tests/test_values.py::test_inplace_modification", "tests/test_values.py::test_copy_conversion" ]
[ "tests/test_hessian.py::test_hessian_class", "tests/test_hessian.py::test_hessian_set", "tests/test_hessian.py::test_hessian_freqs", "tests/test_hessian.py::test_hessian_scaled_freqs", "tests/test_hessian.py::test_hessian_scale_factor", "tests/test_hessian.py::test_proj_modes", "tests/test_hessian.py::test_hessian_linear_freqs", "tests/test_hessian.py::test_gaussian_hessian_extract_h2", "tests/test_hessian.py::test_gaussian_hessian_extract_co2", "tests/test_hessian.py::test_nwchem_hessian_extract_h2o", "tests/test_hessian.py::test_nwchem_hessian_co2", "tests/test_hessian.py::test_imag_mode", "tests/test_hessian.py::test_extract_wrong_molecule_hessian", "tests/test_hessian.py::test_num_hess_invalid_input", "tests/test_hessian.py::test_h2_hessian", "tests/test_hessian.py::test_h2_c_diff_hessian", "tests/test_hessian.py::test_h2_xtb_vs_orca_hessian", "tests/test_hessian.py::test_ind_num_hess_row", "tests/test_hessian.py::test_partial_num_hess_init", "tests/test_hessian.py::test_partial_water_num_hess", "tests/test_hessian.py::test_numerical_hessian_in_daemon", "tests/test_hessian.py::test_serial_calculation_matches_parallel", "tests/test_hessian.py::test_hessian_pickle_and_unpickle", "tests/test_value.py::test_base_value", "tests/test_value.py::test_base_value_numpy_add", "tests/test_value.py::test_energy", "tests/test_value.py::test_energy_equality", "tests/test_value.py::test_enthalpy", "tests/test_value.py::test_free_energy", "tests/test_value.py::test_distance", "tests/test_value.py::test_angle", "tests/test_value.py::test_energies", "tests/test_value.py::test_freqs", "tests/test_value.py::test_mass", "tests/test_value.py::test_contrib_guidelines", "tests/test_value.py::test_gradient_norm", "tests/test_value.py::test_to_wrong_type", "tests/test_value.py::test_div_mul_generate_floats", "tests/test_values.py::test_base_arr", "tests/test_values.py::test_unit_retention", "tests/test_values.py::test_coordinate", "tests/test_values.py::test_coordinates", "tests/test_values.py::test_moi", "tests/test_values.py::test_gradients" ]
2023-01-29 15:42:53+00:00
2,017
duartegroup__autodE-44
diff --git a/autode/smiles/angles.py b/autode/smiles/angles.py index ffec3bc..0695230 100644 --- a/autode/smiles/angles.py +++ b/autode/smiles/angles.py @@ -250,9 +250,10 @@ class Dihedral(Angle): graph (nx.Graph): atoms (list(autode.atoms.Atom)): """ - return self._find_rot_idxs_from_pair(graph, atoms, pair=self.mid_idxs) + return self._find_rot_idxs_from_pair(graph, atoms, pair=self.mid_idxs, + max_bond_distance=1.5*self.mid_dist) - def __init__(self, idxs, rot_idxs=None, phi0=None): + def __init__(self, idxs, rot_idxs=None, phi0=None, mid_dist=2.0): """ A dihedral constructed from atom indexes and possibly indexes that should be rotated, if this dihedral is altered:: @@ -272,9 +273,13 @@ class Dihedral(Angle): should be rotated else 0 phi0 (float | None): Ideal angle for this dihedral (radians) + + mid_dist (float): Optimum distance between X-Y """ super().__init__(idxs=idxs, rot_idxs=rot_idxs, phi0=phi0) # Atom indexes of the central two atoms (X, Y) _, idx_x, idx_y, _ = idxs + self.mid_idxs = (idx_x, idx_y) + self.mid_dist = mid_dist diff --git a/autode/smiles/builder.py b/autode/smiles/builder.py index baad827..4aa2593 100644 --- a/autode/smiles/builder.py +++ b/autode/smiles/builder.py @@ -300,6 +300,10 @@ class Builder(AtomCollection): dihedral = Dihedral(dihedral_idxs) + # Optimum distance between the two middle atoms, used for + # determining if a bond exists thus a dihedral can be rotated + dihedral.mid_dist = self.bonds.first_involving(*dihedral.mid_idxs).r0 + # If both atoms either side of this one are 'pi' atoms e.g. in a # benzene ring, then the ideal angle must be 0 to close the ring if all(self.atoms[idx].is_pi for idx in dihedral.mid_idxs): diff --git a/autode/smiles/parser.py b/autode/smiles/parser.py index 7a55d71..4eded90 100644 --- a/autode/smiles/parser.py +++ b/autode/smiles/parser.py @@ -40,9 +40,13 @@ class Parser: """Approximate spin multiplicity (2S+1). For multiple unpaired electrons will default to a singlet""" - n_electrons = (sum([atom.atomic_number for atom in self.atoms]) + n_electrons = (sum([at.atomic_number for at in self.atoms]) - self.charge) + # Atoms have implicit hydrogens, so add them + n_electrons += sum(at.n_hydrogens if at.n_hydrogens is not None else 0 + for at in self.atoms) + return (n_electrons % 2) + 1 @property diff --git a/autode/smiles/smiles.py b/autode/smiles/smiles.py index 63d07c2..895e40b 100644 --- a/autode/smiles/smiles.py +++ b/autode/smiles/smiles.py @@ -70,6 +70,8 @@ def init_organic_smiles(molecule, smiles): except RuntimeError: raise RDKitFailed + logger.info('Using RDKit to initialise') + molecule.charge = Chem.GetFormalCharge(rdkit_mol) molecule.mult = calc_multiplicity(molecule, NumRadicalElectrons(rdkit_mol))
duartegroup/autodE
43c7a39be9728b76db6c8a7463413010950e7339
diff --git a/tests/test_smiles_parser.py b/tests/test_smiles_parser.py index 4abdf09..4b5abf9 100644 --- a/tests/test_smiles_parser.py +++ b/tests/test_smiles_parser.py @@ -400,3 +400,11 @@ def test_ring_connectivity(): # and has two carbon-sulfur bonds assert n_c_s_bonds == 2 + + +def test_multiplicity_metals(): + + parser = Parser() + + parser.parse(smiles='[Na]C1=CC=CC=C1') + assert parser.mult == 1
Wrong Multiplicity **Describe the bug** SMILES parser generates the wrong Multiplicity **To Reproduce** import autode as ade ade.Config.n_cores = 28 ade.Config.hcode = 'g16' ade.Config.G16.keywords.set_opt_basis_set('6-31+G(d)') ade.Config.G16.keywords.sp.basis_set = '6-311+G(d,p)' ade.Config.G16.keywords.set_opt_functional('B3LYP') ade.Config.G16.keywords.set_functional('B3LYP') test = ade.Molecule(name='test',smiles='CCC1=CC=C(C=C1)C[Na]') test.print_xyz_file() **Expected behavior** The expected results are as follows INFO Initialisation with SMILES successful. Charge=0, Multiplicity=1, Num. Atoms=21 **Environment** - OS: Unix - Version: 1.0.3 **Additional context** INFO Generating a Molecule object for test INFO Parsing CCC1=CC=C(C=C1)C[Na] INFO Inverting stereochemistry INFO Parsed SMILES in: 0.42 ms INFO Setting 21 atom types INFO Have 1 ring(s) INFO Queue: [1] INFO Queue: [2] INFO Queue: [7, 3] INFO Queue: [3, 6] INFO Queuing Dihedral(idxs=[1, 2, 3, 4], φ0=3.14) INFO Have 1 dihedral(s) to rotate INFO Resetting sites on atom 4 INFO Rotating 3 sites onto 1 points INFO Resetting sites on atom 6 INFO Rotating 3 sites onto 1 points INFO Queue: [6, 4] INFO Queuing Dihedral(idxs=[5, 6, 7, 2], φ0=0) INFO Have 1 dihedral(s) to rotate WARNING Could not apply rotation Dihedral(idxs=[5, 6, 7, 2], φ0=0) INFO Queue: [4, 5] INFO Closing ring on: SMILESBond([4, 5], order=2) and adjusting atoms INFO Adjusting ring dihedrals to close the ring INFO Closed ring in: 1.66 ms INFO A ring was poorly closed - adjusting angles WARNING Closing large rings not implemented WARNING Failed to close a ring, minimising on all atoms INFO Double bond - adding constraint INFO Double bond - adding constraint INFO Double bond - adding constraint INFO Resetting sites on atom 4 INFO Rotating 3 sites onto 2 points INFO Resetting sites on atom 5 INFO Rotating 3 sites onto 2 points INFO Queue: [5] INFO Queuing Dihedral(idxs=[3, 4, 5, 6], φ0=0) INFO Have 1 dihedral(s) to rotate WARNING Could not apply rotation Dihedral(idxs=[3, 4, 5, 6], φ0=0) INFO Queue: [8] INFO Queue: [] INFO Minimising non-bonded repulsion by dihedral rotation INFO Have 1 dihedrals to rotate INFO Performed final dihedral rotation in: 9.02 ms INFO Built 3D in: 63.47 ms INFO Generating molecular graph with NetworkX INFO Generating molecular graph with NetworkX INFO Setting the π bonds in a species INFO Setting the stereocentres in a species WARNING Could not find a valid valance for Na. Guessing at 6 INFO Initialisation with SMILES successful. Charge=0, Multiplicity=2, Num. Atoms=21
0.0
[ "tests/test_smiles_parser.py::test_multiplicity_metals" ]
[ "tests/test_smiles_parser.py::test_base_properties", "tests/test_smiles_parser.py::test_sq_brackets_parser", "tests/test_smiles_parser.py::test_multiple_atoms", "tests/test_smiles_parser.py::test_branches", "tests/test_smiles_parser.py::test_rings", "tests/test_smiles_parser.py::test_aromatic", "tests/test_smiles_parser.py::test_hydrogens", "tests/test_smiles_parser.py::test_cis_trans", "tests/test_smiles_parser.py::test_is_pi_atom", "tests/test_smiles_parser.py::test_implicit_hydrogens", "tests/test_smiles_parser.py::test_multiplicity", "tests/test_smiles_parser.py::test_double_bond_stereo_branch", "tests/test_smiles_parser.py::test_alt_ring_branch", "tests/test_smiles_parser.py::test_ring_connectivity" ]
2021-05-07 09:20:45+00:00
2,018
duartegroup__autodE-77
diff --git a/autode/conformers/conformers.py b/autode/conformers/conformers.py index ef46de0..cda456e 100644 --- a/autode/conformers/conformers.py +++ b/autode/conformers/conformers.py @@ -147,7 +147,7 @@ class Conformers(list): if any(calc_heavy_atom_rmsd(conf.atoms, other.atoms) < rmsd_tol for o_idx, other in enumerate(self) if o_idx != idx): - logger.info(f'Conformer {idx} was close in geometry to at' + logger.info(f'Conformer {idx} was close in geometry to at ' f'least one other - removing') del self[idx] diff --git a/autode/species/complex.py b/autode/species/complex.py index a67efc8..31f7a66 100644 --- a/autode/species/complex.py +++ b/autode/species/complex.py @@ -166,7 +166,7 @@ class Complex(Species): for points in iterprod(points_on_sphere, repeat=n-1): - conf = Conformer(species=self, name=f'{self.name}_conf{n}') + conf = Conformer(species=self, name=f'{self.name}_conf{m}') conf.atoms = get_complex_conformer_atoms(self._molecules, rotations, points) diff --git a/doc/common/water_trimer.py b/doc/common/water_trimer.py index 728b945..22aaea9 100644 --- a/doc/common/water_trimer.py +++ b/doc/common/water_trimer.py @@ -1,12 +1,12 @@ -from autode import Molecule, Config +import autode as ade from autode.species import NCIComplex -from autode.wrappers.XTB import xtb -Config.num_complex_sphere_points = 5 -Config.num_complex_random_rotations = 3 +ade.Config.num_complex_sphere_points = 5 +ade.Config.num_complex_random_rotations = 3 +xtb = ade.methods.XTB() # Make a water molecule and optimise at the XTB level -water = Molecule(name='water', smiles='O') +water = ade.Molecule(name='water', smiles='O') water.optimise(method=xtb) # Make the NCI complex and find the lowest energy structure
duartegroup/autodE
445e96f8477eb41e9a42a7e00c6eedfb24118a86
diff --git a/tests/test_conformers.py b/tests/test_conformers.py index 6f4581e..0a8f4e1 100644 --- a/tests/test_conformers.py +++ b/tests/test_conformers.py @@ -1,5 +1,5 @@ from autode.atoms import Atom -from autode.species import Molecule +from autode.species import Molecule, NCIComplex from autode.conformers import Conformer, Conformers from autode.wrappers.ORCA import ORCA from autode.wrappers.XTB import XTB @@ -14,6 +14,7 @@ from . import testutils import numpy as np import pytest import os +import shutil here = os.path.dirname(os.path.abspath(__file__)) orca = ORCA() @@ -270,3 +271,17 @@ def test_calculation_over_no_conformers(): # Should not raise an exception assert len(confs) == 0 + + +def test_complex_conformers_diff_names(): + + Config.num_complex_sphere_points = 2 + Config.num_complex_random_rotations = 2 + + water = Molecule(smiles='O') + h2o_dimer = NCIComplex(water, water, name='dimer') + h2o_dimer._generate_conformers() + assert len(set(conf.name for conf in h2o_dimer.conformers)) > 1 + + if os.path.exists('conformers'): + shutil.rmtree('conformers')
NCIComplex conformers are not generated correctly **Describe the bug** <!-- A clear and concise description of what the bug is. --> NCI complex conformers are all generated with the same name, which means optimisations skip over all but the first one. The documentation water trimer works, but for other more complex surfaces this is not expected to. **To Reproduce** <!-- Steps to reproduce the behaviour: code with output --> ``` import autode as ade from autode.species import NCIComplex ade.Config.num_complex_sphere_points = 5 ade.Config.num_complex_random_rotations = 3 water = ade.Molecule(name='water', smiles='O') trimer = NCIComplex(water, water, water, name='water_trimer') trimer.find_lowest_energy_conformer(lmethod=ade.methods.XTB()) trimer.print_xyz_file() ``` The conformers directory only contains a single XTB output file **Expected behavior** <!-- A clear and concise description of what you expected to happen. --> **Environment** <!-- please complete the following information. --> - OS: CentOS - Version: v. 1.1.0
0.0
[ "tests/test_conformers.py::test_complex_conformers_diff_names" ]
[ "tests/test_conformers.py::test_conf_class", "tests/test_conformers.py::test_rdkit_atoms", "tests/test_conformers.py::test_confs_energy_pruning1", "tests/test_conformers.py::test_confs_energy_pruning2", "tests/test_conformers.py::test_confs_energy_pruning3", "tests/test_conformers.py::test_confs_no_energy_pruning", "tests/test_conformers.py::test_confs_rmsd_pruning1", "tests/test_conformers.py::test_confs_rmsd_pruning2", "tests/test_conformers.py::test_confs_rmsd_puning3", "tests/test_conformers.py::test_sp_hmethod", "tests/test_conformers.py::test_sp_hmethod_ranking", "tests/test_conformers.py::test_calculation_over_no_conformers" ]
2021-10-04 10:49:40+00:00
2,019
dwavesystems__dwave-cloud-client-567
diff --git a/dwave/cloud/api/client.py b/dwave/cloud/api/client.py index 470f6e0..d330eda 100644 --- a/dwave/cloud/api/client.py +++ b/dwave/cloud/api/client.py @@ -320,9 +320,10 @@ class DWaveAPIClient: retry = urllib3.Retry(**kwargs) - # note: `Retry.BACKOFF_MAX` can't be set on construction + # note: prior to `urllib3==2`, backoff_max had to be set manually on object if backoff_max is not None: - retry.BACKOFF_MAX = backoff_max + # handle `urllib3>=1.21.1,<1.27` AND `urllib3>=1.21.1,<3` + retry.BACKOFF_MAX = retry.backoff_max = backoff_max return retry diff --git a/dwave/cloud/client/base.py b/dwave/cloud/client/base.py index 28a9e9a..43f797e 100644 --- a/dwave/cloud/client/base.py +++ b/dwave/cloud/client/base.py @@ -622,11 +622,7 @@ class Client(object): # create http idempotent Retry config def get_retry_conf(): - # need a subclass to override the backoff_max - class Retry(urllib3.Retry): - BACKOFF_MAX = self.http_retry_backoff_max - - return Retry( + retry = urllib3.Retry( total=self.http_retry_total, connect=self.http_retry_connect, read=self.http_retry_read, @@ -637,6 +633,12 @@ class Client(object): raise_on_status=True, respect_retry_after_header=True) + if self.http_retry_backoff_max is not None: + # handle `urllib3>=1.21.1,<1.27` AND `urllib3>=1.21.1,<3` + retry.BACKOFF_MAX = retry.backoff_max = self.http_retry_backoff_max + + return retry + session = BaseUrlSession(base_url=endpoint) session.mount('http://', TimeoutingHTTPAdapter(timeout=self.request_timeout, diff --git a/releasenotes/notes/support-urllib3-v2-5c5a2cb29a47b43d.yaml b/releasenotes/notes/support-urllib3-v2-5c5a2cb29a47b43d.yaml new file mode 100644 index 0000000..c8e7dad --- /dev/null +++ b/releasenotes/notes/support-urllib3-v2-5c5a2cb29a47b43d.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Correctly set `backoff_max` time for retried requests when ``urllib3>=2.0`` + is used. + See `#566 <https://github.com/dwavesystems/dwave-cloud-client/issues/566>`_. \ No newline at end of file
dwavesystems/dwave-cloud-client
d0f7e6935f3069ffe4d1e04b548427f0413a4013
diff --git a/tests/test_client.py b/tests/test_client.py index 5b72294..e59df11 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -555,7 +555,8 @@ class ClientConstruction(unittest.TestCase): self.assertEqual(retry.redirect, opts['http_retry_redirect']) self.assertEqual(retry.status, opts['http_retry_status']) self.assertEqual(retry.backoff_factor, opts['http_retry_backoff_factor']) - self.assertEqual(retry.BACKOFF_MAX, opts['http_retry_backoff_max']) + backoff_max = getattr(retry, 'backoff_max', getattr(retry, 'BACKOFF_MAX')) + self.assertEqual(backoff_max, opts['http_retry_backoff_max']) def test_http_retry_params_from_config(self): retry_opts = {
Http request retry `backoff_max` not working with `urllib3>=2` ### Problem Prior to `requests==2.30.0` (May 2023), `urllib3` was upper-bounded to [`<1.27`](https://github.com/psf/requests/blob/87d63de8739263bbe17034fba2285c79780da7e8/setup.py#L64C6-L64C27), but in `2.30.0` Requests added support for urllib3, v2. In `urllib3==2`, way of specifying `backoff_max` time for request retries (`urllib3.Retry`) changed. Now they finally support it as a construction-time parameter, but before we had to override `Retry.BACKOFF_MAX` and in later versions `Retry.DEFAULT_BACKOFF_MAX` attributes either before or after construction. Note that we don't use urllib3 directly in the cloud client, but via Requests, which accepts (passes) urllib3's spec for retries, [`max_retries`](https://github.com/dwavesystems/dwave-cloud-client/blob/d0f7e6935f3069ffe4d1e04b548427f0413a4013/dwave/cloud/client/base.py#L643). ### Impact For users with `urllib3>=2` installed (fresh installs after May 3, 2023): - minimal for `dwave.cloud.Client` usage (primarily multipart upload requests), and - minimal for `dwave.cloud.api` clients (`Region` requests), i.e. `backoff_max` would not be set to 60 sec (our default), but to 120 sec (urllib3's default). Only if user explicitly wanted to modify the `backoff_max` time, via our `http_retry_backoff_max` config parameter, they would notice somewhat significant impact of this issue.
0.0
[ "tests/test_client.py::ClientConstruction::test_http_retry_params_from_config", "tests/test_client.py::ClientConstruction::test_http_retry_params_from_kwargs" ]
[ "tests/test_client.py::ClientConstruction::test_boolean_options_parsed_from_config", "tests/test_client.py::ClientConstruction::test_class_defaults", "tests/test_client.py::ClientConstruction::test_client_cert_from_config", "tests/test_client.py::ClientConstruction::test_client_cert_from_kwargs", "tests/test_client.py::ClientConstruction::test_client_type", "tests/test_client.py::ClientConstruction::test_custom_kwargs", "tests/test_client.py::ClientConstruction::test_custom_kwargs_overrides_config", "tests/test_client.py::ClientConstruction::test_default", "tests/test_client.py::ClientConstruction::test_defaults_as_kwarg", "tests/test_client.py::ClientConstruction::test_defaults_partial_update", "tests/test_client.py::ClientConstruction::test_headers_from_config", "tests/test_client.py::ClientConstruction::test_headers_from_kwargs", "tests/test_client.py::ClientConstruction::test_metadata_api_endpoint_from_env_accepted", "tests/test_client.py::ClientConstruction::test_none_kwargs_do_not_override_config", "tests/test_client.py::ClientConstruction::test_polling_params_from_config", "tests/test_client.py::ClientConstruction::test_polling_params_from_kwargs", "tests/test_client.py::ClientConstruction::test_positional_args", "tests/test_client.py::ClientConstruction::test_region_default", "tests/test_client.py::ClientConstruction::test_region_endpoint_pair_kwarg_overrides_region_endpoint_pair_from_config", "tests/test_client.py::ClientConstruction::test_region_from_env_overrides_endpoint_from_config", "tests/test_client.py::ClientConstruction::test_region_kwarg_overrides_endpoint_from_config", "tests/test_client.py::ClientConstruction::test_region_selection_over_defaults", "tests/test_client.py::ClientConstruction::test_solver_features_from_config", "tests/test_client.py::ClientConstruction::test_solver_features_kwargs_override_config", "tests/test_client.py::ClientConstruction::test_solver_name_from_config", "tests/test_client.py::ClientConstruction::test_solver_name_overrides_config_features", "tests/test_client.py::ClientConfigIntegration::test_custom_options", "tests/test_client.py::MultiRegionSupport::test_region_endpoint_fallback_when_no_metadata_api", "tests/test_client.py::MultiRegionSupport::test_region_endpoint_fallback_when_region_unknown", "tests/test_client.py::MultiRegionSupport::test_region_endpoint_null_case", "tests/test_client.py::MultiRegionSupport::test_region_selection_mocked_end_to_end", "tests/test_client.py::FeatureBasedSolverSelection::test_anneal_schedule", "tests/test_client.py::FeatureBasedSolverSelection::test_availability_combo", "tests/test_client.py::FeatureBasedSolverSelection::test_category", "tests/test_client.py::FeatureBasedSolverSelection::test_default", "tests/test_client.py::FeatureBasedSolverSelection::test_derived_category_properties", "tests/test_client.py::FeatureBasedSolverSelection::test_derived_category_properties_without_category", "tests/test_client.py::FeatureBasedSolverSelection::test_lower_noise_derived_property", "tests/test_client.py::FeatureBasedSolverSelection::test_membership_ops", "tests/test_client.py::FeatureBasedSolverSelection::test_name", "tests/test_client.py::FeatureBasedSolverSelection::test_nested_properties_intermediate_key_lookup", "tests/test_client.py::FeatureBasedSolverSelection::test_nested_properties_leaf_lookup", "tests/test_client.py::FeatureBasedSolverSelection::test_num_qubits", "tests/test_client.py::FeatureBasedSolverSelection::test_online", "tests/test_client.py::FeatureBasedSolverSelection::test_order_by_callable", "tests/test_client.py::FeatureBasedSolverSelection::test_order_by_edgecases", "tests/test_client.py::FeatureBasedSolverSelection::test_order_by_in_default_solver", "tests/test_client.py::FeatureBasedSolverSelection::test_order_by_respects_default_solver", "tests/test_client.py::FeatureBasedSolverSelection::test_order_by_string", "tests/test_client.py::FeatureBasedSolverSelection::test_parameter_availability_check", "tests/test_client.py::FeatureBasedSolverSelection::test_property_availability_check", "tests/test_client.py::FeatureBasedSolverSelection::test_range_boolean_combo", "tests/test_client.py::FeatureBasedSolverSelection::test_range_ops", "tests/test_client.py::FeatureBasedSolverSelection::test_regex", "tests/test_client.py::FeatureBasedSolverSelection::test_relational_ops", "tests/test_client.py::FeatureBasedSolverSelection::test_set_ops" ]
2023-08-29 12:44:12+00:00
2,051
dwavesystems__dwave-cloud-client-606
diff --git a/dwave/cloud/auth/flows.py b/dwave/cloud/auth/flows.py index 9776baa..679d752 100644 --- a/dwave/cloud/auth/flows.py +++ b/dwave/cloud/auth/flows.py @@ -189,6 +189,7 @@ class AuthFlow: url=self.token_endpoint, grant_type='authorization_code', code=code, + code_verifier=self.code_verifier, **kwargs) logger.debug(f"{type(self).__name__}.fetch_token() = {token!r}") diff --git a/releasenotes/notes/fix-pkce-missing-code-verifier-in-fetch-token-b5cc871cc9d6dfac.yaml b/releasenotes/notes/fix-pkce-missing-code-verifier-in-fetch-token-b5cc871cc9d6dfac.yaml new file mode 100644 index 0000000..4b6df21 --- /dev/null +++ b/releasenotes/notes/fix-pkce-missing-code-verifier-in-fetch-token-b5cc871cc9d6dfac.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fix PKCE support in ``dwave.cloud.auth.flow.AuthFlow`` by properly including + ``code_verifier`` in fetch token (code exchange) requests. + See `#605 <https://github.com/dwavesystems/dwave-cloud-client/issues/605>`_.
dwavesystems/dwave-cloud-client
40c8d5c1985f70f467c088aef78b2fd6542c7e45
diff --git a/tests/auth/test_flows.py b/tests/auth/test_flows.py index 1506b19..8c897a4 100644 --- a/tests/auth/test_flows.py +++ b/tests/auth/test_flows.py @@ -91,14 +91,18 @@ class TestAuthFlow(unittest.TestCase): m.get(requests_mock.ANY, status_code=404) m.post(requests_mock.ANY, status_code=404) + m.post(self.token_endpoint, json=dict(error="error", error_description="bad request")) m.post(self.token_endpoint, additional_matcher=post_body_matcher, json=self.token) # reset creds self.creds.clear() - # verify token fetch flow + # make auth request to generate all request params (like PKCE's verifier) flow = AuthFlow(**self.test_args) + _ = flow.get_authorization_url() + expected_params.update(code_verifier=flow.code_verifier) + # verify token fetch flow response = flow.fetch_token(code=code) self.assertEqual(response, self.token)
PKCE `code_verifier` absent from fetch token request Although `code_challenge` is present in the initial authorization request ([rfc7636, section 4.3](https://datatracker.ietf.org/doc/html/rfc7636#section-4.3)), and `code_verifier` is generated client-side, it's missing in the code exchange request (see [section 4.5](https://datatracker.ietf.org/doc/html/rfc7636#section-4.5)). This represents a security vulnerability for public clients.
0.0
[ "tests/auth/test_flows.py::TestAuthFlow::test_fetch_token" ]
[ "tests/auth/test_flows.py::TestAuthFlow::test_auth_url", "tests/auth/test_flows.py::TestAuthFlow::test_ensure_active_token", "tests/auth/test_flows.py::TestAuthFlow::test_fetch_token_state", "tests/auth/test_flows.py::TestAuthFlow::test_refresh_token", "tests/auth/test_flows.py::TestAuthFlow::test_session_config", "tests/auth/test_flows.py::TestAuthFlow::test_token_expires_soon", "tests/auth/test_flows.py::TestAuthFlow::test_token_setter", "tests/auth/test_flows.py::TestLeapAuthFlow::test_client_id_from_config", "tests/auth/test_flows.py::TestLeapAuthFlow::test_from_common_config", "tests/auth/test_flows.py::TestLeapAuthFlow::test_from_default_config", "tests/auth/test_flows.py::TestLeapAuthFlow::test_from_minimal_config", "tests/auth/test_flows.py::TestLeapAuthFlow::test_from_minimal_config_with_overrides", "tests/auth/test_flows.py::TestLeapAuthFlowOOB::test_oob", "tests/auth/test_flows.py::TestLeapAuthFlowRedirect::test_auth_denied", "tests/auth/test_flows.py::TestLeapAuthFlowRedirect::test_exchange_fails", "tests/auth/test_flows.py::TestLeapAuthFlowRedirect::test_non_auth_failure_during_code_exchange", "tests/auth/test_flows.py::TestLeapAuthFlowRedirect::test_success" ]
2024-02-27 14:38:43+00:00
2,052
e2nIEE__pandapipes-501
diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 783719d..2ba5825 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,10 @@ Change Log ============= +[upcoming release] - 2023-..-.. +------------------------------- +- [ADDED] support Python 3.11 (now included in test pipeline) + [0.8.3] - 2023-01-09 ------------------------------- - [FIXED] inconsistency between testpypi and pypi diff --git a/pandapipes/pipeflow.py b/pandapipes/pipeflow.py index a106c23..9f9544a 100644 --- a/pandapipes/pipeflow.py +++ b/pandapipes/pipeflow.py @@ -83,8 +83,8 @@ def pipeflow(net, sol_vec=None, **kwargs): nodes_connected, branches_connected = check_connectivity( net, branch_pit, node_pit, check_heat=calculate_heat) else: - nodes_connected = node_pit[:, ACTIVE_ND].astype(np.bool) - branches_connected = branch_pit[:, ACTIVE_BR].astype(np.bool) + nodes_connected = node_pit[:, ACTIVE_ND].astype(bool) + branches_connected = branch_pit[:, ACTIVE_BR].astype(bool) reduce_pit(net, node_pit, branch_pit, nodes_connected, branches_connected)
e2nIEE/pandapipes
5491aff63039b20d44c72c471392bbeca3b260d1
diff --git a/.github/workflows/run_tests_develop.yml b/.github/workflows/run_tests_develop.yml index 30dfe43..30ed69b 100644 --- a/.github/workflows/run_tests_develop.yml +++ b/.github/workflows/run_tests_develop.yml @@ -18,17 +18,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest python-igraph pytest-split numba + python -m pip install pytest python-igraph pytest-split + if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower pip install . @@ -58,9 +59,9 @@ jobs: python-version: ['3.8'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies @@ -86,17 +87,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split python-igraph numba + python -m pip install pytest nbmake pytest-xdist pytest-split python-igraph + if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@develop#egg=pandapower pip install . @@ -113,9 +115,9 @@ jobs: matrix: python-version: [ '3.8' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Check docs for Python ${{ matrix.python-version }} diff --git a/.github/workflows/run_tests_master.yml b/.github/workflows/run_tests_master.yml index d360b78..3597d16 100644 --- a/.github/workflows/run_tests_master.yml +++ b/.github/workflows/run_tests_master.yml @@ -17,18 +17,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest python-igraph pytest-split numba + python -m pip install pytest python-igraph pytest-split + if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower pip install . @@ -56,15 +57,16 @@ jobs: matrix: python-version: ['3.7', '3.8', '3.9', '3.10'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install pytest nbmake pytest-xdist pytest-split python-igraph numba + python -m pip install pytest nbmake pytest-xdist pytest-split python-igraph + if ${{ matrix.python-version != '3.11' }}; then python -m pip install numba; fi if [ -f requirements.txt ]; then pip install -r requirements.txt; fi python -m pip install git+https://github.com/e2nIEE/pandapower@master#egg=pandapower pip install . @@ -81,9 +83,9 @@ jobs: matrix: python-version: [ '3.8' ] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Check docs for Python ${{ matrix.python-version }}
Add support for Python 3.11 We should add Python 3.11 to the test pipeline and fix any issues that are related to deprecations.
0.0
[ "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos1[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos1[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos2[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos2[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos3[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos3[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos4[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos4[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos5[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos5[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos6[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_mixed_indexing_oos6[False]" ]
[ "pandapipes/test/api/test_aux_function.py::test_select_from_pit", "pandapipes/test/api/test_components/test_circ_pump_mass.py::test_circulation_pump_constant_mass[True]", "pandapipes/test/api/test_components/test_circ_pump_mass.py::test_circulation_pump_constant_mass[False]", "pandapipes/test/api/test_components/test_circ_pump_pressure.py::test_circulation_pump_constant_pressure[True]", "pandapipes/test/api/test_components/test_circ_pump_pressure.py::test_circulation_pump_constant_pressure[False]", "pandapipes/test/api/test_components/test_compressor.py::test_compressor_pressure_ratio[True]", "pandapipes/test/api/test_components/test_compressor.py::test_compressor_pressure_ratio[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_ext_grid_sorting[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_ext_grid_sorting[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_p_type[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_p_type[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_single_pipe[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_single_pipe[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee_2zu_2ab[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee_2zu_2ab[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee_2zu_2ab2[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee_2zu_2ab2[False]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee_2zu_2ab3[True]", "pandapipes/test/api/test_components/test_ext_grid.py::test_t_type_tee_2zu_2ab3[False]", "pandapipes/test/api/test_components/test_flow_control.py::test_flow_control_simple_heat[True]", "pandapipes/test/api/test_components/test_flow_control.py::test_flow_control_simple_heat[False]", "pandapipes/test/api/test_components/test_flow_control.py::test_flow_control_simple_gas[True]", "pandapipes/test/api/test_components/test_flow_control.py::test_flow_control_simple_gas[False]", "pandapipes/test/api/test_components/test_flow_control.py::test_flow_control_simple_gas_two_eg[True]", "pandapipes/test/api/test_components/test_flow_control.py::test_flow_control_simple_gas_two_eg[False]", "pandapipes/test/api/test_components/test_heat_exchanger.py::test_heat_exchanger[True]", "pandapipes/test/api/test_components/test_heat_exchanger.py::test_heat_exchanger[False]", "pandapipes/test/api/test_components/test_mass_storage.py::test_mass_storage[True]", "pandapipes/test/api/test_components/test_mass_storage.py::test_mass_storage[False]", "pandapipes/test/api/test_components/test_pipe_results.py::test_pipe_velocity_results[True]", "pandapipes/test/api/test_components/test_pipe_results.py::test_pipe_velocity_results[False]", "pandapipes/test/api/test_components/test_pressure_control.py::test_pressure_control_from_measurement_parameters[True]", "pandapipes/test/api/test_components/test_pressure_control.py::test_pressure_control_from_measurement_parameters[False]", "pandapipes/test/api/test_components/test_pressure_control.py::test_2pressure_controller_controllability", "pandapipes/test/api/test_components/test_pump.py::test_pump_from_measurement_parameteres[True]", "pandapipes/test/api/test_components/test_pump.py::test_pump_from_measurement_parameteres[False]", "pandapipes/test/api/test_components/test_pump.py::test_pump_from_regression_parameteres[True]", "pandapipes/test/api/test_components/test_pump.py::test_pump_from_regression_parameteres[False]", "pandapipes/test/api/test_components/test_pump.py::test_pump_from_std_type[True]", "pandapipes/test/api/test_components/test_pump.py::test_pump_from_std_type[False]", "pandapipes/test/api/test_components/test_pump.py::test_pump_bypass_on_reverse_flow[True]", "pandapipes/test/api/test_components/test_pump.py::test_pump_bypass_on_reverse_flow[False]", "pandapipes/test/api/test_components/test_pump.py::test_pump_bypass_high_vdot[True]", "pandapipes/test/api/test_components/test_pump.py::test_pump_bypass_high_vdot[False]", "pandapipes/test/api/test_components/test_valve.py::test_valve[True]", "pandapipes/test/api/test_components/test_valve.py::test_valve[False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.1.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.1.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.1.1-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.1.1-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.1.2-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.1.2-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.2.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.2.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.4.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.4.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.5.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.5.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.6.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.6.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.7.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.7.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.0-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.0-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.1-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.1-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.2-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.2-False]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.3-True]", "pandapipes/test/api/test_convert_format.py::test_convert_format[0.8.3-False]", "pandapipes/test/api/test_create.py::test_create_network", "pandapipes/test/api/test_create.py::test_create_junction", "pandapipes/test/api/test_create.py::test_create_sink", "pandapipes/test/api/test_create.py::test_create_source", "pandapipes/test/api/test_create.py::test_create_ext_grid", "pandapipes/test/api/test_create.py::test_create_heat_exchanger", "pandapipes/test/api/test_create.py::test_create_pipe", "pandapipes/test/api/test_create.py::test_create_pipe_from_parameters", "pandapipes/test/api/test_create.py::test_create_valve", "pandapipes/test/api/test_create.py::test_create_pump", "pandapipes/test/api/test_create.py::test_create_pump_from_parameters", "pandapipes/test/api/test_create.py::test_create_mass_storage", "pandapipes/test/api/test_create.py::test_create_junctions", "pandapipes/test/api/test_create.py::test_create_pipes_from_parameters", "pandapipes/test/api/test_create.py::test_create_pipes_from_parameters_raise_except", "pandapipes/test/api/test_create.py::test_create_pipes", "pandapipes/test/api/test_create.py::test_create_pipes_raise_except", "pandapipes/test/api/test_create.py::test_create_valves", "pandapipes/test/api/test_create.py::test_create_valves_raise_except", "pandapipes/test/api/test_create.py::test_create_pressure_controls", "pandapipes/test/api/test_create.py::test_create_pressure_controls_raise_except", "pandapipes/test/api/test_create.py::test_create_sinks", "pandapipes/test/api/test_create.py::test_create_sinks_raise_except", "pandapipes/test/api/test_create.py::test_create_sources", "pandapipes/test/api/test_create.py::test_create_sources_raise_except", "pandapipes/test/api/test_network_tables.py::test_default_input_tables", "pandapipes/test/api/test_network_tables.py::test_additional_tables", "pandapipes/test/api/test_special_networks.py::test_one_node_net[True]", "pandapipes/test/api/test_special_networks.py::test_one_node_net[False]", "pandapipes/test/api/test_special_networks.py::test_two_node_net[True]", "pandapipes/test/api/test_special_networks.py::test_two_node_net[False]", "pandapipes/test/api/test_special_networks.py::test_random_net_and_one_node_net[True]", "pandapipes/test/api/test_special_networks.py::test_random_net_and_one_node_net[False]", "pandapipes/test/api/test_std_types.py::test_create_and_load_std_type_pipe", "pandapipes/test/api/test_std_types.py::test_create_std_types_pipe", "pandapipes/test/api/test_std_types.py::test_copy_std_types_from_net_pipe", "pandapipes/test/api/test_std_types.py::test_delete_std_type", "pandapipes/test/api/test_std_types.py::test_available_std_types", "pandapipes/test/api/test_time_series.py::test_person_run_fct_time_series", "pandapipes/test/converter/test_stanet_converter.py::test_mini_exampelonia", "pandapipes/test/converter/test_stanet_converter.py::test_mini_exampelonia_not_stanetlike", "pandapipes/test/converter/test_stanet_converter.py::test_mini_exampelonia_stanetlike", "pandapipes/test/converter/test_stanet_converter.py::test_mini_exampelonia_sliders_open", "pandapipes/test/converter/test_stanet_converter.py::test_mini_exampelonia_sliders_closed", "pandapipes/test/io/test_file_io.py::test_pickle", "pandapipes/test/io/test_file_io.py::test_json", "pandapipes/test/io/test_file_io.py::test_json_multinet", "pandapipes/test/io/test_file_io.py::test_json_string", "pandapipes/test/io/test_file_io.py::test_json_string_multinet", "pandapipes/test/multinet/test_control_multinet.py::test_p2g_single", "pandapipes/test/multinet/test_control_multinet.py::test_g2p_single", "pandapipes/test/multinet/test_control_multinet.py::test_g2g_single", "pandapipes/test/multinet/test_control_multinet.py::test_p2g_multiple", "pandapipes/test/multinet/test_control_multinet.py::test_g2p_multiple", "pandapipes/test/multinet/test_control_multinet.py::test_g2g_multiple", "pandapipes/test/multinet/test_control_multinet.py::test_const_p2g_control", "pandapipes/test/multinet/test_control_multinet.py::test_run_control_wo_controller", "pandapipes/test/multinet/test_control_multinet.py::test_p2g_single_run_parameter", "pandapipes/test/multinet/test_time_series_multinet.py::test_time_series_p2g_control", "pandapipes/test/multinet/test_time_series_multinet.py::test_time_series_p2g_control_run_parameter", "pandapipes/test/networks/test_networks.py::test_schutterwald", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_delta[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_delta[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_delta_2sinks[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_delta_2sinks[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_heights[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_heights[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_one_pipe[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_one_pipe[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_one_source[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_one_source[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_section_variation[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_section_variation[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_t_cross[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_t_cross[False]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_two_pipes[True]", "pandapipes/test/openmodelica_comparison/test_heat_transfer_openmodelica.py::test_case_two_pipes[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_mixed_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_mixed_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_mixed_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_mixed_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_versatility_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_versatility_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_versatility_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_combined_versatility_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_delta_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_delta_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_delta_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_delta_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_2valves_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_2valves_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_2valves_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_2valves_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_pumps_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_pumps_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_pumps_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_pumps_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_heights_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_heights_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_heights_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_meshed_heights_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_1_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_1_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_1_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_1_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_2_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_2_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_2_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_2_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_3_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_3_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_3_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_one_pipe_3_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_cross3ext_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_cross3ext_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_cross3ext_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_cross3ext_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pipes_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pipes_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pipes_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pipes_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pumps_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pumps_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pumps_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_strand_net_2pumps_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_valves_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_valves_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_valves_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_tcross_valves_sj[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_2eg_two_pipes_pc[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_2eg_two_pipes_pc[False]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_2eg_two_pipes_sj[True]", "pandapipes/test/openmodelica_comparison/test_water_openmodelica.py::test_case_2eg_two_pipes_sj[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_inservice_gas[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_inservice_gas[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_inservice_water[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_inservice_water[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_hydraulic[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_hydraulic[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_hydraulic2[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_hydraulic2[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_heat1[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_heat1[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_heat2[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_heat2[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_heat3[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_connectivity_heat3[False]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_exclude_unconnected_junction[True]", "pandapipes/test/pipeflow_internals/test_inservice.py::test_exclude_unconnected_junction[False]", "pandapipes/test/pipeflow_internals/test_non_convergence.py::test_pipeflow_non_convergence[True]", "pandapipes/test/pipeflow_internals/test_non_convergence.py::test_pipeflow_non_convergence[False]", "pandapipes/test/pipeflow_internals/test_options.py::test_set_user_pf_options[True]", "pandapipes/test/pipeflow_internals/test_options.py::test_set_user_pf_options[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_gas_internal_nodes[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_gas_internal_nodes[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_single_pipe[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_single_pipe[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_tee_2ab_1zu[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_tee_2ab_1zu[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_tee_2zu_1ab[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_tee_2zu_1ab[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_tee_2zu_1ab_direction_changed[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_tee_2zu_1ab_direction_changed[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_2zu_2ab[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_2zu_2ab[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_masche_1load[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_masche_1load[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_masche_1load_changed_direction[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_analytic_comparison.py::test_temperature_internal_nodes_masche_1load_changed_direction[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_modes.py::test_hydraulic_only[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_modes.py::test_hydraulic_only[False]", "pandapipes/test/pipeflow_internals/test_pipeflow_modes.py::test_heat_only[True]", "pandapipes/test/pipeflow_internals/test_pipeflow_modes.py::test_heat_only[False]", "pandapipes/test/pipeflow_internals/test_time_series.py::test_time_series", "pandapipes/test/pipeflow_internals/test_time_series.py::test_time_series_default_ow", "pandapipes/test/pipeflow_internals/test_update_matrix.py::test_update[True]", "pandapipes/test/pipeflow_internals/test_update_matrix.py::test_update[False]", "pandapipes/test/plotting/test_collections.py::test_collection_lengths", "pandapipes/test/plotting/test_collections.py::test_collections2", "pandapipes/test/plotting/test_collections.py::test_collection_valve_pipe", "pandapipes/test/plotting/test_pipeflow_results.py::test_pressure_profile_to_junction_geodata", "pandapipes/test/plotting/test_simple_collections.py::test_simple_collections", "pandapipes/test/plotting/test_simple_collections.py::test_simple_collections_out_of_service", "pandapipes/test/properties/test_fluid_specials.py::test_add_fluid", "pandapipes/test/properties/test_fluid_specials.py::test_property_adaptation", "pandapipes/test/properties/test_fluid_specials.py::test_fluid_exceptions", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_viscosity_lgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_viscosity_hgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_density_lgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_density_hgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_heat_capacity_lgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_heat_capacity_hgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_molar_mass_lgas", "pandapipes/test/properties/test_properties_toolbox.py::test_mixture_molar_mass_hgas", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_3parallel_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_3parallel_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_combined_3parallel_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_combined_3parallel_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_square_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_square_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_square_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_square_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_delta_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_delta_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_pumps[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_pumps[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_2valves_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_2valves_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_2valves_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_meshed_2valves_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe1_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe1_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe1_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe1_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe2_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe2_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe2_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_one_pipe2_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_strand_2pipes_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_strand_2pipes_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_strand_2pipes_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_strand_2pipes_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_strand_pump[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_strand_pump[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross1_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross1_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross1_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross1_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross2_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross2_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross2_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_tcross2_pc[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_2eg_hnet_n[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_2eg_hnet_n[False]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_2eg_hnet_pc[True]", "pandapipes/test/stanet_comparison/test_gas_stanet.py::test_case_2eg_hnet_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_district_grid_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_district_grid_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_district_grid_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_district_grid_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_pumps_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_pumps_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_delta_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_delta_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_meshed_2valves_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_meshed_2valves_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_meshed_2valves_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_meshed_2valves_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe1_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe1_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe1_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe1_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe2_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe2_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe2_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe2_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe3_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe3_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe3_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_one_pipe3_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_simple_strand_net_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_simple_strand_net_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_simple_strand_net_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_simple_strand_net_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_two_pipes_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_two_pipes_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_two_pipes_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_two_pipes_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_cross_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_cross_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_pump_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_pump_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_tcross_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_tcross_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_tcross_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_tcross_pc[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_2eg_two_pipes_n[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_2eg_two_pipes_n[False]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_2eg_two_pipes_pc[True]", "pandapipes/test/stanet_comparison/test_water_stanet.py::test_case_2eg_two_pipes_pc[False]", "pandapipes/test/test_imports.py::test_import_packages", "pandapipes/test/test_toolbox.py::test_reindex_junctions", "pandapipes/test/test_toolbox.py::test_fuse_junctions", "pandapipes/test/test_toolbox.py::test_create_continuous_index", "pandapipes/test/test_toolbox.py::test_select_subnet", "pandapipes/test/test_toolbox.py::test_pit_extraction", "pandapipes/test/topology/test_graph_searches.py::test_connected_components", "pandapipes/test/topology/test_nxgraph.py::test_include_branches" ]
2023-01-30 15:14:05+00:00
2,054
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
38