Bug in remove command in Web VPython 3.2?

36 views
Skip to first unread message

Jethomas5

unread,
Jul 28, 2022, 1:28:09 AM7/28/22
to Glowscript Users
bb=[1, 2, 3]
bb.remove(1)

aa=[vec( -1.5, -1.5, 1.5 ), vec( -1.5, 1.5, -1.5 ), vec( 1.5, -1.5, -1.5 ), vec( 1.5, 1.5, 1.5)]

aa.remove(vec( -1.5, -1.5, 1.5 ))


ValueError: < -1.5, -1.5, 1.5 > not in list

Harlan Gilbert

unread,
Jul 28, 2022, 1:35:31 AM7/28/22
to glowscri...@googlegroups.com
It works if you assign 
x=vec…
aa=[x, …
aa.remove(x)



--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/glowscript-users/d823718f-9e28-476b-bdeb-9c31fd1bfd8an%40googlegroups.com.
--
Harlan Gilbert, Ph.D.
High School Chair and Math, Physics, Computer Science, and Philosophy Teacher
Green Meadow Waldorf High School
Chestnut Ridge, NY 10977

Bruce Sherwood

unread,
Jul 28, 2022, 12:24:49 PM7/28/22
to Glowscript Users
That's very odd. It looks like it's a bug in the RapydScript-NG Python-to-JavaScript transpiler, and I've asked its developer about this. Thanks for the report.

Emmanuel Vendé

unread,
Jul 28, 2022, 12:44:43 PM7/28/22
to glowscri...@googlegroups.com
Probably the __hash__ method of vpython.vector class does not return same value for 2 objects constructed with vector() constructor with same numeric input values. Maybe due to vector() implementation or, if not the case and like Bruce suggests, due to transpiler. 
If at transpiling level, can result from different origins though.
It's tricky indeed

Le jeu. 28 juil. 2022, 18:24, Bruce Sherwood <bruce.s...@gmail.com> a écrit :
That's very odd. It looks like it's a bug in the RapydScript-NG Python-to-JavaScript transpiler, and I've asked its developer about this. Thanks for the report.

--

---
You received this message because you are subscribed to the Google Groups "Glowscript Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to glowscript-use...@googlegroups.com.

Bruce Sherwood

unread,
Jul 28, 2022, 2:14:05 PM7/28/22
to Glowscript Users
It's not just vectors. Here is the report I made to the RapydScript-NG developer REPL is a place where you can try out the transpiler: )https://sw.kovidgoyal.net/rapydscript/repl/

The following program throws an error in the REPL: ValueError: [1, 2, 3] not in list

a = [[1,2,3], 5, 10]
a.remove([1,2,3])
print(a)

Does this make any sense to you? In contrast, print([1,2,3] in a) yields True.

Bruce Sherwood

unread,
Aug 4, 2022, 1:20:32 PM8/4/22
to Glowscript Users
Web VPython now correctly handles the "index", "remove", and "in" methods for lists that contain vectors and/or lists.

Thanks for the report!

Bruce

Reply all
Reply to author
Forward
0 new messages