Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ root = true
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = false

# Matches multiple files with brace expansion notation
# Set default charset
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ concurrency:
cancel-in-progress: true

jobs:
typos:
name: Spelling (typos)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: crate-ci/typos@master

ruff:
name: Linting (ruff)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1

test:
name: Unittest (${{ matrix.os }}-${{ matrix.compiler }}-py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
Expand Down
48 changes: 26 additions & 22 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,61 @@
import sys
import os
import sys
from unittest.mock import MagicMock as Mock

from setuptools_scm import get_version


MOCK_MODULES = [
'numpy', 'numpy.testing', 'numpy.random',
'symengine', 'symengine.printing', 'symengine.lib.symengine_wrapper',
'jitcxde_common.helpers','jitcxde_common.numerical','jitcxde_common.symbolic'
"numpy", "numpy.testing", "numpy.random",
"symengine", "symengine.printing", "symengine.lib.symengine_wrapper",
"jitcxde_common.helpers","jitcxde_common.numerical","jitcxde_common.symbolic"
]
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)

class GroupHandler_mock(object): pass
sys.modules['jitcxde_common.transversal'] = Mock(GroupHandler=GroupHandler_mock)
class GroupHandler_mock:
pass

sys.modules["jitcxde_common.transversal"] = Mock(GroupHandler=GroupHandler_mock)

sys.path.insert(0,os.path.abspath("../examples"))
sys.path.insert(0,os.path.abspath("../jitcsde"))

needs_sphinx = '1.3'
needs_sphinx = "1.3"

extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.mathjax',
'numpydoc',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.mathjax",
"numpydoc",
]

source_suffix = '.rst'
source_suffix = ".rst"

master_doc = 'index'
master_doc = "index"

project = u'JiTCSDE'
copyright = u'2017, Gerrit Ansmann'
project = "JiTCSDE"
copyright = "2017, Gerrit Ansmann"

release = version = get_version(root='..', relative_to=__file__)
release = version = get_version(root="..", relative_to=__file__)

default_role = "any"

add_function_parentheses = True

add_module_names = False

html_theme = 'nature'
pygments_style = 'colorful'
htmlhelp_basename = 'JiTCSDEdoc'
html_theme = "nature"
pygments_style = "colorful"
htmlhelp_basename = "JiTCSDEdoc"

numpydoc_show_class_members = False
autodoc_member_order = 'bysource'
autodoc_member_order = "bysource"

def on_missing_reference(app, env, node, contnode):
if node['reftype'] == 'any':
if node["reftype"] == "any":
return contnode
else:
return None

def setup(app):
app.connect('missing-reference', on_missing_reference)
app.connect("missing-reference", on_missing_reference)
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ References

.. [RN17] C. Rackauckas, Q. Nie: Adaptive methods for stochastic differential equations via natural embeddings and rejection sampling with memory, Discrete Cont. Dyn.-B 22, pp. 2731–2761 (2017), `10.3934/dcdsb.2017133 <http://dx.doi.org/10.3934/dcdsb.2017133>`_.

.. [R10] A. Rößler, Runge–Kutta methods for the strong approximation of solutions of stochastic differential equations, SIAM J. Numer. Anal. 48, pp. 922–952 (2010) `10.1137/09076636X <http://dx.doi.org/10.1137/09076636X>`_.
.. [R10] A. Rößler, Runge–Kutta methods for the strong approximation of solutions of stochastic differential equations, SIAM J. Numerical Anal. 48, pp. 922–952 (2010) `10.1137/09076636X <http://dx.doi.org/10.1137/09076636X>`_.

.. _JiTCODE: http://github.com/neurophysik/jitcode

Expand Down
21 changes: 10 additions & 11 deletions examples/noisy_and_jumpy_lorenz.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
As an example, suppose that we want to add jumps to the noisy Lorenz oscillator from `example`.
These shall have exponentially distributed waiting times (i.e. they are a Poisson process) with a scale parameter :math:`β=1.0`.
Expand Down Expand Up @@ -29,10 +26,12 @@
"""

if __name__ == "__main__":
from jitcsde import y, jitcsde_jump
import numpy
import numpy as np
import symengine

from jitcsde import jitcsde_jump, y

rng = np.random.default_rng(seed=42)
ρ = 28
σ = 10
β = symengine.Rational(8,3)
Expand All @@ -47,22 +46,22 @@
g = [ p*y(i) for i in range(3) ]

def IJI(time,state):
return numpy.random.exponential(1.0)
return rng.exponential(1.0)

def jump(time,state):
return numpy.array([
return np.array([
0.0,
0.0,
numpy.random.normal(0.0,abs(state[2]))
rng.normal(0.0,abs(state[2]))
])

SDE = jitcsde_jump(IJI,jump,f,g)

initial_state = numpy.random.random(3)
initial_state = rng.random(3)
SDE.set_initial_value(initial_state,0.0)

data = []
for time in numpy.arange(0.0, 100.0, 0.01):
for time in np.arange(0.0, 100.0, 0.01):
data.append( SDE.integrate(time) )
numpy.savetxt("timeseries.dat", data)
np.savetxt("timeseries.dat", data)

17 changes: 8 additions & 9 deletions examples/noisy_lorenz.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
r"""
Suppose we want to integrate Lorenz oscillator each of whose components is subject to a diffusion that amounts to :math:`p` of the respective component, i.e.:

.. math::
Expand Down Expand Up @@ -72,10 +69,12 @@
"""

if __name__ == "__main__":
from jitcsde import y, jitcsde
import numpy
import numpy as np
import symengine

from jitcsde import jitcsde, y

rng = np.random.default_rng(seed=42)
ρ = 28
σ = 10
β = symengine.Rational(8,3)
Expand All @@ -91,11 +90,11 @@

SDE = jitcsde(f,g)

initial_state = numpy.random.random(3)
initial_state = rng.random(3)
SDE.set_initial_value(initial_state,0.0)

data = []
for time in numpy.arange(0.0, 100.0, 0.01):
for time in np.arange(0.0, 100.0, 0.01):
data.append( SDE.integrate(time) )
numpy.savetxt("timeseries.dat", data)
np.savetxt("timeseries.dat", data)

12 changes: 4 additions & 8 deletions jitcsde/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
from ._jitcsde import (
jitcsde, jitcsde_jump,
t, y,
UnsuccessfulIntegration,
test
)
from ._jitcsde import UnsuccessfulIntegration, jitcsde, jitcsde_jump, t, test, y # noqa: F401


try:
from .version import version as __version__
from .version import version as __version__ # noqa: F401
except ImportError:
from warnings import warn
warn('Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.')
warn("Failed to find (autogenerated) version.py. Do not worry about this unless you really need to know the version.", stacklevel=2)
Loading