Skip to content

Commit

Permalink
Move modules in probnum.core to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinpfoertner committed Aug 26, 2020
1 parent 4f92600 commit 479d730
Show file tree
Hide file tree
Showing 32 changed files with 52 additions and 81 deletions.
2 changes: 1 addition & 1 deletion benchmarks/random_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np

from probnum.core import random_variable as rvs
from probnum import random_variables as rvs
import probnum.linalg.linops as linops

# Module level variables
Expand Down
Empty file removed src/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions src/probnum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
from . import filtsmooth
from . import linalg
from . import quad
from . import random_variables
from . import utils

from .core import *

from .random_variables import asrandvar, RandomVariable

# -*- coding: utf-8 -*-
from pkg_resources import get_distribution, DistributionNotFound
Expand Down
File renamed without changes.
31 changes: 0 additions & 31 deletions src/probnum/core/__init__.py

This file was deleted.

19 changes: 0 additions & 19 deletions src/probnum/core/random_variables/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion src/probnum/diffeq/odefiltsmooth/ivp2filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from probnum.filtsmooth import ExtendedKalman, UnscentedKalman
from probnum.filtsmooth.statespace.discrete import DiscreteGaussianModel
from probnum.core import random_variables as rvs
from probnum import random_variables as rvs


def ivp2ekf0(ivp, prior, evlvar):
Expand Down
2 changes: 1 addition & 1 deletion src/probnum/diffeq/odefiltsmooth/ivpfiltsmooth.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings
import numpy as np

from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.diffeq import odesolver
from probnum.diffeq.odefiltsmooth.prior import ODEPrior
from probnum.diffeq.odesolution import ODESolution
Expand Down
2 changes: 1 addition & 1 deletion src/probnum/diffeq/odefiltsmooth/prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from scipy.special import factorial # vectorised factorial for IBM-Q(h)

from probnum.filtsmooth.statespace.continuous import LTISDEModel
from probnum.core.random_variables import Normal
from probnum.random_variables import Normal


class ODEPrior(LTISDEModel):
Expand Down
4 changes: 2 additions & 2 deletions src/probnum/diffeq/odesolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Provides dense output by being callable.
Can function values can also be accessed by indexing.
"""
from probnum.core.random_variables import Normal
from probnum.core._randomvariablelist import _RandomVariableList
from probnum.random_variables import Normal
from probnum._randomvariablelist import _RandomVariableList
from probnum.filtsmooth.filtsmoothposterior import FiltSmoothPosterior
from probnum.filtsmooth import KalmanPosterior

Expand Down
2 changes: 1 addition & 1 deletion src/probnum/filtsmooth/gaussfiltsmooth/extendedkalman.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from probnum.filtsmooth.gaussfiltsmooth.gaussfiltsmooth import GaussFiltSmooth
from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.filtsmooth.statespace import (
ContinuousModel,
DiscreteModel,
Expand Down
2 changes: 1 addition & 1 deletion src/probnum/filtsmooth/gaussfiltsmooth/gaussfiltsmooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np

from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.filtsmooth.bayesfiltsmooth import BayesFiltSmooth
from probnum.filtsmooth.gaussfiltsmooth.kalmanposterior import KalmanPosterior

Expand Down
2 changes: 1 addition & 1 deletion src/probnum/filtsmooth/gaussfiltsmooth/kalman.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import numpy as np
from probnum.filtsmooth.gaussfiltsmooth.gaussfiltsmooth import GaussFiltSmooth
from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.filtsmooth.statespace import (
ContinuousModel,
DiscreteModel,
Expand Down
2 changes: 1 addition & 1 deletion src/probnum/filtsmooth/gaussfiltsmooth/kalmanposterior.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import numpy as np

from probnum.core._randomvariablelist import _RandomVariableList
from probnum._randomvariablelist import _RandomVariableList
from probnum.filtsmooth.filtsmoothposterior import FiltSmoothPosterior


Expand Down
2 changes: 1 addition & 1 deletion src/probnum/filtsmooth/gaussfiltsmooth/unscentedkalman.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import numpy as np

from probnum.filtsmooth.gaussfiltsmooth.gaussfiltsmooth import GaussFiltSmooth
from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.filtsmooth.gaussfiltsmooth.unscentedtransform import UnscentedTransform
from probnum.filtsmooth.statespace import (
ContinuousModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import numpy as np
import scipy.linalg
from probnum.filtsmooth.statespace.continuous import continuousmodel
from probnum.core.random_variables import Normal
from probnum.random_variables import Normal

__all__ = ["LinearSDEModel", "LTISDEModel"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
x_{i+1} = N(g(i, x_i), S(i))
"""

from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.filtsmooth.statespace.discrete import discretemodel


Expand Down
2 changes: 1 addition & 1 deletion src/probnum/linalg/linearsolvers/matrixbased.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import GPy

import probnum
from probnum.core import random_variables as rvs
from probnum import random_variables as rvs
from probnum.linalg import linops


Expand Down
21 changes: 21 additions & 0 deletions src/probnum/random_variables/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
This package implements random variables. Random variables are the primary in- and
outputs of probabilistic numerical methods. A generic signature of such methods looks
like this:
.. highlight:: python
.. code-block:: python
randvar_out, info = probnum_method(problem, randvar_in, **kwargs)
"""

from ._random_variable import (
asrandvar,
RandomVariable,
DiscreteRandomVariable,
ContinuousRandomVariable,
)

from ._dirac import Dirac
from ._normal import Normal
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any, Callable, Dict, Tuple, Union

from ._random_variable import RandomVariable as _RandomVariable
from probnum.core.random_variables import Dirac as _Dirac, Normal as _Normal
from probnum.random_variables import Dirac as _Dirac, Normal as _Normal


def add(rv1: _RandomVariable, rv2: _RandomVariable) -> _RandomVariable:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _binary_operator_factory(
) -> Callable[["Dirac", "Dirac"], "Dirac"]:
def _dirac_binary_operator(dirac_rv1: Dirac, dirac_rv2: Dirac) -> Dirac:
return Dirac(
support=operator(dirac_rv1, dirac_rv2),
support=operator(dirac_rv1.support, dirac_rv2.support),
random_state=_utils.derive_random_seed(
dirac_rv1.random_state, dirac_rv2.random_state,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def _scale(self, scalar, other_random_state=None):
)

if scalar == 0:
from probnum.core import random_variables as rvs
from probnum import random_variables as rvs

return rvs.Dirac(
support=np.zeros_like(self._mean), random_state=derived_random_seed,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ def asrandvar(obj) -> RandomVariable:
"""

# pylint: disable=import-outside-toplevel
from probnum.core import random_variables as rvs
from probnum import random_variables as rvs

# RandomVariable
if isinstance(obj, RandomVariable):
Expand Down Expand Up @@ -868,7 +868,7 @@ def _scipystats_to_rv(
"""

# pylint: disable=import-outside-toplevel
from probnum.core import random_variables as rvs
from probnum import random_variables as rvs

# Univariate distributions (implemented in this package)
if isinstance(scipyrv, scipy.stats._distn_infrastructure.rv_frozen):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_diffeq/test_ode/test_ivp.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
import numpy as np
from probnum.diffeq.ode import ivp
from probnum.core.random_variables import Dirac
from probnum.random_variables import Dirac
from tests.testing import NumpyAssertions

TEST_NDIM = 3
Expand Down
2 changes: 1 addition & 1 deletion tests/test_diffeq/test_odefiltsmooth/test_ivp2filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from probnum.diffeq import IBM, ivp2filter, lotkavolterra
from probnum.filtsmooth import ExtendedKalman, UnscentedKalman
from probnum.core.random_variables import Dirac
from probnum.random_variables import Dirac
from tests.testing import NumpyAssertions


Expand Down
2 changes: 1 addition & 1 deletion tests/test_diffeq/test_odefiltsmooth/test_odefiltsmooth.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from probnum.diffeq.odefiltsmooth import probsolve_ivp
from probnum.diffeq import ode
from probnum.core.random_variables import Dirac
from probnum.random_variables import Dirac

from tests.testing import NumpyAssertions

Expand Down
2 changes: 1 addition & 1 deletion tests/test_diffeq/test_odefiltsmooth/test_prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import numpy as np

from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.diffeq.odefiltsmooth import prior
from tests.testing import NumpyAssertions

Expand Down
4 changes: 2 additions & 2 deletions tests/test_diffeq/test_odesolution.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import unittest
import numpy as np

from probnum.core.random_variables import Dirac
from probnum.core._randomvariablelist import _RandomVariableList
from probnum.random_variables import Dirac
from probnum._randomvariablelist import _RandomVariableList
from probnum.diffeq import probsolve_ivp
from probnum.diffeq.ode import lotkavolterra, logistic

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
generate_cd,
DiscreteGaussianModel,
)
from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from tests.testing import NumpyAssertions

__all__ = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np

from probnum.filtsmooth.gaussfiltsmooth import Kalman
from probnum.core._randomvariablelist import _RandomVariableList
from probnum._randomvariablelist import _RandomVariableList
from tests.testing import NumpyAssertions

from .filtsmooth_testcases import CarTrackingDDTestCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from probnum.core.random_variables import Normal, Dirac
from probnum.random_variables import Normal, Dirac
from probnum.filtsmooth.statespace.continuous import continuousmodel

VISUALISE = False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np

from probnum.core.random_variables import Normal
from probnum.random_variables import Normal
from probnum.filtsmooth.statespace.continuous import linearsdemodel

TEST_NDIM = 2
Expand Down

0 comments on commit 479d730

Please sign in to comment.