fix ci and add formatting (#48)

* add dependency

* dont run blocking zmq example and add formatting

* format files
This commit is contained in:
Bechir Braham
2024-04-03 13:47:52 +02:00
committed by GitHub
parent 23c855acbc
commit 31a20d4f6c
34 changed files with 438 additions and 522 deletions

View File

@ -45,7 +45,7 @@ jobs:
pwd
export PROJECT_ROOT_DIR="."
ls build/examples/*_example
find build/examples -name "*_example" | xargs -I {} -n 1 -t bash -c {}
find build/examples -name "*_example" -not -name "zmq_example" | xargs -I {} -n 1 -t bash -c {}

19
.github/workflows/format.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: test-formatting
on:
push:
jobs:
test-formatting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: check if files are formatted
# find all examples in build/examples and run them
run: |
pwd
find -name "*.cpp" -not -path "./build/*" | xargs -I {} -n 1 -P 10 clang-format {} -Werror --dry-run -style='file:.clang-format'

View File

@ -7,3 +7,4 @@ dependencies:
- pybind11
- nlohmann_json
- catch2
- zeromq

View File

@ -4,7 +4,6 @@
namespace aare {
DType::DType(const std::type_info &t) {
if (t == typeid(int8_t))
m_type = TypeIndex::INT8;
@ -29,8 +28,7 @@ DType::DType(const std::type_info &t) {
else if (t == typeid(double))
m_type = TypeIndex::DOUBLE;
else
throw std::runtime_error(
"Could not construct data type. Type not supported.");
throw std::runtime_error("Could not construct data type. Type not supported.");
}
uint8_t DType::bitdepth() const {
@ -56,7 +54,6 @@ uint8_t DType::bitdepth()const {
default:
throw std::runtime_error(LOCATION + "Could not get bitdepth. Type not supported.");
}
}
DType::DType(DType::TypeIndex ti) : m_type(ti) {}
@ -99,8 +96,7 @@ DType::DType(std::string_view sv) {
else if (sv == "f8")
m_type = TypeIndex::DOUBLE;
else
throw std::runtime_error(
"Could not construct data type. Type no supported.");
throw std::runtime_error("Could not construct data type. Type no supported.");
}
std::string DType::str() const {
@ -138,18 +134,10 @@ std::string DType::str() const {
return {};
}
bool DType::operator==(const DType &other) const noexcept {
return m_type == other.m_type;
}
bool DType::operator!=(const DType &other) const noexcept {
return !(*this == other);
}
bool DType::operator==(const DType &other) const noexcept { return m_type == other.m_type; }
bool DType::operator!=(const DType &other) const noexcept { return !(*this == other); }
bool DType::operator==(const std::type_info &t) const {
return DType(t) == *this;
}
bool DType::operator!=(const std::type_info &t) const {
return DType(t) != *this;
}
bool DType::operator==(const std::type_info &t) const { return DType(t) == *this; }
bool DType::operator!=(const std::type_info &t) const { return DType(t) != *this; }
} // namespace pl
} // namespace aare

View File

@ -1,24 +1,21 @@
#include "aare/Frame.hpp"
#include "aare/utils/logger.hpp"
#include <iostream>
#include <cassert>
#include <iostream>
namespace aare {
Frame::Frame(std::byte* bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth):
m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
Frame::Frame(std::byte *bytes, ssize_t rows, ssize_t cols, ssize_t bitdepth)
: m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
m_data = new std::byte[rows * cols * bitdepth / 8];
std::memcpy(m_data, bytes, rows * cols * bitdepth / 8);
}
Frame::Frame(ssize_t rows, ssize_t cols, ssize_t bitdepth):
m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
Frame::Frame(ssize_t rows, ssize_t cols, ssize_t bitdepth) : m_rows(rows), m_cols(cols), m_bitdepth(bitdepth) {
m_data = new std::byte[rows * cols * bitdepth / 8];
std::memset(m_data, 0, rows * cols * bitdepth / 8);
}
std::byte *Frame::get(int row, int col) {
if (row < 0 || row >= m_rows || col < 0 || col >= m_cols) {
std::cerr << "Invalid row or column index" << std::endl;
@ -27,5 +24,4 @@ std::byte* Frame::get(int row, int col) {
return m_data + (row * m_cols + col) * (m_bitdepth / 8);
}
} // namespace aare

View File

@ -1,10 +1,9 @@
#include "aare/ZmqSocket.hpp"
#include <zmq.h>
#include <fmt/core.h>
#include <zmq.h>
namespace aare {
ZmqSocket::ZmqSocket(const std::string &endpoint) : m_endpoint(endpoint) {
memset(m_header_buffer, 0, m_max_header_size);
}
@ -40,13 +39,9 @@ ZmqSocket::~ZmqSocket(){
delete[] m_header_buffer;
}
void ZmqSocket::set_zmq_hwm(int hwm){
m_zmq_hwm = hwm;
}
void ZmqSocket::set_zmq_hwm(int hwm) { m_zmq_hwm = hwm; }
void ZmqSocket::set_timeout_ms(int n){
m_timeout_ms = n;
}
void ZmqSocket::set_timeout_ms(int n) { m_timeout_ms = n; }
int ZmqSocket::receive(zmqHeader &header, std::byte *data) {

View File

@ -6,8 +6,6 @@
using aare::DType;
using aare::endian;
TEST_CASE("Construct from typeid") {
REQUIRE(DType(typeid(int)) == typeid(int));
REQUIRE(DType(typeid(int)) != typeid(double));
@ -45,7 +43,6 @@ TEST_CASE("Construct from string") {
REQUIRE(DType("f4") == typeid(float));
REQUIRE(DType("f8") == typeid(double));
}
}
TEST_CASE("Construct from string with endianess") {
@ -54,5 +51,4 @@ TEST_CASE("Construct from string with endianess"){
REQUIRE_THROWS(DType(">i4") == typeid(int32_t));
}
TEST_CASE("Convert to string") { REQUIRE(DType(typeid(int)).str() == "<i4"); }

View File

@ -15,7 +15,6 @@ TEST_CASE("Construct a frame"){
REQUIRE(frame.bitdepth() == bitdepth);
REQUIRE(frame.size() == rows * cols * bitdepth / 8);
// data should be initialized to 0
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
@ -37,7 +36,6 @@ TEST_CASE("Set a value in a 8 bit frame"){
uint8_t value = 255;
frame.set(5, 7, value);
// only the value we did set should be non-zero
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
@ -63,7 +61,6 @@ TEST_CASE("Set a value in a 64 bit frame"){
uint64_t value = 255;
frame.set(5, 7, value);
// only the value we did set should be non-zero
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
@ -78,7 +75,6 @@ TEST_CASE("Set a value in a 64 bit frame"){
}
}
TEST_CASE("Move construct a frame") {
ssize_t rows = 10;
ssize_t cols = 10;

View File

@ -1,21 +1,17 @@
#include <catch2/catch_test_macros.hpp>
#include "aare/NDArray.hpp"
#include <array>
#include <catch2/catch_test_macros.hpp>
using aare::NDArray;
using aare::NDView;
using aare::Shape;
TEST_CASE("Initial size is zero if no size is specified")
{
TEST_CASE("Initial size is zero if no size is specified") {
NDArray<double> a;
REQUIRE(a.size() == 0);
REQUIRE(a.shape() == Shape<2>{0, 0});
}
TEST_CASE("Construct from a DataSpan") {
std::vector<int> some_data(9, 42);
NDView<int, 2> view(some_data.data(), Shape<2>{3, 3});
@ -35,8 +31,6 @@ TEST_CASE("Construct from a DataSpan"){
for (int i = 0; i < image.size(); ++i) {
REQUIRE(image(i) != view(i));
}
}
TEST_CASE("1D image") {
@ -44,7 +38,6 @@ TEST_CASE("1D image"){
NDArray<short, 1> img(shape, 3);
REQUIRE(img.size() == 20);
REQUIRE(img(5) == 3);
}
TEST_CASE("Accessing a const object") {
@ -55,11 +48,9 @@ TEST_CASE("Accessing a const object"){
REQUIRE(img.shape(0) == 3);
REQUIRE(img.shape(1) == 4);
REQUIRE(img.shape(2) == 5);
}
TEST_CASE("Indexing of a 2D image")
{
TEST_CASE("Indexing of a 2D image") {
std::array<ssize_t, 2> shape{{3, 7}};
NDArray<long> img(shape, 5);
for (int i = 0; i != img.size(); ++i) {
@ -74,8 +65,7 @@ TEST_CASE("Indexing of a 2D image")
REQUIRE(img(1, 0) == 7);
}
TEST_CASE("Indexing of a 3D image")
{
TEST_CASE("Indexing of a 3D image") {
NDArray<float, 3> img{{{3, 4, 2}}, 5.0f};
for (int i = 0; i != img.size(); ++i) {
REQUIRE(img(i) == 5.0f);
@ -101,11 +91,9 @@ TEST_CASE("Divide double by int"){
for (auto it : a) {
REQUIRE(it == 1.0);
}
}
TEST_CASE("Elementwise multiplication of 3D image")
{
TEST_CASE("Elementwise multiplication of 3D image") {
std::array<ssize_t, 3> shape{3, 4, 2};
NDArray<double, 3> a{shape};
NDArray<double, 3> b{shape};
@ -121,8 +109,7 @@ TEST_CASE("Elementwise multiplication of 3D image")
REQUIRE(c(2, 3, 1) == 23 * 23);
}
TEST_CASE("Compare two images")
{
TEST_CASE("Compare two images") {
NDArray<int> a;
NDArray<int> b;
CHECK(a == b);
@ -137,8 +124,7 @@ TEST_CASE("Compare two images")
CHECK(a != b);
}
TEST_CASE("Size and shape matches")
{
TEST_CASE("Size and shape matches") {
ssize_t w = 15;
ssize_t h = 75;
std::array<ssize_t, 2> shape{w, h};
@ -147,8 +133,7 @@ TEST_CASE("Size and shape matches")
REQUIRE(a.shape() == shape);
}
TEST_CASE("Initial value matches for all elements")
{
TEST_CASE("Initial value matches for all elements") {
double v = 4.35;
NDArray<double> a{{5, 5}, v};
for (int i = 0; i < a.size(); ++i) {
@ -165,7 +150,6 @@ TEST_CASE("Data layout of 3D image, fast index last"){
*ptr++ = 10 + i;
REQUIRE(a(0, 0, i) == 10 + i);
REQUIRE(a(i) == 10 + i);
}
}
@ -182,7 +166,6 @@ TEST_CASE("Bitwise and on data"){
REQUIRE(a(0) == 300);
REQUIRE(a(1) == 300);
REQUIRE(a(2) == 384);
}
// TEST_CASE("Benchmarks")
@ -220,14 +203,12 @@ TEST_CASE("Bitwise and on data"){
// }
// }
TEST_CASE("Elementwise operatios on images")
{
TEST_CASE("Elementwise operatios on images") {
std::array<ssize_t, 2> shape{5, 5};
double a_val = 3.0;
double b_val = 8.0;
SECTION("Add two images")
{
SECTION("Add two images") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
@ -252,8 +233,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(A.data() != B.data());
REQUIRE(B.data() != C.data());
}
SECTION("Subtract two images")
{
SECTION("Subtract two images") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
auto C = A - B;
@ -277,8 +257,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(A.data() != B.data());
REQUIRE(B.data() != C.data());
}
SECTION("Multiply two images")
{
SECTION("Multiply two images") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
auto C = A * B;
@ -302,8 +281,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(A.data() != B.data());
REQUIRE(B.data() != C.data());
}
SECTION("Divide two images")
{
SECTION("Divide two images") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
auto C = A / B;
@ -328,8 +306,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(B.data() != C.data());
}
SECTION("subtract scalar")
{
SECTION("subtract scalar") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
double v = 1.0;
@ -346,8 +323,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(A(i) == a_val);
}
}
SECTION("add scalar")
{
SECTION("add scalar") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
double v = 1.0;
@ -364,8 +340,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(A(i) == a_val);
}
}
SECTION("divide with scalar")
{
SECTION("divide with scalar") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
double v = 3.7;
@ -382,8 +357,7 @@ TEST_CASE("Elementwise operatios on images")
REQUIRE(A(i) == a_val);
}
}
SECTION("multiply with scalar")
{
SECTION("multiply with scalar") {
NDArray<double> A(shape, a_val);
NDArray<double> B(shape, b_val);
double v = 3.7;

View File

@ -142,7 +142,6 @@ TEST_CASE("iterators") {
}
}
TEST_CASE("shape from vector") {
std::vector<int> vec;
for (int i = 0; i != 12; ++i) {
@ -175,7 +174,6 @@ TEST_CASE("Retrieve shape"){
NDView<int, 2> data(vec.data(), Shape<2>{3, 4});
REQUIRE(data.shape()[0] == 3);
REQUIRE(data.shape()[1] == 4);
}
TEST_CASE("compare two views") {

View File

@ -1,5 +1,5 @@
#include <catch2/catch_all.hpp>
#include "aare/ProducerConsumerQueue.hpp"
#include <catch2/catch_all.hpp>
// using arve::SimpleQueue;
TEST_CASE("push pop") {

View File

@ -1,6 +1,6 @@
#include "aare/defs.hpp"
#include <catch2/catch_test_macros.hpp>
#include <string>
#include "aare/defs.hpp"
TEST_CASE("Enum to string conversion") {
// By the way I don't think the enum string conversions should be in the defs.hpp file
// but let's use this to show a test

View File

@ -1,12 +1,11 @@
#include <aare/NDView.hpp>
#include <aare/Frame.hpp>
#include <aare/NDView.hpp>
#include <catch2/catch_test_macros.hpp>
#include <cstdint>
using aare::Frame;
using aare::NDView;
using aare::NDArray;
using aare::NDView;
TEST_CASE("Frame") {
auto data = new uint16_t[100];

View File

@ -1,6 +1,6 @@
#include "aare/utils/logger.hpp"
#include <iostream>
#include <fstream>
#include <iostream>
int main() {
aare::logger::debug(LOCATION, "hello", 1, "world", std::vector<long>{1, 2, 3, 4, 5});
@ -9,15 +9,12 @@ int main() {
aare::logger::debug(LOCATION, "NOTHING SHOULD BE PRINTED");
aare::logger::info(LOCATION, "info printed");
// writing to file
std::ofstream textfile;
textfile.open("Test.txt");
aare::logger::set_streams(textfile.rdbuf());
aare::logger::info(LOCATION, "info printed to file");
// writing with a local logger instance
aare::logger::Logger logger;
logger.set_verbosity(aare::logger::WARNING);
@ -27,7 +24,6 @@ int main() {
aare::logger::info(LOCATION, "info printed in file ##");
textfile.close();
// setting file output by path
// user doesn't have to close file
aare::logger::set_output_file("Test2.txt");

View File

@ -2,7 +2,6 @@
#include "aare/File.hpp"
#include "aare/utils/logger.hpp"
#include <iostream>
#include <iostream>
#define AARE_ROOT_DIR_VAR "PROJECT_ROOT_DIR"

View File

@ -9,7 +9,6 @@ using aare::File;
using aare::FileConfig;
using aare::Frame;
int main() {
auto path = std::filesystem::path("/tmp/test.npy");
auto dtype = aare::DType(typeid(uint32_t));
@ -25,7 +24,4 @@ int main() {
npy.write(f);
npy.write(f);
return 0;
}

View File

@ -1,7 +1,7 @@
// Your First C++ Program
#include "aare/File.hpp"
#include <iostream>
#include "aare/utils/logger.hpp"
#include <iostream>
#define AARE_ROOT_DIR_VAR "PROJECT_ROOT_DIR"
@ -21,7 +21,8 @@ int main() {
if (PROJECT_ROOT_DIR.empty()) {
throw std::runtime_error("environment variable PROJECT_ROOT_DIR is not set");
}
std::filesystem::path fpath(PROJECT_ROOT_DIR / "data" /"moench"/ "moench04_noise_200V_sto_both_100us_no_light_thresh_900_master_0.raw");
std::filesystem::path fpath(PROJECT_ROOT_DIR / "data" / "moench" /
"moench04_noise_200V_sto_both_100us_no_light_thresh_900_master_0.raw");
File file(fpath, "r");
test(file, 0);
test(file, 2);

View File

@ -1,8 +1,6 @@
#include <string>
#include <fmt/core.h>
#include "aare/ZmqSocket.hpp"
#include <fmt/core.h>
#include <string>
int main() {
std::string endpoint = "tcp://localhost:5555";
@ -12,7 +10,6 @@ int main(){
aare::zmqHeader header;
while (true) {
int rc = socket.receive(header, reinterpret_cast<std::byte *>(data));
}
delete[] data;
return 0;

View File

@ -33,4 +33,4 @@ File::File(File &&other) {
// write move assignment operator
}
} // namespace aare

View File

@ -1,8 +1,7 @@
#include "aare/FileFactory.hpp"
#include "aare/FileInterface.hpp"
#include "aare/RawFileFactory.hpp"
#include "aare/NumpyFileFactory.hpp"
#include "aare/utils/logger.hpp"
#include "aare/RawFileFactory.hpp"
#include "aare/utils/logger.hpp"
#include <iostream>
@ -27,5 +26,3 @@ FileFactory *FileFactory::get_factory(std::filesystem::path fpath) {
}
} // namespace aare

View File

@ -26,8 +26,7 @@ NumpyFile::NumpyFile(FileConfig config, header_t header) {
throw std::runtime_error(fmt::format("Could not open: {} for reading", m_fname.c_str()));
}
initial_header_len =
aare::NumpyHelpers::write_header(std::filesystem::path(m_fname.c_str()), header);
initial_header_len = aare::NumpyHelpers::write_header(std::filesystem::path(m_fname.c_str()), header);
}
void NumpyFile::write(Frame &frame) {
@ -41,8 +40,6 @@ void NumpyFile::write(Frame &frame) {
fwrite(frame.data(), frame.size(), 1, fp);
}
Frame NumpyFile::get_frame(size_t frame_number) {
Frame frame(m_header.shape[1], m_header.shape[2], m_header.dtype.bitdepth());
get_frame_into(frame_number, frame.data());
@ -97,13 +94,10 @@ NumpyFile::~NumpyFile() {
std::string header_str = ss.str();
// write header
fwrite(header_str.c_str(), header_str.size(), 1, fp);
}
if (fp != nullptr) {
fclose(fp);
}
}
@ -142,7 +136,6 @@ void NumpyFile::load_metadata(){
std::string header(header_len, '\0');
fread(header.data(), header_len, 1, fp);
// parse header
std::vector<std::string> keys{"descr", "fortran_order", "shape"};
aare::logger::debug("original header: \"header\"");
@ -171,5 +164,4 @@ void NumpyFile::load_metadata(){
m_header = {dtype, fortran_order, shape};
}
} // namespace aare

View File

@ -5,7 +5,6 @@ namespace aare {
NumpyFileFactory::NumpyFileFactory(std::filesystem::path fpath) { this->m_fpath = fpath; }
NumpyFile *NumpyFileFactory::load_file_read() {
NumpyFile *file = new NumpyFile(this->m_fpath);
return file;
@ -14,8 +13,6 @@ NumpyFile *NumpyFileFactory::load_file_read() {
NumpyFile *NumpyFileFactory::load_file_write(FileConfig config) {
NumpyFile *file = new NumpyFile(config, {config.dtype, false, {config.rows, config.cols}});
return file;
};

View File

@ -214,7 +214,6 @@ size_t write_header(std::filesystem::path fname, const header_t &header) {
return write_header(out, header);
}
size_t write_header(std::ostream &out, const header_t &header) {
std::string header_dict = write_header_dict(header.dtype.str(), header.fortran_order, header.shape);

View File

@ -62,8 +62,6 @@ void RawFile::read_into(std::byte *image_buf, size_t n_frames) {
}
}
size_t RawFile::frame_number(size_t frame_index) {
if (frame_index > this->m_total_frames) {
throw std::runtime_error(LOCATION + "Frame number out of range");

View File

@ -114,8 +114,8 @@ void RawFileFactory::open_subfiles(FileInterface *_file) {
for (size_t i = 0; i != file->n_subfiles; ++i) {
auto v = std::vector<SubFile *>(file->n_subfile_parts);
for (size_t j = 0; j != file->n_subfile_parts; ++j) {
v[j] =
new SubFile(file->data_fname(i, j), file->m_type, file->subfile_rows, file->subfile_cols, file->bitdepth());
v[j] = new SubFile(file->data_fname(i, j), file->m_type, file->subfile_rows, file->subfile_cols,
file->bitdepth());
}
file->subfiles.push_back(v);
}
@ -147,7 +147,6 @@ sls_detector_header RawFileFactory::read_header(const std::filesystem::path &fna
return h;
}
void RawFileFactory::find_geometry(FileInterface *_file) {
auto file = dynamic_cast<RawFile *>(_file);
uint16_t r{};

View File

@ -12,7 +12,8 @@ SubFile::SubFile(std::filesystem::path fname, DetectorType detector, ssize_t row
this->m_bitdepth = bitdepth;
this->n_frames = std::filesystem::file_size(fname) / (sizeof(sls_detector_header) + rows * cols * bitdepth / 8);
if (read_impl_map.find({detector, bitdepth}) == read_impl_map.end()) {
auto error_msg = LOCATION + "No read_impl function found for detector: " + toString(detector) + " and bitdepth: " + std::to_string(bitdepth);
auto error_msg = LOCATION + "No read_impl function found for detector: " + toString(detector) +
" and bitdepth: " + std::to_string(bitdepth);
throw std::runtime_error(error_msg);
}
this->read_impl = read_impl_map.at({detector, bitdepth});

View File

@ -1,11 +1,11 @@
#include <catch2/catch_test_macros.hpp>
#include "aare/NumpyFile.hpp"
#include "aare/NDArray.hpp"
#include <catch2/catch_test_macros.hpp>
#include "test_config.hpp"
using aare::NumpyFile;
using aare::DType;
using aare::NumpyFile;
TEST_CASE("Read a 1D numpy file with int32 data type") {
auto fpath = test_data_path() / "numpy" / "test_1d_int32.npy";
@ -22,7 +22,6 @@ TEST_CASE("Read a 1D numpy file with int32 data type"){
for (size_t i = 0; i < 10; i++) {
REQUIRE(data(i) == i);
}
}
TEST_CASE("Read a 3D numpy file with np.double data type") {
@ -48,6 +47,4 @@ TEST_CASE("Read a 3D numpy file with np.double data type"){
REQUIRE(data(0, 0, 1) == 2.0);
REQUIRE(data(0, 1, 0) == 72.0);
REQUIRE(data(2, 0, 4) == 63.0);
}

View File

@ -1,5 +1,5 @@
#include <catch2/catch_test_macros.hpp>
#include "aare/NumpyHelpers.hpp" //Is this really a public header?
#include <catch2/catch_test_macros.hpp>
using namespace aare::NumpyHelpers;
@ -19,9 +19,7 @@ TEST_CASE("Check for quotes and return stripped string"){
REQUIRE(parse_str("''") == "");
}
TEST_CASE("parsing a string without quotes throws"){
REQUIRE_THROWS(parse_str("hej"));
}
TEST_CASE("parsing a string without quotes throws") { REQUIRE_THROWS(parse_str("hej")); }
TEST_CASE("trim whitespace") {
REQUIRE(trim(" hej ") == "hej");

View File

@ -4,17 +4,15 @@
#include <pybind11/stl.h>
#include <string>
#include "aare/defs.hpp"
#include "aare/Frame.hpp"
#include "aare/FileHandler.hpp"
#include "aare/Frame.hpp"
#include "aare/defs.hpp"
namespace py = pybind11;
PYBIND11_MODULE(_aare, m) {
// helps to convert from std::string to std::filesystem::path
py::class_<std::filesystem::path>(m, "Path")
.def(py::init<std::string>());
py::class_<std::filesystem::path>(m, "Path").def(py::init<std::string>());
py::implicitly_convertible<std::string, std::filesystem::path>();
// TODO: find a solution to avoid code duplication and include other detectors
@ -22,7 +20,6 @@ PYBIND11_MODULE(_aare, m) {
.def(py::init<std::filesystem::path>())
.def("get_frame", &FileHandler::get_frame);
py::enum_<DetectorType>(m, "DetectorType");
py::class_<Frame>(m, "_Frame")
@ -31,14 +28,4 @@ PYBIND11_MODULE(_aare, m) {
.def_property_readonly("rows", &Frame::rows)
.def_property_readonly("cols", &Frame::cols)
.def_property_readonly("bitdepth", &Frame::bitdepth);
}