From 0ad1f5c6bb905cb4606b0e199e800892d4943204 Mon Sep 17 00:00:00 2001 From: Brandon Amos Date: Fri, 25 Mar 2016 16:25:21 -0400 Subject: README: Briefly mention Tensor checks. --- README.md | 32 +++++++++++++++++++++++++------- 1 file 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.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 -- cgit v1.2.3