Skip to content

Commit

Permalink
Use Double.parseDouble instead of DataTools.parseDouble to fix test f…
Browse files Browse the repository at this point in the history
…ailures
  • Loading branch information
melissalinkert committed Apr 22, 2024
1 parent 6bc132a commit 7865d78
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 92 deletions.
21 changes: 9 additions & 12 deletions components/formats-gpl/src/loci/formats/in/BaseZeissReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import java.util.ArrayList;
import java.lang.Math;

import loci.common.DataTools;
import loci.common.DateTools;
import loci.formats.CoreMetadata;
import loci.formats.FormatTools;
Expand Down Expand Up @@ -401,12 +400,10 @@ protected void fillMetadataPass7(MetadataStore store) throws FormatException, IO
exposure = exposureTime.values().iterator().next();
}
Double exp = 0d;
try { exp = DataTools.parseDouble(exposure); }
try { exp = Double.parseDouble(exposure); }
catch (NumberFormatException e) { }
catch (NullPointerException e) { }
if (exp != null) {
store.setPlaneExposureTime(new Time(exp, UNITS.SECOND), i, plane);
}
store.setPlaneExposureTime(new Time(exp, UNITS.SECOND), i, plane);

int posIndex = i * getImageCount() + plane;

Expand Down Expand Up @@ -913,7 +910,7 @@ else if (key.startsWith("NumberOfRawImages") && rawCount == 0)
}
else if (key.startsWith("Emission Wavelength")) {
if (cIndex != -1) {
Double wave = DataTools.parseDouble(value);
Double wave = Double.parseDouble(value);
Length emission = FormatTools.getEmissionWavelength(wave);
if (emission != null) {
emWavelength.put(cIndex, emission);
Expand All @@ -922,7 +919,7 @@ else if (key.startsWith("Emission Wavelength")) {
}
else if (key.startsWith("Excitation Wavelength")) {
if (cIndex != -1) {
Double wave = DataTools.parseDouble(value);
Double wave = Double.parseDouble(value);
Length excitation = FormatTools.getExcitationWavelength(wave);
if (excitation != null) {
exWavelength.put(cIndex, excitation);
Expand Down Expand Up @@ -964,7 +961,7 @@ else if (key.startsWith("Objective ID")) {
store.setObjectiveImmersion(MetadataTools.getImmersion("Other"), 0, 0);
}
else if (key.startsWith("Objective N.A.")) {
store.setObjectiveLensNA(DataTools.parseDouble(value), 0, 0);
store.setObjectiveLensNA(Double.parseDouble(value), 0, 0);
}
else if (key.startsWith("Objective Name")) {
String[] tokens = value.split(" ");
Expand All @@ -975,14 +972,14 @@ else if (key.startsWith("Objective Name")) {
Double.parseDouble(tokens[q].substring(0, slash - q));
String na = tokens[q].substring(slash + 1);
store.setObjectiveNominalMagnification(mag, 0, 0);
store.setObjectiveLensNA(DataTools.parseDouble(na), 0, 0);
store.setObjectiveLensNA(Double.parseDouble(na), 0, 0);
store.setObjectiveCorrection(MetadataTools.getCorrection(tokens[q - 1]), 0, 0);
break;
}
}
}
else if (key.startsWith("Objective Working Distance")) {
store.setObjectiveWorkingDistance(new Length(DataTools.parseDouble(value), UNITS.MICROMETER), 0, 0);
store.setObjectiveWorkingDistance(new Length(Double.parseDouble(value), UNITS.MICROMETER), 0, 0);
}
else if (key.startsWith("Objective Immersion Type")) {
String immersion = "Other";
Expand All @@ -1008,10 +1005,10 @@ else if (key.startsWith("Stage Position Y")) {
addGlobalMetaList("Y position for position", value);
}
else if (key.startsWith("Orca Analog Gain")) {
detectorGain.put(cIndex, DataTools.parseDouble(value));
detectorGain.put(cIndex, Double.parseDouble(value));
}
else if (key.startsWith("Orca Analog Offset")) {
detectorOffset.put(cIndex, DataTools.parseDouble(value));
detectorOffset.put(cIndex, Double.parseDouble(value));
}
else if (key.startsWith("Comments")) {
imageDescription = value;
Expand Down
14 changes: 7 additions & 7 deletions components/formats-gpl/src/loci/formats/in/CellWorxReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ protected void parseWellLogFile(int wellIndex, MetadataStore store)
}
else if (key.equals("Scan Origin")) {
String[] axes = value.split(",");
Double posX = DataTools.parseDouble(axes[0]);
Double posY = DataTools.parseDouble(axes[1]);
Double posX = Double.parseDouble(axes[0]);
Double posY = Double.parseDouble(axes[1]);
for (int fieldRow=0; fieldRow<fieldMap.length; fieldRow++) {
for (int fieldCol=0; fieldCol<fieldMap[fieldRow].length; fieldCol++) {
if (fieldMap[fieldRow][fieldCol] && wellFiles[row][col] != null) {
Expand All @@ -799,8 +799,8 @@ else if (key.equals("Scan Area")) {
int s = value.indexOf('x');
if (s > 0) {
int end = value.indexOf(" ", s + 2);
Double xSize = DataTools.parseDouble(value.substring(0, s).trim());
Double ySize = DataTools.parseDouble(value.substring(s + 1, end).trim());
Double xSize = Double.parseDouble(value.substring(0, s).trim());
Double ySize = Double.parseDouble(value.substring(s + 1, end).trim());

Length x = FormatTools.getPhysicalSizeX(xSize / getSizeX());
Length y = FormatTools.getPhysicalSizeY(ySize / getSizeY());
Expand All @@ -827,7 +827,7 @@ else if (key.startsWith("Channel")) {
token = token.trim();
if (token.startsWith("gain")) {
String instrumentID = MetadataTools.createLSID("Instrument", 0);
Double gain = DataTools.parseDouble(token.replaceAll("gain ", ""));
Double gain = Double.parseDouble(token.replaceAll("gain ", ""));
String detectorID = MetadataTools.createLSID("Detector", 0, 0);

store.setInstrumentID(instrumentID, 0);
Expand All @@ -854,8 +854,8 @@ else if (token.startsWith("EX")) {
}
}

Double emission = DataTools.parseDouble(em);
Double excitation = DataTools.parseDouble(ex);
Double emission = Double.parseDouble(em);
Double excitation = Double.parseDouble(ex);

Length exWave = FormatTools.getExcitationWavelength(excitation);
Length emWave = FormatTools.getEmissionWavelength(emission);
Expand Down
11 changes: 4 additions & 7 deletions components/formats-gpl/src/loci/formats/in/ND2Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public void populateROIs(MetadataStore store) {
store.setLabelFontSize(new Length(fontSize, UNITS.POINT), r, 0);
}
store.setLabelText(roi.get("eval-text"), r, 0);
Length l = new Length(DataTools.parseDouble(roi.get("line-width")), UNITS.PIXEL);
Length l = new Length(Double.parseDouble(roi.get("line-width")), UNITS.PIXEL);
store.setLabelStrokeWidth(l, r, 0);

String rectangle = roi.get("rectangle");
Expand Down Expand Up @@ -885,11 +885,11 @@ else if (key.equals("Line")) {
}
else if (key.equalsIgnoreCase("Emission wavelength")) {
String[] v = value.split(" ");
emWave.add(DataTools.parseDouble(v[0]));
emWave.add(Double.parseDouble(v[0]));
}
else if (key.equalsIgnoreCase("Excitation wavelength")) {
String[] v = value.split(" ");
exWave.add(DataTools.parseDouble(v[0]));
exWave.add(Double.parseDouble(v[0]));
}
else if (key.equals("Power")) {
power.add(DataTools.parseDouble(value).intValue());
Expand All @@ -898,10 +898,7 @@ else if (key.equals("CameraUniqueName")) {
cameraModel = value;
}
else if (key.equals("ExposureTime")) {
Double time = DataTools.parseDouble(value);
if (time != null) {
exposureTime.add(time / 1000d);
}
exposureTime.add(Double.parseDouble(value) / 1000d);
}
else if (key.equals("sDate")) {
date = DateTools.formatDate(value, DATE_FORMAT);
Expand Down
Loading

0 comments on commit 7865d78

Please sign in to comment.