Skip to content

Commit 4b89d67

Browse files
authored
Update randomizeop.py
1 parent 6ed75c7 commit 4b89d67

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

kaleidoscope/operators/randomizeop.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,25 +132,26 @@ def run(self, source: Dataset) -> Dataset: # noqa: D102
132132
_decode(b.data, b.attrs),
133133
clip=a.get("clip", None),
134134
)
135-
if get_logger().is_enabled(Logging.DEBUG):
136-
get_logger().debug(f"min: {da.nanmin(z).compute() :.3f}")
137-
get_logger().debug(f"max: {da.nanmax(z).compute() :.3f}")
138-
get_logger().debug(f"mean: {da.nanmean(z).compute() :.3f}")
139-
get_logger().debug(f"std: {da.nanstd(z).compute() :.3f}")
140135
target[v] = DataArray(
141136
data=z, coords=x.coords, dims=x.dims, attrs=x.attrs
142137
)
138+
if "actual_range" in target[v].attrs:
139+
target[v].attrs["actual_range"] = np.array(
140+
[
141+
da.nanmin(z).compute(),
142+
da.nanmax(z).compute(),
143+
],
144+
dtype=z.dtype,
145+
)
143146
target[v].attrs["dtype"] = x.dtype
144-
target[v].attrs["actual_range"] = np.array(
145-
[
146-
da.nanmin(z).compute(),
147-
da.nanmax(z).compute(),
148-
],
149-
dtype=z.dtype,
150-
)
151147
target[v].attrs["entropy"] = np.array(
152148
self.entropy(v, source_id), dtype=np.int64
153149
)
150+
if get_logger().is_enabled(Logging.DEBUG):
151+
get_logger().debug(f"min: {da.nanmin(z).compute() :.3f}")
152+
get_logger().debug(f"max: {da.nanmax(z).compute() :.3f}")
153+
get_logger().debug(f"mean: {da.nanmean(z).compute() :.3f}")
154+
get_logger().debug(f"std: {da.nanstd(z).compute() :.3f}")
154155
get_logger().info(f"finished graph for variable: {v}")
155156
return target
156157

0 commit comments

Comments
 (0)