Comments (10)
Thanks for pointing this out. That code looks ugly.
from rxpy.
Thanks for jumping on it so quickly. Any idea when this would get merged into master?
from rxpy.
I don't have code that triggers the bug, so it's hard for me to know if really fixes the bug. If you could verify the fix, or post some minimal code that triggers the bug, then I can make a unit-test. When we know the fix is correct, then I can merge to master.
from rxpy.
Hi, @dbrattli
Hi, @trilokacharya
I tried this by using Python 2.7 and RxPY 1.1.
I reproduced the bug in RxPY 1.1 with the code below and I also confirmed the 72eecb fixes the problem.
from __future__ import print_function
import rx
s = rx.Observable.range(0, 5)
rx.Observable.zip_array(
s,
s.skip(1),
s.skip(2)
).subscribe(print)
result
File "/usr/local/lib/python2.7/dist-packages/rx/linq/observable/ziparray.py", line 82, in action
queues[n] = []
IndexError: list assignment index out of range
from rxpy.
The code in Observable.zip
and Observable.zip_array
looks very similar. What is really the difference between zip_array
and zip(s1, s2, lambda: x, y: [x, y])
@mattpodwysocki ? I checked the JavaScript sources, and they still have both operators Observable.zipArray
and observableProto.zip
that are very similar. Would be nice if we could refactor this code, and implement zip_array
(or really zip_list
in python) just using zip
.
from rxpy.
@dbrattli, my understanding from reading the docs at http://reactivex.io/documentation/operators/zip.html is that zip_array is supposed to take a variable number of observables and zip them all.
This is not pretty, but I think it shows the intended behavior:
# Note: please excuse the formatting errors. I can't figure out how to get my formatting to stick in Markup
def flat_add(a,b):
""" if a = valueA, b = valueB : returns [valueA, valueB].
if a = [V1,V2..Vn], b = valueB : returns [V1,V2..Vn,valueB ]
"""
if isinstance(a,list):
a.append(b)
return a
else:
return [a,b]
s1 = rx.Observable.range(0, 5)
s2 = s1.skip(1)
s3 = s1.skip(2)
reduce(lambda a,b:a.zip(b,flat_add),[s1,s2,s3])
"""
result =
[0, 1, 2]
[1, 2, 3]
[2, 3, 4]
""""
from rxpy.
Yes, but you can do that already with zip
:
>>> import rx
>>> def res(*args):
... return list(args)
...
>>> s1 = rx.Observable.range(0, 5)
>>> s2 = s1.skip(1)
>>> s3 = s1.skip(2)
>>> rx.Observable.zip(s1, s2, s3, res).subscribe(print)
[0, 1, 2]
[1, 2, 3]
[2, 3, 4]
<rx.autodetachobserver.AutoDetachObserver object at 0x1025c1320>
Isn't this the same?
from rxpy.
You're right. I should've read the description better instead of just looking at the diagram and thinking zip only works on 2 observables at a time.
from rxpy.
I've now added the simplified Observable.zip_array to the develop branch.
from rxpy.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
from rxpy.
Related Issues (20)
- [Question] shiping data between asyncio and rxpy HOT 1
- [Question] Reading/writing from/to a Pandas DataFrame in rxpy HOT 2
- [TESTING] Notification equality uses string representation HOT 2
- Cannot pickle reactive classes
- unexpected behaviour regarding item count HOT 2
- Zip operator does not work HOT 3
- Rolling throttle operator
- reactivex.timer emits immediately on second subscription HOT 1
- Unexpected results of switch_map operator HOT 1
- Verson number in GitHub release is 0.0.0
- [BUG] buffer_with_time_or_count lost some data HOT 1
- [BUG] buffer_with_time_or_count loses data
- Python 3.12 deprecates timezone non aware utcfromtimestamp() and utcnow()
- This is a concurrent library, but not thread safe?
- AsyncIOScheduler.schedule is not thread safe!
- RxPY/ example / timer.py broken: Future is not iterable
- switch_map() operator not listed in documentation
- `operators.retry(n)` interferes with non-erroring repeats
- Concurrent Execution Not Working as Expected with RxPY ThreadPoolScheduler HOT 1
- Questions about Copilot + Open Source Software Hierarchy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxpy.