signalling-games-org / evoke

A Python package for evolutionary signalling games
https://evoke.readthedocs.io/en/latest/
GNU General Public License v3.0
1 stars 1 forks source link

Vectorize loops where appropriate #48

Open stephenfmann opened 1 year ago

stephenfmann commented 1 year ago

Loops that might be vectorizable:

stephenfmann commented 1 year ago

@manolomartinez What version of numpy do you have? I'm on 1.21.2 but sender_pairs = sender_payoff_matrix.T[pairs] failed with a FutureWarning.

I'm going to update my numpy, and I think we need to change the dependency in pyproject.toml (currently numpy = ">1.20") to whatever you have.

manolomartinez commented 1 year ago

What does the warning say? If we can support older versions of numpy it's better, I suppose

stephenfmann commented 1 year ago

I already upgraded numpy and didn't save the message, but it basically said "in future this will work differently, to ensure backwards compatibility please wrap your list of tuples in np.array(). It wants sender_payoff_matrix.T[pairs] to be sender_payoff_matrix.T[np.array(pairs)], ditto for the next line with receiver_payoff_matrix.

Shall I put this in and make older versions of numpy happy? The earliest version I have that doesn't display the message is 1.24.2, so it's only some versions earlier than that which will have problems.

manolomartinez commented 1 year ago

Shall I put this in and make older versions of numpy happy?

Yeah, I'd do that.