-
Notifications
You must be signed in to change notification settings - Fork 469
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
iter for single value.... #751
Comments
This because pint (currently) uses a single type for iterable and non-iterable object. Quantity does has a |
Ok, but if I do
If I do the same with a pint object...
I'd argue pint should do the same thing as numpy... Agreed that |
True. According to the iter docs
Therefore, I think that could be accomplished by doing for |
The fix seems straightforward - just need to change class Wrapper:
def __init__(self, inner):
self.inner = inner
def __iter__(self):
it_inner = iter(self.inner)
def it_outer():
for elem in it_inner:
yield (elem, "wrapped")
return it_outer()
a = Wrapper([1, 2])
print(iter(a))
print(list(iter(a)))
b = Wrapper(1)
iter(b) Output:
|
@crusaderky Thanks for catching that! I can't believe I missed that. I put in #891 with your suggested fix. |
Perhaps related to #55, but I can't see where that was resolved...
I have the input to a function that can either be a single value or an array. I just want the first value of the array or the value. Note that this has to work with or without pint.
If I do
I get:
Note that
iter(width)
also works fine...So maybe I'm just missing something, but how do I check if
width
is a singleton?The text was updated successfully, but these errors were encountered: