pyt-team / TopoNetX

Computing on Topological Domains
https://pyt-team.github.io/toponetx/
MIT License
172 stars 31 forks source link

Inconsistencies in `__contains__` implementation across complex types #273

Open ffl096 opened 9 months ago

ffl096 commented 9 months ago

The function __contains__ is not consistently implemented across different complex types:

The Complex ABC documents that __contains__ checks whether the complex contains an item (i.e., simplicial and path complexes are correct).

mhajij commented 9 months ago

@ffl096 there is an issue here though. Iter iterates only over nodes now consistent with NetworkX (we just closed this issue recently ). So it would make more sense to make __getitem__ also works same way? namely it will only check if a node is in the complex. If one wants to check if an item is in the complex then one should check in CC.cells or PC.paths or SC.simplices, also consistent with NetworkX, what do you think?

ffl096 commented 9 months ago

I agree on that, __iter__, __contains__ and so on should be consistent in that a complex does not "contain" something that is not iterated over ect. We have to update the documentation of Complex.__contains__ for that.