Skip to content

FIX: Handle scalar case in tests #88

@iraedeus

Description

@iraedeus

There is some issues in mathematical functions in distributions and mixture with scalar and non-scalar inputs. For example in core/mixture.py on lines 234-253:

    def pdf(self, X: ArrayLike) -> NDArray[float64]:
        """Probability Density Function of the mixture.

        The PDF is computed as the weighted sum of the PDFs of its
        components.

        Parameters
        ----------
        X : ArrayLike
            The input data points at which to evaluate the PDF.

        Returns
        -------
        NDArray[np.float64]
            The PDF values corresponding to each point in :attr:`X`.
        """

        X = np.asarray(X, dtype=float64)
        component_pdfs = np.array([comp.pdf(X) for comp in self.components])
        return np.asarray(np.dot(self.weights, component_pdfs))

Make sure that all functions returns scalar if the input is scalar and return ndarray with internal dtype if the input is non-scalar.
Add tests to it.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions