Skip to content

Commit aa8a9d9

Browse files
committed
Improve tutorial for upcoming release on github
* Also some minor deletion of dead code in tests. * Bump version up to v1.8.1 Change-Id: Ie345aaf5795e9bf9dff76199d130e12a201655ac
1 parent ad9d7dc commit aa8a9d9

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

example/tutorial.py

100644100755
Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
# encoding: utf-8
33
"""
4-
54
Small informal tutorial hastily thrown together to demonstrate how to use
65
the spike-based sampling (sbs) library.
76
@@ -563,7 +562,25 @@ def is_noarg_function(f):
563562
return True
564563
return False
565564

565+
def print_paragraph(text):
566+
import textwrap
567+
for line in textwrap.wrap(text, width=80, initial_indent="# ",
568+
subsequent_indent="# "):
569+
print(line)
570+
566571
def show_functions():
572+
message = "# sbs tutorial (using v{version}) #".format(
573+
version=sbs.__version__)
574+
barrier = "#" * len(message)
575+
print(barrier)
576+
print(message)
577+
print(barrier)
578+
print("#")
579+
print_paragraph("The following tutorial functions are defined. "
580+
"Run them by typing:")
581+
print("# python {script} <function-name>".format(
582+
script=sys.argv[0]))
583+
print("#")
567584
functions.sort()
568585
for f in functions:
569586
print(f)
@@ -576,5 +593,9 @@ def show_functions():
576593
run = globals()[launch]
577594
run()
578595
else:
579-
print(launch, "not part of functions:")
596+
print_paragraph(
597+
"ERROR: '{to_launch}' not part of functions!".format(
598+
to_launch=launch))
599+
print("#")
580600
show_functions()
601+
sys.exit(1)

sbs/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
__version__ = (1, 8, 0)
2+
__version__ = (1, 8, 1)

tests/test_basics.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,13 +441,11 @@ def test_sample_network_fixed_spikes(self):
441441
bm.dist_marginal_theo, bm.dist_marginal_sim)
442442
log.info("DKL marginal: {}".format(dkl_marginal))
443443
self.assertTrue(dkl_marginal > 0)
444-
# self.assertTrue(dkl_marginal < 1) # not assured here
445444

446445
dkl_joint = sbs.utils.dkl(
447-
bm.dist_joint_theo.flatten(), bm.dist_joint_sim.flatten())
446+
bm.dist_joint_theo.flatten(), bm.dist_joint_sim.flatten())
448447
log.info("DKL joint: {}".format(dkl_joint))
449448
self.assertTrue(dkl_joint > 0)
450-
# self.assertTrue(dkl_joint < 1) # not assured here
451449

452450
bm.plot_dist_marginal(prefix="test_basics_fixed_spike-", save=True)
453451
bm.plot_dist_joint(prefix="test_basics_fixed_spike-", save=True)

tests/test_utils.py

100755100644
File mode changed.

0 commit comments

Comments
 (0)