Skip to content

Commit

Permalink
Release updates (#697)
Browse files Browse the repository at this point in the history
* Silenced Pandas and Numpy warnings
* Ugly workarounds for markdown-rendering bugs in Jupyter
* Updated to match changes in HoloViews
* Fixed typos and wording
  • Loading branch information
jbednar authored Jan 29, 2019
1 parent 29da688 commit f945be4
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 68 deletions.
23 changes: 12 additions & 11 deletions datashader/transfer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def eq_hist(data, mask=None, nbins=256*256):
if not isinstance(data, np.ndarray):
raise TypeError("data must be np.ndarray")
data2 = data if mask is None else data[~mask]
if np.issubdtype(data2.dtype, np.integer):
if data2.dtype == bool or np.issubdtype(data2.dtype, np.integer):
hist = np.bincount(data2.ravel())
bin_centers = np.arange(len(hist))
idx = np.nonzero(hist)[0][0]
Expand Down Expand Up @@ -210,16 +210,17 @@ def _interpolate(agg, cmap, how, alpha, span, min_alpha, name):

interp = data - offset

data = interpolater(interp, mask)
if span is None:
span = [np.nanmin(data), np.nanmax(data)]
else:
if how == 'eq_hist':
# For eq_hist to work with span, we'll need to store the histogram
# from the data and then apply it to the span argument.
raise ValueError("span is not (yet) valid to use with eq_hist")

span = interpolater([0, span[1] - span[0]], 0)
with np.errstate(invalid="ignore", divide="ignore"):
data = interpolater(interp, mask)
if span is None:
span = [np.nanmin(data), np.nanmax(data)]
else:
if how == 'eq_hist':
# For eq_hist to work with span, we'll need to store the histogram
# from the data and then apply it to the span argument.
raise ValueError("span is not (yet) valid to use with eq_hist")

span = interpolater([0, span[1] - span[0]], 0)

if isinstance(cmap, Iterator):
cmap = list(cmap)
Expand Down
9 changes: 5 additions & 4 deletions examples/getting_started/2_Pipeline.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"from collections import OrderedDict as odict\n",
"\n",
"num=10000\n",
"np.random.seed(1)\n",
"\n",
"dists = {cat: pd.DataFrame.from_items([('x',np.random.normal(x,s,num)), \n",
" ('y',np.random.normal(y,s,num)), \n",
" ('val',val), \n",
" ('cat',cat)]) \n",
"dists = {cat: pd.DataFrame(odict([('x',np.random.normal(x,s,num)), \n",
" ('y',np.random.normal(y,s,num)), \n",
" ('val',val), \n",
" ('cat',cat)])) \n",
" for x, y, s, val, cat in \n",
" [( 2, 2, 0.03, 10, \"d1\"), \n",
" ( 2, -2, 0.10, 20, \"d2\"), \n",
Expand Down
9 changes: 5 additions & 4 deletions examples/getting_started/3_Interactivity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@
"import numpy as np\n",
"import datashader as ds\n",
"import datashader.transfer_functions as tf\n",
"from collections import OrderedDict as odict\n",
"\n",
"num=100000\n",
"np.random.seed(1)\n",
"\n",
"dists = {cat: pd.DataFrame.from_items([('x',np.random.normal(x,s,num)), \n",
" ('y',np.random.normal(y,s,num)), \n",
" ('val',val), \n",
" ('cat',cat)]) \n",
"dists = {cat: pd.DataFrame(odict([('x',np.random.normal(x,s,num)), \n",
" ('y',np.random.normal(y,s,num)), \n",
" ('val',val), \n",
" ('cat',cat)])) \n",
" for x, y, s, val, cat in \n",
" [( 2, 2, 0.03, 10, \"d1\"), \n",
" ( 2, -2, 0.10, 20, \"d2\"), \n",
Expand Down
2 changes: 1 addition & 1 deletion examples/nyc_taxi-nongeo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
"source": [
"Here datashader is aggregating over both fare_amount and trip_distance, but trip_distance was specified to have only a height of 2, because it will be further collapsed to create the histogram being displayed. You can now use the wheel zoom tool when hovering over the x axis, and the plot will zoom in or out, dynamically resampling at the given location to make a new histogram (as long as there is a live Python server running). \n",
"\n",
"In this particular plot, there is a very wide range of fare amounts, with an implausibly high maximum fare of over \\$4000, but you can easily zoom in to the bulk of the data to show that nearly all fares are between \\$4 and \\$20, following something like a gamma distribution, and they are discretized to the nearest $0.50 in this dataset."
"In this particular plot, there is a very wide range of fare amounts, with an implausibly high maximum fare of over 4000 dollars, but you can easily zoom in to the bulk of the data to show that nearly all fares are between 4 and 20 dollars, following something like a gamma distribution, and they are discretized to the nearest 50 cents in this dataset."
]
}
],
Expand Down
2 changes: 1 addition & 1 deletion examples/topics/nyc_taxi.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
4 changes: 2 additions & 2 deletions examples/user_guide/10_Performance.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"```\n",
"\n",
"If your data includes categorical values that take on a limited, fixed\n",
"number of possible values (e.g. \"Male\", \"Female\"), With parquet,\n",
"categorical columns use a more memory-efficient data representation and\n",
"number of possible values (e.g. \"Male\", \"Female\"),\n",
"Parquet's categorical columns use a more memory-efficient data representation and\n",
"are optimized for common operations such as sorting and finding uniques.\n",
"Before saving, just convert the column as follows:\n",
"\n",
Expand Down
Loading

0 comments on commit f945be4

Please sign in to comment.