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

check if positions values are tuples #1832

Merged
merged 1 commit into from
Oct 8, 2023
Merged

Conversation

maskarb
Copy link
Contributor

@maskarb maskarb commented Oct 7, 2023

#1831

Add extra check to the accept_tuple_argument wrapper. If positions is a tuple of tuples of length 2, then the iter_cell_list_contents raises a TypeError.

Example, given a cell_list of ((0, 98), (1, 99)), this will unpack here x, y in cell_list as x = (0, 98) and y = (1, 99).

@maskarb maskarb force-pushed the accept-tuple-arg branch 2 times, most recently from 55b9229 to 237b2ce Compare October 7, 2023 19:27
return wrapped_function(grid_instance, [positions])
else:
return wrapped_function(grid_instance, positions)
if len(positions) == 2 and not isinstance(positions[0], tuple):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes more sense, because the previous code mistakenly detects ((1, 2), (2, 3)) as [positions].

@codecov
Copy link

codecov bot commented Oct 8, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (d888a8c) 81.38% compared to head (f813875) 81.38%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1832   +/-   ##
=======================================
  Coverage   81.38%   81.38%           
=======================================
  Files          15       15           
  Lines         881      881           
  Branches      186      186           
=======================================
  Hits          717      717           
  Misses        141      141           
  Partials       23       23           
Files Coverage Δ
mesa/space.py 90.88% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rht rht merged commit 3cbe56f into projectmesa:main Oct 8, 2023
@rht
Copy link
Contributor

rht commented Oct 8, 2023

Merged, thank you!

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 this pull request may close these issues.

2 participants