From 562a79cd766e68608c7e89b56ff857787da316cd Mon Sep 17 00:00:00 2001 From: Dag Brattli Date: Sat, 5 Mar 2022 15:18:44 +0100 Subject: [PATCH] Update docs for pre-release install --- .pre-commit-config.yaml | 2 +- README.rst | 20 ++---- authors.txt | 2 +- docs/installation.rst | 2 +- notebooks/Getting Started.ipynb | 116 +++++++++++++++++--------------- 5 files changed, 71 insertions(+), 71 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0525e740e..972ff8000 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -26,7 +26,7 @@ repos: language: node pass_filenames: false types: [python] - additional_dependencies: ["pyright@1.1.226"] + additional_dependencies: ["pyright@1.1.227"] repo: local - hooks: - id: mypy diff --git a/README.rst b/README.rst index f0dfba9bd..9247fc755 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,7 @@ install: .. code:: console - pip3 install reactivex + pip3 install reactivex --pre About ReactiveX @@ -77,17 +77,9 @@ There is also a list of third party documentation available `here Community ---------- -Join the conversation on Slack! - -The gracious folks at `PySlackers `_ have given us a home -in the `#rxpy `_ Slack channel. Please -join us there for questions, conversations, and all things related to RxPY. - -To join, navigate the page above to receive an email invite. After signing up, -join us in the #rxpy channel. - -Please follow the community guidelines and terms of service. - +Join the conversation on GitHub `Discussions +`_! if you have any questions or +suggestions. Differences from .NET and RxJS ------------------------------ @@ -100,8 +92,8 @@ is mostly a direct port of RxJS, but also borrows a bit from Rx.NET and RxJava i terms of threading and blocking operators. ReactiveX for Python follows `PEP 8 `_, so -all function and method names are lowercase with words separated by underscores as -necessary to improve readability. +all function and method names are ``snake_cased`` i.e lowercase with words separated by +underscores as necessary to improve readability. Thus .NET code such as: diff --git a/authors.txt b/authors.txt index d1a9276da..be455e281 100644 --- a/authors.txt +++ b/authors.txt @@ -1,4 +1,4 @@ -RxPY v3 team +ReactiveX for Python maintainers Dag Brattli @dbrattli Erik Kemperman, @erikkemperman diff --git a/docs/installation.rst b/docs/installation.rst index f3a6c9a8f..63638dfdc 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -7,7 +7,7 @@ ReactiveX for Python v4.x runs on `Python `__ 3. To inst .. code:: console - pip3 install reactivex + pip3 install reactivex --pre RxPY v3.x runs on `Python `__ 3. To install RxPY: diff --git a/notebooks/Getting Started.ipynb b/notebooks/Getting Started.ipynb index e8b3bd0d7..88559611f 100644 --- a/notebooks/Getting Started.ipynb +++ b/notebooks/Getting Started.ipynb @@ -56,7 +56,7 @@ ], "source": [ "%%bash\n", - "pip install rx" + "pip install reactivex" ] }, { @@ -68,14 +68,15 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import reactivex\n", - "from reactivex import Observable, Observer" + "from reactivex import operators as ops\n", + "from reactivex import Observer" ] }, { @@ -89,7 +90,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 23, "metadata": { "collapsed": false }, @@ -113,23 +114,23 @@ } ], "source": [ - "class MyObserver(Observer):\n", - " def on_next(self, x):\n", - " print(\"Got: %s\" % x)\n", - " \n", - " def on_error(self, e):\n", - " print(\"Got error: %s\" % e)\n", - " \n", + "class MyObserver(Observer[int]):\n", + " def on_next(self, value: int):\n", + " print(\"Got: %s\" % value)\n", + "\n", + " def on_error(self, error: Exception):\n", + " print(\"Got error: %s\" % error)\n", + "\n", " def on_completed(self):\n", " print(\"Sequence completed\")\n", "\n", - "xs = Observable.from_iterable(range(10))\n", + "xs = reactivex.from_iterable(range(10))\n", "d = xs.subscribe(MyObserver())" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": { "collapsed": false }, @@ -152,7 +153,7 @@ } ], "source": [ - "xs = Observable.from_(range(10))\n", + "xs = reactivex.from_(range(10))\n", "d = xs.subscribe(print)" ] }, @@ -172,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 9, "metadata": { "collapsed": false, "scrolled": true @@ -191,10 +192,11 @@ } ], "source": [ - "xs = Observable.from_(range(10))\n", - "d = xs.filter(\n", + "xs = reactivex.from_(range(10))\n", + "d = xs.pipe(\n", + " ops.filter(\n", " lambda x: x % 2\n", - " ).subscribe(print)" + " )).subscribe(print)" ] }, { @@ -206,7 +208,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "metadata": { "collapsed": false }, @@ -229,10 +231,11 @@ } ], "source": [ - "xs = Observable.from_(range(10))\n", - "d = xs.map(\n", + "xs = reactivex.from_(range(10))\n", + "d = xs.pipe(\n", + " ops.map(\n", " lambda x: x * 2\n", - " ).subscribe(print)" + " )).subscribe(print)" ] }, { @@ -244,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 12, "metadata": { "collapsed": false }, @@ -262,10 +265,11 @@ } ], "source": [ - "xs = Observable.from_(range(10, 20, 2))\n", - "d = xs.map(\n", + "xs = reactivex.from_(range(10, 20, 2))\n", + "d = xs.pipe(\n", + " ops.map_indexed(\n", " lambda x, i: \"%s: %s\" % (i, x * 2)\n", - " ).subscribe(print)" + " )).subscribe(print)" ] }, { @@ -279,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 13, "metadata": { "collapsed": false }, @@ -288,23 +292,22 @@ "name": "stdout", "output_type": "stream", "text": [ - "a\n", "1\n", + "a\n", "b\n", - "2\n", "c\n", - "3\n", "d\n", - "4\n", "e\n", - "5\n" + "2\n", + "3\n", + "4\n" ] } ], "source": [ - "xs = Observable.range(1, 5)\n", - "ys = Observable.from_(\"abcde\")\n", - "zs = xs.merge(ys).subscribe(print)" + "xs = reactivex.range(1, 5)\n", + "ys = reactivex.from_(\"abcde\")\n", + "zs = xs.pipe(ops.merge(ys)).subscribe(print)" ] }, { @@ -329,11 +332,11 @@ "source": [ "## Marbles and Marble Diagrams\n", "\n", - "As we saw in the previous section it's nice to add some time when playing with Rx and RxPY. A great way to explore RxPY is to use the `marbles` test module that enables us to play with [marble diagrams](http://rxmarbles.com). The marbles module adds two new extension methods to `Observable`. The methods are `from_marbles()` and `to_marbles()`.\n", + "As we saw in the previous section it's nice to add some time when playing with Rx and RxPY. A great way to explore RxPY is to use the `marbles` test module that enables us to play with [marble diagrams](http://rxmarbles.com). The marbles module adds two new function to. The methods are `from_marbles()` and `to_marbles()`.\n", "\n", "Examples:\n", - "1. `res = reactivex.Observable.from_marbles(\"1-2-3-|\")`\n", - "2. `res = reactivex.Observable.from_marbles(\"1-2-3-x\", rx.Scheduler.timeout)`\n", + "1. `res = reactivex.from_marbles(\"1-2-3-|\")`\n", + "2. `res = reactivex.from_marbles(\"1-2-3-x\", rx.Scheduler.timeout)`\n", "\n", "The marble string consists of some special characters:\n", "\n", @@ -350,7 +353,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 17, "metadata": { "collapsed": false }, @@ -358,19 +361,17 @@ { "data": { "text/plain": [ - "'a-b-c-|'" + "['a', 'b', 'c']" ] }, - "execution_count": 8, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "from reactivex.testing import marbles\n", - "\n", - "xs = Observable.from_marbles(\"a-b-c-|\")\n", - "xs.to_blocking().to_marbles()" + "xs = reactivex.from_marbles(\"a-b-c-|\")\n", + "xs.pipe(ops.to_list()).run()" ] }, { @@ -384,7 +385,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 24, "metadata": { "collapsed": false }, @@ -392,18 +393,25 @@ { "data": { "text/plain": [ - "'11-22-33-4x'" + "" ] }, - "execution_count": 9, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "error\n" + ] } ], "source": [ - "xs = Observable.from_marbles(\"1-2-3-x-5\")\n", - "ys = Observable.from_marbles(\"1-2-3-4-5\")\n", - "xs.merge(ys).to_blocking().to_marbles()" + "xs = reactivex.from_marbles(\"1-2-3-#-\")\n", + "ys = reactivex.from_marbles(\"1-2-3-4-5\")\n", + "xs.pipe(ops.merge(ys)).subscribe(on_error=print)" ] }, { @@ -419,7 +427,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 16, "metadata": { "collapsed": false }, @@ -435,7 +443,7 @@ "source": [ "from reactivex.subject import Subject\n", "\n", - "stream = Subject()\n", + "stream = Subject[int]()\n", "stream.on_next(41)\n", "\n", "d = stream.subscribe(lambda x: print(\"Got: %s\" % x))\n", @@ -479,7 +487,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.10.0" } }, "nbformat": 4,