Commit e3441398 authored by Linus Pithan's avatar Linus Pithan Committed by Cyril Guilloud
Browse files

[shell] export certain numpy functions flat to the shell env_dict

parent c15ec4c2
Pipeline #24061 canceled with stages
in 3 minutes and 43 seconds
...@@ -96,6 +96,35 @@ from bliss.common.types import ( ...@@ -96,6 +96,35 @@ from bliss.common.types import (
_providing_channel, _providing_channel,
) )
############## imports that are only used simpyly the
############## shell user access to these functions
# hint: don't forget to add to __all__ as well
from numpy import (
sin,
cos,
tan,
arcsin,
arccos,
arctan,
arctan2,
log,
log10,
sqrt,
exp,
power,
deg2rad,
rad2deg,
)
from numpy.random import rand
from time import asctime as date
# gevent sleep
##############
__all__ = ( __all__ = (
[ [
"wa", "wa",
...@@ -139,6 +168,25 @@ __all__ = ( ...@@ -139,6 +168,25 @@ __all__ = (
+ ["cleanup", "error_cleanup", "plot", "lscnt", "lsmg", "wid"] + ["cleanup", "error_cleanup", "plot", "lscnt", "lsmg", "wid"]
+ ["SoftAxis", "SoftCounter", "edit_roi_counters", "edit_mg"] + ["SoftAxis", "SoftCounter", "edit_roi_counters", "edit_mg"]
+ list(limatools.__all__) + list(limatools.__all__)
+ [
"sin",
"cos",
"tan",
"arcsin",
"arccos",
"arctan",
"arctan2",
"log",
"log10",
"sqrt",
"exp",
"power",
"deg2rad",
"rad2deg",
"rand",
"sleep",
"date",
]
) )
tabulate.PRESERVE_WHITESPACE = True tabulate.PRESERVE_WHITESPACE = True
......
import logging
import subprocess import subprocess
import time import time
import pytest import pytest
import numpy
from bliss.shell.standard import wa, wm, sta, stm, _launch_silx, umv from bliss.shell.standard import wa, wm, sta, stm, _launch_silx, umv
from bliss.shell.standard import sin, cos, tan, arcsin, arccos, arctan, arctan2
from bliss.shell.standard import log, log10, sqrt, exp, power, deg2rad, rad2deg
from bliss.shell.standard import rand, date, sleep
@pytest.fixture @pytest.fixture
def s1hg(default_session): def s1hg(default_session):
...@@ -14,6 +18,19 @@ def s1hg(default_session): ...@@ -14,6 +18,19 @@ def s1hg(default_session):
s1hg.__close__() s1hg.__close__()
def test_std_func():
# No mathematical proof, just to ensure all functions are imported.
numpy.testing.assert_almost_equal(sin(cos(tan(arcsin(0.1)))), 0.838733, 4)
numpy.testing.assert_almost_equal(arccos(arctan(arctan2(0.1, 1))), 1.47129, 4)
numpy.testing.assert_almost_equal(log(sqrt(exp(power(2, 3)))), 4.0, 4)
numpy.testing.assert_almost_equal(log10(deg2rad(rad2deg(4))), 0.602, 4)
_ = rand()
_ = date()
sleep(0.001)
def test_wa_normal(default_session, capsys): def test_wa_normal(default_session, capsys):
bad = default_session.config.get("bad") bad = default_session.config.get("bad")
bad.controller.bad_position = False bad.controller.bad_position = False
...@@ -130,8 +147,8 @@ def test_sta_slits(s1hg, capsys): ...@@ -130,8 +147,8 @@ def test_sta_slits(s1hg, capsys):
captured = capsys.readouterr() captured = capsys.readouterr()
assert "s1hg" in captured.out assert "s1hg" in captured.out
assert not "s1f" in captured.out assert "s1f" not in captured.out
assert not "s1b" in captured.out assert "s1b" not in captured.out
def test_sta_exception(default_session, capsys): def test_sta_exception(default_session, capsys):
......
Supports Markdown
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