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

'list' object has no attribute 'discard' #431

Closed
vhvictorhugo opened this issue Mar 24, 2024 · 5 comments · Fixed by #436
Closed

'list' object has no attribute 'discard' #431

vhvictorhugo opened this issue Mar 24, 2024 · 5 comments · Fixed by #436

Comments

@vhvictorhugo
Copy link

vhvictorhugo commented Mar 24, 2024

I'm trying to execute the hex2vec_embedder.ipynb notebook, but the follow error appears when i execute all the notebook (without any changes):

OBS: the error appears in the cell that generate region embeddings, i. e., before viewing the embeddings' similarity.

File ~/.local/lib/python3.10/site-packages/srai/neighbourhoods/_base.py:161, in Neighbourhood._handle_center(self, index, distance, neighbours, at_distance, include_center_override)

159 neighbours.add(index)
160 else:
--> 161 neighbours.discard(index)
162 return neighbours

AttributeError: 'list' object has no attribute 'discard'

I've been looking to this function (_handle_center at srai/neighbourhoods/_base.py file) that the problems appear and setting the neighbours variable as python set, like neighbours = set(neighbours) at the beginning of the function and works fine, but i'm reporting this problem because i belive that have another optimized ways to resolve this problem.

This colab notebook contains the complete error code.

@vhvictorhugo
Copy link
Author

vhvictorhugo commented Mar 24, 2024

Captura de tela de 2024-03-23 22-49-06
I'm leaving a print of the solution that i mentioned at the issue.

OBS: the line 145 contains the alteration mentioned.

@piotrgramacki
Copy link
Collaborator

Hi @vhvictorhugo,
Thanks for letting us know about it. We'll look at it to find a permanent solution, but your solution will give you the correct results. There should be a set there in all cases.

@vhvictorhugo
Copy link
Author

Hello, @piotrgramacki!
Thanks for your attention! For now i'll continue this way. I'm awaiting for new updates.

@piotrgramacki
Copy link
Collaborator

This problem is a result of a change in the h3 library: https://github.com/uber/h3-py/releases/tag/v4.0.0b3
We'll update our library and release a new version soon.

For now, one solution to this problem is to apply the change proposed by @vhvictorhugo. Another one (if you don't want to install srai as an editable package) is to install the previous version of the h3 library with h3==4.0.0b2 in the requirements file.

@vhvictorhugo
Copy link
Author

Thanks for feedback @piotrgramacki

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

Successfully merging a pull request may close this issue.

2 participants