blink1073 / oct2py
Showing 1 of 4 files from the diff.
Other files ignored by Codecov

@@ -275,8 +275,9 @@
Loading
275 275
            Name of function to run or a path to an m-file.
276 276
        func_args: object, optional
277 277
            Args to send to the function.
278 -
        nout: int, optional
279 -
            Desired number of return arguments, defaults to 1.
278 +
        nout: int or str, optional. 
279 +
            Desired number of return arguments, defaults to 1. If nout 
280 +
            value is 'max_nout', get_max_nout() will be used.
280 281
        store_as: str, optional
281 282
            If given, saves the result to the given Octave variable name
282 283
            instead of returning it.
@@ -342,6 +343,8 @@
Loading
342 343
        nout = kwargs.get('nout', None)
343 344
        if nout is None:
344 345
            nout = 1
346 +
        elif nout == 'max_nout':
347 +
            nout = self._get_max_nout(func_path)
345 348
346 349
        plot_dir = kwargs.get('plot_dir')
347 350
@@ -743,3 +746,31 @@
Loading
743 746
        setattr(self, attr, obj)
744 747
745 748
        return obj
749 +
750 +
    def _get_max_nout(self, func_path):
751 +
        """Get or count maximum nout of .m function."""
752 +
        
753 +
        if not osp.isabs(func_path):
754 +
            func_path = self.which(func_path)
755 +
756 +
        nout = 0
757 +
        status = 'NOT FUNCTION'
758 +
        with open(func_path, encoding='utf8') as f:
759 +
            for l in f: 
760 +
                if l[0] != 'f': #not function
761 +
                    if status == 'NOT FUNCTION':
762 +
                        continue
763 +
                l = l.translate(str.maketrans('', '', '[]()')).split()
764 +
                try:
765 +
                    l.remove('function')
766 +
                except:
767 +
                    pass
768 +
                for s in l:
769 +
                    if s == '...':
770 +
                        status = 'FUNCTION'
771 +
                        continue
772 +
                    if s != '=':
773 +
                        nout += 1
774 +
                    else:
775 +
                        return nout
776 +
        return nout
Files Coverage
oct2py 90.45%
Project Totals (10 files) 90.45%
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
codecov-umbrella
Build #195506738 -
unittests
1
comment: off
2
# show coverage in CI status, but never consider it a failure
3
coverage:
4
  status:
5
    project:
6
      default:
7
        target: 0%
8
    patch:
9
      default:
10
        target: 0%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading