Skip to content

Commit

Permalink
fix: Skip interpolation validator if tracing for autograd
Browse files Browse the repository at this point in the history
  • Loading branch information
yaugenst-flex authored and tylerflex committed Jun 3, 2024
1 parent 2cf9de0 commit fb44160
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions tidy3d/components/data/data_array.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Storing tidy3d data at it's most fundamental level as xr.DataArray objects"""

from __future__ import annotations
from typing import Dict, List, Union
from abc import ABC
Expand Down Expand Up @@ -113,9 +114,17 @@ def assign_data_attrs(cls, val):
return val

def _interp_validator(self, field_name: str = None) -> None:
"""Make sure we can interp()/sel() the data."""
# NOTE: this does not check every 'DataArray' by default. Instead, when required, this check can be
# called from a validator, as is the case with 'CustomMedium' and 'CustomFieldSource'.
"""Make sure we can interp()/sel() the data.
NOTE
----
This does not check every 'DataArray' by default. Instead, when required, this check can be
called from a validator, as is the case with 'CustomMedium' and 'CustomFieldSource'.
"""
# skip this validator if currently tracing for autograd because
# self.values will be dtype('object') and not interpolatable
if isbox(self.values.flat[0]):
return

if field_name is None:
field_name = "DataArray"
Expand Down

0 comments on commit fb44160

Please sign in to comment.