TransWikia.com

Accessing elements in Set

Stack Overflow Asked by lost_and_found on November 15, 2021

I am quite new to Python and thus struggling with its structures. Please ignore my silliness. I tried my best to find a solution but failed so far.

I have a set "self.gamma" which looks like

{<pomdpy.solvers.alpha_vector.AlphaVector object at 0x0000015E7B5F8908>, <pomdpy.solvers.alpha_vector.AlphaVector object at 0x0000015E7B5F8E48>, <pomdpy.solvers.alpha_vector.AlphaVector object at 0x0000015E7B5F8948>

I want to access its elements and I can do it this way:

[av.v for av in self.gamma]
[av.action for av in self.gamma]

which gives

[array([-95. ,   9.5]), array([  9.5, -95. ]), array([-0.95, -0.95])]
[1, 2, 0]

respectively. There are two types of data in the set – "v" (short for value) and "actions". Here is what I want to do:

  1. Do what I did without the for loop
  2. Access individual arrays from within self.gamma, e.g., self.gamma.v[0] should give me array([-95. , 9.5])

I hope I was clear with my question. Thank you in advance!

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP