Skip to content

Commit 4a79426

Browse files
committed
Move to modern package management: automatic upload to pypi, ruff, pyproject.toml...
1 parent 8dc188a commit 4a79426

21 files changed

+2332
-1975
lines changed

.github/workflows/release.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Publish to PyPI.org
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
pypi:
7+
name: upload release to PyPI
8+
runs-on: ubuntu-latest
9+
environment: pypi
10+
permissions:
11+
# IMPORTANT: this permission is mandatory for Trusted Publishing
12+
id-token: write
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- run: python3 -m pip install --upgrade build && python3 -m build
19+
- name: Publish package to PyPI
20+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/ruff.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Ruff
2+
on: [ push, pull_request ]
3+
jobs:
4+
ruff-check:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout repository
8+
uses: actions/checkout@v4
9+
10+
- name: Set Python Version
11+
uses: actions/setup-python@v5
12+
with:
13+
python-version: "3.13"
14+
15+
- name: Python Ruff Lint and Format
16+
uses: adityabhangle658/[email protected]
17+
18+
19+

docs/conf.py

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
# Configuration file for the Sphinx documentation builder.
42
#
53
# This file does only contain a selection of the most common options. For a
@@ -13,21 +11,25 @@
1311
# documentation root, use os.path.abspath to make it absolute, like shown here.
1412
#
1513
import os
16-
import sys
1714
import re
18-
sys.path.insert(0, os.path.abspath('../'))
15+
import sys
16+
17+
sys.path.insert(0, os.path.abspath("../"))
1918

2019

2120
# -- Project information -----------------------------------------------------
2221

23-
project = 'Mr. Estimator'
24-
copyright = '2018, Paul Spitzner, Jonas Dehning, Annika Hagemann, Jens Wilting, Viola Priesemann'
25-
author = 'Paul Spitzner, Jonas Dehning, Annika Hagemann, Jens Wilting, Viola Priesemann'
22+
project = "Mr. Estimator"
23+
copyright = (
24+
"2018, Paul Spitzner, Jonas Dehning, Annika Hagemann, "
25+
"Jens Wilting, Viola Priesemann"
26+
)
27+
author = "Paul Spitzner, Jonas Dehning, Annika Hagemann, Jens Wilting, Viola Priesemann"
2628

2729
verstr = "unknown"
2830
try:
29-
verstrline = open('../mrestimator/_version.py', "rt").read()
30-
except EnvironmentError:
31+
verstrline = open("../mrestimator/_version.py").read()
32+
except OSError:
3133
pass
3234
else:
3335
VSRE = r"^__version__ = ['\"]([^'\"]*)['\"]"
@@ -36,7 +38,7 @@
3638
verstr = mo.group(1)
3739
else:
3840
raise RuntimeError("unable to find version in mrestimator/_version.py")
39-
print('sphinx found version: {}'.format(verstr))
41+
print(f"sphinx found version: {verstr}")
4042
# The short X.Y version
4143
version = verstr
4244
# The full version, including alpha/beta/rc tags
@@ -53,40 +55,34 @@
5355
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
5456
# ones.
5557
extensions = [
56-
'sphinx.ext.autodoc',
57-
'sphinx.ext.doctest',
58-
'sphinx.ext.todo',
59-
'sphinx.ext.coverage',
60-
'sphinx.ext.mathjax',
61-
'sphinx.ext.napoleon',
58+
"sphinx.ext.autodoc",
59+
"sphinx.ext.doctest",
60+
"sphinx.ext.todo",
61+
"sphinx.ext.coverage",
62+
"sphinx.ext.mathjax",
63+
"sphinx.ext.napoleon",
6264
# 'numpydoc',
63-
'sphinx.ext.intersphinx',
64-
'sphinx.ext.viewcode',
65-
'm2r',
65+
"sphinx.ext.intersphinx",
66+
"sphinx.ext.viewcode",
67+
"m2r",
6668
# 'sphinx_autorun'
6769
]
6870

6971

7072
# Mock imports
71-
autodoc_mock_imports = [
72-
'numpy',
73-
'matplotlib',
74-
'matplotlib.pyplot',
75-
'scipy',
76-
'neo'
77-
]
73+
autodoc_mock_imports = ["numpy", "matplotlib", "matplotlib.pyplot", "scipy", "neo"]
7874

7975
# Add any paths that contain templates here, relative to this directory.
80-
templates_path = ['_templates']
76+
templates_path = ["_templates"]
8177

8278
# The suffix(es) of source filenames.
8379
# You can specify multiple suffix as a list of string:
8480
#
85-
source_suffix = ['.rst', '.md']
81+
source_suffix = [".rst", ".md"]
8682
# source_suffix = '.rst'
8783

8884
# The master toctree document.
89-
master_doc = 'index'
85+
master_doc = "index"
9086

9187
# The language for content autogenerated by Sphinx. Refer to documentation
9288
# for a list of supported languages.
@@ -98,10 +94,10 @@
9894
# List of patterns, relative to source directory, that match files and
9995
# directories to ignore when looking for source files.
10096
# This pattern also affects html_static_path and html_extra_path .
101-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
97+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
10298

10399
# The name of the Pygments (syntax highlighting) style to use.
104-
pygments_style = 'sphinx'
100+
pygments_style = "sphinx"
105101

106102

107103
# Napoleon settings
@@ -113,8 +109,8 @@
113109
# napoleon_use_admonition_for_examples = False
114110
# napoleon_use_admonition_for_notes = False
115111
# napoleon_use_admonition_for_references = False
116-
napoleon_use_ivar = True # True enables links for attribute types
117-
napoleon_use_param = True # True enables links for parameter types
112+
napoleon_use_ivar = True # True enables links for attribute types
113+
napoleon_use_param = True # True enables links for parameter types
118114
napoleon_use_rtype = False
119115

120116
# -- Options for HTML output -------------------------------------------------
@@ -124,23 +120,23 @@
124120
# The theme to use for HTML and HTML Help pages. See the documentation for
125121
# a list of builtin themes.
126122
#
127-
html_theme = 'sphinx_rtd_theme'
123+
html_theme = "sphinx_rtd_theme"
128124

129125
# Theme options are theme-specific and customize the look and feel of a theme
130126
# further. For a list of options available for each theme, see the
131127
# documentation.
132128

133129
html_theme_options = {
134-
'collapse_navigation': False,
135-
'display_version': False,
136-
'navigation_depth': 4,
137-
'sticky_navigation': True,
130+
"collapse_navigation": False,
131+
"display_version": False,
132+
"navigation_depth": 4,
133+
"sticky_navigation": True,
138134
}
139135

140136
# Add any paths that contain custom static files (such as style sheets) here,
141137
# relative to this directory. They are copied after the builtin static files,
142138
# so a file named "default.css" will overwrite the builtin "default.css".
143-
html_static_path = ['_static']
139+
html_static_path = ["_static"]
144140

145141
# Custom sidebar templates, must be a dictionary that maps document names
146142
# to template names.
@@ -153,14 +149,14 @@
153149
# html_sidebars = {}
154150

155151
# icons
156-
html_favicon = 'media/favicon.ico'
157-
html_logo = 'media/logo.png'
152+
html_favicon = "media/favicon.ico"
153+
html_logo = "media/logo.png"
158154

159155

160156
# -- Options for HTMLHelp output ---------------------------------------------
161157

162158
# Output file base name for HTML help builder.
163-
htmlhelp_basename = 'mredoc'
159+
htmlhelp_basename = "mredoc"
164160

165161

166162
# -- Options for LaTeX output ------------------------------------------------
@@ -169,15 +165,12 @@
169165
# The paper size ('letterpaper' or 'a4paper').
170166
#
171167
# 'papersize': 'letterpaper',
172-
173168
# The font size ('10pt', '11pt' or '12pt').
174169
#
175170
# 'pointsize': '10pt',
176-
177171
# Additional stuff for the LaTeX preamble.
178172
#
179173
# 'preamble': '',
180-
181174
# Latex figure (float) alignment
182175
#
183176
# 'figure_align': 'htbp',
@@ -187,19 +180,15 @@
187180
# (source start file, target name, title,
188181
# author, documentclass [howto, manual, or own class]).
189182
latex_documents = [
190-
(master_doc, 'mre.tex', 'mre Documentation',
191-
'Paul Spitzner', 'manual'),
183+
(master_doc, "mre.tex", "mre Documentation", "Paul Spitzner", "manual"),
192184
]
193185

194186

195187
# -- Options for manual page output ------------------------------------------
196188

197189
# One entry per manual page. List of tuples
198190
# (source start file, name, description, authors, manual section).
199-
man_pages = [
200-
(master_doc, 'mre', 'mre Documentation',
201-
[author], 1)
202-
]
191+
man_pages = [(master_doc, "mre", "mre Documentation", [author], 1)]
203192

204193

205194
# -- Options for Texinfo output ----------------------------------------------
@@ -208,19 +197,26 @@
208197
# (source start file, target name, title, author,
209198
# dir menu entry, description, category)
210199
texinfo_documents = [
211-
(master_doc, 'mre', 'mre Documentation',
212-
author, 'mre', 'One line description of project.',
213-
'Miscellaneous'),
200+
(
201+
master_doc,
202+
"mre",
203+
"mre Documentation",
204+
author,
205+
"mre",
206+
"One line description of project.",
207+
"Miscellaneous",
208+
),
214209
]
215210

216211

217212
# -- Extension configuration -------------------------------------------------
218213

219-
intersphinx_mapping = {'python': ('http://docs.python.org/3', None),
220-
'numpy': ('http://docs.scipy.org/doc/numpy', None),
221-
'scipy': ('http://docs.scipy.org/doc/scipy/reference', None),
222-
'matplotlib': ('http://matplotlib.sourceforge.net', None)
223-
}
214+
intersphinx_mapping = {
215+
"python": ("http://docs.python.org/3", None),
216+
"numpy": ("http://docs.scipy.org/doc/numpy", None),
217+
"scipy": ("http://docs.scipy.org/doc/scipy/reference", None),
218+
"matplotlib": ("http://matplotlib.sourceforge.net", None),
219+
}
224220

225221
# -- Options for todo extension ----------------------------------------------
226222

examples/basic_usage.ipynb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@
4848
}
4949
],
5050
"source": [
51-
"#imports the toolbox\n",
51+
"# imports the toolbox\n",
5252
"import mrestimator as mre\n",
5353
"\n",
54-
"#ensures that the plots are embedded in the notebook\n",
54+
"# ensures that the plots are embedded in the notebook\n",
5555
"%matplotlib inline "
5656
]
5757
},
@@ -79,7 +79,9 @@
7979
}
8080
],
8181
"source": [
82-
"data = mre.simulate_branching(m=0.98, a=1000,subp=0.05, length=20000, numtrials=10, seed=43771)"
82+
"data = mre.simulate_branching(\n",
83+
" m=0.98, a=1000, subp=0.05, length=20000, numtrials=10, seed=43771\n",
84+
")"
8385
]
8486
},
8587
{
@@ -144,7 +146,14 @@
144146
}
145147
],
146148
"source": [
147-
"result = mre.full_analysis(data, kmax=500, coefficientmethod='trialseparated', dt=1, dtunit=' bp steps', fitfuncs=['e', 'eo'])"
149+
"result = mre.full_analysis(\n",
150+
" data,\n",
151+
" kmax=500,\n",
152+
" coefficientmethod=\"trialseparated\",\n",
153+
" dt=1,\n",
154+
" dtunit=\" bp steps\",\n",
155+
" fitfuncs=[\"e\", \"eo\"],\n",
156+
")"
148157
]
149158
}
150159
],
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,32 @@
11
import os
2+
23
import numpy as np
3-
import matplotlib.pyplot as plt
4+
45
import mrestimator as mre
56

67
# set working directory to use relative paths
78
os.chdir(os.path.dirname(__file__))
89
try:
9-
os.mkdir('./data')
10+
os.mkdir("./data")
1011
except FileExistsError:
1112
pass
1213

1314
h = np.ones(10000)
14-
h[int(len(h)/3):int(len(h)/3+10)] += 100
15-
h*=2
15+
h[int(len(h) / 3) : int(len(h) / 3 + 10)] += 100
16+
h *= 2
1617
foo = mre.simulate_branching(m=0.995, h=h, numtrials=10, seed=314)
1718
sub = mre.simulate_subsampling(foo, prob=0.1, seed=271)
1819

1920
h = np.vstack((np.arange(0, len(h)), h))
2021

2122
hdr = "two column file containing a time index and the time series of the drive\n"
2223
hdr += "one timestep per row\n\n"
23-
np.savetxt('./data/drive.tsv', h.T, fmt='%5d', header=hdr)
24+
np.savetxt("./data/drive.tsv", h.T, fmt="%5d", header=hdr)
2425
hdr = "original trials with full activity\n"
2526
hdr += "one trial in each column, increasing timesteps in each row\n\n"
26-
np.savetxt('./data/full.tsv', foo.T, fmt='%5d', header=hdr)
27+
np.savetxt("./data/full.tsv", foo.T, fmt="%5d", header=hdr)
2728
for idx, ts in enumerate(sub):
28-
hdr = ''
29-
hdr += 'subsampled trials in indivual files with one column each\n'
30-
hdr += 'this is trial {:02d}\n\n'.format(idx)
31-
np.savetxt('./data/sub_{:02d}.tsv'.format(idx), ts, fmt='%5d', header=hdr)
32-
33-
34-
35-
29+
hdr = ""
30+
hdr += "subsampled trials in indivual files with one column each\n"
31+
hdr += f"this is trial {idx:02d}\n\n"
32+
np.savetxt(f"./data/sub_{idx:02d}.tsv", ts, fmt="%5d", header=hdr)

0 commit comments

Comments
 (0)