pwollstadt / IDTxl

The Information Dynamics Toolkit xl (IDTxl) is a comprehensive software package for efficient inference of networks and their node dynamics from multivariate time series data using information theory.
http://pwollstadt.github.io/IDTxl/
GNU General Public License v3.0
243 stars 77 forks source link

Bug: AttributeError in estimators_jidt.py for v1.5 #105

Closed LennoxLiu closed 8 months ago

LennoxLiu commented 9 months ago

Description

I encountered an error when running the demo files in demos folder after installing IDTxl-v1.5. Basically, all demo files failed because of the same bug.

I tried switching to IDTxl-v1.4 and v1.4 works well, so it's only a problem for v1.5.

Expected Behavior

The program runs successfully.

Actual Behavior

The demo file(e.g. demo_bivariate_te.py) threw an AttributeError when calling the function in file estimators_jidt.py:

File "idtxl-1.5\idtxl\estimators_jidt.py", line 1298, in estimate
    self.calc.setObservations2D(var1, var2)
AttributeError: 'infodynamics.measures.continuous.gaussian.MutualIn' object has no attribute 'setObservations2D'. Did you mean: 'setObservations'?

Step to Reproduce

Execute python demos/demo_bivariate_te.py or any other files in demos folder.

Environment

Full output

Running demos/demo_bivariate_te.py:

Adding data with properties: 5 processes, 1000 samples, 5 replications
overwriting existing data

####### analysing target with index 0 from list [0, 1, 2, 3, 4]

Target: 0 - testing sources [1, 2, 3, 4]

---------------------------- (1) include target candidates
candidate set: [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5)]
Traceback (most recent call last):
  File "My_file_path\IDTxl-1.5\demos\demo_bivariate_te.py", line 18, in <module>       
    results = network_analysis.analyse_network(settings=settings, data=data)
  File "My_file_path\idtxl-1.5\idtxl\bivariate_te.py", line 159, in analyse_network    
    res_single = self.analyse_single_target(
  File "My_file_path\idtxl-1.5\idtxl\bivariate_te.py", line 286, in analyse_single_target
    self._include_target_candidates(data)
  File "My_file_path\idtxl-1.5\idtxl\network_inference.py", line 463, in _include_target_candidates
    sources_found = self._include_candidates(candidates, data)
  File "My_file_path\idtxl-1.5\idtxl\network_inference.py", line 115, in _include_candidates
    temp_te = self._cmi_estimator.estimate_parallel(
  File "My_file_path\idtxl-1.5\idtxl\estimator.py", line 363, in estimate_parallel     
    results[i] = self.estimate(**chunk_data)
  File "My_file_path\idtxl-1.5\idtxl\estimators_jidt.py", line 1368, in estimate       
    return self.est_mi.estimate(var1, var2)
  File "My_file_path\idtxl-1.5\idtxl\estimators_jidt.py", line 1298, in estimate       
    self.calc.setObservations2D(var1, var2)
AttributeError: 'infodynamics.measures.continuous.gaussian.MutualIn' object has no attribute 'setObservations2D'. Did you mean: 'setObservations'?
jessjyu commented 9 months ago

I encountered the same issue.

jlizier commented 9 months ago

Validated.

In short: It seems v1.5 is distributing an older version of the JIDT infodynamic.jar file which overwrote the correct version on a merge from the develop branch.

More detail: The distributed jar looks to be an older build from June 2017 before we changed method calls (in both python and JIDT) to be compatible with latest jpype libaries. The jar on the main branch (along with python files) had been updated in July 2019 for this (see history of this file) but the correct jar version was overwritten more recently by the aforementioned merge from the development branch. The python code itself looks to have retained the updates, so not sure why only the jar was reverted.

Fix: In any case, infodynamics.jar needs to be replaced with the one uploaded in July 2019. Another alternative is to replace with the latest JIDT version, but that may require more testing to ensure it doesn't break anything else. Patricia and co - will leave to you guys to decide which to go with?

pwollstadt commented 9 months ago

Hi @LennoxLiu,thanks for the thorough error report. I was not in the office over the holidays, but will look into this now.

Thanks @jlizier for confirming. I think updating to a later JIDT version would be nice. Also to work with the latest JPype version. After a first quick check this does not look like too much of a hassle.

jlizier commented 9 months ago

Ok cool - you should be able to grab the jar straight from the latest v1.6.1 https://github.com/jlizier/jidt/releases/tag/v1.6.1 JIDT release (which is relatively recent from August 2023). That shouldn't break anything, but worth running the tests of course

Message ID: @.***>

xiaoxuanren commented 9 months ago

I've tried replace the infodynamis.jar 1.6 and 1.6.1 but it doesn't work. I still got the error message" AttributeError: 'infodynamics.measures.continuous.gaussian.MutualIn' object has no attribute 'setObservations2D'"

pwollstadt commented 8 months ago

Hy all, I ran a few tests on this. I could confirm the initial error and replacing the JIDT jar file with version 1.6.1 did solve the issue for me.

@xiaoxuanren what Jpype1 version are you using? That is sometimes an issue. I had no problems with Jpype1 1.2.1 and JIDT 1.6.1. Could you try that?

pwollstadt commented 8 months ago

I created a new release (v1.5.1) using JIDT version 1.6.1. I will close this for now, please let me know if the error persists. Thanks for the feedback!