-
Notifications
You must be signed in to change notification settings - Fork 22
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
Error while executing repeat_report #55
Comments
The problem is that your reporter returns more then one value, while the current code assumes that a reporter returns only a single value. |
Hi. Thanks for the prompt reply. However, when I query for xcor of sheep in the wolf sheep predation model it returns a list of xcors for each tick. What am I missing? How do I get the xcors of all turtles at each tick? Thanks for your help. |
that is actually a good question that warrants some investigation. My hunch is that it has to do with how jpype (the python library that bridges to java) automatically converts stuff and the knock-on effects of this in pynetlogo. |
can you test what happens if you do
|
I have tried with all turtle attributes, both inbuilt and user created. Same result. Could it possibly be something to do with the netlogo version the model is created in? I used 6.2.2 |
I think the issue can be resolved by changing line 617 in core.py to |
Thanks for the suggested fix, I will have to test this once I have a bit more time. |
OS: Fedora 36
Netlogo version: 6.2.2
pyNetlogo version 0.4.2
python version 3.10
Netlogo Model:
pyNetlogo Code:
Error:
ValueError Traceback (most recent call last)
/tmp/ipykernel_66101/872701698.py in
1 netlogo.command('setup')
----> 2 df = netlogo.repeat_report('[xcor] of turtles',100)
~/.local/lib/python3.10/site-packages/pyNetLogo/core.py in repeat_report(self, netlogo_reporter, reps, go, include_t0)
615 for entry in result.split()])
616
--> 617 results_df.loc[:, key] = result
618
619 os.remove(value)
~/.local/lib/python3.10/site-packages/pandas/core/indexing.py in setitem(self, key, value)
721
722 iloc = self if self.name == "iloc" else self.obj.iloc
--> 723 iloc._setitem_with_indexer(indexer, value, self.name)
724
725 def _validate_key(self, key, axis: int):
~/.local/lib/python3.10/site-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value, name)
1730 self._setitem_with_indexer_split_path(indexer, value, name)
1731 else:
-> 1732 self._setitem_single_block(indexer, value, name)
1733
1734 def _setitem_with_indexer_split_path(self, indexer, value, name: str):
~/.local/lib/python3.10/site-packages/pandas/core/indexing.py in _setitem_single_block(self, indexer, value, name)
1966
1967 # actually do the set
-> 1968 self.obj._mgr = self.obj._mgr.setitem(indexer=indexer, value=value)
1969 self.obj._maybe_update_cacher(clear=True)
1970
~/.local/lib/python3.10/site-packages/pandas/core/internals/managers.py in setitem(self, indexer, value)
353
354 def setitem(self: T, indexer, value) -> T:
--> 355 return self.apply("setitem", indexer=indexer, value=value)
356
357 def putmask(self, mask, new, align: bool = True):
~/.local/lib/python3.10/site-packages/pandas/core/internals/managers.py in apply(self, f, align_keys, ignore_failures, **kwargs)
325 applied = b.apply(f, **kwargs)
326 else:
--> 327 applied = getattr(b, f)(**kwargs)
328 except (TypeError, NotImplementedError):
329 if not ignore_failures:
~/.local/lib/python3.10/site-packages/pandas/core/internals/blocks.py in setitem(self, indexer, value)
981 values, len(values[indexer]), value # type: ignore[arg-type]
982 )
--> 983 values[indexer] = value
984
985 if transpose:
ValueError: could not broadcast input array from shape (101,10) into shape (101,)
The text was updated successfully, but these errors were encountered: