Skip to content

Commit

Permalink
libpressio version 0.31.0
Browse files Browse the repository at this point in the history
Major Changes

+ `pressio_dtype_from_type` api made public

Bug Fix

+ Added documentation to printer functions
  • Loading branch information
robertu94 committed Jan 28, 2020
1 parent ca6ff12 commit 3b69137
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(libpressio VERSION "0.30.1" LANGUAGES CXX C)
project(libpressio VERSION "0.31.0" LANGUAGES CXX C)

#correct was to set a default build type
# https://blog.kitware.com/cmake-and-the-default-build-type/
Expand Down
2 changes: 1 addition & 1 deletion COPYRIGHT.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Copyright © 2020 , UChicago Argonne, LLC
All Rights Reserved
[libpressio, Version 0.30.1]
[libpressio, Version 0.31.0]
Robert Underwood
Argonne National Laboratory

Expand Down
24 changes: 24 additions & 0 deletions include/libpressio_ext/cpp/dtype.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <pressio_dtype.h>

/**
* Convert types to pressio_dtypes
*
* \tparam T the type to identify
* \returns which pressio_dtype corresponds to the type T.
*/
template <class T>
constexpr pressio_dtype pressio_dtype_from_type() {
return (std::is_same<T, double>::value ? pressio_double_dtype :
std::is_same<T, float>::value ? pressio_float_dtype :
std::is_same<T, int64_t>::value ? pressio_int64_dtype :
std::is_same<T, int32_t>::value ? pressio_int32_dtype :
std::is_same<T, int16_t>::value ? pressio_int16_dtype :
std::is_same<T, int8_t>::value ? pressio_int8_dtype :
std::is_same<T, uint64_t>::value ? pressio_uint64_dtype :
std::is_same<T, uint32_t>::value ? pressio_uint32_dtype :
std::is_same<T, uint16_t>::value ? pressio_uint16_dtype :
std::is_same<T, uint8_t>::value ? pressio_uint8_dtype :
pressio_byte_dtype
);
}

5 changes: 5 additions & 0 deletions include/libpressio_ext/cpp/printers.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
* \brief C++ stream compatible IO functions
* */

/**
* human readable debugging IO function for pressio_data, the format is unspecified
* \param[in] out the output stream to print to
* \param[in] data the data struct to print
*/
template <class CharT = char, class Traits = std::char_traits<CharT>>
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& out, pressio_data const& data) {
Expand Down
19 changes: 2 additions & 17 deletions swig/pypressio.h
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
#include "pressio_data.h"
#include "libpressio_ext/cpp/dtype.h"
#include "libpressio_ext/cpp/data.h"
#include <vector>
#include <cstdint>
#include <algorithm>

namespace {
template <class T>
constexpr pressio_dtype type_to_dtype() {
return (std::is_same<T, double>::value ? pressio_double_dtype :
std::is_same<T, float>::value ? pressio_float_dtype :
std::is_same<T, int64_t>::value ? pressio_int64_dtype :
std::is_same<T, int32_t>::value ? pressio_int32_dtype :
std::is_same<T, int16_t>::value ? pressio_int16_dtype :
std::is_same<T, int8_t>::value ? pressio_int8_dtype :
std::is_same<T, uint64_t>::value ? pressio_uint64_dtype :
std::is_same<T, uint32_t>::value ? pressio_uint32_dtype :
std::is_same<T, uint16_t>::value ? pressio_uint16_dtype :
std::is_same<T, uint8_t>::value ? pressio_uint8_dtype :
pressio_byte_dtype
);
}

template <class T>
pressio_data*
_pressio_io_data_from_numpy_impl(T* data, std::vector<size_t> dims) {
return pressio_data_new_copy(
type_to_dtype<T>(),
pressio_dtype_from_type<T>(),
data,
dims.size(),
dims.data()
Expand Down

0 comments on commit 3b69137

Please sign in to comment.