Skip to content

Commit bf3d99f

Browse files
authored
Merge pull request #32 from anshuman23/dev
Fixed indentation and corrected warnings
2 parents eb5ce56 + 15fc0c4 commit bf3d99f

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

Diff for: lib/tensorflex.ex

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
defmodule Tensorflex do
22
@moduledoc """
33
A simple and fast library for running Tensorflow graph models in Elixir.
4-
Tensorflex is written around the [Tensorflow C
5-
API](https://www.tensorflow.org/install/install_c), and allows Elixir
6-
developers to leverage Machine Learning and Deep Learning solutions in their
7-
projects.
4+
Tensorflex is written around the [Tensorflow C
5+
API](https://www.tensorflow.org/install/install_c), and allows Elixir
6+
developers to leverage Machine Learning and Deep Learning solutions in their
7+
projects.
88
99
__NOTE__:
1010
@@ -24,7 +24,7 @@ projects.
2424
different tensor datatypes than the ones required by the graph can all lead to
2525
failure. While these are not easy errors to make, do ensure that you test your
2626
solution well before deployment.
27-
"""
27+
"""
2828

2929
alias Tensorflex.{NIFs, Graph, Tensor, Matrix}
3030

@@ -41,7 +41,7 @@ projects.
4141
Returns a tuple `{:ok, %Graph}`.
4242
4343
`%Graph` is an internal Tensorflex struct which holds the name of the graph
44-
file and the binary definition data that is read in via the `.pb` file.
44+
file and the binary definition data that is read in via the `.pb` file.
4545
4646
## Examples:
4747
@@ -217,7 +217,7 @@ file and the binary definition data that is read in via the `.pb` file.
217217
```
218218
"""
219219

220-
def get_graph_ops(%Graph{def: ref, name: filepath}) do
220+
def get_graph_ops(%Graph{def: ref, name: _filepath}) do
221221
NIFs.get_graph_ops(ref)
222222
end
223223

@@ -343,7 +343,7 @@ file and the binary definition data that is read in via the `.pb` file.
343343
```
344344
"""
345345

346-
def matrix_pos(%Matrix{nrows: nrows, ncols: ncols, data: ref}, row, col) when row > 0 and col > 0 do
346+
def matrix_pos(%Matrix{nrows: _nrows, ncols: _ncols, data: ref}, row, col) when row > 0 and col > 0 do
347347
NIFs.matrix_pos(ref, row, col)
348348
end
349349

@@ -370,7 +370,7 @@ file and the binary definition data that is read in via the `.pb` file.
370370
```
371371
"""
372372

373-
def size_of_matrix(%Matrix{nrows: nrows, ncols: ncols, data: ref}) do
373+
def size_of_matrix(%Matrix{nrows: nrows, ncols: ncols, data: _ref}) do
374374
{nrows, ncols}
375375
end
376376

@@ -453,7 +453,7 @@ file and the binary definition data that is read in via the `.pb` file.
453453
```
454454
"""
455455

456-
def matrix_to_lists(%Matrix{nrows: nrows, ncols: ncols, data: ref}) do
456+
def matrix_to_lists(%Matrix{nrows: _nrows, ncols: _ncols, data: ref}) do
457457
NIFs.matrix_to_lists(ref)
458458
end
459459

@@ -495,7 +495,7 @@ file and the binary definition data that is read in via the `.pb` file.
495495
```
496496
"""
497497

498-
def float64_tensor(%Matrix{nrows: val_rows, ncols: val_cols, data: val_ref}, %Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
498+
def float64_tensor(%Matrix{nrows: _val_rows, ncols: _val_cols, data: val_ref}, %Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
499499
{:ok, ref} = NIFs.float64_tensor(val_ref, dim_ref)
500500
{:ok, %Tensor{datatype: :tf_double, tensor: ref}}
501501
end
@@ -575,7 +575,7 @@ file and the binary definition data that is read in via the `.pb` file.
575575
```
576576
"""
577577

578-
def float32_tensor(%Matrix{nrows: val_rows, ncols: val_cols, data: val_ref}, %Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
578+
def float32_tensor(%Matrix{nrows: _val_rows, ncols: _val_cols, data: val_ref}, %Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
579579
{:ok, ref} = NIFs.float32_tensor(val_ref, dim_ref)
580580
{:ok, %Tensor{datatype: :tf_float, tensor: ref}}
581581
end
@@ -659,7 +659,7 @@ file and the binary definition data that is read in via the `.pb` file.
659659
```
660660
"""
661661

662-
def int32_tensor(%Matrix{nrows: val_rows, ncols: val_cols, data: val_ref}, %Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
662+
def int32_tensor(%Matrix{nrows: _val_rows, ncols: _val_cols, data: val_ref}, %Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
663663
{:ok, ref} = NIFs.int32_tensor(val_ref, dim_ref)
664664
{:ok, %Tensor{datatype: :tf_int32, tensor: ref}}
665665
end
@@ -769,7 +769,7 @@ file and the binary definition data that is read in via the `.pb` file.
769769
```
770770
"""
771771

772-
def int32_tensor_alloc(%Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
772+
def int32_tensor_alloc(%Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
773773
{:ok, ref} = NIFs.int32_tensor_alloc(dim_ref)
774774
{:ok, %Tensor{datatype: :tf_int32, tensor: ref}}
775775
end
@@ -805,7 +805,7 @@ file and the binary definition data that is read in via the `.pb` file.
805805
```
806806
"""
807807

808-
def float32_tensor_alloc(%Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
808+
def float32_tensor_alloc(%Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
809809
{:ok, ref} = NIFs.float32_tensor_alloc(dim_ref)
810810
{:ok, %Tensor{datatype: :tf_float, tensor: ref}}
811811
end
@@ -841,7 +841,7 @@ file and the binary definition data that is read in via the `.pb` file.
841841
```
842842
"""
843843

844-
def float64_tensor_alloc(%Matrix{nrows: dim_rows, ncols: dim_cols, data: dim_ref}) do
844+
def float64_tensor_alloc(%Matrix{nrows: _dim_rows, ncols: _dim_cols, data: dim_ref}) do
845845
{:ok, ref} = NIFs.float64_tensor_alloc(dim_ref)
846846
{:ok, %Tensor{datatype: :tf_double, tensor: ref}}
847847
end
@@ -871,7 +871,7 @@ file and the binary definition data that is read in via the `.pb` file.
871871
```
872872
"""
873873

874-
def tensor_datatype(%Tensor{datatype: datatype, tensor: ref}) do
874+
def tensor_datatype(%Tensor{datatype: datatype, tensor: _ref}) do
875875
{:ok, datatype}
876876
end
877877

@@ -898,7 +898,7 @@ file and the binary definition data that is read in via the `.pb` file.
898898
arguments. Support for grayscale images and other image formats such as `PNG`
899899
will be added in the future.
900900
901-
## Examples
901+
## Examples
902902
903903
To exemplify the working of the `load_image_as_tensor/1` function we will
904904
cover the entire prediction pipeline for the Inception model. However, this
@@ -992,7 +992,7 @@ file and the binary definition data that is read in via the `.pb` file.
992992
panda, panda, panda bear, coon bear, Ailuropoda melanoleuca` (Line 3691 in the
993993
file). Thus, we have correctly identified the animal in the image as a panda
994994
using Tensorflex.
995-
"""
995+
"""
996996

997997
def load_image_as_tensor(imagepath) do
998998
unless File.exists?(imagepath) do
@@ -1182,9 +1182,9 @@ file and the binary definition data that is read in via the `.pb` file.
11821182
11831183
* Working with an RNN-LSTM example for sentiment analysis is covered
11841184
[here](https://github.com/anshuman23/tensorflex/pull/25).
1185-
"""
1185+
"""
11861186

1187-
def run_session(%Graph{def: graphdef, name: filepath}, %Tensor{datatype: input_datatype, tensor: input_ref}, %Tensor{datatype: output_datatype, tensor: output_ref}, input_opname, output_opname) do
1187+
def run_session(%Graph{def: graphdef, name: _filepath}, %Tensor{datatype: _input_datatype, tensor: input_ref}, %Tensor{datatype: _output_datatype, tensor: output_ref}, input_opname, output_opname) do
11881188
NIFs.run_session(graphdef, input_ref, output_ref, input_opname, output_opname)
11891189
end
11901190

Diff for: test/tensorflex_test.exs

+5-5
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ defmodule TensorflexTest do
138138

139139
describe "graph loading and reading functionalities" do
140140
test "graph loading check" do
141-
{:ok, graph_toy} = Tensorflex.read_graph "./test/graphdef_toy.pb"
142-
{:ok, graph_iris} = Tensorflex.read_graph "./test/graphdef_iris.pb"
141+
{:ok, _graph_toy} = Tensorflex.read_graph "./test/graphdef_toy.pb"
142+
{:ok, _graph_iris} = Tensorflex.read_graph "./test/graphdef_iris.pb"
143143
end
144144

145145
test "get all graph ops" do
@@ -151,11 +151,11 @@ defmodule TensorflexTest do
151151

152152
test "incorrect usage check" do
153153
assert_raise ArgumentError, fn ->
154-
{:ok, graph} = Tensorflex.read_graph "Makefile"
154+
{:ok, _graph} = Tensorflex.read_graph "Makefile"
155155
end
156156

157157
assert_raise ArgumentError, fn ->
158-
{:ok, graph} = Tensorflex.read_graph "Makefile.pb"
158+
{:ok, _graph} = Tensorflex.read_graph "Makefile.pb"
159159
end
160160
end
161161
end
@@ -185,7 +185,7 @@ defmodule TensorflexTest do
185185

186186
test "CSV-to-matrix function incorrect usage check" do
187187
assert_raise ArgumentError, fn ->
188-
m = Tensorflex.load_csv_as_matrix("./test/sample1.csv", header: :no_header, delimiter: ",")
188+
_m = Tensorflex.load_csv_as_matrix("./test/sample1.csv", header: :no_header, delimiter: ",")
189189
end
190190
end
191191
end

0 commit comments

Comments
 (0)