mirror of
https://github.com/donnemartin/data-science-ipython-notebooks.git
synced 2024-03-22 13:30:56 +08:00
Renamed Util to TypeUtil in the IPython Notebook to be more more descriptive. Previously I erroneously renamed this in the generated .py file only.
This commit is contained in:
parent
1bc5e1cf83
commit
adc34fe231
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"metadata": {
|
||||
"name": "",
|
||||
"signature": "sha256:4c5eb8edee509b17587401073eef999428a00c5241d92995407623e288d445f1"
|
||||
"signature": "sha256:de3e7aeb6537656e464e30d624c213fb29ce962afef43280fb2d84c3a1ca1858"
|
||||
},
|
||||
"nbformat": 3,
|
||||
"nbformat_minor": 0,
|
||||
|
@ -348,7 +348,7 @@
|
|||
"collapsed": false,
|
||||
"input": [
|
||||
"%%file type_util.py\n",
|
||||
"class Util:\n",
|
||||
"class TypeUtil:\n",
|
||||
"\n",
|
||||
" @classmethod\n",
|
||||
" def is_iterable(cls, obj):\n",
|
||||
|
@ -399,18 +399,18 @@
|
|||
"input": [
|
||||
"%%file tests/test_type_util.py\n",
|
||||
"from nose.tools import assert_equal\n",
|
||||
"from pydatasnippets.core.type_util import Util\n",
|
||||
"from pydatasnippets.core.type_util import TypeUtil\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class TestUtil():\n",
|
||||
"\n",
|
||||
" def test_is_iterable(self):\n",
|
||||
" assert_equal(Util.is_iterable('foo'), True)\n",
|
||||
" assert_equal(Util.is_iterable(7), False)\n",
|
||||
" assert_equal(TypeUtil.is_iterable('foo'), True)\n",
|
||||
" assert_equal(TypeUtil.is_iterable(7), False)\n",
|
||||
"\n",
|
||||
" def test_convert_to_list(self):\n",
|
||||
" assert_equal(isinstance(Util.convert_to_list('foo'), list), True)\n",
|
||||
" assert_equal(isinstance(Util.convert_to_list(7), list), False)"
|
||||
" assert_equal(isinstance(TypeUtil.convert_to_list('foo'), list), True)\n",
|
||||
" assert_equal(isinstance(TypeUtil.convert_to_list(7), list), False)"
|
||||
],
|
||||
"language": "python",
|
||||
"metadata": {},
|
||||
|
|
|
@ -16,8 +16,8 @@ class TypeUtil:
|
|||
|
||||
@classmethod
|
||||
def convert_to_list(cls, obj):
|
||||
"""Converts obj to a list if it is not a list and it is iterable, else
|
||||
returns the original obj.
|
||||
"""Converts obj to a list if it is not a list and it is iterable,
|
||||
else returns the original obj.
|
||||
"""
|
||||
if not isinstance(obj, list) and cls.is_iterable(obj):
|
||||
obj = list(obj)
|
||||
|
|
Loading…
Reference in New Issue
Block a user