Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/argcheck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSoumith Chintala <soumith@gmail.com>2016-04-16 06:06:24 +0300
committerSoumith Chintala <soumith@gmail.com>2016-04-16 06:06:24 +0300
commit1781cd574bddd39fdad3b3833db510d3b8b1474f (patch)
treeefbffa8d92b1c911fee18a654c5481eb85ace2e6
parent3cab0aed4edc6e78bcb9687182cee4407dc7c367 (diff)
parent0ad1f5c6bb905cb4606b0e199e800892d4943204 (diff)
Merge pull request #7 from bamos/master
README: Briefly mention Tensor checks.
-rw-r--r--README.md32
1 files changed, 25 insertions, 7 deletions
diff --git a/README.md b/README.md
index b55912f..e1665fd 100644
--- a/README.md
+++ b/README.md
@@ -95,9 +95,9 @@ at all, `argcheck` will complain:
```lua
arguments:
{
- x = number --
+ x = number --
}
-
+
stdin:2: invalid arguments
```
@@ -142,8 +142,8 @@ becomes more clear:
```lua
> addfive('')
stdin:2: invalid arguments
-
-This function is going to do a simple addition.
+
+This function is going to do a simple addition.
Give a number, it adds 5. Amazing.
arguments:
@@ -188,9 +188,9 @@ hello world
> addfive(4)
stdin:2: invalid arguments
-
-This function is going to do a simple addition.
-Give a number, it adds 5. Amazing.
+
+This function is going to do a simple addition.
+Give a number, it adds 5. Amazing.
arguments:
{
@@ -282,6 +282,24 @@ hello world
nil
```
+### Torch Tensors
+Argcheck supports Torch Tensors type checks.
+Specific tensor types like `Int`, `Float`, or `Double` can be
+checked with `torch.<Type>Tensor`.
+Any tensor type can be checked with `torch.*Tensor`.
+
+```lua
+check = argcheck{
+ {name="anyTensor", type="torch.*Tensor"},
+ {name="fTensor", type="torch.FloatTensor"}
+}
+
+check(torch.IntTensor(), torch.FloatTensor()) -- Good.
+check(torch.FloatTensor(), torch.FloatTensor()) -- Good.
+check(torch.FloatTensor(), torch.IntTensor()) -- Invalid.
+```
+
+
### Specific per-rule check
It is possible to add an extra specific checking function for a given checking