Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/6677_wikima…
Browse files Browse the repository at this point in the history
…ker_win_debug. Refs #6677

Wouldn't usually merge from master but these conflicts were quite involved
to solve.

Conflicts:
	Code/Mantid/Build/wiki_maker.py
	Code/Mantid/Framework/PythonInterface/mantid/simpleapi.py
  • Loading branch information
martyngigg committed Mar 15, 2013
2 parents d53698c + c922f04 commit 9f9c6cf
Show file tree
Hide file tree
Showing 129 changed files with 3,419 additions and 2,080 deletions.
9 changes: 7 additions & 2 deletions Code/Mantid/Build/CMake/CPackLinuxSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if ( ${UNIX_DIST} MATCHES "Ubuntu" )
endif ( ${UNIX_DIST} MATCHES "Ubuntu" )

#RedHatEnterpriseClient RedHatEnterpriseWorkstation
if ( ${UNIX_DIST} MATCHES "RedHatEnterprise" OR ${UNIX_DIST} MATCHES "Fedora")
if ( ${UNIX_DIST} MATCHES "RedHatEnterprise" OR ${UNIX_DIST} MATCHES "Fedora" OR ${UNIX_DIST} MATCHES "SUSE LINUX" )
find_program ( RPMBUILD_CMD rpmbuild )
if ( RPMBUILD_CMD )
set ( CPACK_GENERATOR "RPM" )
Expand All @@ -61,6 +61,10 @@ if ( ${UNIX_DIST} MATCHES "RedHatEnterprise" OR ${UNIX_DIST} MATCHES "Fedora")
set ( CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}.fc15" )
elseif ( ${UNIX_CODENAME} MATCHES "Verne" )
set ( CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}.fc16" )
elseif ( ${UNIX_CODENAME} MATCHES "BeefyMiracle" )
set ( CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}.fc17" )
elseif ( ${UNIX_CODENAME} MATCHES "SphericalCow" )
set ( CPACK_RPM_PACKAGE_RELEASE "${CPACK_RPM_PACKAGE_RELEASE}.fc18" )
endif ( ${UNIX_CODENAME} MATCHES "Tikanga" )

# If CPACK_SET_DESTDIR is ON then the Prefix doesn't get put in the spec file
Expand All @@ -73,4 +77,5 @@ if ( ${UNIX_DIST} MATCHES "RedHatEnterprise" OR ${UNIX_DIST} MATCHES "Fedora")
set ( CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}.${CPACK_RPM_PACKAGE_ARCHITECTURE}" )
endif ( RPMBUILD_CMD)
endif ( ${UNIX_DIST} MATCHES "RedHatEnterprise" OR ${UNIX_DIST} MATCHES "Fedora")
endif ( ${UNIX_DIST} MATCHES "RedHatEnterprise" OR ${UNIX_DIST} MATCHES "Fedora" OR ${UNIX_DIST} MATCHES "SUSE LINUX" )

38 changes: 27 additions & 11 deletions Code/Mantid/Build/wiki_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
reporter = WikiReporter()

#======================================================================
def confirm(prompt=None, resp=False):
def confirm(prompt=None, resp=False, continueconfirm=False):
"""prompts for yes or no response from the user. Returns True for yes and
False for no.
'resp' should be set to the default value assumed by the caller when
user simply types ENTER.
if 'continueconfirm', then skip the confirmation, using No (false) as the choice.
>>> confirm(prompt='Create Directory?', resp=True)
Create Directory? [y]|n:
Expand All @@ -35,6 +37,11 @@ def confirm(prompt=None, resp=False):
"""

# Early exit.
if continueconfirm:
print 'Skip confirmation, changes have not been accepted.'
return False

if prompt is None:
prompt = 'Confirm'

Expand Down Expand Up @@ -84,9 +91,13 @@ def last_page_editor(page):
def wiki_maker_page(page):
"""
returns True if the wikimaker was the last editor.
determines if there is a bot comment, which implies that the wikimaker was used to create the page last.
"""
return ("WikiMaker" == last_page_editor(page))

#Get the last editor of the page.
revisions = page.revisions()
for rev in revisions:
return re.search("^Bot", rev['comment'])

#======================================================================
def do_algorithm(args, algo, version):
""" Do the wiki page
Expand Down Expand Up @@ -139,25 +150,27 @@ def do_algorithm(args, algo, version):
print

wiki_maker_edited_last = wiki_maker_page(page)

last_modifier = last_page_editor(page);
if not wiki_maker_edited_last:
print "The last editor was NOT the WIKIMAKER"
last_modifier = last_page_editor(page);
print "The last page editor was ", last_modifier
print "The last edit was manual. Last edit NOT done by WIKIMAKER script."
if not last_modifier == None:
# Report a failure test case
reporter.addFailureTestCase(algo, version, last_modifier, ''.join(diff_list))
else:
print "The last edit was automatic via a script. Last edit was done by WIKIMAKER script."
print "Last change by ", last_modifier

if args.dryrun:
print "Dry run of saving page to http://www.mantidproject.org/%s" % wiki_page_name
elif wiki_maker_edited_last or args.force or confirm("Do you want to replace the website wiki page?", True):
elif wiki_maker_edited_last or args.force or confirm("Do you want to replace the website wiki page?", True, args.continueconfirm):
print "Saving page to http://www.mantidproject.org/%s" % wiki_page_name
page.save(new_contents, summary = 'Bot: replaced contents using the wiki_maker.py script.' )

saved_text = open(wiki_page_name+'.txt', 'w')
saved_text.write(new_contents)
saved_text.close()


#======================================================================
if __name__ == "__main__":

Expand Down Expand Up @@ -195,16 +208,19 @@ def do_algorithm(args, algo, version):
help="Force overwriting the wiki page on the website if different (don't ask the user)")

parser.add_option('--alg-version', dest='algversion', default=noversion,
help='Algorithm version to create the wiki for.')
help='Algorithm version to create the wiki for. Latest version if absent.')

parser.add_option('--report', dest='wikimakerreport', default=False, action='store_const', const=True,
help="Record authors and corresponding algorithm wiki-pages that have not been generated with the wiki-maker")

parser.add_option('--cache-config', dest='cacheconfig', default=False, action='store_const', const=True,
help="If true, the creditials of the executor will be cached for the next run.")
help="If set, the creditials of the executor will be cached for the next run.")

parser.add_option('--dry-run', dest='dryrun', default=False, action='store_const', const=True,
help="If false, then the utility will work exactly the same, but no changes will actually be pushed to the wiki.")
help="If set, then the utility will work exactly the same, but no changes will actually be pushed to the wiki.")

parser.add_option('--continue-confirm', dest='continueconfirm', default=False, action='store_const', const=True,
help="If set, then any user-required confirmation will be skipped, without applying the change.")


(args, algos) = parser.parse_args()
Expand Down
89 changes: 78 additions & 11 deletions Code/Mantid/Build/wiki_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
python_d_exe = None
# no version identier
noversion = -1
# Direction
InputDirection = "Input"
OutputDirection = "Output"
InOutDirection = "InOut"
NoDirection = "None"
direction_string = [InputDirection, OutputDirection, InOutDirection, NoDirection]

# Holds on to location of sources
file_search_done=False
Expand Down Expand Up @@ -106,6 +112,61 @@ def get_wiki_description(algo, version):
print "Getting algorithm description from source."
return desc

#======================================================================
def create_function_signature(alg, algo_name):
"""
create the function signature for the algorithm.
"""
from mantid.simpleapi import _get_function_spec
import mantid.simpleapi
_alg = getattr(mantid.simpleapi, algo_name)
prototype = algo_name + _get_function_spec(_alg)

# Replace every nth column with a newline.
nth = 4
commacount = 0
prototype_reformated = ""
for char in prototype:
if char == ',':
commacount += 1
if (commacount % nth == 0):
prototype_reformated += ",\n "
else:
prototype_reformated += char
else:
prototype_reformated += char

# Strip out the version.
prototype_reformated = prototype_reformated.replace(",[Version]", "")

# Add the output properties
props = alg.getProperties()
allreturns = []
workspacereturn = None
# Loop through all the properties looking for output properties
for prop in props:
if (direction_string[prop.direction] == OutputDirection):
allreturns.append(prop.name)
# Cache the last workspace property seen.
if isinstance(prop, IWorkspaceProperty):
workspacereturn = prop.name

lhs = ""
comments = ""
if not allreturns:
pass
elif (len(allreturns) == 1) and (workspacereturn is not None):
lhs = workspacereturn + " = "
else :
lhs = "result = "
comments = "\n "
comments += "\n # -------------------------------------------------- \n"
comments += " # result is a tuple containing\n"
comments += " # (" + ",".join(allreturns ) + ")\n"
comments += " # To access individual outputs use result[i], where i is the index of the required output.\n"

return lhs + prototype_reformated + comments

#======================================================================
def intialize_files():
""" Get path to every header file """
Expand Down Expand Up @@ -415,13 +476,19 @@ def make_wiki(algo_name, version, latest_version):
raise RuntimeError("Error in processing output from subprocess. Most likely a bug in wiki_tools")
return output

#======================================================================
def do_make_wiki(algo_name, version, latest_version):
""" Return wiki text for a given algorithm
@param algo_name :: name of the algorithm (bare)
@param version :: version requested
@param latest_version :: the latest algorithm
"""
out = ""

external_image = "http://download.mantidproject.org/algorithm_screenshots/ScreenShotImages/%s_dlg.png" % algo_name
out = "<anchor url='%s'><img width=400px align='right' src='%s' style='position:relative; z-index:1000;'></anchor>\n\n" % (external_image, external_image)

# Deprecated algorithms: Simply return the deprecation message
print "Creating... ", algo_name, version
import mantid
from mantid.api import AlgorithmManager,DeprecatedAlgorithmChecker
# Deprecated algorithms: Simply returnd the deprecation message
Expand All @@ -435,10 +502,10 @@ def do_make_wiki(algo_name, version, latest_version):
deprecstr = deprecstr.replace(" instead.", "]] instead.")
out += deprecstr
out += "\n\n"

alg = AlgorithmManager.createUnmanaged(algo_name, version)
alg.initialize()

if (latest_version > 1):
if (version < latest_version):
out += "Note: This page refers to version %d of %s. The latest version is %d - see [[%s v.%d]].\n\n" % (version, algo_name, latest_version, algo_name, latest_version)
Expand All @@ -455,6 +522,10 @@ def do_make_wiki(algo_name, version, latest_version):

out += "== Summary ==\n\n"
out += alg.getWikiSummary().replace("\n", " ") + "\n\n"

out += "\n\n== Usage ==\n\n"
out += " " + create_function_signature(alg, algo_name) + "\n\n"
out += "<br clear=all>\n\n"
out += "== Properties ==\n\n"

out += """{| border="1" cellpadding="5" cellspacing="0"
Expand Down Expand Up @@ -513,7 +584,7 @@ def do_make_wiki(algo_name, version, latest_version):
out += "{{AlgorithmLinks|%s}}\n" % (algo_name)

return out

#======================================================================
def make_property_table_line(propnum, p):
""" Make one line of the property table
Expand All @@ -523,20 +594,15 @@ def make_property_table_line(propnum, p):
p :: Property object
Returns:
string to add to the wiki
"""
"""
from mantid.api import IWorkspaceProperty

out = ""
# The property number
out += "|" + str(propnum) + "\n"
# Name of the property
out += "|" + p.name + "\n"
# Direction
InputDirection = "Intput"
OutputDirection = "Output"
InOutDirection = "InOut"
NoDirection = "None"
direction_string = [InputDirection, OutputDirection, InOutDirection, NoDirection]

out += "|" + direction_string[p.direction] + "\n"
# Type (as string) wrap an IWorkspaceProperty in a link.
if isinstance(p, IWorkspaceProperty):
Expand All @@ -557,6 +623,7 @@ def make_property_table_line(propnum, p):
# End of table line
out += "|-\n"
return out


#======================================================================
def make_group_header_line(group):
Expand Down
8 changes: 4 additions & 4 deletions Code/Mantid/Framework/API/inc/MantidAPI/Axis.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class MANTID_API_DLL Axis
virtual ~Axis();

/// Virtual constructor
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace = NULL) = 0;
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace) = 0;
/// Virtual constructor for axis of different length
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace = NULL) = 0;
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace) = 0;

const std::string& title() const;
std::string& title();
Expand Down Expand Up @@ -84,8 +84,8 @@ class MANTID_API_DLL Axis
/// @param index :: The index
/// @param value :: The new value
virtual void setValue(const std::size_t& index, const double& value) = 0;
/// Get a non-mutable spectrum index
virtual const specid_t& spectraNo(const std::size_t& index) const;
/// Get the spectrum index
virtual specid_t spectraNo(const std::size_t& index) const;

/// Get the length of the axis
virtual std::size_t length() const = 0;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/NumericAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ class MANTID_API_DLL NumericAxis: public Axis
public:
NumericAxis(const std::size_t& length);
virtual ~NumericAxis(){}
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace = NULL);
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace = NULL);
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace);
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace);
///Is the axis numeric - always true for this class
virtual bool isNumeric() const{return true;}
virtual std::size_t length() const{return m_values.size();}
Expand Down
24 changes: 12 additions & 12 deletions Code/Mantid/Framework/API/inc/MantidAPI/SpectraAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ class MatrixWorkspace;
class MANTID_API_DLL SpectraAxis: public Axis
{
public:
explicit SpectraAxis(const std::size_t& length, const bool initWithDefaults = true);
explicit SpectraAxis(const std::size_t length, const Geometry::ISpectraDetectorMap & spectramap);
explicit SpectraAxis(const MatrixWorkspace* const parentWorkspace);
virtual ~SpectraAxis(){}
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace = NULL);
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace = NULL);
virtual std::size_t length() const{return m_values.size();}
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace);
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace);
virtual std::size_t length() const;
/// If this is a spectra Axis - always true for this class
virtual bool isSpectra() const{return true;}
virtual double operator()(const std::size_t& index, const std::size_t& verticalIndex = 0) const;
virtual void setValue(const std::size_t& index, const double& value);
virtual bool operator==(const Axis&) const;
std::string label(const std::size_t& index)const;

const specid_t& spectraNo(const std::size_t& index) const;
specid_t spectraNo(const std::size_t& index) const;
// Get a map that contains the spectra index as the key and the index in the array as teh value
void getSpectraIndexMap(spec2index_map&) const;
void getIndexSpectraMap(index2spec_map& map) const;

/// returns min value defined on axis
double getMin()const{return double(m_values.front()) ; }
/// returns max value defined on axis
double getMax()const{return double(m_values.back()); }
double getMin() const;
double getMax() const;

private:
/// Default constructor
SpectraAxis();
/// Private, undefined copy constructor
SpectraAxis(const SpectraAxis&);
/// Private, undefined copy assignment operator
const SpectraAxis& operator=(const SpectraAxis&);
/// A vector holding the axis values for the axis.
std::vector<specid_t> m_values;
/// A pointer to the workspace holding the axis
const MatrixWorkspace* const m_parentWS;
};

} // namespace API
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/TextAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class MANTID_API_DLL TextAxis: public Axis
public:
TextAxis(const std::size_t& length);
virtual ~TextAxis(){}
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace = NULL);
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace = NULL);
virtual Axis* clone(const MatrixWorkspace* const parentWorkspace);
virtual Axis* clone(const std::size_t length, const MatrixWorkspace* const parentWorkspace);
virtual std::size_t length() const{return m_values.size();}
/// If this is a TextAxis, always return true for this class
virtual bool isText() const{return true;}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/Axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ double Axis::getValue(const std::size_t& index, const std::size_t& verticalIndex
* @return The spectrum number as an int
* @throw domain_error If this method is called on a numeric axis
*/
const specid_t& Axis::spectraNo(const std::size_t& index) const
specid_t Axis::spectraNo(const std::size_t& index) const
{
UNUSED_ARG(index)
throw std::domain_error("Cannot call spectraNo() on a non-spectra axis.");
Expand Down

0 comments on commit 9f9c6cf

Please sign in to comment.