Skip to content

Commit

Permalink
[CHORE] Different behavior on prod and locally. Wild guess
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Sikina committed Oct 1, 2024
1 parent 61f08b4 commit e481e60
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ private Float parseFromIndex(String valuesArr, int index) {
if (arr.length() != 2) {
return 0F;
}
String raw = arr.getString(index);
if (raw.contains("e")) {
// scientific notation
return Double.valueOf(raw).floatValue();
} else {
return Float.parseFloat(raw);
}
Object raw = arr.get(index);
return switch (raw) {
case Double d -> d.floatValue();
case Integer i -> i.floatValue();
default -> 0f;
};
} catch (JSONException ex) {
log.warn("Invalid json array for values: ", ex);
return 0F;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,14 @@ void shouldGetContConceptWithSciNotation() {
Assertions.assertEquals((float) min, concept.min());
Assertions.assertEquals((float) max, concept.max());
}

@Test
void shouldGetContConceptWithDecimalNotation() {
Optional<Concept> actual = subject.getConcept("phs000007", "\\phs000007\\pht000033\\phv00008849\\D080\\");

Assertions.assertTrue(actual.isPresent());
ContinuousConcept concept = (ContinuousConcept) actual.get();
Assertions.assertEquals(0.57f, concept.min());
Assertions.assertEquals(6.77f, concept.max());
}
}
2 changes: 1 addition & 1 deletion src/test/resources/seed.sql
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ COPY public.concept_node_meta (concept_node_meta_id, concept_node_id, key, value
124 268 description Whole exome sequencing
40 229 values [0, 3]
46 232 values [0, 1]
52 235 values [0, 5]
52 235 values [0.57,6.77]
60 241 values ["5e-21", "7e+33"]
125 268 values TRUE
126 269 description Whole genome sequencing
Expand Down

0 comments on commit e481e60

Please sign in to comment.