Skip to content

Commit 5452e3f

Browse files
yaugenst-flexmomchil-flex
authored andcommitted
fix: xarray 2024.10 compatibility
1 parent 4e794af commit 5452e3f

File tree

5 files changed

+10
-11
lines changed

5 files changed

+10
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
### Fixed
1818
- Regression in local field projection leading to incorrect results for `far_field_approx=True`.
1919
- Bug when differentiating with respect to `Cylinder.center`.
20+
- `xarray` 2024.10.0 compatibility for autograd.
2021

2122

2223
## [2.7.6] - 2024-10-30

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ipython = { version = "*", optional = true }
5757
memory_profiler = { version = "*", optional = true }
5858
pre-commit = { version = "*", optional = true }
5959
pylint = { version = "*", optional = true }
60-
pytest = { version = "*", optional = true }
60+
pytest = { version = ">=8.1", optional = true }
6161
pytest-timeout = { version = "*", optional = true }
6262
tox = { version = "*", optional = true }
6363

tidy3d/components/autograd/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import autograd.numpy as anp
2-
from autograd.extend import VJPNode, register_notrace
3-
41
from .boxes import TidyArrayBox
52
from .functions import interpn
63
from .types import (
@@ -14,8 +11,6 @@
1411
)
1512
from .utils import get_static, is_tidy_box, split_list
1613

17-
register_notrace(VJPNode, anp.full_like)
18-
1914
__all__ = [
2015
"TidyArrayBox",
2116
"TracedFloat",

tidy3d/components/autograd/boxes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
1-
# Adds some functionality to the autograd arraybox
2-
# NOTE: this is not a subclass of ArrayBox since that would break autograd's internal checks
1+
# Adds some functionality to the autograd arraybox and related autograd patches
2+
# NOTE: we do not subclass ArrayBox since that would break autograd's internal checks
33

44
import importlib
55
from typing import Any, Callable, Dict, List, Tuple
66

77
import autograd.numpy as anp
8-
from autograd.extend import defjvp
8+
from autograd.extend import VJPNode, defjvp, register_notrace
99
from autograd.numpy.numpy_boxes import ArrayBox
1010
from autograd.numpy.numpy_wrapper import _astype
1111

1212
TidyArrayBox = ArrayBox # NOT a subclass
1313

1414
_autograd_module_cache = {} # cache for imported autograd modules
1515

16+
register_notrace(VJPNode, anp.full_like)
17+
1618
defjvp(
1719
_astype,
1820
lambda g, ans, A, dtype, order="K", casting="unsafe", subok=True, copy=True: _astype(g, dtype),
1921
)
2022

2123
anp.astype = _astype
24+
anp.permute_dims = anp.transpose
2225

2326

2427
@classmethod

0 commit comments

Comments
 (0)