Skip to content

Commit

Permalink
Remove feature gate for serde (SpectralSequences#141)
Browse files Browse the repository at this point in the history
* Remove `serde_json` gates

* Adjust `web_ext`
  • Loading branch information
JoeyBF authored Nov 27, 2023
1 parent 8075e0a commit aa6b8fe
Show file tree
Hide file tree
Showing 19 changed files with 20 additions and 55 deletions.
4 changes: 1 addition & 3 deletions ext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ license = "(MIT OR Apache-2.0)"
resolver = "2"

[dependencies]
algebra = { path = "crates/algebra", default-features = false, features = [
"json",
] }
algebra = { path = "crates/algebra", default-features = false }
bivec = { path = "crates/bivec" }
chart = { path = "crates/chart" }
fp = { path = "crates/fp", default-features = false }
Expand Down
7 changes: 3 additions & 4 deletions ext/crates/algebra/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ itertools = { version = "0.10.0", default-features = false, features = [
] }
nom = { version = "7.0.0", default-features = false, features = ["alloc"] }
rustc-hash = "1.1.0"
serde = { version = "1.0.0", features = ["derive"], optional = true }
serde_json = { version = "1.0.0", optional = true }
serde = { version = "1.0.0", features = ["derive"] }
serde_json = "1.0.0"

[dev-dependencies]
bencher = "0.1.5"
expect-test = "1.1.0"
rstest = "0.17.0"

[features]
default = ["odd-primes", "json"]
default = ["odd-primes"]
cache-multiplication = []
concurrent = ["fp/concurrent", "maybe-rayon/concurrent"]
json = ["serde", "serde_json", "bivec/json", "fp/json"]
odd-primes = ["fp/odd-primes"]

[[bench]]
Expand Down
9 changes: 3 additions & 6 deletions ext/crates/algebra/src/algebra/milnor_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use fp::prime::{factor_pk, integer_power, Binomial, BitflagIterator, ValidPrime}
use fp::vector::{FpVector, Slice, SliceMut};
use once::OnceVec;

#[cfg(feature = "json")]
use {serde::Deserialize, serde::Serialize};

// This is here so that the Python bindings can use modules defined for AdemAlgebraT with their own algebra enum.
Expand All @@ -24,22 +23,20 @@ impl MilnorAlgebraT for MilnorAlgebra {
}
}

#[cfg(feature = "json")]
fn q_part_default() -> u32 {
!0
}

#[cfg_attr(feature = "json", derive(Deserialize, Serialize))]
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct MilnorProfile {
/// If `true`, unspecified p_part entries will be 0. Otherwise they will be infinity.
pub truncated: bool,
/// A bitmask indicating which of the Q_k we want to include (1 = include). Defaults to `!0`.
/// This is only relevant at odd primes.
#[cfg_attr(feature = "json", serde(default = "q_part_default"))]
#[serde(default = "q_part_default")]
pub q_part: u32,
/// The profile function for the Q part.
#[cfg_attr(feature = "json", serde(default))]
#[serde(default)]
pub p_part: PPart,
}

Expand Down
3 changes: 0 additions & 3 deletions ext/crates/algebra/src/algebra/steenrod_algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use anyhow::anyhow;

use std::io::{Read, Write};

#[cfg(feature = "json")]
use {serde::Deserialize, serde_json::Value};

// This is here so that the Python bindings can use modules defined aor SteenrodAlgebraT with their own algebra enum.
Expand Down Expand Up @@ -144,15 +143,13 @@ impl Bialgebra for SteenrodAlgebra {
}
}

#[cfg(feature = "json")]
#[derive(Deserialize, Debug)]
struct AlgebraSpec {
p: ValidPrime,
algebra: Option<Vec<String>>,
profile: Option<crate::algebra::milnor_algebra::MilnorProfile>,
}

#[cfg(feature = "json")]
impl SteenrodAlgebra {
pub fn from_json(
json: &Value,
Expand Down
1 change: 0 additions & 1 deletion ext/crates/algebra/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ mod algebra;

pub use crate::algebra::*;

#[cfg(feature = "json")]
pub(crate) fn module_gens_from_json(
gens: &serde_json::Value,
) -> (
Expand Down
2 changes: 0 additions & 2 deletions ext/crates/algebra/src/module/finite_dimensional_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use fp::vector::{FpVector, SliceMut};
use std::fmt::Write as _;
use std::sync::Arc;

#[cfg(feature = "json")]
use {
crate::algebra::GeneratedAlgebra,
crate::module::ModuleFailedRelationError,
Expand Down Expand Up @@ -450,7 +449,6 @@ impl<M: Module> From<&M> for FiniteDimensionalModule<M::Algebra> {
}
}

#[cfg(feature = "json")]
impl<A: GeneratedAlgebra> FiniteDimensionalModule<A> {
pub fn from_json(algebra: Arc<A>, json: &Value) -> anyhow::Result<Self> {
let (graded_dimension, gen_names, gen_to_idx) = crate::module_gens_from_json(&json["gens"]);
Expand Down
2 changes: 0 additions & 2 deletions ext/crates/algebra/src/module/finitely_presented_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::module::{FreeModule, Module, ZeroModule};
use fp::vector::{FpVector, SliceMut};
use once::OnceBiVec;

#[cfg(feature = "json")]
use {itertools::Itertools, serde_json::Value};

struct FPMIndexTable {
Expand Down Expand Up @@ -95,7 +94,6 @@ impl<A: Algebra> FinitelyPresentedModule<A> {
}
}

#[cfg(feature = "json")]
impl<A: Algebra> FinitelyPresentedModule<A> {
pub fn from_json(algebra: Arc<A>, json: &Value) -> anyhow::Result<Self> {
use crate::steenrod_parser::digits;
Expand Down
3 changes: 0 additions & 3 deletions ext/crates/algebra/src/module/rpn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use fp::vector::SliceMut;

use std::sync::Arc;

#[cfg(feature = "json")]
use {serde::Deserialize, serde_json::Value};

/// This is $\mathbb{RP}_{\mathrm{min}}^{\mathrm{max}}$. The cohomology is the subquotient of
Expand Down Expand Up @@ -203,15 +202,13 @@ where
}
}

#[cfg(feature = "json")]
#[derive(Deserialize, Debug)]
struct RPSpec {
min: i32,
clear_bottom: Option<bool>,
max: Option<i32>,
}

#[cfg(feature = "json")]
impl<A: Algebra> RealProjectiveSpace<A> {
pub fn from_json(algebra: Arc<A>, json: &Value) -> anyhow::Result<Self> {
let spec: RPSpec = RPSpec::deserialize(json)?;
Expand Down
2 changes: 0 additions & 2 deletions ext/crates/algebra/src/module/steenrod_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::algebra::SteenrodAlgebra;

pub type SteenrodModule = Box<dyn Module<Algebra = SteenrodAlgebra>>;

#[cfg(feature = "json")]
mod json {
use super::*;

Expand Down Expand Up @@ -42,7 +41,6 @@ mod json {
}
}

#[cfg(feature = "json")]
pub use json::*;

use super::Module;
3 changes: 1 addition & 2 deletions ext/crates/bivec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ authors = [
edition = "2021"

[dependencies]
serde = { version = "1.0.0", optional = true }
serde = "1.0.0"

[features]
json = ["serde"]
4 changes: 1 addition & 3 deletions ext/crates/bivec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::ops::Index;
use core::ops::IndexMut;
#[cfg(feature = "json")]

use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::slice::{Iter, IterMut};
Expand Down Expand Up @@ -245,7 +245,6 @@ impl<A> std::iter::Extend<A> for BiVec<A> {
}
}

#[cfg(feature = "json")]
impl<T: Serialize> Serialize for BiVec<T> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -255,7 +254,6 @@ impl<T: Serialize> Serialize for BiVec<T> {
}
}

#[cfg(feature = "json")]
impl<'de, T: Deserialize<'de>> Deserialize<'de> for BiVec<T> {
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
where
Expand Down
5 changes: 2 additions & 3 deletions ext/crates/fp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ build_const = "0.2.2"
byteorder = "1.4.3"
cfg-if = "1.0.0"
itertools = { version = "0.10.0", default-features = false }
serde = { version = "1.0.0", optional = true }
serde_json = { version = "1.0.0", optional = true }
serde = "1.0.0"
serde_json = "1.0.0"

maybe-rayon = { path = "../maybe-rayon" }

Expand All @@ -29,7 +29,6 @@ build_const = "0.2.2"
[features]
default = ["odd-primes"]
concurrent = ["maybe-rayon/concurrent"]
json = ["serde_json", "serde"]
odd-primes = []

[[bench]]
Expand Down
3 changes: 0 additions & 3 deletions ext/crates/fp/src/prime.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "json")]
use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use std::convert::TryFrom;

Expand Down Expand Up @@ -113,7 +112,6 @@ impl std::fmt::Display for ValidPrime {
}
}

#[cfg(feature = "json")]
impl Serialize for ValidPrime {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -123,7 +121,6 @@ impl Serialize for ValidPrime {
}
}

#[cfg(feature = "json")]
impl<'de> Deserialize<'de> for ValidPrime {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
Expand Down
4 changes: 1 addition & 3 deletions ext/crates/fp/src/vector/vector_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::{Read, Write};
use std::mem::size_of;

use itertools::Itertools;
#[cfg(feature = "json")]

use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::limb::{entries_per_limb_const, Limb};
Expand Down Expand Up @@ -113,7 +113,6 @@ impl<'a> IntoIterator for &'a FpVector {
}
}

#[cfg(feature = "json")]
impl Serialize for FpVector {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -123,7 +122,6 @@ impl Serialize for FpVector {
}
}

#[cfg(feature = "json")]
impl<'de> Deserialize<'de> for FpVector {
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
where
Expand Down
4 changes: 1 addition & 3 deletions ext/crates/fp/src/vector/vector_generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::io::{Read, Write};
use std::mem::size_of;

use itertools::Itertools;
#[cfg(feature = "json")]

use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::limb::{entries_per_limb, Limb};
Expand Down Expand Up @@ -428,7 +428,6 @@ impl_try_into!(_3, 3);
impl_try_into!(_5, 5);
impl_try_into!(_7, 7);

#[cfg(feature = "json")]
impl Serialize for FpVector {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
Expand All @@ -438,7 +437,6 @@ impl Serialize for FpVector {
}
}

#[cfg(feature = "json")]
impl<'de> Deserialize<'de> for FpVector {
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
where
Expand Down
5 changes: 2 additions & 3 deletions ext/crates/sseq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fp = { path = "../fp/", default-features = false }
maybe-rayon = { path = "../maybe-rayon" }
once = { path = "../once/" }

serde = { version = "1.0.0", optional = true }
serde_json = { version = "1.0.0", optional = true }
serde = "1.0.0"
serde_json = "1.0.0"

[dev-dependencies]
expect-test = "1.1.0"
Expand All @@ -23,5 +23,4 @@ rand = "0.8"
[features]
default = ["odd-primes"]
concurrent = ["maybe-rayon/concurrent"]
json = ["serde_json", "serde"]
odd-primes = ["fp/odd-primes"]
4 changes: 1 addition & 3 deletions ext/crates/sseq/src/coordinates/bidegree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ use std::{
ops::{Add, Sub},
};

#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};

/// Type synonym for (s, t) bidegrees.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Bidegree {
/// Homological degree
s: u32,
Expand Down
4 changes: 1 addition & 3 deletions ext/crates/sseq/src/coordinates/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ use super::{Bidegree, BidegreeElement};

use std::fmt::{self, Display, Formatter};

#[cfg(feature = "json")]
use serde::{Deserialize, Serialize};

/// A *basis* element of a bigraded vector space. Most commonly used to index elements of spectral
/// sequences.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "json", derive(Serialize, Deserialize))]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct BidegreeGenerator {
/// Bidegree of the element
degree: Bidegree,
Expand Down
6 changes: 3 additions & 3 deletions web_ext/sseq_gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ edition = "2021"

[dependencies]
algebra = { path = "../../ext/crates/algebra", default-features = false }
bivec = { path = "../../ext/crates/bivec", features = ["json"] }
bivec = { path = "../../ext/crates/bivec" }
ext = { path = "../../ext", default-features = false }
fp = { path = "../../ext/crates/fp", features = ["json"], default-features = false }
fp = { path = "../../ext/crates/fp", default-features = false }
once = { path = "../../ext/crates/once" }
sseq = { path = "../../ext/crates/sseq", features = ["json"], default-features = false }
sseq = { path = "../../ext/crates/sseq", default-features = false }

anyhow = "1.0.0"
enum_dispatch = "0.3"
Expand Down

0 comments on commit aa6b8fe

Please sign in to comment.