Skip to content

Commit

Permalink
Merge pull request #33 from dls-controls/bump
Browse files Browse the repository at this point in the history
Bump to latest versions and fix NaN issue
  • Loading branch information
coretl authored Apr 22, 2022
2 parents 0f56812 + 90d4f8e commit 56cb10b
Show file tree
Hide file tree
Showing 9 changed files with 357 additions and 182 deletions.
9 changes: 0 additions & 9 deletions .readthedocs.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

17 changes: 0 additions & 17 deletions CHANGELOG.rst

This file was deleted.

428 changes: 326 additions & 102 deletions Pipfile.lock

Large diffs are not rendered by default.

Binary file removed docs/images/dls-favicon.ico
Binary file not shown.
11 changes: 0 additions & 11 deletions docs/images/dls-logo.svg

This file was deleted.

7 changes: 4 additions & 3 deletions src/coniql/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ def make_number_format_string(
return "{:.%df}" % precision


def return_unchanged(value):
return value
def return_if_number(value):
if math.isfinite(value):
return value


def return_none(*args, **kwargs):
Expand All @@ -77,7 +78,7 @@ def for_number(
to_string=number_format_string.format,
to_string_with_units=units_format_string.format,
# number -> float just returns the number
to_float=return_unchanged,
to_float=return_if_number,
)
return formatter

Expand Down
6 changes: 5 additions & 1 deletion tests/soft_records.db
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ record (mbbi, "$(P)enum") {
field(THVL, "4")
field(VAL, "3")
field(PINI, "YES")
}
}

record(ao, "$(P)nan") {
field(VAL, "NaN")
}
23 changes: 22 additions & 1 deletion tests/test_caplugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import math
import random
import string
import subprocess
Expand All @@ -11,7 +12,7 @@
from unittest.mock import ANY

import pytest
from aioca import purge_channel_caches
from aioca import caget, purge_channel_caches
from tartiflette import Engine

from coniql.app import make_context
Expand Down Expand Up @@ -133,6 +134,26 @@ async def test_get_str_pv(engine: Engine, ioc: Popen):
assert result == dict(data=dict(getChannel=dict(value=dict(string="longout"))))


@pytest.mark.asyncio
async def test_get_nan_pv(engine: Engine, ioc: Popen):
query = (
"""
query {
getChannel(id: "ca://%snan") {
value {
float
}
}
}
"""
% PV_PREFIX
)
val = await caget(PV_PREFIX + "nan")
assert math.isnan(val)
result = await engine.execute(query, context=make_context())
assert result == dict(data=dict(getChannel=dict(value=dict(float=None))))


@pytest.mark.asyncio
async def test_get_enum_pv(engine: Engine, ioc: Popen):
query = (
Expand Down

0 comments on commit 56cb10b

Please sign in to comment.