Skip to content

Commit

Permalink
inital test
Browse files Browse the repository at this point in the history
  • Loading branch information
bingli621 committed May 7, 2024
1 parent 4485705 commit a49ac83
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 7 deletions.
12 changes: 6 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: mypythonapp
name: tavi
channels:
- conda-forge
dependencies:
# -- Runtime dependencies
# base: list all base dependencies here
- python>=3.8 # please specify the mimimum version of python here
- python>=3.10 # please specify the mimimum version of python here
- versioningit
# compute: list all compute dependencies here
- numpy
Expand Down Expand Up @@ -33,7 +33,7 @@ dependencies:
# add additional sections such as Qt, etc. if needed
# --------------------------------------------------
# if pakcages are not available on conda, list them here
- pip
- pip:
- bm3d-streak-removal # example
- pytest-playwright
# - pip
# - pip:
# - bm3d-streak-removal # example
# - pytest-playwright
1 change: 1 addition & 0 deletions src/packagenamepy/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1+d20240507"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions src/tavi/scans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import numpy as np


class Scan(object):
"""
Scan class
"""

def __init__(self):
self.metadata = {}
self.data = {}

def get_metadata(self):
return self.metadata

def get_data(self):
return self.data

def plot_gen(
self,
x_str=None,
y_str=None,
xerr_str=None,
yerr_str=None,
norm_str=None,
norm_val=None,
):
if x_str == None:
x_str = self.get_metadata()["def_x"]

if y_str == None:
y_str = self.get_metadata()["def_y"]

x = self.data[x_str]
y = self.data[y_str]
xerr = None
yerr = None

return x, y, xerr, yerr
File renamed without changes.
23 changes: 23 additions & 0 deletions tests/test_scan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np
from tavi.scans import Scan


def test_get_metadata():
s1 = Scan()
s1.metadata = dict(IPTS=1234, exp=567, def_x="s1")
# print(s1)
# assert s1.metadata["def_x"] == "test"
md = s1.get_metadata()
assert md["def_x"] == "s1"


def test_plot_gen():
s2 = Scan()
s2.metadata = dict(def_x="s1", def_y="detector")
s2.data = dict(s1=np.arange(0, 1, 0.2), detector=np.arange(100, 300, 40))
x, y, xerr, yerr = s2.plot_gen()
print(x)
assert np.allclose(x, np.arange(0, 1, 0.2))
# assert y == np.arange(100, 300, 40)
# assert xerr == 0
# assert yerr == 0
4 changes: 3 additions & 1 deletion tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from packagenamepy import __version__
from tavi import __version__


def test_version():
print(__version__)
assert __version__ == "unknown"
# assert __version__ == "0.0.1"

0 comments on commit a49ac83

Please sign in to comment.