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

EnsembleConfig::devices in Swig/python. #682

Closed
ptheywood opened this issue Sep 2, 2021 · 2 comments · Fixed by #749
Closed

EnsembleConfig::devices in Swig/python. #682

ptheywood opened this issue Sep 2, 2021 · 2 comments · Fixed by #749

Comments

@ptheywood
Copy link
Member

CUDAEnsemble::EnsembleConfig::devices is a std::set<int>.

This does not appear to be well-wrapped by swig currently, so is not (obviously) usable from python (other than via the CLI)

The current command line argument takes a comma separated string of non-negative integers, which is parsed into a std::set.

Although uniqueness is useful, it might be worth using an order-preserving data structure (although probably not neccesary). This might also help if Swig is not great with sets, as we know it's usable with vectors. It could then be converted to a set at time of use.

@Robadob
Copy link
Member

Robadob commented Sep 2, 2021

swig has a std_set.i file, so it might just need to be included.

Found in _deps\swig-src\Lib\python

@Robadob
Copy link
Member

Robadob commented Dec 9, 2021

Have fixed this, PR coming soon.

Type "help", "copyright", "credits" or "license" for more information.
>>> import pyflamegpu
>>> model = pyflamegpu.ModelDescription("m")
>>> sim = pyflamegpu.CUDAEnsemble(model)
>>> sim.Config().devices
<pyflamegpu.pyflamegpu.IntSet; proxy of <Swig Object of type 'std::set< int > *' at 0x0000024C2061E090> >
>>> for a in sim.Config().devices:
...   print(a)
...
>>> sim.Config().devices+=1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +=: 'IntSet' and 'int'
>>> sim.Config().devices.add(1)
>>> for a in sim.Config().devices:
...   print(a)
...
1
>>> sim.Config().devices.add(1333)
>>> sim.Config().devices.add(1)
>>> for a in sim.Config().devices:
...   print(a)
...
1
1333

Robadob added a commit that referenced this issue Dec 9, 2021
This is a set, so wasn't being handled by Swig by default.

Closes #682
mondus pushed a commit that referenced this issue Dec 14, 2021
This is a set, so wasn't being handled by Swig by default.

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

Successfully merging a pull request may close this issue.

2 participants