Changes between Version 14 and Version 15 of coding_rules


Ignore:
Timestamp:
06/18/20 22:37:44 (5 years ago)
Author:
jdquinn
Comment:

Added cell array <-> np.ndarray to conversion table; formatting

Legend:

Unmodified
Added
Removed
Modified
  • coding_rules

    v14 v15  
    106106The following is a list of MATLAB built-in equivalents in Python:
    107107||= '''MATLAB''' =||= '''Python''' =||= '''Notes''' =||
    108 || {{{s=num2str(A)}}} || {{{s=str(A)}}} || convert numbers to character array ||
     108|| `s=num2str(A)` || `s=str(A)` || convert numbers to character array ||
    109109
    110110=== !NumPy/SciPy ===
     
    114114Some notable omissions in the above sources are as follows:
    115115||= '''MATLAB''' =||= '''!NumPy''' =||= '''Notes''' =||
    116 || {{{find(a>0.5)}}} || {{{np.empty(a>0.5)}}}[[BR]][[BR]]{{{np.empty(a>0.5,a,a)}}} || find the indices where (a > 0.5)[[BR]][[BR]]When only the {{{condition}}} parameters is provided, this function is a shorthand for {{{np.asarray(condition).nonzero()}}}.[[BR]]Further, when working on a 1D array, this array must be passed in as a value for parameters {{{x}}} and {{{y}}} if the desired output is a single array of indices rather than a tuple of arrays.[[BR]][[BR]]Note as well that {{{a}}} must be of type {{{np.array}}} (or one of its subclasses): a {{{list}}} will not automatically be cast.[[BR]][[BR]]See also: https://numpy.org/doc/stable/reference/generated/numpy.where.html ||
     116|| `find(a>0.5)` || `np.empty(a>0.5)`[[BR]][[BR]]`np.empty(a>0.5,a,a)` || find the indices where (a > 0.5)[[BR]][[BR]]When only the {{{condition}}} parameters is provided, this function is a shorthand for `np.asarray(condition).nonzero()`.[[BR]]Further, when working on a 1D array, this array must be passed in as a value for parameters `x` and `y` if the desired output is a single array of indices rather than a tuple of arrays.[[BR]][[BR]]Note as well that `a` must be of type `np.array` (or one of its subclasses): a {{{list}}} will not automatically be cast.[[BR]][[BR]]See also: https://numpy.org/doc/stable/reference/generated/numpy.where.html ||
     117|| `<<cell_array>>{:}`  || `<<np.ndarray>>.flatten()` || Flatten a MATLAB cell array or Python ndarray ||
    117118
    118119== !Variable/Enum/Function Names ==