mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2025-06-11 06:47:14 +02:00
added additional tests
All checks were successful
Build on RHEL9 / buildh (push) Successful in 1m52s
All checks were successful
Build on RHEL9 / buildh (push) Successful in 1m52s
This commit is contained in:
@ -3,7 +3,7 @@ from . import _aare
|
||||
|
||||
|
||||
from ._aare import File, RawMasterFile, RawSubFile, JungfrauDataFile
|
||||
from ._aare import Pedestal_d, Pedestal_f, ClusterFinder, VarClusterFinder
|
||||
from ._aare import Pedestal_d, Pedestal_f, ClusterFinder_Cluster3x3i, VarClusterFinder
|
||||
from ._aare import DetectorType
|
||||
from ._aare import ClusterFile_Cluster3x3i as ClusterFile
|
||||
from ._aare import hitmap
|
||||
|
@ -19,11 +19,12 @@
|
||||
namespace py = pybind11;
|
||||
using namespace ::aare;
|
||||
|
||||
template <typename ClusterType>
|
||||
template <typename Type, uint8_t CoordSizeX, uint8_t CoordSizeY,
|
||||
typename CoordType = uint16_t>
|
||||
void define_cluster_file_io_bindings(py::module &m,
|
||||
const std::string &typestr) {
|
||||
// PYBIND11_NUMPY_DTYPE(Cluster<int, 3, 3>, x, y,
|
||||
// data); // is this used - maybe use as cluster type
|
||||
|
||||
using ClusterType = Cluster<Type, CoordSizeX, CoordSizeY, CoordType>;
|
||||
|
||||
auto class_name = fmt::format("ClusterFile_{}", typestr);
|
||||
|
||||
|
@ -32,12 +32,12 @@ PYBIND11_MODULE(_aare, m) {
|
||||
define_interpolation_bindings(m);
|
||||
define_jungfrau_data_file_io_bindings(m);
|
||||
|
||||
define_cluster_file_io_bindings<Cluster<int, 3, 3>>(m, "Cluster3x3i");
|
||||
define_cluster_file_io_bindings<Cluster<double, 3, 3>>(m, "Cluster3x3d");
|
||||
define_cluster_file_io_bindings<Cluster<float, 3, 3>>(m, "Cluster3x3f");
|
||||
define_cluster_file_io_bindings<Cluster<int, 2, 2>>(m, "Cluster2x2i");
|
||||
define_cluster_file_io_bindings<Cluster<float, 2, 2>>(m, "Cluster2x2f");
|
||||
define_cluster_file_io_bindings<Cluster<double, 2, 2>>(m, "Cluster2x2d");
|
||||
define_cluster_file_io_bindings<int, 3, 3, uint16_t>(m, "Cluster3x3i");
|
||||
define_cluster_file_io_bindings<double, 3, 3, uint16_t>(m, "Cluster3x3d");
|
||||
define_cluster_file_io_bindings<float, 3, 3, uint16_t>(m, "Cluster3x3f");
|
||||
define_cluster_file_io_bindings<int, 2, 2, uint16_t>(m, "Cluster2x2i");
|
||||
define_cluster_file_io_bindings<float, 2, 2, uint16_t>(m, "Cluster2x2f");
|
||||
define_cluster_file_io_bindings<double, 2, 2, uint16_t>(m, "Cluster2x2d");
|
||||
|
||||
define_cluster_vector<int, 3, 3, uint16_t>(m, "Cluster3x3i");
|
||||
define_cluster_vector<double, 3, 3, uint16_t>(m, "Cluster3x3d");
|
||||
|
@ -25,5 +25,10 @@ def pytest_collection_modifyitems(config, items):
|
||||
|
||||
@pytest.fixture
|
||||
def test_data_path():
|
||||
return Path(os.environ["AARE_TEST_DATA"])
|
||||
env_value = os.environ.get("AARE_TEST_DATA")
|
||||
if not env_value:
|
||||
raise RuntimeError("Environment variable AARE_TEST_DATA is not set or is empty")
|
||||
|
||||
return Path(env_value)
|
||||
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
|
||||
import aare._aare as aare #import ClusterVector_Cluster3x3i, ClusterVector_Cluster2x2i, Interpolator, Cluster3x3i, ClusterFinder_Cluster3x3i, Cluster2x2i, ClusterFile_Cluster3x3i, Cluster3x3f, calculate_eta2
|
||||
import aare._aare as aare
|
||||
from conftest import test_data_path
|
||||
|
||||
|
||||
def test_ClusterVector():
|
||||
"""Test ClusterVector"""
|
||||
@ -64,15 +66,19 @@ def test_Interpolator():
|
||||
assert interpolated_photons[0]["energy"] == 4
|
||||
|
||||
@pytest.mark.files
|
||||
def test_cluster_file():
|
||||
def test_cluster_file(test_data_path):
|
||||
"""Test ClusterFile"""
|
||||
cluster_file = aare.ClusterFile_Cluster3x3i(test_data_path() / "clust/single_frame_97_clustrers.clust")
|
||||
clustervector = cluster_file.read_clusters() #conversion does not work
|
||||
cluster_file = aare.ClusterFile_Cluster3x3i(test_data_path / "clust/single_frame_97_clustrers.clust")
|
||||
clustervector = cluster_file.read_clusters(10) #conversion does not work
|
||||
|
||||
cluster_file.close()
|
||||
|
||||
assert clustervector.size == 10
|
||||
|
||||
###reading with wrong file
|
||||
cluster_file = ClusterFile_Cluster2x2i(test_data_path() / "clust/single_frame_97_clustrers.clust") #TODO check behavior!
|
||||
with pytest.raises(TypeError):
|
||||
cluster_file = aare.ClusterFile_Cluster2x2i(test_data_path / "clust/single_frame_97_clustrers.clust")
|
||||
cluster_file.close()
|
||||
|
||||
def test_calculate_eta():
|
||||
"""Calculate Eta"""
|
||||
@ -103,6 +109,7 @@ def test_cluster_finder():
|
||||
assert clusters.size == 0
|
||||
|
||||
|
||||
#TODO dont understand behavior
|
||||
def test_cluster_collector():
|
||||
"""Test ClusterCollector"""
|
||||
|
||||
|
Reference in New Issue
Block a user