fix: Extract fixes incl. draw, array-copy on export.
parent
785995117e
commit
badadfbfc2
|
@ -109,6 +109,7 @@ ignore = [
|
||||||
"ERA001", # 'Commented-out code' seems to be just about anything to ruff
|
"ERA001", # 'Commented-out code' seems to be just about anything to ruff
|
||||||
"F722", # jaxtyping uses type annotations that ruff sees as "syntax error"
|
"F722", # jaxtyping uses type annotations that ruff sees as "syntax error"
|
||||||
"N806", # Sometimes we like using types w/uppercase in functions, sue me
|
"N806", # Sometimes we like using types w/uppercase in functions, sue me
|
||||||
|
"RUF001", # We use a lot of unicode, yes, on purpose!
|
||||||
|
|
||||||
# Line Length - Controversy Incoming
|
# Line Length - Controversy Incoming
|
||||||
## Hot Take: Let the Formatter Worry about Line Length
|
## Hot Take: Let the Formatter Worry about Line Length
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
"""Declares `ExtractDataNode`."""
|
||||||
|
|
||||||
import enum
|
import enum
|
||||||
import typing as typ
|
import typing as typ
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
import jax
|
import jax
|
||||||
import jax.numpy as jnp
|
import numpy as np
|
||||||
import sympy.physics.units as spu
|
import sympy.physics.units as spu
|
||||||
import tidy3d as td
|
import tidy3d as td
|
||||||
|
|
||||||
|
@ -246,9 +248,17 @@ class ExtractDataNode(base.MaxwellSimNode):
|
||||||
row = col.row()
|
row = col.row()
|
||||||
box = row.box()
|
box = row.box()
|
||||||
grid = box.grid_flow(row_major=True, columns=2, even_columns=True)
|
grid = box.grid_flow(row_major=True, columns=2, even_columns=True)
|
||||||
for monitor_name, monitor_type in self.sim_data_monitor_nametype.items():
|
if has_sim_data:
|
||||||
grid.label(text=monitor_name)
|
for (
|
||||||
grid.label(text=monitor_type)
|
monitor_name,
|
||||||
|
monitor_type,
|
||||||
|
) in self.sim_data_monitor_nametype.items():
|
||||||
|
grid.label(text=monitor_name)
|
||||||
|
grid.label(text=monitor_type.replace('Data', ''))
|
||||||
|
elif has_monitor_data:
|
||||||
|
for component_name in self.monitor_data_components:
|
||||||
|
grid.label(text=component_name)
|
||||||
|
grid.label(text=self.monitor_data_type)
|
||||||
|
|
||||||
####################
|
####################
|
||||||
# - Events
|
# - Events
|
||||||
|
@ -319,6 +329,7 @@ class ExtractDataNode(base.MaxwellSimNode):
|
||||||
"""Compute `Data:Array` by querying an array-like attribute of `Monitor Data`, then constructing an `ct.ArrayFlow`.
|
"""Compute `Data:Array` by querying an array-like attribute of `Monitor Data`, then constructing an `ct.ArrayFlow`.
|
||||||
|
|
||||||
Uses the internal `xarray` data returned by Tidy3D.
|
Uses the internal `xarray` data returned by Tidy3D.
|
||||||
|
By using `np.array` on the `.data` attribute of the `xarray`, instead of the usual JAX array constructor, we should save a (possibly very big) copy.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
The attribute to query is read directly from `self.extract_filter`.
|
The attribute to query is read directly from `self.extract_filter`.
|
||||||
|
@ -335,8 +346,7 @@ class ExtractDataNode(base.MaxwellSimNode):
|
||||||
xarray_data = getattr(
|
xarray_data = getattr(
|
||||||
input_sockets['Monitor Data'], props['extract_filter']
|
input_sockets['Monitor Data'], props['extract_filter']
|
||||||
)
|
)
|
||||||
return ct.ArrayFlow(values=jnp.array(xarray_data.data), unit=None)
|
return ct.ArrayFlow(values=np.array(xarray_data.data), unit=None)
|
||||||
## TODO: Try np.array instead, as it removes a copy, while still (I believe) being JIT-compatible.
|
|
||||||
|
|
||||||
return ct.FlowSignal.FlowPending
|
return ct.FlowSignal.FlowPending
|
||||||
|
|
||||||
|
@ -373,6 +383,11 @@ class ExtractDataNode(base.MaxwellSimNode):
|
||||||
kind=ct.FlowKind.Params,
|
kind=ct.FlowKind.Params,
|
||||||
)
|
)
|
||||||
def compute_data_params(self) -> ct.ParamsFlow:
|
def compute_data_params(self) -> ct.ParamsFlow:
|
||||||
|
"""Declare an empty `Data:Params`, to indicate the start of a function-composition pipeline.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A completely empty `ParamsFlow`, ready to be composed.
|
||||||
|
"""
|
||||||
return ct.ParamsFlow()
|
return ct.ParamsFlow()
|
||||||
|
|
||||||
@events.computes_output_socket(
|
@events.computes_output_socket(
|
||||||
|
|
|
@ -375,7 +375,6 @@ class CachedBLProperty:
|
||||||
return
|
return
|
||||||
|
|
||||||
if value == Signal.InvalidateCache:
|
if value == Signal.InvalidateCache:
|
||||||
log.critical('![%s] Invalidating %s', str(bl_instance), str(self))
|
|
||||||
self._invalidate_cache(bl_instance)
|
self._invalidate_cache(bl_instance)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -577,7 +576,6 @@ class BLField:
|
||||||
Thus, whenever the user wants the items in the enum to update, they must manually set the descriptor attribute to the value `Signal.ResetEnumItems`.
|
Thus, whenever the user wants the items in the enum to update, they must manually set the descriptor attribute to the value `Signal.ResetEnumItems`.
|
||||||
"""
|
"""
|
||||||
if self._enum_cb_cache.get(_self.instance_id) is None:
|
if self._enum_cb_cache.get(_self.instance_id) is None:
|
||||||
log.critical('REGEN ENUM')
|
|
||||||
# Retrieve Dynamic Enum Items
|
# Retrieve Dynamic Enum Items
|
||||||
enum_items = self._enum_cb(_self, context)
|
enum_items = self._enum_cb(_self, context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue