Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nfill for blank values in ndlist #2

Merged
merged 10 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 15 additions & 19 deletions build.tcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package require tin 1.0
tin import assert from tin
tin import tcltest
set version 0.1.1
set version 0.2
set vutil_version 1.1
set config [dict create VERSION $version VUTIL_VERSION $vutil_version]
tin bake src build $config
Expand All @@ -22,7 +22,7 @@ test nrepeat {
# Assert that nrepeat works
} -body {
ndlist 2D {1 {2 3}}
} -result {{1 0} {2 3}}
} -result {{1 {}} {2 3}}

# nrepeat
################################################################################
Expand All @@ -33,17 +33,17 @@ test nrepeat {
nrepeat {1 2 3} 0
} -result {{{0 0 0} {0 0 0}}}

# nrange
# range
################################################################################
puts "Creating nrange"
test nrange {
puts "Creating range"
test range {
# Generate range of integers
} -body {
assert [nrange 3] eq [nrange 0 2]
assert [nrange 10 3 -2] eq {10 8 6 4}
assert [nrange 4] eq {0 1 2 3}
assert [nrange 0 4] eq {0 1 2 3 4}
assert [nrange 0 4 2] eq {0 2 4}
assert [range 3] eq [range 0 2]
assert [range 10 3 -2] eq {10 8 6 4}
assert [range 4] eq {0 1 2 3}
assert [range 0 4] eq {0 1 2 3 4}
assert [range 0 4 2] eq {0 2 4}
} -result {}

# nshape/nsize
Expand Down Expand Up @@ -321,7 +321,7 @@ test nset_I_2D {
for {set i 0} {$i < 3} {incr i} {
nset I $i $i 1
}
set I
nfill 2D $I 0
} -result {{1 0 0} {0 1 0} {0 0 1}}

test nset_I_3D {
Expand All @@ -331,7 +331,7 @@ test nset_I_3D {
for {set i 0} {$i < 3} {incr i} {
nset I $i $i $i 1
}
set I
nfill 3D $I 0
} -result {{{1 0 0} {0 0 0} {0 0 0}} {{0 0 0} {0 1 0} {0 0 0}} {{0 0 0} {0 0 0} {0 0 1}}}

test nset2 {
Expand All @@ -341,17 +341,13 @@ test nset2 {
nset a {1 0} : [nget $a {0 1} :]
} -result {{3 4} {1 2} {5 6}}

test nset_filler {
# Test out custom filler
test nset_fill_foobar {
# Fill blanks with a value.
} -body {
assert $::ndlist::filler eq 0
set a ""
set ::ndlist::filler bar; # custom filler
nset a 1 1 1 foo
nfill 3D $a bar
} -result {{{bar bar} {bar bar}} {{bar bar} {bar foo}}}
set ::ndlist::filler 0; # reset to default



# nop
test nop1 {
Expand Down
Binary file modified doc/ndlist.pdf
Binary file not shown.
Loading