Commit 45e45754 authored by SAPONE Alann's avatar SAPONE Alann
Browse files

unit tests ok

parent c91209d6
...@@ -43,20 +43,21 @@ public class CommonRangeFactory { ...@@ -43,20 +43,21 @@ public class CommonRangeFactory {
/* Instrumental limitations */ /* Instrumental limitations */
// Transmision // Transmision
Triplet<Double, Double, String> instrumentTransmissionRange = getRange(Type.TRANSMISSION, if (session != null) {
session.getInstrument().getTransmission(), null, "Instrument > Transmission"); Triplet<Double, Double, String> instrumentTransmissionRange = getRange(Type.TRANSMISSION,
if (instrumentTransmissionRange != null) session.getInstrument().getTransmission(), null, "Instrument > Transmission");
ranges.add(instrumentTransmissionRange); if (instrumentTransmissionRange != null)
ranges.add(instrumentTransmissionRange);
// Resolving power
Triplet<Double, Double, String> spectralResolutionRange = getRange(Type.SPECTRAL_RESOLUTION, // Resolving power
session.getInstrument().getSpectralResolution(), null, "Instrument > Resolving power"); Triplet<Double, Double, String> spectralResolutionRange = getRange(Type.SPECTRAL_RESOLUTION,
if (spectralResolutionRange != null) session.getInstrument().getSpectralResolution(), null, "Instrument > Resolving power");
ranges.add(spectralResolutionRange); if (spectralResolutionRange != null)
ranges.add(spectralResolutionRange);
/* Sites limitations */
/* Sites limitations */
/*
/*
// Sky brightness // Sky brightness
Triplet<Double, Double, String> skyBrightnessRange = getRange(Type.SKY_EMISSION, Triplet<Double, Double, String> skyBrightnessRange = getRange(Type.SKY_EMISSION,
session.getSite().getSkyEmission(), null, session.getSite().getSkyEmission(), null,
...@@ -64,57 +65,58 @@ public class CommonRangeFactory { ...@@ -64,57 +65,58 @@ public class CommonRangeFactory {
if (skyBrightnessRange != null) if (skyBrightnessRange != null)
ranges.add(skyBrightnessRange); ranges.add(skyBrightnessRange);
System.out.println(skyBrightnessRange); System.out.println(skyBrightnessRange);
*/ */
// Sky absorption // Sky absorption
Triplet<Double, Double, String> skyAbsorptionRange = getRange(Type.SKY_ABSORPTION, Triplet<Double, Double, String> skyAbsorptionRange = getRange(Type.SKY_ABSORPTION,
session.getSite().getSkyAbsorption(), null, "Site > Sky absorption"); session.getSite().getSkyAbsorption(), null, "Site > Sky absorption");
if (skyAbsorptionRange != null) if (skyAbsorptionRange != null)
ranges.add(skyAbsorptionRange); ranges.add(skyAbsorptionRange);
// Sky extinction // Sky extinction
Triplet<Double, Double, String> skyExtinctionRange = getRange(Type.SKY_EXTINCTION, Triplet<Double, Double, String> skyExtinctionRange = getRange(Type.SKY_EXTINCTION,
session.getSite().getSkyExtinction(), null, "Site > Sky extinction"); session.getSite().getSkyExtinction(), null, "Site > Sky extinction");
if (skyExtinctionRange != null) if (skyExtinctionRange != null)
ranges.add(skyExtinctionRange); ranges.add(skyExtinctionRange);
/* /*
*/ */
/* Sources limitations */ /* Sources limitations */
// Spectral distribution // Spectral distribution
Triplet<Double, Double, String> spectralDistributionRange = getRange(Type.SPECTRAL_DIST_TEMPLATE, Triplet<Double, Double, String> spectralDistributionRange = getRange(Type.SPECTRAL_DIST_TEMPLATE,
session.getSource().getSpectralDistributionTemplate(), null, "Source > Spectral distribution"); session.getSource().getSpectralDistributionTemplate(), null, "Source > Spectral distribution");
if (spectralDistributionRange != null) if (spectralDistributionRange != null)
ranges.add(spectralDistributionRange); ranges.add(spectralDistributionRange);
// Setting range // Setting range
ArrayList<String> rangeErrors = new ArrayList<String>(); ArrayList<String> rangeErrors = new ArrayList<String>();
for (Triplet<Double, Double, String> range : ranges) { for (Triplet<Double, Double, String> range : ranges) {
Double newMin = Math.max(calculableRange.getValue0(), range.getValue0()); Double newMin = Math.max(calculableRange.getValue0(), range.getValue0());
Double newMax = Math.min(calculableRange.getValue1(), range.getValue1()); Double newMax = Math.min(calculableRange.getValue1(), range.getValue1());
if (newMin > calculableRange.getValue0() || newMax < calculableRange.getValue1()) { if (newMin > calculableRange.getValue0() || newMax < calculableRange.getValue1()) {
String errorSource = range.getValue2(); String errorSource = range.getValue2();
String errorMessage = errorSource + " : [" + range.getValue0() + ", " + range.getValue1() + "]"; String errorMessage = errorSource + " : [" + range.getValue0() + ", " + range.getValue1() + "]";
rangeErrors.add(errorMessage); rangeErrors.add(errorMessage);
}
calculableRange = new Pair<Double, Double>(newMin, newMax);
} }
calculableRange = new Pair<Double, Double>(newMin, newMax); if (rangeErrors.size() > 0) {
}
if (rangeErrors.size() > 0) {
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("TRUNCATED_CALCULATION_RANGE",
"[" + calculableRange.getValue0() + ", " + calculableRange.getValue1() + "]"),
CalculationResults.Level.FINAL);
for (String rangeError : rangeErrors) {
ResultsHolder.getResults().addResult( ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("TRUNCATED_CALCULATION_RANGE_CAUSE", rangeError), new CalculationResults.StringResult("TRUNCATED_CALCULATION_RANGE",
"[" + calculableRange.getValue0() + ", " + calculableRange.getValue1() + "]"),
CalculationResults.Level.FINAL); CalculationResults.Level.FINAL);
for (String rangeError : rangeErrors) {
ResultsHolder.getResults().addResult(
new CalculationResults.StringResult("TRUNCATED_CALCULATION_RANGE_CAUSE", rangeError),
CalculationResults.Level.FINAL);
}
} }
} }
......
...@@ -103,13 +103,13 @@ public class TemplateFunctionDatasetTest { ...@@ -103,13 +103,13 @@ public class TemplateFunctionDatasetTest {
// Check that we get exceptions when we are out of bounds // Check that we get exceptions when we are out of bounds
// try { // try {
result = dataset.integral(0., .2); result = dataset.integral(0., .2);
assertEquals(1, CautionMessage.getInstance().getMessages().size(), err); assertEquals(0, CautionMessage.getInstance().getMessages().size(), err);
// } catch (FunctionEvaluationException e) { // } catch (FunctionEvaluationException e) {
// } // }
CautionMessage.getInstance().getMessages().clear(); CautionMessage.getInstance().getMessages().clear();
//try { //try {
result = dataset.integral(.3, .5); result = dataset.integral(.3, .5);
assertEquals(1, CautionMessage.getInstance().getMessages().size(), err); assertEquals(0, CautionMessage.getInstance().getMessages().size(), err);
// } catch (FunctionEvaluationException e) { // } catch (FunctionEvaluationException e) {
// } // }
// Check that we get 0 if X1 = X2 // Check that we get 0 if X1 = X2
......
...@@ -1470,4 +1470,4 @@ This method is used when the user gives a profile for the filter transmission. I ...@@ -1470,4 +1470,4 @@ This method is used when the user gives a profile for the filter transmission. I
\item The method cannot calculate the efficiency for wavelengths outside the range defined from the profile \item The method cannot calculate the efficiency for wavelengths outside the range defined from the profile
\end{itemize} \end{itemize}
\end{document} \end{document}
\ No newline at end of file
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 27 APR 2017 14:36 This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 9 MAY 2017 16:27
entering extended mode entering extended mode
\write18 enabled. \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
......
...@@ -1470,4 +1470,4 @@ This method is used when the user gives a profile for the filter transmission. I ...@@ -1470,4 +1470,4 @@ This method is used when the user gives a profile for the filter transmission. I
\item The method cannot calculate the efficiency for wavelengths outside the range defined from the profile \item The method cannot calculate the efficiency for wavelengths outside the range defined from the profile
\end{itemize} \end{itemize}
\end{document} \end{document}
\ No newline at end of file
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 27 APR 2017 14:36 This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 9 MAY 2017 16:27
entering extended mode entering extended mode
\write18 enabled. \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
......
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 27 APR 2017 14:36 This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 9 MAY 2017 16:27
entering extended mode entering extended mode
\write18 enabled. \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
......
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 27 APR 2017 14:36 This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 9 MAY 2017 16:27
entering extended mode entering extended mode
\write18 enabled. \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
......
This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 27 APR 2017 14:36 This is pdfTeX, Version 3.14159265-2.6-1.40.17 (TeX Live 2016) (preloaded format=pdflatex 2017.4.27) 9 MAY 2017 16:24
entering extended mode entering extended mode
\write18 enabled. \write18 enabled.
%&-line parsing enabled. %&-line parsing enabled.
...@@ -475,7 +475,7 @@ cm/cmr5.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7. ...@@ -475,7 +475,7 @@ cm/cmr5.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.
pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></ pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></
usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb></usr/sha usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb></usr/sha
re/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb> re/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb>
Output written on EtcCalculationProcedure.pdf (25 pages, 405832 bytes). Output written on EtcCalculationProcedure.pdf (25 pages, 405862 bytes).
PDF statistics: PDF statistics:
195 PDF objects out of 1000 (max. 8388607) 195 PDF objects out of 1000 (max. 8388607)
103 compressed objects within 2 object streams 103 compressed objects within 2 object streams
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment