@@ -148,6 +148,9 @@ def run(self, source: Dataset) -> Dataset: # noqa: D102
148148 ],
149149 dtype = z .dtype ,
150150 )
151+ target [v ].attrs ["kaleidoscope_entropy" ] = np .array (
152+ self .entropy (v , source_id )
153+ )
151154 get_logger ().info (f"finished graph for variable: { v } " )
152155 return target
153156
@@ -162,20 +165,20 @@ def config(self) -> dict[str : dict[str:Any]]:
162165 config = json .load (r )
163166 return config
164167
165- def entropy (self , vid : str , did : str , n : int = 8 ) -> list [int ]:
168+ def entropy (self , name : str , uuid : str , n : int = 8 ) -> list [int ]:
166169 """
167170 Returns the entropy of the seed sequence used for a given variable.
168171
169172 Entropy is generated using the Philox bit generator, which produces
170173 truly independent sequences for different values of the seed.
171174
172- :param vid : The variable ID .
173- :param did : The dataset ID .
175+ :param name : The variable name .
176+ :param uuid : The dataset UUID .
174177 :param n: The length of the seed sequence.
175178 :return: The entropy.
176179 """
177180 from numpy .random import Philox
178181
179- seed = _hash (f"{ vid } -{ did } " ) + self ._args .selector
182+ seed = _hash (f"{ name } -{ uuid } " ) + self ._args .selector
180183 g = DefaultGenerator (Philox (seed ))
181184 return [g .next () for _ in range (n )]
0 commit comments