From c0625786cbc450f889d4b4e09304269f1314a180 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Tue, 29 Dec 2020 17:07:08 -0500 Subject: [PATCH 01/24] create cnpy package --- recipes/cnpy/all/CMakeLists.txt | 7 +++ recipes/cnpy/all/conandata.yml | 4 ++ recipes/cnpy/all/conanfile.py | 66 ++++++++++++++++++++ recipes/cnpy/all/test_package/CMakeLists.txt | 8 +++ recipes/cnpy/all/test_package/conanfile.py | 19 ++++++ recipes/cnpy/all/test_package/example1.cpp | 55 ++++++++++++++++ recipes/cnpy/config.yml | 3 + 7 files changed, 162 insertions(+) create mode 100644 recipes/cnpy/all/CMakeLists.txt create mode 100644 recipes/cnpy/all/conandata.yml create mode 100644 recipes/cnpy/all/conanfile.py create mode 100644 recipes/cnpy/all/test_package/CMakeLists.txt create mode 100644 recipes/cnpy/all/test_package/conanfile.py create mode 100644 recipes/cnpy/all/test_package/example1.cpp create mode 100644 recipes/cnpy/config.yml diff --git a/recipes/cnpy/all/CMakeLists.txt b/recipes/cnpy/all/CMakeLists.txt new file mode 100644 index 0000000000000..9440cfeecb17c --- /dev/null +++ b/recipes/cnpy/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory("source_subfolder") diff --git a/recipes/cnpy/all/conandata.yml b/recipes/cnpy/all/conandata.yml new file mode 100644 index 0000000000000..2d9158283d7b8 --- /dev/null +++ b/recipes/cnpy/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0": + url: "https://github.com/hongyx11/cnpy/archive/v1.0.tar.gz" + sha256: "a61b209c268db20a00240876df9fd8314a73d3c9b4139d00a0df048fe9c8e59f" diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py new file mode 100644 index 0000000000000..6395a61d31166 --- /dev/null +++ b/recipes/cnpy/all/conanfile.py @@ -0,0 +1,66 @@ +import os + +from conans import ConanFile, CMake, tools + +class CnpyConan(ConanFile): + name = "cnpy" + description = "cnpy conan package" + license = "MIT License" + topics = ("conan", "cnpy") + homepage = "https://github.com/hongyx11/cnpy" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + _cmake = None + + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename(self.name + "-" + self.version, self._source_subfolder) + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "cnpy" + self.cpp_info.names["cmake_find_package_multi"] = "cnpy" + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/cnpy/all/test_package/CMakeLists.txt b/recipes/cnpy/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..96912494bcda7 --- /dev/null +++ b/recipes/cnpy/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15.0) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() +set(CMAKE_CXX_STANDARD 11) +add_executable(${PROJECT_NAME} example1.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) diff --git a/recipes/cnpy/all/test_package/conanfile.py b/recipes/cnpy/all/test_package/conanfile.py new file mode 100644 index 0000000000000..157ce0f09876a --- /dev/null +++ b/recipes/cnpy/all/test_package/conanfile.py @@ -0,0 +1,19 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + requires = [ + "zlib/1.2.11" + ] + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp new file mode 100644 index 0000000000000..70ac5aa4e062a --- /dev/null +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -0,0 +1,55 @@ +#include"cnpy.h" +#include +#include +#include +#include +#include + +const int Nx = 128; +const int Ny = 64; +const int Nz = 32; + +int main() +{ + //set random seed so that result is reproducible (for testing) + srand(0); + //create random data + std::vector> data(Nx*Ny*Nz); + for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); + + //save it to file + cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); + + //load it into a new array + cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); + std::complex* loaded_data = arr.data>(); + + //make sure the loaded data matches the saved data + assert(arr.word_size == sizeof(std::complex)); + assert(arr.shape.size() == 3 && arr.shape[0] == Nz && arr.shape[1] == Ny && arr.shape[2] == Nx); + for(int i = 0; i < Nx*Ny*Nz;i++) assert(data[i] == loaded_data[i]); + + //append the same data to file + //npy array on file now has shape (Nz+Nz,Ny,Nx) + cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"a"); + + //now write to an npz file + //non-array variables are treated as 1D arrays with 1 element + double myVar1 = 1.2; + char myVar2 = 'a'; + cnpy::npz_save("out.npz","myVar1",&myVar1,{1},"w"); //"w" overwrites any existing file + cnpy::npz_save("out.npz","myVar2",&myVar2,{1},"a"); //"a" appends to the file we created above + cnpy::npz_save("out.npz","arr1",&data[0],{Nz,Ny,Nx},"a"); //"a" appends to the file we created above + + //load a single var from the npz file + cnpy::NpyArray arr2 = cnpy::npz_load("out.npz","arr1"); + + //load the entire npz file + cnpy::npz_t my_npz = cnpy::npz_load("out.npz"); + + //check that the loaded myVar1 matches myVar1 + cnpy::NpyArray arr_mv1 = my_npz["myVar1"]; + double* mv1 = arr_mv1.data(); + assert(arr_mv1.shape.size() == 1 && arr_mv1.shape[0] == 1); + assert(mv1[0] == myVar1); +} diff --git a/recipes/cnpy/config.yml b/recipes/cnpy/config.yml new file mode 100644 index 0000000000000..edab1ee152d36 --- /dev/null +++ b/recipes/cnpy/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0": + folder: all From 222547b77c658cafcec46cc751af0bcd111363b4 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Tue, 29 Dec 2020 17:27:38 -0500 Subject: [PATCH 02/24] change python indention --- recipes/cnpy/all/conanfile.py | 103 ++++++++++----------- recipes/cnpy/all/test_package/conanfile.py | 26 +++--- 2 files changed, 64 insertions(+), 65 deletions(-) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 6395a61d31166..2577c40333784 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -3,64 +3,63 @@ from conans import ConanFile, CMake, tools class CnpyConan(ConanFile): - name = "cnpy" - description = "cnpy conan package" - license = "MIT License" - topics = ("conan", "cnpy") - homepage = "https://github.com/hongyx11/cnpy" - url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt"] - generators = "cmake" - settings = "os", "arch", "compiler", "build_type" - _cmake = None + name = "cnpy" + description = "cnpy conan package" + license = "MIT License" + topics = ("conan", "cnpy") + homepage = "https://github.com/hongyx11/cnpy" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + _cmake = None + + options = { + "shared": [True, False], + "fPIC": [True, False] + } + default_options = { + "shared": False, + "fPIC": True + } + @property + def _source_subfolder(self): + return "source_subfolder" - options = { - "shared": [True, False], - "fPIC": [True, False] - } - default_options = { - "shared": False, - "fPIC": True - } + @property + def _build_subfolder(self): + return "build_subfolder" - @property - def _source_subfolder(self): - return "source_subfolder" + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC - @property - def _build_subfolder(self): - return "build_subfolder" + def configure(self): + del self.settings.compiler.libcxx + del self.settings.compiler.cppstd - def config_options(self): - if self.settings.os == "Windows": - del self.options.fPIC + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename(self.name + "-" + self.version, self._source_subfolder) - def configure(self): - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd + def build(self): + cmake = self._configure_cmake() + cmake.build() - def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake - def build(self): - cmake = self._configure_cmake() - cmake.build() + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() - def _configure_cmake(self): - if self._cmake: - return self._cmake - self._cmake = CMake(self) - self._cmake.configure(build_folder=self._build_subfolder) - return self._cmake - - def package(self): - self.copy("LICENSE", dst="licenses", src=self._source_subfolder) - cmake = self._configure_cmake() - cmake.install() - - def package_info(self): - self.cpp_info.names["cmake_find_package"] = "cnpy" - self.cpp_info.names["cmake_find_package_multi"] = "cnpy" - self.cpp_info.libs = tools.collect_libs(self) + def package_info(self): + self.cpp_info.names["cmake_find_package"] = "cnpy" + self.cpp_info.names["cmake_find_package_multi"] = "cnpy" + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/cnpy/all/test_package/conanfile.py b/recipes/cnpy/all/test_package/conanfile.py index 157ce0f09876a..072697b0d4b52 100644 --- a/recipes/cnpy/all/test_package/conanfile.py +++ b/recipes/cnpy/all/test_package/conanfile.py @@ -3,17 +3,17 @@ from conans import ConanFile, CMake, tools class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" - generators = "cmake" - requires = [ - "zlib/1.2.11" - ] - def build(self): - cmake = CMake(self) - cmake.configure() - cmake.build() + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + requires = [ + "zlib/1.2.11" + ] + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() - def test(self): - if not tools.cross_building(self.settings): - bin_path = os.path.join("bin", "test_package") - self.run(bin_path, run_environment=True) + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) From 5c5289ec1034b8828fc6f59c4e1fa3f8b959ddac Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:16:39 -0500 Subject: [PATCH 03/24] Update recipes/cnpy/all/test_package/CMakeLists.txt Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/test_package/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/test_package/CMakeLists.txt b/recipes/cnpy/all/test_package/CMakeLists.txt index 96912494bcda7..c1510635203e9 100644 --- a/recipes/cnpy/all/test_package/CMakeLists.txt +++ b/recipes/cnpy/all/test_package/CMakeLists.txt @@ -3,6 +3,6 @@ project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) conan_basic_setup() -set(CMAKE_CXX_STANDARD 11) add_executable(${PROJECT_NAME} example1.cpp) target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) From e50dbd9960878edbbf0c2058fa69246fea5f8f1d Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:16:56 -0500 Subject: [PATCH 04/24] Update recipes/cnpy/all/test_package/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/test_package/conanfile.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/recipes/cnpy/all/test_package/conanfile.py b/recipes/cnpy/all/test_package/conanfile.py index 072697b0d4b52..1657e07d4ce2c 100644 --- a/recipes/cnpy/all/test_package/conanfile.py +++ b/recipes/cnpy/all/test_package/conanfile.py @@ -5,9 +5,6 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake" - requires = [ - "zlib/1.2.11" - ] def build(self): cmake = CMake(self) cmake.configure() From 00a87d794729768fd5f2dde16dda3b0682e7b75a Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:20:21 -0500 Subject: [PATCH 05/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Uilian Ries --- recipes/cnpy/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 2577c40333784..1009c36ee9f9c 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -5,7 +5,7 @@ class CnpyConan(ConanFile): name = "cnpy" description = "cnpy conan package" - license = "MIT License" + license = "MIT" topics = ("conan", "cnpy") homepage = "https://github.com/hongyx11/cnpy" url = "https://github.com/conan-io/conan-center-index" From 4468aa5b77f1bbd5603e7017a67c92987f71be5f Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:20:28 -0500 Subject: [PATCH 06/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 1009c36ee9f9c..118cb184aeef8 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -4,7 +4,7 @@ class CnpyConan(ConanFile): name = "cnpy" - description = "cnpy conan package" + description = "library to read/write .npy and .npz files in C/C++" license = "MIT" topics = ("conan", "cnpy") homepage = "https://github.com/hongyx11/cnpy" From a1637d445bf88823e4ea35bee23fc7a4980637f9 Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:20:32 -0500 Subject: [PATCH 07/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 118cb184aeef8..e358c5b9028ee 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -62,4 +62,4 @@ def package(self): def package_info(self): self.cpp_info.names["cmake_find_package"] = "cnpy" self.cpp_info.names["cmake_find_package_multi"] = "cnpy" - self.cpp_info.libs = tools.collect_libs(self) + self.cpp_info.libs = ["cnpy"] From f9b830d1ad4c034377e6400d9aae8b705d1bec51 Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:20:43 -0500 Subject: [PATCH 08/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index e358c5b9028ee..b16bfa3d697df 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -39,6 +39,9 @@ def configure(self): del self.settings.compiler.libcxx del self.settings.compiler.cppstd + def requirements(self): + self.requires("zlib/1.2.11") + def source(self): tools.get(**self.conan_data["sources"][self.version]) os.rename(self.name + "-" + self.version, self._source_subfolder) From 61c962f781e4588897d43bc56c9d8b2e6c344f4d Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Wed, 30 Dec 2020 15:20:53 -0500 Subject: [PATCH 09/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index b16bfa3d697df..0d3bc69ab26a0 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -36,6 +36,8 @@ def config_options(self): del self.options.fPIC def configure(self): + if self.options.shared: + del self.options.fPIC del self.settings.compiler.libcxx del self.settings.compiler.cppstd From 06091134f82b2623d3658006b9c4a936121f3e9a Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 30 Dec 2020 18:10:07 -0300 Subject: [PATCH 10/24] Fix package version Signed-off-by: Uilian Ries --- recipes/cnpy/all/conandata.yml | 6 +++--- recipes/cnpy/all/conanfile.py | 15 +++++++++++---- recipes/cnpy/config.yml | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/recipes/cnpy/all/conandata.yml b/recipes/cnpy/all/conandata.yml index 2d9158283d7b8..de92d6f4433be 100644 --- a/recipes/cnpy/all/conandata.yml +++ b/recipes/cnpy/all/conandata.yml @@ -1,4 +1,4 @@ sources: - "1.0": - url: "https://github.com/hongyx11/cnpy/archive/v1.0.tar.gz" - sha256: "a61b209c268db20a00240876df9fd8314a73d3c9b4139d00a0df048fe9c8e59f" + "cci.20180601": + url: "https://github.com/rogersce/cnpy/archive/4e8810b1a8637695171ed346ce68f6984e585ef4.tar.gz" + sha256: "5120abc54a564efa92c642cc0199cc4fd3f345901157de9fbbdcedbb34d28d8a" diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 0d3bc69ab26a0..1f92a2dadf442 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -1,4 +1,5 @@ import os +import glob from conans import ConanFile, CMake, tools @@ -13,7 +14,7 @@ class CnpyConan(ConanFile): generators = "cmake" settings = "os", "arch", "compiler", "build_type" _cmake = None - + options = { "shared": [True, False], "fPIC": [True, False] @@ -25,7 +26,7 @@ class CnpyConan(ConanFile): @property def _source_subfolder(self): - return "source_subfolder" + return "source_subfolder" @property def _build_subfolder(self): @@ -46,7 +47,8 @@ def requirements(self): def source(self): tools.get(**self.conan_data["sources"][self.version]) - os.rename(self.name + "-" + self.version, self._source_subfolder) + extracted_dir = glob.glob(self.name + "-*")[0] + os.rename(extracted_dir, self._source_subfolder) def build(self): cmake = self._configure_cmake() @@ -54,8 +56,9 @@ def build(self): def _configure_cmake(self): if self._cmake: - return self._cmake + return self._cmake self._cmake = CMake(self) + self._cmake.definitions["ENABLE_STATIC"] = not self.options.shared self._cmake.configure(build_folder=self._build_subfolder) return self._cmake @@ -63,6 +66,10 @@ def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() + if not self.options.shared: + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so") + tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.dylib") + tools.rmdir(os.path.join(self.package_folder, "bin")) def package_info(self): self.cpp_info.names["cmake_find_package"] = "cnpy" diff --git a/recipes/cnpy/config.yml b/recipes/cnpy/config.yml index edab1ee152d36..6a02f84aa19d5 100644 --- a/recipes/cnpy/config.yml +++ b/recipes/cnpy/config.yml @@ -1,3 +1,3 @@ versions: - "1.0": + "cci.20180601": folder: all From 0cf1083a4b629b8afeecfb6a7c8a4aa65a7c0756 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 30 Dec 2020 18:45:21 -0300 Subject: [PATCH 11/24] Fix Windows build Signed-off-by: Uilian Ries --- recipes/cnpy/all/CMakeLists.txt | 2 +- recipes/cnpy/all/conandata.yml | 4 ++ recipes/cnpy/all/conanfile.py | 8 ++-- .../all/patches/0001-exclude-example.patch | 37 +++++++++++++++++++ recipes/cnpy/all/test_package/CMakeLists.txt | 2 +- 5 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 recipes/cnpy/all/patches/0001-exclude-example.patch diff --git a/recipes/cnpy/all/CMakeLists.txt b/recipes/cnpy/all/CMakeLists.txt index 9440cfeecb17c..1848ca5a77c35 100644 --- a/recipes/cnpy/all/CMakeLists.txt +++ b/recipes/cnpy/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15.0) +cmake_minimum_required(VERSION 2.8.12) project(cmake_wrapper) include(conanbuildinfo.cmake) diff --git a/recipes/cnpy/all/conandata.yml b/recipes/cnpy/all/conandata.yml index de92d6f4433be..953d832ba545b 100644 --- a/recipes/cnpy/all/conandata.yml +++ b/recipes/cnpy/all/conandata.yml @@ -2,3 +2,7 @@ sources: "cci.20180601": url: "https://github.com/rogersce/cnpy/archive/4e8810b1a8637695171ed346ce68f6984e585ef4.tar.gz" sha256: "5120abc54a564efa92c642cc0199cc4fd3f345901157de9fbbdcedbb34d28d8a" +patches: + "cci.20180601": + - patch_file: "patches/0001-exclude-example.patch" + base_path: "source_subfolder" diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 1f92a2dadf442..538e4985a2976 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -10,7 +10,7 @@ class CnpyConan(ConanFile): topics = ("conan", "cnpy") homepage = "https://github.com/hongyx11/cnpy" url = "https://github.com/conan-io/conan-center-index" - exports_sources = ["CMakeLists.txt"] + exports_sources = ["CMakeLists.txt", "patches/*"] generators = "cmake" settings = "os", "arch", "compiler", "build_type" _cmake = None @@ -51,6 +51,8 @@ def source(self): os.rename(extracted_dir, self._source_subfolder) def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -66,10 +68,6 @@ def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = self._configure_cmake() cmake.install() - if not self.options.shared: - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.so") - tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.dylib") - tools.rmdir(os.path.join(self.package_folder, "bin")) def package_info(self): self.cpp_info.names["cmake_find_package"] = "cnpy" diff --git a/recipes/cnpy/all/patches/0001-exclude-example.patch b/recipes/cnpy/all/patches/0001-exclude-example.patch new file mode 100644 index 0000000000000..f39f242261c6a --- /dev/null +++ b/recipes/cnpy/all/patches/0001-exclude-example.patch @@ -0,0 +1,37 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 9eb550f..d57c6dd 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,26 +5,17 @@ endif(COMMAND cmake_policy) + + project(CNPY) + +-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +- +-option(ENABLE_STATIC "Build static (.a) library" ON) +- + find_package(ZLIB REQUIRED) + + include_directories(${ZLIB_INCLUDE_DIRS}) + +-add_library(cnpy SHARED "cnpy.cpp") ++add_library(cnpy "cnpy.cpp") + target_link_libraries(cnpy ${ZLIB_LIBRARIES}) +-install(TARGETS "cnpy" LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) +- +-if(ENABLE_STATIC) +- add_library(cnpy-static STATIC "cnpy.cpp") +- set_target_properties(cnpy-static PROPERTIES OUTPUT_NAME "cnpy") +- install(TARGETS "cnpy-static" ARCHIVE DESTINATION lib) +-endif(ENABLE_STATIC) ++set_property(TARGET cnpy PROPERTY CXX_STANDARD 11) ++install(TARGETS "cnpy" ++ LIBRARY DESTINATION lib PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ++ ARCHIVE DESTINATION lib ++ RUNTIME DESTINATION bin) + + install(FILES "cnpy.h" DESTINATION include) +-install(FILES "mat2npz" "npy2mat" "npz2mat" DESTINATION bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) + +-add_executable(example1 example1.cpp) +-target_link_libraries(example1 cnpy) diff --git a/recipes/cnpy/all/test_package/CMakeLists.txt b/recipes/cnpy/all/test_package/CMakeLists.txt index c1510635203e9..9145952903057 100644 --- a/recipes/cnpy/all/test_package/CMakeLists.txt +++ b/recipes/cnpy/all/test_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15.0) +cmake_minimum_required(VERSION 3.1.0) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) From 41cbe90a9402f517a80c02dd025aa32ceca14e82 Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 30 Dec 2020 18:49:00 -0300 Subject: [PATCH 12/24] Export all symbols Signed-off-by: Uilian Ries --- recipes/cnpy/all/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/cnpy/all/CMakeLists.txt b/recipes/cnpy/all/CMakeLists.txt index 1848ca5a77c35..c8289efe723ba 100644 --- a/recipes/cnpy/all/CMakeLists.txt +++ b/recipes/cnpy/all/CMakeLists.txt @@ -4,4 +4,6 @@ project(cmake_wrapper) include(conanbuildinfo.cmake) conan_basic_setup() +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) + add_subdirectory("source_subfolder") From 0452853d2e76d6f2922816c9b506c7456c4cf385 Mon Sep 17 00:00:00 2001 From: bincrafters-user Date: Wed, 30 Dec 2020 21:49:53 +0000 Subject: [PATCH 13/24] cnpy: Update Conan conventions Automatically created by bincrafters-conventions 0.30.1 --- recipes/cnpy/all/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/CMakeLists.txt b/recipes/cnpy/all/CMakeLists.txt index c8289efe723ba..faa97ba1ac412 100644 --- a/recipes/cnpy/all/CMakeLists.txt +++ b/recipes/cnpy/all/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.4) project(cmake_wrapper) include(conanbuildinfo.cmake) From 10b925d171e2061c6c6b81fae52de1b2deafe3d4 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Wed, 30 Dec 2020 21:58:35 -0500 Subject: [PATCH 14/24] fix windows problem --- recipes/cnpy/all/test_package/example1.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 70ac5aa4e062a..2f1f2c12f8eee 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -5,9 +5,9 @@ #include #include -const int Nx = 128; -const int Ny = 64; -const int Nz = 32; +const size_t Nx = 128; +const size_t Ny = 64; +const size_t Nz = 32; int main() { From bc4066f72730fc258dfab633e1e09319c2c3e25d Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Thu, 31 Dec 2020 01:10:43 -0500 Subject: [PATCH 15/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Chris Mc --- recipes/cnpy/all/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index 538e4985a2976..f9b94077074c9 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -39,8 +39,6 @@ def config_options(self): def configure(self): if self.options.shared: del self.options.fPIC - del self.settings.compiler.libcxx - del self.settings.compiler.cppstd def requirements(self): self.requires("zlib/1.2.11") From 12102c0cc29ecb6312c7afa8e288e3c70fa88bd7 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Thu, 31 Dec 2020 01:47:16 -0500 Subject: [PATCH 16/24] update example test --- recipes/cnpy/all/test_package/conanfile.py | 3 +- recipes/cnpy/all/test_package/example1.cpp | 44 +++++++++++++--------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/recipes/cnpy/all/test_package/conanfile.py b/recipes/cnpy/all/test_package/conanfile.py index 1657e07d4ce2c..3a20778fb6d8a 100644 --- a/recipes/cnpy/all/test_package/conanfile.py +++ b/recipes/cnpy/all/test_package/conanfile.py @@ -9,7 +9,8 @@ def build(self): cmake = CMake(self) cmake.configure() cmake.build() - + def requirements(self): + self.requires("gtest/1.10.0") def test(self): if not tools.cross_building(self.settings): bin_path = os.path.join("bin", "test_package") diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 2f1f2c12f8eee..66a223abc2e2b 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -4,31 +4,38 @@ #include #include #include +#include const size_t Nx = 128; const size_t Ny = 64; const size_t Nz = 32; -int main() -{ - //set random seed so that result is reproducible (for testing) +class CNPYTest : public testing::Test { + protected: + std::vector> data; + void SetUp(){ srand(0); - //create random data - std::vector> data(Nx*Ny*Nz); + data = std::vector>(Nx*Ny*Nz); for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); + } +}; - //save it to file - cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); +TEST_F(CNPYTest, save){ + cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); +} - //load it into a new array - cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); - std::complex* loaded_data = arr.data>(); - - //make sure the loaded data matches the saved data - assert(arr.word_size == sizeof(std::complex)); - assert(arr.shape.size() == 3 && arr.shape[0] == Nz && arr.shape[1] == Ny && arr.shape[2] == Nx); - for(int i = 0; i < Nx*Ny*Nz;i++) assert(data[i] == loaded_data[i]); +TEST_F(CNPYTest, load){ + cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); + std::complex* loaded_data = arr.data>(); + EXPECT_EQ(arr.word_size, sizeof(std::complex)); + EXPECT_EQ(arr.shape.size(), 3); + EXPECT_EQ(arr.shape[0], Nz); + EXPECT_EQ(arr.shape[1], Ny); + EXPECT_EQ(arr.shape[2], Nx); + for(int i = 0; i < Nx*Ny*Nz;i++) EXPECT_EQ(data[i],loaded_data[i]); +} +TEST_F(CNPYTest, append){ //append the same data to file //npy array on file now has shape (Nz+Nz,Ny,Nx) cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"a"); @@ -50,6 +57,7 @@ int main() //check that the loaded myVar1 matches myVar1 cnpy::NpyArray arr_mv1 = my_npz["myVar1"]; double* mv1 = arr_mv1.data(); - assert(arr_mv1.shape.size() == 1 && arr_mv1.shape[0] == 1); - assert(mv1[0] == myVar1); -} + EXPECT_EQ(arr_mv1.shape.size(),1); + EXPECT_EQ(arr_mv1.shape[0], 1); + EXPECT_EQ(mv1[0], myVar1); +} \ No newline at end of file From c4bfc6d1a0573ad4f6bfe5a49b29472fc8e570e1 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Thu, 31 Dec 2020 01:49:41 -0500 Subject: [PATCH 17/24] add new line --- recipes/cnpy/all/test_package/example1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 66a223abc2e2b..7cbda91d8c256 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -60,4 +60,4 @@ TEST_F(CNPYTest, append){ EXPECT_EQ(arr_mv1.shape.size(),1); EXPECT_EQ(arr_mv1.shape[0], 1); EXPECT_EQ(mv1[0], myVar1); -} \ No newline at end of file +} From 61950319729c03647c8e5472e85ea7e943b63610 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Thu, 31 Dec 2020 04:41:29 -0500 Subject: [PATCH 18/24] update remove exampletest --- recipes/cnpy/all/test_package/example1.cpp | 112 +++++++++++---------- 1 file changed, 58 insertions(+), 54 deletions(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 7cbda91d8c256..09aac286b40f8 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -6,58 +6,62 @@ #include #include -const size_t Nx = 128; -const size_t Ny = 64; -const size_t Nz = 32; - -class CNPYTest : public testing::Test { - protected: - std::vector> data; - void SetUp(){ - srand(0); - data = std::vector>(Nx*Ny*Nz); - for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); - } -}; - -TEST_F(CNPYTest, save){ - cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); -} - -TEST_F(CNPYTest, load){ - cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); - std::complex* loaded_data = arr.data>(); - EXPECT_EQ(arr.word_size, sizeof(std::complex)); - EXPECT_EQ(arr.shape.size(), 3); - EXPECT_EQ(arr.shape[0], Nz); - EXPECT_EQ(arr.shape[1], Ny); - EXPECT_EQ(arr.shape[2], Nx); - for(int i = 0; i < Nx*Ny*Nz;i++) EXPECT_EQ(data[i],loaded_data[i]); -} - -TEST_F(CNPYTest, append){ - //append the same data to file - //npy array on file now has shape (Nz+Nz,Ny,Nx) - cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"a"); - - //now write to an npz file - //non-array variables are treated as 1D arrays with 1 element - double myVar1 = 1.2; - char myVar2 = 'a'; - cnpy::npz_save("out.npz","myVar1",&myVar1,{1},"w"); //"w" overwrites any existing file - cnpy::npz_save("out.npz","myVar2",&myVar2,{1},"a"); //"a" appends to the file we created above - cnpy::npz_save("out.npz","arr1",&data[0],{Nz,Ny,Nx},"a"); //"a" appends to the file we created above - - //load a single var from the npz file - cnpy::NpyArray arr2 = cnpy::npz_load("out.npz","arr1"); - - //load the entire npz file - cnpy::npz_t my_npz = cnpy::npz_load("out.npz"); +// const size_t Nx = 128; +// const size_t Ny = 64; +// const size_t Nz = 32; + +// class CNPYTest : public testing::Test { +// protected: +// std::vector> data; +// void SetUp(){ +// srand(0); +// data = std::vector>(Nx*Ny*Nz); +// for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); +// } +// }; + +// TEST_F(CNPYTest, save){ +// cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); +// } + +// TEST_F(CNPYTest, load){ +// cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); +// std::complex* loaded_data = arr.data>(); +// EXPECT_EQ(arr.word_size, sizeof(std::complex)); +// EXPECT_EQ(arr.shape.size(), 3); +// EXPECT_EQ(arr.shape[0], Nz); +// EXPECT_EQ(arr.shape[1], Ny); +// EXPECT_EQ(arr.shape[2], Nx); +// for(int i = 0; i < Nx*Ny*Nz;i++) EXPECT_EQ(data[i],loaded_data[i]); +// } + +// TEST_F(CNPYTest, append){ +// //append the same data to file +// //npy array on file now has shape (Nz+Nz,Ny,Nx) +// cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"a"); + +// //now write to an npz file +// //non-array variables are treated as 1D arrays with 1 element +// double myVar1 = 1.2; +// char myVar2 = 'a'; +// cnpy::npz_save("out.npz","myVar1",&myVar1,{1},"w"); //"w" overwrites any existing file +// cnpy::npz_save("out.npz","myVar2",&myVar2,{1},"a"); //"a" appends to the file we created above +// cnpy::npz_save("out.npz","arr1",&data[0],{Nz,Ny,Nx},"a"); //"a" appends to the file we created above + +// //load a single var from the npz file +// cnpy::NpyArray arr2 = cnpy::npz_load("out.npz","arr1"); + +// //load the entire npz file +// cnpy::npz_t my_npz = cnpy::npz_load("out.npz"); - //check that the loaded myVar1 matches myVar1 - cnpy::NpyArray arr_mv1 = my_npz["myVar1"]; - double* mv1 = arr_mv1.data(); - EXPECT_EQ(arr_mv1.shape.size(),1); - EXPECT_EQ(arr_mv1.shape[0], 1); - EXPECT_EQ(mv1[0], myVar1); -} +// //check that the loaded myVar1 matches myVar1 +// cnpy::NpyArray arr_mv1 = my_npz["myVar1"]; +// double* mv1 = arr_mv1.data(); +// EXPECT_EQ(arr_mv1.shape.size(),1); +// EXPECT_EQ(arr_mv1.shape[0], 1); +// EXPECT_EQ(mv1[0], myVar1); +// } + +int main(){ + return 0; +} \ No newline at end of file From ff5f7319bf621038ebbe068ddc8ac31bf5625864 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Thu, 31 Dec 2020 05:27:25 -0500 Subject: [PATCH 19/24] update remove exampletest --- recipes/cnpy/all/test_package/example1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 09aac286b40f8..56900dc8290e2 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -64,4 +64,4 @@ int main(){ return 0; -} \ No newline at end of file +} From 213b1f481715e97013b50a86af242d6c45fcc9de Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Thu, 31 Dec 2020 11:12:37 -0500 Subject: [PATCH 20/24] Update recipes/cnpy/all/test_package/conanfile.py Co-authored-by: Uilian Ries --- recipes/cnpy/all/test_package/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cnpy/all/test_package/conanfile.py b/recipes/cnpy/all/test_package/conanfile.py index 3a20778fb6d8a..ea57a464900be 100644 --- a/recipes/cnpy/all/test_package/conanfile.py +++ b/recipes/cnpy/all/test_package/conanfile.py @@ -5,12 +5,12 @@ class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" generators = "cmake" + def build(self): cmake = CMake(self) cmake.configure() cmake.build() - def requirements(self): - self.requires("gtest/1.10.0") + def test(self): if not tools.cross_building(self.settings): bin_path = os.path.join("bin", "test_package") From 33a0c0e84f1c4d454f1243a7219d13b04d9af2fb Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Thu, 31 Dec 2020 11:12:54 -0500 Subject: [PATCH 21/24] Update recipes/cnpy/all/test_package/example1.cpp Co-authored-by: Uilian Ries --- recipes/cnpy/all/test_package/example1.cpp | 73 ++++------------------ 1 file changed, 13 insertions(+), 60 deletions(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 56900dc8290e2..725b235ebc7be 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -1,67 +1,20 @@ -#include"cnpy.h" +#include +#include #include -#include -#include -#include -#include -#include - -// const size_t Nx = 128; -// const size_t Ny = 64; -// const size_t Nz = 32; - -// class CNPYTest : public testing::Test { -// protected: -// std::vector> data; -// void SetUp(){ -// srand(0); -// data = std::vector>(Nx*Ny*Nz); -// for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); -// } -// }; -// TEST_F(CNPYTest, save){ -// cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); -// } - -// TEST_F(CNPYTest, load){ -// cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); -// std::complex* loaded_data = arr.data>(); -// EXPECT_EQ(arr.word_size, sizeof(std::complex)); -// EXPECT_EQ(arr.shape.size(), 3); -// EXPECT_EQ(arr.shape[0], Nz); -// EXPECT_EQ(arr.shape[1], Ny); -// EXPECT_EQ(arr.shape[2], Nx); -// for(int i = 0; i < Nx*Ny*Nz;i++) EXPECT_EQ(data[i],loaded_data[i]); -// } - -// TEST_F(CNPYTest, append){ -// //append the same data to file -// //npy array on file now has shape (Nz+Nz,Ny,Nx) -// cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"a"); +#include"cnpy.h" -// //now write to an npz file -// //non-array variables are treated as 1D arrays with 1 element -// double myVar1 = 1.2; -// char myVar2 = 'a'; -// cnpy::npz_save("out.npz","myVar1",&myVar1,{1},"w"); //"w" overwrites any existing file -// cnpy::npz_save("out.npz","myVar2",&myVar2,{1},"a"); //"a" appends to the file we created above -// cnpy::npz_save("out.npz","arr1",&data[0],{Nz,Ny,Nx},"a"); //"a" appends to the file we created above +int main() { + const int Nx = 128; + const int Ny = 64; + const int Nz = 32; -// //load a single var from the npz file -// cnpy::NpyArray arr2 = cnpy::npz_load("out.npz","arr1"); + std::vector> data(Nx*Ny*Nz); + for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); -// //load the entire npz file -// cnpy::npz_t my_npz = cnpy::npz_load("out.npz"); - -// //check that the loaded myVar1 matches myVar1 -// cnpy::NpyArray arr_mv1 = my_npz["myVar1"]; -// double* mv1 = arr_mv1.data(); -// EXPECT_EQ(arr_mv1.shape.size(),1); -// EXPECT_EQ(arr_mv1.shape[0], 1); -// EXPECT_EQ(mv1[0], myVar1); -// } + cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); + cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); + std::complex* loaded_data = arr.data>(); -int main(){ - return 0; + return EXIT_SUCCESS; } From 45041425b05d93e26c29ba4e524a5a1ea4c98923 Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Thu, 31 Dec 2020 16:14:03 -0500 Subject: [PATCH 22/24] windows --- recipes/cnpy/all/test_package/example1.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index 725b235ebc7be..f4dafb6298173 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -1,20 +1,15 @@ #include #include -#include - #include"cnpy.h" int main() { - const int Nx = 128; - const int Ny = 64; - const int Nz = 32; - - std::vector> data(Nx*Ny*Nz); - for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = std::complex(rand(),rand()); + const size_t Nx = 16; + const size_t Ny = 16; + const size_t Nz = 16; + std::vector data(Nx*Ny*Nz); + for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = rand(); cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); - std::complex* loaded_data = arr.data>(); - return EXIT_SUCCESS; } From 7159ae8a915f5f253fee25a9e09dd87dd101226b Mon Sep 17 00:00:00 2001 From: "yuxi.hong" Date: Thu, 31 Dec 2020 17:00:16 -0500 Subject: [PATCH 23/24] update --- recipes/cnpy/all/test_package/example1.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/test_package/example1.cpp b/recipes/cnpy/all/test_package/example1.cpp index f4dafb6298173..99a4af4d04a9a 100644 --- a/recipes/cnpy/all/test_package/example1.cpp +++ b/recipes/cnpy/all/test_package/example1.cpp @@ -11,5 +11,5 @@ int main() { for(int i = 0;i < Nx*Ny*Nz;i++) data[i] = rand(); cnpy::npy_save("arr1.npy",&data[0],{Nz,Ny,Nx},"w"); cnpy::NpyArray arr = cnpy::npy_load("arr1.npy"); - return EXIT_SUCCESS; + return 0; } From d5d8896abebb702bcf6ed31794d75523269906a7 Mon Sep 17 00:00:00 2001 From: Yuxi Hong Date: Fri, 1 Jan 2021 03:50:55 +0000 Subject: [PATCH 24/24] Update recipes/cnpy/all/conanfile.py Co-authored-by: Anonymous Maarten --- recipes/cnpy/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cnpy/all/conanfile.py b/recipes/cnpy/all/conanfile.py index f9b94077074c9..794d778b22da5 100644 --- a/recipes/cnpy/all/conanfile.py +++ b/recipes/cnpy/all/conanfile.py @@ -11,7 +11,7 @@ class CnpyConan(ConanFile): homepage = "https://github.com/hongyx11/cnpy" url = "https://github.com/conan-io/conan-center-index" exports_sources = ["CMakeLists.txt", "patches/*"] - generators = "cmake" + generators = "cmake", "cmake_find_package" settings = "os", "arch", "compiler", "build_type" _cmake = None