collection module not accessible from the top module

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

collection module not accessible from the top module

stalaga
Hi,

I am not quite sure if it is a bug or a design decision (although it seems
quite inconvenient, so I guess it may be a bug), but `collection` module is
not accessible from the top module object.

More specifically, this code does not run:

import graph_tool as gt
gt.collection.data['karate']

----
AttributeError: module 'graph_tool' has no attribute 'collection'
----

And according to the documentation it should
(https://graph-tool.skewed.de/static/doc/collection.html)

As a matter of fact the same problem affects also other submodules, for
instance `spectral` also cannot
be accesses via an attribute of the top module `gt` after importing.

Graph-tool version I am using is: '2.31 (commit b1411e3e, Sun Mar 29
21:53:41 2020 +0200)'
I installed it a few days ago from conda-forge, so I guess it is up-to-date.

Thanks in advance for any help with this problem (maybe I am doing something
wrong?). And thanks for this great package!

Best,
Szymon.



--
Sent from: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool
Reply | Threaded
Open this post in threaded view
|

Re: collection module not accessible from the top module

Tiago Peixoto
Administrator
Am 12.05.20 um 22:52 schrieb stalaga:

> I am not quite sure if it is a bug or a design decision (although it seems
> quite inconvenient, so I guess it may be a bug), but `collection` module is
> not accessible from the top module object.
>
> More specifically, this code does not run:
>
> import graph_tool as gt
> gt.collection.data['karate']
>
> ----
> AttributeError: module 'graph_tool' has no attribute 'collection'
> ----
In Python, a module (even a submodule) needs to be imported before it
can be used, so you need to do:

   import graph_tool.collection
   graph_tool.collection.data['karate']

As is explained in the documentation, there is a convenience module
called 'all' which imports all submodules, so you do not need to do this
individually for each one:

   import graph_tool.all as gt
   gt.collection.data['karate']

Best,
Tiago

--
Tiago de Paula Peixoto <[hidden email]>


_______________________________________________
graph-tool mailing list
[hidden email]
https://lists.skewed.de/mailman/listinfo/graph-tool

signature.asc (849 bytes) Download Attachment
--
Tiago de Paula Peixoto <tiago@skewed.de>