Skip to content

Commit

Permalink
Merge 59f97ba into 2ba25c5
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanhemani committed Jul 2, 2019
2 parents 2ba25c5 + 59f97ba commit 497491c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pip install datascience

This project adheres to [Semantic Versioning](http://semver.org/).

### v0.12.1
* Adds a new optional argument to `make_array` to specify the dtype of the data.

### v0.12.0
* Changes `Table#scatter`'s argument name of `colors` to `group` to mirror `Table#hist`.
* Makes a grouped scatterplot's legend identical to a group histogram's legend.
Expand Down
4 changes: 3 additions & 1 deletion datascience/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Change matplotlib formatting. TODO incorporate into a style?
plt.rcParams["patch.force_edgecolor"] = True

def make_array(*elements):
def make_array(*elements, dtype=None):
"""Returns an array containing all the arguments passed to this function.
A simple way to make an array with a few elements.
Expand All @@ -33,6 +33,8 @@ def make_array(*elements):
>>> make_array()
array([], dtype=float64)
"""
if dtype:
return np.array(elements, dtype=dtype)
return np.array(elements)


Expand Down
2 changes: 1 addition & 1 deletion datascience/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.12.0'
__version__ = '0.12.1'
15 changes: 14 additions & 1 deletion tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@
from datascience import util
import numpy as np


def test_doctests():
results = doctest.testmod(util, optionflags=doctest.NORMALIZE_WHITESPACE)
assert results.failed == 0

def test_make_array_dtype():
test1 = ds.make_array(0)
assert len(test1) == 1
test2 = ds.make_array(2, 3, 4)
assert sum(test2) == 9
test3 = ds.make_array("foo", "bar")
assert test3.dtype == "<U3"
test4 = ds.make_array(1, 2, 3, dtype="int32")
assert test4.dtype == "int32"
test5 = ds.make_array(1, 2, 3, dtype="int64")
assert test5.dtype == "int64"
test6 = ds.make_array("foo", "bar", dtype="<U6")
assert test6.dtype == "<U6"


def test_percentile():
assert ds.percentile(0, [1, 3, 5, 9]) == 1
Expand Down

0 comments on commit 497491c

Please sign in to comment.