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

Review Algorithm Property Defaults #9996

Closed
PeterParker opened this issue Mar 10, 2014 · 1 comment
Closed

Review Algorithm Property Defaults #9996

PeterParker opened this issue Mar 10, 2014 · 1 comment
Assignees
Labels
Framework Issues and pull requests related to components in the Framework Low Priority Things that you don't ever want to be done.
Milestone

Comments

@PeterParker
Copy link
Contributor

This issue was originally TRAC 9153

The "Properties" tables generated by WikiMaker expose the fact that for some algorithms we are using rather user-unfriendly conventions to denote various default values.

Examples:

  • There are 78 algorithms that use -1. Presumably, there will be some fraction of these where -1 is an acceptable value that can be used by the algorithm, but in most cases they are associated with a "must-be-positive" validator. Andrei has suggested that using -DBL_MAX in such cases might be a viable alternative.
  • -1.0 is used by an algorithm to denote an unspecified, default stop time.
  • There are 5 algorithms that use -0 as a default.

This problem has become more visible since http://trac.mantidproject.org/mantid/ticket/2480, which populates algorithm dialogs with default values.

A solution to this problem would make documentation a lot clearer, and would hopefully make algorithms easier to understand and use.

@PeterParker
Copy link
Contributor Author

@PeterParker (2014-03-10T12:14:17):
I offer up the following script to the eventual owner of this ticket, as a quick way to see which algorithms use which default values:

def get_all_prop_defaults():
    """Get prop default information in a form we can use."""
    prop_defaults = {}
    for alg_name in AlgorithmFactory.getRegisteredAlgorithms(True).keys():
        alg = AlgorithmManager.create(alg_name)
        for prop_name in alg.orderedProperties():
            prop = alg.getProperty(prop_name)
            if prop.getDefault in prop_defaults:
                prop_defaults[prop.getDefault][0] += 1
                prop_defaults[prop.getDefault][1].append(str(alg))
            else:
                prop_defaults[prop.getDefault] = [1, [str(alg)], prop_name]
    return prop_defaults

def print_default_usage_table():
    """Prints a table of all default values, how many times they are used, and an example algorithm
    that uses it."""
    table = [["#", "Default", "Example Algorithm"]]

    prop_defaults = get_all_prop_defaults()
    for prop_default in sorted(prop_defaults.keys()):
        table.append([
            prop_defaults[prop_default][0],
            prop_default,
            prop_defaults[prop_default][1]])

    row_format ="{:>5} | {:<35} | {:<50}"
    for row in table:
        print row_format.format(*row)

def print_all_algs_that_use_default_value(default_str):
    """For a given default value, print the names of all the algorithms that have
    properties that use it."""
    prop_defaults = get_all_prop_defaults()

    try:
        algs = prop_defaults[default_str][1]
    except:
        print "No properties exist with a default value of %s." % default_str
    else:
        print "The following algorithms contain a property with default value of %s:" % default_str
        for alg in algs:
            print alg
        print

# Uncomment to use:
# print_all_algs_that_use_default_value("#")
# print_default_usage_table()

@NickDraper (2015-04-27T08:10:35):
Moved to R3.5 at the R3.4 code freeze

@PeterParker PeterParker added Low Priority Things that you don't ever want to be done. Framework Issues and pull requests related to components in the Framework labels Jun 3, 2015
@PeterParker PeterParker added this to the Release 3.5 milestone Jun 3, 2015
@NickDraper NickDraper modified the milestones: Release 3.5, Release 3.6 Sep 14, 2015
@NickDraper NickDraper modified the milestones: Release 3.6, Release 3.7 Jan 22, 2016
@NickDraper NickDraper modified the milestones: Release 3.7, Release 3.8 May 13, 2016
@NickDraper NickDraper modified the milestones: Release 3.8, Release 3.9 Oct 3, 2016
@NickDraper NickDraper modified the milestones: Release 3.9, Temporary Holding Oct 14, 2016
@NickDraper NickDraper modified the milestones: Release 3.9, Release 3.10 Jan 23, 2017
@NickDraper NickDraper removed this from the Release 3.9 milestone Jan 23, 2017
@NickDraper NickDraper modified the milestones: Release 3.10, Release 3.11 May 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues and pull requests related to components in the Framework Low Priority Things that you don't ever want to be done.
Projects
None yet
Development

No branches or pull requests

2 participants