Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] error in importing adjacency matrix with Pyntacle.importer #57

Open
Bioswinger opened this issue Mar 8, 2021 · 2 comments
Open

Comments

@Bioswinger
Copy link

command used:
g1=Pyntalce.importer.AdjacencyMatrix("my_directed_graph.adjm")

error received:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-221-d7b8e50b8195> in <module>()
      1 from pyntacle.io_stream.importer import PyntacleImporter as Pyimp
      2 
----> 3 g1=Pyimp.AdjacencyMatrix("pws_48_mass_transfer.txt")

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pyntacle/internal/io_utils.py in func_wrapper(file, *args, **kwargs)
     51             raise FileNotFoundError("Input file does not exist")
     52 
---> 53         return func(file, *args, **kwargs)
     54 
     55     return func_wrapper

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pyntacle/internal/io_utils.py in func_wrapper(file, sep, *args, **kwargs)
     97                 raise ValueError("\"sep\" must be a string {} found".format(type(sep).__name__))
     98 
---> 99         return func(file, sep, *args, **kwargs)
    100 
    101     return func_wrapper

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pyntacle/io_stream/importer.py in AdjacencyMatrix(file, sep, header)
    140                 f.index = f.index.map(str) #force index to string, in case is not identified properly
    141                 f = f.reindex(sorted(f.columns), axis=1)  # sort columns alphabetically
--> 142                 f = f.reindex(sorted(f.index), axis=0)  # sort indices alphabetically
    143                 node_names = f.columns.values.tolist()
    144 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/util/_decorators.py in wrapper(*args, **kwargs)
    307         @wraps(func)
    308         def wrapper(*args, **kwargs) -> Callable[..., Any]:
--> 309             return func(*args, **kwargs)
    310 
    311         kind = inspect.Parameter.POSITIONAL_OR_KEYWORD

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/frame.py in reindex(self, *args, **kwargs)
   4034         kwargs.pop("axis", None)
   4035         kwargs.pop("labels", None)
-> 4036         return super().reindex(**kwargs)
   4037 
   4038     def drop(

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/generic.py in reindex(self, *args, **kwargs)
   4460         # perform the reindex on the axes
   4461         return self._reindex_axes(
-> 4462             axes, level, limit, tolerance, method, fill_value, copy
   4463         ).__finalize__(self, method="reindex")
   4464 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/frame.py in _reindex_axes(self, axes, level, limit, tolerance, method, fill_value, copy)
   3881         if index is not None:
   3882             frame = frame._reindex_index(
-> 3883                 index, method, copy, level, fill_value, limit, tolerance
   3884             )
   3885 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/frame.py in _reindex_index(self, new_index, method, copy, level, fill_value, limit, tolerance)
   3903             copy=copy,
   3904             fill_value=fill_value,
-> 3905             allow_dups=False,
   3906         )
   3907 

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/generic.py in _reindex_with_indexers(self, reindexers, fill_value, copy, allow_dups)
   4528                 fill_value=fill_value,
   4529                 allow_dups=allow_dups,
-> 4530                 copy=copy,
   4531             )
   4532             # If we've made a copy once, no need to make another one

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/internals/managers.py in reindex_indexer(self, new_axis, indexer, axis, fill_value, allow_dups, copy, consolidate)
   1274         # some axes don't allow reindexing with dups
   1275         if not allow_dups:
-> 1276             self.axes[axis]._can_reindex(indexer)
   1277 
   1278         if axis >= self.ndim:

/home/lorenzo/miniconda3/envs/new_pynt_env/lib/python3.7/site-packages/pandas/core/indexes/base.py in _can_reindex(self, indexer)
   3287         # trying to reindex on an axis with duplicates
   3288         if not self.is_unique and len(indexer):
-> 3289             raise ValueError("cannot reindex from a duplicate axis")
   3290 
   3291     def reindex(self, target, method=None, level=None, limit=None, tolerance=None):

ValueError: cannot reindex from a duplicate axis
@mazzalab
Copy link
Owner

mazzalab commented Mar 9, 2021

can you share here the "pws_48_mass_transfer.txt" file?

@Bioswinger
Copy link
Author

of course, here the file
pws_48_mass_transfer.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants