Skip to content

Rename Scalars::one to Scalars::single #9436

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion crates/store/re_types/src/archetypes/scalar.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion crates/store/re_types/src/archetypes/scalars.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/store/re_types/src/archetypes/scalars_ext.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
impl crate::archetypes::Scalars {
/// Constructor for a single scalar.
pub fn one(value: impl Into<crate::components::Scalar>) -> Self {
pub fn single(value: impl Into<crate::components::Scalar>) -> Self {
Self::new([value.into()])
}
}
10 changes: 8 additions & 2 deletions crates/store/re_types/src/archetypes/series_line.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions crates/store/re_types/src/archetypes/series_lines.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/store/re_types/src/archetypes/series_point.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/store/re_types/src/archetypes/series_points.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions crates/viewer/re_view_dataframe/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ pub fn test_null_timeline() {
let timeline_b = Timeline::new_sequence("timeline_b");

test_context.log_entity("first".into(), |builder| {
builder.with_archetype(RowId::new(), [(timeline_a, 0)], &Scalars::one(10.0))
builder.with_archetype(RowId::new(), [(timeline_a, 0)], &Scalars::single(10.0))
});

test_context.log_entity("second".into(), |builder| {
builder.with_archetype(
RowId::new(),
[(timeline_a, 1), (timeline_b, 10)],
&Scalars::one(12.0),
&Scalars::single(12.0),
)
});

Expand All @@ -46,9 +46,9 @@ pub fn test_unknown_timeline() {

test_context.log_entity("some_entity".into(), |builder| {
builder
.with_archetype(RowId::new(), [(timeline, 0)], &Scalars::one(10.0))
.with_archetype(RowId::new(), [(timeline, 1)], &Scalars::one(20.0))
.with_archetype(RowId::new(), [(timeline, 2)], &Scalars::one(30.0))
.with_archetype(RowId::new(), [(timeline, 0)], &Scalars::single(10.0))
.with_archetype(RowId::new(), [(timeline, 1)], &Scalars::single(20.0))
.with_archetype(RowId::new(), [(timeline, 2)], &Scalars::single(30.0))
});

let view_id = setup_blueprint(&mut test_context, &TimelineName::from("unknown_timeline"));
Expand Down
6 changes: 3 additions & 3 deletions crates/viewer/re_view_time_series/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn test_clear_series_points_and_line_impl(two_series_per_entity: bool) {
(i as f64 / 5.0 + 1.0).cos(), // Shifted a bit to make the cap more visible
])
} else {
re_types::archetypes::Scalars::one((i as f64 / 5.0).sin())
re_types::archetypes::Scalars::single((i as f64 / 5.0).sin())
};

test_context.log_entity("plots/line".into(), |builder| {
Expand Down Expand Up @@ -110,8 +110,8 @@ fn scalars_for_properties_test(
)
} else {
(
re_types::archetypes::Scalars::one((step as f64 / 5.0).sin()),
re_types::archetypes::Scalars::one((step as f64 / 5.0).cos()),
re_types::archetypes::Scalars::single((step as f64 / 5.0).sin()),
re_types::archetypes::Scalars::single((step as f64 / 5.0).cos()),
)
}
}
Expand Down
12 changes: 9 additions & 3 deletions docs/snippets/all/archetypes/scalars_multiple_plots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rec.set_time_sequence("step", t);

// Log two time series under a shared root so that they show in the same plot by default.
rec.log("trig/sin", &rerun::Scalars::one((t as f64 / 100.0).sin()))?;
rec.log("trig/cos", &rerun::Scalars::one((t as f64 / 100.0).cos()))?;
rec.log(
"trig/sin",
&rerun::Scalars::single((t as f64 / 100.0).sin()),
)?;
rec.log(
"trig/cos",
&rerun::Scalars::single((t as f64 / 100.0).cos()),
)?;

// Log scattered points under a different root so that it shows in a different plot by default.
lcg_state = (1140671485_i64
.wrapping_mul(lcg_state)
.wrapping_add(128201163))
% 16777216; // simple linear congruency generator
rec.log("scatter/lcg", &rerun::Scalars::one(lcg_state as f64))?;
rec.log("scatter/lcg", &rerun::Scalars::single(lcg_state as f64))?;
}

Ok(())
Expand Down
5 changes: 4 additions & 1 deletion docs/snippets/all/archetypes/scalars_row_updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

for step in 0..64 {
rec.set_time_sequence("step", step);
rec.log("scalars", &rerun::Scalars::one((step as f64 / 10.0).sin()))?;
rec.log(
"scalars",
&rerun::Scalars::single((step as f64 / 10.0).sin()),
)?;
}

Ok(())
Expand Down
5 changes: 4 additions & 1 deletion docs/snippets/all/archetypes/scalars_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Log the data on a timeline called "step".
for step in 0..64 {
rec.set_time_sequence("step", step);
rec.log("scalar", &rerun::Scalars::one((step as f64 / 10.0).sin()))?;
rec.log(
"scalar",
&rerun::Scalars::single((step as f64 / 10.0).sin()),
)?;
}

Ok(())
Expand Down
10 changes: 8 additions & 2 deletions docs/snippets/all/archetypes/series_lines_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rec.set_time_sequence("step", t);

// Log two time series under a shared root so that they show in the same plot by default.
rec.log("trig/sin", &rerun::Scalars::one((t as f64 / 100.0).sin()))?;
rec.log("trig/cos", &rerun::Scalars::one((t as f64 / 100.0).cos()))?;
rec.log(
"trig/sin",
&rerun::Scalars::single((t as f64 / 100.0).sin()),
)?;
rec.log(
"trig/cos",
&rerun::Scalars::single((t as f64 / 100.0).cos()),
)?;
}

Ok(())
Expand Down
4 changes: 2 additions & 2 deletions docs/snippets/all/archetypes/series_points_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rec.set_time_sequence("step", t);

// Log two time series under a shared root so that they show in the same plot by default.
rec.log("trig/sin", &rerun::Scalars::one((t as f64 / 10.0).sin()))?;
rec.log("trig/cos", &rerun::Scalars::one((t as f64 / 10.0).cos()))?;
rec.log("trig/sin", &rerun::Scalars::single((t as f64 / 10.0).sin()))?;
rec.log("trig/cos", &rerun::Scalars::single((t as f64 / 10.0).cos()))?;
}

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion tests/rust/plot_dashboard_stress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ fn run(rec: &rerun::RecordingStream, args: &Args) -> anyhow::Result<()> {
rerun::Scalars::new(values.copied()).columns_of_unit_batches()?,
)?;
} else {
rec.log(path, &rerun::Scalars::one(series_values[offset]))?;
rec.log(path, &rerun::Scalars::single(series_values[offset]))?;
}
}
}
Expand Down