Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-kirienko committed Feb 4, 2025
1 parent 9946ef0 commit 7d56bad
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
nox:
timeout-minutes: 180
timeout-minutes: 240
runs-on: ubuntu-latest
if: >
github.event_name == 'pull_request' ||
Expand Down
1 change: 1 addition & 0 deletions .idea/dictionaries/pavel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/jafit/mag.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def extract_H_c_B_r_BH_max(hm: npt.NDArray[np.float64], *, intrinsic: bool = Fal
x = x[(x[:, 0] <= 0) & (x[:, 1] >= 0)] # Keep only the second quadrant: H<=0, B>=0
if len(x) > 0:
H_c = np.abs(np.min(x[:, 0]))
# TODO: empirical data is often noisy and sparse, which causes this method to incur a large error.
# Interpolation could help with sparsity but not with noise.
# Perhaps we could use a high-order least-squares polynomial fit here?
BH_max = -np.min(x[:, 0] * x[:, 1])
else:
H_c, BH_max = 0, 0
Expand Down
4 changes: 2 additions & 2 deletions src/jafit/opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def cb(intermediate_result: opt.OptimizeResult) -> None:
_logger.info("Global optimization result:\n%s", res)
# We have to check is_done because an early stop is considered an error by the optimizer (strange but true).
if res.success or (is_done and np.all(np.isfinite(res.x))):
return conv(res.x)
return conv(res.x) # type: ignore
raise RuntimeError(f"Global optimization failed: {res.message}")


Expand Down Expand Up @@ -197,7 +197,7 @@ def cb(intermediate_result: opt.OptimizeResult) -> None:

_logger.info("Local optimization result:\n%s", res)
if res.success or (is_done and np.all(np.isfinite(res.x))):
return conv(res.x)
return conv(res.x) # type: ignore
raise RuntimeError(f"Local optimization failed: {res.message}")


Expand Down

0 comments on commit 7d56bad

Please sign in to comment.