build: fix compilation without default features (#218)
* build: fix compilation with optional features * Remove unused config from Cargo.toml * Fix cache keys Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
This commit is contained in:
@@ -23,15 +23,15 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
TZ: "/usr/share/zoneinfo/your/location"
|
TZ: "/usr/share/zoneinfo/your/location"
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Cache .cargo and target
|
- name: Cache .cargo and target
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo
|
~/.cargo
|
||||||
./target
|
./target
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
key: ${{ runner.os }}-cargo-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.toml') }}
|
||||||
restore-keys: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}
|
restore-keys: ${{ runner.os }}-cargo-${{ matrix.platform.target }}-${{ hashFiles('**/Cargo.toml') }}
|
||||||
- name: Install Rust toolchain
|
- name: Install Rust toolchain
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
@@ -56,3 +56,34 @@ jobs:
|
|||||||
- name: Tests in WASM
|
- name: Tests in WASM
|
||||||
if: matrix.platform.target == 'wasm32-unknown-unknown'
|
if: matrix.platform.target == 'wasm32-unknown-unknown'
|
||||||
run: wasm-pack test --node -- --all-features
|
run: wasm-pack test --node -- --all-features
|
||||||
|
|
||||||
|
check_features:
|
||||||
|
runs-on: "${{ matrix.platform.os }}-latest"
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
platform: [{ os: "ubuntu" }]
|
||||||
|
features: ["--features serde", "--features datasets", ""]
|
||||||
|
env:
|
||||||
|
TZ: "/usr/share/zoneinfo/your/location"
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Cache .cargo and target
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo
|
||||||
|
./target
|
||||||
|
key: ${{ runner.os }}-cargo-features-${{ hashFiles('**/Cargo.toml') }}
|
||||||
|
restore-keys: ${{ runner.os }}-cargo-features-${{ hashFiles('**/Cargo.toml') }}
|
||||||
|
- name: Install Rust toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
target: ${{ matrix.platform.target }}
|
||||||
|
profile: minimal
|
||||||
|
default: true
|
||||||
|
- name: Stable Build
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
args: --no-default-features ${{ matrix.features }}
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ bincode = "1.3.1"
|
|||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||||
wasm-bindgen-test = "0.3"
|
wasm-bindgen-test = "0.3"
|
||||||
|
|
||||||
[profile.bench]
|
|
||||||
debug = true
|
|
||||||
|
|
||||||
resolver = "2"
|
|
||||||
|
|
||||||
[profile.test]
|
[profile.test]
|
||||||
debug = 1
|
debug = 1
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use std::ops::Range;
|
|||||||
use std::slice::Iter;
|
use std::slice::Iter;
|
||||||
|
|
||||||
use approx::{AbsDiffEq, RelativeEq};
|
use approx::{AbsDiffEq, RelativeEq};
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::linalg::basic::arrays::{
|
use crate::linalg::basic::arrays::{
|
||||||
@@ -19,7 +20,8 @@ use crate::numbers::basenum::Number;
|
|||||||
use crate::numbers::realnum::RealNumber;
|
use crate::numbers::realnum::RealNumber;
|
||||||
|
|
||||||
/// Dense matrix
|
/// Dense matrix
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct DenseMatrix<T> {
|
pub struct DenseMatrix<T> {
|
||||||
ncols: usize,
|
ncols: usize,
|
||||||
nrows: usize,
|
nrows: usize,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use num_traits::{Float, Signed};
|
use num_traits::{Float, Signed};
|
||||||
|
|
||||||
use crate::numbers::basenum::Number;
|
use crate::{numbers::basenum::Number, rand_custom::get_rng_impl};
|
||||||
|
|
||||||
/// Defines float number
|
/// Defines float number
|
||||||
/// <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML"></script>
|
/// <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_CHTML"></script>
|
||||||
@@ -57,7 +57,7 @@ impl FloatNumber for f64 {
|
|||||||
|
|
||||||
fn rand() -> f64 {
|
fn rand() -> f64 {
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = get_rng_impl(None);
|
||||||
rng.gen()
|
rng.gen()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ impl FloatNumber for f32 {
|
|||||||
|
|
||||||
fn rand() -> f32 {
|
fn rand() -> f32 {
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = get_rng_impl(None);
|
||||||
rng.gen()
|
rng.gen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -52,6 +52,7 @@ impl<'a> Debug for dyn Kernel<'_> + 'a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "serde")]
|
||||||
impl<'a> Serialize for dyn Kernel<'_> + 'a {
|
impl<'a> Serialize for dyn Kernel<'_> + 'a {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
@@ -64,7 +65,8 @@ impl<'a> Serialize for dyn Kernel<'_> + 'a {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Pre-defined kernel functions
|
/// Pre-defined kernel functions
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
pub struct Kernels {}
|
pub struct Kernels {}
|
||||||
|
|
||||||
impl<'a> Kernels {
|
impl<'a> Kernels {
|
||||||
|
|||||||
+1
-1
@@ -133,7 +133,7 @@ pub struct SVCParameters<
|
|||||||
pub struct SVC<'a, TX: Number + RealNumber, TY: Number + Ord, X: Array2<TX>, Y: Array1<TY>> {
|
pub struct SVC<'a, TX: Number + RealNumber, TY: Number + Ord, X: Array2<TX>, Y: Array1<TY>> {
|
||||||
classes: Option<Vec<TY>>,
|
classes: Option<Vec<TY>>,
|
||||||
instances: Option<Vec<Vec<TX>>>,
|
instances: Option<Vec<Vec<TX>>>,
|
||||||
#[serde(skip)]
|
#[cfg_attr(feature = "serde", serde(skip))]
|
||||||
parameters: Option<&'a SVCParameters<'a, TX, TY, X, Y>>,
|
parameters: Option<&'a SVCParameters<'a, TX, TY, X, Y>>,
|
||||||
w: Option<Vec<TX>>,
|
w: Option<Vec<TX>>,
|
||||||
b: Option<TX>,
|
b: Option<TX>,
|
||||||
|
|||||||
+1
-1
@@ -92,7 +92,7 @@ pub struct SVRParameters<'a, T: Number + RealNumber> {
|
|||||||
pub c: T,
|
pub c: T,
|
||||||
/// Tolerance for stopping criterion.
|
/// Tolerance for stopping criterion.
|
||||||
pub tol: T,
|
pub tol: T,
|
||||||
#[serde(skip_deserializing)]
|
#[cfg_attr(feature = "serde", serde(skip_deserializing))]
|
||||||
/// The kernel function.
|
/// The kernel function.
|
||||||
pub kernel: Option<&'a dyn Kernel<'a>>,
|
pub kernel: Option<&'a dyn Kernel<'a>>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user