Skip to content

Commit

Permalink
#1496 replace np.product by np.prod everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
DavAug committed Oct 9, 2023
1 parent d8cec9b commit 22df291
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pints/_error_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MeanSquaredError(ProblemErrorMeasure):
"""
def __init__(self, problem, weights=None):
super(MeanSquaredError, self).__init__(problem)
self._ninv = 1.0 / np.product(self._values.shape)
self._ninv = 1.0 / np.prod(self._values.shape)

if weights is None:
weights = [1] * self._n_outputs
Expand Down
2 changes: 1 addition & 1 deletion pints/_log_likelihoods.py
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ def __init__(self, log_likelihood):
self._log_likelihood = log_likelihood

# Pre-calculate parts
self._f = 1.0 / np.product(self._values.shape)
self._f = 1.0 / np.prod(self._values.shape)

def __call__(self, x):
return self._f * self._log_likelihood(x)
Expand Down
2 changes: 1 addition & 1 deletion pints/_log_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ def __init__(self, lower_or_boundaries, upper=None):
# Use normalised value (1/area) for rectangular boundaries,
# otherwise just use 1.
if isinstance(self._boundaries, pints.RectangularBoundaries):
self._value = -np.log(np.product(self._boundaries.range()))
self._value = -np.log(np.prod(self._boundaries.range()))
else:
self._value = 1

Expand Down
6 changes: 3 additions & 3 deletions pints/_mcmc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, x0, sigma0=None):
self._sigma0 = np.diag(0.01 * self._sigma0)
else:
self._sigma0 = np.array(sigma0, copy=True)
if np.product(self._sigma0.shape) == self._n_parameters:
if np.prod(self._sigma0.shape) == self._n_parameters:
# Convert from 1d array
self._sigma0 = self._sigma0.reshape((self._n_parameters,))
self._sigma0 = np.diag(self._sigma0)
Expand Down Expand Up @@ -192,7 +192,7 @@ def __init__(self, chains, x0, sigma0=None):
self._sigma0 = np.diag(0.01 * self._sigma0)
else:
self._sigma0 = np.array(sigma0, copy=True)
if np.product(self._sigma0.shape) == self._n_parameters:
if np.prod(self._sigma0.shape) == self._n_parameters:
# Convert from 1d array
self._sigma0 = self._sigma0.reshape((self._n_parameters,))
self._sigma0 = np.diag(self._sigma0)
Expand Down Expand Up @@ -352,7 +352,7 @@ def __init__(
else:
n_parameters = log_pdf[0].n_parameters()
# Make sure sigma0 is a (covariance) matrix
if np.product(sigma0.shape) == n_parameters:
if np.prod(sigma0.shape) == n_parameters:
# Convert from 1d array
sigma0 = sigma0.reshape((n_parameters,))
sigma0 = np.diag(sigma0)
Expand Down
2 changes: 1 addition & 1 deletion pints/_optimisers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def __init__(self, function, dimension, x, y):
self.d = dimension
self.x = x
self.y = y
self.n = 1 / np.product(y.shape) # Total number of points in data
self.n = 1 / np.prod(y.shape) # Total number of points in data

def n_parameters(self):
return self.d
Expand Down
4 changes: 2 additions & 2 deletions pints/tests/test_log_priors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ def test_uniform_prior(self):
self.assertEqual(p([10, 10]), m)
self.assertEqual(p([5, 20]), m)

w = -np.log(np.product(upper - lower))
w = -np.log(np.prod(upper - lower))
self.assertEqual(p([1, 2]), w)
self.assertEqual(p([1, 5]), w)
self.assertEqual(p([1, 20 - 1e-14]), w)
Expand Down Expand Up @@ -1110,7 +1110,7 @@ def test_uniform_prior(self):
self.assertEqual(p([10, 10]), m)
self.assertEqual(p([5, 20]), m)

w = -np.log(np.product(upper - lower))
w = -np.log(np.prod(upper - lower))
self.assertEqual(p([1, 2]), w)
self.assertEqual(p([1, 5]), w)
self.assertEqual(p([1, 20 - 1e-14]), w)
Expand Down

0 comments on commit 22df291

Please sign in to comment.