Made computation of RGB colors for matrix double precision.
Removed printing of binary information in xpm files
since it makes the header not reproducible. This is
not very useful anyway and the alternative to write
an XPM matcher would be overkill.
Change-Id: I4b12da5aaae246e4a146496b6973d5d6880fbf91
gmx_bool bDiscrete)
{
fprintf(out, "/* XPM */\n");
- try
- {
- gmx::BinaryInformationSettings settings;
- settings.generatedByHeader(true);
- settings.linePrefix("/* ");
- settings.lineSuffix(" */");
- gmx::printBinaryInformation(out, gmx::getProgramContext(),
- settings);
- }
- GMX_CATCH_ALL_AND_EXIT_WITH_FATAL_ERROR;
fprintf(out, "/* This file can be converted to EPS by the GROMACS program xpm2ps */\n");
fprintf(out, "/* title: \"%s\" */\n", title);
fprintf(out, "/* legend: \"%s\" */\n", legend);
t_rgb rlo, t_rgb rmid, t_rgb rhi)
{
int i, nmid;
- real r, g, b, clev_lo, clev_hi;
+ double r, g, b, clev_lo, clev_hi;
if (*nlevels > NMAP*NMAP)
{
fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n",
mapper[i % NMAP],
(*nlevels <= NMAP) ? ' ' : mapper[i/NMAP],
- static_cast<unsigned int>(round(255*r)),
- static_cast<unsigned int>(round(255*g)),
- static_cast<unsigned int>(round(255*b)),
+ static_cast<unsigned int>(std::round(255*r)),
+ static_cast<unsigned int>(std::round(255*g)),
+ static_cast<unsigned int>(std::round(255*b)),
((nmid - i)*lo + i*mid)/clev_lo);
}
for (i = 0; (i < (*nlevels-nmid)); i++)
fprintf(out, "\"%c%c c #%02X%02X%02X \" /* \"%.3g\" */,\n",
mapper[(i+nmid) % NMAP],
(*nlevels <= NMAP) ? ' ' : mapper[(i+nmid)/NMAP],
- static_cast<unsigned int>(round(255*r)),
- static_cast<unsigned int>(round(255*g)),
- static_cast<unsigned int>(round(255*b)),
+ static_cast<unsigned int>(std::round(255*r)),
+ static_cast<unsigned int>(std::round(255*g)),
+ static_cast<unsigned int>(std::round(255*b)),
((*nlevels - 1 - nmid - i)*mid + i*hi)/clev_hi);
}
}
#include <string>
#include "gromacs/gmxana/gmx_ana.h"
-#include "gromacs/utility/filestream.h"
-#include "gromacs/utility/path.h"
#include "testutils/cmdlinetest.h"
#include "testutils/refdata.h"
#include "testutils/testasserts.h"
+#include "testutils/textblockmatchers.h"
#include "testutils/xvgtest.h"
namespace gmx
public:
ClustsizeTest()
{
- setInputFile("-f", "clustsize.pdb");
- }
-
- void runTest(bool mol,
- bool cutoff)
- {
- const char *const command[] = { "clustsize" };
- CommandLine args = CommandLine(command);
double tolerance = 1e-4;
test::XvgMatch xvg;
+ test::XvgMatch &toler = xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, tolerance));
- setOutputFile("-mc", ".xvg",
- xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, tolerance)));
- setOutputFile("-nc", ".xvg",
- xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, tolerance)));
- setOutputFile("-ac", ".xvg",
- xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, tolerance)));
- setOutputFile("-hc", ".xvg",
- xvg.tolerance(gmx::test::relativeToleranceAsFloatingPoint(1, tolerance)));
-
- if (mol)
- {
- setInputFile("-s", "clustsize.tpr");
- args.addOption("-mol");
- }
- else
- {
- setInputFile("-n", "clustsize.ndx");
- }
- if (cutoff)
- {
- args.addOption("-cut", "0.3");
- }
- rootChecker().checkString(args.toString(), "CommandLine");
+ setOutputFile("-mc", ".xvg", toler);
+ setOutputFile("-nc", ".xvg", toler);
+ setOutputFile("-ac", ".xvg", toler);
+ setOutputFile("-hc", ".xvg", toler);
+ setInputFile("-f", "clustsize.pdb");
+ }
+ void runTest(const CommandLine &args)
+ {
CommandLine &cmdline = commandLine();
cmdline.merge(args);
+ gmx::test::TestReferenceChecker rootChecker(this->rootChecker());
+ rootChecker.checkString(args.toString(), "CommandLine");
+
ASSERT_EQ(0, gmx_clustsize(cmdline.argc(), cmdline.argv()));
checkOutputFiles();
TEST_F(ClustsizeTest, NoMolDefaultCutoff)
{
- runTest(false, false);
+ const char *const command[] = { "clustsize" };
+ CommandLine args = CommandLine(command);
+
+ setInputFile("-n", "clustsize.ndx");
+
+ runTest(args);
}
TEST_F(ClustsizeTest, NoMolShortCutoff)
{
- runTest(false, true);
+ const char *const command[] = { "clustsize", "-cut", "0.3" };
+ CommandLine args = CommandLine(command);
+
+ setInputFile("-n", "clustsize.ndx");
+
+ runTest(args);
}
TEST_F(ClustsizeTest, MolDefaultCutoff)
{
- runTest(true, false);
+ const char *const command[] = { "clustsize", "-mol" };
+ CommandLine args = CommandLine(command);
+
+ setInputFile("-s", "clustsize.tpr");
+
+ runTest(args);
}
TEST_F(ClustsizeTest, MolShortCutoff)
{
- runTest(true, true);
+ const char *const command[] = { "clustsize", "-mol", "-cut", "0.3" };
+ CommandLine args = CommandLine(command);
+
+ setInputFile("-s", "clustsize.tpr");
+
+ runTest(args);
+}
+
+TEST_F(ClustsizeTest, MolCSize)
+{
+ const char *const command[] = { "clustsize", "-mol", "-nlevels", "6" };
+ CommandLine args = CommandLine(command);
+
+ setOutputFile("-o", ".xpm", ExactTextMatch());
+ setOutputFile("-ow", ".xpm", ExactTextMatch());
+
+ setInputFile("-s", "clustsize.tpr");
+
+ runTest(args);
}
} // namespace
--- /dev/null
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="referencedata.xsl"?>
+<ReferenceData>
+ <String Name="CommandLine">clustsize -mol -nlevels 6</String>
+ <OutputFiles Name="Files">
+ <File Name="-o">
+ <String Name="Contents"><![CDATA[
+/* XPM */
+/* This file can be converted to EPS by the GROMACS program xpm2ps */
+/* title: "Cluster size distribution" */
+/* legend: "# clusters" */
+/* x-label: "Time (ps)" */
+/* y-label: "Size" */
+/* type: "Continuous" */
+static char *gromacs_xpm[] = {
+"2 2 6 1",
+"A c #FFFF00 " /* "1" */,
+"B c #CCCC33 " /* "2" */,
+"C c #999966 " /* "3" */,
+"D c #666699 " /* "4" */,
+"E c #3333CC " /* "5" */,
+"F c #0000FF " /* "6" */,
+/* x-axis: 1 2 */
+/* y-axis: 1 2 */
+"AA",
+"FF"
+]]></String>
+ </File>
+ <File Name="-ow">
+ <String Name="Contents"><![CDATA[
+/* XPM */
+/* This file can be converted to EPS by the GROMACS program xpm2ps */
+/* title: "Weighted cluster size distribution" */
+/* legend: "Fraction" */
+/* x-label: "Time (ps)" */
+/* y-label: "Size" */
+/* type: "Continuous" */
+static char *gromacs_xpm[] = {
+"2 2 6 1",
+"A c #FFFFFF " /* "0" */,
+"B c #FFFF00 " /* "2" */,
+"C c #BFBF40 " /* "3" */,
+"D c #808080 " /* "4" */,
+"E c #4040BF " /* "5" */,
+"F c #0000FF " /* "6" */,
+/* x-axis: 1 2 */
+/* y-axis: 1 2 */
+"BB",
+"FF"
+]]></String>
+ </File>
+ <File Name="-mc">
+ <XvgLegend Name="Legend">
+ <String Name="XvgLegend"><![CDATA[
+title "Max cluster size"
+xaxis label "Time (ps)"
+yaxis label "#molecules"
+TYPE xy
+]]></String>
+ </XvgLegend>
+ <XvgData Name="Data">
+ <Sequence Name="Row0">
+ <Int Name="Length">2</Int>
+ <Real>1.000000e+00</Real>
+ <Real>2</Real>
+ </Sequence>
+ <Sequence Name="Row1">
+ <Int Name="Length">2</Int>
+ <Real>2.000000e+00</Real>
+ <Real>2</Real>
+ </Sequence>
+ </XvgData>
+ </File>
+ <File Name="-nc">
+ <XvgLegend Name="Legend">
+ <String Name="XvgLegend"><![CDATA[
+title "Number of clusters"
+xaxis label "Time (ps)"
+yaxis label "N"
+TYPE xy
+]]></String>
+ </XvgLegend>
+ <XvgData Name="Data">
+ <Sequence Name="Row0">
+ <Int Name="Length">2</Int>
+ <Real>1.000000e+00</Real>
+ <Real>7</Real>
+ </Sequence>
+ <Sequence Name="Row1">
+ <Int Name="Length">2</Int>
+ <Real>2.000000e+00</Real>
+ <Real>7</Real>
+ </Sequence>
+ </XvgData>
+ </File>
+ <File Name="-ac">
+ <XvgLegend Name="Legend">
+ <String Name="XvgLegend"><![CDATA[
+title "Average cluster size"
+xaxis label "Time (ps)"
+yaxis label "#molecules"
+TYPE xy
+]]></String>
+ </XvgLegend>
+ <XvgData Name="Data">
+ <Sequence Name="Row0">
+ <Int Name="Length">2</Int>
+ <Real>1.000000e+00</Real>
+ <Real>2.000</Real>
+ </Sequence>
+ <Sequence Name="Row1">
+ <Int Name="Length">2</Int>
+ <Real>2.000000e+00</Real>
+ <Real>2.000</Real>
+ </Sequence>
+ </XvgData>
+ </File>
+ <File Name="-hc">
+ <XvgLegend Name="Legend">
+ <String Name="XvgLegend"><![CDATA[
+title "Cluster size distribution"
+xaxis label "Cluster size"
+yaxis label "()"
+TYPE xy
+]]></String>
+ </XvgLegend>
+ <XvgData Name="Data">
+ <Sequence Name="Row0">
+ <Int Name="Length">2</Int>
+ <Real>0</Real>
+ <Real>0.000</Real>
+ </Sequence>
+ <Sequence Name="Row1">
+ <Int Name="Length">2</Int>
+ <Real>1</Real>
+ <Real>6.000</Real>
+ </Sequence>
+ <Sequence Name="Row2">
+ <Int Name="Length">2</Int>
+ <Real>2</Real>
+ <Real>1.000</Real>
+ </Sequence>
+ <Sequence Name="Row3">
+ <Int Name="Length">2</Int>
+ <Real>3</Real>
+ <Real>0.000</Real>
+ </Sequence>
+ </XvgData>
+ </File>
+ </OutputFiles>
+</ReferenceData>