Skip to content

Commit

Permalink
finish resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
eacharles committed Nov 30, 2023
1 parent 6b51f11 commit 56c4521
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 48 deletions.
44 changes: 1 addition & 43 deletions src/qp/mixmod_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,9 @@ class mixmod_gen(Pdf_rows_gen):

# pylint: disable=protected-access

<<<<<<< HEAD
name = "mixmod"
version = 0

=======
>>>>>>> 9b08a50 (Started implementing mixture model implementation with generic scipy base function. So far only the ones using loc and scale parameters work. PPFs need to be implemented.)
_support_mask = rv_continuous._support_mask

name = 'gen_mixmod'
name = 'mixmod'
version = 0

def __init__(self, gen_func, weights, data, ancil=None, *args, **kwargs):
Expand All @@ -58,12 +52,8 @@ def __init__(self, gen_func, weights, data, ancil=None, *args, **kwargs):
stds: array_like
The standard deviations of the basis functions
weights : array_like
<<<<<<< HEAD
The weights to attach to the Gaussians. Weights should sum up to one.
If not, the weights are interpreted as relative weights.
=======
The weights to attach to the basis functions. Weights should sum up to one. If not, the weights are interpreted as relative weights.
>>>>>>> 9b08a50 (Started implementing mixture model implementation with generic scipy base function. So far only the ones using loc and scale parameters work. PPFs need to be implemented.)
"""
self._gen_func = gen_func
self._frozen = self._gen_func(**data)
Expand All @@ -73,17 +63,6 @@ def __init__(self, gen_func, weights, data, ancil=None, *args, **kwargs):

self._scipy_version_warning()
self._weights = reshape_to_pdf_size(weights, -1)
<<<<<<< HEAD
kwargs["shape"] = means.shape[:-1]
self._ncomps = means.shape[-1]
super().__init__(*args, **kwargs)
if np.any(self._weights < 0):
raise ValueError("All weights need to be larger than zero")
self._weights = self._weights / self._weights.sum(axis=1)[:, None]
self._addobjdata("weights", self._weights)
self._addobjdata("stds", self._stds)
self._addobjdata("means", self._means)
=======
for key in self._data.keys():
self._data[key] = reshape_to_pdf_size(self._data[key],-1)
kwargs['shape'] = weights.shape[:-1]
Expand All @@ -93,7 +72,6 @@ def __init__(self, gen_func, weights, data, ancil=None, *args, **kwargs):
raise ValueError('All weights need to be larger than zero')
self._weights = self._weights/self._weights.sum(axis=1)[:,None]
self._addobjdata('weights', self._weights)
>>>>>>> 9b08a50 (Started implementing mixture model implementation with generic scipy base function. So far only the ones using loc and scale parameters work. PPFs need to be implemented.)

def _scipy_version_warning(self):
import scipy # pylint: disable=import-outside-toplevel
Expand All @@ -115,41 +93,21 @@ def _pdf(self, x, row):
# pylint: disable=arguments-differ
if np.ndim(x) > 1: # pragma: no cover
x = np.expand_dims(x, -2)
<<<<<<< HEAD
return (
self.weights[row].swapaxes(-2, -1)
* sps.norm(
loc=self._means[row].swapaxes(-2, -1),
scale=self._stds[row].swapaxes(-2, -1),
).pdf(x)
).sum(axis=0)
=======
data_swap=dict()
for key in self._data.keys():
data_swap[key] = self._data[key][row].swapaxes(-2,-1)
return (self.weights[row].swapaxes(-2,-1) *
self._gen_func(**data_swap).pdf(x)).sum(axis=0)
>>>>>>> 9b08a50 (Started implementing mixture model implementation with generic scipy base function. So far only the ones using loc and scale parameters work. PPFs need to be implemented.)

def _cdf(self, x, row):
# pylint: disable=arguments-differ
if np.ndim(x) > 1: # pragma: no cover
x = np.expand_dims(x, -2)
<<<<<<< HEAD
return (
self.weights[row].swapaxes(-2, -1)
* sps.norm(
loc=self._means[row].swapaxes(-2, -1),
scale=self._stds[row].swapaxes(-2, -1),
).cdf(x)
).sum(axis=0)
=======
data_swap=dict()
for key in self._data.keys():
data_swap[key] = self._data[key][row].swapaxes(-2,-1)
return (self.weights[row].swapaxes(-2,-1) *
self._gen_func(**data_swap).cdf(x)).sum(axis=0)
>>>>>>> 9b08a50 (Started implementing mixture model implementation with generic scipy base function. So far only the ones using loc and scale parameters work. PPFs need to be implemented.)

def _ppf(self, x, row):
# pylint: disable=arguments-differ
Expand Down
5 changes: 0 additions & 5 deletions src/qp/pdf_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,8 @@ def create_gen(cls, **kwds):
"""Create and return a `scipy.stats.rv_continuous` object using the
keyword arguemntets provided"""
kwds_copy = kwds.copy()
<<<<<<< HEAD
name = kwds_copy.pop("name", "dist")
return (cls(name=name), kwds_copy)
=======
name = kwds_copy.pop('name', 'dist')
return (cls(), kwds_copy)
>>>>>>> 71047e2 (fixed mixture model implementation with scipy basis functions that require additional parameters)

@classmethod
def create(cls, **kwds):
Expand Down

0 comments on commit 56c4521

Please sign in to comment.