Skip to content

Commit

Permalink
Add missing test data file
Browse files Browse the repository at this point in the history
  • Loading branch information
thombashi committed Jun 2, 2018
1 parent e9391b2 commit b62eb23
Showing 1 changed file with 264 additions and 0 deletions.
264 changes: 264 additions & 0 deletions test/data/DataProperty.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from __future__ import print_function\n",
"\n",
"import six"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import datetime\n",
"from dataproperty import DataProperty, DataPropertyExtractor\n",
"from typepy import Typecode\n",
"\n",
"dt = datetime.datetime(2017, 1, 1, 0, 0, 0)\n",
"inf = float(\"inf\")\n",
"nan = float(\"nan\")\n",
"data_matrix = [\n",
" [1, 1.1, \"aa\", 1, 1, True, inf, nan, dt],\n",
" [2, 2.2, \"bbb\", 2.2, 2.2, False, \"inf\", \"nan\", dt],\n",
" [3, 3.33, \"cccc\", -3, \"ccc\", \"true\", inf, \"NAN\", \"2017-01-01T01:23:45+0900\"],\n",
"]\n",
"dp_extractor = DataPropertyExtractor()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=-1.1, typename=REAL_NUMBER, align=right, ascii_char_width=4, integer_digits=1, decimal_places=1, additional_format_len=1\n"
]
}
],
"source": [
"print(DataProperty(-1.1))"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=123456789, typename=INTEGER, align=right, ascii_char_width=9, integer_digits=9, decimal_places=0, additional_format_len=0\n"
]
}
],
"source": [
"print(DataProperty(123456789))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=sample string, typename=STRING, align=left, ascii_char_width=13, length=13, additional_format_len=0\n"
]
}
],
"source": [
"print(DataProperty(\"sample string\"))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=吾輩は猫である, typename=STRING, align=left, ascii_char_width=14, length=7, additional_format_len=0\n"
]
}
],
"source": [
"print(six.text_type(DataProperty(u\"吾輩は猫である\")))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=2017-01-01 00:00:00, typename=DATETIME, align=left, ascii_char_width=19, additional_format_len=0\n"
]
}
],
"source": [
"import datetime\n",
"print(DataProperty(datetime.datetime(2017, 1, 1, 0, 0, 0)))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=2017-01-01T01:23:45+0900, typename=STRING, align=left, ascii_char_width=24, length=24, additional_format_len=0\n"
]
}
],
"source": [
"print(DataProperty(\"2017-01-01T01:23:45+0900\"))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"data=True, typename=BOOL, align=left, ascii_char_width=4, additional_format_len=0\n"
]
}
],
"source": [
"print(DataProperty(True))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"row=0, col=0, data=1, typename=INTEGER, align=right, ascii_char_width=1, integer_digits=1, decimal_places=0, additional_format_len=0\n",
"row=0, col=1, data=1.1, typename=REAL_NUMBER, align=right, ascii_char_width=3, integer_digits=1, decimal_places=1, additional_format_len=0\n",
"row=0, col=2, data=aa, typename=STRING, align=left, ascii_char_width=2, length=2, additional_format_len=0\n",
"row=0, col=3, data=1, typename=INTEGER, align=right, ascii_char_width=1, integer_digits=1, decimal_places=0, additional_format_len=0\n",
"row=0, col=4, data=1, typename=INTEGER, align=right, ascii_char_width=1, integer_digits=1, decimal_places=0, additional_format_len=0\n",
"row=0, col=5, data=True, typename=BOOL, align=left, ascii_char_width=4, additional_format_len=0\n",
"row=0, col=6, data=Infinity, typename=INFINITY, align=left, ascii_char_width=8, additional_format_len=0\n",
"row=0, col=7, data=NaN, typename=NAN, align=left, ascii_char_width=3, additional_format_len=0\n",
"row=0, col=8, data=2017-01-01 00:00:00, typename=DATETIME, align=left, ascii_char_width=19, additional_format_len=0\n",
"row=1, col=0, data=2, typename=INTEGER, align=right, ascii_char_width=1, integer_digits=1, decimal_places=0, additional_format_len=0\n",
"row=1, col=1, data=2.2, typename=REAL_NUMBER, align=right, ascii_char_width=3, integer_digits=1, decimal_places=1, additional_format_len=0\n",
"row=1, col=2, data=bbb, typename=STRING, align=left, ascii_char_width=3, length=3, additional_format_len=0\n",
"row=1, col=3, data=2.2, typename=REAL_NUMBER, align=right, ascii_char_width=3, integer_digits=1, decimal_places=1, additional_format_len=0\n",
"row=1, col=4, data=2.2, typename=REAL_NUMBER, align=right, ascii_char_width=3, integer_digits=1, decimal_places=1, additional_format_len=0\n",
"row=1, col=5, data=False, typename=BOOL, align=left, ascii_char_width=5, additional_format_len=0\n",
"row=1, col=6, data=Infinity, typename=INFINITY, align=left, ascii_char_width=8, additional_format_len=0\n",
"row=1, col=7, data=NaN, typename=NAN, align=left, ascii_char_width=3, additional_format_len=0\n",
"row=1, col=8, data=2017-01-01 00:00:00, typename=DATETIME, align=left, ascii_char_width=19, additional_format_len=0\n",
"row=2, col=0, data=3, typename=INTEGER, align=right, ascii_char_width=1, integer_digits=1, decimal_places=0, additional_format_len=0\n",
"row=2, col=1, data=3.33, typename=REAL_NUMBER, align=right, ascii_char_width=4, integer_digits=1, decimal_places=2, additional_format_len=0\n",
"row=2, col=2, data=cccc, typename=STRING, align=left, ascii_char_width=4, length=4, additional_format_len=0\n",
"row=2, col=3, data=-3, typename=INTEGER, align=right, ascii_char_width=2, integer_digits=1, decimal_places=0, additional_format_len=1\n",
"row=2, col=4, data=ccc, typename=STRING, align=left, ascii_char_width=3, length=3, additional_format_len=0\n",
"row=2, col=5, data=True, typename=BOOL, align=left, ascii_char_width=4, additional_format_len=0\n",
"row=2, col=6, data=Infinity, typename=INFINITY, align=left, ascii_char_width=8, additional_format_len=0\n",
"row=2, col=7, data=NaN, typename=NAN, align=left, ascii_char_width=3, additional_format_len=0\n",
"row=2, col=8, data=2017-01-01T01:23:45+0900, typename=STRING, align=left, ascii_char_width=24, length=24, additional_format_len=0\n"
]
}
],
"source": [
"dp_matrix = dp_extractor.to_dp_matrix(data_matrix)\n",
"\n",
"for row, dp_list in enumerate(dp_matrix):\n",
" for col, dp in enumerate(dp_list):\n",
" print(\"row={:d}, col={:d}, {}\".format(row, col, str(dp)))"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"column=0, typename=INTEGER, align=right, ascii_char_width=3, bit_len=2, integer_digits=1, decimal_places=0\n",
"column=1, typename=REAL_NUMBER, align=right, ascii_char_width=5, integer_digits=1, decimal_places=(min=1, max=2)\n",
"column=2, typename=STRING, align=left, ascii_char_width=4\n",
"column=3, typename=REAL_NUMBER, align=right, ascii_char_width=4, integer_digits=1, decimal_places=(min=0, max=1), additional_format_len=(min=0, max=1)\n",
"column=4, typename=STRING, align=left, ascii_char_width=3, integer_digits=1, decimal_places=(min=0, max=1)\n",
"column=5, typename=BOOL, align=left, ascii_char_width=5\n",
"column=6, typename=INFINITY, align=left, ascii_char_width=8\n",
"column=7, typename=NAN, align=left, ascii_char_width=3\n",
"column=8, typename=STRING, align=left, ascii_char_width=24\n"
]
}
],
"source": [
"dp_extractor.header_list = [\"int\", \"float\", \"str\", \"num\", \"mix\", \"bool\", \"inf\", \"nan\", \"time\"]\n",
"col_dp_list = dp_extractor.to_column_dp_list(dp_matrix)\n",
"\n",
"for col_idx, col_dp in enumerate(col_dp_list):\n",
" print(str(col_dp))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 1
}

0 comments on commit b62eb23

Please sign in to comment.