Skip to content

Small fixes to work with Mac OS. #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "CI"

on:
push:
branches:
- main

pull_request:

jobs:
checks:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.12'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Checks
uses: pre-commit/[email protected]

gcc:
runs-on: 'ubuntu-latest'
strategy:
matrix:
cxx: [g++-12, clang++]
name: ${{ matrix.cxx }}
env:
CXX: ${{ matrix.cxx }}
steps:
- uses: actions/checkout@v4
- name: CMake
run: |
sudo apt-get update
sudo apt-get install libhdf5-dev g++-12
cmake -B build
- name: Build
run: make -C build -j `nproc`
- name: Test
run: |
./build/test/gtest/binsparse-tests

macos:
runs-on: 'macos-latest'
steps:
- uses: actions/checkout@v4
- name: CMake
run: |
brew install hdf5
cmake -B build
- name: Build
run: make -C build -j
- name: Test
run: |
./build/test/gtest/binsparse-tests
5 changes: 2 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)

add_subdirectory(include)

find_package(HDF5 REQUIRED COMPONENTS CXX)
target_link_libraries(binsparse INTERFACE ${HDF5_CXX_LIBRARIES})
target_include_directories(binsparse INTERFACE . ${HDF5_INCLUDE_DIRS})
find_package(HDF5 REQUIRED COMPONENTS C CXX)
target_link_libraries(binsparse INTERFACE ${HDF5_C_LIBRARIES} hdf5::hdf5_cpp)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Dependencies needed only for examples/test
Expand Down
1 change: 1 addition & 0 deletions include/binsparse/hdf5_tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <H5Cpp.h>
#include <cassert>
#include <cstdint>
#include <ranges>
#include <type_traits>
#include <vector>
Expand Down
5 changes: 3 additions & 2 deletions include/binsparse/type_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ struct type_info<uint64_t> {
}
};

template <>
struct type_info<std::size_t> {
template <typename T>
requires std::is_same_v<T, std::size_t>
struct type_info<T> {
static constexpr auto label() noexcept {
return "uint64";
}
Expand Down
12 changes: 7 additions & 5 deletions test/gtest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ function(download_data url file_name)
${url}
${DATASET_ARCHIVE})

string(REPLACE
string(REPLACE
".tar.gz" ""
DATSET_DIR
DATASET_DIR
${DATASET_ARCHIVE})

file(ARCHIVE_EXTRACT INPUT
${DATASET_ARCHIVE}
${DATASET_DIR})
cmake_path(REMOVE_FILENAME DATASET_DIR)

file(ARCHIVE_EXTRACT INPUT ${DATASET_ARCHIVE} DESTINATION ${DATASET_DIR})

message(STATUS "Downloading file ${DATASET_ARCHIVE}, extracting to ${DATASET_DIR}.")
endfunction()

enable_testing()
Expand Down
19 changes: 10 additions & 9 deletions test/gtest/coo_test.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#include <gtest/gtest.h>

#include <fmt/core.h>

#include "util.hpp"
#include <binsparse/binsparse.hpp>

inline std::vector file_paths({"1138_bus/1138_bus.mtx",
"chesapeake/chesapeake.mtx",
"mouse_gene/mouse_gene.mtx"});
#include <filesystem>
#include <fmt/core.h>
#include <gtest/gtest.h>

TEST(BinsparseReadWrite, COOFormat) {
using T = float;
using I = std::size_t;

std::string binsparse_file = "out.bsp.hdf5";

for (auto&& file_path : file_paths) {
auto base_path = find_prefix(files.front());

for (auto&& file : files) {
auto file_path = base_path + file;
auto x = binsparse::__detail::mmread<
T, I, binsparse::__detail::coo_matrix_owning<T, I>>(file_path);

Expand Down Expand Up @@ -46,4 +45,6 @@ TEST(BinsparseReadWrite, COOFormat) {
delete matrix_.rowind;
delete matrix_.colind;
}

std::filesystem::remove(binsparse_file);
}
19 changes: 10 additions & 9 deletions test/gtest/csr_test.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#include <gtest/gtest.h>

#include <fmt/core.h>

#include "util.hpp"
#include <binsparse/binsparse.hpp>

inline std::vector file_paths({"1138_bus/1138_bus.mtx",
"chesapeake/chesapeake.mtx",
"mouse_gene/mouse_gene.mtx"});
#include <filesystem>
#include <fmt/core.h>
#include <gtest/gtest.h>

TEST(BinsparseReadWrite, CSRFormat) {
using T = float;
using I = std::size_t;

std::string binsparse_file = "out.bsp.hdf5";

for (auto&& file_path : file_paths) {
auto base_path = find_prefix(files.front());

for (auto&& file : files) {
auto file_path = base_path + file;
auto x = binsparse::__detail::mmread<
T, I, binsparse::__detail::csr_matrix_owning<T, I>>(file_path);

Expand Down Expand Up @@ -46,4 +45,6 @@ TEST(BinsparseReadWrite, CSRFormat) {
delete matrix_.row_ptr;
delete matrix_.colind;
}

std::filesystem::remove(binsparse_file);
}
19 changes: 19 additions & 0 deletions test/gtest/util.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#pragma once

#include <filesystem>
#include <string>
#include <vector>

inline std::vector<std::string> files({"data/1138_bus/1138_bus.mtx",
"data/chesapeake/chesapeake.mtx",
"data/mouse_gene/mouse_gene.mtx"});

inline std::string find_prefix(std::string file_name) {
if (std::filesystem::exists("../../" + file_name)) {
return "../../";
} else if (std::filesystem::exists("build/" + file_name)) {
return "build/";
} else {
return "";
}
}