Skip to content

Commit

Permalink
Merge pull request #67 from DynamicsAndNeuralSystems/jmoo2880-JIDT-up…
Browse files Browse the repository at this point in the history
…grade

Infotheory SPI reproducibility fix
  • Loading branch information
joshuabmoore authored Apr 22, 2024
2 parents e2fe31d + be68799 commit 0a53795
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 41 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pyspi"
version = "1.0.2"
version = "1.0.3"
authors = [
{ name ="Oliver M. Cliff", email="oliver.m.cliff@gmail.com"},
]
Expand Down
30 changes: 15 additions & 15 deletions pyspi/lib/jidt/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</description>

<!-- set global properties for this build -->
<property name="version" value="1.5"/>
<property name="version" value="1.6.1"/>
<property name="mainfilename" value="infodynamics"/>
<property name="jarplainname" value="${mainfilename}.jar" />
<property name="jarversiondistnamezip" value="${mainfilename}-jar-${version}.zip" />
Expand Down Expand Up @@ -43,17 +43,17 @@

<!-- Compile the java toolkit -->
<target name="compile" depends="init" description="compile the source">
<!-- Compile to Java 6 to provide compatibility for users with older JREs.
<!-- Compile to Java 7 to provide compatibility for users with older JREs.
Caveat: The flags here only check the language compatibility, but
may still use newer libraries which may cause issues for users with JDK 6.
Indeed, one gets the warning: "bootstrap class path not set in conjunction with -source 1.6"
may still use newer libraries which may cause issues for users with JDK 7.
Indeed, one gets the warning: "bootstrap class path not set in conjunction with -source 1.7"
To fix this, one would use the bootstrap classpath to point our JDK to an rt.jar
for Java 6.
At this stage, I'm sure I'm not using new library calls from Java 7/8, so we can
ignore the warning, and I don't want to bother installing Java 7 just to compile
for Java 7.
At this stage, I'm sure I'm not using new library calls from Java 8+, so we can
ignore the warning, and I don't want to bother installing newer Java just to compile
like this. I'll endeavour not to use JDK 8 libraries so as not to cause
any issues here ... -->
<javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.6" source="1.6" encoding="UTF8">
<javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.7" source="1.7" encoding="UTF8">
<classpath refid="apache-classpath"/>
</javac>

Expand Down Expand Up @@ -116,12 +116,12 @@
<target name="javadocs" depends="compile" description="Make the javadocs for the toolkit">
<delete dir="${javadocsdir}"/>
<javadoc destdir="${javadocsdir}">
<fileset dir="${src}">
<include name="**/*.java"/>
<exclude name="infodynamics/demos/**/*.java"/>
<exclude name="**/commonsmath3/*.java"/>
<exclude name="**/commonsmath3/**/*.java"/>
</fileset>
<packageset dir="${src}">
<include name="**"/>
<exclude name="infodynamics/demos/**"/>
<exclude name="**/commonsmath3/*"/>
<exclude name="**/commonsmath3/**"/>
</packageset>
</javadoc>
<!-- Change some of the style in the javadocs css for our lists: -->
<concat destfile="${javadocsdir}/stylesheet.css" append="true">
Expand Down Expand Up @@ -177,7 +177,7 @@
<!-- Compile and jar the toolkit with debug symbols -->
<target name="debug" depends="init" description="compile and jar with debug symbols">
<echo message="Compiling for debug"/>
<javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.6" source="1.6" debug="true">
<javac srcdir="${src}" destdir="${bin}" includeAntRuntime="false" target="1.7" source="1.7" debug="true">
<classpath refid="apache-classpath"/>
</javac>

Expand Down
Binary file modified pyspi/lib/jidt/infodynamics.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions pyspi/lib/jidt/license-gplv3.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,18 @@ makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.

No covered work shall be deemed part of an effective technological
statistic under any applicable law fulfilling obligations under article
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
statistics.
measures.

When you convey a covered work, you waive any legal power to forbid
circumvention of technological statistics to the extent such circumvention
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological statistics.
technological measures.

4. Conveying Verbatim Copies.

Expand Down
37 changes: 28 additions & 9 deletions pyspi/lib/jidt/readme.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
Java Information Dynamics Toolkit (JIDT)
Copyright (C) 2012-2014 Joseph T. Lizier
Copyright (C) 2014-2016 Joseph T. Lizier and Ipek Özdemir
Copyright (C) 2017- Joseph T. Lizier, Ipek Özdemir and Pedro Mediano
Copyright (C) 2016-2019 Joseph T. Lizier, Ipek Özdemir and Pedro Mediano
Copyright (C) 2019-2022 Joseph T. Lizier, Ipek Özdemir, Pedro Mediano, Emanuele Crosato, Sooraj Sekhar and Oscar Huaigu Xu
Copyright (C) 2022- Joseph T. Lizier, Ipek Özdemir, Pedro Mediano, Emanuele Crosato, Sooraj Sekhar, Oscar Huaigu Xu and David Shorten

Version 1.5 (see release notes below)
Version 1.6.1 (see release notes below)

JIDT provides a standalone, open source code Java implementation (usable in Matlab, Octave and Python) of information-theoretic statistics of distributed computation in complex systems: i.e. information storage, transfer and modification.
JIDT provides a standalone, open source code Java implementation (usable in Matlab, Octave and Python) of information-theoretic measures of distributed computation in complex systems: i.e. information storage, transfer and modification.

This includes implementations for:
- both discrete and continuous-valued variables, principally for the statistics transfer entropy, mutual information and active information storage;
- both discrete and continuous-valued variables, principally for the measures transfer entropy, mutual information and active information storage;
- using various types of estimators (e.g. Kraskov-Stögbauer-Grassberger estimators, kernel estimation, linear-Gaussian).

=============
Expand Down Expand Up @@ -60,7 +62,7 @@ Documentation

A research paper describing the toolkit is included in the top level directory -- "InfoDynamicsToolkit.pdf".

A tutorial, providing background to the information-theoretic statistics, various estimators, and then to the JIDT toolkit itself is included in the tutorial folder (see "JIDT-TutorialSlides.pdf" for the tutorial slides, and "README-TutorialAndExercise.pdf" for further description of the tutorial exercises).
A tutorial, providing background to the information-theoretic measures, various estimators, and then to the JIDT toolkit itself is included in the tutorial folder (see "JIDT-TutorialSlides.pdf" for the tutorial slides, and "README-TutorialAndExercise.pdf" for further description of the tutorial exercises).

Javadocs for the toolkit are included in the full distribution at javadocs.
They can also be generated using "ant javadocs" (useful if you are on a git clone).
Expand All @@ -78,7 +80,7 @@ You can also join our email discussion group jidt-discuss at http://groups.googl

Several sets of demonstration code are distributed with the toolkit:

a. demos/AutoAnalyser -- a GUI tool to compute the information-theoretic statistics on a chosen data set with the toolkit, and also automatically generate code in Java, Python and Matlab to show how to do this calculation with the toolkit. See description at https://github.com/jlizier/jidt/wiki/AutoAnalyser
a. demos/AutoAnalyser -- a GUI tool to compute the information-theoretic measures on a chosen data set with the toolkit, and also automatically generate code in Java, Python and Matlab to show how to do this calculation with the toolkit. See description at https://github.com/jlizier/jidt/wiki/AutoAnalyser

b. demos/java -- basic examples on easily using the Java toolkit -- run these from the shell scripts in this directory -- see description at https://github.com/jlizier/jidt/wiki/SimpleJavaExamples

Expand All @@ -96,7 +98,7 @@ Several sets of demonstration code are distributed with the toolkit:

d. demos/octave/CellularAutomata -- using the Java toolkit to plot local information dynamics profiles in cellular automata; the toolkit is run under Octave or Matlab -- see description at https://github.com/jlizier/jidt/wiki/CellularAutomataDemos

e. demos/octave/SchreiberTransferEntropyExamples -- recreates the transfer entropy examples in Schreiber's original paper presenting this statistic; shows the correct parameter settings to reproduce these results -- see description at https://github.com/jlizier/jidt/wiki/SchreiberTeDemos
e. demos/octave/SchreiberTransferEntropyExamples -- recreates the transfer entropy examples in Schreiber's original paper presenting this measure; shows the correct parameter settings to reproduce these results -- see description at https://github.com/jlizier/jidt/wiki/SchreiberTeDemos

f. demos/octave/DetectingInteractionLags -- demonstration of using the transfer entropy with source-destination lags; the demo is run under Octave or Matlab -- see description at https://github.com/jlizier/jidt/wiki/DetectingInteractionLags

Expand Down Expand Up @@ -134,6 +136,23 @@ Notices for this software are found in the notices/JAMA directory.
Release notes
===============

v1.6.1 22/8/2023
-------------
(after 909 commits recorded by github, repository as at https://github.com/jlizier/jidt/tree/90baf68ee7332e15030447b44d262a0fc54773f6 save for this file update)
Minor updates to supporting use in Python, including virtual environments;
Minor tweaks to fish schooling examples (mostly comments)

v1.6 5/9/2022
-------------
(after 889 commits recorded by github, repository as at https://github.com/jlizier/jidt/tree/d750a737bea2a8b1f33b7cd0ad167ec999d907ef save for this file update)
Adding Flocking/Schooling/Swarming demo;
Included Pedro's code on IIT and O-/S-Information measures;
Spiking TE estimator added from David;
Fixed up AutoAnalyser to work well for Python3 and numpy;
Links to lecture videos included in the beta wiki for the course;
Added rudimentary effective network inference (simplified version of the IDTxl full algorithm) in demos/octave/EffectiveNetworkInference;


v1.5 26/11/2018
---------------
(after 753 commits recorded by github, repository as at https://github.com/jlizier/jidt/tree/603445651cc0bf155a42c9ba336141bc7f29bccd save for this file update)
Expand Down Expand Up @@ -215,7 +234,7 @@ Javadocs made ready for release;
Switched source->destination arguments for discrete TE calculators to be with source first in line with continuous calculators;
Renamed all discrete calculators to have Discrete suffix -- TE and conditional TE calculators also renamed to remove "Apparent" prefix and change "Complete" to "Conditional";
Kraskov estimators now using 4 nearest neighbours by default;
Unit test for Gaussian TE against ChaLearn Granger causality statisticment;
Unit test for Gaussian TE against ChaLearn Granger causality measurement;
Added Schreiber TE demos; Interregional transfer demos; documentation for Interaction lag demos; added examples 7 and 8 to Simple Java demos;
Added property to add noise to data for Kraskov MI;
Added derivation of Apache Commons Math code for chi square distribution, and included relevant notices in our release;
Expand Down Expand Up @@ -263,5 +282,5 @@ First distribution

=============

Joseph T. Lizier, 25/11/2018
Joseph T. Lizier, 22/08/2023

8 changes: 0 additions & 8 deletions pyspi/lib/jidt/version-1.5.txt

This file was deleted.

11 changes: 11 additions & 0 deletions pyspi/lib/jidt/version-1.6.1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Java Information Dynamics Toolkit (JIDT)
Copyright (C) 2012-2014 Joseph T. Lizier
Copyright (C) 2014-2016 Joseph T. Lizier and Ipek Özdemir
Copyright (C) 2016-2019 Joseph T. Lizier, Ipek Özdemir and Pedro Mediano
Copyright (C) 2019-2022 Joseph T. Lizier, Ipek Özdemir, Pedro Mediano, Emanuele Crosato, Sooraj Sekhar and Oscar Huaigu Xu
Copyright (C) 2022- Joseph T. Lizier, Ipek Özdemir, Pedro Mediano, Emanuele Crosato, Sooraj Sekhar, Oscar Huaigu Xu and David Shorten

Version 1.6.1

22/08/2023

1 change: 1 addition & 0 deletions pyspi/statistics/causal.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ def _from_cache(self, data):
target=targname,
libSizes=lib_sizes,
sample=100,
seed=42,
)
ccmf[_i, _j] = ccm_df.iloc[:, 1].values[: (nlibs + 1)]
ccmf[_j, _i] = ccm_df.iloc[:, 2].values[: (nlibs + 1)]
Expand Down
2 changes: 2 additions & 0 deletions pyspi/statistics/infotheory.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class JIDTBase(Unsigned):
_TAU_SEARCH_MAX_PROP_NAME = "AUTO_EMBED_TAU_SEARCH_MAX"
_BIAS_CORRECTION = "BIAS_CORRECTION"
_NORMALISE = "NORMALISE"
_SEED = "NOISE_SEED"

_base_class = jp.JPackage("infodynamics.measures.continuous")

Expand Down Expand Up @@ -104,6 +105,7 @@ def _setup(self, calc):
calc.setProperty(self._NNK_PROP_NAME, str(self._prop_k))

calc.setProperty(self._BIAS_CORRECTION, "false")
calc.setProperty(self._SEED, "42")

return calc

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
'data/standard_normal.npy',
'data/cml7.npy']},
include_package_data=True,
version='1.0.2',
version='1.0.3',
description='Library for pairwise analysis of time series data.',
author='Oliver M. Cliff',
author_email='oliver.m.cliff@gmail.com',
Expand Down
Binary file modified tests/CML7_benchmark_tables.pkl
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def pytest_sessionfinish(session, exitstatus):

# print problematic SPIs in table format
if spi_warnings:
print(f"\nDetected {len(spi_warnings)} SPI(s) with outputs exceeding the specified 2 sigma threshold.\n")
print(f"\nDetected {len(spi_warnings)} SPI(s) with outputs exceeding the specified 1 sigma threshold.\n")

# table header
print(f"{'SPI':<25}{'Cat':<10}{'Max ZSc.':>10}{'# Exceed. Pairs':>20}{'Unq. Pairs':>15}")
Expand All @@ -44,7 +44,7 @@ def pytest_sessionfinish(session, exitstatus):
error = " **"
print(f"{est+error:<25}{module_name:<10}{max_z:>10.4g}{num_exceed:>15}{num_iteractions:>20}")
else:
print("\n\nNo SPIs exceeded the sigma threshold.\n")
print("\n\nNo SPIs exceeded the 1 sigma threshold.\n")

print(footer_line)
print(padded_footer)
2 changes: 1 addition & 1 deletion tests/test_SPIs.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def pytest_generate_tests(metafunc):

def test_mpi(est, est_ob, mpi_benchmark, mpi_new, spi_warning_logger):
"""Run the benchmarking tests."""
zscore_threshold = 2 # 2 sigma
zscore_threshold = 1 # 2 sigma

# separate the the mean and std. dev tables for the benchmark
mean_table = mpi_benchmark['mean']
Expand Down

0 comments on commit 0a53795

Please sign in to comment.