diff --git a/+stdlib/+dotnet/create_symlink.m b/+stdlib/+dotnet/create_symlink.m index 05d19a6e..f13de249 100644 --- a/+stdlib/+dotnet/create_symlink.m +++ b/+stdlib/+dotnet/create_symlink.m @@ -1,6 +1,5 @@ -%% DOTNET.CREATE_SYMLINK create symbolic link to target - function ok = create_symlink(target, link) +% DOTNET.CREATE_SYMLINK create symbolic link to target if ~stdlib.exists(target) || stdlib.strempty(link) || stdlib.exists(link) ok = false; diff --git a/+stdlib/+dotnet/disk_available.m b/+stdlib/+dotnet/disk_available.m index c609041a..9b34723b 100644 --- a/+stdlib/+dotnet/disk_available.m +++ b/+stdlib/+dotnet/disk_available.m @@ -1,6 +1,5 @@ -%% DOTNET.DISK_AVAILABLE find the disk space available to the user - function i = disk_available(file) +% DOTNET.DISK_AVAILABLE find the disk space available to the user i = uint64([]); % Windows needs exists() not just strempty() diff --git a/+stdlib/+dotnet/disk_capacity.m b/+stdlib/+dotnet/disk_capacity.m index a032c8eb..33879b87 100644 --- a/+stdlib/+dotnet/disk_capacity.m +++ b/+stdlib/+dotnet/disk_capacity.m @@ -1,6 +1,5 @@ -%% DOTNET.DISK_CAPACITY find the overall disk capacity visible to user - function i = disk_capacity(file) +% DOTNET.DISK_CAPACITY find the overall disk capacity visible to user i = uint64([]); % Windows needs exists() not just strempty() diff --git a/+stdlib/+dotnet/file_checksum.m b/+stdlib/+dotnet/file_checksum.m index 843aac6a..5fdb01df 100644 --- a/+stdlib/+dotnet/file_checksum.m +++ b/+stdlib/+dotnet/file_checksum.m @@ -1,8 +1,8 @@ -%% DOTNET.FILE_CHECKSUM compute checksum has of file - +function hash = file_checksum(file, hash_method) +% DOTNET.FILE_CHECKSUM compute checksum has of file +% % Ref: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/MessageDigest.html#getInstance(java.lang.String) -function hash = file_checksum(file, hash_method) if strcmpi(hash_method, 'sha256') hash_method = "SHA-256"; diff --git a/+stdlib/+dotnet/filesystem_type.m b/+stdlib/+dotnet/filesystem_type.m index b0a9f877..c9d2e489 100644 --- a/+stdlib/+dotnet/filesystem_type.m +++ b/+stdlib/+dotnet/filesystem_type.m @@ -1,6 +1,7 @@ -%% DOTNET.FILESYSTEM_TYPE type of the partition e.g. NTFS, ext4, ... - function t = filesystem_type(file) +% DOTNET.FILESYSTEM_TYPE type of the partition e.g. NTFS, ext4, ... +% +% Ref: % https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.driveformat t = ''; @@ -9,7 +10,6 @@ return end -% https://learn.microsoft.com/en-us/dotnet/api/system.io.driveinfo.driveformat try t = char(System.IO.DriveInfo(System.IO.Path.GetFullPath(file)).DriveFormat); diff --git a/+stdlib/+dotnet/get_owner.m b/+stdlib/+dotnet/get_owner.m index a4c8bc17..06138895 100644 --- a/+stdlib/+dotnet/get_owner.m +++ b/+stdlib/+dotnet/get_owner.m @@ -1,7 +1,6 @@ -%% DOTNET.GET_OWNER get the owner of a filepath - function o = get_owner(file) - +% DOTNET.GET_OWNER get the owner of a filepath +% % This is not yet possible with .NET on Unix, even with .NET 10. % It would require Pinvoke or external Mono.Unix diff --git a/+stdlib/+dotnet/get_username.m b/+stdlib/+dotnet/get_username.m index 3e7ca80a..5c8ab38a 100644 --- a/+stdlib/+dotnet/get_username.m +++ b/+stdlib/+dotnet/get_username.m @@ -1,7 +1,7 @@ -%% DOTNET.GET_USERNAME get the login name - function n = get_username() -% https://learn.microsoft.com/en-us/dotnet/api/system.environment.username +% DOTNET.GET_USERNAME get the login name +% +% Ref: https://learn.microsoft.com/en-us/dotnet/api/system.environment.username try n = char(System.Environment.UserName); diff --git a/+stdlib/+dotnet/hostname.m b/+stdlib/+dotnet/hostname.m index a3e54976..68fed1f3 100644 --- a/+stdlib/+dotnet/hostname.m +++ b/+stdlib/+dotnet/hostname.m @@ -1,8 +1,8 @@ -%% DOTNET.HOSTNAME get the computer network hostname - function n = hostname() - -%n = char(System.Environment.MachineName); +% DOTNET.HOSTNAME get the computer network hostname +% +% alternative for machine name: +% n = char(System.Environment.MachineName); % https://learn.microsoft.com/en-us/dotnet/api/system.environment.machinename try diff --git a/+stdlib/+dotnet/is_admin.m b/+stdlib/+dotnet/is_admin.m index 2e2919d6..5b4d147e 100644 --- a/+stdlib/+dotnet/is_admin.m +++ b/+stdlib/+dotnet/is_admin.m @@ -1,6 +1,5 @@ -%% DOTNET.IS_ADMIN is the user running as root? - function y = is_admin() +% DOTNET.IS_ADMIN is the user running as root? y = logical([]); diff --git a/+stdlib/+dotnet/is_symlink.m b/+stdlib/+dotnet/is_symlink.m index c481cb12..66b1083b 100644 --- a/+stdlib/+dotnet/is_symlink.m +++ b/+stdlib/+dotnet/is_symlink.m @@ -1,6 +1,5 @@ -%% DOTNET.IS_SYMLINK check if a file is a symbolic link - function y = is_symlink(file) +% DOTNET.IS_SYMLINK check if a file is a symbolic link if ~stdlib.exists(file) % necessary to avoid having to catch 'MATLAB:NET:CLRException:MethodInvoke' on Windows diff --git a/+stdlib/+dotnet/ram_total.m b/+stdlib/+dotnet/ram_total.m index 8e92d68d..d85baac9 100644 --- a/+stdlib/+dotnet/ram_total.m +++ b/+stdlib/+dotnet/ram_total.m @@ -1,8 +1,9 @@ -%% DOTNET.RAM_TOTAL get total physical RAM - function bytes = ram_total() - % .NET is 2-3x faster than Java for this - % https://learn.microsoft.com/en-us/dotnet/api/system.gcmemoryinfo.totalavailablememorybytes +% DOTNET.RAM_TOTAL get total physical RAM +% +% .NET is 2-3x faster than Java for this +% Ref: https://learn.microsoft.com/en-us/dotnet/api/system.gcmemoryinfo.totalavailablememorybytes + try bytes = System.GC.GetGCMemoryInfo().TotalAvailableMemoryBytes; catch diff --git a/+stdlib/+dotnet/read_symlink.m b/+stdlib/+dotnet/read_symlink.m index e4180150..c9ff95c3 100644 --- a/+stdlib/+dotnet/read_symlink.m +++ b/+stdlib/+dotnet/read_symlink.m @@ -1,7 +1,6 @@ -%% DOTNET.READ_SYMLINK resolve the symbolic links of a filepath -% .NET >= 6 required - function r = read_symlink(file) +% DOTNET.READ_SYMLINK resolve the symbolic links of a filepath +% .NET >= 6 required try h = System.IO.FileInfo(file); diff --git a/+stdlib/+dotnet/uptime.m b/+stdlib/+dotnet/uptime.m index 0dbabc89..71199af8 100644 --- a/+stdlib/+dotnet/uptime.m +++ b/+stdlib/+dotnet/uptime.m @@ -1,6 +1,5 @@ -%% DOTNET.UPTIME get system uptime - function t = uptime() +% DOTNET.UPTIME get system uptime try tms = System.Environment.TickCount64; @@ -11,4 +10,4 @@ t = []; end -end \ No newline at end of file +end diff --git a/+stdlib/+java/file_checksum.m b/+stdlib/+java/file_checksum.m index ec83d862..43f29424 100644 --- a/+stdlib/+java/file_checksum.m +++ b/+stdlib/+java/file_checksum.m @@ -1,7 +1,7 @@ -%% JAVA.FILE_CHECKSUM compute checksum hash of file -% Ref: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/MessageDigest.html#getInstance(java.lang.String) - function hash = file_checksum(file, hash_method) +% JAVA.FILE_CHECKSUM compute checksum hash of file +% +% Ref: https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/security/MessageDigest.html#getInstance(java.lang.String) if strcmpi(hash_method, 'sha256') hash_method = "SHA-256"; diff --git a/+stdlib/+java/filesystem_type.m b/+stdlib/+java/filesystem_type.m index c08839d7..bf75f4ad 100644 --- a/+stdlib/+java/filesystem_type.m +++ b/+stdlib/+java/filesystem_type.m @@ -1,10 +1,8 @@ -%% JAVA.FILESYSTEM_TYPE - - -function t = filesystem_type(file) +function t = filesystem_type(p) +% JAVA.FILESYSTEM_TYPE get filesystem type holding a given path t = ''; -if stdlib.strempty(file) +if stdlib.strempty(p) return end @@ -15,7 +13,7 @@ % stdlib.exists() was true, the Java function threw java.nio.file.NoSuchFileException. % % this try-catch is faster and more robust - p = javaAbsolutePath(file); + p = javaAbsolutePath(p); s = javaMethod('getFileStore', 'java.nio.file.Files', p); t = char(s.type); catch e diff --git a/+stdlib/+java/get_owner.m b/+stdlib/+java/get_owner.m index d7193d70..963e9ff7 100644 --- a/+stdlib/+java/get_owner.m +++ b/+stdlib/+java/get_owner.m @@ -1,8 +1,6 @@ -%% JAVA.GET_OWNER get owner of file - - function n = get_owner(file) - +% JAVA.GET_OWNER get owner of file +% % https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/Files.html#getOwner(java.nio.file.Path,java.nio.file.LinkOption...) % https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/nio/file/LinkOption.html diff --git a/+stdlib/+java/hard_link_count.m b/+stdlib/+java/hard_link_count.m index 1731d346..ec7fd101 100644 --- a/+stdlib/+java/hard_link_count.m +++ b/+stdlib/+java/hard_link_count.m @@ -1,6 +1,5 @@ function i = hard_link_count(file) - i = []; if stdlib.strempty(file) return diff --git a/+stdlib/+java/private/javaPathObject.m b/+stdlib/+java/private/javaPathObject.m index 19b6409f..915c1013 100644 --- a/+stdlib/+java/private/javaPathObject.m +++ b/+stdlib/+java/private/javaPathObject.m @@ -1,5 +1,5 @@ -%% JAVAPATHOBJECT Return a Java nio.file.Path object for a given file path. function o = javaPathObject(p) +% JAVAPATHOBJECT return a Java nio.file.Path object for a given file path. ja = javaArray('java.lang.String', 0); o = javaMethod('get', 'java.nio.file.Paths', p, ja); diff --git a/+stdlib/+java/ram_total.m b/+stdlib/+java/ram_total.m index d1f039ce..337d3d86 100644 --- a/+stdlib/+java/ram_total.m +++ b/+stdlib/+java/ram_total.m @@ -1,7 +1,6 @@ -%% JAVA.RAM_TOTAL get the total physical RAM - function bytes = ram_total() - +% JAVA.RAM_TOTAL get the total physical RAM +% % https://docs.oracle.com/en/java/javase/21/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getTotalMemorySize() try diff --git a/+stdlib/+java/read_symlink.m b/+stdlib/+java/read_symlink.m index 4823d644..e3d27bb1 100644 --- a/+stdlib/+java/read_symlink.m +++ b/+stdlib/+java/read_symlink.m @@ -1,8 +1,7 @@ -%% JAVA.READ_SYMLINK resolve the symbolic links of a filepath -% empty if no symlinks - function r = read_symlink(file) - +% JAVA.READ_SYMLINK resolve the symbolic links of a filepath +% empty if no symlinks +% % must be absolute path % must not be .canonical or symlink is gobbled! % https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/nio/file/Files.html#readSymbolicLink(java.nio.file.Path) diff --git a/+stdlib/+java/samepath.m b/+stdlib/+java/samepath.m index 522871cc..728d252d 100644 --- a/+stdlib/+java/samepath.m +++ b/+stdlib/+java/samepath.m @@ -1,6 +1,5 @@ -%% JAVA.SAMEPATH are inputs the same path - function y = samepath(path1, path2) +% JAVA.SAMEPATH are inputs the same path try f1 = javaObject('java.io.File', path1); diff --git a/+stdlib/+java/set_modtime.m b/+stdlib/+java/set_modtime.m index 3f502ddb..cc87abba 100644 --- a/+stdlib/+java/set_modtime.m +++ b/+stdlib/+java/set_modtime.m @@ -1,6 +1,5 @@ -%% JAVA.SET_MODTIME set the modification time of a filepath - function ok = set_modtime(file, time) +% JAVA.SET_MODTIME set the modification time of a filepath try utc = posixtime(datetime(time, 'TimeZone', 'UTC')); diff --git a/+stdlib/+native/samepath.m b/+stdlib/+native/samepath.m index 24719139..585bbb84 100644 --- a/+stdlib/+native/samepath.m +++ b/+stdlib/+native/samepath.m @@ -1,9 +1,8 @@ -%% NATIVE.SAMEPATH are two paths equivalent +function y = samepath(path1, path2) +% NATIVE.SAMEPATH are two paths equivalent % % this canonical string method is less preferred to using device + inode. -function y = samepath(path1, path2) - c1 = stdlib.canonical(path1, true); c2 = stdlib.canonical(path2, true); diff --git a/+stdlib/+perl/get_uid.m b/+stdlib/+perl/get_uid.m index b987ac86..972249f8 100644 --- a/+stdlib/+perl/get_uid.m +++ b/+stdlib/+perl/get_uid.m @@ -1,6 +1,5 @@ -%% PERL.GET_UID tell UID (numeric) of current user - function u = get_uid() +% PERL.GET_UID tell UID (numeric) of current user u = []; if ispc() diff --git a/+stdlib/+perl/perl2cmd.m b/+stdlib/+perl/perl2cmd.m index a24fe38c..9ca31958 100644 --- a/+stdlib/+perl/perl2cmd.m +++ b/+stdlib/+perl/perl2cmd.m @@ -1,13 +1,12 @@ -%% PERL2CMD prepare Perl cmd for Matlab sprintf +function c = perl2cmd(p) +% PERL2CMD prepare Perl cmd for Matlab sprintf % % Windows wants double quotes, Unix wants single quotes -function c = perl2cmd(p) - if ispc() c = sprintf('"%s"', p); else c = sprintf('''%s''', p); end -end \ No newline at end of file +end diff --git a/+stdlib/+python/has_psutil.m b/+stdlib/+python/has_psutil.m index bc597e60..ce7b0e5e 100644 --- a/+stdlib/+python/has_psutil.m +++ b/+stdlib/+python/has_psutil.m @@ -1,6 +1,6 @@ -%% PYTHON.HAS_PSUTIL is Python psutil module availble - function y = has_psutil(force_old) +% PYTHON.HAS_PSUTIL is Python psutil module availble + if nargin < 1 force_old = false; end diff --git a/+stdlib/+python/is_admin.m b/+stdlib/+python/is_admin.m index aec773f5..9f4ac283 100644 --- a/+stdlib/+python/is_admin.m +++ b/+stdlib/+python/is_admin.m @@ -1,6 +1,5 @@ function y = is_admin() - y = logical([]); try diff --git a/+stdlib/+python/is_mount.m b/+stdlib/+python/is_mount.m index 4a2a5f69..e077f188 100644 --- a/+stdlib/+python/is_mount.m +++ b/+stdlib/+python/is_mount.m @@ -1,9 +1,7 @@ -%% PYTHON.IS_MOUNT is path a mount point -% -% https://docs.python.org/3/library/os.path.html#os.path.ismount - function y = is_mount(filepath) - +% PYTHON.IS_MOUNT is path a mount point +% +% Ref: https://docs.python.org/3/library/os.path.html#os.path.ismount try y = false; diff --git a/+stdlib/+sys/create_symlink.m b/+stdlib/+sys/create_symlink.m index 78b08d15..5ce90e96 100644 --- a/+stdlib/+sys/create_symlink.m +++ b/+stdlib/+sys/create_symlink.m @@ -1,4 +1,3 @@ - function [ok, cmd, m] = create_symlink(target, link) ok = false; diff --git a/+stdlib/+sys/file_checksum.m b/+stdlib/+sys/file_checksum.m index b71226ec..398946c5 100644 --- a/+stdlib/+sys/file_checksum.m +++ b/+stdlib/+sys/file_checksum.m @@ -1,5 +1,5 @@ -%% SYS.FILE_CHECKSUM compute checksum of file function [hash, cmd] = file_checksum(file, hash_method) +% SYS.FILE_CHECKSUM compute checksum of file switch lower(hash_method) case {"sha-256", "sha256"} diff --git a/+stdlib/+sys/hard_link_count.m b/+stdlib/+sys/hard_link_count.m index 49edf1f5..a2fe6965 100644 --- a/+stdlib/+sys/hard_link_count.m +++ b/+stdlib/+sys/hard_link_count.m @@ -1,9 +1,8 @@ -%% SYS.HARD_LINK_COUNT number of hard links to file +function [n, cmd] = hard_link_count(file) +% SYS.HARD_LINK_COUNT number of hard links to file % % Powershell is 0, 1, or 2 -function [n, cmd] = hard_link_count(file) - n = []; if ispc() diff --git a/+stdlib/+sys/inode.m b/+stdlib/+sys/inode.m index b23177dc..691224f3 100644 --- a/+stdlib/+sys/inode.m +++ b/+stdlib/+sys/inode.m @@ -1,6 +1,5 @@ -%% SYS.INODE get file inode - function [i, cmd] = inode(file) +% SYS.INODE get file inode i = []; diff --git a/+stdlib/+sys/is_removable.m b/+stdlib/+sys/is_removable.m index 51f052a1..b8e09899 100644 --- a/+stdlib/+sys/is_removable.m +++ b/+stdlib/+sys/is_removable.m @@ -1,6 +1,5 @@ -%% SYS.IS_REMOVABLE - function y = is_removable(filepath) +% SYS.IS_REMOVABLE check if path is on removable drive y = false; diff --git a/+stdlib/+sys/uptime.m b/+stdlib/+sys/uptime.m index 5594fd03..df2cf0ac 100644 --- a/+stdlib/+sys/uptime.m +++ b/+stdlib/+sys/uptime.m @@ -1,6 +1,5 @@ -%% SYS.UPTIME - function t = uptime() +% SYS.UPTIME Get system uptime in seconds. t = []; diff --git a/+stdlib/Backend.m b/+stdlib/Backend.m index a0d8085d..dc6e439e 100644 --- a/+stdlib/Backend.m +++ b/+stdlib/Backend.m @@ -1,4 +1,5 @@ -%% BACKEND auto-selection of function backend per-function +classdef Backend < matlab.mixin.SetGet +% BACKEND auto-selection of function backend per-function % the user can specify a backend, or else this class automatically % determines suitable backends for the system. % @@ -8,8 +9,6 @@ % * 'native' uses the latest Matlab syntax available % * 'legacy' is Matlab syntax for older Matlab versions. Sometimes legacy is faster than native, but native is more robust/general. -classdef Backend < matlab.mixin.SetGet - properties (Constant) optionalBackends = ["java", "perl", "python", "dotnet"] namespace = "stdlib" diff --git a/+stdlib/absolute.m b/+stdlib/absolute.m index 43ab06d2..e58148b2 100644 --- a/+stdlib/absolute.m +++ b/+stdlib/absolute.m @@ -1,21 +1,31 @@ +function c = absolute(p, base) %% ABSOLUTE Determine absolute path -% c = absolute(p); +% +% Does not normalize path. +% Non-existent path is made absolute relative to pwd +% +%% +% +% c = absolute(p); +% % Path "p" need not exist. % Absolute path will be relative to pwd if path does not exist. % -% c = absolute(p, base); +%%% +% +% c = absolute(p, base); +% % the "base" path is used instead of pwd. % -%%% Inputs +%% Inputs +% % * p: path to make absolute % * base: if present, base on this instead of cwd -%%% Outputs -% * c: absolute path % -% does not normalize path -% non-existant path is made absolute relative to pwd +%% Outputs +% +% * c: absolute path -function c = absolute(p, base) if nargin < 2 base = pwd(); end diff --git a/+stdlib/allToolboxes.m b/+stdlib/allToolboxes.m index 1306d2a7..43b41c52 100644 --- a/+stdlib/allToolboxes.m +++ b/+stdlib/allToolboxes.m @@ -1,7 +1,6 @@ -%% ALLTOOLBOXES tell all the Matlab toolboxes known for this Matlab release -% requires: java, Matlab >= R2018a - function names = allToolboxes() +% ALLTOOLBOXES tell all the Matlab toolboxes known for this Matlab release +% requires: java, Matlab >= R2018a tbx = com.mathworks.product.util.ProductIdentifier.values; %#ok diff --git a/+stdlib/append.m b/+stdlib/append.m index ee51fbf2..e7bfe62e 100644 --- a/+stdlib/append.m +++ b/+stdlib/append.m @@ -1,3 +1,4 @@ +function s = append(txt, varargin) %% APPEND Concatenate strings or character arrays without removing trailing whitespace % APPEND(S1, S2, ...) appends strings or character vectors S1, S2, ... together. % the output is a scalar string or character vector @@ -6,8 +7,6 @@ % strcat() has the side effect of trimming whitespace, so we prefer % stdlib.append() for string concatenation in case a user path has trailing whitespace. -function s = append(txt, varargin) - s = string(txt); if stdlib.matlabOlderThan('R2019a') @@ -25,4 +24,4 @@ end -%!assert(stdlib.append('a','b'), 'ab') \ No newline at end of file +%!assert(stdlib.append('a','b'), 'ab') diff --git a/+stdlib/auto_chunk_size.m b/+stdlib/auto_chunk_size.m index 3d168b44..8edd73f3 100644 --- a/+stdlib/auto_chunk_size.m +++ b/+stdlib/auto_chunk_size.m @@ -1,4 +1,5 @@ -%% AUTO_CHUNK_SIZE determine HDF5 / NetCDF4 chunk size +function csize = auto_chunk_size(dims) +% AUTO_CHUNK_SIZE determine HDF5 / NetCDF4 chunk size % % based on https://github.com/h5py/h5py/blob/master/h5py/_hl/filters.py % refer to https://support.hdfgroup.org/HDF5/Tutor/layout.html @@ -6,7 +7,7 @@ %%% Inputs % * dims: proposed dataset dimensions (like size()) -function csize = auto_chunk_size(dims) + % arguments % dims (1,:) {mustBeInteger,mustBePositive} % end diff --git a/+stdlib/canonical.m b/+stdlib/canonical.m index 42ce0c32..2bd60dbd 100644 --- a/+stdlib/canonical.m +++ b/+stdlib/canonical.m @@ -1,4 +1,5 @@ -%% CANONICAL Canonicalize path +function c = canonical(file, strict) +% CANONICAL Canonicalize path % c = canonical(p); % If exists, canonical absolute path is returned. % if any component of path does not exist, normalized relative path is returned. @@ -12,7 +13,6 @@ %%% Outputs % * c: canonical path, if determined -function c = canonical(file, strict) if nargin < 2 strict = false; end diff --git a/+stdlib/checkRAM.m b/+stdlib/checkRAM.m index 58a03bd6..80e1cb11 100644 --- a/+stdlib/checkRAM.m +++ b/+stdlib/checkRAM.m @@ -1,4 +1,5 @@ -%% CHECKRAM estimate if RAM will fit a new array +function [OK,newSizeBytes,freebytes] = checkRAM(newSize, myclass) +% CHECKRAM estimate if RAM will fit a new array % checks that requested memory for the new array won't exceed AVAILABLE RAM with Matlab % %%% Inputs @@ -13,9 +14,6 @@ % create an array using ALL available RAM, but at least you know when you % certainly CAN'T create an array without digging deep into swap or worse. - -function [OK,newSizeBytes,freebytes] = checkRAM(newSize, myclass) - % get available RAM freebytes = stdlib.ram_free(); diff --git a/+stdlib/checkout_license.m b/+stdlib/checkout_license.m index 54941978..090dc52b 100644 --- a/+stdlib/checkout_license.m +++ b/+stdlib/checkout_license.m @@ -1,4 +1,5 @@ -%% CHECKOUT_LICENSE checkout Matlab license +function [ok, featureName] = checkout_license(packageName) +% CHECKOUT_LICENSE checkout Matlab license % NOTE: checking out a license holds that license as long as Matlab is % running. This could impact other users at an institution with a limited % number of networked licenses. Only use this function at point-of-use, @@ -10,7 +11,6 @@ % This function better tells that a function can % be used rather than just checking if the relevant toolbox is installed. -function [ok, featureName] = checkout_license(packageName) arguments packageName (1,1) string end diff --git a/+stdlib/cpu_arch.m b/+stdlib/cpu_arch.m index a770a02b..9ef7a409 100644 --- a/+stdlib/cpu_arch.m +++ b/+stdlib/cpu_arch.m @@ -1,4 +1,5 @@ -%% CPU_ARCH get the Operating System CPU architecture +function a = cpu_arch() +% CPU_ARCH get the Operating System CPU architecture % % This function retrieves the CPU architecture of the current operating system. % The physical CPU architecture can be obscured and even determining it in high-level @@ -9,8 +10,6 @@ %%% Outputs % * a: the CPU architecture as a character vector: -function a = cpu_arch() - if ispc() a = getenv('PROCESSOR_ARCHITECTURE'); else diff --git a/+stdlib/cpu_count.m b/+stdlib/cpu_count.m index 637571f6..1005a73b 100644 --- a/+stdlib/cpu_count.m +++ b/+stdlib/cpu_count.m @@ -1,5 +1,5 @@ -%% CPU_COUNT how many CPUs are available function N = cpu_count() +% CPU_COUNT how many CPUs are available N = maxNumCompThreads; @@ -15,4 +15,4 @@ %!assert (stdlib.cpu_count() >= 0) %!test -%! mustBeInteger(stdlib.cpu_count()) \ No newline at end of file +%! mustBeInteger(stdlib.cpu_count()) diff --git a/+stdlib/dotnet_api.m b/+stdlib/dotnet_api.m index d2867744..5718828e 100644 --- a/+stdlib/dotnet_api.m +++ b/+stdlib/dotnet_api.m @@ -1,6 +1,5 @@ -%% DOTNET_API major version integer .NET - function v = dotnet_api() +% DOTNET_API major version integer .NET try v = System.Environment.Version.Major; diff --git a/+stdlib/dotnet_home.m b/+stdlib/dotnet_home.m index 1dfba474..fc26cc33 100644 --- a/+stdlib/dotnet_home.m +++ b/+stdlib/dotnet_home.m @@ -1,6 +1,5 @@ -%% DOTNET_HOME give .NET RuntimeLocation - function h = dotnet_home() +% DOTNET_HOME give .NET RuntimeLocation h = string.empty; diff --git a/+stdlib/dotnet_version.m b/+stdlib/dotnet_version.m index 8e0c021a..393082c1 100644 --- a/+stdlib/dotnet_version.m +++ b/+stdlib/dotnet_version.m @@ -1,6 +1,5 @@ -%% DOTNET_VERSION version string - function v = dotnet_version() +% DOTNET_VERSION version string try vs = System.Environment.Version; diff --git a/+stdlib/get_pid.m b/+stdlib/get_pid.m index 44e3fdc2..c4929a97 100644 --- a/+stdlib/get_pid.m +++ b/+stdlib/get_pid.m @@ -1,9 +1,8 @@ -%% GET_PID process ID of Matlab session - function pid = get_pid() +% GET_PID process ID of Matlab session if stdlib.matlabOlderThan('R2025a') - pid = feature('getpid'); + pid = feature('getpid'); %#ok else pid = matlabProcessID; end diff --git a/+stdlib/private/fileAttribCompatible.m b/+stdlib/private/fileAttribCompatible.m index 9d611511..4631c93c 100644 --- a/+stdlib/private/fileAttribCompatible.m +++ b/+stdlib/private/fileAttribCompatible.m @@ -1,6 +1,5 @@ -%% FILEATTRIBCOMPATIBLE fileattrib required char until R2018a; this provides a seamless fallback - function [s, r, id] = fileAttribCompatible(file) +% FILEATTRIBCOMPATIBLE fileattrib required char until R2018a; this provides a seamless fallback % need stdlib.strempty for Matlab < R2020b if stdlib.strempty(file) diff --git a/+stdlib/private/h5save_exist.m b/+stdlib/private/h5save_exist.m index a577e7b6..819c9708 100644 --- a/+stdlib/private/h5save_exist.m +++ b/+stdlib/private/h5save_exist.m @@ -1,7 +1,7 @@ -%% H5SAVE_EXIST write data to existing HDF5 dataset +function h5save_exist(filename, varname, A, sizeA) +% H5SAVE_EXIST write data to existing HDF5 dataset % normally users use h5save() instead of this function -function h5save_exist(filename, varname, A, sizeA) % arguments % filename % varname diff --git a/+stdlib/private/h5save_new.m b/+stdlib/private/h5save_new.m index 2605d109..b6664136 100644 --- a/+stdlib/private/h5save_new.m +++ b/+stdlib/private/h5save_new.m @@ -1,7 +1,7 @@ -%% H5SAVE_NEW Save a variable to an new HDF5 dataset +function h5save_new(filename, varname, A, sizeA, compressLevel) +% H5SAVE_NEW Save a variable to an new HDF5 dataset % normally users will use h5save() instead of this function -function h5save_new(filename, varname, A, sizeA, compressLevel) % arguments % filename % varname diff --git a/+stdlib/private/h5save_scalar.m b/+stdlib/private/h5save_scalar.m index 5eb8a892..8768c426 100644 --- a/+stdlib/private/h5save_scalar.m +++ b/+stdlib/private/h5save_scalar.m @@ -1,6 +1,7 @@ function h5save_scalar(filename, hpath, A) -%% write HDF5 scalar as a scalar +% H5SAVE_SCALAR write HDF5 scalar as a scalar % h5create doesn't support scalars + % arguments % filename (1,1) string % hpath (1,1) string diff --git a/+stdlib/private/javaPathObject.m b/+stdlib/private/javaPathObject.m index 1868c534..438c5785 100644 --- a/+stdlib/private/javaPathObject.m +++ b/+stdlib/private/javaPathObject.m @@ -1,5 +1,5 @@ -%% JAVAPATHOBJECT Return a Java nio.file.Path object for a given file path. function o = javaPathObject(p) +% JAVAPATHOBJECT Return a Java nio.file.Path object for a given file path. o = java.nio.file.Paths.get(p, javaArray('java.lang.String', 0)); diff --git a/+stdlib/private/ncsave_exist.m b/+stdlib/private/ncsave_exist.m index 7ba7b53d..486fb4b5 100644 --- a/+stdlib/private/ncsave_exist.m +++ b/+stdlib/private/ncsave_exist.m @@ -1,7 +1,7 @@ -%% NCSAVE_EXIST save a variable to a NetCDF4 existing dataset +function ncsave_exist(filename, varname, A, sizeA) +% NCSAVE_EXIST save a variable to a NetCDF4 existing dataset % normally users will use ncsave() instead of this function -function ncsave_exist(filename, varname, A, sizeA) % arguments % filename % varname diff --git a/+stdlib/private/ncsave_new.m b/+stdlib/private/ncsave_new.m index f362e82e..7c95353b 100644 --- a/+stdlib/private/ncsave_new.m +++ b/+stdlib/private/ncsave_new.m @@ -1,7 +1,7 @@ -%% NCSAVE_NEW Save a variable to an new NetCDF4 dataset +function ncsave_new(file, varname, A, sizeA, ncdims, compressLevel) +% NCSAVE_NEW Save a variable to an new NetCDF4 dataset % normally users will use ncsave() instead of this function -function ncsave_new(file, varname, A, sizeA, ncdims, compressLevel) % arguments % file % varname diff --git a/+stdlib/private/perm2char.m b/+stdlib/private/perm2char.m index 647ccd7f..495c6f48 100644 --- a/+stdlib/private/perm2char.m +++ b/+stdlib/private/perm2char.m @@ -1,6 +1,5 @@ -%% NATIVE.PERM2CHAR convert file permissions to permission string - function p = perm2char(v) +% NATIVE.PERM2CHAR convert file permissions to permission string if isempty(v) p = ''; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 35197f95..97c75dd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,6 @@ on: - "**.cpp" - ".github/workflows/ci.yml" - ".github/workflows/*/action.yml" - - "!private/publish_gen_index_html.m" - "!scripts/**" - "!example/**" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8d00eb99..50ee6cea 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -51,7 +51,7 @@ jobs: uses: matlab-actions/setup-matlab@v2 with: release: ${{ matrix.release }} - cache: false + cache: true - name: Run Matlab buildtool uses: matlab-actions/run-build@v2 diff --git a/example/+dotnet/is_removable.m b/example/+dotnet/is_removable.m index d75033a7..82230433 100644 --- a/example/+dotnet/is_removable.m +++ b/example/+dotnet/is_removable.m @@ -1,11 +1,10 @@ -%% DOTNET.IS_REMOVABLE detect removable drive +function y = is_removable(filepath) +% DOTNET.IS_REMOVABLE detect removable drive % % This does NOT detect USB flash drives, so we DON'T automatically use it. % % Ref: https://learn.microsoft.com/en-us/dotnet/api/system.io.drivetype -function y = is_removable(filepath) - try fmt = System.IO.DriveInfo(filepath).DriveType; y = any(isequal(fmt, {System.IO.DriveType.Removable, ... diff --git a/example/dotnet/cpu_arch.m b/example/dotnet/cpu_arch.m index 0d64b3ee..a9b2def3 100644 --- a/example/dotnet/cpu_arch.m +++ b/example/dotnet/cpu_arch.m @@ -1,6 +1,6 @@ -%% DOTNET.CPU_ARCH get the Operating System architecture - function a = cpu_arch() +% DOTNET.CPU_ARCH get the Operating System architecture + a = char(System.Runtime.InteropServices.RuntimeInformation.OSArchitecture); % https://learn.microsoft.com/en-us/dotnet/core/compatibility/interop/7.0/osarchitecture-emulation end diff --git a/example/dotnet/device.m b/example/dotnet/device.m index 17491b60..851ba8ae 100644 --- a/example/dotnet/device.m +++ b/example/dotnet/device.m @@ -1,7 +1,6 @@ -%% DOTNET.DEVICE find the drive device ID - function i = device(path) - +% DOTNET.DEVICE find the drive device ID +% % this has been not so stable, so we disabled it and leave it here for reference. i = 0; diff --git a/example/dotnet/relative_to.m b/example/dotnet/relative_to.m index 4e7a03c8..ad62a9f4 100644 --- a/example/dotnet/relative_to.m +++ b/example/dotnet/relative_to.m @@ -1,9 +1,8 @@ -%% DOTNET.RELATIVE_TO find the relative path to other from base +function rel = relative_to(base, other) +% DOTNET.RELATIVE_TO find the relative path to other from base % % not normally used because it's overly complex -function rel = relative_to(base, other) - assert(stdlib.dotnet_api() >= 5) if stdlib.strempty(other) diff --git a/scripts/installMatlabPackageManager.m b/scripts/installMatlabPackageManager.m index 0b86cc64..bb99a8f5 100644 --- a/scripts/installMatlabPackageManager.m +++ b/scripts/installMatlabPackageManager.m @@ -1,7 +1,7 @@ -%% Download and install official Matlab Package Manger (mpm) -% https://www.mathworks.com/help/install/ug/get-mpm-os-command-line.html - function pexe = installMatlabPackageManager(installDir) +% installMatlabPackageManager Download and install official Matlab Package Manger (mpm) +% +% Ref: https://www.mathworks.com/help/install/ug/get-mpm-os-command-line.html arguments installDir (1,1) string = fileparts(mfilename('fullpath')) end