Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
abbef84
Linting: Fix f-string (UP032)
kopperp Mar 13, 2026
0c893d2
Linting: Fix in-dict-keys (SIM118)
kopperp Mar 13, 2026
f2a14a5
Linting: Fix useless-return (PLR1711)
kopperp Mar 13, 2026
96e8082
Linting: Fix unnecessary-class-parentheses (UP039)
kopperp Mar 13, 2026
2cf3d00
Linting: Fix unnecessary-assign (RET504)
kopperp Mar 13, 2026
d7dd94c
Linting: Fix unnecessary-collection-call (C408)
kopperp Mar 13, 2026
23498b3
Linting: Fix printf-string-formatting (UP031)
kopperp Mar 13, 2026
d537b50
Linting: Fix non-pep585-annotation (UP006)
kopperp Mar 13, 2026
d011766
Linting: Fix try-consider-else (TRY300)
kopperp Mar 13, 2026
90d6996
Linting: Fix set-attr-with-constant (B010)
kopperp Mar 13, 2026
5be81a9
Linting: Fix loop-variable-overrides-iterator (B020)
kopperp Mar 13, 2026
1f15f90
Linting: Ignore dict-index-missing-items (PLC0206)
kopperp Mar 13, 2026
6773d60
Linting: Ignore unnecessary-iterable-allocation-for-first-element (RU…
kopperp Mar 13, 2026
f4d73cd
Linting: Fix incorrect-dict-iterator (PERF102)
kopperp Mar 13, 2026
f26b090
Linting: Fix deprecated-import (UP035)
kopperp Mar 13, 2026
058c50a
Linting: Fix manual-list-comprehension (PERF401)
kopperp Mar 13, 2026
9c85239
Linting: Fix collapsible-if (SIM102)
kopperp Mar 13, 2026
b492fd9
Linting: Fix comparison-of-constant (PLR0133)
kopperp Mar 13, 2026
7b7e668
Linting: Fix unnecessary-literal-within-tuple-call (C409)
kopperp Mar 13, 2026
160889d
Linting: Fix format-literals (UP030)
kopperp Mar 13, 2026
d525948
Linting: Fix unnecessary-map (C417)
kopperp Mar 13, 2026
496b9b9
Linting: Fix unnecessary-generator-set (C401)
kopperp Mar 13, 2026
cbdfbeb
Linting: Fix unnecessary-literal-set (C405)
kopperp Mar 13, 2026
05251c0
Linting: Fix unnecessary-list-comprehension-set (C403)
kopperp Mar 13, 2026
bb21cb4
Linting: Ignore open-file-with-context-handler (SIM115)
kopperp Mar 13, 2026
c01b36f
Linting: Fix unnecessary-comprehension-in-call (C419)
kopperp Mar 13, 2026
62cc374
Linting: Fix self-assigning-variable (PLW0127)
kopperp Mar 13, 2026
bca7b44
Linting: Ignore mutable-class-default (RUF012)
kopperp Mar 13, 2026
12ecf38
Linting: Fix quoted-annotation (UP037)
kopperp Mar 13, 2026
a3b3782
Linting: Fix unsorted-dunder-slots (RUF023)
kopperp Mar 13, 2026
9a9a64b
Linting: Ignore native-literals (UP018)
kopperp Mar 13, 2026
92c1792
Linting: Fix unnecessary-double-cast-or-process (C414)
kopperp Mar 13, 2026
250934d
Linting: Fix cached-instance-method (B019)
kopperp Mar 13, 2026
ecab4a6
Linting: Fix if-else-block-instead-of-dict-get (SIM401)
kopperp Mar 13, 2026
d38e8d2
Linting: Fix if-expr-with-true-false (SIM210)
kopperp Mar 13, 2026
4fdd99d
Linting: Fix multiple-with-statements (SIM117)
kopperp Mar 13, 2026
19d482d
Linting: Fix function-uses-loop-variable (B023)
kopperp Mar 13, 2026
395b3e6
Linting: Fix subprocess-run-without-check (PLW1510)
kopperp Mar 13, 2026
734e3d3
Linting: Fix replace-stdout-stderr (UP022)
kopperp Mar 13, 2026
d7628e0
Linting: Fix zip-without-explicit-strict (B905)
kopperp Mar 13, 2026
99b2755
Linting: Fix raise-without-from-inside-except (B904)
kopperp Mar 13, 2026
ceb7fb4
Linting: Fix unused-loop-control-variable (B007)
kopperp Mar 13, 2026
bfb7473
Linting: Fix loop-iterator-mutation (B909)
kopperp Mar 13, 2026
17a1243
Linting: Fix if-else-block-instead-of-if-exp (SIM108)
kopperp Mar 13, 2026
28872f0
Linting: Fix dict-get-with-none-default (SIM910)
kopperp Mar 13, 2026
d2560d6
Linting: Fix superfluous-else-return (RET505)
kopperp Mar 13, 2026
0ea3100
Linting: Fix superfluous-else-continue (RET507)
kopperp Mar 13, 2026
a36e785
Linting: Fix unnecessary-placeholder (PIE790)
kopperp Mar 13, 2026
532c656
Linting: Fix repeated-append (FURB113)
kopperp Mar 13, 2026
3303019
Linting: Fix write-whole-file (FURB103)
kopperp Mar 13, 2026
616d2e6
Linting: Fix for-loop-set-mutations (FURB142)
kopperp Mar 13, 2026
d517ac0
Linting: Fix unnecessary-enumerate (FURB148)
kopperp Mar 13, 2026
308bc6f
Linting: Fix missing-f-string-syntax (RUF027)
kopperp Mar 13, 2026
609ccf7
Linting: Fix collection-literal-concatenation (RUF005)
kopperp Mar 13, 2026
7fcea26
Linting: Fix read-whole-file (FURB101)
kopperp Mar 13, 2026
be5f3a6
Linting: Fix if-else-block-instead-of-if-exp (SIM108)
kopperp Mar 13, 2026
abdd6ec
Linting: Fix unnecessary-comprehension (C416)
kopperp Mar 13, 2026
aa0d41e
Linting: Upgrade pyproject.toml
kopperp Mar 13, 2026
1f45823
Linting: Fix no-matching-overload
kopperp Mar 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions pyhope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,27 @@
# Standard libraries
# ----------------------------------------------------------------------------------------------------------------------------------
from collections import namedtuple
from collections.abc import Callable
from contextlib import contextmanager
from functools import update_wrapper
from typing import final
from typing import ParamSpec, TypeVar
# ----------------------------------------------------------------------------------------------------------------------------------
# Third-party libraries
# ----------------------------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------------------------
# Local imports
# ----------------------------------------------------------------------------------------------------------------------------------
P = ParamSpec('P')
R = TypeVar( 'R')
# ==================================================================================================================================


def _staticwrapper(func):
def _staticwrapper(func: Callable[P, R]) -> Callable[P, R]:
""" Custom helper to lift the (annotations, doc, etc.) to the staticmethod
"""
# Create a wrapper that carries the metadata
def wrapper(*args, **kwargs):
def wrapper(*args: P.args, **kwargs: P.kwargs) -> R:
return func(*args, **kwargs)

# Lift metadata (annotations, doc, etc.) to the wrapper
Expand Down Expand Up @@ -150,34 +154,33 @@ def Mesh(*args: str, stdout: bool = False, stderr: bool = True):
raise ValueError(f'Mesh file not a valid HDF5 file: {arg}')

# Suppress output to standard output
with ExitStack() as stack:
with open(os.devnull, 'w') as null:
if not stdout:
stack.enter_context(redirect_stdout(null))
if not stderr:
stack.enter_context(redirect_stderr(null))

# Perform the reduced PyHOPE initialization
with DefineConfig() as dc:
config.prms = dc
DefineCommon()
DefineIO()
DefineMesh()

with ReadConfig(args[0]) as rc:
config.params = rc

# Read-in required parameters
InitCommon()
InitIO()
InitMesh()

# Generate the actual mesh
GenerateMesh()

# Build our data structures
GenerateSides()
ConnectMesh()
with ExitStack() as stack, open(os.devnull, 'w') as null:
if not stdout:
stack.enter_context(redirect_stdout(null))
if not stderr:
stack.enter_context(redirect_stderr(null))

# Perform the reduced PyHOPE initialization
with DefineConfig() as dc:
config.prms = dc
DefineCommon()
DefineIO()
DefineMesh()

with ReadConfig(args[0]) as rc:
config.params = rc

# Read-in required parameters
InitCommon()
InitIO()
InitMesh()

# Generate the actual mesh
GenerateMesh()

# Build our data structures
GenerateSides()
ConnectMesh()

# Export mesh variables
mesh = mesh_vars.mesh
Expand Down
26 changes: 13 additions & 13 deletions pyhope/basis/basis_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def check_sides(elem,
# Sanity check the flip with the other nodes
elem0 = elems[side[0].elemID]
elem1 = elems[side[1].elemID]
if elem1.type % 100 != 8:
if elem1.type % 10 != 8:
continue

# Map the meshio nodes to the tensor-product nodes
Expand All @@ -95,7 +95,7 @@ def check_sides(elem,
try:
# Translate to periodic nodes if required
if side[0].bcid is not None and side[1].bcid is not None and bcs[side[1].bcid].type[0] == 1:
nbNodes = np.vectorize(lambda s: mesh_vars.periNodes[(s, bcs[side[1].bcid].name)], otypes=[int])(nbNodes)
nbNodes = np.vectorize(lambda s, side=side: mesh_vars.periNodes[(s, bcs[side[1].bcid].name)], otypes=[int])(nbNodes)
# Check if the node IDs match
success = np.array_equal(nodes, nbNodes)
# Fallback to comparison of physical coordinates
Expand Down Expand Up @@ -157,8 +157,8 @@ def CheckConnect() -> None:
elems: Final[list] = mesh_vars.elems

# Only consider hexahedrons
if any(cast(int, e.type) % 100 != 8 for e in elems):
elemTypes = list(set([e.type for e in elems if e.type % 100 != 8]))
if any(cast(int, e.type) % 10 != 8 for e in elems):
elemTypes = list({e.type for e in elems if e.type % 10 != 8})
print(hopout.warn('Ignored element type: {}'.format(
[re.sub(r"\d+$", "", mesh_vars.ELEMTYPE.inam[e][0]) for e in elemTypes]
)))
Expand Down Expand Up @@ -192,7 +192,7 @@ def CheckConnect() -> None:
if side.connection is None or side.sideType < 0:
continue
# Big mortar side is counted once
elif side.connection < 0:
if side.connection < 0:
nconn += 1
# Internal side: only count the canonical representative and ignore virtual mortar sides
elif side.connection >= 0:
Expand Down Expand Up @@ -220,16 +220,16 @@ def CheckConnect() -> None:
# Print the information
strLen = max(len(str(side.sideID+1)), len(str(nbside.sideID+1)))
print(hopout.warn(f'> Element { elem.elemID+1:>{strLen}}, Side { side.face}, Side { side.sideID+1:>{strLen}}')) # noqa: E501
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[-1, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[-1, -1]]) + ']')) # noqa: E271
# print()
print(hopout.warn(f'> Element {nbelem.elemID+1:>{strLen}}, Side {nbside.face}, Side {nbside.sideID+1:>{strLen}}')) # noqa: E501
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[-1, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[-1, -1]]) + ']')) # noqa: E271

hopout.warning(f'Connectivity check failed for {len(results)} / {nconn} connections!')
sys.exit(1)
11 changes: 5 additions & 6 deletions pyhope/basis/basis_jacobian.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@
def evaluate_jacobian_dispatch(nodeCoords, VdmGLtoAP, D_EqToGL, elem_type):
if elem_type in SIMPLEX_TYPES:
return evaluate_jacobian_simplex(nodeCoords, VdmGLtoAP, D_EqToGL)
elif elem_type == HEX_TYPE:
if elem_type == HEX_TYPE:
return evaluate_jacobian( nodeCoords, VdmGLtoAP, D_EqToGL)
else:
raise ValueError(f"Unsupported element type {elem_type}")
raise ValueError(f"Unsupported element type {elem_type}")


def plot_histogram(data: npt.NDArray[np.float64]) -> None:
Expand Down Expand Up @@ -155,7 +154,7 @@ def CheckJacobians() -> None:
nGeo: Final[int] = mesh_vars.nGeo + 1
elems: Final[list] = mesh_vars.elems
nodes: Final[npt.NDArray[np.float64]] = mesh_vars.mesh.points
elemBases: Final[set] = set([e.type % 100 for e in elems])
elemBases: Final[set] = {e.type % 10 for e in elems}

# Compute the equidistant point set used by meshIO
xEq_fn = {4: lambda: equi_nodes_tetra(nGeo), # Tetrahedron
Expand Down Expand Up @@ -201,7 +200,7 @@ def CheckJacobians() -> None:
# Pre-compute LINTEN mappings for all element types
linCache = {}
elemOrder = 100 if mesh_vars.nGeo == 1 else 200
elemTypes = tuple([s + elemOrder for s in elemBases])
elemTypes = tuple(s + elemOrder for s in elemBases)
for elemType in elemTypes:
try:
_, mapLin = LINTEN(elemType, order=mesh_vars.nGeo)
Expand All @@ -213,7 +212,7 @@ def CheckJacobians() -> None:

for elem in elems:
elemType = elem.type
elemBase = int(elemType) % 100
elemBase = int(elemType) % 10

# Get the mapping
mapLin = linCache[elemType]
Expand Down
30 changes: 15 additions & 15 deletions pyhope/basis/basis_watertight.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def check_sides(elem,
continue

# Big mortar side
elif side.connection < 0:
if side.connection < 0:
mortarType = abs(side.connection)
# INFO: This should be faster but I could not confirm the speedup in practice
# nSurf = eval_nsurf(np.moveaxis( points[ nodes], 2, 0), VdmEqToGP, DGP, weights)
Expand Down Expand Up @@ -288,8 +288,8 @@ def CheckWatertight() -> None:
# checked = np.zeros((len(sides)), dtype=bool)

# Only consider hexahedrons
if any(e.type % 100 != 8 for e in elems):
elemTypes = list(set([e.type for e in elems if e.type % 100 != 8]))
if any(e.type % 10 != 8 for e in elems):
elemTypes = list({e.type for e in elems if e.type % 10 != 8})
print(hopout.warn('Ignored element type: {}'.format(
[re.sub(r"\d+$", "", mesh_vars.ELEMTYPE.inam[e][0]) for e in elemTypes]
)))
Expand Down Expand Up @@ -323,7 +323,7 @@ def CheckWatertight() -> None:
if side.connection is None or side.sideType < 0:
continue
# Big mortar side is counted once
elif side.connection < 0:
if side.connection < 0:
nconn += 1
# Internal side: only count the canonical representative and ignore virtual mortar sides
elif side.connection >= 0:
Expand All @@ -348,24 +348,24 @@ def CheckWatertight() -> None:
print()
# Check if side is oriented inwards
errStr = 'Side is oriented inwards!' if nSurfErr < 0 \
else 'Surface normals are not within tolerance {:9.6e} > {:9.6e}'.format(nSurfErr, tol)
else f'Surface normals are not within tolerance {nSurfErr:9.6e} > {tol:9.6e}'
print(hopout.warn(errStr, length=len(errStr)+16))

# Print the information
strLen = max(len(str(side.sideID+1)), len(str(nbside.sideID+1)))
print(hopout.warn(f'> Element { elem.elemID+1:>{strLen}}, Side { side.face}, Side { side.sideID+1:>{strLen}}')) # noqa: E501
print(hopout.warn('> Normal vector: [' + ' '.join('{:12.3f}'.format(s) for s in nSurf) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[ nodes[-1, -1]]) + ']')) # noqa: E271
print(hopout.warn('> Normal vector: [' + ' '.join(f'{s:12.3f}' for s in nSurf) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[ nodes[-1, -1]]) + ']')) # noqa: E271
# print()
print(hopout.warn(f'> Element {nbelem.elemID+1:>{strLen}}, Side {nbside.face}, Side {nbside.sideID+1:>{strLen}}')) # noqa: E501
print(hopout.warn('> Normal vector: [' + ' '.join('{:12.3f}'.format(s) for s in nbnSurf) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join('{:12.3f}'.format(s) for s in points[nbnodes[-1, -1]]) + ']')) # noqa: E271
print(hopout.warn('> Normal vector: [' + ' '.join(f'{s:12.3f}' for s in nbnSurf) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[ 0, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[ 0, -1]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[-1, 0]]) + ']')) # noqa: E271
print(hopout.warn('- Coordinates : [' + ' '.join(f'{s:12.3f}' for s in points[nbnodes[-1, -1]]) + ']')) # noqa: E271

hopout.error(f'Watertightness check failed for {len(results)} / {nconn} connections!')

Expand Down
8 changes: 4 additions & 4 deletions pyhope/check/check_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def GmshVersion() -> tuple[Union[Version, bool, None], Union[str, None]]:

if path:
try:
p = subprocess.run([path, '--info'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=5)
p = subprocess.run([path, '--info'], capture_output=True, text=True, timeout=5, check=True)
raw = (p.stdout or '') + "\n" + (p.stderr or '')
# Parse version from the Version line if present
v = _ParseVersion(raw)
Expand Down Expand Up @@ -172,7 +172,7 @@ def DependencyVersion(program: str) -> Optional[Version | bool]:
if path:
for flag in ('--version', '-V', 'version', '-v'):
try:
p = subprocess.run([path, flag], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, timeout=5)
p = subprocess.run([path, flag], capture_output=True, text=True, timeout=5, check=True)
except Exception:
continue

Expand Down Expand Up @@ -339,7 +339,7 @@ def CheckHealth() -> None:
# For optional dependencies, split the first part
opts = [p.split(';')[0] for p in pkgs if len(p.split(';')) > 1] # noqa: E272

all_pkg_names = sorted(list(set([program] + [_PackageExtractName(p) for p in deps + opts])))
all_pkg_names = sorted(set([program] + [_PackageExtractName(p) for p in deps + opts]))

# Fetch all versions in parallel
with ThreadPoolExecutor(max_workers=10) as executor:
Expand All @@ -349,7 +349,7 @@ def CheckHealth() -> None:

# Query PyPI for all packages
pypi_results = list(executor.map(PyPIVersion, all_pkg_names))
pypi_map = dict(zip(all_pkg_names, pypi_results))
pypi_map = dict(zip(all_pkg_names, pypi_results, strict=True))

# Display system and packages sections
hopout.small_banner('System')
Expand Down
18 changes: 8 additions & 10 deletions pyhope/check/check_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# ----------------------------------------------------------------------------------------------------------------------------------
import h5py
import numpy as np
import pathlib
# ----------------------------------------------------------------------------------------------------------------------------------
# Local imports
# ----------------------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -102,9 +103,8 @@ def _make_request(url : str,
bar.title( '│ Downloading tests')
# Retry the request
continue
else:
# Re-raise other HTTP errors
raise
# Re-raise other HTTP errors
raise

apiURL = f'https://api.github.com/repos/{user}/{repo}/contents/{path}?ref={branch}'

Expand Down Expand Up @@ -145,8 +145,7 @@ def _make_request(url : str,
content = lfs_u.read()

# Write the final content (either regular file or LFS file) to disk
with open(subPath, 'wb') as f:
f.write(content)
pathlib.Path(subPath).write_bytes(content)

case 'dir':
# Recursively call the function for subdirectories
Expand Down Expand Up @@ -275,10 +274,9 @@ def CheckInstall(path: Optional[str] = None) -> None:

# Suppress output to standard output
try:
with open(os.devnull, 'w') as null, redirect_stdout(null):
# All code that should have silent stdout here
with ReadConfig(parameter) as rc:
params = rc
# All code that should have silent stdout here
with open(os.devnull, 'w') as null, redirect_stdout(null), ReadConfig(parameter) as rc:
params = rc
except Exception:
# Config read failed
bar.step()
Expand Down Expand Up @@ -374,7 +372,7 @@ def CheckInstall(path: Optional[str] = None) -> None:
# Load the stats from the TOML file
if h5stats is not None \
and tomlData is not None \
and key in tomlData.keys(): # noqa: E271, E272
and key in tomlData: # noqa: E271, E272
# Fallback tolerances:
if 'GlobalNodeIDs' in key:
# GlobalNodeIDs are susceptible to rounding issues
Expand Down
3 changes: 2 additions & 1 deletion pyhope/common/common_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
# ----------------------------------------------------------------------------------------------------------------------------------
import sys
import traceback
from collections.abc import Callable
from multiprocessing import Pool, Queue, Process
from typing import Callable, Union
from typing import Union
# ----------------------------------------------------------------------------------------------------------------------------------
# Third-party libraries
# ----------------------------------------------------------------------------------------------------------------------------------
Expand Down
Loading
Loading