Skip to content

Commit

Permalink
removed debugging statement
Browse files Browse the repository at this point in the history
  • Loading branch information
m-wells committed Feb 14, 2020
1 parent 96e161d commit 28b15f6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 84 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "AlignedBinaryFormat"
uuid = "94fc9360-1a5e-4d84-93be-ddbadb32b3a7"
authors = ["m-wells <[email protected]>"]
version = "0.5.2"
version = "0.5.3"

[deps]
Mmap = "a63ad114-7e13-5084-954f-fe012c677804"
Expand Down
82 changes: 39 additions & 43 deletions README.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -85,17 +85,10 @@
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"string(AbfSerializer) = \"AbfSerializer\"\n"
]
},
{
"data": {
"text/plain": [
"AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_jrx5dO>)\n",
"AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_cMROHo>)\n",
"┌────────────┬──────────────────┬───────────┬────────┬────────────┐\n",
"│ label │ type │ shape │ bytes │ status │\n",
"├────────────┼──────────────────┼───────────┼────────┼────────────┤\n",
Expand Down Expand Up @@ -151,11 +144,11 @@
"name": "stdout",
"output_type": "stream",
"text": [
"count(abf[\"bitmat\"]) = 5\n",
"count(abf[\"bitmat\"]) = 3\n",
"this is what I did\n",
"and how!\n",
"\n",
"AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_jrx5dO>)\n",
"AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_cMROHo>)\n",
"┌────────────┬──────────────────┬───────────┬────────┬────────────┐\n",
"│ label │ type │ shape │ bytes │ status │\n",
"├────────────┼──────────────────┼───────────┼────────┼────────────┤\n",
Expand Down Expand Up @@ -223,42 +216,42 @@
"output_type": "stream",
"text": [
"x = 10-element Array{Float64,1}:\n",
" 0.41808342392430364\n",
" 0.8340965780634206 \n",
" 0.4422525925297145 \n",
" 0.7464876087842214 \n",
" 0.8760053500303144 \n",
" 0.8812312947613306 \n",
" 0.12907825453926614\n",
" 0.8227926275555029 \n",
" 0.5770610771209626 \n",
" 0.2427376128034029 \n",
" 0.6737894194841203 \n",
" 0.28704212997665324\n",
" 0.8980864989824102 \n",
" 0.5948813070093115 \n",
" 0.03298590842249727\n",
" 0.9587674078053836 \n",
" 0.4213390775874484 \n",
" 0.8851345495595084 \n",
" 0.35869029635893646\n",
" 0.4629117484636671 \n",
"\n",
"AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_jrx5dO>)\n",
"AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_cMROHo>)\n",
"┌───────┬──────────────────┬───────┬───────┬────────┐\n",
"│ label │ type │ shape │ bytes │ status │\n",
"├───────┼──────────────────┼───────┼───────┼────────┤\n",
"│ x │ Array{Float64,1} │ (10,) │ <80B> │ loaded │\n",
"└───────┴──────────────────┴───────┴───────┴────────┘\n",
"\n",
"\n",
"AlignedBinaryFormat.AbfFile([closed] <file /tmp/jl_jrx5dO>)\n",
"AlignedBinaryFormat.AbfFile([closed] <file /tmp/jl_cMROHo>)\n",
"┌───────┬──────┬───────┬───────┬────────┐\n",
"│ label │ type │ shape │ bytes │ status │\n",
"├───────┼──────┼───────┼───────┼────────┤\n",
"└───────┴──────┴───────┴───────┴────────┘\n",
"\n",
"x = 10-element Array{Float64,1}:\n",
" 0.41808342392430364\n",
" 0.8340965780634206 \n",
" 0.4422525925297145 \n",
" 0.7464876087842214 \n",
" 0.8760053500303144 \n",
" 0.8812312947613306 \n",
" 0.12907825453926614\n",
" 0.8227926275555029 \n",
" 0.5770610771209626 \n",
" 0.2427376128034029 \n",
" 0.6737894194841203 \n",
" 0.28704212997665324\n",
" 0.8980864989824102 \n",
" 0.5948813070093115 \n",
" 0.03298590842249727\n",
" 0.9587674078053836 \n",
" 0.4213390775874484 \n",
" 0.8851345495595084 \n",
" 0.35869029635893646\n",
" 0.4629117484636671 \n",
"\n"
]
}
Expand Down Expand Up @@ -309,27 +302,27 @@
"output_type": "stream",
"text": [
"file opened with \"w\"\n",
"AlignedBinaryFormat.ReadOnlyError(IOStream(<file /tmp/jl_jrx5dO>))\n",
"AlignedBinaryFormat.AbfReadError(IOStream(<file /tmp/jl_cMROHo>))\n",
"\n",
"file opened with \"w+\"\n",
"x[1] = 0.9897101065968341\n",
"x[1] = 0.3923187061956266\n",
"x[1] = -1.0\n",
"\n",
"file opened with \"r+\"\n",
"(abf[\"x\"])[1] = 3.0\n",
"abf[\"y\"] = [0.8188509909345121, 0.7005578254412208]\n",
"abf[\"y\"] = [0.3650633407781294, 0.06535729174631832]\n",
"\n",
"file opened with \"r\"\n",
"x[1] = 3.0\n",
"abf[\"y\"] = [0.8188509909345121, 0.7005578254412208]\n",
"abf[\"y\"] = [0.3650633407781294, 0.06535729174631832]\n",
"ReadOnlyMemoryError()\n",
"\n",
"file opened with \"a\"\n",
"AlignedBinaryFormat.ReadOnlyError(IOStream(<file /tmp/jl_jrx5dO>))\n",
"AlignedBinaryFormat.AbfReadError(IOStream(<file /tmp/jl_cMROHo>))\n",
"\n",
"file opened with \"a+\"\n",
"(read(abf, \"x\"))[1] = 3.0\n",
"(read(abf, \"z\"))[1] = 0.07216051054053385\n"
"(read(abf, \"z\"))[1] = 0.9387386553608443\n"
]
}
],
Expand All @@ -340,7 +333,8 @@
" try\n",
" x = read(abf, \"x\")\n",
" catch e\n",
" println(e)\n",
" show(e)\n",
" println()\n",
" end\n",
"end\n",
"println(\"\\nfile opened with \\\"w+\\\"\")\n",
Expand All @@ -366,15 +360,17 @@
" try\n",
" x[1] = 3\n",
" catch e\n",
" println(e)\n",
" show(e)\n",
" println()\n",
" end\n",
"end;\n",
"println(\"\\nfile opened with \\\"a\\\"\")\n",
"abfopen(temp, \"a\") do abf\n",
" try\n",
" x = read(abf, \"x\")\n",
" catch e\n",
" println(e)\n",
" show(e)\n",
" println()\n",
" end\n",
" write(abf, \"z\", rand(3))\n",
"end;\n",
Expand Down Expand Up @@ -475,7 +471,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_jrx5dO>)\n",
"AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_cMROHo>)\n",
"┌───────────┬──────────────────┬─────────┬────────┬────────────┐\n",
"│ label │ type │ shape │ bytes │ status │\n",
"├───────────┼──────────────────┼─────────┼────────┼────────────┤\n",
Expand Down
76 changes: 38 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,10 @@ end
abf = abfopen(temp, "r")
```

string(AbfSerializer) = "AbfSerializer"





AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_jrx5dO>)
AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_cMROHo>)
┌────────────┬──────────────────┬───────────┬────────┬────────────┐
│ label │ type │ shape │ bytes │ status │
├────────────┼──────────────────┼───────────┼────────┼────────────┤
Expand Down Expand Up @@ -100,11 +97,11 @@ println(read(abf, "log"))
show(abf)
```

count(abf["bitmat"]) = 5
count(abf["bitmat"]) = 3
this is what I did
and how!

AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_jrx5dO>)
AlignedBinaryFormat.AbfFile([read] <file /tmp/jl_cMROHo>)
┌────────────┬──────────────────┬───────────┬────────┬────────────┐
│ label │ type │ shape │ bytes │ status │
├────────────┼──────────────────┼───────────┼────────┼────────────┤
Expand Down Expand Up @@ -153,42 +150,42 @@ println("\n")
```

x = 10-element Array{Float64,1}:
0.41808342392430364
0.8340965780634206
0.4422525925297145
0.7464876087842214
0.8760053500303144
0.8812312947613306
0.12907825453926614
0.8227926275555029
0.5770610771209626
0.2427376128034029
0.6737894194841203
0.28704212997665324
0.8980864989824102
0.5948813070093115
0.03298590842249727
0.9587674078053836
0.4213390775874484
0.8851345495595084
0.35869029635893646
0.4629117484636671

AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_jrx5dO>)
AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_cMROHo>)
┌───────┬──────────────────┬───────┬───────┬────────┐
│ label │ type │ shape │ bytes │ status │
├───────┼──────────────────┼───────┼───────┼────────┤
│ x │ Array{Float64,1} │ (10,) │ <80B> │ loaded │
└───────┴──────────────────┴───────┴───────┴────────┘


AlignedBinaryFormat.AbfFile([closed] <file /tmp/jl_jrx5dO>)
AlignedBinaryFormat.AbfFile([closed] <file /tmp/jl_cMROHo>)
┌───────┬──────┬───────┬───────┬────────┐
│ label │ type │ shape │ bytes │ status │
├───────┼──────┼───────┼───────┼────────┤
└───────┴──────┴───────┴───────┴────────┘

x = 10-element Array{Float64,1}:
0.41808342392430364
0.8340965780634206
0.4422525925297145
0.7464876087842214
0.8760053500303144
0.8812312947613306
0.12907825453926614
0.8227926275555029
0.5770610771209626
0.2427376128034029
0.6737894194841203
0.28704212997665324
0.8980864989824102
0.5948813070093115
0.03298590842249727
0.9587674078053836
0.4213390775874484
0.8851345495595084
0.35869029635893646
0.4629117484636671



Expand All @@ -215,7 +212,8 @@ abfopen(temp, "w") do abf
try
x = read(abf, "x")
catch e
println(e)
show(e)
println()
end
end
println("\nfile opened with \"w+\"")
Expand All @@ -241,15 +239,17 @@ abfopen(temp, "r") do abf
try
x[1] = 3
catch e
println(e)
show(e)
println()
end
end;
println("\nfile opened with \"a\"")
abfopen(temp, "a") do abf
try
x = read(abf, "x")
catch e
println(e)
show(e)
println()
end
write(abf, "z", rand(3))
end;
Expand All @@ -261,27 +261,27 @@ end;
```

file opened with "w"
AlignedBinaryFormat.ReadOnlyError(IOStream(<file /tmp/jl_jrx5dO>))
AlignedBinaryFormat.AbfReadError(IOStream(<file /tmp/jl_cMROHo>))

file opened with "w+"
x[1] = 0.9897101065968341
x[1] = 0.3923187061956266
x[1] = -1.0

file opened with "r+"
(abf["x"])[1] = 3.0
abf["y"] = [0.8188509909345121, 0.7005578254412208]
abf["y"] = [0.3650633407781294, 0.06535729174631832]

file opened with "r"
x[1] = 3.0
abf["y"] = [0.8188509909345121, 0.7005578254412208]
abf["y"] = [0.3650633407781294, 0.06535729174631832]
ReadOnlyMemoryError()

file opened with "a"
AlignedBinaryFormat.ReadOnlyError(IOStream(<file /tmp/jl_jrx5dO>))
AlignedBinaryFormat.AbfReadError(IOStream(<file /tmp/jl_cMROHo>))

file opened with "a+"
(read(abf, "x"))[1] = 3.0
(read(abf, "z"))[1] = 0.07216051054053385
(read(abf, "z"))[1] = 0.9387386553608443


## Why not use `JLD/HDF5`?
Expand Down Expand Up @@ -348,7 +348,7 @@ abfopen(temp, "w+") do abf
end;
```

AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_jrx5dO>)
AlignedBinaryFormat.AbfFile([read/write] <file /tmp/jl_cMROHo>)
┌───────────┬──────────────────┬─────────┬────────┬────────────┐
│ label │ type │ shape │ bytes │ status │
├───────────┼──────────────────┼─────────┼────────┼────────────┤
Expand Down
8 changes: 6 additions & 2 deletions src/AlignedBinaryFormat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ struct AbfReadError <: Exception
io::IOStream
end

function Base.showerror(io::IO, e::T) where T<:AbfReadError
print(io, T, ": isreadable(", e.io.name, ") = ", isreadable(e.io))
function Base.showerror(io::IO, e::AbfReadError)
print(io, "AbfReadError: isreadable(", e.io.name, ") = ", isreadable(e.io))
end

check_readable(io::IOStream) = isreadable(io) ? nothing : throw(AbfReadError(io))
Expand All @@ -22,6 +22,10 @@ struct AbfWriteError <: Exception
io::IOStream
end

function Base.showerror(io::IO, e::AbfWriteError)
print(io, "AbfWriteError: iswritable(", e.io.name, ") = ", iswritable(e.io))
end

#function Base.showerror(io::IO, e::AbfWriteError)
# print(io, "iswritable(", e.io.name, ") = ", iswritable(e.io))
#end
Expand Down

0 comments on commit 28b15f6

Please sign in to comment.