Skip to content

Commit 8de9145

Browse files
committed
rename stuff
1 parent da7224c commit 8de9145

5 files changed

Lines changed: 63 additions & 55 deletions

File tree

.cargo/config.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
[unstable]
2-
build-std = ["std", "panic_abort"]
3-
rustflags = ["-Zunstable-options", "-Cpanic=immediate-abort"]
2+
build-std = ["std"]

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
cargo-features = ["panic-immediate-abort"]
12
[package]
23
name = "kalc-plot"
34
version = "0.1.2"
@@ -11,7 +12,7 @@ homepage = "https://github.com/bgkillas/kalc-plot"
1112
[profile.release]
1213
lto = true
1314
strip = true
14-
panic = "abort"
15+
panic = "immediate-abort"
1516
split-debuginfo = "packed"
1617
incremental=true
1718
codegen-units=1
@@ -70,4 +71,4 @@ wasm-bindgen = {version="0.2.108",optional = true}
7071
console_error_panic_hook = { version = "0.1.7", optional = true }
7172
wee_alloc = {version = "0.4.5", optional = true}
7273
lz4_flex = {version="0.12.0", default-features = false, optional = true}
73-
base64 = {version="0.22.1", optional = true}
74+
base64 = {version="0.22.1", optional = true}

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "nightly"

src/data.rs

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use rayon::iter::IndexedParallelIterator;
2727
use rayon::iter::IntoParallelIterator;
2828
#[cfg(feature = "rayon")]
2929
use rayon::iter::ParallelIterator;
30-
use rupl::types::{Bound, Complex, Graph, GraphType, Prec};
30+
use rupl::types::{Bound, Complex, Graph, GraphData, Prec};
3131
#[cfg(feature = "bincode")]
3232
use serde::{Deserialize, Serialize};
3333
#[cfg(not(feature = "kalc-lib"))]
@@ -202,7 +202,7 @@ impl Data {
202202
})
203203
.next();
204204
let apply_names =
205-
|data: &[GraphType], complex: bool, plot: &mut Graph, k: Option<usize>| {
205+
|data: &[GraphData], complex: bool, plot: &mut Graph, k: Option<usize>| {
206206
if let Some(names) = names {
207207
let names = get_names(data, names);
208208
if let Some(k) = k {
@@ -376,12 +376,12 @@ impl Data {
376376
lenx: usize,
377377
leny: usize,
378378
n: Option<usize>,
379-
buffer: &mut Vec<GraphType>,
379+
buffer: &mut Vec<GraphData>,
380380
) -> bool {
381381
let len = if n.is_some() { 1 } else { self.data.len() };
382382
if len > buffer.len() {
383383
for _ in 0..len - buffer.len() {
384-
buffer.push(GraphType::None)
384+
buffer.push(GraphData::None)
385385
}
386386
}
387387
buffer.into_par_iter().enumerate().any(|(mut i, b)| {
@@ -418,16 +418,22 @@ impl Data {
418418
endy: f64,
419419
lenx: usize,
420420
leny: usize,
421-
buffer: &mut GraphType,
421+
buffer: &mut GraphData,
422422
) -> Option<bool> {
423423
let dx = (endx - startx) / lenx as f64;
424424
let dy = (endy - starty) / leny as f64;
425425
Some(match &data.graph_type.val {
426426
Val::Num(n) => {
427427
if let Some(c) = n {
428-
*buffer = GraphType::Constant(*c, data.graph_type.inv());
428+
*buffer = GraphData::Constant(*c, data.graph_type.inv());
429429
matches!(c, Complex::Complex(_, _) | Complex::Imag(_))
430430
} else {
431+
/*TODO
432+
buffer.set_type(GraphType::Width3D, (leny+1)*(lenx+1));
433+
let GraphData::Width3D(v, sx,sy,ex,ey) = buffer else {
434+
unreachable!()
435+
};
436+
*/
431437
let data = (0..=leny)
432438
.into_par_iter()
433439
.flat_map(|j| {
@@ -469,14 +475,14 @@ impl Data {
469475
let (a, b) = compact(data);
470476
#[cfg(not(feature = "kalc-lib"))]
471477
let (a, b) = (data, is_complex());
472-
*buffer = GraphType::Width3D(a, startx, starty, endx, endy);
478+
*buffer = GraphData::Width3D(a, startx, starty, endx, endy);
473479
b
474480
}
475481
}
476482
#[cfg(feature = "kalc-lib")]
477483
Val::Vector(v) => {
478484
if let Some(v) = v {
479-
*buffer = GraphType::Point(*v);
485+
*buffer = GraphData::Point(*v);
480486
false
481487
} else {
482488
let data = (0..=leny)
@@ -517,7 +523,7 @@ impl Data {
517523
})
518524
.collect::<Vec<(f64, Complex)>>();
519525
let (a, b) = compact_coord(data);
520-
*buffer = GraphType::Coord(a);
526+
*buffer = GraphData::Coord(a);
521527
b
522528
}
523529
}
@@ -562,7 +568,7 @@ impl Data {
562568
})
563569
.collect::<Vec<(f64, f64, Complex)>>();
564570
let (a, b) = compact_coord3d(data);
565-
*buffer = GraphType::Coord3D(a);
571+
*buffer = GraphData::Coord3D(a);
566572
b
567573
}
568574
#[cfg(feature = "kalc-lib")]
@@ -609,13 +615,13 @@ impl Data {
609615
}
610616
}
611617
let mut b = false;
612-
*buffer = GraphType::List(
618+
*buffer = GraphData::List(
613619
ndata
614620
.into_iter()
615621
.map(|data| {
616622
let (a, c) = compact_coord3d(data);
617623
b |= c;
618-
GraphType::Coord3D(a)
624+
GraphData::Coord3D(a)
619625
})
620626
.collect(),
621627
);
@@ -624,7 +630,7 @@ impl Data {
624630
#[cfg(feature = "kalc-lib")]
625631
Val::Matrix(m) => {
626632
if let Mat::D3(m) = m {
627-
*buffer = GraphType::Coord3D(
633+
*buffer = GraphData::Coord3D(
628634
m.iter().map(|m| (m.x, m.y, Complex::Real(m.z))).collect(),
629635
);
630636
false
@@ -646,12 +652,12 @@ impl Data {
646652
slice: isize,
647653
view_x: bool,
648654
n: Option<usize>,
649-
buffer: &mut Vec<GraphType>,
655+
buffer: &mut Vec<GraphData>,
650656
) -> bool {
651657
let len = if n.is_some() { 1 } else { self.data.len() };
652658
if len > buffer.len() {
653659
for _ in 0..len - buffer.len() {
654-
buffer.push(GraphType::None)
660+
buffer.push(GraphData::None)
655661
}
656662
}
657663
self.get_2d_slice(
@@ -670,7 +676,7 @@ impl Data {
670676
mut leny: usize,
671677
view_x: bool,
672678
n: Option<usize>,
673-
buffer: &mut Vec<GraphType>,
679+
buffer: &mut Vec<GraphData>,
674680
) -> bool {
675681
#[cfg(feature = "kalc-lib")]
676682
let (xstr, ystr, startx, starty, endx, endy) = if view_x {
@@ -702,7 +708,7 @@ impl Data {
702708
return false;
703709
};
704710
if let Val::Num(Some(c)) = data.graph_type.val {
705-
*buf = GraphType::Constant(c, data.graph_type.inv());
711+
*buf = GraphData::Constant(c, data.graph_type.inv());
706712
matches!(c, Complex::Complex(_, _) | Complex::Imag(_))
707713
} else {
708714
#[cfg(feature = "kalc-lib")]
@@ -740,17 +746,17 @@ impl Data {
740746
let (a, b) = compact(data);
741747
#[cfg(not(feature = "kalc-lib"))]
742748
let (a, b) = (data, is_complex());
743-
*buf = GraphType::Width3D(a, starx, stary, enx, eny);
749+
*buf = GraphData::Width3D(a, starx, stary, enx, eny);
744750
b
745751
}
746752
#[cfg(feature = "kalc-lib")]
747753
Val::Vector(_) => {
748-
*buf = GraphType::None;
754+
*buf = GraphData::None;
749755
false
750756
}
751757
#[cfg(feature = "kalc-lib")]
752758
Val::Vector3D => {
753-
*buf = GraphType::None;
759+
*buf = GraphData::None;
754760
false
755761
}
756762
#[cfg(feature = "kalc-lib")]
@@ -789,13 +795,13 @@ impl Data {
789795
}
790796
}
791797
let mut b = false;
792-
*buf = GraphType::List(
798+
*buf = GraphData::List(
793799
ndata
794800
.into_iter()
795801
.map(|data| {
796802
let (a, c) = compact_coord3d(data);
797803
b |= c;
798-
GraphType::Coord3D(a)
804+
GraphData::Coord3D(a)
799805
})
800806
.collect(),
801807
);
@@ -804,12 +810,12 @@ impl Data {
804810
#[cfg(feature = "kalc-lib")]
805811
Val::Matrix(m) => {
806812
if let Mat::D2(m) = m {
807-
*buf = GraphType::Coord(
813+
*buf = GraphData::Coord(
808814
m.iter().map(|m| (m.x, Complex::Real(m.y))).collect(),
809815
);
810816
false
811817
} else {
812-
*buf = GraphType::None;
818+
*buf = GraphData::None;
813819
false
814820
}
815821
}
@@ -823,12 +829,12 @@ impl Data {
823829
end: f64,
824830
len: usize,
825831
n: Option<usize>,
826-
buffer: &mut Vec<GraphType>,
832+
buffer: &mut Vec<GraphData>,
827833
) -> bool {
828834
let l = if n.is_some() { 1 } else { self.data.len() };
829835
if l > buffer.len() {
830836
for _ in 0..l - buffer.len() {
831-
buffer.push(GraphType::None)
837+
buffer.push(GraphData::None)
832838
}
833839
}
834840
buffer.into_par_iter().enumerate().any(|(mut i, b)| {
@@ -865,13 +871,13 @@ impl Data {
865871
start: f64,
866872
end: f64,
867873
len: usize,
868-
buffer: &mut GraphType,
874+
buffer: &mut GraphData,
869875
) -> Option<bool> {
870876
let dx = (end - start) / len as f64;
871877
Some(match &data.graph_type.val {
872878
Val::Num(n) => {
873879
if let Some(c) = n {
874-
*buffer = GraphType::Constant(*c, data.graph_type.inv());
880+
*buffer = GraphData::Constant(*c, data.graph_type.inv());
875881
matches!(c, Complex::Complex(_, _) | Complex::Imag(_))
876882
} else if data.graph_type.inv() {
877883
let data = (0..=len)
@@ -898,7 +904,7 @@ impl Data {
898904
let (a, b) = compact_coord(data);
899905
#[cfg(not(feature = "kalc-lib"))]
900906
let (a, b) = (data, is_complex());
901-
*buffer = GraphType::Coord(a);
907+
*buffer = GraphData::Coord(a);
902908
b
903909
} else {
904910
let data = (0..=len)
@@ -925,14 +931,14 @@ impl Data {
925931
let (a, b) = compact(data);
926932
#[cfg(not(feature = "kalc-lib"))]
927933
let (a, b) = (data, is_complex());
928-
*buffer = GraphType::Width(a, start, end);
934+
*buffer = GraphData::Width(a, start, end);
929935
b
930936
}
931937
}
932938
#[cfg(feature = "kalc-lib")]
933939
Val::Vector(v) => {
934940
if let Some(v) = v {
935-
*buffer = GraphType::Point(*v);
941+
*buffer = GraphData::Point(*v);
936942
false
937943
} else {
938944
let data = (0..=len)
@@ -962,7 +968,7 @@ impl Data {
962968
})
963969
.collect::<Vec<(f64, Complex)>>();
964970
let (a, b) = compact_coord(data);
965-
*buffer = GraphType::Coord(a);
971+
*buffer = GraphData::Coord(a);
966972
b
967973
}
968974
}
@@ -996,7 +1002,7 @@ impl Data {
9961002
})
9971003
.collect::<Vec<(f64, f64, Complex)>>();
9981004
let (a, b) = compact_coord3d(data);
999-
*buffer = GraphType::Coord3D(a);
1005+
*buffer = GraphData::Coord3D(a);
10001006
b
10011007
}
10021008
#[cfg(feature = "kalc-lib")]
@@ -1022,7 +1028,7 @@ impl Data {
10221028
}
10231029
}
10241030
}
1025-
*buffer = GraphType::List(ndata.into_iter().map(GraphType::Coord).collect());
1031+
*buffer = GraphData::List(ndata.into_iter().map(GraphData::Coord).collect());
10261032
false
10271033
} else {
10281034
let mut ndata: Vec<Vec<(f64, Complex)>> = Vec::new();
@@ -1054,13 +1060,13 @@ impl Data {
10541060
}
10551061
}
10561062
let mut b = false;
1057-
*buffer = GraphType::List(
1063+
*buffer = GraphData::List(
10581064
ndata
10591065
.into_iter()
10601066
.map(|data| {
10611067
let (a, c) = compact_coord(data);
10621068
b |= c;
1063-
GraphType::Coord(a)
1069+
GraphData::Coord(a)
10641070
})
10651071
.collect(),
10661072
);
@@ -1071,7 +1077,7 @@ impl Data {
10711077
Val::Matrix(m) => {
10721078
if let Mat::D2(m) = m {
10731079
*buffer =
1074-
GraphType::Coord(m.iter().map(|m| (m.x, Complex::Real(m.y))).collect());
1080+
GraphData::Coord(m.iter().map(|m| (m.x, Complex::Real(m.y))).collect());
10751081
false
10761082
} else {
10771083
return None;

0 commit comments

Comments
 (0)