Problem with types in jython console

Extensions and customization
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
stablum
Posts:2
Joined:04 Jan 2013 15:45
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Problem with types in jython console

Post by stablum » 04 Jan 2013 15:50

Hi,

I am trying to run a graph metric algorithm in the jython console. Unfortunately I cannot call the method 'execute' in a GraphDistance object.

This is the class of statistics object I need to use:

Code: Select all

>>> type(gd)
<type 'org.gephi.statistics.plugin.GraphDistance'>
The type of the graph class is this:

Code: Select all

>>> type(gu)
<type 'org.gephi.graph.dhns.graph.HierarchicalUndirectedGraphImpl'>
That is actually a subclass of HierarchicalGraph:

Code: Select all

>>> gu.class.__bases__[0].__bases__[0]
<type 'org.gephi.graph.api.HierarchicalGraph'>
I also have the 'attributes' object as requested:

Code: Select all

>>> type(ga)
<type 'org.gephi.data.attributes.AttributeRowImpl'>
But the execute states that the required type is not correct:

Code: Select all

>>> gd.execute(gu,ga)
Traceback (most recent call last):
  File "<input>", line 1, in <module>
TypeError: execute(): 1st arg can't be coerced to org.gephi.graph.api.HierarchicalGraph, org.gephi.graph.api.GraphModel
This does not make much sense for me since the class of the graph object I am using is derived from the class that is required.

Any ideas?

User avatar
eduramiba
Gephi Code Manager
Posts:1064
Joined:22 Mar 2010 15:30
Location:Madrid, Spain
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Problem with types in jython console

Post by eduramiba » 04 Jan 2013 23:13

Hi,
The first argument actually looks fine, but the second argument should be of type org.gephi.data.attributes.api.AttributeModel instead of org.gephi.data.attributes.AttributeRowImpl.

Eduardo

stablum
Posts:2
Joined:04 Jan 2013 15:45
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Problem with types in jython console

Post by stablum » 06 Jan 2013 15:32

Thanks! Do you know how to get the AttributeModel? I am trying to experiment with many methods of the 'g' global variable, but i am not finding anything useful.
cheers,
Francesco

User avatar
eduramiba
Gephi Code Manager
Posts:1064
Joined:22 Mar 2010 15:30
Location:Madrid, Spain
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Problem with types in jython console

Post by eduramiba » 07 Jan 2013 14:35

Hi,
Try the following code:

Code: Select all

import org.openide.util.Lookup;
import org.gephi.data.attributes.api.AttributeController;
org.openide.util.Lookup.getDefault().lookup(org.gephi.data.attributes.api.AttributeController).getModel();
You can obtain many different controllers such as GraphController, AttributeController or DynamicController in Gephi through the Lookup mechanism.
Eduardo

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable