rich7420 commented on code in PR #777:
URL: https://github.com/apache/mahout/pull/777#discussion_r2658956549


##########
qdp/qdp-core/src/readers/numpy.rs:
##########
@@ -0,0 +1,264 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+//! NumPy format reader implementation.
+//!
+//! Provides support for reading .npy files containing 2D float64 arrays.
+
+use std::path::Path;
+
+use ndarray::Array2;
+use ndarray_npy::ReadNpyError;
+
+use crate::error::{MahoutError, Result};
+use crate::reader::DataReader;
+
+/// Reader for NumPy `.npy` files containing 2D float64 arrays.
+///
+/// # Expected Format
+/// - 2D array with shape `[num_samples, sample_size]`
+/// - Data type: `float64`
+/// - Fortran (column-major) or C (row-major) order supported
+///
+/// # Example
+///
+/// ```rust,ignore
+/// use qdp_core::reader::DataReader;
+/// use qdp_core::readers::NumpyReader;
+///
+/// let mut reader = NumpyReader::new("data.npy").unwrap();
+/// let (data, num_samples, sample_size) = reader.read_batch().unwrap();
+/// println!("Read {} samples of size {}", num_samples, sample_size);
+/// ```
+pub struct NumpyReader {
+    path: std::path::PathBuf,
+    read: bool,
+}
+
+impl NumpyReader {
+    /// Create a new NumPy reader.
+    ///
+    /// # Arguments
+    /// * `path` - Path to the `.npy` file
+    pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
+        let path = path.as_ref();
+
+        // Verify file exists
+        if !path.exists() {

Review Comment:
   I think we could add this `path.exists()` in other format.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to