From 49f75582251dba830098121f5c7ca9fc7d499213 Mon Sep 17 00:00:00 2001 From: Palash Tyagi <23239946+Magnus167@users.noreply.github.com> Date: Sun, 22 Jun 2025 05:00:42 +0100 Subject: [PATCH] Enhance column access methods to clarify usage by name and physical index --- src/frame/base.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/frame/base.rs b/src/frame/base.rs index daad7ee..4698dee 100644 --- a/src/frame/base.rs +++ b/src/frame/base.rs @@ -309,7 +309,7 @@ impl Frame { ) } - /// Returns an immutable slice of the specified column's data. + /// Returns an immutable slice of the specified column's data by name. /// Panics if the column name is not found. pub fn column(&self, name: &str) -> &[T] { let idx = self @@ -318,7 +318,13 @@ impl Frame { self.matrix.column(idx) } - /// Returns a mutable slice of the specified column's data. + /// Returns an immutable slice of the specified column's data by its physical index. + /// Panics if the index is out of bounds. + pub fn column_by_physical_idx(&self, idx: usize) -> &[T] { + self.matrix.column(idx) + } + + /// Returns a mutable slice of the specified column's data by name. /// Panics if the column name is not found. pub fn column_mut(&mut self, name: &str) -> &mut [T] { let idx = self @@ -327,6 +333,12 @@ impl Frame { self.matrix.column_mut(idx) } + /// Returns a mutable slice of the specified column's data by its physical index. + /// Panics if the index is out of bounds. + pub fn column_mut_by_physical_idx(&mut self, idx: usize) -> &mut [T] { + self.matrix.column_mut(idx) + } + // Row access methods /// Returns an immutable view of the row for the given integer key.