-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add concatenation operator #1
Comments
A problem is that "+" would also be a logical choice for concatenation, but it's already taken. Is there any precedent for using "&" for concatenation? Actually, it seems to me that "&" might be a more consistent operator for what you are now calling "+"; you are cycling property "A" and property "B" together. An alternative would be to skip the concatenation operator and use an Conclusion: use "&" for inner product composition, "+" for concatenation. |
As far as I see we could still "use" the
At the moment, trying to do 2. will error saying we have like keys, but actually this makes sense not only algebraically, but pythonically as well. Currently this error follows the logic that we can't have a repeated keyword argument, Now back to the beginning when I said to take this lightly, on the one hand it feels like jamming too much into an operator, but actually now the more I think about it, it feels perfectly right... Note, that here, as with regular algebra, we can add together products |
Although I see the logic in your suggested double-overloading of "+", it doesn't lend itself to readable code. Cycler is already a bit on the tricky side--better not to push it over the edge. It would make the "+" operator non-associative; and whether it is commutative would depend on the operands. |
I am also 👎 on double overloading of I think 'inner product' is going to be much more common than concatenation so I would rather use I think the analogy I was going for with On the other hand, using We could also just follow numpy here and have a I also have an urge to use |
From an algebraic stand point I don't see it as double-overloading, but I agree it could get a bit confusing, especially when it comes to debug. I prefer @efiring suggestions of switching the meanings of |
From a group theory pov, they are very different. There are two different My algebra professors just felt a disturbance in the force due to that We are missing some things to make these real groups: an identity element On Sun, Jul 5, 2015, 2:43 PM OceanWolf [email protected] wrote:
|
Interesting, for an identity, does Another little issue I have with the inner product, that we must use equal length... as I wrote above, I expect it to return two cycles zipped together, but that shouldn't prevent us from joining cycles of unequal lengths, right? c = cycler('lw', [1,2,3]) + cycler('color', ['r', 'g']) # with + giving inner product
c = c()
for i in range(6):
print c.next() would give
|
Thoughts an tagging a v1.0 without this feature? |
How about putting the functionality in a chain-able method?
The operator question can then be delayed a bit, without loss of functionality... (note I wrote this without properly reading the thread, nor the code, so my comment might be entirely useless 😉 ) |
Adds a top level function `concat` and a `Cycler` method `concat` which will concatenate two cyclers. The method can be chained. closes matplotlib#1
Technically, I'm not sure #20 closed this issue, as we only added a function and method, not an operator. @tacaswell - did you want to take the discussion further? |
I grew pessimistic about getting consensus on what infix operator to use so put the gh-foo close magic in my commit messages. If we accept my initial infix assignments, then we are left with the choice of I feel pretty strongly that we should not make the operators do, essentially, broadcasting and guess from looking at the keys if it should zip or concatenate. https://docs.python.org/3.5/reference/datamodel.html#emulating-numeric-types
|
Candidate operator is
&
such thatcycler('c', 'rgb') & cycler('c', 'cmyk') == cycler('c', 'rgbcmyk')
If the keys do not match exactly, raises.
The text was updated successfully, but these errors were encountered: