-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trying to find minimal example for #132
- Loading branch information
1 parent
89583d8
commit 9c2511e
Showing
2 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 60, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import traceback\n", | ||
"import pickle\n", | ||
"from collections import OrderedDict\n", | ||
"from lasio import HeaderItem, CurveItem" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 80, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"class TestHeaderItem(OrderedDict):\n", | ||
" def __init__(self, mnemonic='', unit='', value='', descr='', **kwargs):\n", | ||
" super(TestHeaderItem, self).__init__([\n", | ||
" ('mnemonic', mnemonic),\n", | ||
" ('unit', unit),\n", | ||
" ('value', value),\n", | ||
" ('descr', descr)\n", | ||
" ])" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 84, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"odict = OrderedDict(mnemonic='TEST', unit='mV')\n", | ||
"t_hitem = TestHeaderItem(mnemonic='TEST', unit='mV')\n", | ||
"hitem = HeaderItem(mnemonic='TEST', unit='mV')\n", | ||
"citem = CurveItem(mnemonic='TEST', unit='mV')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 85, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"OrderedDict([('mnemonic', 'TEST'), ('unit', 'mV')])\n", | ||
"TestHeaderItem([('mnemonic', 'TEST'), ('unit', 'mV'), ('value', ''), ('descr', '')])\n", | ||
"HeaderItem(mnemonic=TEST, unit=mV, value=, descr=, original_mnemonic=TEST)\n", | ||
"CurveItem(mnemonic=TEST, unit=mV, value=, descr=, original_mnemonic=TEST, data.shape=())\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print(str(odict))\n", | ||
"print(str(t_hitem))\n", | ||
"print(str(hitem))\n", | ||
"print(str(citem))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 86, | ||
"metadata": { | ||
"collapsed": false | ||
}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"-----------OrderedDict\n", | ||
"Success: OrderedDict([('mnemonic', 'TEST'), ('unit', 'mV')])\n", | ||
"-----------TestHeaderItem\n", | ||
"Success: TestHeaderItem([('mnemonic', [['mnemonic', 'TEST'], ['unit', 'mV'], ['value', ''], ['descr', '']]), ('unit', ''), ('value', ''), ('descr', '')])\n", | ||
"-----------HeaderItem\n", | ||
"Failure:\n", | ||
"Traceback (most recent call last):\n", | ||
" File \"<ipython-input-86-9fff9cb3b462>\", line 12, in <module>\n", | ||
" test = pickle.load(f)\n", | ||
" File \"C:\\Users\\kent\\Anaconda2\\lib\\pickle.py\", line 1384, in load\n", | ||
" return Unpickler(file).load()\n", | ||
" File \"C:\\Users\\kent\\Anaconda2\\lib\\pickle.py\", line 864, in load\n", | ||
" dispatch[key](self)\n", | ||
" File \"C:\\Users\\kent\\Anaconda2\\lib\\pickle.py\", line 1139, in load_reduce\n", | ||
" value = func(*args)\n", | ||
" File \"d:\\personal\\code\\lasio\\lasio\\las_items.py\", line 32, in __init__\n", | ||
" if mnemonic.strip() == '':\n", | ||
"AttributeError: 'list' object has no attribute 'strip'\n", | ||
"\n", | ||
"-----------CurveItem\n", | ||
"Failure:\n", | ||
"Traceback (most recent call last):\n", | ||
" File \"<ipython-input-86-9fff9cb3b462>\", line 12, in <module>\n", | ||
" test = pickle.load(f)\n", | ||
" File \"C:\\Users\\kent\\Anaconda2\\lib\\pickle.py\", line 1384, in load\n", | ||
" return Unpickler(file).load()\n", | ||
" File \"C:\\Users\\kent\\Anaconda2\\lib\\pickle.py\", line 864, in load\n", | ||
" dispatch[key](self)\n", | ||
" File \"C:\\Users\\kent\\Anaconda2\\lib\\pickle.py\", line 1139, in load_reduce\n", | ||
" value = func(*args)\n", | ||
" File \"d:\\personal\\code\\lasio\\lasio\\las_items.py\", line 80, in __init__\n", | ||
" super(CurveItem, self).__init__(*args, **kwargs)\n", | ||
" File \"d:\\personal\\code\\lasio\\lasio\\las_items.py\", line 32, in __init__\n", | ||
" if mnemonic.strip() == '':\n", | ||
"AttributeError: 'list' object has no attribute 'strip'\n", | ||
"\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for label, obj in [\n", | ||
" ('OrderedDict', odict),\n", | ||
" ('TestHeaderItem', t_hitem),\n", | ||
" ('HeaderItem', hitem),\n", | ||
" ('CurveItem', citem)\n", | ||
" ]:\n", | ||
" print('-----------%s' % label)\n", | ||
" with open('test', 'wb') as f:\n", | ||
" pickle.dump(obj, f)\n", | ||
" with open('test', 'rb') as f:\n", | ||
" try:\n", | ||
" test = pickle.load(f)\n", | ||
" except:\n", | ||
" print('Failure:\\n' + traceback.format_exc())\n", | ||
" else: \n", | ||
" print('Success: ' + str(test))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 2", | ||
"language": "python", | ||
"name": "python2" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.11" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
clasio.las_items | ||
CurveItem | ||
p0 | ||
((lp1 | ||
tp2 | ||
Rp3 | ||
(dp4 | ||
S'mnemonic' | ||
p5 | ||
S'TEST' | ||
p6 | ||
sS'descr' | ||
p7 | ||
S'' | ||
p8 | ||
sS'useful_mnemonic' | ||
p9 | ||
g6 | ||
sS'value' | ||
p10 | ||
g8 | ||
sS'original_mnemonic' | ||
p11 | ||
g6 | ||
sS'data' | ||
p12 | ||
cnumpy.core.multiarray | ||
_reconstruct | ||
p13 | ||
(cnumpy | ||
ndarray | ||
p14 | ||
(I0 | ||
tp15 | ||
S'b' | ||
p16 | ||
tp17 | ||
Rp18 | ||
(I1 | ||
(tcnumpy | ||
dtype | ||
p19 | ||
(S'f8' | ||
p20 | ||
I0 | ||
I1 | ||
tp21 | ||
Rp22 | ||
(I3 | ||
S'<' | ||
p23 | ||
NNNI-1 | ||
I-1 | ||
I0 | ||
tp24 | ||
bI00 | ||
S'P\x1cx\x02\x00\x00\x00\x00' | ||
p25 | ||
tp26 | ||
bsS'unit' | ||
p27 | ||
S'mV' | ||
p28 | ||
sb. |