Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pvk-developer committed Feb 17, 2023
1 parent 399f81f commit b8348e3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 3 additions & 2 deletions sdv/multi_table/hma.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,9 @@ def _get_likelihoods(self, table_rows, parent_rows, table_name, foreign_key):
synthesizer = self._synthesizer(table_meta, **self._synthesizer_kwargs)
synthesizer._set_parameters(parameters)
try:
synthesizer._numpy_seed = np.random.get_state()[1]
likelihoods[parent_id] = synthesizer._get_likelihood(table_rows)
with np.random.default_rng(np.random.get_state()[1]):
likelihoods[parent_id] = synthesizer._get_likelihood(table_rows)

except (AttributeError, np.linalg.LinAlgError):
likelihoods[parent_id] = None

Expand Down
7 changes: 1 addition & 6 deletions sdv/single_table/copulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class GaussianCopulaSynthesizer(BaseSingleTableSynthesizer):
}

_model = None
_numpy_seed = 73251

@classmethod
def get_distribution_class(cls, distribution):
Expand Down Expand Up @@ -106,7 +105,6 @@ def __init__(self, metadata, enforce_min_max_values=True, enforce_rounding=True,
for field, distribution in self.numerical_distributions.items()
}
self._num_rows = None
self._numpy_generator = np.random.PCG64(self._numpy_seed)

def _fit(self, processed_data):
"""Fit the model to the table.
Expand Down Expand Up @@ -359,10 +357,7 @@ def _rebuild_gaussian_copula(self, model_parameters):
return model_parameters

def _get_likelihood(self, table_rows):
with np.random.default_rng(self._numpy_seed):
probabilities = self._model.probability_density(table_rows)

return probabilities
return self._model.probability_density(table_rows)

def _set_parameters(self, parameters):
"""Set copula model parameters.
Expand Down

0 comments on commit b8348e3

Please sign in to comment.