Skip to content

Commit ff5c362

Browse files
committed
is_char_device: use missing
1 parent c39741b commit ff5c362

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

+stdlib/+python/is_char_device.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
y = py.pathlib.Path(file).is_char_device();
55
catch e
66
pythonException(e)
7-
y = logical([]);
7+
y = missing;
88
end
99

1010
end

+stdlib/is_char_device.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
end
2626

2727

28-
i = logical([]);
28+
i = missing;
2929

3030
for b = backend
3131
switch b
@@ -39,7 +39,7 @@
3939
error('stdlib:is_char_device:ValueError', 'Unknown backend: %s', b)
4040
end
4141

42-
if ~isempty(i)
42+
if ~ismissing(i)
4343
return
4444
end
4545
end

AGENTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ These rules apply under the namespace "stdlib" (directory +stdlib/) and all its
4545
- The code syntax must work for Matlab >= R2020b
4646
- The code must not require any Matlab toolboxes, only base Matlab functionality
4747
- Prohibited to use Matlab factory function "isMATLABReleaseOlderThan()" as it is slow, except in ./test_main.m or ./buildfile.m. Instead we use stdlib.matlabOlderThan() which is like 200x faster than isMATLABReleaseOlderThan() and works for Matlab >= R2016b
48-
- When an exception is encountered, we generally desire that the code return an "empty" value of the appropriate type. In certain cases we may throw or rethrow an error.
48+
- When an exception is encountered, we generally desire that the code return "missing". In certain cases we may throw or rethrow an error.
49+
- When a backend is not available, we require that the code return "missing". The previous behavior of returning empty array or empty char or empty string is deprecated and being transitioned.
4950
- where the output represents a filesystem path, the output should be a string type if any input is string type, otherwise char type.
5051

5152
## Dev notes

test/TestBackend.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function test_backend(tc)
9696

9797
[i,b] = stdlib.is_char_device('.');
9898
tc.assertThat(b, IsSubsetOf(stdlib.Backend('is_char_device').backends));
99-
tc.verifyNotEmpty(i);
99+
tc.verifyNotEqual(i, missing);
100100

101101
[i, b] = stdlib.is_dev_drive('.');
102102
tc.assertThat(b, IsSubsetOf(stdlib.Backend('is_dev_drive').backends))

test/TestExists.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ function test_is_char_device(tc, B_is_char_device)
6666

6767
[r, b] = stdlib.is_char_device(n, B_is_char_device);
6868
tc.assertMatches(b, B_is_char_device)
69-
tc.assertClass(r, 'logical')
7069

7170
if ismember(B_is_char_device, stdlib.Backend().select('is_char_device'))
71+
tc.assertClass(r, 'logical')
7272
tc.verifyTrue(r, n)
7373

7474
tc.verifyTrue(stdlib.is_char_device(string(n), B_is_char_device))
7575
else
76-
tc.verifyEmpty(r)
76+
tc.verifyEqual(r, missing)
7777
end
7878
end
7979
end

0 commit comments

Comments
 (0)