Ticket #10938 (closed: fixed)

Opened 6 years ago

Last modified 5 years ago

Remove hardcoded instances of PI

Reported by: Harry Jeffery Owned by: Harry Jeffery
Priority: minor Milestone: Release 3.4
Component: Framework Keywords:
Cc: Blocked By:
Blocking: Tester: Martyn Gigg

Description (last modified by Harry Jeffery) (diff)

PI is manually defined over sixty times throughout Mantid. Perhaps we should just stick to using M_PI.

Code/Mantid/Framework/API/src/IPowderDiffPeakFunction.cpp:13:const double PI = 3.14159265358979323846264338327950288419716939937510582;
Code/Mantid/Framework/Algorithms/src/RayTracerTester.cpp:69:    double az = double(iaz) * 3.14159 * 2.0 / double(NumAzimuth);
Code/Mantid/Framework/Algorithms/src/RayTracerTester.cpp:71:      double zen = double(iz) * 3.14159 * 1.0 / double(NumZenith);
Code/Mantid/Framework/Algorithms/test/CopyInstrumentParametersTest.h:230:       Geometry::ComponentHelper::moveComponent(*det, *pmap, V3D(sin(3.1415926*double(i)),cos(3.1415926*double(i/500)),7), Absolute );
Code/Mantid/Framework/Algorithms/test/CopyInstrumentParametersTest.h:288:       TS_ASSERT_DELTA( newPos1.X() ,sin(3.1415926*double(i)), 0.0001);
Code/Mantid/Framework/Algorithms/test/CopyInstrumentParametersTest.h:289:       TS_ASSERT_DELTA( newPos1.Y() ,cos(3.1415926*double(i/500)), 0.0001);
Code/Mantid/Framework/Algorithms/test/CorrectFlightPathsTest.h:49:		std::vector<double> polar(5, (30. / 180.) * 3.1415926);
Code/Mantid/Framework/Algorithms/test/CorrectFlightPathsTest.h:52:		azimutal[1] = (45. / 180.) * 3.1415936;
Code/Mantid/Framework/Algorithms/test/CorrectFlightPathsTest.h:53:		azimutal[2] = (90. / 180.) * 3.1415936;
Code/Mantid/Framework/Algorithms/test/CorrectFlightPathsTest.h:54:		azimutal[3] = (135. / 180.) * 3.1415936;
Code/Mantid/Framework/Algorithms/test/CorrectFlightPathsTest.h:55:		azimutal[4] = (180. / 180.) * 3.1415936;
Code/Mantid/Framework/Algorithms/test/ExportTimeSeriesLogTest.h:167:    double PI = 3.14159265;
Code/Mantid/Framework/Algorithms/test/FFTTest.h:23:  FFTTest():dX(0.2),PI(3.1415926535897932384626433832795),h(sqrt(PI/3)),a(PI*PI/3)
Code/Mantid/Framework/Algorithms/test/GenerateEventsFilterTest.h:416:    double PI = 3.14159265;
Code/Mantid/Framework/Algorithms/test/GetTimeSeriesLogInformationTest.h:75:    double PI = 3.14159265;
Code/Mantid/Framework/Algorithms/test/RealFFTTest.h:91:      const double PI = 3.1415926535897932384626433832795;
Code/Mantid/Framework/Algorithms/test/RealFFTTest.h:162:        const double PI = 3.1415926535897932384626433832795;
Code/Mantid/Framework/Algorithms/test/SassenaFFTTest.h:12:#define M_PI 3.14159265358979323846
Code/Mantid/Framework/CurveFitting/src/Bk2BkExpConvPV.cpp:6:#define PI 3.14159265358979323846264338327950288419716939937510582
Code/Mantid/Framework/CurveFitting/src/NeutronBk2BkExpConvPVoigt.cpp:13:const double PI = 3.14159265358979323846264338327950288419716939937510582;
Code/Mantid/Framework/CurveFitting/src/ReflectivityMulf.cpp:5:#define PI 3.14159265358979323846264338327950288419716939937510582
Code/Mantid/Framework/CurveFitting/src/ThermalNeutronBk2BkExpConvPVoigt.cpp:12:const double PI = 3.14159265358979323846264338327950288419716939937510582;
Code/Mantid/Framework/CurveFitting/src/ThermalNeutronDtoTOFFunction.cpp:8:#define PI 3.14159265358979323846264338327950288419716939937510
Code/Mantid/Framework/CurveFitting/test/ExpDecayOscTest.h:105:    TS_ASSERT_DELTA( out->getParameter("Phi"), 3.1415926536/4.0 ,0.01);  // 45 degrees
Code/Mantid/Framework/CurveFitting/test/GausOscTest.h:115:    TS_ASSERT_DELTA( out->getParameter("Phi"), 3.1415926536/4.0 ,0.01);  //  45 degrees
Code/Mantid/Framework/CurveFitting/test/ThermalNeutronDtoTOFFunctionTest.h:78:      double da = -2*exp(-x*x)/sqrt(3.14159265);
Code/Mantid/Framework/DataHandling/src/LoadILLSANS.cpp:588:  return (4 * 3.1415936 * std::sin(twoTheta * (3.1415936 / 180) / 2)) /
Code/Mantid/Framework/Geometry/test/LineTest.h:68:	 const double pi=3.141592653589793238462643383279502884197169399375 ;
Code/Mantid/Framework/Geometry/test/PlaneTest.h:141:	 const double pi=3.141592653589793238462643383279502884197169399375 ;
Code/Mantid/Framework/Kernel/test/VMDTest.h:177:    TS_ASSERT_DELTA( a.angle(b), 3.1415926/2, 1e-4);
Code/Mantid/Framework/MDAlgorithms/test/WeightedMeanMDTest.h:196:    double pi = 3.14159;
Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/ReflectometryTransformKiKf.h:24:      : to_radians_factor(3.14159265 / 180), two_pi(6.28318531),
Code/Mantid/Framework/MDEvents/inc/MantidMDEvents/ReflectometryTransformP.h:21:      : to_radians_factor(3.14159265 / 180), two_pi(6.28318531) {
Code/Mantid/Framework/MDEvents/test/ConvToMDEventsVSHistoTest.h:218:   std::vector<double> polar(5,(30./180.)*3.1415926);
Code/Mantid/Framework/MDEvents/test/ConvToMDEventsVSHistoTest.h:221:   azimutal[1]=(45./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/ConvToMDEventsVSHistoTest.h:222:   azimutal[2]=(90./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/ConvToMDEventsVSHistoTest.h:223:   azimutal[3]=(135./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/ConvToMDEventsVSHistoTest.h:224:   azimutal[4]=(180./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/MDGridBoxTest.h:1673:    do_test_sphereIntegrate(center, 1.0, (1e6/125)*(4.0*3.14159/3.0), 2000.0);
Code/Mantid/Framework/MDEvents/test/MDGridBoxTest.h:1736:    do_test_sphereCentroid(center, 1.0, (1e6/125)*(4.0*3.14159/3.0), 2000);
Code/Mantid/Framework/MDEvents/test/ReflectometryTransformKiKfTest.h:4:#define PI 3.14159265
Code/Mantid/Framework/MDEvents/test/ReflectometryTransformPTest.h:4:#define PI 3.14159265
Code/Mantid/Framework/MDEvents/test/ReflectometryTransformQxQzTest.h:4:#define PI 3.14159265
Code/Mantid/Framework/MDEvents/test/UnitsConversionHelperTest.h:260:    std::vector<double> polar(5,(30./180.)*3.1415926);
Code/Mantid/Framework/MDEvents/test/UnitsConversionHelperTest.h:263:    azimutal[1]=(45./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/UnitsConversionHelperTest.h:264:    azimutal[2]=(90./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/UnitsConversionHelperTest.h:265:    azimutal[3]=(135./180.)*3.1415936;
Code/Mantid/Framework/MDEvents/test/UnitsConversionHelperTest.h:266:    azimutal[4]=(180./180.)*3.1415936;
Code/Mantid/Framework/Nexus/test/NexusAPITest.h:138:    file.putAttr("r4_attribute", 3.14159265);
Code/Mantid/Framework/PythonInterface/test/python/mantid/api/ExperimentInfoTest.py:40:#        ws.setEFixed(1, 3.1415)
Code/Mantid/Framework/PythonInterface/test/python/mantid/api/ExperimentInfoTest.py:41:#      self.assertEquals(ws.getEFixed(1), 3.1415)
Code/Mantid/Framework/UserAlgorithms/Muon_ExpDecayOscTest.cpp:32:             cos(2 * 3.1415926536 * gf * xValues[i] + gphi);
Code/Mantid/Installers/WinInstaller/scons-local/scons-local-2.2.0/SCons/Scanner/LaTeX.py:138:        pdfeTeX 3.141592-1.21a-2.2 (Web2C 7.5.4)
Code/Mantid/MantidPlot/src/ArrowMarker.cpp:41:#define M_PI 3.141592653589793238462643;
Code/Mantid/MantidPlot/src/AxesDialog.cpp:625:#define M_PI	3.141592653589793238462643
Code/Mantid/MantidPlot/src/importOPJ.cpp:541:	double pi=3.141592653589793;
Code/Mantid/TestingTools/cxxtest/docs/texinfo.tex:1076:    % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
Code/Mantid/TestingTools/cxxtest/sample/DeltaTest.h:14:        _pi = 3.1415926535;
Code/Mantid/docs/source/algorithms/UpdateInstrumentFromFile-v1.rst:115:      f.write('{0}  {1}  {2}  {3}  {4}  {5}\n'.format(i+1,(i+1)*3.1415926/200,0.5,100,(i+1)*3.1415926/5,10))
Code/Mantid/instrument/IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING4.xml:95:    <rot val="3.141592653589793" axis-x="0" axis-y="0" axis-z="1" >
Code/Mantid/instrument/IDFs_for_UNIT_TESTING/IDF_for_UNIT_TESTING4.xml:105:    <rot val="3.141592653589793" axis-x="0" axis-y="0" axis-z="1" >
Code/Mantid/scripts/Inelastic/IndirectMuscat.py:37:    PKHT=1.0/3.14159265
Code/Mantid/scripts/Reflectometry/isis_reflectometry/quick.py:192:            PI = 3.1415926535
Test/AutoTestData/NOM_5429.sqa:9896:   22.043072       34.481426      0.14253199       738.03351       3.1418428    
Test/AutoTestData/UsageData/Example.spe:136: 0.000E+00 2.146E+01 3.141E+01 2.306E+01 0.000E+00 2.509E+01 2.634E+01 3.932E+01
Test/AutoTestData/UsageData/NaF_DISF.cdl:200:    2.3561944550823113, 3.1415926067764155, 3.9269907584705188, 

Change History

comment:1 Changed 6 years ago by Harry Jeffery

  • Description modified (diff)

comment:2 Changed 6 years ago by Harry Jeffery

  • Status changed from new to assigned

comment:3 Changed 6 years ago by Harry Jeffery

  • Status changed from assigned to inprogress

Refs #10938 Refactor out pi

Changeset: 2755216cf2cdabee64fb7c7246a132f0ba09ee60

comment:4 Changed 6 years ago by Harry Jeffery

  • Status changed from inprogress to verify
  • Resolution set to fixed

This is being verified as pull request #152.

comment:5 Changed 6 years ago by Martyn Gigg

  • Status changed from verify to verifying
  • Tester set to Martyn Gigg

comment:6 Changed 6 years ago by Martyn Gigg

The system tests all look okay so the precision changes don't seem to have caused any issues.

comment:7 Changed 6 years ago by Martyn Gigg

Merge pull request #152 from mantidproject/feature/10938_remove_hardcoded_pi

Refs #10938 Refactor out pi

Changeset: 5954aa233709a1bca91dd086b184efd263faf411

comment:8 Changed 6 years ago by Martyn Gigg

  • Status changed from verifying to closed

Merge pull request #152 from mantidproject/feature/10938_remove_hardcoded_pi

Refs #10938 Refactor out pi

Full changeset: 5954aa233709a1bca91dd086b184efd263faf411

comment:9 Changed 6 years ago by Martyn Gigg

Merge pull request #152 from mantidproject/feature/10938_remove_hardcoded_pi

Refs #10938 Refactor out pi

Full changeset: 5954aa233709a1bca91dd086b184efd263faf411

comment:10 Changed 5 years ago by Nick Draper

Somehow these slipped through without a resolution. Set to Fixed.

comment:11 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 11777

Note: See TracTickets for help on using tickets.