You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running tests with tox is much more powerful, but requires a bit more setup.
273
273
274
-
You'll need to export an environment variable for *each* tox environment you wish to test with. For example, if you want to test with `Python 2.7` and
274
+
You'll need to export an environment variable for *each* tox environment you wish to test with. For example, if you want to test with `Python 3.9` and
275
275
`Python 3.6`, but only care to check the `core` specs, you would need to ensure that the following variables are exported:
276
276
277
277
```
278
-
export PLOTLY_TOX_PYTHON_27=<python binary>
278
+
export PLOTLY_TOX_PYTHON_39=<python binary>
279
279
export PLOTLY_TOX_PYTHON_36=<python binary>
280
280
```
281
281
@@ -286,15 +286,15 @@ Where the `<python binary` is going to be specific to your development setup. As
286
286
# tox envs #
287
287
############
288
288
289
-
exportPLOTLY_TOX_PYTHON_27=python2.7
290
-
exportPLOTLY_TOX_PYTHON_34=python3.4
291
-
export TOXENV=py27-core,py34-core
289
+
exportPLOTLY_TOX_PYTHON_39=python3.9
290
+
exportPLOTLY_TOX_PYTHON_36=python3.6
291
+
export TOXENV=py39-core,py36-core
292
292
```
293
293
294
294
Where `TOXENV` is the environment list you want to use when invoking `tox` from the command line. Note that the `PLOTLY_TOX_*` pattern is used to pass in variables for use in the `tox.ini` file. Though this is a little setup, intensive, you'll get the following benefits:
295
295
296
296
*`tox` will automatically manage a virtual env for each environment you want to test in.
297
-
* You only have to run `tox` and know that the module is working in both `Python 2` and `Python 3`.
297
+
* You only have to run `tox` and know that the module is working in all included Python versions.
298
298
299
299
Finally, `tox` allows you to pass in additional command line arguments that are formatted in (by us) in the `tox.ini` file, see `{posargs}`. This is setup to help with our configuration of [pytest markers](http://doc.pytest.org/en/latest/example/markers.html), which are set up in `packages/python/plotly/pytest.ini`. To run only tests that are *not* tagged with `nodev`, you could use the following command:
Copy file name to clipboardExpand all lines: doc/unconverted/python/amazon-redshift.md
-2
Original file line number
Diff line number
Diff line change
@@ -45,8 +45,6 @@ This notebook will go over one of the easiest ways to graph data from your [Amaz
45
45
In this notebook we'll be using [Amazon's Sample Redshift Data](http://docs.aws.amazon.com/redshift/latest/gsg/rs-gsg-create-sample-db.html) for this notebook. Although we won't be connecting through a JDBC/ODBC connection we'll be using the [psycopg2 package](http://initd.org/psycopg/docs/index.html) with [SQLAlchemy](http://www.sqlalchemy.org/) and [pandas](http://pandas.pydata.org/) to make it simple to query and analyze our data.
46
46
47
47
```python
48
-
from__future__import print_function #python 3 support
Copy file name to clipboardExpand all lines: packages/python/plotly/plotly/figure_factory/README.md
+13-21
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Add A Figure Factory to the Plotly [Python Library](https://plot.ly/python/)
2
2
3
+
Note: we are generally NOT accepting new figure factories anymore. We'll keep this doc around for context and in case we decide to make an exception, but we've found that figure factories expand the scope of the library (and its maintenance burden) beyond what really makes sense, and generates confusion about how these figures relate to the underlying plotly.js objects.
4
+
5
+
That doesn't mean this pattern is discouraged though, far from it! We encourage you to make more such high-level functions and share them with the community as separate PyPI packages, GitHub Gists, or posts on https://community.plotly.com.
6
+
3
7
## What is a Figure Factory?
4
8
In the Python Plotly Library:
5
9
@@ -61,8 +65,6 @@ If you are making a chart called `foo`, then you must create `_foo.py` in this d
61
65
The inside of the `__init__.py` looks like:
62
66
63
67
```
64
-
from __future__ import absolute_import
65
-
66
68
# Require that numpy exists for figure_factory
67
69
import numpy
68
70
@@ -78,19 +80,9 @@ Now add the following line to the end of `__init__.py`:
78
80
from plotly.figure_factory._foo import create_foo
79
81
```
80
82
81
-
3.Imports
83
+
3.The main function
82
84
83
-
In `_foo.py` write
84
-
85
-
```
86
-
from __future__ import absolute_import
87
-
```
88
-
89
-
at line 1. You can add other imports later if you will need them.
90
-
91
-
4. The main function
92
-
93
-
It's now time to write the main function `create_foo` that will be called directly by the user. It has the form:
85
+
It's now time to write the main function `create_foo` that will be called directly by the user. It lives in `_foo.py` and has the form:
The figure `fig` must be a Plotly Figure, meaning it must have the form `fig = graph_objs.Figure(data=data, layout=layout)`.
138
130
139
-
5. Useful Tips
131
+
4. Useful Tips
140
132
141
133
It is often not a good idea to put all your code into your `create_foo()` function. It is best practice to not repeat yourself and this requires taking repeated blocks of code and putting them into a separate function.
142
134
143
135
It is best to make all other functions besides `create_foo()` secret so a user cannot access them. This is done by placing a `_` before the name of the function, so `_aux_func()` for example.
0 commit comments