diff --git a/.gitattributes b/.gitattributes index 905c30aa5..42f9d0d40 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,5 @@ +*.pt filter=lfs diff=lfs merge=lfs -text *.geoh5 filter=lfs diff=lfs merge=lfs -text +*.h5 filter=lfs diff=lfs merge=lfs -text +*.min.js filter=lfs diff=lfs merge=lfs -text *.ipynb filter=lfs diff=lfs merge=lfs -text diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6bb7e7b8d..e247202da 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ default_language_version: python: python3 exclude: (^docs/(conf.py|_ext/)) -default_stages: [commit,push] +default_stages: [pre-commit,pre-push] fail_fast: false ci: @@ -12,44 +12,45 @@ ci: repos: - repo: https://github.com/hadialqattan/pycln - rev: v2.4.0 + rev: v2.5.0 hooks: - id: pycln args: [--config=pyproject.toml] -- repo: https://github.com/PyCQA/isort - rev: 5.13.2 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.9.1 hooks: - - id: isort - additional_dependencies: [tomli] # to read config from pyproject.toml -- repo: https://github.com/psf/black - rev: 24.4.2 - hooks: - - id: black -- repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 - hooks: - - id: flake8 -- repo: https://github.com/asottile/pyupgrade - rev: v3.15.2 - hooks: - - id: pyupgrade - args: [--py310-plus] + - id: ruff + args: + - --fix + - --exit-non-zero-on-fix +# - --unsafe-fixes + exclude_types: [jupyter] + - id: ruff-format + exclude_types: [jupyter] #- repo: https://github.com/pre-commit/mirrors-mypy # TODO: fix mypy errors # rev: v1.10.0 # hooks: # - id: mypy # additional_dependencies: [ -# numpy==1.26.*, # pre-commit CI does not provide numpy 1.23.* +# numpy==1.26.*, # types-toml, # types-PyYAML, # tomli # to read config from pyproject.toml # ] # exclude: ^(docs|geoapps-assets)/ - repo: https://github.com/codingjoe/relint - rev: 3.1.1 + rev: 3.3.1 hooks: - id: relint args: [-W] # to fail on warnings +- repo: https://github.com/MiraGeoscience/pre-commit-hooks + rev: v1.1.0 + hooks: + - id: check-copyright + files: (^package\.rst|^LICENSE|^README(|-dev)\.rst|\.py|\.pyi)$ + exclude: (^\.|^docs/) + - id: prepare-commit-msg + - id: check-commit-msg - repo: local hooks: - id: pylint @@ -59,31 +60,14 @@ repos: require_serial: true # pylint does its own parallelism types: [python] exclude: ^(devtools|docs)/ - - id: check-copyright - name: Check copyright - entry: python devtools/check-copyright.py - language: python - types: [text] - files: (^LICENSE|^README(|-dev).rst|\.py|\.pyi)$ - exclude: (^\.|^docs/) - - id: prepare-commit-msg - stages: [prepare-commit-msg] - name: Prepare commit message - entry: python devtools/git_message_hook.py --prepare - language: python - - id: check-commit-msg - stages: [commit-msg] - name: Check commit message - entry: python devtools/git_message_hook.py --check - language: python - repo: https://github.com/codespell-project/codespell - rev: v2.2.6 + rev: v2.3.0 hooks: - id: codespell exclude: (-lock\.ya?ml|\benvironments/.*\.ya?ml|\.ipynb|^THIRD_PARTY_SOFTWARE\.rst)$ entry: codespell -I .codespellignore - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace exclude: \.mdj$ @@ -91,7 +75,8 @@ repos: exclude_types: [jupyter] - id: check-toml - id: check-yaml -# - id: check-added-large-files # crashing on some configuration. To be investigated + - id: check-added-large-files +# args: [--enforce-all] - id: check-case-conflict - id: check-merge-conflict - id: debug-statements @@ -111,7 +96,7 @@ repos: exclude_types: [jupyter] exclude: ^docs/.*/images/ - repo: https://github.com/rstcheck/rstcheck - rev: v6.2.0 + rev: v6.2.4 hooks: - id: rstcheck exclude: ^THIRD_PARTY_SOFTWARE.rst$ diff --git a/.rstcheck.cfg b/.rstcheck.cfg index 026a67468..d4d00107a 100644 --- a/.rstcheck.cfg +++ b/.rstcheck.cfg @@ -1,3 +1,4 @@ [rstcheck] ignore_directives=automodule,jupyter-execute,nbgallery report_level=WARNING +ignore_substitutions = copyright_notice diff --git a/LICENSE b/LICENSE index 814813801..186344f22 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 Mira Geoscience +Copyright (c) 2020-2025 Mira Geoscience Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README-dev.rst b/README-dev.rst index a7495d92b..6c5ef3e8b 100644 --- a/README-dev.rst +++ b/README-dev.rst @@ -1,4 +1,3 @@ - Setup for development ===================== @@ -361,11 +360,6 @@ Here is a suggestion for some plugins you can install in PyCharm. .. _.pre-commit-config.yaml: .pre-commit-config.yaml -License -^^^^^^^ -# TODO: ADD LICENSE TERMS - - Copyright ^^^^^^^^^ -Copyright (c) 2024 Mira Geoscience Ltd. +Copyright (c) 2020-2025 Mira Geoscience Ltd. diff --git a/README.rst b/README.rst index 9a796efa4..c52955ed6 100644 --- a/README.rst +++ b/README.rst @@ -167,7 +167,7 @@ License ^^^^^^^ MIT License -Copyright (c) 2024 Mira Geoscience +Copyright (c) 2020-2025 Mira Geoscience Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/devtools/check-copyright.py b/devtools/check-copyright.py deleted file mode 100644 index 223f76038..000000000 --- a/devtools/check-copyright.py +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env python3 - -# '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' -# ' -# This file is part of geoapps. ' -# ' -# geoapps is distributed under the terms and conditions of the MIT License ' -# (see LICENSE file at the root of this source code package). ' -# '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -from __future__ import annotations - -import re -import sys -from datetime import date - -if __name__ == "__main__": - current_year = date.today().year - copyright_re = re.compile( - rf"\bcopyright \(c\) (:?\d{{4}}-|)\b{current_year}\b", re.IGNORECASE - ) - files = sys.argv[1:] - max_lines = 10 - report_files = [] - for f in files: - with open(f, encoding="utf-8") as file: - count = 0 - has_dated_copyright = False - for line in file: - count += 1 - if count >= max_lines and not ( - f.endswith("README.rst") or f.endswith("README-dev.rst") - ): - break - if re.search(copyright_re, line): - has_dated_copyright = True - break - - if not has_dated_copyright: - report_files.append(f) - - if len(report_files) > 0: - for f in report_files: - sys.stderr.write(f"{f}: No copyright or invalid year\n") - sys.exit(1) - -# readonly CURRENT_YEAR=$(date +"%Y") - -# if ! grep -e "Copyright (c) .*$CURRENT_YEAR" $(head -10 $f) 2>&1 1>/dev/null; then -# echo "File '$f' has no copyright or an invalid year" -# exit 1 -# fi diff --git a/devtools/git_message_hook.py b/devtools/git_message_hook.py deleted file mode 100644 index 282e7f34c..000000000 --- a/devtools/git_message_hook.py +++ /dev/null @@ -1,224 +0,0 @@ -#!/usr/bin/env python3 - -# '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' -# ' -# This file is part of geoapps. ' -# ' -# geoapps is distributed under the terms and conditions of the MIT License ' -# (see LICENSE file at the root of this source code package). ' -# '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' - -"""Some Git pre-commit hooks implementations.""" - -from __future__ import annotations - -import argparse -import re -import shlex -import subprocess -import sys - - -def get_jira_id(text) -> str: - """Detect a JIRA issue ID at the begging of the given text. - - :return: the JIRA issue ID if found, else empty string - """ - - class JiraPattern: - """Internal class that encapsulates the regular expression for the JIRA pattern, - making sure it gets compiled only once.""" - - __pattern = re.compile( - r"(?:GEOPY|DEVOPS|QA|GI|GA|GMS|VPem1D|VPem3D|VPmg|UBCGIF|LICMGR)-\d+" - ) - - @staticmethod - def get(): - """:return: the compiled regular expression for the JIRA pattern""" - return JiraPattern.__pattern - - # use re.match() rather than re.search() to enforce the JIRA reference to be at the beginning - match = re.match(JiraPattern.get(), text.strip()) - return match.group(0) if match else "" - - -def get_branch_name() -> str | None: - """:return: the name of the current branch""" - - git_proc = subprocess.run( - shlex.split("git branch --list"), stdout=subprocess.PIPE, text=True, check=False - ) - - # cannot use HEAD during rebase - # git_proc = subprocess.run( - # shlex.split('git symbolic-ref --short HEAD'), stdout=subprocess.PIPE, universal_newlines=True - # ) - # Note: version above suggested by Atlassian. Could also use: git rev-parse --abbrev-ref HEAD - - if git_proc.returncode != 0: - return None - - current_branch = None - # current branch is prefixed by '*' - for line in git_proc.stdout.splitlines(): - stripped = line.strip() - if stripped and stripped[0] == "*": - current_branch = stripped[1:] - break - assert current_branch is not None - - class RebasingPattern: - """Internal class that encapsulates the regular expression for the rebasing - message pattern, making sure it gets compiled only once.""" - - __pattern = re.compile(r"\(.*\s(\S+)\s*\)") - - @staticmethod - def get(): - """:return: the compiled regular expression for the Rebasing pattern""" - return RebasingPattern.__pattern - - match = re.match(RebasingPattern.get(), current_branch.strip()) - if match: - return match.group(1) - - return current_branch - - -def check_commit_message(filepath: str) -> tuple[bool, str]: - """Check if the branch name or the commit message starts with a reference to JIRA, - and if the message meets the minimum required length for the summary line. - - The JIRA reference has to be at the beginning of the branch name, or of the commit - message. - :return: a tuple telling whether the commit message is valid or not, and an error - message (empty in case the message is valid). - """ - - branch_jira_id = "" - branch_name = get_branch_name() - if branch_name: - branch_jira_id = get_jira_id(branch_name) - - message_jira_id = "" - first_line = None - with open(filepath) as message_file: - for line in message_file: - if not line.startswith("#") and len(line.strip()) > 0: - # test only the first non-comment line that is not empty - # (should we reject messages with empty first line?) - first_line = line - message_jira_id = get_jira_id(first_line) - break - assert first_line is not None - - if not branch_jira_id and not ( - message_jira_id or first_line.strip().lower().startswith("merge") - ): - return ( - False, - "Either the branch name or the commit message must start with a JIRA ID.", - ) - - if branch_jira_id and message_jira_id and branch_jira_id != message_jira_id: - return ( - False, - "Different JIRA ID in commit message %s and in branch name %s." - % (message_jira_id, branch_jira_id), - ) - - stripped_message_line = "" - if first_line: - stripped_message_line = first_line.strip() - if message_jira_id: - stripped_message_line = stripped_message_line[ - len(message_jira_id) + 1 : - ].strip() - - min_required_length = 10 - if len(stripped_message_line) < min_required_length: - return ( - False, - "First line of commit message must be at least %s characters long, " - "beyond the JIRA ID." % min_required_length, - ) - - return True, "" - - -def check_commit_msg(filepath: str) -> None: - """To be used a the Git commit-msg hook. - - Exit with non-0 status if the commit message is deemed invalid. - """ - - (is_valid, error_message) = check_commit_message(filepath) - if not is_valid: - print( - """commit-msg hook: **ERROR** %s - Message has been saved to %s.""" - % (error_message, filepath) - ) - sys.exit(1) - - -def prepare_commit_msg(filepath: str, source: str | None = None) -> None: - """To be used a the Git prepare-commit-msg hook. - - Will add the JIRA ID found in the branch name in case it is missing from the commit - message. - """ - - branch_jira_id = "" - branch_name = get_branch_name() - if branch_name: - branch_jira_id = get_jira_id(branch_name) - - if not branch_jira_id: - return - - if source not in [None, "message", "template"]: - return - - with open(filepath, "r+", encoding="utf-8") as message_file: - message_has_jira_id = False - message_lines = message_file.readlines() - for line_index, line_content in enumerate(message_lines): - if not line_content.startswith("#"): - # test only the first non-comment line - message_jira_id = get_jira_id(line_content) - if not message_jira_id: - message_lines[line_index] = branch_jira_id + ": " + line_content - message_has_jira_id = True - break - - if not message_has_jira_id: - # message is empty or all lines are comments: insert JIRA ID at the very beginning - message_lines.insert(0, branch_jira_id + ": ") - - message_file.seek(0, 0) - message_file.write("".join(message_lines)) - - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument("msg_file", help="the message file") - group = parser.add_mutually_exclusive_group(required=True) - group.add_argument( - "-p", "--prepare", action="store_true", help="prepare the commit message" - ) - group.add_argument( - "-c", - "--check", - action="store_true", - help="check if the commit message is valid", - ) - parser.add_argument("args", nargs=argparse.REMAINDER) - - args = parser.parse_args() - if args.prepare: - prepare_commit_msg(args.msg_file, *args.args) - elif args.check: - check_commit_msg(args.msg_file) diff --git a/docs/conf.py b/docs/conf.py index d9c775c7b..2bb627287 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -16,6 +16,8 @@ import sys import shutil import plotly.io as pio +from datetime import datetime +from packaging.version import Version pio.renderers.default = "sphinx_gallery" @@ -92,14 +94,15 @@ master_doc = "index" # General information about the project. -project = "geoapps v0.12.0-beta.2" +project = "geoapps" +project_copyright = "%Y, Mira Geoscience Ltd" +author = "Mira Geoscience Ltd." -# The short X.Y version. -version = "0.12.0" # The full version, including alpha/beta/rc tags. release = "0.12.0-beta.2" - +# The shorter X.Y.Z version. +version = Version(release).base_version # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -173,6 +176,10 @@ # 'display_github': 'True', # } +html_theme_options = { + "description": f"version {release}", +} + # html_logo = 'images/mirageoscience-apps.png' check_meta = False @@ -394,3 +401,12 @@ # TODO: build the source # sphinx-apidoc --templatedir templates/ -o content/api/ ../mirageoscience-apps + + +def get_copyright_notice(): + return f"Copyright {datetime.now().strftime(project_copyright)}" + + +rst_epilog = f""" +.. |copyright_notice| replace:: {get_copyright_notice()}. +""" diff --git a/docs/index.rst b/docs/index.rst index 9cc9394af..b15ced2bf 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -30,3 +30,37 @@ Contents: content/howto.rst content/release_notes.rst content/feedback.rst + + +License +^^^^^^^ +MIT License + +Copyright (c) 2020-2025 Mira Geoscience + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +Curve-apps is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + + +Copyright +^^^^^^^^^ +|copyright_notice| diff --git a/geoapps-assets/__init__.py b/geoapps-assets/__init__.py index c6693bfba..c006bae4f 100644 --- a/geoapps-assets/__init__.py +++ b/geoapps-assets/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2023-2024 Mira Geoscience Ltd. ' +# Copyright (c) 2023-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/__init__.py b/geoapps/__init__.py index b0c063598..862e2a07e 100644 --- a/geoapps/__init__.py +++ b/geoapps/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/base/__init__.py b/geoapps/base/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/base/__init__.py +++ b/geoapps/base/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/base/application.py b/geoapps/base/application.py index 01d3afcc9..bea609f4f 100644 --- a/geoapps/base/application.py +++ b/geoapps/base/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -22,15 +22,17 @@ dict_mapper, entity2uuid, fetch_active_workspace, + list2str, str2uuid, ) from geoh5py.ui_json import InputFile -from geoh5py.ui_json.utils import list2str, monitored_directory_copy +from geoh5py.ui_json.utils import monitored_directory_copy from geoh5py.workspace import Workspace from traitlets import TraitError from geoapps.utils import warn_module_not_found + with warn_module_not_found(): from ipyfilechooser import FileChooser @@ -141,7 +143,7 @@ def __populate__(self, **kwargs): if isinstance(widget, Text): value = list2str(value) - setattr(widget, "value", value) + widget.value = value if hasattr(widget, "style"): widget.style = {"description_width": "initial"} @@ -177,7 +179,7 @@ def file_browser_change(self, _): self.geoh5.close() if extension == ".json" and getattr(self, "_param_class", None) is not None: - self.params = getattr(self, "_param_class")( + self.params = self._param_class( InputFile.read_ui_json(self.file_browser.selected) ) self.refresh.value = False @@ -219,7 +221,7 @@ def live_link_choice(self, _): ) if getattr(self, "_params", None) is not None: - setattr(self.params, "monitoring_directory", self.monitoring_directory) + self.params.monitoring_directory = self.monitoring_directory self.monitoring_panel.children[0].value = "Monitoring path:" else: self.monitoring_panel.children[0].value = "Save to:" @@ -383,9 +385,9 @@ def params(self) -> BaseParams: @params.setter def params(self, params: BaseParams): - assert isinstance( - params, BaseParams - ), f"Input parameters must be an instance of {BaseParams}" + assert isinstance(params, BaseParams), ( + f"Input parameters must be an instance of {BaseParams}" + ) self._params = params @@ -426,9 +428,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) @property diff --git a/geoapps/base/dash_application.py b/geoapps/base/dash_application.py index 07a83b1b4..9d9f4d828 100644 --- a/geoapps/base/dash_application.py +++ b/geoapps/base/dash_application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -200,9 +200,8 @@ def get_params_dict(self, update_dict: dict) -> dict: for key in self.params.to_dict(): if key in update_dict: if ( - bool in validations[key]["types"] - and type(update_dict[key]) == list # noqa: E721 - ): # noqa: E721 + bool in validations[key]["types"] and type(update_dict[key]) == list # noqa: E721 + ): # Convert from dash component checklist to bool if not update_dict[key]: output_dict[key] = False @@ -319,9 +318,9 @@ def params(self) -> BaseParams: @params.setter def params(self, params: BaseParams): - assert isinstance( - params, BaseParams - ), f"Input parameters must be an instance of {BaseParams}" + assert isinstance(params, BaseParams), ( + f"Input parameters must be an instance of {BaseParams}" + ) self._params = params diff --git a/geoapps/base/layout.py b/geoapps/base/layout.py index c88141fcc..a1646b524 100644 --- a/geoapps/base/layout.py +++ b/geoapps/base/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -11,6 +11,7 @@ from dash import dcc, html + workspace_layout = html.Div( [ dcc.Upload( diff --git a/geoapps/base/plot.py b/geoapps/base/plot.py index 4d2685f78..e8343f137 100644 --- a/geoapps/base/plot.py +++ b/geoapps/base/plot.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -21,6 +21,7 @@ from geoapps.utils import warn_module_not_found from geoapps.utils.plotting import plot_plan_data_selection + with warn_module_not_found(): from matplotlib import pyplot as plt diff --git a/geoapps/base/selection.py b/geoapps/base/selection.py index 24cac1d22..465736dd8 100644 --- a/geoapps/base/selection.py +++ b/geoapps/base/selection.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -20,6 +20,7 @@ from geoapps.utils.list import find_value from geoapps.utils.workspace import sorted_children_dict + with warn_module_not_found(): import ipywidgets as widgets from ipywidgets import Dropdown, FloatText, SelectMultiple, VBox @@ -89,9 +90,9 @@ def data(self) -> Dropdown | SelectMultiple: @data.setter def data(self, value): - assert isinstance( - value, (Dropdown, SelectMultiple) - ), f"'Objects' must be of type {Dropdown} or {SelectMultiple}" + assert isinstance(value, (Dropdown, SelectMultiple)), ( + f"'Objects' must be of type {Dropdown} or {SelectMultiple}" + ) self._data = value @property @@ -143,9 +144,9 @@ def object_types(self, entity_types): entity_types = tuple(entity_types) for entity_type in entity_types: - assert issubclass( - entity_type, ObjectBase - ), f"Provided object_types must be instances of {ObjectBase}" + assert issubclass(entity_type, ObjectBase), ( + f"Provided object_types must be instances of {ObjectBase}" + ) self._object_types = entity_types @@ -165,9 +166,9 @@ def exclusion_types(self, entity_types): entity_types = tuple(entity_types) for entity_type in entity_types: - assert issubclass( - entity_type, ObjectBase - ), f"Provided exclusion_types must be instances of {ObjectBase}" + assert issubclass(entity_type, ObjectBase), ( + f"Provided exclusion_types must be instances of {ObjectBase}" + ) self._exclusion_types = tuple(entity_types) @@ -190,9 +191,9 @@ def find_label(self, values): values = [values] for value in values: - assert isinstance( - value, str - ), f"Labels to find must be strings. Value {value} of type {type(value)} provided" + assert isinstance(value, str), ( + f"Labels to find must be strings. Value {value} of type {type(value)} provided" + ) self._find_label = values @property @@ -233,9 +234,9 @@ def workspace(self) -> Workspace | None: @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) # Refresh the list of objects @@ -458,9 +459,9 @@ def multiple_lines(self): @multiple_lines.setter def multiple_lines(self, value): - assert isinstance( - value, bool - ), f"'multiple_lines' property must be of type {bool}" + assert isinstance(value, bool), ( + f"'multiple_lines' property must be of type {bool}" + ) self._multiple_lines = value def update_line_list(self, _): diff --git a/geoapps/block_model_creation/application.py b/geoapps/block_model_creation/application.py index 0e47fb635..38d6128ed 100644 --- a/geoapps/block_model_creation/application.py +++ b/geoapps/block_model_creation/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/block_model_creation/constants.py b/geoapps/block_model_creation/constants.py index cbdfa95bf..0c26346a6 100644 --- a/geoapps/block_model_creation/constants.py +++ b/geoapps/block_model_creation/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -17,6 +17,7 @@ import geoapps from geoapps import assets_path + defaults = { "version": geoapps.__version__, "title": "Block Model Creation", diff --git a/geoapps/block_model_creation/driver.py b/geoapps/block_model_creation/driver.py index 330acc673..082ea71fd 100644 --- a/geoapps/block_model_creation/driver.py +++ b/geoapps/block_model_creation/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/block_model_creation/layout.py b/geoapps/block_model_creation/layout.py index 9840f8b06..fd838617c 100644 --- a/geoapps/block_model_creation/layout.py +++ b/geoapps/block_model_creation/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -11,6 +11,7 @@ from dash import dcc, html + block_model_layout = html.Div( [ dcc.Upload( diff --git a/geoapps/block_model_creation/params.py b/geoapps/block_model_creation/params.py index 7f2e84b39..ff376a552 100644 --- a/geoapps/block_model_creation/params.py +++ b/geoapps/block_model_creation/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/calculator/__init__.py b/geoapps/calculator/__init__.py index 096f62211..4b5c02eed 100644 --- a/geoapps/calculator/__init__.py +++ b/geoapps/calculator/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/calculator/application.py b/geoapps/calculator/application.py index 36c8d76b7..2ec6320ed 100644 --- a/geoapps/calculator/application.py +++ b/geoapps/calculator/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -22,6 +22,7 @@ from geoapps.utils.plotting import plot_plan_data_selection from geoapps.utils.workspace import sorted_children_dict + with warn_module_not_found(): from ipywidgets.widgets import Button, HBox, Layout, Text, Textarea, VBox @@ -35,7 +36,9 @@ class Calculator(ObjectDataSelection): - assert numpy # to make sure numpy is imported here, as it is required to eval the equation + assert ( + numpy + ) # to make sure numpy is imported here, as it is required to eval the equation _select_multiple = True diff --git a/geoapps/clustering/__init__.py b/geoapps/clustering/__init__.py index 1e3522218..70eb90f78 100644 --- a/geoapps/clustering/__init__.py +++ b/geoapps/clustering/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/clustering/application.py b/geoapps/clustering/application.py index 1af7a40e6..83efb0adc 100644 --- a/geoapps/clustering/application.py +++ b/geoapps/clustering/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -740,7 +740,7 @@ def update_colormap(n_clusters: int, color_pickers: list) -> list: color_map[ii] = [ np.min([ii / (n_clusters - 1), 1]), "rgb(" - + ",".join([f"{int(color[i:i + 2], 16)}" for i in (0, 2, 4)]) + + ",".join([f"{int(color[i : i + 2], 16)}" for i in (0, 2, 4)]) + ")", ] else: diff --git a/geoapps/clustering/constants.py b/geoapps/clustering/constants.py index 3a525c7d5..9b7371655 100644 --- a/geoapps/clustering/constants.py +++ b/geoapps/clustering/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -18,6 +18,7 @@ from geoapps import assets_path from geoapps.scatter_plot.constants import default_ui_json as base_default_ui_json + defaults = { "version": geoapps.__version__, "title": "Clustering", diff --git a/geoapps/clustering/driver.py b/geoapps/clustering/driver.py index 1e28539d9..a6be896d1 100644 --- a/geoapps/clustering/driver.py +++ b/geoapps/clustering/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -15,6 +15,7 @@ from geoh5py.workspace import Workspace + os.environ["OMP_NUM_THREADS"] = "1" import numpy as np @@ -218,7 +219,9 @@ def run(self): ast.literal_eval(self.params.data_subset), self.params.geoh5, ) - full_scales_dict = dict(zip(self.params.data_subset, self.params.full_scales)) + full_scales_dict = dict( + zip(self.params.data_subset, self.params.full_scales, strict=False) + ) kmeans, _ = ClusteringDriver.run_clustering( self.params.n_clusters, dataframe, diff --git a/geoapps/clustering/layout.py b/geoapps/clustering/layout.py index 660a18a93..9af43dac3 100644 --- a/geoapps/clustering/layout.py +++ b/geoapps/clustering/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -15,6 +15,7 @@ from geoapps.base.layout import workspace_layout from geoapps.scatter_plot.layout import axis_layout, downsampling_layout, plot_layout + # Layout for histogram, stats table, confusion matrix norm_tabs_layout = html.Div( id="norm_tabs", diff --git a/geoapps/clustering/params.py b/geoapps/clustering/params.py index 3af485490..e2f731f22 100644 --- a/geoapps/clustering/params.py +++ b/geoapps/clustering/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/clustering/plot_data.py b/geoapps/clustering/plot_data.py index 1603daf48..bf44e2dc2 100644 --- a/geoapps/clustering/plot_data.py +++ b/geoapps/clustering/plot_data.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/contours/__init__.py b/geoapps/contours/__init__.py index ede61ec9f..1f577d13a 100644 --- a/geoapps/contours/__init__.py +++ b/geoapps/contours/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/contours/application.py b/geoapps/contours/application.py index 2e9970eed..212201129 100644 --- a/geoapps/contours/application.py +++ b/geoapps/contours/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -36,7 +36,7 @@ class ContourValues(PlotSelection2D): def __init__(self, ui_json=None, plot_result=True, **kwargs): app_initializer.update(kwargs) if ui_json is not None and Path(ui_json).is_file(): - self.params = self._param_class(InputFile(ui_json)) + self.params = self._param_class(input_file=InputFile(ui_json=ui_json)) else: try: self.params = self._param_class(**app_initializer) diff --git a/geoapps/contours/constants.py b/geoapps/contours/constants.py index 181a4fe23..46a68081a 100644 --- a/geoapps/contours/constants.py +++ b/geoapps/contours/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -17,6 +17,7 @@ import geoapps from geoapps import assets_path + defaults = { "version": geoapps.__version__, "title": "Create Contours", diff --git a/geoapps/contours/driver.py b/geoapps/contours/driver.py index f014d0208..cf8fe8cd3 100644 --- a/geoapps/contours/driver.py +++ b/geoapps/contours/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -59,7 +59,9 @@ def run(self): if contour_set is not None: vertices, cells, values = [], [], [] count = 0 - for segs, level in zip(contour_set.allsegs, contour_set.levels): + for segs, level in zip( + contour_set.allsegs, contour_set.levels, strict=False + ): for poly in segs: n_v = len(poly) vertices.append(poly) diff --git a/geoapps/contours/params.py b/geoapps/contours/params.py index 50f9c4f39..2746abb4c 100644 --- a/geoapps/contours/params.py +++ b/geoapps/contours/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/coordinate_transformation/__init__.py b/geoapps/coordinate_transformation/__init__.py index 5879efc77..c8fe29462 100644 --- a/geoapps/coordinate_transformation/__init__.py +++ b/geoapps/coordinate_transformation/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/coordinate_transformation/application.py b/geoapps/coordinate_transformation/application.py index 54de9785a..fb1fa4e49 100644 --- a/geoapps/coordinate_transformation/application.py +++ b/geoapps/coordinate_transformation/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -26,6 +26,7 @@ from ..base.application import BaseApplication + with warn_module_not_found(): from ipywidgets import HBox, Layout, SelectMultiple, Text, Textarea, VBox @@ -34,6 +35,7 @@ from uuid import UUID + with warn_module_not_found(): from osgeo import gdal, osr diff --git a/geoapps/coordinate_transformation/utils.py b/geoapps/coordinate_transformation/utils.py index d47fff9ce..160af1b0d 100644 --- a/geoapps/coordinate_transformation/utils.py +++ b/geoapps/coordinate_transformation/utils.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/driver_base/__init__.py b/geoapps/driver_base/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/driver_base/__init__.py +++ b/geoapps/driver_base/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/driver_base/driver.py b/geoapps/driver_base/driver.py index a49a5179d..14f502c05 100644 --- a/geoapps/driver_base/driver.py +++ b/geoapps/driver_base/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/driver_base/params.py b/geoapps/driver_base/params.py index 39e26ae4a..a49a57306 100644 --- a/geoapps/driver_base/params.py +++ b/geoapps/driver_base/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -122,7 +122,7 @@ def update(self, params_dict: dict[str, Any]): """Update parameters with dictionary contents.""" params_dict = self.input_file.numify(params_dict) if params_dict.get("geoh5", None) is not None and self.input_file.geoh5 is None: - setattr(self, "geoh5", params_dict.pop("geoh5")) + self.geoh5 = params_dict.pop("geoh5") with fetch_active_workspace(self.geoh5): params_dict = self.input_file.promote(params_dict) # pylint: disable=W0212 @@ -242,7 +242,9 @@ def free_parameter_dict(self): # TODO Create a geoh5py validation for "allof" -> ["object", "levels", "type", "distance"] free_parameter_dict[group] = {} forms = utils.collect(self.ui_json, "group", group) - for label, key in zip(forms, self._free_parameter_keys): + for label, key in zip( + forms, self._free_parameter_keys, strict=False + ): if key not in label.lower(): raise ValueError( f"Malformed input refinement group {group}. " @@ -268,9 +270,9 @@ def validations(self) -> dict[str, Any]: @validations.setter def validations(self, validations: dict[str, Any]): - assert isinstance( - validations, dict - ), "Input value must be a dictionary of validations." + assert isinstance(validations, dict), ( + "Input value must be a dictionary of validations." + ) self._validations = validations @property diff --git a/geoapps/driver_base/utils.py b/geoapps/driver_base/utils.py index f2d6cb455..6652082f2 100644 --- a/geoapps/driver_base/utils.py +++ b/geoapps/driver_base/utils.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -57,8 +57,8 @@ def running_mean( def treemesh_2_octree(workspace, treemesh, **kwargs): - index_array, levels = getattr(treemesh, "_ubc_indArr") - ubc_order = getattr(treemesh, "_ubc_order") + index_array, levels = treemesh._ubc_indArr + ubc_order = treemesh._ubc_order index_array = index_array[ubc_order] - 1 levels = levels[ubc_order] diff --git a/geoapps/edge_detection/__init__.py b/geoapps/edge_detection/__init__.py index a07655e20..6f07dc8b7 100644 --- a/geoapps/edge_detection/__init__.py +++ b/geoapps/edge_detection/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/edge_detection/application.py b/geoapps/edge_detection/application.py index 60fd7db8c..6fb496aef 100644 --- a/geoapps/edge_detection/application.py +++ b/geoapps/edge_detection/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -28,6 +28,7 @@ from geoapps.utils import warn_module_not_found from geoapps.utils.formatters import string_name + with warn_module_not_found(): from ipywidgets import Button, FloatSlider, HBox, IntSlider, Layout, Text, VBox @@ -59,7 +60,7 @@ class EdgeDetectionApp(PlotSelection2D): def __init__(self, ui_json=None, plot_result=True, **kwargs): app_initializer.update(kwargs) if ui_json is not None and Path(ui_json).is_file(): - self.params = self._param_class(InputFile(ui_json)) + self.params = self._param_class(input_file=InputFile(ui_json=ui_json)) else: try: self.params = self._param_class(**app_initializer) diff --git a/geoapps/edge_detection/constants.py b/geoapps/edge_detection/constants.py index 6546f054b..3a4a41ca2 100644 --- a/geoapps/edge_detection/constants.py +++ b/geoapps/edge_detection/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -17,6 +17,7 @@ import geoapps from geoapps import assets_path + defaults = { "version": geoapps.__version__, "title": "Edge Detection", diff --git a/geoapps/edge_detection/driver.py b/geoapps/edge_detection/driver.py index bc921673f..39fb3f187 100644 --- a/geoapps/edge_detection/driver.py +++ b/geoapps/edge_detection/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -30,9 +30,7 @@ class EdgeDetectionDriver(BaseDriver): _params_class = EdgeDetectionParams _validations = validations - def __init__( - self, params: EdgeDetectionParams - ): # pylint: disable=useless-super-delegation + def __init__(self, params: EdgeDetectionParams): # pylint: disable=useless-super-delegation super().__init__(params) def run(self): diff --git a/geoapps/edge_detection/params.py b/geoapps/edge_detection/params.py index 14904f4f9..84d63b0cd 100644 --- a/geoapps/edge_detection/params.py +++ b/geoapps/edge_detection/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/export/__init__.py b/geoapps/export/__init__.py index 72602363d..1125318b5 100644 --- a/geoapps/export/__init__.py +++ b/geoapps/export/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/export/application.py b/geoapps/export/application.py index 9e8034a38..c055cdd99 100644 --- a/geoapps/export/application.py +++ b/geoapps/export/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -24,6 +24,7 @@ from geoapps.utils.io import export_grid_2_geotiff from geoapps.utils.plotting import plot_plan_data_selection + with warn_module_not_found(): from matplotlib import pyplot as plt @@ -31,11 +32,12 @@ from osgeo import osr with warn_module_not_found(): - from ipywidgets.widgets import HBox, VBox from ipywidgets import Dropdown, FloatText, Layout, RadioButtons, Text, Textarea + from ipywidgets.widgets import HBox, VBox from .utils import export_curve_2_shapefile, object_2_dataframe + app_initializer = { "geoh5": str(assets_path() / "FlinFlon.geoh5"), "objects": UUID("{538a7eb1-2218-4bec-98cc-0a759aa0ef4f}"), @@ -205,9 +207,9 @@ def _export_csv(self, entity, fields): ) def _export_shapefile(self, entity): - assert isinstance( - entity, Curve - ), f"Only Curve objects are support for type {self.file_type.value}" + assert isinstance(entity, Curve), ( + f"Only Curve objects are support for type {self.file_type.value}" + ) if self.data.value: for key in self.data.value: @@ -276,9 +278,9 @@ def _export_geotiff(self, entity): print(f"Object saved to {name}") def _export_ubc(self, entity, data_values): - assert isinstance( - entity, (Octree, BlockModel) - ), "Export available for BlockModel or octree only" + assert isinstance(entity, (Octree, BlockModel)), ( + "Export available for BlockModel or octree only" + ) if isinstance(entity, Octree): mesh = octree_2_treemesh(entity) diff --git a/geoapps/export/utils.py b/geoapps/export/utils.py index cd492d7aa..5fbf9b594 100644 --- a/geoapps/export/utils.py +++ b/geoapps/export/utils.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -14,6 +14,7 @@ from geoapps.utils import warn_module_not_found + with warn_module_not_found(): from shapely.geometry import LineString, mapping diff --git a/geoapps/interpolation/__init__.py b/geoapps/interpolation/__init__.py index 3d7e73307..15832febb 100644 --- a/geoapps/interpolation/__init__.py +++ b/geoapps/interpolation/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/interpolation/application.py b/geoapps/interpolation/application.py index 7981e3050..4cf916183 100644 --- a/geoapps/interpolation/application.py +++ b/geoapps/interpolation/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -26,6 +26,7 @@ from geoapps.interpolation.params import DataInterpolationParams from geoapps.utils import warn_module_not_found + with warn_module_not_found(): from ipywidgets import Dropdown, FloatText, HBox, Label, RadioButtons, VBox @@ -41,7 +42,7 @@ class DataInterpolation(ObjectDataSelection): def __init__(self, ui_json=None, **kwargs): app_initializer.update(kwargs) if ui_json is not None and Path(ui_json).is_file(): - self.params = self._param_class(InputFile(ui_json)) + self.params = self._param_class(input_file=InputFile(ui_json=ui_json)) else: try: self.params = self._param_class(**app_initializer) @@ -234,9 +235,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) self.update_objects_list() self.out_object.options = self.objects.options diff --git a/geoapps/interpolation/constants.py b/geoapps/interpolation/constants.py index e67af86d0..dad955d53 100644 --- a/geoapps/interpolation/constants.py +++ b/geoapps/interpolation/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -17,6 +17,7 @@ import geoapps from geoapps import assets_path + defaults = { "version": geoapps.__version__, "title": "Data Transfer", diff --git a/geoapps/interpolation/driver.py b/geoapps/interpolation/driver.py index fa8eed96c..077470fb8 100644 --- a/geoapps/interpolation/driver.py +++ b/geoapps/interpolation/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -71,13 +71,13 @@ def run(self): for key in values_interp.keys(): if self.params.space == "Log": values_interp[key] = sign[key] * np.exp(values_interp[key]) - values_interp[key][ - np.isnan(values_interp[key]) - ] = self.params.no_data_value + values_interp[key][np.isnan(values_interp[key])] = ( + self.params.no_data_value + ) if self.params.max_distance is not None: - values_interp[key][ - rad > self.params.max_distance - ] = self.params.no_data_value + values_interp[key][rad > self.params.max_distance] = ( + self.params.no_data_value + ) elif self.params.method == "Inverse Distance": print("Computing inverse distance interpolation") # Inverse distance @@ -103,7 +103,7 @@ def run(self): return_indices=True, ) - for key, val in zip(list(values.keys()), vals): + for key, val in zip(list(values.keys()), vals, strict=False): values_interp[key] = val sign[key] = sign[key][ind_inv[:, 0]] @@ -152,9 +152,9 @@ def run(self): rad, _ = tree.query(xyz_out_orig[:, :2]) for key in values_interp.keys(): if self.params.max_distance is not None: - values_interp[key][ - rad > self.params.max_distance - ] = self.params.no_data_value + values_interp[key][rad > self.params.max_distance] = ( + self.params.no_data_value + ) for key in values_interp.keys(): if dtype[key] == np.dtype("int32"): diff --git a/geoapps/interpolation/params.py b/geoapps/interpolation/params.py index e1bdec534..2ecdc26f1 100644 --- a/geoapps/interpolation/params.py +++ b/geoapps/interpolation/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/__init__.py b/geoapps/inversion/__init__.py index 79931d7a2..eeed4c1cf 100644 --- a/geoapps/inversion/__init__.py +++ b/geoapps/inversion/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/base_inversion_application.py b/geoapps/inversion/base_inversion_application.py index ebe9a6479..c9d6345cb 100644 --- a/geoapps/inversion/base_inversion_application.py +++ b/geoapps/inversion/base_inversion_application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/base_inversion_layout.py b/geoapps/inversion/base_inversion_layout.py index 93ba760f9..c6eea1231 100644 --- a/geoapps/inversion/base_inversion_layout.py +++ b/geoapps/inversion/base_inversion_layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/components/preprocessing.py b/geoapps/inversion/components/preprocessing.py index 8d28956c7..e681cd63d 100644 --- a/geoapps/inversion/components/preprocessing.py +++ b/geoapps/inversion/components/preprocessing.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/constants.py b/geoapps/inversion/constants.py index e078dd58b..52fcfa530 100644 --- a/geoapps/inversion/constants.py +++ b/geoapps/inversion/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -15,6 +15,7 @@ import geoapps + default_ui_json = { "forward_only": False, "topography_object": { diff --git a/geoapps/inversion/electricals/__init__.py b/geoapps/inversion/electricals/__init__.py index ad575ec1c..6a6e87967 100644 --- a/geoapps/inversion/electricals/__init__.py +++ b/geoapps/inversion/electricals/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/application.py b/geoapps/inversion/electricals/application.py index 3925a0f55..e2556b7e0 100644 --- a/geoapps/inversion/electricals/application.py +++ b/geoapps/inversion/electricals/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -45,6 +45,7 @@ from geoapps.utils import warn_module_not_found from geoapps.utils.list import find_value + with warn_module_not_found(): import ipywidgets as widgets from ipywidgets.widgets import ( @@ -729,9 +730,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) self.update_objects_list() # self.lines.workspace = workspace @@ -1200,7 +1201,7 @@ def file_browser_change(self, _): elif data["inversion_type"] == "induced polarization 3d": self._param_class = InducedPolarization3DParams - self.params = getattr(self, "_param_class")( + self.params = self._param_class( InputFile.read_ui_json(self.file_browser.selected) ) self.params.geoh5.open(mode="r") diff --git a/geoapps/inversion/electricals/direct_current/__init__.py b/geoapps/inversion/electricals/direct_current/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/inversion/electricals/direct_current/__init__.py +++ b/geoapps/inversion/electricals/direct_current/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/direct_current/pseudo_three_dimensions/constants.py b/geoapps/inversion/electricals/direct_current/pseudo_three_dimensions/constants.py index aa7a6649e..37dd903e2 100644 --- a/geoapps/inversion/electricals/direct_current/pseudo_three_dimensions/constants.py +++ b/geoapps/inversion/electricals/direct_current/pseudo_three_dimensions/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_dcip.geoh5"), "data_object": UUID("{6e14de2c-9c2f-4976-84c2-b330d869cb82}"), diff --git a/geoapps/inversion/electricals/direct_current/three_dimensions/__init__.py b/geoapps/inversion/electricals/direct_current/three_dimensions/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/electricals/direct_current/three_dimensions/__init__.py +++ b/geoapps/inversion/electricals/direct_current/three_dimensions/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/direct_current/three_dimensions/constants.py b/geoapps/inversion/electricals/direct_current/three_dimensions/constants.py index 475ed6583..7fc13ba41 100644 --- a/geoapps/inversion/electricals/direct_current/three_dimensions/constants.py +++ b/geoapps/inversion/electricals/direct_current/three_dimensions/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_dcip.geoh5"), "data_object": UUID("{6e14de2c-9c2f-4976-84c2-b330d869cb82}"), diff --git a/geoapps/inversion/electricals/direct_current/two_dimensions/__init__.py b/geoapps/inversion/electricals/direct_current/two_dimensions/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/electricals/direct_current/two_dimensions/__init__.py +++ b/geoapps/inversion/electricals/direct_current/two_dimensions/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/direct_current/two_dimensions/constants.py b/geoapps/inversion/electricals/direct_current/two_dimensions/constants.py index ace042295..5341dcd03 100644 --- a/geoapps/inversion/electricals/direct_current/two_dimensions/constants.py +++ b/geoapps/inversion/electricals/direct_current/two_dimensions/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_dcip.geoh5"), "data_object": UUID("{6e14de2c-9c2f-4976-84c2-b330d869cb82}"), diff --git a/geoapps/inversion/electricals/induced_polarization/__init__.py b/geoapps/inversion/electricals/induced_polarization/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/inversion/electricals/induced_polarization/__init__.py +++ b/geoapps/inversion/electricals/induced_polarization/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/induced_polarization/pseudo_three_dimensions/constants.py b/geoapps/inversion/electricals/induced_polarization/pseudo_three_dimensions/constants.py index 579c1ae42..98bcee0d0 100644 --- a/geoapps/inversion/electricals/induced_polarization/pseudo_three_dimensions/constants.py +++ b/geoapps/inversion/electricals/induced_polarization/pseudo_three_dimensions/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_dcip.geoh5"), "data_object": UUID("{6e14de2c-9c2f-4976-84c2-b330d869cb82}"), diff --git a/geoapps/inversion/electricals/induced_polarization/three_dimensions/__init__.py b/geoapps/inversion/electricals/induced_polarization/three_dimensions/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/electricals/induced_polarization/three_dimensions/__init__.py +++ b/geoapps/inversion/electricals/induced_polarization/three_dimensions/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/induced_polarization/three_dimensions/constants.py b/geoapps/inversion/electricals/induced_polarization/three_dimensions/constants.py index db5bb2a06..b4207d4f2 100644 --- a/geoapps/inversion/electricals/induced_polarization/three_dimensions/constants.py +++ b/geoapps/inversion/electricals/induced_polarization/three_dimensions/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_dcip.geoh5"), "data_object": UUID("{6e14de2c-9c2f-4976-84c2-b330d869cb82}"), diff --git a/geoapps/inversion/electricals/induced_polarization/two_dimensions/__init__.py b/geoapps/inversion/electricals/induced_polarization/two_dimensions/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/electricals/induced_polarization/two_dimensions/__init__.py +++ b/geoapps/inversion/electricals/induced_polarization/two_dimensions/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electricals/induced_polarization/two_dimensions/constants.py b/geoapps/inversion/electricals/induced_polarization/two_dimensions/constants.py index ffd743d81..abf15e2fc 100644 --- a/geoapps/inversion/electricals/induced_polarization/two_dimensions/constants.py +++ b/geoapps/inversion/electricals/induced_polarization/two_dimensions/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_dcip.geoh5"), "data_object": UUID("{6e14de2c-9c2f-4976-84c2-b330d869cb82}"), diff --git a/geoapps/inversion/electromagnetics/__init__.py b/geoapps/inversion/electromagnetics/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/inversion/electromagnetics/__init__.py +++ b/geoapps/inversion/electromagnetics/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electromagnetics/application.py b/geoapps/inversion/electromagnetics/application.py index 71b758bb7..29acba0f9 100644 --- a/geoapps/inversion/electromagnetics/application.py +++ b/geoapps/inversion/electromagnetics/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -40,6 +40,7 @@ from geoapps.utils.list import find_value from geoapps.utils.string import string_2_list + with warn_module_not_found(): from matplotlib import pyplot as plt @@ -929,9 +930,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) # Refresh the list of objects diff --git a/geoapps/inversion/electromagnetics/driver.py b/geoapps/inversion/electromagnetics/driver.py index d9e375c3d..d16cd81b4 100644 --- a/geoapps/inversion/electromagnetics/driver.py +++ b/geoapps/inversion/electromagnetics/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -221,7 +221,9 @@ def inversion(input_file): else: em_specs["tx_specs"]["type"] = "VMD" - for dat_uid, unc_uid in zip(data_group.properties, uncert_group.properties): + for dat_uid, unc_uid in zip( + data_group.properties, uncert_group.properties, strict=False + ): d_entity = workspace.get_entity(dat_uid)[0] u_entity = workspace.get_entity(unc_uid)[0] channels[d_entity.name] = True @@ -667,7 +669,7 @@ def offset_receivers_xy(locations, offsets): uncert = np.zeros(n_sounding * block) n_data = 0 - for ind, (d, u) in enumerate(zip(data, uncertainties)): + for ind, (d, u) in enumerate(zip(data, uncertainties, strict=False)): dobs[ind::block] = d[win_ind][stn_id] uncert[ind::block] = u[win_ind][stn_id] n_data += dobs[ind::block].shape[0] diff --git a/geoapps/inversion/electromagnetics/frequency_domain/__init__.py b/geoapps/inversion/electromagnetics/frequency_domain/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/electromagnetics/frequency_domain/__init__.py +++ b/geoapps/inversion/electromagnetics/frequency_domain/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electromagnetics/frequency_domain/constants.py b/geoapps/inversion/electromagnetics/frequency_domain/constants.py index fd7eb3394..4dc01c3ae 100644 --- a/geoapps/inversion/electromagnetics/frequency_domain/constants.py +++ b/geoapps/inversion/electromagnetics/frequency_domain/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,4 +9,5 @@ from __future__ import annotations + app_initializer = {} diff --git a/geoapps/inversion/electromagnetics/time_domain/__init__.py b/geoapps/inversion/electromagnetics/time_domain/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/electromagnetics/time_domain/__init__.py +++ b/geoapps/inversion/electromagnetics/time_domain/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/electromagnetics/time_domain/constants.py b/geoapps/inversion/electromagnetics/time_domain/constants.py index fd7eb3394..4dc01c3ae 100644 --- a/geoapps/inversion/electromagnetics/time_domain/constants.py +++ b/geoapps/inversion/electromagnetics/time_domain/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,4 +9,5 @@ from __future__ import annotations + app_initializer = {} diff --git a/geoapps/inversion/joint/constants.py b/geoapps/inversion/joint/constants.py index fd7eb3394..4dc01c3ae 100644 --- a/geoapps/inversion/joint/constants.py +++ b/geoapps/inversion/joint/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,4 +9,5 @@ from __future__ import annotations + app_initializer = {} diff --git a/geoapps/inversion/joint/joint_cross_gradient/__init__.py b/geoapps/inversion/joint/joint_cross_gradient/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/joint/joint_cross_gradient/__init__.py +++ b/geoapps/inversion/joint/joint_cross_gradient/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/joint/joint_cross_gradient/constants.py b/geoapps/inversion/joint/joint_cross_gradient/constants.py index fd7eb3394..4dc01c3ae 100644 --- a/geoapps/inversion/joint/joint_cross_gradient/constants.py +++ b/geoapps/inversion/joint/joint_cross_gradient/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,4 +9,5 @@ from __future__ import annotations + app_initializer = {} diff --git a/geoapps/inversion/joint/joint_surveys/__init__.py b/geoapps/inversion/joint/joint_surveys/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/joint/joint_surveys/__init__.py +++ b/geoapps/inversion/joint/joint_surveys/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/joint/joint_surveys/constants.py b/geoapps/inversion/joint/joint_surveys/constants.py index fd7eb3394..4dc01c3ae 100644 --- a/geoapps/inversion/joint/joint_surveys/constants.py +++ b/geoapps/inversion/joint/joint_surveys/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,4 +9,5 @@ from __future__ import annotations + app_initializer = {} diff --git a/geoapps/inversion/natural_sources/__init__.py b/geoapps/inversion/natural_sources/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/natural_sources/__init__.py +++ b/geoapps/inversion/natural_sources/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/natural_sources/magnetotellurics/__init__.py b/geoapps/inversion/natural_sources/magnetotellurics/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/natural_sources/magnetotellurics/__init__.py +++ b/geoapps/inversion/natural_sources/magnetotellurics/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/natural_sources/magnetotellurics/constants.py b/geoapps/inversion/natural_sources/magnetotellurics/constants.py index fbfb9243e..1274d0d32 100644 --- a/geoapps/inversion/natural_sources/magnetotellurics/constants.py +++ b/geoapps/inversion/natural_sources/magnetotellurics/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_natural_sources.geoh5"), "topography_object": UUID("{cfabb8dd-d1ad-4c4e-a87c-7b3dd224c3f5}"), diff --git a/geoapps/inversion/natural_sources/tipper/__init__.py b/geoapps/inversion/natural_sources/tipper/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/natural_sources/tipper/__init__.py +++ b/geoapps/inversion/natural_sources/tipper/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/natural_sources/tipper/constants.py b/geoapps/inversion/natural_sources/tipper/constants.py index fd7eb3394..4dc01c3ae 100644 --- a/geoapps/inversion/natural_sources/tipper/constants.py +++ b/geoapps/inversion/natural_sources/tipper/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,4 +9,5 @@ from __future__ import annotations + app_initializer = {} diff --git a/geoapps/inversion/potential_fields/__init__.py b/geoapps/inversion/potential_fields/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/potential_fields/__init__.py +++ b/geoapps/inversion/potential_fields/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/application.py b/geoapps/inversion/potential_fields/application.py index 94ad2f70c..4c697b3fd 100644 --- a/geoapps/inversion/potential_fields/application.py +++ b/geoapps/inversion/potential_fields/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -35,6 +35,7 @@ from ...base.application import BaseApplication + with warn_module_not_found(): import ipywidgets as widgets from ipywidgets.widgets import ( @@ -801,9 +802,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) self.update_objects_list() self.sensor.workspace = workspace @@ -1353,7 +1354,7 @@ def file_browser_change(self, _): elif data["inversion_type"] == "magnetic scalar": self._param_class = MagneticScalarParams - self.params = getattr(self, "_param_class")( + self.params = self._param_class( InputFile.read_ui_json(self.file_browser.selected) ) params = self.params.to_dict() diff --git a/geoapps/inversion/potential_fields/gravity/__init__.py b/geoapps/inversion/potential_fields/gravity/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/potential_fields/gravity/__init__.py +++ b/geoapps/inversion/potential_fields/gravity/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/gravity/application.py b/geoapps/inversion/potential_fields/gravity/application.py index 41e63615d..c284def01 100644 --- a/geoapps/inversion/potential_fields/gravity/application.py +++ b/geoapps/inversion/potential_fields/gravity/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/gravity/constants.py b/geoapps/inversion/potential_fields/gravity/constants.py index 6ca28469d..3470690c6 100644 --- a/geoapps/inversion/potential_fields/gravity/constants.py +++ b/geoapps/inversion/potential_fields/gravity/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -14,6 +14,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon.geoh5"), "monitoring_directory": str((assets_path() / "Temp").resolve()), diff --git a/geoapps/inversion/potential_fields/gravity/layout.py b/geoapps/inversion/potential_fields/gravity/layout.py index b24f97808..397b5f3f3 100644 --- a/geoapps/inversion/potential_fields/gravity/layout.py +++ b/geoapps/inversion/potential_fields/gravity/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -11,6 +11,7 @@ import geoapps.inversion.base_inversion_layout as base_layout + component_list = [ "gx", "gy", diff --git a/geoapps/inversion/potential_fields/magnetic_scalar/__init__.py b/geoapps/inversion/potential_fields/magnetic_scalar/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/potential_fields/magnetic_scalar/__init__.py +++ b/geoapps/inversion/potential_fields/magnetic_scalar/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/magnetic_scalar/application.py b/geoapps/inversion/potential_fields/magnetic_scalar/application.py index f75480584..d4cb427b1 100644 --- a/geoapps/inversion/potential_fields/magnetic_scalar/application.py +++ b/geoapps/inversion/potential_fields/magnetic_scalar/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/magnetic_scalar/constants.py b/geoapps/inversion/potential_fields/magnetic_scalar/constants.py index a64bd2609..72717b3d4 100644 --- a/geoapps/inversion/potential_fields/magnetic_scalar/constants.py +++ b/geoapps/inversion/potential_fields/magnetic_scalar/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -14,6 +14,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon.geoh5"), "monitoring_directory": str((assets_path() / "Temp").resolve()), diff --git a/geoapps/inversion/potential_fields/magnetic_scalar/layout.py b/geoapps/inversion/potential_fields/magnetic_scalar/layout.py index 378f24772..1369982a7 100644 --- a/geoapps/inversion/potential_fields/magnetic_scalar/layout.py +++ b/geoapps/inversion/potential_fields/magnetic_scalar/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -11,6 +11,7 @@ import geoapps.inversion.base_inversion_layout as base_layout + component_list = [ "tmi", "bx", diff --git a/geoapps/inversion/potential_fields/magnetic_vector/__init__.py b/geoapps/inversion/potential_fields/magnetic_vector/__init__.py index 27cfab23a..6844b17f2 100644 --- a/geoapps/inversion/potential_fields/magnetic_vector/__init__.py +++ b/geoapps/inversion/potential_fields/magnetic_vector/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/magnetic_vector/application.py b/geoapps/inversion/potential_fields/magnetic_vector/application.py index 25eb6af54..c9010120b 100644 --- a/geoapps/inversion/potential_fields/magnetic_vector/application.py +++ b/geoapps/inversion/potential_fields/magnetic_vector/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/inversion/potential_fields/magnetic_vector/constants.py b/geoapps/inversion/potential_fields/magnetic_vector/constants.py index 1b717884b..809188ea3 100644 --- a/geoapps/inversion/potential_fields/magnetic_vector/constants.py +++ b/geoapps/inversion/potential_fields/magnetic_vector/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -14,6 +14,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon.geoh5"), "monitoring_directory": str((assets_path() / "Temp").resolve()), diff --git a/geoapps/inversion/potential_fields/magnetic_vector/layout.py b/geoapps/inversion/potential_fields/magnetic_vector/layout.py index 4b25ae04e..1b04e5573 100644 --- a/geoapps/inversion/potential_fields/magnetic_vector/layout.py +++ b/geoapps/inversion/potential_fields/magnetic_vector/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -11,6 +11,7 @@ import geoapps.inversion.base_inversion_layout as base_layout + component_list = [ "tmi", "bx", diff --git a/geoapps/inversion/utils.py b/geoapps/inversion/utils.py index 97954e990..c0d25c0bd 100644 --- a/geoapps/inversion/utils.py +++ b/geoapps/inversion/utils.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -62,8 +62,7 @@ def calculate_2D_trend( """ if not isinstance(order, int) or order < 0: raise ValueError( - "Polynomial 'order' should be an integer > 0. " - f"Value of {order} provided." + f"Polynomial 'order' should be an integer > 0. Value of {order} provided." ) ind_nan = ~np.isnan(values) @@ -77,7 +76,7 @@ def calculate_2D_trend( values = values[hull.vertices] elif not method == "all": raise ValueError( - "'method' must be either 'all', or 'perimeter'. " f"Value {method} provided" + f"'method' must be either 'all', or 'perimeter'. Value {method} provided" ) # Compute center of mass @@ -86,7 +85,7 @@ def calculate_2D_trend( polynomial = [] xx, yy = np.triu_indices(order + 1) - for x, y in zip(xx, yy): + for x, y in zip(xx, yy, strict=False): polynomial.append( (loc_xy[:, 0] - center_x) ** float(x) * (loc_xy[:, 1] - center_y) ** float(y - x) @@ -101,7 +100,7 @@ def calculate_2D_trend( params, _, _, _ = np.linalg.lstsq(polynomial, values, rcond=None) data_trend = np.zeros(points.shape[0]) - for count, (x, y) in enumerate(zip(xx, yy)): + for count, (x, y) in enumerate(zip(xx, yy, strict=False)): data_trend += ( params[count] * (points[:, 0] - center_x) ** float(x) diff --git a/geoapps/iso_surfaces/__init__.py b/geoapps/iso_surfaces/__init__.py index f3a17abf2..0cb4baa89 100644 --- a/geoapps/iso_surfaces/__init__.py +++ b/geoapps/iso_surfaces/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/iso_surfaces/application.py b/geoapps/iso_surfaces/application.py index f3a53431b..07267ed09 100644 --- a/geoapps/iso_surfaces/application.py +++ b/geoapps/iso_surfaces/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -25,6 +25,7 @@ from geoapps.iso_surfaces.params import IsoSurfacesParams from geoapps.utils.importing import warn_module_not_found + with warn_module_not_found(): from ipywidgets import FloatText, HBox, Label, Text, VBox, Widget @@ -42,7 +43,7 @@ class IsoSurface(ObjectDataSelection): def __init__(self, ui_json=None, **kwargs): app_initializer.update(kwargs) if ui_json is not None and Path(ui_json).is_file(): - self.params = self._param_class(InputFile(ui_json)) + self.params = self._param_class(input_file=InputFile(ui_json=ui_json)) else: try: self.params = self._param_class(**app_initializer) diff --git a/geoapps/iso_surfaces/constants.py b/geoapps/iso_surfaces/constants.py index ae8731ed8..daec18aa7 100644 --- a/geoapps/iso_surfaces/constants.py +++ b/geoapps/iso_surfaces/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -17,6 +17,7 @@ import geoapps from geoapps import assets_path + defaults = { "version": geoapps.__version__, "title": "Create Iso Surfaces", diff --git a/geoapps/iso_surfaces/driver.py b/geoapps/iso_surfaces/driver.py index 2f6983580..bd82c4b23 100644 --- a/geoapps/iso_surfaces/driver.py +++ b/geoapps/iso_surfaces/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -61,7 +61,7 @@ def run(self): container = ContainerGroup.create(self.params.geoh5, name="Isosurface") result = [] - for surface, level in zip(surfaces, levels): + for surface, level in zip(surfaces, levels, strict=False): if len(surface[0]) > 0 and len(surface[1]) > 0: result += [ Surface.create( @@ -74,7 +74,7 @@ def run(self): ] self.update_monitoring_directory(container) - print("Isosurface completed. " f"-> {len(surfaces)} surface(s) created.") + print(f"Isosurface completed. -> {len(surfaces)} surface(s) created.") return result diff --git a/geoapps/iso_surfaces/params.py b/geoapps/iso_surfaces/params.py index 4ebb766b8..c6e1f3ce6 100644 --- a/geoapps/iso_surfaces/params.py +++ b/geoapps/iso_surfaces/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/octree_creation/__init__.py b/geoapps/octree_creation/__init__.py index 0b7d2e6da..2188e64b8 100644 --- a/geoapps/octree_creation/__init__.py +++ b/geoapps/octree_creation/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/octree_creation/application.py b/geoapps/octree_creation/application.py index 057f40655..bf65ed108 100644 --- a/geoapps/octree_creation/application.py +++ b/geoapps/octree_creation/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -31,6 +31,7 @@ from geoapps.octree_creation.constants import app_initializer from geoapps.utils import warn_module_not_found + with warn_module_not_found(): from ipywidgets import ( Checkbox, @@ -65,7 +66,7 @@ class OctreeMesh(ObjectDataSelection): def __init__(self, ui_json=None, **kwargs): app_initializer.update(kwargs) if ui_json is not None and Path(ui_json).is_file(): - self.params = self._param_class(InputFile(ui_json)) + self.params = self._param_class(input_file=InputFile(ui_json=ui_json)) else: try: self.params = self._param_class(**app_initializer) @@ -242,9 +243,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) self.update_objects_choices() diff --git a/geoapps/octree_creation/constants.py b/geoapps/octree_creation/constants.py index 1d0134940..3988d4418 100644 --- a/geoapps/octree_creation/constants.py +++ b/geoapps/octree_creation/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon.geoh5"), "objects": UUID("{656acd40-25de-4865-814c-cb700f6ee51a}"), diff --git a/geoapps/peak_finder/__init__.py b/geoapps/peak_finder/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/peak_finder/__init__.py +++ b/geoapps/peak_finder/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/peak_finder/application.py b/geoapps/peak_finder/application.py index e9b30f6c2..4cbcb1ec8 100644 --- a/geoapps/peak_finder/application.py +++ b/geoapps/peak_finder/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -12,7 +12,6 @@ import uuid from pathlib import Path -from geoapps_utils.application.dash_application import ObjectSelection from geoh5py.data import ReferencedData from geoh5py.objects import ObjectBase from geoh5py.shared import Entity @@ -20,6 +19,7 @@ from geoh5py.ui_json import InputFile from ipywidgets import Dropdown, VBox from peak_finder.application import PeakFinder as DashPeakFinder +from peak_finder.dash_application import ObjectSelection from peak_finder.params import PeakFinderParams from geoapps.base.selection import ObjectDataSelection @@ -35,10 +35,9 @@ class PeakFinder(ObjectDataSelection): _add_groups = "only" def __init__(self, ui_json=None, **kwargs): - app_initializer.update(kwargs) if ui_json is not None and Path(ui_json).is_file(): - self.params = self._param_class(InputFile(ui_json)) + self.params = self._param_class(input_file=InputFile(ui_json=ui_json)) else: try: self.params = self._param_class(**app_initializer) diff --git a/geoapps/peak_finder/constants.py b/geoapps/peak_finder/constants.py index 1413aba94..0bfe7c1b7 100644 --- a/geoapps/peak_finder/constants.py +++ b/geoapps/peak_finder/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -11,6 +11,7 @@ from geoapps import assets_path + app_initializer = { "geoh5": str(assets_path() / "FlinFlon_airborne_tem.geoh5"), "objects": UUID("{34698019-cde6-4b43-8d53-a040b25c989a}"), diff --git a/geoapps/scatter_plot/__init__.py b/geoapps/scatter_plot/__init__.py index 66a34f14e..9c9e88bc8 100644 --- a/geoapps/scatter_plot/__init__.py +++ b/geoapps/scatter_plot/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/scatter_plot/application.py b/geoapps/scatter_plot/application.py index 2fea84a39..83dcb5561 100644 --- a/geoapps/scatter_plot/application.py +++ b/geoapps/scatter_plot/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -360,20 +360,25 @@ def update_channel_bounds( trigger = callback_context.triggered[0]["prop_id"].split(".")[0] if trigger == "ui_json_data" or trigger == "": - x_min, x_max = ui_json_data.get("x_min", None), ui_json_data.get( - "x_max", None + x_min, x_max = ( + ui_json_data.get("x_min", None), + ui_json_data.get("x_max", None), ) - y_min, y_max = ui_json_data.get("y_min", None), ui_json_data.get( - "y_max", None + y_min, y_max = ( + ui_json_data.get("y_min", None), + ui_json_data.get("y_max", None), ) - z_min, z_max = ui_json_data.get("z_min", None), ui_json_data.get( - "z_max", None + z_min, z_max = ( + ui_json_data.get("z_min", None), + ui_json_data.get("z_max", None), ) - color_min, color_max = ui_json_data.get( - "color_min", None - ), ui_json_data.get("color_max", None) - size_min, size_max = ui_json_data.get("size_min", None), ui_json_data.get( - "size_max", None + color_min, color_max = ( + ui_json_data.get("color_min", None), + ui_json_data.get("color_max", None), + ) + size_min, size_max = ( + ui_json_data.get("size_min", None), + ui_json_data.get("size_max", None), ) elif trigger == "x": diff --git a/geoapps/scatter_plot/constants.py b/geoapps/scatter_plot/constants.py index f660ddd7f..7ef2ced2d 100644 --- a/geoapps/scatter_plot/constants.py +++ b/geoapps/scatter_plot/constants.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -18,6 +18,7 @@ import geoapps from geoapps import assets_path + defaults = { "version": geoapps.__version__, "title": "Scatter Plot", diff --git a/geoapps/scatter_plot/driver.py b/geoapps/scatter_plot/driver.py index 8703fba9c..bb90481e7 100644 --- a/geoapps/scatter_plot/driver.py +++ b/geoapps/scatter_plot/driver.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/scatter_plot/layout.py b/geoapps/scatter_plot/layout.py index 2738682a5..1ac093e76 100644 --- a/geoapps/scatter_plot/layout.py +++ b/geoapps/scatter_plot/layout.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -12,6 +12,7 @@ import plotly.express as px from dash import dcc, html + downsampling_layout = html.Div( [ html.Div( diff --git a/geoapps/scatter_plot/params.py b/geoapps/scatter_plot/params.py index 4e75e2970..463a3e1bd 100644 --- a/geoapps/scatter_plot/params.py +++ b/geoapps/scatter_plot/params.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/scripts/__init__.py b/geoapps/scripts/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/scripts/__init__.py +++ b/geoapps/scripts/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/scripts/start_notebook.py b/geoapps/scripts/start_notebook.py index 64fe6e384..edcdd102c 100644 --- a/geoapps/scripts/start_notebook.py +++ b/geoapps/scripts/start_notebook.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/shared_utils/__init__.py b/geoapps/shared_utils/__init__.py index 13a8b0f67..a70539a08 100644 --- a/geoapps/shared_utils/__init__.py +++ b/geoapps/shared_utils/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/shared_utils/colors.py b/geoapps/shared_utils/colors.py index 1fd7dd721..8ca5a3a96 100644 --- a/geoapps/shared_utils/colors.py +++ b/geoapps/shared_utils/colors.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,6 +9,7 @@ from __future__ import annotations + UNIQUE_COLORS = [ "#000000", "#FFFF00", diff --git a/geoapps/shared_utils/utils.py b/geoapps/shared_utils/utils.py index 6987e600c..4b34671f1 100644 --- a/geoapps/shared_utils/utils.py +++ b/geoapps/shared_utils/utils.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -131,9 +131,9 @@ def weighted_average( n = np.min([xyz_in.shape[0], n]) assert isinstance(values, list), "Input 'values' must be a list of numpy.ndarrays" - assert all( - [vals.shape[0] == xyz_in.shape[0] for vals in values] - ), "Input 'values' must have the same shape as input 'locations'" + assert all([vals.shape[0] == xyz_in.shape[0] for vals in values]), ( + "Input 'values' must have the same shape as input 'locations'" + ) avg_values = [] for value in values: @@ -462,7 +462,9 @@ def octree_2_treemesh(mesh): tsw_corner = np.asarray(mesh.origin.tolist()) small_cell = [mesh.u_cell_size, mesh.v_cell_size, mesh.w_cell_size] n_cell_dim = [mesh.u_count, mesh.v_count, mesh.w_count] - cell_sizes = [np.ones(nr) * sz for nr, sz in zip(n_cell_dim, small_cell)] + cell_sizes = [ + np.ones(nr) * sz for nr, sz in zip(n_cell_dim, small_cell, strict=False) + ] u_shift, v_shift, w_shift = (np.sum(h[h < 0]) for h in cell_sizes) h1, h2, h3 = (np.abs(h) for h in cell_sizes) x0 = tsw_corner + np.array([u_shift, v_shift, w_shift]) @@ -550,7 +552,7 @@ def get_inversion_output(h5file: str | Workspace, inversion_group: str | UUID): ][:-1] cols = out.pop(0).split(" ") out = [[string_to_numeric(k) for k in line.split(" ")] for line in out] - out = dict(zip(cols, list(map(list, zip(*out))))) + out = dict(zip(cols, list(map(list, zip(*out, strict=False))), strict=False)) return out diff --git a/geoapps/triangulated_surfaces/__init__.py b/geoapps/triangulated_surfaces/__init__.py index 784d8eb14..52d3c14c5 100644 --- a/geoapps/triangulated_surfaces/__init__.py +++ b/geoapps/triangulated_surfaces/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/triangulated_surfaces/application.py b/geoapps/triangulated_surfaces/application.py index 5e274cc9f..9cde5e965 100644 --- a/geoapps/triangulated_surfaces/application.py +++ b/geoapps/triangulated_surfaces/application.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -27,6 +27,7 @@ from geoapps.utils import warn_module_not_found from geoapps.utils.formatters import string_name + with warn_module_not_found(): from ipywidgets import ( FloatText, @@ -345,14 +346,14 @@ def trigger_click(self, _): ) if len(self.models) > 0: - for uid, model in zip(self.data.value, self.models): + for uid, model in zip(self.data.value, self.models, strict=False): surface.add_data( { self.data.uid_name_map[uid]: {"values": model}, } ) else: - for data_obj, model in zip(data_list, self.models): + for data_obj, model in zip(data_list, self.models, strict=False): surface.add_data( { data_obj.name: {"values": model}, @@ -414,9 +415,9 @@ def elevations(self): @elevations.setter def elevations(self, value): - assert isinstance( - value, ObjectDataSelection - ), f"elevations must be an object of type {ObjectDataSelection}" + assert isinstance(value, ObjectDataSelection), ( + f"elevations must be an object of type {ObjectDataSelection}" + ) self._elevations = value @property @@ -497,9 +498,9 @@ def workspace(self): @workspace.setter def workspace(self, workspace): - assert isinstance( - workspace, Workspace - ), f"Workspace must be of class {Workspace}" + assert isinstance(workspace, Workspace), ( + f"Workspace must be of class {Workspace}" + ) self.base_workspace_changes(workspace) # Refresh the list of objects diff --git a/geoapps/utils/__init__.py b/geoapps/utils/__init__.py index 80f85d19b..8a211dded 100644 --- a/geoapps/utils/__init__.py +++ b/geoapps/utils/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/formatters.py b/geoapps/utils/formatters.py index 7cec42bba..4d3c7fdac 100644 --- a/geoapps/utils/formatters.py +++ b/geoapps/utils/formatters.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/geophysical_systems.py b/geoapps/utils/geophysical_systems.py index f7bc5f242..2067e3d39 100644 --- a/geoapps/utils/geophysical_systems.py +++ b/geoapps/utils/geophysical_systems.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/importing.py b/geoapps/utils/importing.py index 2be52f4ee..ff2592bc1 100644 --- a/geoapps/utils/importing.py +++ b/geoapps/utils/importing.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/io.py b/geoapps/utils/io.py index 61b30f0df..cc35e8269 100644 --- a/geoapps/utils/io.py +++ b/geoapps/utils/io.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/list.py b/geoapps/utils/list.py index aa441fd4c..9dfc9e0b5 100644 --- a/geoapps/utils/list.py +++ b/geoapps/utils/list.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/models.py b/geoapps/utils/models.py index 0956cffae..f7269a6f8 100644 --- a/geoapps/utils/models.py +++ b/geoapps/utils/models.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -85,10 +85,8 @@ def drape_to_octree( if method == "nearest": octree_model.append(datum[0].values) else: - lookup_inds = ( - mesh._get_containing_cell_indexes( # pylint: disable=W0212 - model.centroids - ) + lookup_inds = mesh._get_containing_cell_indexes( # pylint: disable=W0212 + model.centroids ) octree_model[lookup_inds] = datum[0].values diff --git a/geoapps/utils/plotting.py b/geoapps/utils/plotting.py index 6a14916c4..c0fb5a6ef 100644 --- a/geoapps/utils/plotting.py +++ b/geoapps/utils/plotting.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -20,6 +20,7 @@ from geoapps.shared_utils.utils import filter_xy from geoapps.utils import warn_module_not_found + with warn_module_not_found(): from matplotlib import colors from matplotlib import pyplot as plt @@ -267,7 +268,7 @@ def plot_plan_data_selection(entity, data, **kwargs): axis.set_xlim([x.min() - width * 0.1, x.max() + width * 0.1]) axis.set_ylim([y.min() - height * 0.1, y.max() + height * 0.1]) - if "colorbar" in kwargs and kwargs["colorbar"]: + if kwargs.get("colorbar"): plt.colorbar(out, ax=axis) line_selection = np.zeros_like(indices, dtype=bool) @@ -363,13 +364,19 @@ def plot_profile_data_selection( yy[-1], yerr=uncertainties[i][0] * np.abs(yy[-1]) + uncertainties[i][1], - color=[c + i * i for c, i in zip(color, c_increment)], + color=[ + c + i * i + for c, i in zip(color, c_increment, strict=False) + ], ) else: ax.plot( xx[-1], yy[-1], - color=[c + i * i for c, i in zip(color, c_increment)], + color=[ + c + i * i + for c, i in zip(color, c_increment, strict=False) + ], ) legend.append(field) @@ -402,9 +409,9 @@ def plotly_scatter( """ Create a plotly.graph_objects.Mesh3D figure. """ - assert ( - getattr(points, "vertices", None) is not None - ), "Input object must have vertices" + assert getattr(points, "vertices", None) is not None, ( + "Input object must have vertices" + ) if figure is None: figure = go.FigureWidget() @@ -483,9 +490,9 @@ def plotly_block_model( """ Create a plotly.graph_objects.Mesh3D figure. """ - assert isinstance( - block_model, BlockModel - ), f"Input block_model must be of type {Surface}" + assert isinstance(block_model, BlockModel), ( + f"Input block_model must be of type {Surface}" + ) if figure is None: figure = go.FigureWidget() diff --git a/geoapps/utils/statistics.py b/geoapps/utils/statistics.py index 6fe43f586..e226e78b7 100644 --- a/geoapps/utils/statistics.py +++ b/geoapps/utils/statistics.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/string.py b/geoapps/utils/string.py index 5db477158..b1511b806 100644 --- a/geoapps/utils/string.py +++ b/geoapps/utils/string.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/surveys.py b/geoapps/utils/surveys.py index 78b1d3167..7333bad90 100644 --- a/geoapps/utils/surveys.py +++ b/geoapps/utils/surveys.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,7 @@ from SimPEG.survey import BaseSurvey + if TYPE_CHECKING: from simpeg_drivers.components import InversionData @@ -177,15 +178,15 @@ def slice_and_map(obj: np.ndarray, slicer: np.ndarray | Callable): if isinstance(slicer, np.ndarray): if slicer.dtype == bool: sliced_object = obj[slicer] - g2l = dict(zip(np.where(slicer)[0], np.arange(len(obj)))) + g2l = dict(zip(np.where(slicer)[0], np.arange(len(obj)), strict=False)) else: sliced_object = obj[slicer] - g2l = dict(zip(slicer, np.arange(len(slicer)))) + g2l = dict(zip(slicer, np.arange(len(slicer)), strict=False)) elif callable(slicer): slicer = np.array([slicer(k) for k in obj]) sliced_object = obj[slicer] - g2l = dict(zip(np.where(slicer)[0], np.arange(len(obj)))) + g2l = dict(zip(np.where(slicer)[0], np.arange(len(obj)), strict=False)) return sliced_object, g2l diff --git a/geoapps/utils/testing.py b/geoapps/utils/testing.py index 25df4161f..0512819b9 100644 --- a/geoapps/utils/testing.py +++ b/geoapps/utils/testing.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/workspace.py b/geoapps/utils/workspace.py index 155d99ba4..a335a0325 100644 --- a/geoapps/utils/workspace.py +++ b/geoapps/utils/workspace.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/geoapps/utils/write_default_uijson.py b/geoapps/utils/write_default_uijson.py index 881a591fa..e56d07c9e 100644 --- a/geoapps/utils/write_default_uijson.py +++ b/geoapps/utils/write_default_uijson.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -53,6 +53,7 @@ from geoapps.iso_surfaces.params import IsoSurfacesParams from geoapps.scatter_plot.params import ScatterPlotParams + active_data_channels = [ "z_real_channel", "z_imag_channel", diff --git a/pyproject.toml b/pyproject.toml index 91411551d..e476b38ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,16 @@ [tool.poetry] name = "geoapps" version = "0.12.0-beta.2" - +license = "MIT" description = "Open-sourced Applications in Geoscience" -authors = ["Mira Geoscience "] +authors = ["Mira Geoscience "] +maintainers = [ + "Benjamin Kary ", + "Dominique Fournier ", +] repository = "https://github.com/MiraGeoscience/geoapps" -documentation = "https://geoapps.readthedocs.io/en/latest/" -homepage = "https://mirageoscience.com" +documentation = "https://mirageoscience-geoapps.readthedocs-hosted.com/" +homepage = "https://www.mirageoscience.com/mining-industry-software/python-integration/" readme = "README.rst" packages = [ @@ -19,12 +23,12 @@ exclude = [ ] include = [ - { path = "COPYING", format = ["sdist", "wheel"] }, - { path = "COPYING.LESSER", format = ["sdist", "wheel"] }, - { path = "LICENSE", format = ["sdist", "wheel"] }, - { path = "README.rst", format = ["sdist", "wheel"] }, - { path = "THIRD_PARTY_SOFTWARE.rst", format = ["sdist", "wheel"] }, - { path = "docs/**/THIRD_PARTY_SOFTWARE.rst", format = ["sdist", "wheel"] }, + { path = "COPYING" }, + { path = "COPYING.LESSER" }, + { path = "LICENSE" }, + { path = "README.rst" }, + { path = "THIRD_PARTY_SOFTWARE.rst" }, + { path = "docs/**/THIRD_PARTY_SOFTWARE.rst" }, ] keywords = ["geology", "geophysics", "earth sciences"] @@ -159,11 +163,56 @@ tomli = "*" platforms = ['win-64', 'linux-64'] channels = ['conda-forge'] -[tool.isort] -profile = "black" +[tool.ruff] +target-version = "py310" + +[tool.ruff.lint] +ignore = [ + "B028", # no-explicit-stacklevel for warnings.warn() + "E501", # line-too-long - code is reformatted (do not care about comments and docstring) + "F401", # unsused-import - covered by pycln + "A005", # TO DO (stdlib-module-shadowing: Module shadows a Python standard-library module) + "RUF005", # TO DO + "B007", # TO DO + "B011", # TO DO + "B904", # TO DO + "C408", # TO DO + "C414", # TO DO + "C416", # TO DO + "C419", # TO DO + "C901", # TO DO + "RUF005", # collection-literal-concatenation - wrong suggestion with numpy arrays + "RUF012", # TO DO + "RUF013", # TO DO + "RUF015", # TO DO + "UP038", # TO DO + "TID252", # TO DO +] +select = [ + "A", # flake8-builtins + "B", # flake8-bugbear + "B006", # Do not use mutable data structures for argument defaults + "B9", # flake8-bugbear opiniated warnings + "BLE", # flake8-blind-except + "C4", # flake8-comprehensions + "C9", # mccabe + "E", # pycodestyle errors + "F", # pyflakes + "I", # isort + "RUF", # ruff rules + "TID", # flake8-tidy-imports + "UP", # pyupgrade + "W", # pycodestyle warnings +] + +[tool.ruff.lint.mccabe] +max-complexity = 18 + +[tool.ruff.lint.isort] +lines-after-imports = 2 -[tool.black] -# defaults are just fine +[tool.ruff.format] +# default formatting is just fine [tool.mypy] warn_unused_configs = true diff --git a/tests/__init__.py b/tests/__init__.py index 108d4347e..8b44dfa97 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -9,6 +9,7 @@ from geoapps import assets_path + PROJECT = assets_path() / "FlinFlon.geoh5" PROJECT_DCIP = assets_path() / "FlinFlon_dcip.geoh5" PROJECT_TEM = assets_path() / "FlinFlon_airborne_tem.geoh5" diff --git a/tests/assets_path_test.py b/tests/assets_path_test.py index cc94d74ec..a13ba3e2c 100644 --- a/tests/assets_path_test.py +++ b/tests/assets_path_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/conftest.py b/tests/conftest.py index 512383eed..4ea468d31 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/data_transfer_test.py b/tests/data_transfer_test.py index 0202fe975..0f2fb8cdb 100644 --- a/tests/data_transfer_test.py +++ b/tests/data_transfer_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/em1d_run_test.py b/tests/em1d_run_test.py index 80d35b794..ace670750 100644 --- a/tests/em1d_run_test.py +++ b/tests/em1d_run_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/formatters_test.py b/tests/formatters_test.py index c7d642cf6..82d64d758 100644 --- a/tests/formatters_test.py +++ b/tests/formatters_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -13,6 +13,6 @@ def test_string_name(): chars = "!@#$%^&*().," value = "H!e(l@l#o.W$o%r^l&d*" - assert ( - string_name(value, characters=chars) == "H_e_l_l_o_W_o_r_l_d_" - ), "string_name validator failed" + assert string_name(value, characters=chars) == "H_e_l_l_o_W_o_r_l_d_", ( + "string_name validator failed" + ) diff --git a/tests/iso_surfaces_test.py b/tests/iso_surfaces_test.py index 3cc749971..f73a49c34 100644 --- a/tests/iso_surfaces_test.py +++ b/tests/iso_surfaces_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/preprocessing_test.py b/tests/preprocessing_test.py index 1cd1ecba9..97b181b93 100644 --- a/tests/preprocessing_test.py +++ b/tests/preprocessing_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/pyproject_test.py b/tests/pyproject_test.py index 5c7e2c27d..5749e793f 100644 --- a/tests/pyproject_test.py +++ b/tests/pyproject_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/run_tests/apps_inversion_test.py b/tests/run_tests/apps_inversion_test.py index 5ed30bbea..7871f1fc0 100644 --- a/tests/run_tests/apps_inversion_test.py +++ b/tests/run_tests/apps_inversion_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -42,6 +42,7 @@ PROJECT_TEM, ) + # import pytest # pytest.skip("eliminating conflicting test.", allow_module_level=True) @@ -208,7 +209,7 @@ def test_dc_inversion(tmp_path: Path): app.write_trigger(None) app.write_trigger(None) # Check that this can run more than once - ifile = InputFile.read_ui_json(getattr(app, "_run_params").input_file.path_name) + ifile = InputFile.read_ui_json(app._run_params.input_file.path_name) params_reload = DirectCurrent3DParams(ifile) @@ -223,9 +224,9 @@ def test_dc_inversion(tmp_path: Path): for param, value in side_effects.items(): p_value = getattr(params_reload, param) p_value = p_value.uid if isinstance(p_value, Entity) else p_value - assert ( - p_value == value - ), f"Side effect parameter {param} not saved and loaded correctly." + assert p_value == value, ( + f"Side effect parameter {param} not saved and loaded correctly." + ) # Test the groups groups = [ @@ -239,15 +240,15 @@ def test_dc_inversion(tmp_path: Path): for group in groups: if "Constant" in getattr(app, "_" + group + "_group").options.options: setattr(app, group, 1.0) - assert ( - getattr(app, "_" + group + "_group").options.value == "Constant" - ), f"Property group {group} did not reset to 'Constant'" + assert getattr(app, "_" + group + "_group").options.value == "Constant", ( + f"Property group {group} did not reset to 'Constant'" + ) if "None" in getattr(app, "_" + group + "_group").options.options: setattr(app, group, None) - assert ( - getattr(app, "_" + group + "_group").options.value == "None" - ), f"Property group {group} did not reset to 'None'" + assert getattr(app, "_" + group + "_group").options.value == "None", ( + f"Property group {group} did not reset to 'None'" + ) def test_ip_inversion(tmp_path: Path): @@ -288,7 +289,7 @@ def test_ip_inversion(tmp_path: Path): setattr(app, param, value) app.write_trigger(None) - ifile = InputFile.read_ui_json(getattr(app, "_run_params").input_file.path_name) + ifile = InputFile.read_ui_json(app._run_params.input_file.path_name) params_reload = InducedPolarization3DParams(ifile) for param, value in changes.items(): @@ -297,16 +298,16 @@ def test_ip_inversion(tmp_path: Path): if param == "chargeability_channel": assert p_value != value and is_uuid(p_value) else: - assert ( - p_value == value - ), f"Parameter {param} not saved and loaded correctly." + assert p_value == value, ( + f"Parameter {param} not saved and loaded correctly." + ) for param, value in side_effects.items(): p_value = getattr(params_reload, param) p_value = p_value.uid if isinstance(p_value, Entity) else p_value - assert ( - p_value == value - ), f"Side effect parameter {param} not saved and loaded correctly." + assert p_value == value, ( + f"Side effect parameter {param} not saved and loaded correctly." + ) groups = [ "topography", @@ -320,15 +321,15 @@ def test_ip_inversion(tmp_path: Path): for group in groups: if "Constant" in getattr(app, "_" + group + "_group").options.options: setattr(app, group, 1.0) - assert ( - getattr(app, "_" + group + "_group").options.value == "Constant" - ), f"Property group {group} did not reset to 'Constant'" + assert getattr(app, "_" + group + "_group").options.value == "Constant", ( + f"Property group {group} did not reset to 'Constant'" + ) if "None" in getattr(app, "_" + group + "_group").options.options: setattr(app, group, None) - assert ( - getattr(app, "_" + group + "_group").options.value == "None" - ), f"Property group {group} did not reset to 'None'" + assert getattr(app, "_" + group + "_group").options.value == "None", ( + f"Property group {group} did not reset to 'None'" + ) def test_em1d_inversion(tmp_path: Path): diff --git a/tests/run_tests/apps_run_test.py b/tests/run_tests/apps_run_test.py index abbf5aeba..31c188b47 100644 --- a/tests/run_tests/apps_run_test.py +++ b/tests/run_tests/apps_run_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -39,6 +39,7 @@ from geoapps.utils.testing import get_output_workspace from tests import PROJECT, PROJECT_TEM + # import pytest # pytest.skip("eliminating conflicting test.", allow_module_level=True) diff --git a/tests/utils_test.py b/tests/utils_test.py index 30b309df8..f1ceaeef2 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' @@ -60,6 +60,7 @@ from . import PROJECT + geoh5 = Workspace(PROJECT) @@ -355,7 +356,7 @@ def test_rectangular_block(): assert [0.0, pos, 5.0] in vertices with pytest.raises(ValueError) as error: - setattr(block, "center", -180.0) + block.center = -180.0 assert "Input value for 'center' must be a list of floats len(3)." in str(error) @@ -366,7 +367,7 @@ def test_rectangular_block(): assert f"Input value for '{attr}' must be a float >0." in str(error) with pytest.raises(ValueError) as error: - setattr(block, "dip", -180.0) + block.dip = -180.0 assert ( "Input value for 'dip' must be a float on the interval [-90, 90] degrees." @@ -374,7 +375,7 @@ def test_rectangular_block(): ) with pytest.raises(ValueError) as error: - setattr(block, "azimuth", -450.0) + block.azimuth = -450.0 assert ( "Input value for 'azimuth' must be a float on the interval [-360, 360] degrees." @@ -382,7 +383,7 @@ def test_rectangular_block(): ) with pytest.raises(ValueError) as error: - setattr(block, "reference", "abc") + block.reference = "abc" assert ( "Input value for 'reference' point should be a str from ['center', 'top']." @@ -436,7 +437,7 @@ def test_sorted_alphanumeric_list(): ] sorted_list = sorted_alphanumeric_list(random.sample(test, len(test))) - assert all(elem == tester for elem, tester in zip(sorted_list, test)) + assert all(elem == tester for elem, tester in zip(sorted_list, test, strict=False)) def test_no_warn_module_not_found(recwarn): @@ -553,15 +554,15 @@ def test_rotation_xyz(): vec = np.c_[1, 0, 0] rot_vec = rotate_xyz(vec, [0, 0], 45) - assert ( - np.linalg.norm(np.cross(rot_vec, [0.7071, 0.7071, 0])) < 1e-8 - ), "Error on positive rotation about origin." + assert np.linalg.norm(np.cross(rot_vec, [0.7071, 0.7071, 0])) < 1e-8, ( + "Error on positive rotation about origin." + ) rot_vec = rotate_xyz(vec, [1, 1], -90) - assert ( - np.linalg.norm(np.cross(rot_vec, [0, 1, 0])) < 1e-8 - ), "Error on negative rotation about point." + assert np.linalg.norm(np.cross(rot_vec, [0, 1, 0])) < 1e-8, ( + "Error on negative rotation about point." + ) def test_running_mean(): @@ -572,12 +573,12 @@ def test_running_mean(): mean_test = (vec[1:] + vec[:-1]) / 2 - assert ( - np.linalg.norm(mean_back[:-1] - mean_test) < 1e-12 - ), "Backward averaging does not match expected values." - assert ( - np.linalg.norm(mean_forw[1:] - mean_test) < 1e-12 - ), "Forward averaging does not match expected values." + assert np.linalg.norm(mean_back[:-1] - mean_test) < 1e-12, ( + "Backward averaging does not match expected values." + ) + assert np.linalg.norm(mean_forw[1:] - mean_test) < 1e-12, ( + "Forward averaging does not match expected values." + ) assert ( np.linalg.norm((mean_test[1:] + mean_test[:-1]) / 2 - mean_cent[1:-1]) < 1e-12 ), "Centered averaging does not match expected values." @@ -664,9 +665,7 @@ def test_treemesh_2_octree(tmp_path: Path): mesh.insert_cells([10, 10, 10], mesh.max_level, finalize=True) omesh = treemesh_2_octree(workspace, mesh, name="test_mesh") assert omesh.n_cells == mesh.n_cells - assert np.all( - (omesh.centroids - mesh.cell_centers[getattr(mesh, "_ubc_order")]) < 1e-14 - ) + assert np.all((omesh.centroids - mesh.cell_centers[mesh._ubc_order]) < 1e-14) expected_refined_cells = [ (0, 0, 6), (0, 0, 7), @@ -805,8 +804,9 @@ def test_filter_xy(): } # Test the windowing functionality w_mask = filter_xy(x_grid, y_grid, window=window) - x_grid_test, y_grid_test = x_grid[w_mask].reshape(5, 9), y_grid[w_mask].reshape( - 5, 9 + x_grid_test, y_grid_test = ( + x_grid[w_mask].reshape(5, 9), + y_grid[w_mask].reshape(5, 9), ) np.testing.assert_allclose( x_grid_test, np.meshgrid(np.arange(1, 10), np.arange(3, 8))[0] @@ -817,8 +817,9 @@ def test_filter_xy(): # Test the downsampling functionality ds_mask = filter_xy(x_grid, y_grid, distance=2) - x_grid_test, y_grid_test = x_grid[ds_mask].reshape(6, 6), y_grid[ds_mask].reshape( - 6, 6 + x_grid_test, y_grid_test = ( + x_grid[ds_mask].reshape(6, 6), + y_grid[ds_mask].reshape(6, 6), ) np.testing.assert_allclose(np.diff(x_grid_test, axis=1), np.full((6, 5), 2)) np.testing.assert_allclose(np.diff(y_grid_test, axis=0), np.full((5, 6), 2)) @@ -826,9 +827,10 @@ def test_filter_xy(): # Test the combo functionality comb_mask = filter_xy(x_grid, y_grid, distance=2, window=window) assert np.all(comb_mask == (w_mask & ds_mask)) - x_grid_test, y_grid_test = x_grid[comb_mask].reshape(2, 4), y_grid[ - comb_mask - ].reshape(2, 4) + x_grid_test, y_grid_test = ( + x_grid[comb_mask].reshape(2, 4), + y_grid[comb_mask].reshape(2, 4), + ) assert np.all((x_grid_test >= 1) & (x_grid_test <= 9)) assert np.all((y_grid_test >= 3) & (y_grid_test <= 7)) np.testing.assert_allclose(np.diff(x_grid_test, axis=1), np.full((2, 3), 2)) @@ -838,8 +840,9 @@ def test_filter_xy(): combo_mask = filter_xy(x_grid_rot, y_grid_rot, distance=2, window=window, angle=-30) xg_test, yg_test = x_grid_rot[comb_mask], y_grid_rot[comb_mask] xy_rot = rotate_xyz(np.c_[xg_test, yg_test], [5, 5], -30) - x_grid_rot_test, y_grid_rot_test = xy_rot[:, 0].reshape(2, 4), xy_rot[:, 1].reshape( - 2, 4 + x_grid_rot_test, y_grid_rot_test = ( + xy_rot[:, 0].reshape(2, 4), + xy_rot[:, 1].reshape(2, 4), ) assert np.all((x_grid_rot_test >= 1) & (x_grid_rot_test <= 9)) assert np.all((y_grid_rot_test >= 3) & (y_grid_rot_test <= 7)) @@ -936,7 +939,7 @@ def test_get_neighbouring_cells(): neighbours = get_neighbouring_cells(mesh, [ind]) assert len(neighbours) == 3, "Incorrect number of neighbours axes returned." - assert all( - len(axis) == 2 for axis in neighbours - ), "Incorrect number of neighbours returned." + assert all(len(axis) == 2 for axis in neighbours), ( + "Incorrect number of neighbours returned." + ) assert np.allclose(np.r_[neighbours].flatten(), np.r_[76, 78, 75, 79, 73, 81]) diff --git a/tests/version_test.py b/tests/version_test.py index 839454084..a58cebb42 100644 --- a/tests/version_test.py +++ b/tests/version_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # ' diff --git a/tests/write_default_uijson_test.py b/tests/write_default_uijson_test.py index 882781720..0c18d6dd6 100644 --- a/tests/write_default_uijson_test.py +++ b/tests/write_default_uijson_test.py @@ -1,5 +1,5 @@ # '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' -# Copyright (c) 2024 Mira Geoscience Ltd. ' +# Copyright (c) 2024-2025 Mira Geoscience Ltd. ' # ' # This file is part of geoapps. ' # '