DataFrame#

class numpy::DataFrame#

numpy C++ class.

Example#

#include <numpy/np_ndarray.h>
using namespace numpy;

// Use DataFrame
DataFrame obj;
// ... operations ...

Constructors#

Signature

Location

Example

DataFrame(const std::map<std::string, std::vector<T>>& data, std::unique_ptr<IndexBase> index = nullptr)

df_dataframe.h:381

DataFrame(const std::vector<Series<T>>& columns, const std::vector<std::string>& column_names, std::unique_ptr<IndexBase> index = nullptr)

df_dataframe.h:433

DataFrame(const numpy::NDArray<T>& data, std::unique_ptr<IndexBase> index = nullptr, const std::vector<std::string>& columns =

df_dataframe.h:492

DataFrame(const DataFrame& other)

df_dataframe.h:543

DataFrame(DataFrame&& other) noexcept

df_dataframe.h:558

Construction#

Signature

Return Type

Location

Example

static DataFrame from_dict( const std::map<std::string, std::vector<T>>& data, const std::string& orient = "columns", const std::vector<std::string>& columns =

DataFrame

df_dataframe.h:18160

static DataFrame from_dict( const std::map<std::string, std::vector<T>>& data, std::unique_ptr<IndexBase> index)

DataFrame

df_dataframe.h:18339

static DataFrame from_dict_tight(const TightDict<T>& tight_data)

DataFrame

df_dataframe.h:18288

static DataFrame from_records( const std::vector<std::vector<T>>& data, const std::vector<std::string>& columns, const std::string& index = "", const std::vector<std::string>& exclude =

DataFrame

df_dataframe.h:18388

static DataFrame from_records( const std::vector<std::map<std::string, T>>& data, const std::string& index = "", const std::vector<std::string>& exclude =

DataFrame

df_dataframe.h:18573

static DataFrame from_records_tuple( const std::vector<std::tuple<Args...>>& data, const std::vector<std::string>& columns, size_t nrows = 0)

DataFrame

df_dataframe.h:18716

oss << make_hsep('+', '-', '+') << "\\n"

oss <<

df_dataframe.h:17976

oss << make_hsep('+', '=', '+') << "\\n"

oss <<

df_dataframe.h:17991

oss << make_hsep('+', '-', '+') << "\\n"

oss <<

df_dataframe.h:18012

Array Creation#

Signature

Return Type

Location

Example

bool empty() const override

bool

df_dataframe.h:616

View

Indexing / Selection#

Signature

Return Type

Location

Example

T at(const std::string& row_label, const std::string& col_label) const

T

df_dataframe.h:1659

View

DataFrame at_time(const std::string& time) const

DataFrame

df_dataframe.h:12177

const Attrs& attrs() const override

const Attrs&

df_dataframe.h:750

Attrs& attrs() override

Attrs&

df_dataframe.h:757

std::optional<ReturnType> get(const std::string& key, std::optional<ReturnType> default_value = std::nullopt) const

std::optional<ReturnType>

df_dataframe.h:6165

View

size_t get_column_index(const std::string& name) const

size_t

df_dataframe.h:1494

std::vector<double> get_column_values_as_double\_(size_t col_idx) const

std::vector<double>

df_dataframe.h:10357

size_t get_num_levels(int axis) const

size_t

df_dataframe.h:8009

std::optional<const NDFrameBase\*> get_optional(const std::string& key) const

std::optional<const NDFrameBase*>

df_dataframe.h:2398

size_t get_row_index(const std::string& label) const

size_t

df_dataframe.h:22250

bool get_value_bool(size_t idx) const override

bool

df_dataframe.h:3287

std::string get_value_str(size_t idx) const override

std::string

df_dataframe.h:22137

ItemsRange items() const

ItemsRange

df_dataframe.h:1045

DataFrame select_dtypes(const std::vector<std::string>& include =

DataFrame

df_dataframe.h:2623

DataFrame take(const std::vector<size_t>& indices) const

DataFrame

df_dataframe.h:1720

View

DataFrame where(const DataFrame& cond, double other = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:3564

View

Shape Manipulation#

Signature

Return Type

Location

Example

DataFrame T() const

DataFrame

df_dataframe.h:685

View

DataFrame squeeze() const

DataFrame

df_dataframe.h:8673

View

DataFrame swapaxes(int axis1 = 0, int axis2 = 1) const

DataFrame

df_dataframe.h:6201

View

DataFrame transpose() const

DataFrame

df_dataframe.h:7426

View

Statistics#

Signature

Return Type

Location

Example

DataFrame cov(int ddof = 1) const

DataFrame

df_dataframe.h:6763

View

Series<numpy::float64> max(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5481

View

Series<numpy::float64> max_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4383

Series<numpy::float64> mean(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5314

View

Series<numpy::float64> mean_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4322

Series<numpy::float64> median(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:4849

View

Series<numpy::float64> median_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4801

Series<numpy::float64> min(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5438

View

Series<numpy::float64> min_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4353

Series<numpy::float64> quantile(double q = 0.5, int axis = 0, bool numeric_only = false, const std::string& interpolation = "linear") const

Series<numpy::float64>

df_dataframe.h:5685

View

Series<numpy::float64> quantile_cols(double q, const std::string& interpolation = "linear") const

Series<numpy::float64>

df_dataframe.h:6681

Series<numpy::float64> std(int axis = 0, bool skipna = true, int ddof = 1, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5357

View

Series<numpy::float64> std_cols(bool skipna = true, int ddof = 1) const

Series<numpy::float64>

df_dataframe.h:4599

Series<numpy::float64> sum(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5274

View

Series<numpy::float64> sum_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4293

Series<numpy::float64> var(int axis = 0, bool skipna = true, int ddof = 1, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5405

View

Series<numpy::float64> var_cols(bool skipna = true, int ddof = 1) const

Series<numpy::float64>

df_dataframe.h:4637

Sorting#

Signature

Return Type

Location

Example

DataFrame sort_index(bool ascending = true) const

DataFrame

df_dataframe.h:7326

DataFrame sort_values(const std::string& by, bool ascending = true) const

DataFrame

df_dataframe.h:7290

DataFrame sort_values(const std::vector<std::string>& by, bool ascending = true) const

DataFrame

df_dataframe.h:7297

Math Operations#

Signature

Return Type

Location

Example

DataFrame abs() const

DataFrame

df_dataframe.h:9252

View

DataFrame add(const DataFrame& other, double fill_value = 0.0) const

DataFrame

df_dataframe.h:8958

View

DataFrame add(double scalar) const

DataFrame

df_dataframe.h:8962

View

void add_column(const std::string& name, const std::vector<T>& data)

void

df_dataframe.h:2466

DataFrame add_prefix(const std::string& prefix, int axis = -1) const

DataFrame

df_dataframe.h:2317

add_shared_string(idx_lbl)

df_dataframe.h:15159

add_shared_string(columns_index\_.get_value_str(c))

df_dataframe.h:15163

add_shared_string(idx_val)

df_dataframe.h:15172

add_shared_string(na_rep)

df_dataframe.h:15179

add_shared_string(val)

df_dataframe.h:15182

DataFrame add_suffix(const std::string& suffix, int axis = -1) const

DataFrame

df_dataframe.h:2362

add_zip_entry("[Content_Types].xml", content_types.str())

df_dataframe.h:15216

add_zip_entry("_rels/.rels", rels.str())

df_dataframe.h:15224

add_zip_entry("xl/_rels/workbook.xml.rels", wb_rels.str())

df_dataframe.h:15234

add_zip_entry("xl/workbook.xml", workbook.str())

df_dataframe.h:15245

add_zip_entry("xl/styles.xml", styles.str())

df_dataframe.h:15257

add_zip_entry("xl/sharedStrings.xml", shared_strings_xml.str())

df_dataframe.h:15268

add_zip_entry("xl/worksheets/sheet1.xml", sheet.str())

df_dataframe.h:15388

DataFrame ceil() const

DataFrame

df_dataframe.h:9245

View

DataFrame divide(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9007

View

DataFrameExpanding expanding(size_t min_periods = 1) const

DataFrameExpanding

df_dataframe.h:5971

DataFrame explode(const std::string& column) const

DataFrame

df_dataframe.h:8613

DataFrame floor() const

DataFrame

df_dataframe.h:9238

View

DataFrame floordiv(const DataFrame& other) const

DataFrame

df_dataframe.h:9022

DataFrame floordiv(double scalar) const

DataFrame

df_dataframe.h:9026

DataFrame mod(const DataFrame& other) const

DataFrame

df_dataframe.h:9033

View

DataFrame mod(double scalar) const

DataFrame

df_dataframe.h:9037

View

\* Returns a DataFrame where each column contains the mode(s) for that column.

* Returns a DataFrame where each column contains the

df_dataframe.h:4903

View

DataFrame mode(int axis = 0, bool numeric_only = false, bool dropna = true) const

DataFrame

df_dataframe.h:4912

View

DataFrame mode_cols(bool numeric_only = false, bool dropna = true) const

DataFrame

df_dataframe.h:4931

DataFrame mode_rows(bool numeric_only = false, bool dropna = true) const

DataFrame

df_dataframe.h:5067

DataFrame multiply(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:8992

View

DataFrame round(int decimals = 0) const

DataFrame

df_dataframe.h:9228

View

DataFrame subtract(const DataFrame& other, double fill_value = 0.0) const

DataFrame

df_dataframe.h:8977

View

DataFrame truncate(const std::optional<std::string>& before = std::nullopt, const std::optional<std::string>& after = std::nullopt) const

DataFrame

df_dataframe.h:12215

View

Linear Algebra#

Signature

Return Type

Location

Example

DataFrame dot(const DataFrame& other) const

DataFrame

df_dataframe.h:8806

View

Series<double> dot(const Series<T>& other) const

Series<double>

df_dataframe.h:8865

View

void invalidate_caches() const

void

df_dataframe.h:22246

Random#

Signature

Return Type

Location

Example

DataFrame sample(size_t n, unsigned int seed = 0) const

DataFrame

df_dataframe.h:1694

View

DataFrame sample_frac(double frac, unsigned int seed = 0) const

DataFrame

df_dataframe.h:1712

Comparison#

Signature

Return Type

Location

Example

bool equals(const DataFrame& other) const

bool

df_dataframe.h:4193

Logical#

Signature

Return Type

Location

Example

bool all(bool skipna = true) const override

bool

df_dataframe.h:11025

View

Series<numpy::bool\_> all_axis(int axis = 0, bool skipna = true) const

Series<numpy::bool_>

df_dataframe.h:11053

bool any(bool skipna = true) const override

bool

df_dataframe.h:11035

View

Series<numpy::bool\_> any_axis(int axis = 0, bool skipna = true) const

Series<numpy::bool_>

df_dataframe.h:11175

Set Operations#

Signature

Return Type

Location

Example

DataFrame isin(const std::vector<T>& values) const

DataFrame

df_dataframe.h:3407

View

DataFrame isin(const std::map<std::string, std::vector<T>>& values) const

DataFrame

df_dataframe.h:3461

View

I/O#

Signature

Return Type

Location

Example

void to_clipboard( bool excel = true, char sep = '\\t', bool index = true, bool header = true, const std::string& na_rep = "") const

void

df_dataframe.h:17591

std::string to_csv(bool include_index = true, char sep = ',') const

std::string

df_dataframe.h:12336

std::map<std::string, std::vector<std::string>> to_dict( const std::string& orient = "list") const

std::map<std::string, std::vector<std::string>>

df_dataframe.h:12669

std::map<std::string, std::map<std::string, std::string>> to_dict_orient_dict( bool index = true) const

std::map<std::string, std::map<std::string, std::string>>

df_dataframe.h:12714

std::map<std::string, std::map<std::string, std::string>> to_dict_orient_index() const

std::map<std::string, std::map<std::string, std::string>>

df_dataframe.h:12800

std::vector<std::map<std::string, std::string>> to_dict_orient_records( bool index = false) const

std::vector<std::map<std::string, std::string>>

df_dataframe.h:12753

std::map<std::string, std::unique_ptr<NDFrameBase>> to_dict_orient_series() const

std::map<std::string, std::unique_ptr<NDFrameBase>>

df_dataframe.h:12954

DictSplitResult to_dict_orient_split(bool index = true) const

DictSplitResult

df_dataframe.h:12840

DictTightResult to_dict_orient_tight(bool index = true) const

DictTightResult

df_dataframe.h:12899

void to_excel( const std::string& excel_writer, const std::string& sheet_name = "Sheet1", const std::string& na_rep = "", const std::string& float_format = "", const std::vector<std::string>& columns =

void

df_dataframe.h:15022

\* This is the inverse operation of to_excel().

* This is the inverse operation of

df_dataframe.h:19062

\* This is the inverse operation of to_feather().

* This is the inverse operation of

df_dataframe.h:20763

std::vector<uint8_t> to_feather( const std::string& path = "", const std::string& compression = "uncompressed", [[maybe_unused]] int compression_level = -1, [[maybe_unused]] int64_t chunksize = -1, int version = 2) const

std::vector<uint8_t>

df_dataframe.h:20934

void to_gbq(const std::string& destination_table, const std::string& project_id = "", const std::string& if_exists = "fail", bool progress_bar = true) const

void

df_dataframe.h:6255

std::vector<uint8_t> to_hdf( const std::string& path_or_buf = "", const std::string& key = "df", const std::string& mode = "a", [[maybe_unused]] std::optional<int> complevel = std::nullopt, [[maybe_unused]] const std::string& complib = "zlib", [[maybe_unused]] bool append = false, const std::string& format = "fixed", bool index = true, [[maybe_unused]] const std::map<std::string, int>& min_itemsize =

std::vector<uint8_t>

df_dataframe.h:14419

\* Reads a file written by to_hdf() and returns its contents as a DataFrame.

* Reads a file written by

df_dataframe.h:19928

\* This is the inverse operation of to_hdf().

* This is the inverse operation of

df_dataframe.h:19929

std::string to_html( std::ostream\* buf = nullptr, const std::vector<std::string>& columns =

std::string

df_dataframe.h:15603

std::string to_json(const std::string& orient = "columns") const

std::string

df_dataframe.h:12367

std::string to_latex( std::ostream\* buf = nullptr, const std::vector<std::string>& columns =

std::string

df_dataframe.h:15983

std::string to_markdown( std::ostream\* buf = nullptr, [[maybe_unused]] const std::string& mode = "wt", bool index = true, const std::string& tablefmt = "pipe", const std::vector<std::string>& colalign =

std::string

df_dataframe.h:17799

numpy::NDArray<numpy::float64> to_numpy(const std::string& dtype = "float64", bool copy = true, double na_value = std::numeric_limits<double>::quiet_NaN()) const

numpy::NDArray<numpy::float64>

df_dataframe.h:6218

View

std::vector<uint8_t> to_orc( const std::string& path = "", const std::string& engine = "pyarrow", std::optional<bool> index = std::nullopt, [[maybe_unused]] const std::map<std::string, std::string>& engine_kwargs =

std::vector<uint8_t>

df_dataframe.h:13005

std::vector<uint8_t> to_parquet( const std::string& path = "", const std::string& engine = "pyarrow", [[maybe_unused]] const std::string& compression = "snappy", std::optional<bool> index = std::nullopt, const std::vector<std::string>& partition_cols =

std::vector<uint8_t>

df_dataframe.h:13568

\* This is the inverse operation of to_parquet().

* This is the inverse operation of

df_dataframe.h:19474

\* (use to_parquet() for custom indices)

* (use

df_dataframe.h:20912

DataFrame to_period(const std::string& freq = "", int axis = 0, bool copy = true) const

DataFrame

df_dataframe.h:12013

std::vector<uint8_t> to_pickle( const std::string& path = "", [[maybe_unused]] const std::string& compression = "infer", [[maybe_unused]] int protocol = 5) const

std::vector<uint8_t>

df_dataframe.h:14213

numpy::RecordArray to_records( bool index = true, const std::map<std::string, std::string>& column_dtypes =

numpy::RecordArray

df_dataframe.h:16347

std::vector<std::map<std::string, std::string>> to_records_dict() const

std::vector<std::map<std::string, std::string>>

df_dataframe.h:20867

std::optional<int64_t> to_sql( const std::string& name, const std::string& con_path, const std::string& schema = "", const std::string& if_exists = "fail", bool index = true, const std::string& index_label = "", std::optional<size_t> chunksize = std::nullopt, const std::map<std::string, std::string>& dtype =

std::optional<int64_t>

df_dataframe.h:14659

\* Reads a SQLite database file created by to_sql() and returns a DataFrame.

* Reads a SQLite database file created by

df_dataframe.h:20155

\* This parses the SQL file format generated by to_sql().

* This parses the SQL file format generated by

df_dataframe.h:20156

\* generated by to_sql(). For full SQL support, use a database library.

* generated by

df_dataframe.h:20176

std::vector<uint8_t> to_stata( const std::string& path = "", const std::map<std::string, std::string>& convert_dates =

std::vector<uint8_t>

df_dataframe.h:16620

\* This is the inverse operation of to_stata().

* This is the inverse operation of

df_dataframe.h:20373

\* If false, write a string representation (similar to to_string()).

* If false, write a string representation (similar to

df_dataframe.h:17544

View

std::string to_string() const override

std::string

df_dataframe.h:22164

View

std::vector<std::string> to_string_vector() const override

std::vector<std::string>

df_dataframe.h:22150

DataFrame to_timestamp(const std::string& freq = "", const std::string& how = "start", int axis = 0, bool copy = true) const

DataFrame

df_dataframe.h:12054

Dataset to_xarray() const

Dataset

df_dataframe.h:21983

std::string to_xml(const std::string& path = "", bool index = true, const std::string& root_name = "data", const std::string& row_name = "row", bool pretty_print = true) const

std::string

df_dataframe.h:6278

Joining / Splitting#

Signature

Return Type

Location

Example

void insert(size_t loc, const std::string& column, std::unique_ptr<NDFrameBase> value)

void

df_dataframe.h:2434

View

insert(ncols(), name, std::make_unique<Series<T>>(data, name))

df_dataframe.h:2467

View

DataFrame stack() const

DataFrame

df_dataframe.h:8694

View

Type Handling#

Signature

Return Type

Location

Example

DataFrame astype(const std::string& dtype) const

DataFrame

df_dataframe.h:9622

View

DataFrame astype(const std::map<std::string, std::string>& dtype_map) const

DataFrame

df_dataframe.h:9644

View

DataFrame copy([[maybe_unused]] bool deep = true) const

DataFrame

df_dataframe.h:12317

View

copy_to_clipboard_impl(text)

df_dataframe.h:17639

static void copy_to_clipboard_impl(const std::string& text)

static void

df_dataframe.h:17648

void copy_value_from(size_t src_idx, size_t dst_idx) override

void

df_dataframe.h:3336

Special Functions#

Signature

Return Type

Location

Example

DataFrame combine(const DataFrame& other, Func func, std::optional<double> fill_value = std::nullopt, bool overwrite = true) const

DataFrame

df_dataframe.h:11622

View

DataFrame combine_first(const DataFrame& other) const

DataFrame

df_dataframe.h:11738

Type Checking#

Signature

Return Type

Location

Example

static bool is_bool_string(const std::string& value)

static bool

df_dataframe.h:9861

static bool is_float_actually_integer(double value)

static bool

df_dataframe.h:9906

static bool is_float_string(const std::string& value)

static bool

df_dataframe.h:9887

bool is_homogeneous_type() const

bool

df_dataframe.h:785

static bool is_integer_string(const std::string& value)

static bool

df_dataframe.h:9869

bool is_na_at(size_t idx) const override

bool

df_dataframe.h:3252

Other Methods#

Signature

Return Type

Location

Example

\* DataFrame A(

* DataFrame

df_dataframe.h:8801

View

\* DataFrame A(

* DataFrame

df_dataframe.h:8859

View

\* DataFrame B(

* DataFrame

df_dataframe.h:8802

View

\* Reads an Excel (.xlsx) file and returns its contents as a DataFrame.

* Reads an

df_dataframe.h:19061

\* Reads a Feather (Arrow IPC) file and returns its contents as a DataFrame.

* Reads a

df_dataframe.h:20762

\* Hierarchical Data Format (HDF) is a self-describing format that allows

* Hierarchical Data

df_dataframe.h:14344

GlobalFree(hMem)

df_dataframe.h:17672

GlobalFree(hMem)

df_dataframe.h:17682

GlobalUnlock(hMem)

df_dataframe.h:17678

\* The Series has a MultiIndex (or single Index) from the unique value combinations.

* The Series has a

df_dataframe.h:6464

\* Writes the DataFrame to an Excel file in the Office Open XML (.xlsx) format.

* Writes the DataFrame to an Excel file in the Office Open

df_dataframe.h:14963

DataFrame agg(const std::string& func_name, int axis = 0) const

DataFrame

df_dataframe.h:10908

DataFrame agg(const std::vector<std::string>& funcs, int axis = 0) const

DataFrame

df_dataframe.h:10968

DataFrame aggregate(const std::string& func_name, int axis = 0) const

DataFrame

df_dataframe.h:10998

DataFrame aggregate(const std::vector<std::string>& funcs, int axis = 0) const

DataFrame

df_dataframe.h:11005

std::pair<DataFrame, DataFrame> align( const DataFrame& other, const std::string& join = "outer", int axis = -1, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

std::pair<DataFrame, DataFrame>

df_dataframe.h:11556

\* If empty, uses default alignment (right for numeric, left for text).

* If empty, uses default

df_dataframe.h:17748

DataFrame apply(Func&& func, int axis = 0) const

DataFrame

df_dataframe.h:9473

std::vector<double> apply_named_transform\_(const std::string& func_name, const std::vector<double>& values) const

std::vector<double>

df_dataframe.h:10375

DataFrame applymap(Func&& func) const

DataFrame

df_dataframe.h:9515

std::istringstream arr_stream(arr_str)

std::istringstream

df_dataframe.h:18980

DataFrame asfreq(const std::string& freq, const std::string& method = "") const

DataFrame

df_dataframe.h:11966

Series<numpy::float64> asof(const std::string& where, const std::vector<std::string>& subset =

Series<numpy::float64>

df_dataframe.h:12260

DataFrame asof(const std::vector<std::string>& where, const std::vector<std::string>& subset =

DataFrame

df_dataframe.h:12266

DataFrame assign(const std::string& col_name, const std::vector<T>& data) const

DataFrame

df_dataframe.h:4253

std::vector<const IndexBase\*> axes() const override

std::vector<const IndexBase*>

df_dataframe.h:706

View

numpy::NDArray<numpy::float64> b(

numpy::NDArray<numpy::float64>

df_dataframe.h:8882

View

DataFrame backfill(int axis = 0, std::optional<int> limit = std::nullopt) const

DataFrame

df_dataframe.h:6012

iterator begin()

iterator

df_dataframe.h:888

View

const_iterator begin() const

const_iterator

df_dataframe.h:892

View

DataFrame between_time(const std::string& start_time, const std::string& end_time, bool include_start = true, bool include_end = true) const

DataFrame

df_dataframe.h:12190

DataFrame between_time(const std::string& start_time, const std::string& end_time, const std::string& inclusive) const

DataFrame

df_dataframe.h:12205

DataFrame bfill(int axis = 0, std::optional<int> limit = std::nullopt) const

DataFrame

df_dataframe.h:2897

DataFrame binary_op(const DataFrame& other, BinaryOp op) const

DataFrame

df_dataframe.h:22262

DataFrame binary_op_fill(const DataFrame& other, double fill_value, BinaryOp op) const

DataFrame

df_dataframe.h:22407

bool bool\_() const

bool

df_dataframe.h:6079

View

const_iterator cbegin() const

const_iterator

df_dataframe.h:896

const_iterator cend() const

const_iterator

df_dataframe.h:912

std::ifstream check_file(path_or_buf)

std::ifstream

df_dataframe.h:14575

View

std::ifstream check_file(con_path)

std::ifstream

df_dataframe.h:14691

View

void clear_cache() const override

void

df_dataframe.h:22233

DataFrame clip(double lower, double upper) const

DataFrame

df_dataframe.h:9259

View

std::unique_ptr<NDFrameBase> clone() const override

std::unique_ptr<NDFrameBase>

df_dataframe.h:12325

View

numpy::NDArray<numpy::int64> code_arr(std::vector<size_t>

numpy::NDArray<numpy::int64>

df_dataframe.h:6657

Series<T>& col(const std::string& name)

Series<T>&

df_dataframe.h:1467

const Series<T>& col(const std::string& name) const

const Series<T>&

df_dataframe.h:1481

std::istringstream cols_stream(cols_def)

std::istringstream

df_dataframe.h:20211

\* Counts the number of unique (distinct) values per column (axis=0) or per row (axis=1).

* Counts the number of unique (distinct) values per

df_dataframe.h:6396

View

\* Apply a named transform function to each column (axis=0) or row (axis=1).

* Apply a named transform function to each

df_dataframe.h:10681

View

const Index<std::string>& columns() const

const Index<std::string>&

df_dataframe.h:692

View

\* Data columns (total 3 columns):

* Data

df_dataframe.h:12432

View

std::vector<std::vector<std::string>> columns(col_names.size())

std::vector<std::vector<std::string>>

df_dataframe.h:18836

View

std::vector<std::vector<std::string>> columns(col_indices.size())

std::vector<std::vector<std::string>>

df_dataframe.h:19406

View

std::vector<std::vector<std::string>> columns_data(col_names.size())

std::vector<std::vector<std::string>>

df_dataframe.h:20303

DataFrame compare( const DataFrame& other, bool keep_shape = false, bool keep_equal = false) const

DataFrame

df_dataframe.h:11832

DataFrame compare_op(const DataFrame& other, CompOp op) const

DataFrame

df_dataframe.h:22376

static DataFrame concat(const std::vector<DataFrame>& frames, bool ignore_index = false)

static DataFrame

df_dataframe.h:11278

inline DataFrame concat(const std::vector<DataFrame>& frames, bool ignore_index = false)

DataFrame

df_dataframe.h:22493

DataFrame convert_dtypes( bool infer_objects = true, bool convert_string = true, bool convert_integer = true, bool convert_boolean = true, bool convert_floating = true) const

DataFrame

df_dataframe.h:10058

\* Unlike convert_dtypes(), this method:

* Unlike

df_dataframe.h:10183

static numpy::bool\_ convert_to_bool(const std::string& value, const std::string& source_dtype, const std::string& col_name, size_t row_idx)

static numpy::bool_

df_dataframe.h:9829

static numpy::float64 convert_to_float64(const std::string& value, const std::string& source_dtype, const std::string& col_name, size_t row_idx)

static numpy::float64

df_dataframe.h:9795

static numpy::int64 convert_to_int64(const std::string& value, const std::string& source_dtype, const std::string& col_name, size_t row_idx)

static numpy::int64

df_dataframe.h:9767

DataFrame corr(const std::string& method = "pearson") const

DataFrame

df_dataframe.h:6722

Series<numpy::float64> corrwith(const DataFrame& other, int axis = 0, bool drop = false, const std::string& method = "pearson", bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:6809

Series<numpy::float64> corrwith(const Series<T>& other, int axis = 0, bool drop = false, const std::string& method = "pearson", bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:7105

size_t count() const override

size_t

df_dataframe.h:2756

View

Series<numpy::int64> count_cols() const

Series<numpy::int64>

df_dataframe.h:4653

DataFrame cummax(int axis = 0) const

DataFrame

df_dataframe.h:9367

DataFrame cummin(int axis = 0) const

DataFrame

df_dataframe.h:9336

DataFrame cumprod(int axis = 0) const

DataFrame

df_dataframe.h:9305

View

DataFrame cumsum(int axis = 0) const

DataFrame

df_dataframe.h:9274

View

DataArray<numpy::float64> da(data,

DataArray<numpy::float64>

df_dataframe.h:22054

DataArray<numpy::int64> da(data,

DataArray<numpy::int64>

df_dataframe.h:22065

DataArray<numpy::int32> da(data,

DataArray<numpy::int32>

df_dataframe.h:22076

DataArray<numpy::float32> da(data,

DataArray<numpy::float32>

df_dataframe.h:22087

DataArray<bool> da(data,

DataArray<bool>

df_dataframe.h:22098

DataArray<std::string> da(data,

DataArray<std::string>

df_dataframe.h:22110

DataArray<std::string> da(data,

DataArray<std::string>

df_dataframe.h:22120

numpy::NDArray<numpy::float64> data(std::vector<size_t>

numpy::NDArray<numpy::float64>

df_dataframe.h:22050

View

numpy::NDArray<numpy::int64> data(std::vector<size_t>

numpy::NDArray<numpy::int64>

df_dataframe.h:22061

View

numpy::NDArray<numpy::int32> data(std::vector<size_t>

numpy::NDArray<numpy::int32>

df_dataframe.h:22072

View

numpy::NDArray<numpy::float32> data(std::vector<size_t>

numpy::NDArray<numpy::float32>

df_dataframe.h:22083

View

numpy::NDArray<bool> data(std::vector<size_t>

numpy::NDArray<bool>

df_dataframe.h:22094

View

numpy::NDArray<std::string> data(std::vector<size_t>

numpy::NDArray<std::string>

df_dataframe.h:22106

View

numpy::NDArray<std::string> data(std::vector<size_t>

numpy::NDArray<std::string>

df_dataframe.h:22116

View

DataFrame describe() const

DataFrame

df_dataframe.h:4670

View

\* DataFrame df(

* DataFrame

df_dataframe.h:880

\* DataFrame df(

* DataFrame

df_dataframe.h:924

\* DataFrame df(

* DataFrame

df_dataframe.h:1030

\* DataFrame df(

* DataFrame

df_dataframe.h:1169

\* DataFrame df(

* DataFrame

df_dataframe.h:1379

\* DataFrame df(

* DataFrame

df_dataframe.h:1761

\* DataFrame df(

* DataFrame

df_dataframe.h:3401

\* DataFrame df(

* DataFrame

df_dataframe.h:3451

\* DataFrame df(

* DataFrame

df_dataframe.h:3558

\* DataFrame df(

* DataFrame

df_dataframe.h:3611

\* DataFrame df(

* DataFrame

df_dataframe.h:3665

\* DataFrame df(

* DataFrame

df_dataframe.h:3804

\* DataFrame df(

* DataFrame

df_dataframe.h:6468

\* DataFrame df(

* DataFrame

df_dataframe.h:10049

\* DataFrame df(

* DataFrame

df_dataframe.h:10196

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12655

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12705

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12745

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12791

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12831

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12886

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:12946

\* DataFrame df(std::map<std::string, std::vector<int>>

* DataFrame

df_dataframe.h:16322

\* pandas::DataFrame df(

* pandas::DataFrame

df_dataframe.h:17560

\* DataFrame df(

* DataFrame

df_dataframe.h:17760

\* DataFrame df(data, nullptr,

* DataFrame

df_dataframe.h:21973

\* DataFrame df(

* DataFrame

df_dataframe.h:22462

\* Converts a sequence of dicts (maps) into a DataFrame. Each dict represents

* Converts a sequence of

df_dataframe.h:18539

DataFrame diff(int periods = 1, int axis = 0) const

DataFrame

df_dataframe.h:9398

View

DataFrame div(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:8999

DataFrame div(double scalar) const

DataFrame

df_dataframe.h:9003

DataFrame drop(const std::vector<std::string>& labels, int axis = 0) const

DataFrame

df_dataframe.h:2542

DataFrame drop_duplicates(const std::vector<std::string>& subset =

DataFrame

df_dataframe.h:4117

void drop_inplace(const std::vector<std::string>& labels, int axis = 0)

void

df_dataframe.h:2551

static std::string drop_level_from_label(const std::string& label, size_t level)

static std::string

df_dataframe.h:7673

DataFrame droplevel(int level, int axis = 0) const

DataFrame

df_dataframe.h:7483

DataFrame droplevel(int level, const std::string& axis) const

DataFrame

df_dataframe.h:7500

DataFrame droplevel(const std::string& level_name, int axis = 0) const

DataFrame

df_dataframe.h:7522

DataFrame droplevel(const std::vector<int>& levels, int axis = 0) const

DataFrame

df_dataframe.h:7544

DataFrame droplevel_columns(int level) const

DataFrame

df_dataframe.h:7617

DataFrame droplevel_index(int level) const

DataFrame

df_dataframe.h:7567

DataFrame dropna(int axis = 0, const std::string& how = "any") const

DataFrame

df_dataframe.h:2767

\* DatetimeIndex dt_idx(

* DatetimeIndex

df_dataframe.h:11998

\* DatetimeIndex dt_idx(

* DatetimeIndex

df_dataframe.h:12146

std::string dtype_name() const override

std::string

df_dataframe.h:649

View

Series<std::string> dtypes() const

Series<std::string>

df_dataframe.h:713

View

Series<numpy::bool\_> duplicated(const std::vector<std::string>& subset =

Series<numpy::bool_>

df_dataframe.h:4050

iterator end()

iterator

df_dataframe.h:904

View

const_iterator end() const

const_iterator

df_dataframe.h:908

View

\* Provides begin() and end() for range-based for loops.

* Provides begin() and

df_dataframe.h:1002

View

\* Provides begin() and end() for range-based for loops.

* Provides begin() and

df_dataframe.h:1132

View

\* Provides begin() and end() for range-based for loops.

* Provides begin() and

df_dataframe.h:1336

View

DataFrame eq(const DataFrame& other) const

DataFrame

df_dataframe.h:8912

escape_html(url) + "</a>"

df_dataframe.h:15725

oss << escape_latex(index\_->name().value())

oss <<

df_dataframe.h:16190

oss << escape_latex(col_name)

oss <<

df_dataframe.h:16202

oss << escape_latex(index\_->name().value())

oss <<

df_dataframe.h:16220

oss << escape_latex(col_name)

oss <<

df_dataframe.h:16230

oss << escape_latex(idx_val)

oss <<

df_dataframe.h:16254

static std::string escape_xml(const std::string& str)

static std::string

df_dataframe.h:6334

std::variant<Series<numpy::float64>, DataFrame, std::monostate> eval( const std::string& expr, bool inplace = false)

std::variant<Series<numpy::float64>, DataFrame, std::monostate>

df_dataframe.h:3822

std::vector<double> eval_expression(const std::string& expr) const

std::vector<double>

df_dataframe.h:3928

double eval_postfix(const std::vector<eval_internal::EvalToken>& postfix, size_t row) const

double

df_dataframe.h:3950

bool evaluate_comparison(const query::ComparisonNode\* comp, size_t row) const

bool

df_dataframe.h:3736

bool evaluate_query_node(const query::ASTNode\* node, size_t row) const

bool

df_dataframe.h:3704

evaluate_query_node(and_node->right.get(), row)

df_dataframe.h:3715

evaluate_query_node(or_node->right.get(), row)

df_dataframe.h:3720

DataFrameEWM ewm(double span, bool adjust = true, bool ignore_na = false) const

DataFrameEWM

df_dataframe.h:5982

DataFrame ffill(int axis = 0, std::optional<int> limit = std::nullopt) const

DataFrame

df_dataframe.h:2811

std::ofstream file(path)

std::ofstream

df_dataframe.h:6318

View

std::ofstream file(path, std::ios::binary)

std::ofstream

df_dataframe.h:13506

View

std::ofstream file(path, std::ios::binary)

std::ofstream

df_dataframe.h:14149

View

std::ofstream file(path, std::ios::binary)

std::ofstream

df_dataframe.h:14328

View

std::ofstream file(path_or_buf, std::ios::binary)

std::ofstream

df_dataframe.h:14582

View

std::ofstream file(excel_writer, std::ios::binary)

std::ofstream

df_dataframe.h:15502

View

\* std::ofstream file("output.html")

* std::ofstream

df_dataframe.h:15562

View

\* std::ofstream file("output.tex")

* std::ofstream

df_dataframe.h:15958

View

std::ofstream file(path, std::ios::binary)

std::ofstream

df_dataframe.h:17521

View

\* std::ofstream file("output.md")

* std::ofstream

df_dataframe.h:17793

View

std::ifstream file(path, std::ios::binary \| std::ios::ate)

std::ifstream

df_dataframe.h:19101

View

std::ifstream file(path, std::ios::binary \| std::ios::ate)

std::ifstream

df_dataframe.h:19500

View

std::ifstream file(path, std::ios::binary \| std::ios::ate)

std::ifstream

df_dataframe.h:19955

View

std::ifstream file(con)

std::ifstream

df_dataframe.h:20187

View

std::ifstream file(path, std::ios::binary \| std::ios::ate)

std::ifstream

df_dataframe.h:20399

View

std::ifstream file(path, std::ios::binary \| std::ios::ate)

std::ifstream

df_dataframe.h:20789

View

std::ofstream file(path, std::ios::binary)

std::ofstream

df_dataframe.h:21935

View

DataFrame fillna(double value) const

DataFrame

df_dataframe.h:3512

DataFrame fillna(const std::map<std::string, double>& values) const

DataFrame

df_dataframe.h:3523

void fillna_double(double value) override

void

df_dataframe.h:3265

DataFrame filter(const std::vector<std::string>& items =

DataFrame

df_dataframe.h:6103

View

DataFrame filter_items(const std::vector<std::string>& items) const

DataFrame

df_dataframe.h:1727

DataFrame filter_like(const std::string& like) const

DataFrame

df_dataframe.h:1734

DataFrame first(const std::string& offset) const

DataFrame

df_dataframe.h:12223

View

std::optional<std::string> first_valid_index() const

std::optional<std::string>

df_dataframe.h:6030

const Flags& flags() const override

const Flags&

df_dataframe.h:771

View

insert_sql << format_sql_value(index\_->get_value_str(r), col_types[col_idx])

insert_sql <<

df_dataframe.h:14878

insert_sql << format_sql_value(columns\_[c]->get_value_str(r), col_types[col_idx])

insert_sql <<

df_dataframe.h:14885

insert_sql << format_sql_value(index\_->get_value_str(r), col_types[col_idx])

insert_sql <<

df_dataframe.h:14908

insert_sql << format_sql_value(columns\_[c]->get_value_str(r), col_types[col_idx])

insert_sql <<

df_dataframe.h:14915

oss << format_value(c, r)

oss <<

df_dataframe.h:16265

std::string found(reinterpret_cast<const char\*>(&buffer[pos]), expected_start.size())

std::string

df_dataframe.h:20418

View

std::string found(reinterpret_cast<const char\*>(&buffer[pos]), tag.size())

std::string

df_dataframe.h:20428

View

DataFrame ge(const DataFrame& other) const

DataFrame

df_dataframe.h:8947

std::mt19937 gen(seed == 0 ? std::random_device

std::mt19937

df_dataframe.h:1700

View

DataFrameGroupBy groupby(const std::string& by, bool as_index = true, bool sort = true, bool dropna = true) const

DataFrameGroupBy

df_dataframe.h:11908

DataFrameGroupBy groupby(const std::vector<std::string>& by, bool as_index = true, bool sort = true, bool dropna = true) const

DataFrameGroupBy

df_dataframe.h:11921

DataFrame gt(const DataFrame& other) const

DataFrame

df_dataframe.h:8940

bool has_cached_values() const override

bool

df_dataframe.h:22237

bool has_column(const std::string& name) const

bool

df_dataframe.h:1505

bool hasnans() const override

bool

df_dataframe.h:2746

DataFrame head(size_t n = 5) const

DataFrame

df_dataframe.h:1678

\* Can also be a list of strings to use as column headers (aliases).

* Can also be a list of strings to use as column

df_dataframe.h:14974

T iat(size_t row, size_t col_idx) const

T

df_dataframe.h:1667

numpy::NDArray<numpy::int64> idx_arr(std::vector<size_t>

numpy::NDArray<numpy::int64>

df_dataframe.h:22014

numpy::NDArray<numpy::float64> idx_arr(std::vector<size_t>

numpy::NDArray<numpy::float64>

df_dataframe.h:22022

Series<std::string> idxmax(int axis = 0, bool skipna = true) const

Series<std::string>

df_dataframe.h:4425

Series<std::string> idxmin(int axis = 0, bool skipna = true) const

Series<std::string>

df_dataframe.h:4518

T iloc(size_t row, size_t col_idx) const

T

df_dataframe.h:1562

DataFrame iloc(const std::vector<size_t>& row_indices, const std::vector<size_t>& col_indices) const

DataFrame

df_dataframe.h:1645

DataFrame iloc_cols(const std::vector<size_t>& col_indices) const

DataFrame

df_dataframe.h:1631

DataFrame iloc_row(size_t row) const

DataFrame

df_dataframe.h:1580

DataFrame iloc_rows(size_t start, size_t stop, size_t step = 1) const

DataFrame

df_dataframe.h:1590

DataFrame iloc_rows(const std::vector<size_t>& row_indices) const

DataFrame

df_dataframe.h:1601

const IndexBase& index() const override

const IndexBase&

df_dataframe.h:699

View

\* For hierarchical index (MultiIndex-like structure represented as \* concatenated strings), select rows matching all levels.

* For hierarchical

df_dataframe.h:1811

View

static std::string infer_best_dtype( const std::vector<std::string>& str_values, const std::string& source_dtype, bool convert_string, bool convert_integer, bool convert_boolean, bool convert_floating)

static std::string

df_dataframe.h:9921

DataFrame infer_objects(bool copy = true) const

DataFrame

df_dataframe.h:10206

void info(std::ostream& buf = std::cout, bool verbose = true, size_t max_cols = 0) const

void

df_dataframe.h:12442

View

DataFrame interpolate(const std::string& method = "linear", int axis = 0, std::optional<int> limit = std::nullopt, const std::string& limit_direction = "both") const

DataFrame

df_dataframe.h:2989

interpolate_column(result, c, method, limit, limit_direction)

df_dataframe.h:3015

void interpolate_column(DataFrame& result, size_t col_idx, const std::string& method, std::optional<int> limit, const std::string& limit_direction) const

void

df_dataframe.h:3032

interpolate_row(result, r, method, limit, limit_direction)

df_dataframe.h:3020

void interpolate_row(DataFrame& result, size_t row_idx, const std::string& method, std::optional<int> limit, const std::string& limit_direction) const

void

df_dataframe.h:3145

void isetitem(size_t loc, const std::vector<T>& value)

void

df_dataframe.h:6182

numpy::NDArray<numpy::bool\_> isna() const

numpy::NDArray<numpy::bool_>

df_dataframe.h:3360

numpy::NDArray<numpy::bool\_> isnull() const

numpy::NDArray<numpy::bool_>

df_dataframe.h:5994

std::istringstream iss(eval_expr)

std::istringstream

df_dataframe.h:3840

std::istringstream iss(label)

std::istringstream

df_dataframe.h:7675

std::istringstream iss(label)

std::istringstream

df_dataframe.h:7710

RowsRange iterrows() const

RowsRange

df_dataframe.h:1186

\* and dtype preservation, consider using itertuples() instead.

* and dtype preservation, consider using

df_dataframe.h:1068

\* preservation, use itertuples() instead.

* preservation, use

df_dataframe.h:1162

TuplesRange itertuples(bool index = true, const std::string& name = "Pandas") const

TuplesRange

df_dataframe.h:1411

DataFrame join( const DataFrame& other, const std::string& how = "left", const std::string& lsuffix = "", const std::string& rsuffix = "_r", bool sort = false) const

DataFrame

df_dataframe.h:11475

View

const Index<std::string>& keys() const

const Index<std::string>&

df_dataframe.h:933

View

\* Returns a dictionary with five keys (superset of 'split'):

* Returns a dictionary with five

df_dataframe.h:12874

View

Series<numpy::float64> kurt(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5619

Series<numpy::float64> kurt_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4753

Series<numpy::float64> kurtosis(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5673

View

\* Returns the row label (index) where the maximum value occurs for each column.

* Returns the row

df_dataframe.h:4413

\* Returns the row label (index) where the minimum value occurs for each column.

* Returns the row

df_dataframe.h:4506

\* over the column labels (info axis).

* over the column

df_dataframe.h:822

DataFrame last(const std::string& offset) const

DataFrame

df_dataframe.h:12230

std::optional<std::string> last_valid_index() const

std::optional<std::string>

df_dataframe.h:6050

DataFrame le(const DataFrame& other) const

DataFrame

df_dataframe.h:8933

std::vector<std::vector<std::string>> level_arrays(col_names.size())

std::vector<std::vector<std::string>>

df_dataframe.h:6614

\* innermost levels (i=-2, j=-1). Hierarchical indices are represented

* innermost

df_dataframe.h:7875

View

T loc(const std::string& row_label, const std::string& col_label) const

T

df_dataframe.h:1517

DataFrame loc(const std::vector<std::string>& row_labels, const std::vector<std::string>& col_labels) const

DataFrame

df_dataframe.h:1548

DataFrame loc_row(const std::string& row_label) const

DataFrame

df_dataframe.h:1526

DataFrame loc_rows(const std::vector<std::string>& row_labels) const

DataFrame

df_dataframe.h:1534

DataFrame lt(const DataFrame& other) const

DataFrame

df_dataframe.h:8926

\* map() applies the function to every individual element.

*

df_dataframe.h:9550

DataFrame map(Func&& func, const std::string& na_action = "") const

DataFrame

df_dataframe.h:9562

\* This is the inverse of where(): mask(cond, other) == where(!cond, other)

* This is the inverse of where():

df_dataframe.h:3607

View

DataFrame mask(const DataFrame& cond, double other = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:3617

View

DataFrame melt(const std::vector<std::string>& id_vars, const std::vector<std::string>& value_vars =

DataFrame

df_dataframe.h:8538

Series<numpy::int64> memory_usage(bool index = true, bool deep = false) const

Series<numpy::int64>

df_dataframe.h:12552

size_t memory_usage_total(bool deep = false) const

size_t

df_dataframe.h:12597

DataFrame merge( const DataFrame& right, const std::string& how = "inner", const std::vector<std::string>& on =

DataFrame

df_dataframe.h:11311

DataFrame merge( const DataFrame& right, const std::string& how, const std::string& on, const std::pair<std::string, std::string>& suffixes =

DataFrame

df_dataframe.h:11459

DataFrame mul(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:8984

DataFrame mul(double scalar) const

DataFrame

df_dataframe.h:8988

MultiIndex multi_idx(std::move(levels), std::move(codes), level_names)

MultiIndex

df_dataframe.h:6664

std::string name(reinterpret_cast<const char\*>(&buffer[pos + 30]), name_len)

std::string

df_dataframe.h:19156

View

\* with hierarchical column names (original_col_func_name).

* with hierarchical column

df_dataframe.h:10764

View

size_t nbytes() const override

size_t

df_dataframe.h:637

View

size_t ncols() const

size_t

df_dataframe.h:678

size_t ndim() const override

size_t

df_dataframe.h:630

View

DataFrame ne(const DataFrame& other) const

DataFrame

df_dataframe.h:8919

DataFrame nlargest(size_t n, const std::string& column) const

DataFrame

df_dataframe.h:7348

numpy::NDArray<numpy::bool\_> notna() const

numpy::NDArray<numpy::bool_>

df_dataframe.h:3375

numpy::NDArray<numpy::bool\_> notnull() const

numpy::NDArray<numpy::bool_>

df_dataframe.h:6002

size_t nrows() const

size_t

df_dataframe.h:671

DataFrame nsmallest(size_t n, const std::string& column) const

DataFrame

df_dataframe.h:7356

Series<numpy::int64> nunique(int axis = 0, bool dropna = true) const

Series<numpy::int64>

df_dataframe.h:6403

Series<numpy::int64> nunique_cols(bool dropna = true) const

Series<numpy::int64>

df_dataframe.h:6358

std::istringstream obj_stream(obj_str)

std::istringstream

df_dataframe.h:19020

\* Series objects (as NDFrameBase pointers for type-erasure).

* Series

df_dataframe.h:12940

View

\* a generator of (label, content) pairs.

* a generator

df_dataframe.h:1027

View

DataFrame pad(int axis = 0, std::optional<int> limit = std::nullopt) const

DataFrame

df_dataframe.h:6022

View

oss << pad_string(idx_header, widths[0], alignments[0]) << " "

oss <<

df_dataframe.h:18020

oss << pad_string(columns_index\_.get_value_str(c), widths[w_idx], alignments[w_idx])

oss <<

df_dataframe.h:18024

oss << pad_string(index\_->get_value_str(r), widths[0], alignments[0]) << " "

oss <<

df_dataframe.h:18043

oss << pad_string(val, widths[w_idx], alignments[w_idx])

oss <<

df_dataframe.h:18053

oss << pad_string(idx_header, widths[0], alignments[0]) << " "

oss <<

df_dataframe.h:18064

oss << pad_string(columns_index\_.get_value_str(c), widths[w_idx], alignments[w_idx])

oss <<

df_dataframe.h:18068

oss << pad_string(index\_->get_value_str(r), widths[0], alignments[0]) << " "

oss <<

df_dataframe.h:18076

oss << pad_string(val, widths[w_idx], alignments[w_idx])

oss <<

df_dataframe.h:18086

pad_to_8(body_buffer)

df_dataframe.h:21147

pad_to_8(body_buffer)

df_dataframe.h:21258

pad_to_8(body_buffer)

df_dataframe.h:21271

pad_to_8(feather_bytes)

df_dataframe.h:21868

std::vector<std::pair<std::string, numpy::int64>> pairs(counts.begin(), counts.end())

std::vector<std::pair<std::string, numpy::int64>>

df_dataframe.h:6570

View

query::QueryExpression parsed(expr)

query::QueryExpression

df_dataframe.h:3675

DataFrame pct_change(int periods = 1) const

DataFrame

df_dataframe.h:7260

\* PeriodIndex period_idx(

* PeriodIndex

df_dataframe.h:12036

auto pipe(Func&& func, Args&&... args) const

auto

df_dataframe.h:11013

DataFrame pivot(const std::string& index_col, const std::string& columns_col, const std::string& values_col) const

DataFrame

df_dataframe.h:8094

DataFrame pivot_table(const std::string& values, const std::string& index, const std::string& columns, const std::string& aggfunc = "mean", double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:8165

DataFrame pivot_table(const std::vector<std::string>& values, const std::vector<std::string>& index, const std::string& columns, const std::string& aggfunc = "mean", double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:8186

DataFrame pivot_table_with_margins( const std::string& values, const std::string& index, const std::string& columns, const std::string& aggfunc = "mean", double fill_value = std::numeric_limits<double>::quiet_NaN(), bool margins = false, const std::string& margins_name = "All" ) const

DataFrame

df_dataframe.h:8363

DataFrame pivot_table_with_margins( const std::vector<std::string>& values, const std::vector<std::string>& index, const std::string& columns, const std::string& aggfunc = "mean", double fill_value = std::numeric_limits<double>::quiet_NaN(), bool margins = false, const std::string& margins_name = "All" ) const

DataFrame

df_dataframe.h:8390

DataFrame pow(const DataFrame& other) const

DataFrame

df_dataframe.h:9044

View

DataFrame pow(double exponent) const

DataFrame

df_dataframe.h:9048

View

\* to specify which axis to prefix (0 for index, 1 for columns).

* to specify which axis to

df_dataframe.h:2307

View

Series<numpy::float64> prod(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5214

View

Series<numpy::float64> prod_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:5168

Series<numpy::float64> product(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5791

View

\* empty vector if path is provided (file written to disk).

* empty vector if path is

df_dataframe.h:12980

DataFrame query(const std::string& expr) const

DataFrame

df_dataframe.h:3673

DataFrame radd(const DataFrame& other, double fill_value = 0.0) const

DataFrame

df_dataframe.h:9066

DataFrame radd(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9071

DataFrame rank(int axis = 0, const std::string& method = "average", bool ascending = true, const std::string& na_option = "keep", bool pct = false) const

DataFrame

df_dataframe.h:7370

DataFrame rdiv(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9135

DataFrame rdiv(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9139

std::regex re(regex)

std::regex

df_dataframe.h:6115

std::regex re(regex)

std::regex

df_dataframe.h:6142

static DataFrame read_csv( const std::string& csv_data, char sep = ',', bool header = true, const std::string& index_col = "")

static DataFrame

df_dataframe.h:18779

static DataFrame read_excel( const std::string& path, const std::string& sheet_name = "Sheet1", int header = 0, const std::vector<std::string>& usecols =

static DataFrame

df_dataframe.h:19093

static DataFrame read_feather( const std::string& path, [[maybe_unused]] const std::vector<std::string>& columns =

static DataFrame

df_dataframe.h:20784

static DataFrame read_hdf( const std::string& path, [[maybe_unused]] const std::string& key = "")

static DataFrame

df_dataframe.h:19950

static DataFrame read_json( const std::string& json_data, const std::string& orient = "columns")

static DataFrame

df_dataframe.h:18930

static DataFrame read_parquet( const std::string& path, const std::vector<std::string>& columns =

static DataFrame

df_dataframe.h:19495

static DataFrame read_sql( [[maybe_unused]] const std::string& sql, const std::string& con, [[maybe_unused]] const std::vector<std::string>& columns =

static DataFrame

df_dataframe.h:20181

static DataFrame read_stata( const std::string& path, [[maybe_unused]] bool convert_dates = true)

static DataFrame

df_dataframe.h:20394

DataFrame reindex(const std::vector<std::string>& labels, int axis = 0, double fill_value = std::nan("")) const

DataFrame

df_dataframe.h:2175

DataFrame reindex_by_indexer( const numpy::NDArray<numpy::int64>& indexer, const Index<std::string>& new_index, double fill_value) const

DataFrame

df_dataframe.h:12273

DataFrame reindex_like(const DataFrame& other) const

DataFrame

df_dataframe.h:2410

DataFrame rename(const std::map<std::string, std::string>& mapper, int axis = 0) const

DataFrame

df_dataframe.h:2146

DataFrame rename_axis(const std::string& name, int axis = 0) const

DataFrame

df_dataframe.h:2284

DataFrame rename_columns(const std::map<std::string, std::string>& mapper) const

DataFrame

df_dataframe.h:2124

DataFrame reorder_levels(const std::vector<int>& order, int axis = 0) const

DataFrame

df_dataframe.h:7775

DataFrame reorder_levels(const std::vector<int>& order, const std::string& axis) const

DataFrame

df_dataframe.h:7826

DataFrame reorder_levels(const std::vector<std::string>& order, int axis = 0) const

DataFrame

df_dataframe.h:7849

DataFrame reorder_levels_columns(const std::vector<size_t>& order) const

DataFrame

df_dataframe.h:8051

static std::string reorder_levels_in_label(const std::string& label, const std::vector<size_t>& order)

static std::string

df_dataframe.h:7708

DataFrame reorder_levels_index(const std::vector<size_t>& order) const

DataFrame

df_dataframe.h:8024

DataFrame replace(double to_replace, double value) const

DataFrame

df_dataframe.h:3540

View

void replace_value(double to_replace, double value) override

void

df_dataframe.h:3275

std::string repr() const override

std::string

df_dataframe.h:22218

\* representation (default: true). Currently unused.

*

df_dataframe.h:15531

View

\* representation (default: true). Currently unused.

*

df_dataframe.h:15925

View

DataFrameResampler resample(const std::string& freq, const std::string& closed = "left", const std::string& label = "left") const

DataFrameResampler

df_dataframe.h:11952

void reset_index(bool drop) override

void

df_dataframe.h:2096

numpy::RecordArray result(struct_dtype,

numpy::RecordArray

df_dataframe.h:16454

View

DataFrame rfloordiv(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9165

DataFrame rfloordiv(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9169

DataFrame rmod(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9187

DataFrame rmod(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9191

DataFrame rmul(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9112

DataFrame rmul(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9117

\* Provides rolling (moving) window aggregation methods for DataFrames.

* Provides

df_dataframe.h:5802

DataFrameRolling rolling(size_t window, size_t min_periods = 1, bool center = false) const

DataFrameRolling

df_dataframe.h:5962

DataFrame rpow(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9209

DataFrame rpow(double base, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9213

DataFrame rsub(const DataFrame& other, double fill_value = 0.0) const

DataFrame

df_dataframe.h:9090

DataFrame rsub(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9094

DataFrame rtruediv(const DataFrame& other, double fill_value = 1.0) const

DataFrame

df_dataframe.h:9147

DataFrame rtruediv(double scalar, double fill_value = std::numeric_limits<double>::quiet_NaN()) const

DataFrame

df_dataframe.h:9151

DataFrame scalar_op(double scalar, BinaryOp op) const

DataFrame

df_dataframe.h:22319

DataFrame scalar_op_with_fill(double scalar, double fill_value, BinaryOp op) const

DataFrame

df_dataframe.h:22345

Series<numpy::float64> sem(int axis = 0, bool skipna = true, int ddof = 1, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5525

Series<numpy::float64> sem_cols(bool skipna = true, int ddof = 1) const

Series<numpy::float64>

df_dataframe.h:4699

\* sequences (default: true).

*

df_dataframe.h:15544

View

void set_attrs(const Attrs& attrs) override

void

df_dataframe.h:764

DataFrame set_axis(const std::vector<std::string>& labels, int axis = 0) const

DataFrame

df_dataframe.h:2245

set_field_value(r, field.first, field.second, index\_->get_value_str(r))

df_dataframe.h:16530

set_field_value(r, field.first, field.second, columns\_[c]->get_value_str(r))

df_dataframe.h:16537

void set_flags(const Flags& flags) override

void

df_dataframe.h:778

void set_index(std::unique_ptr<IndexBase> new_index) override

void

df_dataframe.h:2060

DataFrame set_index_col(const std::string& col_name, bool drop = true) const

DataFrame

df_dataframe.h:2073

void set_value_double(size_t idx, double value) override

void

df_dataframe.h:3317

void set_value_nan(size_t idx) override

void

df_dataframe.h:3301

std::vector<size_t> shape() const override

std::vector<size_t>

df_dataframe.h:623

View

DataFrame shift(int periods = 1, int axis = 0) const

DataFrame

df_dataframe.h:9432

View

size_t size() const override

size_t

df_dataframe.h:609

View

Series<numpy::float64> skew(int axis = 0, bool skipna = true, bool numeric_only = false) const

Series<numpy::float64>

df_dataframe.h:5566

View

Series<numpy::float64> skew_cols(bool skipna = true) const

Series<numpy::float64>

df_dataframe.h:4715

\* represent time spans (periods) rather than time points.

* represent time

df_dataframe.h:11973

\* Format specification (simplified):

* Format

df_dataframe.h:14406

std::ofstream sql_file(sql_file_path)

std::ofstream

df_dataframe.h:14936

std::stringstream ss(val)

std::stringstream

df_dataframe.h:8625

View

std::string str(reinterpret_cast<const char\*>(&buffer[pos]), len)

std::string

df_dataframe.h:20017

View

numpy::str64 str_field(str_val)

numpy::str64

df_dataframe.h:16511

numpy::str64 str_field(str_val)

numpy::str64

df_dataframe.h:16518

std::istringstream stream(csv_data)

std::istringstream

df_dataframe.h:18786

\* If empty string (default), passes NaN to func like any other value.

* If empty

df_dataframe.h:9546

View

inline Styler style() const

inline Styler

df_dataframe.h:22483

DataFrame sub(const DataFrame& other, double fill_value = 0.0) const

DataFrame

df_dataframe.h:8969

DataFrame sub(double scalar) const

DataFrame

df_dataframe.h:8973

\* to specify which axis to suffix (0 for index, 1 for columns).

* to specify which axis to

df_dataframe.h:2352

DataFrame swaplevel(int i = -2, int j = -1, int axis = 0) const

DataFrame

df_dataframe.h:7912

DataFrame swaplevel(int i, int j, const std::string& axis) const

DataFrame

df_dataframe.h:7960

DataFrame swaplevel(const std::string& i, const std::string& j, int axis = 0) const

DataFrame

df_dataframe.h:7983

DataFrame tail(size_t n = 5) const

DataFrame

df_dataframe.h:1686

DataFrame transform(Func&& func, int axis = 0) const

DataFrame

df_dataframe.h:10615

DataFrame transform(const std::string& func_name, int axis = 0) const

DataFrame

df_dataframe.h:10713

DataFrame transform(const std::vector<std::string>& func_names, int axis = 0) const

DataFrame

df_dataframe.h:10777

DataFrame transform(const std::map<std::string, std::string>& col_func_map, int axis = 0) const

DataFrame

df_dataframe.h:10817

DataFrame transform(const std::map<std::string, std::vector<std::string>>& col_funcs_map, int axis = 0) const

DataFrame

df_dataframe.h:10866

DataFrame truediv(const DataFrame& other) const

DataFrame

df_dataframe.h:9011

DataFrame truediv(double scalar) const

DataFrame

df_dataframe.h:9015

DataFrame tz_convert(const std::string& tz, int axis = 0, int level = -1, bool copy = true) const

DataFrame

df_dataframe.h:12106

View

\* use tz_convert() to change timezones.

* use

df_dataframe.h:12160

View

\* use tz_localize() first to assign a timezone.

* use

df_dataframe.h:12102

View

DataFrame tz_localize(const std::string& tz, int axis = 0, int level = -1, bool copy = true, const std::string& ambiguous = "raise", const std::string& nonexistent = "raise") const

DataFrame

df_dataframe.h:12164

View

DataFrame unary_op(UnaryOp op) const

DataFrame

df_dataframe.h:22293

DataFrame unstack() const

DataFrame

df_dataframe.h:8708

\* Currently unused (no MultiIndex column support yet).

* Currently

df_dataframe.h:15935

View

void update(const DataFrame& other, bool overwrite = true)

void

df_dataframe.h:11791

\* Series<double> v(

* Series<double>

df_dataframe.h:8860

View

\* Can be a single value (applies to all) or per-column values.

* Can be a single

df_dataframe.h:15524

View

std::variant<Series<numpy::int64>, Series<numpy::float64>> value_counts( const std::vector<std::string>& subset =

std::variant<Series<numpy::int64>, Series<numpy::float64>>

df_dataframe.h:6490

numpy::NDArray<numpy::float64> values() const

numpy::NDArray<numpy::float64>

df_dataframe.h:730

View

\* missing values (NA). It analyzes the data in each column and infers the

* missing

df_dataframe.h:10028

View

\* Provides exponential weighted (EWM) aggregation methods for DataFrames.

* Provides exponential

df_dataframe.h:5909

\* object implementing a binary write() function. If empty, returns

* object implementing a binary

df_dataframe.h:14169

View

write_byte(static_cast<uint8_t>(data_label.length()))

df_dataframe.h:16978

write_byte(static_cast<uint8_t>(c))

df_dataframe.h:16981

write_byte(static_cast<uint8_t>(ts.length()))

df_dataframe.h:16997

write_byte(static_cast<uint8_t>(c))

df_dataframe.h:16999

write_byte(static_cast<uint8_t>(missing_int8))

df_dataframe.h:17139

write_byte(static_cast<uint8_t>(static_cast<int8_t>(val)))

df_dataframe.h:17142

write_byte(0)

df_dataframe.h:17236

write_byte(0)

df_dataframe.h:17237

write_byte(0)

df_dataframe.h:17238

write_byte(static_cast<uint8_t>(c))

df_dataframe.h:17261

write_byte(big_endian ? 0x01 : 0x02)

df_dataframe.h:17302

write_byte(0x01)

df_dataframe.h:17305

write_byte(0x00)

df_dataframe.h:17308

write_byte(static_cast<uint8_t>(col.stata_type))

df_dataframe.h:17335

write_byte(static_cast<uint8_t>(col.stata_type))

df_dataframe.h:17337

write_byte(0x00)

df_dataframe.h:17376

write_byte(static_cast<uint8_t>(missing_int8))

df_dataframe.h:17424

write_byte(static_cast<uint8_t>(static_cast<int8_t>(val)))

df_dataframe.h:17427

write_byte(0)

df_dataframe.h:17495

write_byte(static_cast<uint8_t>(c))

df_dataframe.h:17509

write_byte(0)

df_dataframe.h:17511

write_field_header(page_header, 1, THRIFT_I32, prev_fid)

df_dataframe.h:13806

write_field_header(page_header, 2, THRIFT_I32, prev_fid)

df_dataframe.h:13810

write_field_header(page_header, 3, THRIFT_I32, prev_fid)

df_dataframe.h:13814

write_field_header(page_header, 5, THRIFT_STRUCT, prev_fid)

df_dataframe.h:13818

write_field_header(page_header, 1, THRIFT_I32, prev_dph)

df_dataframe.h:13822

write_field_header(page_header, 2, THRIFT_I32, prev_dph)

df_dataframe.h:13825

write_field_header(page_header, 3, THRIFT_I32, prev_dph)

df_dataframe.h:13828

write_field_header(page_header, 4, THRIFT_I32, prev_dph)

df_dataframe.h:13831

write_field_header(page_header, 1, THRIFT_I32, prev_fid)

df_dataframe.h:13949

write_field_header(page_header, 2, THRIFT_I32, prev_fid)

df_dataframe.h:13953

write_field_header(page_header, 3, THRIFT_I32, prev_fid)

df_dataframe.h:13957

write_field_header(page_header, 5, THRIFT_STRUCT, prev_fid)

df_dataframe.h:13961

write_field_header(page_header, 1, THRIFT_I32, prev_dph)

df_dataframe.h:13964

write_field_header(page_header, 2, THRIFT_I32, prev_dph)

df_dataframe.h:13966

write_field_header(page_header, 3, THRIFT_I32, prev_dph)

df_dataframe.h:13968

write_field_header(page_header, 4, THRIFT_I32, prev_dph)

df_dataframe.h:13970

write_field_header(metadata, 1, THRIFT_I32, prev_fid)

df_dataframe.h:13996

write_field_header(metadata, 2, THRIFT_LIST, prev_fid)

df_dataframe.h:14000

write_field_header(metadata, 4, THRIFT_BINARY, prev_se)

df_dataframe.h:14008

write_field_header(metadata, 6, THRIFT_I32, prev_se)

df_dataframe.h:14011

write_field_header(metadata, 1, THRIFT_I32, prev_se)

df_dataframe.h:14020

write_field_header(metadata, 4, THRIFT_BINARY, prev_se)

df_dataframe.h:14023

write_field_header(metadata, 7, THRIFT_I32, prev_se)

df_dataframe.h:14027

write_field_header(metadata, 3, THRIFT_I64, prev_fid)

df_dataframe.h:14033

write_field_header(metadata, 4, THRIFT_LIST, prev_fid)

df_dataframe.h:14037

write_field_header(metadata, 1, THRIFT_LIST, prev_rg)

df_dataframe.h:14045

write_field_header(metadata, 2, THRIFT_I64, prev_cc)

df_dataframe.h:14052

write_field_header(metadata, 3, THRIFT_STRUCT, prev_cc)

df_dataframe.h:14056

write_field_header(metadata, 1, THRIFT_I32, prev_cm)

df_dataframe.h:14061

write_field_header(metadata, 2, THRIFT_LIST, prev_cm)

df_dataframe.h:14065

write_field_header(metadata, 3, THRIFT_LIST, prev_cm)

df_dataframe.h:14070

write_field_header(metadata, 4, THRIFT_I32, prev_cm)

df_dataframe.h:14075

write_field_header(metadata, 5, THRIFT_I64, prev_cm)

df_dataframe.h:14079

write_field_header(metadata, 6, THRIFT_I64, prev_cm)

df_dataframe.h:14083

write_field_header(metadata, 7, THRIFT_I64, prev_cm)

df_dataframe.h:14087

write_field_header(metadata, 9, THRIFT_I64, prev_cm)

df_dataframe.h:14091

write_field_header(metadata, 2, THRIFT_I64, prev_rg)

df_dataframe.h:14101

write_field_header(metadata, 3, THRIFT_I64, prev_rg)

df_dataframe.h:14105

write_field_header(metadata, 5, THRIFT_LIST, prev_fid)

df_dataframe.h:14112

write_field_header(metadata, 1, THRIFT_BINARY, prev_kv)

df_dataframe.h:14116

write_field_header(metadata, 2, THRIFT_BINARY, prev_kv)

df_dataframe.h:14118

write_field_header(metadata, 6, THRIFT_BINARY, prev_fid)

df_dataframe.h:14124

write_flatbuf_string(fields_data, name)

df_dataframe.h:21359

write_float32(missing_f)

df_dataframe.h:17165

write_float32(static_cast<float>(val))

df_dataframe.h:17168

write_float32(missing_f)

df_dataframe.h:17447

write_float32(static_cast<float>(val))

df_dataframe.h:17450

write_float64(val)

df_dataframe.h:17125

write_float64(missing_d)

df_dataframe.h:17175

write_float64(stata_ms)

df_dataframe.h:17181

write_float64(val)

df_dataframe.h:17184

write_float64(val)

df_dataframe.h:17413

write_float64(missing_d)

df_dataframe.h:17456

write_float64(stata_ms)

df_dataframe.h:17461

write_float64(val)

df_dataframe.h:17464

write_int16(missing_int16)

df_dataframe.h:17147

write_int16(static_cast<int16_t>(val))

df_dataframe.h:17150

write_int16(static_cast<int16_t>(nvar))

df_dataframe.h:17311

write_int16(0)

df_dataframe.h:17352

write_int16(missing_int16)

df_dataframe.h:17431

write_int16(static_cast<int16_t>(val))

df_dataframe.h:17434

write_int32(missing_int32)

df_dataframe.h:17118

write_int32(static_cast<int32_t>(val))

df_dataframe.h:17120

write_int32(missing_int32)

df_dataframe.h:17155

write_int32(static_cast<int32_t>(val))

df_dataframe.h:17158

write_int32(lbl_len)

df_dataframe.h:17230

write_int32(static_cast<int32_t>(labels.size()))

df_dataframe.h:17241

write_int32(static_cast<int32_t>(txt_len))

df_dataframe.h:17244

write_int32(offset)

df_dataframe.h:17249

write_int32(val)

df_dataframe.h:17255

write_int32(static_cast<int32_t>(nobs))

df_dataframe.h:17314

write_int32(static_cast<int32_t>(val))

df_dataframe.h:17410

write_int32(missing_int32)

df_dataframe.h:17438

write_int32(static_cast<int32_t>(val))

df_dataframe.h:17441

write_int32(lbl_len)

df_dataframe.h:17493

write_int32(static_cast<int32_t>(labels.size()))

df_dataframe.h:17496

write_int32(static_cast<int32_t>(txt_len))

df_dataframe.h:17497

write_int32(offset)

df_dataframe.h:17501

write_int32(val)

df_dataframe.h:17505

write_int64(range_idx->start())

df_dataframe.h:14279

write_int64(range_idx->stop())

df_dataframe.h:14280

write_int64(range_idx->step())

df_dataframe.h:14281

write_int64(range_idx->start())

df_dataframe.h:14525

write_int64(range_idx->stop())

df_dataframe.h:14526

write_int64(range_idx->step())

df_dataframe.h:14527

write_int64(static_cast<int64_t>(nobs))

df_dataframe.h:16966

write_le32(body_buffer, static_cast<int32_t>(val))

df_dataframe.h:21173

write_le32(body_buffer, static_cast<int32_t>(bits))

df_dataframe.h:21195

write_le32(body_buffer, current_offset)

df_dataframe.h:21252

write_le32(body_buffer, current_offset)

df_dataframe.h:21255

write_le32(fields_data, bit_width)

df_dataframe.h:21370

write_le32(feather_bytes, metadata_size)

df_dataframe.h:21766

write_le32(feather_bytes, static_cast<int32_t>(rb_message.size()))

df_dataframe.h:21862

write_le32(feather_bytes, footer_size)

df_dataframe.h:21927

write_le64(body_buffer, val)

df_dataframe.h:21175

write_le64(body_buffer, static_cast<int64_t>(bits))

df_dataframe.h:21209

write_le64(body_buffer, val)

df_dataframe.h:21237

write_list_header(metadata, column_chunks.size(), THRIFT_STRUCT)

df_dataframe.h:14046

write_list_header(metadata, 1, THRIFT_I32)

df_dataframe.h:14066

write_list_header(metadata, 1, THRIFT_BINARY)

df_dataframe.h:14071

write_list_header(metadata, 1, THRIFT_STRUCT)

df_dataframe.h:14113

write_string(metadata, "schema")

df_dataframe.h:14009

write_string(metadata, column_chunks[i].col_name)

df_dataframe.h:14024

write_string(metadata, cc.col_name)

df_dataframe.h:14072

write_string(metadata, "pandas")

df_dataframe.h:14117

write_string(metadata, "

df_dataframe.h:14119

write_string(metadata, "PandasCore C++ Library")

df_dataframe.h:14125

write_string(range_idx->name().value())

df_dataframe.h:14283

write_string(index\_->get_value_str(i))

df_dataframe.h:14292

write_string(index\_->name().value())

df_dataframe.h:14296

write_string(columns_index\_.get_value_str(c))

df_dataframe.h:14307

write_string(dtype)

df_dataframe.h:14311

write_string(val_str)

df_dataframe.h:14322

write_string(key)

df_dataframe.h:14510

write_string(range_idx->name().value())

df_dataframe.h:14529

write_string(index\_->get_value_str(i))

df_dataframe.h:14538

write_string(index\_->name().value())

df_dataframe.h:14542

write_string(columns_index\_.get_value_str(c))

df_dataframe.h:14554

write_string(dtype)

df_dataframe.h:14558

write_string(val_str)

df_dataframe.h:14567

write_string(name, varname_len)

df_dataframe.h:17029

write_string(col.format, format_len)

df_dataframe.h:17045

write_string(col.name, varname_len)

df_dataframe.h:17055

write_string("", varname_len)

df_dataframe.h:17057

write_string(col.label, varlabel_len)

df_dataframe.h:17066

write_string(idx_str, col.stata_type)

df_dataframe.h:17128

write_string(val, col.stata_type)

df_dataframe.h:17189

write_string(col.name, varname_len)

df_dataframe.h:17233

write_string(data_label, 81)

df_dataframe.h:17317

write_string(ts, 18)

df_dataframe.h:17329

write_string(name, 33)

df_dataframe.h:17347

write_string(col.format, 49)

df_dataframe.h:17357

write_string(col.name, 33)

df_dataframe.h:17363

write_string("", 33)

df_dataframe.h:17365

write_string(col.label, 81)

df_dataframe.h:17371

write_string(idx_str, col.stata_type)

df_dataframe.h:17415

write_string(val, col.stata_type)

df_dataframe.h:17468

write_string(col.name, 33)

df_dataframe.h:17494

write_tag("<stata_dta>")

df_dataframe.h:16941

write_tag("<header>")

df_dataframe.h:16942

write_tag("<release>")

df_dataframe.h:16945

write_tag(std::to_string(version))

df_dataframe.h:16946

write_tag("</release>")

df_dataframe.h:16947

write_tag("<byteorder>")

df_dataframe.h:16950

write_tag(big_endian ? "MSF" : "LSF")

df_dataframe.h:16951

write_tag("</byteorder>")

df_dataframe.h:16952

write_tag("<K>")

df_dataframe.h:16955

write_tag("</K>")

df_dataframe.h:16961

write_tag("<N>")

df_dataframe.h:16964

write_tag("</N>")

df_dataframe.h:16970

write_tag("<label>")

df_dataframe.h:16973

write_tag("</label>")

df_dataframe.h:16983

write_tag("<timestamp>")

df_dataframe.h:16986

write_tag("</timestamp>")

df_dataframe.h:17001

write_tag("</header>")

df_dataframe.h:17003

write_tag("<map>")

df_dataframe.h:17007

write_tag("</map>")

df_dataframe.h:17011

write_tag("<variable_types>")

df_dataframe.h:17015

write_tag("</variable_types>")

df_dataframe.h:17019

write_tag("<varnames>")

df_dataframe.h:17023

write_tag("</varnames>")

df_dataframe.h:17031

write_tag("<sortlist>")

df_dataframe.h:17035

write_tag("</sortlist>")

df_dataframe.h:17039

write_tag("<formats>")

df_dataframe.h:17043

write_tag("</formats>")

df_dataframe.h:17047

write_tag("<value_label_names>")

df_dataframe.h:17051

write_tag("</value_label_names>")

df_dataframe.h:17060

write_tag("<variable_labels>")

df_dataframe.h:17064

write_tag("</variable_labels>")

df_dataframe.h:17068

write_tag("<characteristics>")

df_dataframe.h:17072

write_tag("</characteristics>")

df_dataframe.h:17073

write_tag("<data>")

df_dataframe.h:17077

write_tag("</data>")

df_dataframe.h:17194

write_tag("<strls>")

df_dataframe.h:17198

write_tag("</strls>")

df_dataframe.h:17199

write_tag("<value_labels>")

df_dataframe.h:17203

write_tag("<lbl>")

df_dataframe.h:17214

write_tag("</lbl>")

df_dataframe.h:17266

write_tag("</value_labels>")

df_dataframe.h:17271

write_tag("</stata_dta>")

df_dataframe.h:17275

write_uint16(nvar)

df_dataframe.h:16959

write_uint16(static_cast<uint16_t>(data_label.length()))

df_dataframe.h:16976

write_uint16(col.stata_type)

df_dataframe.h:17017

write_uint16(0)

df_dataframe.h:17037

write_uint32(static_cast<uint32_t>(str.size()))

df_dataframe.h:14267

write_uint32(0)

df_dataframe.h:14298

write_uint32(static_cast<uint32_t>(ncols()))

df_dataframe.h:14303

write_uint32(static_cast<uint32_t>(str.size()))

df_dataframe.h:14503

write_uint32(0)

df_dataframe.h:14544

write_uint32(static_cast<uint32_t>(ncols()))

df_dataframe.h:14550

write_uint32(static_cast<uint32_t>(nvar))

df_dataframe.h:16957

write_uint32(static_cast<uint32_t>(nobs))

df_dataframe.h:16968

write_uint64(index\_->size())

df_dataframe.h:14290

write_uint64(n)

df_dataframe.h:14315

write_uint64(index\_->size())

df_dataframe.h:14536

write_uint64(n)

df_dataframe.h:14562

write_varint(encoded)

df_dataframe.h:13066

write_varint(data.size())

df_dataframe.h:13081

write_varint(str.size())

df_dataframe.h:13087

write_zigzag_to(page_header, 0)

df_dataframe.h:13807

write_zigzag_to(page_header, static_cast<int64_t>(page_data.size()))

df_dataframe.h:13811

write_zigzag_to(page_header, static_cast<int64_t>(page_data.size()))

df_dataframe.h:13815

write_zigzag_to(page_header, static_cast<int64_t>(nrows()))

df_dataframe.h:13823

write_zigzag_to(page_header, ENCODING_PLAIN)

df_dataframe.h:13826

write_zigzag_to(page_header, ENCODING_PLAIN)

df_dataframe.h:13829

write_zigzag_to(page_header, ENCODING_PLAIN)

df_dataframe.h:13832

write_zigzag_to(page_header, 0)

df_dataframe.h:13950

write_zigzag_to(page_header, static_cast<int64_t>(page_data.size()))

df_dataframe.h:13954

write_zigzag_to(page_header, static_cast<int64_t>(page_data.size()))

df_dataframe.h:13958

write_zigzag_to(page_header, static_cast<int64_t>(nrows()))

df_dataframe.h:13965

write_zigzag_to(page_header, ENCODING_PLAIN)

df_dataframe.h:13967

write_zigzag_to(page_header, ENCODING_PLAIN)

df_dataframe.h:13969

write_zigzag_to(page_header, ENCODING_PLAIN)

df_dataframe.h:13971

write_zigzag_to(metadata, static_cast<int64_t>(total_cols))

df_dataframe.h:14012

write_zigzag_to(metadata, column_chunks[i].parquet_type)

df_dataframe.h:14021

write_zigzag_to(metadata, static_cast<int64_t>(nrows()))

df_dataframe.h:14034

write_zigzag_to(metadata, cc.file_offset)

df_dataframe.h:14053

write_zigzag_to(metadata, cc.parquet_type)

df_dataframe.h:14062

write_zigzag_to(metadata, ENCODING_PLAIN)

df_dataframe.h:14067

write_zigzag_to(metadata, COMPRESSION_UNCOMPRESSED)

df_dataframe.h:14076

write_zigzag_to(metadata, cc.num_values)

df_dataframe.h:14080

write_zigzag_to(metadata, cc.total_size)

df_dataframe.h:14084

write_zigzag_to(metadata, cc.total_size)

df_dataframe.h:14088

write_zigzag_to(metadata, cc.file_offset)

df_dataframe.h:14092

write_zigzag_to(metadata, row_group_total_size)

df_dataframe.h:14102

write_zigzag_to(metadata, static_cast<int64_t>(nrows()))

df_dataframe.h:14106

std::string xml(entry.data.begin(), entry.data.end())

std::string

df_dataframe.h:19175

std::string xml(entry.data.begin(), entry.data.end())

std::string

df_dataframe.h:19225

std::string xml(entry.data.begin(), entry.data.end())

std::string

df_dataframe.h:19265

DataFrame xs(const std::string& key, int axis = 0, bool drop_level = true) const

DataFrame

df_dataframe.h:1775

DataFrame xs(const std::string& key, const std::string& axis, bool drop_level = true) const

DataFrame

df_dataframe.h:1796

DataFrame xs(const std::vector<std::string>& keys, int axis = 0, const std::vector<size_t>& levels =

DataFrame

df_dataframe.h:1826

DataFrame xs_col(const std::string& key, bool drop_level) const

DataFrame

df_dataframe.h:1893

DataFrame xs_cols_multi(const std::vector<std::string>& keys, const std::vector<size_t>& levels, bool drop_level) const

DataFrame

df_dataframe.h:1999

DataFrame xs_row(const std::string& key, bool drop_level) const

DataFrame

df_dataframe.h:1841

DataFrame xs_rows_multi(const std::vector<std::string>& keys, const std::vector<size_t>& levels, bool drop_level) const

DataFrame

df_dataframe.h:1941

Code Examples#

The following examples are extracted from the test suite.

empty (np_test_1_all.cpp:6316)
6306}
6307
6308void test_data_generator_emptyBenchmarkSorting() {
6309    std::cout << "========= test_data_generator_empty =======================";
6310
6311    DataGenerator<int> gen(42);
6312
6313    // Test empty data generation
6314    std::vector<int> data = gen.generate(0, DataPattern::RANDOM);
6315
6316    if (!(data.empty())) {
6317        std::string description = std::string("test_data_generator_emptyBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.empty())";
6318        std::cout << std::string("[FAIL] ") + description << std::endl;
6319        throw std::runtime_error(description);
6320    }
6321
6322    // std::cout << "Empty data generation test passed" << std::endl;
6323
6324    std::cout << " -> tests passed" << std::endl;
6325}
at (np_test_1_all.cpp:144)
134    array.setElementAt({0, 0}, 1);
135    array.setElementAt({0, 1}, 2);
136    array.setElementAt({0, 2}, 3);
137    array.setElementAt({1, 1}, 5);
138    array.setElementAt({2, 2}, 9);
139
140    // std::cout << "Array after setting elements:" << std::endl;
141    //array.printArray();
142
143    // std::cout << "Element at (1,1): " << array.getElementAt({1, 1}) << std::endl;
144    // std::cout << "Element at (2,2): " << array.getElementAt({2, 2});
145
146    std::cout << " -> tests passed" << std::endl;
147}
148
149void testArithmetic() {
150    std::cout << "========= testArithmeticOperations =======================";
151
152    auto array1 = createFloat32Array({2, 2}, 5.0f);
153    auto array2 = createFloat32Array({2, 2}, 3.0f);
get (np_test_1_all.cpp:28526)
28516      std::cout << " -> tests passed" << std::endl;
28517    }
28518
28519    void np_test_indexing_mask_indices() {
28520      std::cout << "========= mask_indices: triangular mask indices =======================";
28521
28522      // Get upper triangular indices for 3x3 matrix
28523      auto triu_idx = numpy::mask_indices(3, "triu", 0);
28524
28525      // Should return tuple of 2 arrays
28526      bool passed = (std::get<0>(triu_idx).getSize() > 0);
28527      passed = passed && (std::get<1>(triu_idx).getSize() > 0);
28528      passed = passed && (std::get<0>(triu_idx).getSize() == std::get<1>(triu_idx).getSize());
28529
28530      // Get lower triangular indices
28531      auto tril_idx = numpy::mask_indices(3, "tril", 0);
28532      passed = passed && (std::get<0>(tril_idx).getSize() > 0);
28533      passed = passed && (std::get<1>(tril_idx).getSize() > 0);
28534
28535      if (!passed) {
28536        std::cout << "  [FAIL] : in np_test_indexing_mask_indices() : Mask indices incorrect";
take (np_test_5_all.cpp:4313)
4303      for (size_t i = 0; i < 6; ++i) {
4304        arr.setElementAt({ i }, static_cast<int32_t>(i * 10));  // [0, 10, 20, 30, 40, 50]
4305      }
4306
4307      // Take specific indices
4308      numpy::NDArray<size_t> indices({ 3 });
4309      indices.setElementAt({ 0 }, 5);  // 50
4310      indices.setElementAt({ 1 }, 2);  // 20
4311      indices.setElementAt({ 2 }, 0);  // 0
4312
4313      auto result = numpy::take(arr, indices);
4314
4315      if (result.getSize() != 3) {
4316        std::cout << "  [FAIL] : in np_test_take_basic() : Wrong result size";
4317        throw std::runtime_error("Test failed");
4318      }
4319
4320      if (result.getElementAt({ 0 }) != 50 || result.getElementAt({ 1 }) != 20 || result.getElementAt({ 2 }) != 0) {
4321        std::cout << "  [FAIL] : in np_test_take_basic() : Wrong values extracted";
4322        throw std::runtime_error("Test failed");
4323      }
where (np_test_3_all.cpp:15253)
15243      auto y_data = createInt32Array({ 4 }, 0);
15244      y_data.setElementAt({ 0 }, 100);
15245      y_data.setElementAt({ 1 }, 200);
15246      y_data.setElementAt({ 2 }, 300);
15247      y_data.setElementAt({ 3 }, 400);
15248
15249      auto y_mask = createBoolArray({ 4 }, false);
15250      MaskedArray<int32> y(y_data, y_mask, -999);
15251
15252      // Test where() selection
15253      auto result = where(condition, x, y);
15254
15255      if (!(result.getElementAt({ 0 }) == 10)) {
15256          std::string description = std::string("test_where_selection():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({ 0 }) == 10)";
15257          std::cout << std::string("[FAIL] ") + description << std::endl;
15258          throw std::runtime_error(description);
15259      }
15260      if (!(result.getElementAt({ 1 }) == 200)) {
15261          std::string description = std::string("test_where_selection():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({ 1 }) == 200)";
15262          std::cout << std::string("[FAIL] ") + description << std::endl;
T (np_test_1_all.cpp:20062)
20052    std::mt19937 gen;
20053
20054  public:
20055    MatrixGenerator(unsigned seed = 12345) : gen(seed) {}
20056
20057    // Generate real matrix with known real eigenvalues
20058    NDArray<T> real_matrix_real_eigenvalues(size_t n) {
20059      // Create diagonal matrix with known eigenvalues
20060      NDArray<T> D = NDArray<T>::createZeros({ n, n });
20061      for (size_t i = 0; i < n; ++i) {
20062        D.setElementAt({ i, i }, T(i + 1)); // Eigenvalues 1, 2, 3, ...
20063      }
20064
20065      // Create random orthogonal transformation
20066      auto Q = random_orthogonal_matrix(n);
20067      auto QT = Q.transposeArray();
20068
20069      // A = Q * D * Q^T
20070      return matmul(matmul(Q, D), QT);
20071    }
squeeze (np_test_1_all.cpp:18076)
18066  using namespace numpy;
18067
18068
18069  void testSqueeze() {
18070    std::cout << "========= testSqueeze =======================";
18071
18072    // Create array with singleton dimensions
18073    auto array = createInt32Array({ 1, 4, 1, 3, 1 }, 5);
18074
18075    // Test squeeze all singleton dimensions
18076    auto squeezed_all = squeeze(array);
18077    if (!(squeezed_all.getShape().size() == 2)) {
18078        std::string description = std::string("testSqueeze():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(squeezed_all.getShape().size() == 2)";
18079        std::cout << std::string("[FAIL] ") + description << std::endl;
18080        throw std::runtime_error(description);
18081    }
18082    if (!(squeezed_all.getShape()[0] == 4)) {
18083        std::string description = std::string("testSqueeze():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(squeezed_all.getShape()[0] == 4)";
18084        std::cout << std::string("[FAIL] ") + description << std::endl;
18085        throw std::runtime_error(description);
18086    }
swapaxes (np_test_2_all.cpp:3707)
3697          std::cout << std::string("[FAIL] ") + description << std::endl;
3698          throw std::runtime_error(description);
3699      }
3700      if (!(isApproxEqualMCO(rolled.getElementAt({ 0, 0 }), arr.getElementAt({ 0, 3 })))) {
3701          std::string description = std::string("testRotationFlipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(isApproxEqualMCO(rolled.getElementAt({ 0, 0 }), arr.getElementAt({ 0, 3 })))";
3702          std::cout << std::string("[FAIL] ") + description << std::endl;
3703          throw std::runtime_error(description);
3704      }
3705
3706      // Test swapaxes
3707      auto swapped = swapaxes(arr, 0, 1);
3708      if (!(swapped.getShape() == std::vector<size_t>({ 4, 3 }))) {
3709          std::string description = std::string("testRotationFlipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(swapped.getShape() == std::vector<size_t>({ 4, 3 }))";
3710          std::cout << std::string("[FAIL] ") + description << std::endl;
3711          throw std::runtime_error(description);
3712      }
3713      if (!(isApproxEqualMCO(swapped.getElementAt({ 0, 0 }), arr.getElementAt({ 0, 0 })))) {
3714          std::string description = std::string("testRotationFlipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(isApproxEqualMCO(swapped.getElementAt({ 0, 0 }), arr.getElementAt({ 0, 0 })))";
3715          std::cout << std::string("[FAIL] ") + description << std::endl;
3716          throw std::runtime_error(description);
3717      }
transpose (np_test_2_all.cpp:4973)
4963    }
4964
4965    /**
4966     * Test matrix properties and methods
4967     */
4968    void testMatrixProperties() {
4969      std::cout << "========= testMatrixProperties =======================";
4970
4971      // Test transpose
4972      numpy::Matrix<double> m("1 2 3; 4 5 6");
4973      auto mt = m.transpose();
4974      assert_test(mt.rows() == 3, "Transpose rows");
4975      assert_test(mt.cols() == 2, "Transpose cols");
4976      assert_test(std::abs(mt(0, 1) - 4.0) < 1e-10, "Transpose element");
4977      assert_test(std::abs(mt(2, 0) - 3.0) < 1e-10, "Transpose element");
4978
4979      // Test trace for square matrix
4980      numpy::Matrix<double> square("1 2; 3 4");
4981      double tr = square.trace();
4982      assert_test(std::abs(tr - 5.0) < 1e-10, "Matrix trace");
cov (np_test_1_all.cpp:12038)
12028    data.setElementAt({ 0, 0 }, 1.0);
12029    data.setElementAt({ 0, 1 }, 2.0);
12030    data.setElementAt({ 0, 2 }, 3.0);
12031
12032    // Variable 2: [2, 4, 6] (perfectly correlated)
12033    data.setElementAt({ 1, 0 }, 2.0);
12034    data.setElementAt({ 1, 1 }, 4.0);
12035    data.setElementAt({ 1, 2 }, 6.0);
12036
12037    // Test covariance matrix
12038    auto cov_matrix = cov(data);
12039    if (!(cov_matrix.getShape()[0] == 2)) {
12040        std::string description = std::string("testCovarianceAndCorrelation():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(cov_matrix.getShape()[0] == 2)";
12041        std::cout << std::string("[FAIL] ") + description << std::endl;
12042        throw std::runtime_error(description);
12043    }
12044    if (!(cov_matrix.getShape()[1] == 2)) {
12045        std::string description = std::string("testCovarianceAndCorrelation():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(cov_matrix.getShape()[1] == 2)";
12046        std::cout << std::string("[FAIL] ") + description << std::endl;
12047        throw std::runtime_error(description);
12048    }
max (np_test_1_all.cpp:7274)
7264    if (sizeof(uintp) == sizeof(void*)) {
7265        // std::cout << "                -> uintp size matches pointer size";
7266    } else {
7267        // std::cout << "  ✗ uintp size doesn't match pointer size" << std::endl;
7268    }
7269
7270    // Test range limits
7271    // std::cout << "Range Information:" << std::endl;
7272    // std::cout << "  intp min: " << std::numeric_limits<intp>::min() << std::endl;
7273    // std::cout << "  intp max: " << std::numeric_limits<intp>::max() << std::endl;
7274    // std::cout << "  uintp max: " << std::numeric_limits<uintp>::max() << std::endl;
7275    // std::cout << "  longdouble digits: " << std::numeric_limits<longdouble>::digits << std::endl;
7276
7277    std::cout << " -> tests passed" << std::endl;
7278}
7279
7280void testComplexArithmeticExtendedTypes() {
7281    std::cout << "========= testComplexArithmeticExtendedTypes =======================";
7282
7283    clongdouble c1(3.0L, 4.0L);  // 3 + 4i
mean (np_test_1_all.cpp:11714)
11704    // Create test array
11705    auto array = createInt32Array({ 2, 3 }, 0);
11706    array.setElementAt({ 0, 0 }, 1);
11707    array.setElementAt({ 0, 1 }, 2);
11708    array.setElementAt({ 0, 2 }, 3);
11709    array.setElementAt({ 1, 0 }, 4);
11710    array.setElementAt({ 1, 1 }, 5);
11711    array.setElementAt({ 1, 2 }, 6);
11712
11713    // Test mean without axis
11714    auto mean_all = mean(array);
11715    if (!(approx_equal(mean_all.getElementAt({ 0 }), 3.5, 1e-10))) {
11716        std::string description = std::string("testBasicStatistics():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(mean_all.getElementAt({ 0 }), 3.5, 1e-10))";
11717        std::cout << std::string("[FAIL] ") + description << std::endl;
11718        throw std::runtime_error(description);
11719    }
11720    // std::cout << "[OK] mean (all elements) works correctly\n";
11721
11722    // Test mean along axis 0
11723    auto mean_axis0 = mean(array, 0);
11724    if (!(mean_axis0.getShape()[0] == 3)) {
median (np_test_1_all.cpp:11882)
11872    std::cout << "========= testMedianAndPercentiles =======================";
11873
11874    // Test median with odd number of elements
11875    auto odd_array = createInt32Array({ 5 }, 0);
11876    odd_array.setElementAt({ 0 }, 1);
11877    odd_array.setElementAt({ 1 }, 3);
11878    odd_array.setElementAt({ 2 }, 5);
11879    odd_array.setElementAt({ 3 }, 7);
11880    odd_array.setElementAt({ 4 }, 9);
11881
11882    auto median_odd = median(odd_array);
11883    if (!(approx_equal(median_odd.getElementAt({ 0 }), 5.0, 1e-10))) {
11884        std::string description = std::string("testMedianAndPercentiles():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(median_odd.getElementAt({ 0 }), 5.0, 1e-10))";
11885        std::cout << std::string("[FAIL] ") + description << std::endl;
11886        throw std::runtime_error(description);
11887    }
11888    // std::cout << "[OK] Median with odd count works correctly\n";
11889
11890    // Test median with even number of elements
11891    auto even_array = createInt32Array({ 4 }, 0);
11892    even_array.setElementAt({ 0 }, 1);
min (np_test_1_all.cpp:2350)
2340        if (i % 3 == 0) {
2341            large_array.setElementAt({i}, object_(static_cast<int>(i)));
2342        } else if (i % 3 == 1) {
2343            large_array.setElementAt({i}, object_(static_cast<double>(i) * 0.5));
2344        } else {
2345            large_array.setElementAt({i}, object_(std::string("str") + std::to_string(i)));
2346        }
2347    }
2348
2349    // Verify pattern
2350    for (size_t i = 0; i < std::min(large_size, size_t(100)); ++i) {  // Check first 100
2351        object_ obj = large_array.getElementAt({i});
2352        if (i % 3 == 0) {
2353            if (!(obj.is_type<int>())) {
2354                std::string description = std::string("testArrayEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(obj.is_type<int>())";
2355                std::cout << std::string("[FAIL] ") + description << std::endl;
2356                throw std::runtime_error(description);
2357            }
2358        } else if (i % 3 == 1) {
2359            if (!(obj.is_type<double>())) {
2360                std::string description = std::string("unknown_function():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(obj.is_type<double>())";
quantile (np_test_1_all.cpp:11929)
11919    // Test 25th percentile
11920    auto perc25 = percentile(perc_array, 25.0);
11921    if (!(approx_equal(perc25.getElementAt({ 0 }), 3.25, 1e-10))) {
11922        std::string description = std::string("testMedianAndPercentiles():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(perc25.getElementAt({ 0 }), 3.25, 1e-10))";
11923        std::cout << std::string("[FAIL] ") + description << std::endl;
11924        throw std::runtime_error(description);
11925    }
11926    // std::cout << "[OK] 25th percentile works correctly\n";
11927
11928    // Test quantile (equivalent to percentile/100)
11929    auto quant75 = quantile(perc_array, 0.75);
11930    auto perc75 = percentile(perc_array, 75.0);
11931    if (!(approx_equal(quant75.getElementAt({ 0 }), perc75.getElementAt({ 0 }), 1e-10))) {
11932        std::string description = std::string("testMedianAndPercentiles():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(quant75.getElementAt({ 0 }), perc75.getElementAt({ 0 }), 1e-10))";
11933        std::cout << std::string("[FAIL] ") + description << std::endl;
11934        throw std::runtime_error(description);
11935    }
11936    // std::cout << "[OK] Quantile function works correctly\n";
11937    std::cout << " -> tests passed" << std::endl;
11938  }
std (np_test_1_all.cpp:11836)
11826    auto var_sample = var(array, std::nullopt, 1);  // ddof=1 for sample variance
11827    double expected_sample_var = 1.25 * 4.0 / 3.0;  // Bessel's correction
11828    if (!(approx_equal(var_sample.getElementAt({ 0 }), expected_sample_var, 1e-10))) {
11829        std::string description = std::string("testVarianceAndStandardDeviation():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(var_sample.getElementAt({ 0 }), expected_sample_var, 1e-10))";
11830        std::cout << std::string("[FAIL] ") + description << std::endl;
11831        throw std::runtime_error(description);
11832    }
11833    // std::cout << "[OK] Sample variance works correctly\n";
11834
11835    // Test standard deviation
11836    auto std_result = numpy::std(array, std::nullopt, 0);
11837    if (!(approx_equal(std_result.getElementAt({ 0 }), std::sqrt(expected_var), 1e-10))) {
11838        std::string description = std::string("testVarianceAndStandardDeviation():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(std_result.getElementAt({ 0 }), std::sqrt(expected_var), 1e-10))";
11839        std::cout << std::string("[FAIL] ") + description << std::endl;
11840        throw std::runtime_error(description);
11841    }
11842    // std::cout << "[OK] Standard deviation works correctly\n";
11843
11844    // Test along axis
11845    auto array2d = createFloat64Array({ 2, 2 }, 0);
11846    array2d.setElementAt({ 0, 0 }, 1.0);
sum (np_test_1_all.cpp:11766)
11756        throw std::runtime_error(description);
11757    }
11758    if (!(approx_equal(mean_axis1.getElementAt({ 1 }), 5.0, 1e-10))) {
11759        std::string description = std::string("testBasicStatistics():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(mean_axis1.getElementAt({ 1 }), 5.0, 1e-10))";
11760        std::cout << std::string("[FAIL] ") + description << std::endl;
11761        throw std::runtime_error(description);
11762    }
11763    // std::cout << "[OK] mean along axis 1 works correctly\n";
11764
11765    // Test sum
11766    auto sum_all = sum(array);
11767    if (!(sum_all.getElementAt({ 0 }) == 21)) {
11768        std::string description = std::string("testBasicStatistics():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(sum_all.getElementAt({ 0 }) == 21)";
11769        std::cout << std::string("[FAIL] ") + description << std::endl;
11770        throw std::runtime_error(description);
11771    }
11772    // std::cout << "[OK] sum works correctly\n";
11773
11774    // Test min and max
11775    auto min_all = min(array);
11776    auto max_all = max(array);
var (np_test_1_all.cpp:11816)
11806    std::cout << "========= testVarianceAndStandardDeviation =======================";
11807
11808    // Create test array with known variance
11809    auto array = createFloat64Array({ 4 }, 0);
11810    array.setElementAt({ 0 }, 1.0);
11811    array.setElementAt({ 1 }, 2.0);
11812    array.setElementAt({ 2 }, 3.0);
11813    array.setElementAt({ 3 }, 4.0);
11814
11815    // Test variance (population)
11816    auto var_result = var(array, std::nullopt, 0);  // ddof=0 for population variance
11817    double expected_var = 1.25;  // Known variance for [1,2,3,4]
11818    if (!(approx_equal(var_result.getElementAt({ 0 }), expected_var, 1e-10))) {
11819        std::string description = std::string("testVarianceAndStandardDeviation():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(var_result.getElementAt({ 0 }), expected_var, 1e-10))";
11820        std::cout << std::string("[FAIL] ") + description << std::endl;
11821        throw std::runtime_error(description);
11822    }
11823    // std::cout << "[OK] Population variance works correctly\n";
11824
11825    // Test variance (sample)
11826    auto var_sample = var(array, std::nullopt, 1);  // ddof=1 for sample variance
abs (np_test_1_all.cpp:101)
 91        if (arr.getShape().size() == 1 && arr.getShape()[0] <= 10) {
 92            for (size_t i = 0; i < arr.getShape()[0]; ++i) {
 93                // std::cout << static_cast<int64_t>(arr.getElementAt({i})) << " ";
 94            }
 95        }
 96        // std::cout << std::endl;
 97    }
 98
 99    // Helper function for core array extensions tests
100    bool isApproxEqualExt(double a, double b, double tolerance = 1e-10) {
101        return std::abs(a - b) < tolerance;
102    }
103}
104
105void f_nothing() {
106    // This function does nothing and tests nothing
107    // It's a placeholder test function
108}
109
110// ------ merging np_test_advanced_indexing.cpp -- number of functions merged=16 --------------------------------
add (np_test_1_all.cpp:6410)
6400void testCharArrayStringOperationsCharArray() {
6401    std::cout << "========= testStringOperations =======================";
6402
6403    // Test string concatenation
6404    std::vector<std::string> words1 = {"Hello", "Good", "Nice"};
6405    std::vector<std::string> words2 = {" World", " Day", " Work"};
6406
6407    auto arr1 = array<32>(words1);
6408    auto arr2 = array<32>(words2);
6409
6410    auto result = add(arr1, arr2);
6411    // std::cout << "String concatenation (add):" << std::endl;
6412    for (size_t i = 0; i < result.size(); ++i) {
6413        // std::cout << "'" << arr1[i] << "' + '" << arr2[i] << "' = '" << result[i] << "'";
6414    }
6415
6416    // Test scalar addition
6417    auto scalar_result = add(arr1, "!");
6418    // std::cout << "Scalar concatenation:" << std::endl;
6419    for (size_t i = 0; i < scalar_result.size(); ++i) {
6420        // std::cout << "'" << arr1[i] << "' + '!' = '" << scalar_result[i] << "'";
add (np_test_1_all.cpp:6410)
6400void testCharArrayStringOperationsCharArray() {
6401    std::cout << "========= testStringOperations =======================";
6402
6403    // Test string concatenation
6404    std::vector<std::string> words1 = {"Hello", "Good", "Nice"};
6405    std::vector<std::string> words2 = {" World", " Day", " Work"};
6406
6407    auto arr1 = array<32>(words1);
6408    auto arr2 = array<32>(words2);
6409
6410    auto result = add(arr1, arr2);
6411    // std::cout << "String concatenation (add):" << std::endl;
6412    for (size_t i = 0; i < result.size(); ++i) {
6413        // std::cout << "'" << arr1[i] << "' + '" << arr2[i] << "' = '" << result[i] << "'";
6414    }
6415
6416    // Test scalar addition
6417    auto scalar_result = add(arr1, "!");
6418    // std::cout << "Scalar concatenation:" << std::endl;
6419    for (size_t i = 0; i < scalar_result.size(); ++i) {
6420        // std::cout << "'" << arr1[i] << "' + '!' = '" << scalar_result[i] << "'";
ceil (np_test_2_all.cpp:5735)
5725          throw std::runtime_error(description);
5726      }
5727      if (!(approx_equal(floor_result.getElementAt({ 5 }), std::floor(2.7)))) {
5728          std::string description = std::string("testRoundingFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(floor_result.getElementAt({ 5 }), std::floor(2.7)))";
5729          std::cout << std::string("[FAIL] ") + description << std::endl;
5730          throw std::runtime_error(description);
5731      }
5732      // std::cout << "[OK] floor function works correctly\n";
5733
5734      // Test ceil
5735      auto ceil_result = ceil(values);
5736      if (!(approx_equal(ceil_result.getElementAt({ 0 }), std::ceil(-2.7)))) {
5737          std::string description = std::string("testRoundingFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(ceil_result.getElementAt({ 0 }), std::ceil(-2.7)))";
5738          std::cout << std::string("[FAIL] ") + description << std::endl;
5739          throw std::runtime_error(description);
5740      }
5741      if (!(approx_equal(ceil_result.getElementAt({ 5 }), std::ceil(2.7)))) {
5742          std::string description = std::string("testRoundingFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(ceil_result.getElementAt({ 5 }), std::ceil(2.7)))";
5743          std::cout << std::string("[FAIL] ") + description << std::endl;
5744          throw std::runtime_error(description);
5745      }
divide (np_test_3_all.cpp:16880)
16870      std::cout << " -> tests passed" << std::endl;
16871    }
16872
16873    void np_test_missing_math_functions_divide_array() {
16874      std::cout << "========= divide: array-array division =======================";
16875
16876      // explicit namespace to avoid name clashes
16877      numpy::NDArray<double> a = numpy::arange<double>(10.0, 16.0, 1.0);
16878      numpy::NDArray<double> b = numpy::arange<double>(2.0, 8.0, 1.0);
16879
16880      numpy::NDArray<double> result = numpy::divide(a, b);
16881
16882      // Verify values: [10,11,12,13,14,15] / [2,3,4,5,6,7] = [5,3.666...,3,2.6,2.333...,2.142...]
16883      auto pass = true;
16884      double expected[] = { 5.0, 11.0 / 3.0, 3.0, 2.6, 14.0 / 6.0, 15.0 / 7.0 };
16885      for (size_t i = 0; i < 6 && pass; ++i) {
16886        double val = result.getElementAt({ i });
16887        double exp = expected[i];
16888        if (std::abs(val - exp) > 1e-10) {
16889          pass = false;
16890        }
floor (np_test_2_all.cpp:5721)
5711          throw std::runtime_error(description);
5712      }
5713      if (!(approx_equal(round_result.getElementAt({ 5 }), std::round(2.7)))) {
5714          std::string description = std::string("testRoundingFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(round_result.getElementAt({ 5 }), std::round(2.7)))";
5715          std::cout << std::string("[FAIL] ") + description << std::endl;
5716          throw std::runtime_error(description);
5717      }
5718      // std::cout << "[OK] round function works correctly\n";
5719
5720      // Test floor
5721      auto floor_result = floor(values);
5722      if (!(approx_equal(floor_result.getElementAt({ 0 }), std::floor(-2.7)))) {
5723          std::string description = std::string("testRoundingFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(floor_result.getElementAt({ 0 }), std::floor(-2.7)))";
5724          std::cout << std::string("[FAIL] ") + description << std::endl;
5725          throw std::runtime_error(description);
5726      }
5727      if (!(approx_equal(floor_result.getElementAt({ 5 }), std::floor(2.7)))) {
5728          std::string description = std::string("testRoundingFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(approx_equal(floor_result.getElementAt({ 5 }), std::floor(2.7)))";
5729          std::cout << std::string("[FAIL] ") + description << std::endl;
5730          throw std::runtime_error(description);
5731      }
mod (np_test_1_all.cpp:21258)
21248    a.setElementAt({ 1 }, -7);
21249    a.setElementAt({ 2 }, 7);
21250    a.setElementAt({ 3 }, -7);
21251
21252    auto b = NDArray<int32>({ 4 });
21253    b.setElementAt({ 0 }, 3);
21254    b.setElementAt({ 1 }, 3);
21255    b.setElementAt({ 2 }, -3);
21256    b.setElementAt({ 3 }, -3);
21257
21258    auto result = mod(a, b);
21259
21260    if (!(result.getElementAt({ 0 }) == 1)) {
21261        std::string description = std::string("testModFunction():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({ 0 }) == 1)";
21262        std::cout << std::string("[FAIL] ") + description << std::endl;
21263        throw std::runtime_error(description);
21264    }
21265    if (!(result.getElementAt({ 1 }) == 2)) {
21266        std::string description = std::string("testModFunction():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({ 1 }) == 2)";
21267        std::cout << std::string("[FAIL] ") + description << std::endl;
21268        throw std::runtime_error(description);
mod (np_test_1_all.cpp:21258)
21248    a.setElementAt({ 1 }, -7);
21249    a.setElementAt({ 2 }, 7);
21250    a.setElementAt({ 3 }, -7);
21251
21252    auto b = NDArray<int32>({ 4 });
21253    b.setElementAt({ 0 }, 3);
21254    b.setElementAt({ 1 }, 3);
21255    b.setElementAt({ 2 }, -3);
21256    b.setElementAt({ 3 }, -3);
21257
21258    auto result = mod(a, b);
21259
21260    if (!(result.getElementAt({ 0 }) == 1)) {
21261        std::string description = std::string("testModFunction():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({ 0 }) == 1)";
21262        std::cout << std::string("[FAIL] ") + description << std::endl;
21263        throw std::runtime_error(description);
21264    }
21265    if (!(result.getElementAt({ 1 }) == 2)) {
21266        std::string description = std::string("testModFunction():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({ 1 }) == 2)";
21267        std::cout << std::string("[FAIL] ") + description << std::endl;
21268        throw std::runtime_error(description);
mode (np_test_4_all.cpp:20711)
20701#include <stdexcept>
20702
20703using namespace numpy;
20704
20705namespace numpy_tests {
20706namespace numpy_tests_phase6b {
20707
20708void np_test_phase6b_can_cast() {
20709    std::cout << "=== Test can_cast() ===";
20710
20711    // Test SAFE casting mode (default)
20712    {
20713        // Same type is always safe
20714        if (!(can_cast(DType::INT32, DType::INT32, CastingMode::SAFE) == true)) {
20715            std::string description = std::string("np_test_phase6b_can_cast():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(can_cast(DType::INT32, DType::INT32, CastingMode::SAFE) == true)";
20716            std::cout << std::string("[FAIL] ") + description << std::endl;
20717            throw std::runtime_error(description);
20718        }
20719        if (!(can_cast(DType::FLOAT64, DType::FLOAT64, CastingMode::SAFE) == true)) {
20720            std::string description = std::string("np_test_phase6b_can_cast():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(can_cast(DType::FLOAT64, DType::FLOAT64, CastingMode::SAFE) == true)";
20721            std::cout << std::string("[FAIL] ") + description << std::endl;
mode (np_test_4_all.cpp:20711)
20701#include <stdexcept>
20702
20703using namespace numpy;
20704
20705namespace numpy_tests {
20706namespace numpy_tests_phase6b {
20707
20708void np_test_phase6b_can_cast() {
20709    std::cout << "=== Test can_cast() ===";
20710
20711    // Test SAFE casting mode (default)
20712    {
20713        // Same type is always safe
20714        if (!(can_cast(DType::INT32, DType::INT32, CastingMode::SAFE) == true)) {
20715            std::string description = std::string("np_test_phase6b_can_cast():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(can_cast(DType::INT32, DType::INT32, CastingMode::SAFE) == true)";
20716            std::cout << std::string("[FAIL] ") + description << std::endl;
20717            throw std::runtime_error(description);
20718        }
20719        if (!(can_cast(DType::FLOAT64, DType::FLOAT64, CastingMode::SAFE) == true)) {
20720            std::string description = std::string("np_test_phase6b_can_cast():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(can_cast(DType::FLOAT64, DType::FLOAT64, CastingMode::SAFE) == true)";
20721            std::cout << std::string("[FAIL] ") + description << std::endl;
multiply (np_test_1_all.cpp:6426)
6416    // Test scalar addition
6417    auto scalar_result = add(arr1, "!");
6418    // std::cout << "Scalar concatenation:" << std::endl;
6419    for (size_t i = 0; i < scalar_result.size(); ++i) {
6420        // std::cout << "'" << arr1[i] << "' + '!' = '" << scalar_result[i] << "'";
6421    }
6422
6423    // Test string multiplication
6424    std::vector<std::string> patterns = {"Ha", "Ho", "Hi"};
6425    auto pattern_arr = array<32>(patterns);
6426    auto repeated = multiply(pattern_arr, 3);
6427    // std::cout << "String multiplication:" << std::endl;
6428    for (size_t i = 0; i < repeated.size(); ++i) {
6429        // std::cout << "'" << pattern_arr[i] << "' * 3 = '" << repeated[i] << "'";
6430    }
6431
6432    std::cout << " -> tests passed" << std::endl;
6433}
6434
6435void testCaseConversionsCharArray() {
6436    std::cout << "========= testCaseConversions =======================";
round (np_test_1_all.cpp:23769)
23759          throw std::runtime_error(description);
23760      }
23761      if (!(power_scalar_result.getShape() == array.getShape())) {
23762          std::string description = std::string("testMathFunctionSignatures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(power_scalar_result.getShape() == array.getShape())";
23763          std::cout << std::string("[FAIL] ") + description << std::endl;
23764          throw std::runtime_error(description);
23765      }
23766      // std::cout << "[OK] Power functions have correct signatures\n";
23767
23768      // Test rounding functions with new decimals parameter
23769      auto round_result = round(array);        // Default decimals=0
23770      auto round_decimals_result = round(array, 2);  // With decimals
23771      if (!(round_result.getShape() == array.getShape())) {
23772          std::string description = std::string("testMathFunctionSignatures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(round_result.getShape() == array.getShape())";
23773          std::cout << std::string("[FAIL] ") + description << std::endl;
23774          throw std::runtime_error(description);
23775      }
23776      if (!(round_decimals_result.getShape() == array.getShape())) {
23777          std::string description = std::string("testMathFunctionSignatures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(round_decimals_result.getShape() == array.getShape())";
23778          std::cout << std::string("[FAIL] ") + description << std::endl;
23779          throw std::runtime_error(description);
subtract (np_test_3_all.cpp:16825)
16815      std::cout << " -> tests passed" << std::endl;
16816    }
16817
16818    void np_test_missing_math_functions_subtract_array() {
16819      std::cout << "========= subtract: array-array subtraction =======================";
16820
16821      // explicit namespace to avoid name clashes
16822      numpy::NDArray<double> a = numpy::arange<double>(10.0, 16.0, 1.0);
16823      numpy::NDArray<double> b = numpy::arange<double>(0.0, 6.0, 1.0);
16824
16825      numpy::NDArray<double> result = numpy::subtract(a, b);
16826
16827      // Verify values: [10,11,12,13,14,15] - [0,1,2,3,4,5] = [10,10,10,10,10,10]
16828      auto pass = true;
16829      for (size_t i = 0; i < 6 && pass; ++i) {
16830        double val = result.getElementAt({ i });
16831        double exp = 10.0;
16832        if (std::abs(val - exp) > 1e-10) {
16833          pass = false;
16834        }
16835      }
truncate (np_test_5_all.cpp:7536)
7526      if (!passed) {
7527        std::cout << "  [FAIL] : cutdeg failed";
7528        throw std::runtime_error("np_test_cutdeg failed");
7529      }
7530
7531      std::cout << " -> tests passed" << std::endl;
7532    }
7533
7534    void np_test_truncate() {
7535      std::cout << "========= truncate: truncate to size =======================";
7536
7537      numpy::Polynomial<double> p({ 1.0, 2.0, 3.0, 4.0, 5.0 });
7538      auto truncated = p.truncate(3);  // Keep only first 3 coefficients
7539
7540      auto coefs = truncated.coefficients();
7541      bool passed = (coefs.size() == 3 &&
7542        std::abs(coefs[0] - 1.0) < 1e-10 &&
7543        std::abs(coefs[1] - 2.0) < 1e-10 &&
7544        std::abs(coefs[2] - 3.0) < 1e-10);
dot (np_test_2_all.cpp:11523)
11513      numpy::NDArray<double> v2({ 3 });
11514
11515      v1.setElementAt({ 0 }, 1.0);
11516      v1.setElementAt({ 1 }, 2.0);
11517      v1.setElementAt({ 2 }, 3.0);
11518
11519      v2.setElementAt({ 0 }, 4.0);
11520      v2.setElementAt({ 1 }, 5.0);
11521      v2.setElementAt({ 2 }, 6.0);
11522
11523      auto result = numpy::linalg::dot(v1, v2);
11524      double expected = 1.0 * 4.0 + 2.0 * 5.0 + 3.0 * 6.0; // = 32
11525
11526      // Extract scalar from 0-D array
11527      double result_value = result.getElementAt({});
11528
11529      if (std::abs(result_value - expected) > 1e-10) {
11530        std::cout << "  [FAIL] : dot product incorrect, expected " << expected << ", got " << result_value;
11531        throw std::runtime_error("dot test failed");
11532      }
dot (np_test_2_all.cpp:11523)
11513      numpy::NDArray<double> v2({ 3 });
11514
11515      v1.setElementAt({ 0 }, 1.0);
11516      v1.setElementAt({ 1 }, 2.0);
11517      v1.setElementAt({ 2 }, 3.0);
11518
11519      v2.setElementAt({ 0 }, 4.0);
11520      v2.setElementAt({ 1 }, 5.0);
11521      v2.setElementAt({ 2 }, 6.0);
11522
11523      auto result = numpy::linalg::dot(v1, v2);
11524      double expected = 1.0 * 4.0 + 2.0 * 5.0 + 3.0 * 6.0; // = 32
11525
11526      // Extract scalar from 0-D array
11527      double result_value = result.getElementAt({});
11528
11529      if (std::abs(result_value - expected) > 1e-10) {
11530        std::cout << "  [FAIL] : dot product incorrect, expected " << expected << ", got " << result_value;
11531        throw std::runtime_error("dot test failed");
11532      }
sample (np_test_1_all.cpp:22321)
22311        throw std::runtime_error(description);
22312    }
22313    for (size_t i = 0; i < 3; ++i) {
22314      double val = random_samp.getElementAt({ i });
22315      if (!(val >= 0.0 && val < 1.0)) {
22316          std::string description = std::string("testRandomUtilityFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(val >= 0.0 && val < 1.0)";
22317          std::cout << std::string("[FAIL] ") + description << std::endl;
22318          throw std::runtime_error(description);
22319      }
22320    }
22321    // std::cout << "[OK] Random sample (alias)\n";
22322
22323    auto ranf_arr = ranf<double>({ {3} });
22324    if (!(ranf_arr.getShape()[0] == 3)) {
22325        std::string description = std::string("testRandomUtilityFunctions():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(ranf_arr.getShape()[0] == 3)";
22326        std::cout << std::string("[FAIL] ") + description << std::endl;
22327        throw std::runtime_error(description);
22328    }
22329    // std::cout << "[OK] ranf (alias)\n";
22330
22331    auto sample_arr = sample<double>({ {3} });
all (np_test_4_all.cpp:23928)
23918                        }
23919                    }
23920                }
23921
23922                auto result = numpy::einsum<numpy::float64>("ijk->ik", {A});
23923
23924                if (result.getShape()[0] != 2 || result.getShape()[1] != 2) {
23925                    throw std::runtime_error("einsum partial sum shape wrong");
23926                }
23927
23928                // Sum over j: 1+2+3 = 6 for all (i,k) positions
23929                if (std::abs(result.getElementAt({0, 0}) - 6.0) > 1e-10 ||
23930                    std::abs(result.getElementAt({1, 1}) - 6.0) > 1e-10) {
23931                    throw std::runtime_error("einsum partial sum values wrong");
23932                }
23933
23934                // std::cout << "  OK: Partial sum: 'ijk->ik'\n";
23935            }
23936
23937            // Test 5: Size-1 dimension handling
23938            {
any (np_test_2_all.cpp:16758)
16748    // ANY() TESTS - SCALAR RESULT
16749    // ============================================================================
16750
16751    void np_test_logic_any_scalar_all_false() {
16752      std::cout << "========= any: all false elements =======================";
16753
16754      // Create array with all false/zero elements
16755      std::vector<double> data = { 0.0, 0.0, 0.0 };
16756      numpy::NDArray<double> arr = numpy::createArrayFromVector<double>({ 3 }, data);
16757
16758      bool result = numpy::any(arr);
16759
16760      if (result != false) {
16761        std::cout << "  [FAIL] : in np_test_logic_any_scalar_all_false() : expected false for all-zero array";
16762        throw std::runtime_error("np_test_logic_any_scalar_all_false failed: expected false");
16763      }
16764
16765      std::cout << " -> tests passed" << std::endl;
16766    }
16767
16768    void np_test_logic_any_scalar_all_true() {
isin (np_test_1_all.cpp:19434)
19424        std::cout << std::string("[FAIL] ") + description << std::endl;
19425        throw std::runtime_error(description);
19426    }
19427    if (!(membership.getElementAt({ 5 }) == false)) {
19428        std::string description = std::string("testMembershipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(membership.getElementAt({ 5 }) == false)";
19429        std::cout << std::string("[FAIL] ") + description << std::endl;
19430        throw std::runtime_error(description);
19431    }
19432    // std::cout << "[OK] Membership testing (in1d) works correctly\n";
19433
19434    // Test isin (alias for in1d)
19435    auto isin_result = isin(test_array, test_values);
19436
19437    // Should be identical to in1d result
19438    for (size_t i = 0; i < membership.getSize(); ++i) {
19439      if (!(isin_result.getElementAt({ i }) == membership.getElementAt({ i }))) {
19440          std::string description = std::string("testMembershipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(isin_result.getElementAt({ i }) == membership.getElementAt({ i }))";
19441          std::cout << std::string("[FAIL] ") + description << std::endl;
19442          throw std::runtime_error(description);
19443      }
19444    }
isin (np_test_1_all.cpp:19434)
19424        std::cout << std::string("[FAIL] ") + description << std::endl;
19425        throw std::runtime_error(description);
19426    }
19427    if (!(membership.getElementAt({ 5 }) == false)) {
19428        std::string description = std::string("testMembershipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(membership.getElementAt({ 5 }) == false)";
19429        std::cout << std::string("[FAIL] ") + description << std::endl;
19430        throw std::runtime_error(description);
19431    }
19432    // std::cout << "[OK] Membership testing (in1d) works correctly\n";
19433
19434    // Test isin (alias for in1d)
19435    auto isin_result = isin(test_array, test_values);
19436
19437    // Should be identical to in1d result
19438    for (size_t i = 0; i < membership.getSize(); ++i) {
19439      if (!(isin_result.getElementAt({ i }) == membership.getElementAt({ i }))) {
19440          std::string description = std::string("testMembershipOperations():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(isin_result.getElementAt({ i }) == membership.getElementAt({ i }))";
19441          std::cout << std::string("[FAIL] ") + description << std::endl;
19442          throw std::runtime_error(description);
19443      }
19444    }
to_numpy (np_test_5_all.cpp:21373)
21363    if (errors == 0) {
21364        std::cout << "np_test_timedelta_components -> tests passed" << std::endl;
21365    }
21366    return errors;
21367}
21368
21369// =============================================================================
21370// Test 4: Total Conversion Properties
21371// =============================================================================
21372int np_test_timedelta_total_conversions() {
21373    int errors = 0;
21374
21375    numpy::Timedelta td(1, 12, 0);  // 1 day 12 hours = 1.5 days = 36 hours
21376
21377    // total_seconds
21378    {
21379        double secs = td.total_seconds();
21380        double expected = (24 + 12) * 3600.0;
21381        if (std::abs(secs - expected) > 0.0001) {
21382            std::cout << "[FAIL] np_test_timedelta_total_conversions: total_seconds expected "
21383                      << expected << ", got " << secs << std::endl;
to_string (np_test_1_all.cpp:454)
444    // Modify through different views
445    view1.setElementAt({0, 0}, 100);
446    view2.setElementAt({2, 1}, 200);  // This is (1, 2) in original
447    view3.setElementAt({0, 0}, 300);  // This is (1, 1) in original
448
449    // std::cout << "After modifications through multiple views:" << std::endl;
450    //original.printArray();
451
452    // Verify all changes are reflected
453    if (!(original.getElementAt({0, 0}) == 100)) {
454        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({0, 0}) == 100)";
455        std::cout << std::string("[FAIL] ") + description << std::endl;
456        throw std::runtime_error(description);
457    }
458    if (!(original.getElementAt({1, 2}) == 200)) {
459        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 2}) == 200)";
460        std::cout << std::string("[FAIL] ") + description << std::endl;
461        throw std::runtime_error(description);
462    }
463    if (!(original.getElementAt({1, 1}) == 300)) {
464        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 1}) == 300)";
to_string (np_test_1_all.cpp:454)
444    // Modify through different views
445    view1.setElementAt({0, 0}, 100);
446    view2.setElementAt({2, 1}, 200);  // This is (1, 2) in original
447    view3.setElementAt({0, 0}, 300);  // This is (1, 1) in original
448
449    // std::cout << "After modifications through multiple views:" << std::endl;
450    //original.printArray();
451
452    // Verify all changes are reflected
453    if (!(original.getElementAt({0, 0}) == 100)) {
454        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({0, 0}) == 100)";
455        std::cout << std::string("[FAIL] ") + description << std::endl;
456        throw std::runtime_error(description);
457    }
458    if (!(original.getElementAt({1, 2}) == 200)) {
459        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 2}) == 200)";
460        std::cout << std::string("[FAIL] ") + description << std::endl;
461        throw std::runtime_error(description);
462    }
463    if (!(original.getElementAt({1, 1}) == 300)) {
464        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 1}) == 300)";
insert (np_test_1_all.cpp:6990)
6980}
6981
6982void testBusinessDateRangeDateTime() {
6983    std::cout << "========= testBusinessDateRangeDateTime =======================";
6984
6985    datetime64 start("2024-03-11");  // Monday
6986    datetime64 end("2024-03-22");    // Friday (2 weeks later)
6987
6988    // Create holidays set
6989    std::set<datetime64> holidays;
6990    holidays.insert(datetime64("2024-03-15"));  // Friday holiday
6991
6992    auto business_dates = createBusinessDateRange(start, end, holidays);
6993    // std::cout << "Business dates from " << start.toString()
6994              // << " to " << end.toString() << " (excluding 2024-03-15):" << std::endl;
6995    //business_dates.printArray();
6996
6997        std::cout << " -> tests passed" << std::endl;
6998}
6999
7000void testMonthRangeDateTime() {
insert (np_test_1_all.cpp:6990)
6980}
6981
6982void testBusinessDateRangeDateTime() {
6983    std::cout << "========= testBusinessDateRangeDateTime =======================";
6984
6985    datetime64 start("2024-03-11");  // Monday
6986    datetime64 end("2024-03-22");    // Friday (2 weeks later)
6987
6988    // Create holidays set
6989    std::set<datetime64> holidays;
6990    holidays.insert(datetime64("2024-03-15"));  // Friday holiday
6991
6992    auto business_dates = createBusinessDateRange(start, end, holidays);
6993    // std::cout << "Business dates from " << start.toString()
6994              // << " to " << end.toString() << " (excluding 2024-03-15):" << std::endl;
6995    //business_dates.printArray();
6996
6997        std::cout << " -> tests passed" << std::endl;
6998}
6999
7000void testMonthRangeDateTime() {
stack (np_test_1_all.cpp:5509)
5499void testStackArrayUtils() {
5500    std::cout << "========= testStackArrayUtils =======================";
5501
5502    // Test 1D stacking
5503    auto arr1 = NDArray<int32>::createRange(0, 3, 1);  // [0, 1, 2]
5504    auto arr2 = NDArray<int32>::createRange(3, 6, 1);  // [3, 4, 5]
5505    auto arr3 = NDArray<int32>::createRange(6, 9, 1);  // [6, 7, 8]
5506
5507    // Stack along axis 0 (new first dimension)
5508    auto result0 = stack<int32>({arr1, arr2, arr3}, 0);
5509    // std::cout << "1D stack (axis=0):";
5510    //result0.printArray();
5511
5512    if (!(result0.getShape()[0] == 3)) {
5513        std::string description = std::string("testStackArrayUtils():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result0.getShape()[0] == 3)";
5514        std::cout << std::string("[FAIL] ") + description << std::endl;
5515        throw std::runtime_error(description);
5516    }
5517    if (!(result0.getShape()[1] == 3)) {
5518        std::string description = std::string("testStackArrayUtils():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result0.getShape()[1] == 3)";
astype (np_test_3_all.cpp:796)
786        auto ufunc_square = numpy::frompyfunc(square, 1, 1);
787
788        numpy::NDArray<double> arr({ 3 });
789        arr.setElementAt({ 0 }, 2.0);
790        arr.setElementAt({ 1 }, 3.0);
791        arr.setElementAt({ 2 }, 4.0);
792
793        auto result = ufunc_square(arr);
794
795        // Convert back to double to check values
796        auto typed_result = numpy::astype<double>(result);
797        if (std::abs(typed_result.getElementAt({ 0 }) - 4.0) > 1e-10 ||
798          std::abs(typed_result.getElementAt({ 1 }) - 9.0) > 1e-10 ||
799          std::abs(typed_result.getElementAt({ 2 }) - 16.0) > 1e-10) {
800          std::cout << "[FAIL] Basic frompyfunc creation failed";
801          return 1;
802        }
803
804        // std::cout << "[OK] Basic frompyfunc creation works correctly" << std::endl;
805        std::cout << " -> tests passed" << std::endl;
806        return 0;
astype (np_test_3_all.cpp:796)
786        auto ufunc_square = numpy::frompyfunc(square, 1, 1);
787
788        numpy::NDArray<double> arr({ 3 });
789        arr.setElementAt({ 0 }, 2.0);
790        arr.setElementAt({ 1 }, 3.0);
791        arr.setElementAt({ 2 }, 4.0);
792
793        auto result = ufunc_square(arr);
794
795        // Convert back to double to check values
796        auto typed_result = numpy::astype<double>(result);
797        if (std::abs(typed_result.getElementAt({ 0 }) - 4.0) > 1e-10 ||
798          std::abs(typed_result.getElementAt({ 1 }) - 9.0) > 1e-10 ||
799          std::abs(typed_result.getElementAt({ 2 }) - 16.0) > 1e-10) {
800          std::cout << "[FAIL] Basic frompyfunc creation failed";
801          return 1;
802        }
803
804        // std::cout << "[OK] Basic frompyfunc creation works correctly" << std::endl;
805        std::cout << " -> tests passed" << std::endl;
806        return 0;
copy (np_test_1_all.cpp:9812)
9802    //original.printArray();
9803
9804    // The modification should be at position (1,1) in original
9805    if (!(original.getElementAt({1, 1}) == 9999)) {
9806        std::string description = std::string("testSliceCopyVsViewMemoryOwnership():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 1}) == 9999)";
9807        std::cout << std::string("[FAIL] ") + description << std::endl;
9808        throw std::runtime_error(description);
9809    }
9810    // std::cout << "[OK] Slice view shares memory with original";
9811
9812    // Test slice copy (should be independent)
9813    auto slice_copy = original.sliceArray({{2, 4}, {2, 4}});
9814    // std::cout << "Slice copy [2:4, 2:4]:";
9815    //slice_copy.printArray();
9816
9817    slice_copy.setElementAt({0, 0}, 7777);
9818
9819    // std::cout << "After modifying slice copy at (0,0):" << std::endl;
9820    // std::cout << "Original array:" << std::endl;
9821    //original.printArray();
9822    // std::cout << "Slice copy:" << std::endl;
combine (np_test_5_all.cpp:22273)
22263      auto pass = true;
22264      std::string fail_msg;
22265
22266      // Default constructor (NaT)
22267      numpy::Timestamp nat;
22268      if (!nat.isNaT()) {
22269        pass = false;
22270        fail_msg = "Default constructor should create NaT";
22271      }
22272
22273      // Component constructor
22274      numpy::Timestamp ts1(2024, 6, 15, 14, 30, 45);
22275      if (ts1.year() != 2024 || ts1.month() != 6 || ts1.day() != 15 ||
22276          ts1.hour() != 14 || ts1.minute() != 30 || ts1.second() != 45) {
22277        pass = false;
22278        fail_msg = "Component constructor values incorrect";
22279      }
22280
22281      // With microseconds and nanoseconds
22282      numpy::Timestamp ts2(2024, 1, 1, 12, 0, 0, 123456, 789);
A (np_test_1_all.cpp:15562)
15552    auto pseudoinv = pinv(matrix);
15553
15554    // std::cout << "Pseudoinverse:" << std::endl;
15555    //pseudoinv.printArray();
15556
15557    // Test Moore-Penrose conditions
15558    // 1. A * A^+ * A = A
15559    auto AApA = matmul(matmul(matrix, pseudoinv), matrix);
15560
15561    // std::cout << "A * A^+ * A (should equal A):" << std::endl;
15562    //AApA.printArray();
15563
15564    // Check reconstruction
15565    double max_error = 0.0;
15566    for (size_t i = 0; i < 3; ++i) {
15567      for (size_t j = 0; j < 2; ++j) {
15568        double error = std::abs(matrix.getElementAt({ i, j }) - AApA.getElementAt({ i, j }));
15569        if (error > max_error) max_error = error;
15570      }
15571    }
A (np_test_1_all.cpp:15562)
15552    auto pseudoinv = pinv(matrix);
15553
15554    // std::cout << "Pseudoinverse:" << std::endl;
15555    //pseudoinv.printArray();
15556
15557    // Test Moore-Penrose conditions
15558    // 1. A * A^+ * A = A
15559    auto AApA = matmul(matmul(matrix, pseudoinv), matrix);
15560
15561    // std::cout << "A * A^+ * A (should equal A):" << std::endl;
15562    //AApA.printArray();
15563
15564    // Check reconstruction
15565    double max_error = 0.0;
15566    for (size_t i = 0; i < 3; ++i) {
15567      for (size_t j = 0; j < 2; ++j) {
15568        double error = std::abs(matrix.getElementAt({ i, j }) - AApA.getElementAt({ i, j }));
15569        if (error > max_error) max_error = error;
15570      }
15571    }
B (np_test_2_all.cpp:3245)
3235      mkl_set_num_threads(4);
3236      int num_threads = mkl_get_max_threads();
3237      // std::cout << "MKL Max Threads: " << num_threads << std::endl;
3238
3239      std::cout << " -> tests passed" << std::endl;
3240    }
3241
3242    void testMKLMatrixMultiplication() {
3243      std::cout << "========= testMKLMatrixMultiplication =======================";
3244
3245      // Create test matrices: A (3x4) * B (4x2) = C (3x2)
3246      const int m = 3, n = 2, k = 4;
3247
3248      // Matrix A (3x4) - row major order
3249      std::vector<double> A = {
3250          1.0, 2.0, 3.0, 4.0,    // row 0
3251          5.0, 6.0, 7.0, 8.0,    // row 1
3252          9.0, 10.0, 11.0, 12.0  // row 2
3253      };
3254
3255      // Matrix B (4x2) - row major order
axes (np_test_5_all.cpp:16631)
16621        return 0;
16622    } else {
16623        std::cout << "  [FAIL] reshape() failed" << std::endl;
16624        return 1;
16625    }
16626}
16627
16628// Test 15: transpose() - Transpose array (SKIPPED - needs implementation)
16629int test_transpose() {
16630    std::cout << "\n[TEST] ma.transpose() - SKIPPED (needs correct transpose API)" << std::endl;
16631    return 0;  // Skip for now
16632}
16633
16634// Test 16: swapaxes() - Swap two axes (SKIPPED - needs implementation)
16635int test_swapaxes() {
16636    std::cout << "\n[TEST] ma.swapaxes() - SKIPPED (needs correct swapaxes API)" << std::endl;
16637    return 0;  // Skip for now
16638}
16639
16640// Test 17: repeat() - Repeat elements
16641int test_repeat() {
b (np_test_1_all.cpp:7707)
7697    // std::cout << "Float16 ones array (2x3):";
7698    //ones_array.printArray();
7699
7700    std::cout << " -> tests passed" << std::endl;
7701}
7702
7703void testFloat16ArithmeticFloat16() {
7704    std::cout << "========= testFloat16ArithmeticFloat16 =======================";
7705
7706    float16 a(2.5f);
7707    float16 b(1.5f);
7708
7709    // std::cout << "a = " << a << ", b = " << b << std::endl;
7710    // std::cout << "a + b = " << (a + b) << std::endl;
7711    // std::cout << "a - b = " << (a - b) << std::endl;
7712    // std::cout << "a * b = " << (a * b) << std::endl;
7713    // std::cout << "a / b = " << (a / b) << std::endl;
7714
7715    // Test array arithmetic
7716    auto arr1 = createFloat16Array({2}, float16(2.5f));
7717    auto arr2 = createFloat16Array({2}, float16(1.5f));
begin (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
begin (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
bool_ (np_test_3_all.cpp:15233)
15223      std::cout << "========= test_where_selection ====";
15224
15225      // Create condition, x, and y arrays
15226      auto cond_data = createBoolArray({ 4 }, false);
15227      cond_data.setElementAt({ 0 }, true);
15228      cond_data.setElementAt({ 1 }, false);
15229      cond_data.setElementAt({ 2 }, true);
15230      cond_data.setElementAt({ 3 }, false);
15231
15232      auto cond_mask = createBoolArray({ 4 }, false);
15233      MaskedArray<bool_> condition(cond_data, cond_mask, bool_(false));
15234
15235      auto x_data = createInt32Array({ 4 }, 0);
15236      x_data.setElementAt({ 0 }, 10);
15237      x_data.setElementAt({ 1 }, 20);
15238      x_data.setElementAt({ 2 }, 30);
15239      x_data.setElementAt({ 3 }, 40);
15240
15241      auto x_mask = createBoolArray({ 4 }, false);
15242      MaskedArray<int32> x(x_data, x_mask, -999);
check_file (np_test_5_all.cpp:709)
699          arr.setElementAt({ static_cast<size_t>(i / 3), static_cast<size_t>(i % 3) }, i);
700        }
701
702        writer.add_array("data", arr);
703        writer.finalize();  // Test finalize
704
705        // std::cout << "  NPZ file finalized successfully" << std::endl;
706      }
707
708      // Verify file was written
709      std::ifstream check_file(filename, std::ios::binary);
710      assert_condition(check_file.good(), "NPZ file was not created after finalize()");
711      check_file.close();
712
713      // std::cout << "  Verified NPZ file exists on disk" << std::endl;
714
715      std::cout << " -> tests passed" << std::endl;
716    }
717
718    void np_test_io_npz_add_arrays_to_writer() {
719      std::cout << "========= add_arrays_to_writer() helper ========================";
check_file (np_test_5_all.cpp:709)
699          arr.setElementAt({ static_cast<size_t>(i / 3), static_cast<size_t>(i % 3) }, i);
700        }
701
702        writer.add_array("data", arr);
703        writer.finalize();  // Test finalize
704
705        // std::cout << "  NPZ file finalized successfully" << std::endl;
706      }
707
708      // Verify file was written
709      std::ifstream check_file(filename, std::ios::binary);
710      assert_condition(check_file.good(), "NPZ file was not created after finalize()");
711      check_file.close();
712
713      // std::cout << "  Verified NPZ file exists on disk" << std::endl;
714
715      std::cout << " -> tests passed" << std::endl;
716    }
717
718    void np_test_io_npz_add_arrays_to_writer() {
719      std::cout << "========= add_arrays_to_writer() helper ========================";
clip (np_test_1_all.cpp:15142)
15132      numpy::NDArray<double> values({ 5 });
15133      values.setElementAt({ 0 }, -2.0);
15134      values.setElementAt({ 1 }, -1.0);
15135      values.setElementAt({ 2 }, 0.5);
15136      values.setElementAt({ 3 }, 2.0);
15137      values.setElementAt({ 4 }, 5.0);
15138      double min_val = -1.0;
15139      double max_val = 3.0;
15140
15141      auto clip_result = numpy::clip(values, min_val, max_val);
15142
15143      bool test8_pass = true;
15144      if (std::abs(clip_result.getElementAt({ 0 }) - (-1.0)) > 1e-10 ||
15145        std::abs(clip_result.getElementAt({ 3 }) - 2.0) > 1e-10 ||
15146        std::abs(clip_result.getElementAt({ 4 }) - 3.0) > 1e-10) {
15147        test8_pass = false;
15148      }
15149
15150      if (test8_pass) {
15151        // std::cout << "[OK] Clip function works correctly";
clone (np_test_1_all.cpp:24942)
24932      }
24933
24934      // Test reproducibility
24935      numpy::random::PCG64DXSM rng2(11111);
24936      if (rng2.next_uint64() != val) {
24937        std::cout << "  [FAIL] : in np_test_bitgen_pcg64dxsm() : not reproducible";
24938        throw std::runtime_error("np_test_bitgen_pcg64dxsm failed");
24939      }
24940
24941      // Test clone
24942      auto cloned = rng.clone();
24943      if (cloned->name() != "PCG64DXSM") {
24944        std::cout << "  [FAIL] : in np_test_bitgen_pcg64dxsm() : clone name incorrect";
24945        throw std::runtime_error("np_test_bitgen_pcg64dxsm failed");
24946      }
24947
24948      std::cout << " -> tests passed" << std::endl;
24949    }
24950
24951    // ============================================================================
24952    // PHILOX TESTS
column (np_test_4_all.cpp:21695)
21685        data.setElementAt({0, 1}, 2.0);
21686        data.setElementAt({0, 2}, 3.0);
21687        data.setElementAt({1, 0}, 4.0);
21688        data.setElementAt({1, 1}, 5.0);
21689        data.setElementAt({1, 2}, 6.0);
21690        data.setElementAt({2, 0}, 7.0);
21691        data.setElementAt({2, 1}, 8.0);
21692        data.setElementAt({2, 2}, 9.0);
21693
21694        NDArray<bool_> mask({3, 3}, bool_(false));
21695        // Mask entire middle column (col 1)
21696        mask.setElementAt({0, 1}, bool_(true));
21697        mask.setElementAt({1, 1}, bool_(true));
21698        mask.setElementAt({2, 1}, bool_(true));
21699
21700        auto ma = ma::masked_array(data, mask);
21701        auto result = ma::compress_cols(ma);
21702
21703        // Should keep columns 0 and 2 only
21704        if (!(result.getShape()[0] == 3)) {
21705            std::string description = std::string("np_test_phase6c_compress_cols():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getShape()[0] == 3)";
column (np_test_4_all.cpp:21695)
21685        data.setElementAt({0, 1}, 2.0);
21686        data.setElementAt({0, 2}, 3.0);
21687        data.setElementAt({1, 0}, 4.0);
21688        data.setElementAt({1, 1}, 5.0);
21689        data.setElementAt({1, 2}, 6.0);
21690        data.setElementAt({2, 0}, 7.0);
21691        data.setElementAt({2, 1}, 8.0);
21692        data.setElementAt({2, 2}, 9.0);
21693
21694        NDArray<bool_> mask({3, 3}, bool_(false));
21695        // Mask entire middle column (col 1)
21696        mask.setElementAt({0, 1}, bool_(true));
21697        mask.setElementAt({1, 1}, bool_(true));
21698        mask.setElementAt({2, 1}, bool_(true));
21699
21700        auto ma = ma::masked_array(data, mask);
21701        auto result = ma::compress_cols(ma);
21702
21703        // Should keep columns 0 and 2 only
21704        if (!(result.getShape()[0] == 3)) {
21705            std::string description = std::string("np_test_phase6c_compress_cols():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getShape()[0] == 3)";
columns (np_test_4_all.cpp:22531)
22521    mask.setElementAt({1, 3}, false);
22522
22523    mask.setElementAt({2, 0}, false);
22524    mask.setElementAt({2, 1}, true);
22525    mask.setElementAt({2, 2}, true);
22526    mask.setElementAt({2, 3}, false);
22527
22528    MaskedArray<int> marr(data, mask);
22529    auto result = numpy::ma::compress_nd(marr, 1);
22530
22531    // Should have 2 columns (columns 0 and 3)
22532    if (!(result.data().getShape().size() == 2)) {
22533        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape().size() == 2)";
22534        std::cout << std::string("[FAIL] ") + description << std::endl;
22535        throw std::runtime_error(description);
22536    }
22537    if (!(result.data().getShape()[0] == 3)) {
22538        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape()[0] == 3)";
22539        std::cout << std::string("[FAIL] ") + description << std::endl;
22540        throw std::runtime_error(description);
22541    }
columns (np_test_4_all.cpp:22531)
22521    mask.setElementAt({1, 3}, false);
22522
22523    mask.setElementAt({2, 0}, false);
22524    mask.setElementAt({2, 1}, true);
22525    mask.setElementAt({2, 2}, true);
22526    mask.setElementAt({2, 3}, false);
22527
22528    MaskedArray<int> marr(data, mask);
22529    auto result = numpy::ma::compress_nd(marr, 1);
22530
22531    // Should have 2 columns (columns 0 and 3)
22532    if (!(result.data().getShape().size() == 2)) {
22533        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape().size() == 2)";
22534        std::cout << std::string("[FAIL] ") + description << std::endl;
22535        throw std::runtime_error(description);
22536    }
22537    if (!(result.data().getShape()[0] == 3)) {
22538        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape()[0] == 3)";
22539        std::cout << std::string("[FAIL] ") + description << std::endl;
22540        throw std::runtime_error(description);
22541    }
columns (np_test_4_all.cpp:22531)
22521    mask.setElementAt({1, 3}, false);
22522
22523    mask.setElementAt({2, 0}, false);
22524    mask.setElementAt({2, 1}, true);
22525    mask.setElementAt({2, 2}, true);
22526    mask.setElementAt({2, 3}, false);
22527
22528    MaskedArray<int> marr(data, mask);
22529    auto result = numpy::ma::compress_nd(marr, 1);
22530
22531    // Should have 2 columns (columns 0 and 3)
22532    if (!(result.data().getShape().size() == 2)) {
22533        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape().size() == 2)";
22534        std::cout << std::string("[FAIL] ") + description << std::endl;
22535        throw std::runtime_error(description);
22536    }
22537    if (!(result.data().getShape()[0] == 3)) {
22538        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape()[0] == 3)";
22539        std::cout << std::string("[FAIL] ") + description << std::endl;
22540        throw std::runtime_error(description);
22541    }
columns (np_test_4_all.cpp:22531)
22521    mask.setElementAt({1, 3}, false);
22522
22523    mask.setElementAt({2, 0}, false);
22524    mask.setElementAt({2, 1}, true);
22525    mask.setElementAt({2, 2}, true);
22526    mask.setElementAt({2, 3}, false);
22527
22528    MaskedArray<int> marr(data, mask);
22529    auto result = numpy::ma::compress_nd(marr, 1);
22530
22531    // Should have 2 columns (columns 0 and 3)
22532    if (!(result.data().getShape().size() == 2)) {
22533        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape().size() == 2)";
22534        std::cout << std::string("[FAIL] ") + description << std::endl;
22535        throw std::runtime_error(description);
22536    }
22537    if (!(result.data().getShape()[0] == 3)) {
22538        std::string description = std::string("test_compress_nd_2d_axis1():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.data().getShape()[0] == 3)";
22539        std::cout << std::string("[FAIL] ") + description << std::endl;
22540        throw std::runtime_error(description);
22541    }
count (np_test_1_all.cpp:3616)
3606    // Create larger arrays for performance testing
3607    auto large_arr = NDArray<double>::createOnes({100, 100});
3608    auto broadcast_arr = NDArray<double>::createOnes({1, 100});
3609
3610    // Time the operation (basic timing)
3611    auto start = std::chrono::high_resolution_clock::now();
3612    auto result = large_arr.addArrays(broadcast_arr);
3613    auto end = std::chrono::high_resolution_clock::now();
3614
3615    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - start);
3616    // std::cout << "Large array broadcasting took " << duration.count() << " microseconds" << std::endl;
3617
3618    // Verify result shape
3619    if (!((result.getShape() == std::vector<size_t>{100, 100}))) {
3620        std::string description = std::string("test_broadcasting_performance():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !((result.getShape() == std::vector<size_t>{100, 100}))";
3621        std::cout << std::string("[FAIL] ") + description << std::endl;
3622        throw std::runtime_error(description);
3623    }
3624    if (!(result.getElementAt({50, 50}) == 2.0)) {
3625        std::string description = std::string("test_broadcasting_performance():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.getElementAt({50, 50}) == 2.0)";
3626        std::cout << std::string("[FAIL] ") + description << std::endl;
cumprod (np_test_5_all.cpp:5107)
5097    }
5098
5099    void np_test_cumprod_1d() {
5100      std::cout << "========= cumprod 1D =======================";
5101
5102      // Test cumprod with 1D array
5103      numpy::NDArray<int32_t> arr({ 5 });
5104      arr.setElementAt({ 0 }, 1);
5105      arr.setElementAt({ 1 }, 2);
5106      arr.setElementAt({ 2 }, 3);
5107      arr.setElementAt({ 3 }, 4);
5108      arr.setElementAt({ 4 }, 5);
5109
5110      auto result = numpy::cumprod(arr);
5111
5112      // Expected: [1, 2, 6, 24, 120]
5113      if (result.getElementAt({ 0 }) != 1 || result.getElementAt({ 1 }) != 2 ||
5114        result.getElementAt({ 2 }) != 6 || result.getElementAt({ 3 }) != 24 ||
5115        result.getElementAt({ 4 }) != 120) {
5116        std::cout << "  [FAIL] : in np_test_cumprod_1d() : Incorrect cumprod result";
5117        throw std::runtime_error("Test failed");
cumsum (np_test_5_all.cpp:5028)
5018  namespace numpy_tests_cumulative_operations {
5019
5020    void np_test_cumsum_1d() {
5021      std::cout << "========= cumsum 1D =======================";
5022
5023      // Test cumsum with 1D array
5024      numpy::NDArray<int32_t> arr({ 5 });
5025      arr.setElementAt({ 0 }, 1);
5026      arr.setElementAt({ 1 }, 2);
5027      arr.setElementAt({ 2 }, 3);
5028      arr.setElementAt({ 3 }, 4);
5029      arr.setElementAt({ 4 }, 5);
5030
5031      auto result = numpy::cumsum(arr);
5032
5033      // Expected: [1, 3, 6, 10, 15]
5034      if (result.getElementAt({ 0 }) != 1 || result.getElementAt({ 1 }) != 3 ||
5035        result.getElementAt({ 2 }) != 6 || result.getElementAt({ 3 }) != 10 ||
5036        result.getElementAt({ 4 }) != 15) {
5037        std::cout << "  [FAIL] : in np_test_cumsum_1d() : Incorrect cumsum result";
5038        throw std::runtime_error("Test failed");
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
data (np_test_1_all.cpp:2084)
2074    }
2075    if (!(derived_ptr->extra == 2)) {
2076        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(derived_ptr->extra == 2)";
2077        std::cout << std::string("[FAIL] ") + description << std::endl;
2078        throw std::runtime_error(description);
2079    }
2080
2081    // Test 6: Large object handling
2082    struct LargeObject {
2083        std::vector<double> data;
2084        LargeObject() : data(10000, 3.14159) {}  // Large object
2085    };
2086
2087    LargeObject large;
2088    object_ large_obj(large);  // Should handle large objects
2089    if (!(!large_obj.is_null())) {
2090        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!large_obj.is_null())";
2091        std::cout << std::string("[FAIL] ") + description << std::endl;
2092        throw std::runtime_error(description);
2093    }
2094    if (!(large_obj.is_type<LargeObject>())) {
describe (np_test_1_all.cpp:11448)
11438    auto moment2_result = moment(normal_data, 2);
11439    // std::cout << "2nd moment: " << moment2_result.getElementAt({ 0 }) << std::endl;
11440    if (!(moment2_result.getElementAt({ 0 }) > 0)) {
11441        std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(moment2_result.getElementAt({ 0 }) > 0)";
11442        std::cout << std::string("[FAIL] ") + description << std::endl;
11443        throw std::runtime_error(description);
11444    }
11445    // std::cout << "[OK] Moment calculation\n";
11446
11447    // Test describe
11448    auto desc_result = describe(normal_data);
11449    // std::cout << "Describe result:" << std::endl;
11450    // std::cout << "  nobs: " << desc_result.nobs << std::endl;
11451    // std::cout << "  min: " << desc_result.minmax.first << ", max: " << desc_result.minmax.second << std::endl;
11452    // std::cout << "  mean: " << desc_result.mean << std::endl;
11453    // std::cout << "  variance: " << desc_result.variance << std::endl;
11454    if (!(desc_result.nobs == 5)) {
11455        std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(desc_result.nobs == 5)";
11456        std::cout << std::string("[FAIL] ") + description << std::endl;
11457        throw std::runtime_error(description);
11458    }
diff (np_test_2_all.cpp:4947)
4937      // Test matrix addition and subtraction
4938      numpy::Matrix<double> a("1 2; 3 4");
4939      numpy::Matrix<double> b("5 6; 7 8");
4940
4941      auto sum = a + b;
4942      assert_test(std::abs(sum(0, 0) - 6.0) < 1e-10, "Matrix addition");
4943      assert_test(std::abs(sum(1, 1) - 12.0) < 1e-10, "Matrix addition");
4944
4945      auto diff = b - a;
4946      assert_test(std::abs(diff(0, 0) - 4.0) < 1e-10, "Matrix subtraction");
4947      assert_test(std::abs(diff(1, 1) - 4.0) < 1e-10, "Matrix subtraction");
4948
4949      // Test matrix multiplication (not element-wise!)
4950      auto product = a * b;
4951      assert_test(std::abs(product(0, 0) - 19.0) < 1e-10, "Matrix multiplication 0,0");
4952      assert_test(std::abs(product(0, 1) - 22.0) < 1e-10, "Matrix multiplication 0,1");
4953      assert_test(std::abs(product(1, 0) - 43.0) < 1e-10, "Matrix multiplication 1,0");
4954      assert_test(std::abs(product(1, 1) - 50.0) < 1e-10, "Matrix multiplication 1,1");
4955
4956      // Test scalar multiplication
dtype_name (np_test_2_all.cpp:3567)
3557          std::cout << std::string("[FAIL] ") + description << std::endl;
3558          throw std::runtime_error(description);
3559      }
3560      if (!(flags_info.writeable == true)) {
3561          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(flags_info.writeable == true)";
3562          std::cout << std::string("[FAIL] ") + description << std::endl;
3563          throw std::runtime_error(description);
3564      }
3565
3566      // Test dtype functions
3567      if (!(dtype_name(arr) == "float64")) {
3568          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(dtype_name(arr) == \"float64\")";
3569          std::cout << std::string("[FAIL] ") + description << std::endl;
3570          throw std::runtime_error(description);
3571      }
3572      if (!(dtype_itemsize(arr) == sizeof(double))) {
3573          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(dtype_itemsize(arr) == sizeof(double))";
3574          std::cout << std::string("[FAIL] ") + description << std::endl;
3575          throw std::runtime_error(description);
3576      }
dtypes (np_test_4_all.cpp:10403)
10393    }
10394    catch (const std::exception& e) {
10395      std::cout << "====================================== np_test_power_scalar FAILED ==================================== ";
10396      std::cout << "Exception: " << e.what() << std::endl;
10397      return 1;
10398    }
10399  }
10400
10401} // namespace numpy_tests
10402// Test file for abs() scalar support
10403// Tests all 13 dtypes (8 int, 1 bool, 2 float, 2 complex) + edge cases
10404// Expected: 17 tests, all passing
10405
10406#include <iostream>
10407#include <cmath>
10408#include <stdexcept>
10409#include "../numpy/np_ndarray.h"
10410#include "../numpy/np_math_utils_sqrt.h"
10411
10412namespace numpy_tests {
10413namespace numpy_tests_abs_scalar {
end (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
end (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
end (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
end (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
end (np_test_1_all.cpp:6171)
6161    // Test sorted data generation
6162    std::vector<int> data = gen.generate(50, DataPattern::SORTED);
6163
6164    if (!(data.size() == 50)) {
6165        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 50)";
6166        std::cout << std::string("[FAIL] ") + description << std::endl;
6167        throw std::runtime_error(description);
6168    }
6169
6170    // Verify data is sorted
6171    if (!(std::is_sorted(data.begin(), data.end()))) {
6172        std::string description = std::string("test_data_generator_sortedBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::is_sorted(data.begin(), data.end()))";
6173        std::cout << std::string("[FAIL] ") + description << std::endl;
6174        throw std::runtime_error(description);
6175    }
6176
6177    // std::cout << "Sorted data generation test passed" << std::endl;
6178
6179    std::cout << " -> tests passed" << std::endl;
6180}
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
file (np_test_1_all.cpp:27026)
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream
27026      std::ifstream file(test_filename, std::ios::binary);
27027      file.seekg(30);  // Move to position 30
27028      size_t size2 = io::get_remaining_size(file);
27029      if (size2 != 70) {
27030        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 70 remaining bytes, got " << size2;
27031        throw std::runtime_error("test_get_remaining_size failed: incorrect remaining size");
27032      }
27033
27034      // Verify position preserved
27035      auto pos = file.tellg();
27036      if (pos != 30) {
filter (np_test_2_all.cpp:9555)
9545      for (int i = 0; i < size; i++) {
9546        signal[i] = std::sin(2.0f * 3.14159f * i / 8.0f) + 0.1f * (i % 3 - 1);
9547      }
9548
9549      // std::cout << "Original Signal: ";
9550      for (int i = 0; i < size; i++) {
9551        // std::cout << std::setw(8) << std::fixed << std::setprecision(3) << signal[i] << " ";
9552      }
9553      // std::cout << std::endl;
9554
9555      // Apply a simple smoothing filter (moving average)
9556      const int kernel_size = 3;
9557      std::vector<Ipp32f> kernel = { 1.0f / 3.0f, 1.0f / 3.0f, 1.0f / 3.0f };
9558
9559      // For simplicity, we'll do a basic convolution manually for demonstration
9560      for (int i = 1; i < size - 1; i++) {
9561        filtered[i] = (signal[i - 1] + signal[i] + signal[i + 1]) / 3.0f;
9562      }
9563      filtered[0] = signal[0];
9564      filtered[size - 1] = signal[size - 1];
first (np_test_4_all.cpp:12410)
12400    // std::cout << "[OK] NaN-ignoring behavior tests\n";
12401}
12402
12403// Test both NaN returns first NaN
12404void test_fmax_both_nan() {
12405    std::cout << "========= test_fmax_both_nan ====";
12406
12407    double nan1 = std::numeric_limits<double>::quiet_NaN();
12408    double nan2 = std::numeric_limits<double>::quiet_NaN();
12409
12410    // If both are NaN, return first (which is still NaN)
12411    double result = numpy::fmax(nan1, nan2);
12412    if (!std::isnan(result)) {
12413        std::cout << "  [FAIL] : test_fmax_both_nan failed - fmax(NaN, NaN) should be NaN";
12414        throw std::runtime_error("fmax(NaN, NaN) should return NaN");
12415    }
12416
12417    // std::cout << "[OK] Both NaN returns NaN test\n";
12418}
12419
12420// Test type preservation
flags (np_test_2_all.cpp:3554)
3544      }
3545
3546      // Test nbytes
3547      if (!(nbytes(arr) == 24 * sizeof(double))) {
3548          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(nbytes(arr) == 24 * sizeof(double))";
3549          std::cout << std::string("[FAIL] ") + description << std::endl;
3550          throw std::runtime_error(description);
3551      }
3552
3553      // Test flags
3554      auto flags_info = flags(arr);
3555      if (!(flags_info.owndata == true)) {
3556          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(flags_info.owndata == true)";
3557          std::cout << std::string("[FAIL] ") + description << std::endl;
3558          throw std::runtime_error(description);
3559      }
3560      if (!(flags_info.writeable == true)) {
3561          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(flags_info.writeable == true)";
3562          std::cout << std::string("[FAIL] ") + description << std::endl;
3563          throw std::runtime_error(description);
3564      }
found (np_test_1_all.cpp:27676)
27666    void test_clump_masked_unmasked() {
27667      std::cout << "========= ma::clump_masked() and ma::clump_unmasked(): find sequences ===";
27668
27669      auto data = numpy::array({ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 });
27670      auto mask = numpy::array({ false, true, true, false, false, true });
27671      auto ma = numpy::ma::masked_array(data, mask);
27672
27673      auto masked_clumps = numpy::ma::clump_masked(ma);
27674      auto unmasked_clumps = numpy::ma::clump_unmasked(ma);
27675
27676      // std::cout << "  ma::clump_masked([F,T,T,F,F,T]): " << masked_clumps.size() << " sequences found (expected: 2)" << std::endl;
27677      // std::cout << "  ma::clump_unmasked([F,T,T,F,F,T]): " << unmasked_clumps.size() << " sequences found (expected: 2)" << std::endl;
27678      std::cout << " -> tests passed" << std::endl;
27679    }
27680
27681    void test_mask_rows_cols() {
27682      std::cout << "========= ma::mask_rows() and ma::mask_cols(): mask operations ===";
27683
27684      auto data = numpy::array({ {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0} });
27685      auto mask = numpy::array({ {false, true, false}, {false, false, false} });
27686      auto ma = numpy::ma::masked_array(data, mask);
found (np_test_1_all.cpp:27676)
27666    void test_clump_masked_unmasked() {
27667      std::cout << "========= ma::clump_masked() and ma::clump_unmasked(): find sequences ===";
27668
27669      auto data = numpy::array({ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 });
27670      auto mask = numpy::array({ false, true, true, false, false, true });
27671      auto ma = numpy::ma::masked_array(data, mask);
27672
27673      auto masked_clumps = numpy::ma::clump_masked(ma);
27674      auto unmasked_clumps = numpy::ma::clump_unmasked(ma);
27675
27676      // std::cout << "  ma::clump_masked([F,T,T,F,F,T]): " << masked_clumps.size() << " sequences found (expected: 2)" << std::endl;
27677      // std::cout << "  ma::clump_unmasked([F,T,T,F,F,T]): " << unmasked_clumps.size() << " sequences found (expected: 2)" << std::endl;
27678      std::cout << " -> tests passed" << std::endl;
27679    }
27680
27681    void test_mask_rows_cols() {
27682      std::cout << "========= ma::mask_rows() and ma::mask_cols(): mask operations ===";
27683
27684      auto data = numpy::array({ {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0} });
27685      auto mask = numpy::array({ {false, true, false}, {false, false, false} });
27686      auto ma = numpy::ma::masked_array(data, mask);
gen (np_test_1_all.cpp:6126)
6116    }
6117
6118    // std::cout << "BenchmarkResult storage test passed" << std::endl;
6119
6120    std::cout << " -> tests passed" << std::endl;
6121}
6122
6123void test_data_generator_randomBenchmarkSorting() {
6124    std::cout << "========= test_data_generator_random =======================";
6125
6126    DataGenerator<int> gen(42); // Fixed seed for reproducibility
6127
6128    // Test random data generation
6129    std::vector<int> data = gen.generate(100, DataPattern::RANDOM);
6130
6131    if (!(data.size() == 100)) {
6132        std::string description = std::string("test_data_generator_randomBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(data.size() == 100)";
6133        std::cout << std::string("[FAIL] ") + description << std::endl;
6134        throw std::runtime_error(description);
6135    }
index (np_test_5_all.cpp:1283)
1273    // ============================================================================
1274    // SEARCH OPERATION TESTS
1275    // ============================================================================
1276
1277    void np_test_string_index() {
1278      std::cout << "========= index search operation =======================";
1279
1280      std::vector<std::string> strings = { "hello world", "tomorrow" };
1281      auto arr = numpy::char_::array<32>(strings);
1282      auto indices = numpy::char_::index(arr, "o");
1283
1284      bool passed = (indices.getSize() == arr.size());
1285
1286      if (!passed) {
1287        std::cout << "  [FAIL] : in np_test_string_index() : indices size mismatch";
1288        throw std::runtime_error("np_test_string_index failed");
1289      }
1290
1291      std::cout << " -> tests passed" << std::endl;
1292    }
index (np_test_5_all.cpp:1283)
1273    // ============================================================================
1274    // SEARCH OPERATION TESTS
1275    // ============================================================================
1276
1277    void np_test_string_index() {
1278      std::cout << "========= index search operation =======================";
1279
1280      std::vector<std::string> strings = { "hello world", "tomorrow" };
1281      auto arr = numpy::char_::array<32>(strings);
1282      auto indices = numpy::char_::index(arr, "o");
1283
1284      bool passed = (indices.getSize() == arr.size());
1285
1286      if (!passed) {
1287        std::cout << "  [FAIL] : in np_test_string_index() : indices size mismatch";
1288        throw std::runtime_error("np_test_string_index failed");
1289      }
1290
1291      std::cout << " -> tests passed" << std::endl;
1292    }
info (np_test_2_all.cpp:19772)
19762    // ============================================================================
19763    // INFO TESTS (using primitive types to avoid NDArray complexities)
19764    // ============================================================================
19765
19766    void np_test_introspection_info() {
19767      std::cout << "========= info: display object information =======================";
19768
19769      // Test info on primitive type
19770      int x = 42;
19771      // std::cout << "Primitive type info:" << std::endl;
19772      numpy::introspection::info(x);
19773
19774      double y = 3.14;
19775      // std::cout << "Double type info:" << std::endl;
19776      numpy::introspection::info(y, true);
19777
19778      bool passed = true;  // Just verify no exceptions
19779
19780      if (!passed) {
19781        std::cout << "  [FAIL] : in np_test_introspection_info() : info test failed";
19782        throw std::runtime_error("np_test_introspection_info failed");
join (np_test_5_all.cpp:1341)
1331    // ============================================================================
1332
1333    void np_test_string_join() {
1334      std::cout << "========= join operation =======================";
1335
1336      // Join takes a separator string and vector of CharArrays
1337      std::vector<numpy::CharArray<32>> arrays;
1338      arrays.push_back(numpy::char_::array<32>({ "a", "b", "c" }));
1339      arrays.push_back(numpy::char_::array<32>({ "x", "y", "z" }));
1340
1341      auto result = numpy::char_::join("-", arrays);
1342
1343      bool passed = true;
1344
1345      if (!passed) {
1346        std::cout << "  [FAIL] : in np_test_string_join() : join operation failed";
1347        throw std::runtime_error("np_test_string_join failed");
1348      }
1349
1350      std::cout << " -> tests passed" << std::endl;
1351    }
keys (np_test_2_all.cpp:8614)
8604          if (!indices.empty()) {
8605            std::cout << "   IPP empty array test:                                                                   -> [FAIL]";
8606            throw std::runtime_error("IPP empty array test: FAILED - should return empty");
8607          }
8608          // std::cout << "[OK] IPP empty array test: PASSED" << std::endl;
8609        }
8610
8611        // Test 6: Large array performance
8612        {
8613          const size_t n = 10000;
8614          std::vector<std::vector<int>> keys(2);
8615          keys[0].resize(n);
8616          keys[1].resize(n);
8617
8618          std::mt19937 gen(42);
8619          std::uniform_int_distribution<int> dist(0, 1000);
8620
8621          for (size_t i = 0; i < n; ++i) {
8622            keys[0][i] = dist(gen);
8623            keys[1][i] = dist(gen);
8624          }
keys (np_test_2_all.cpp:8614)
8604          if (!indices.empty()) {
8605            std::cout << "   IPP empty array test:                                                                   -> [FAIL]";
8606            throw std::runtime_error("IPP empty array test: FAILED - should return empty");
8607          }
8608          // std::cout << "[OK] IPP empty array test: PASSED" << std::endl;
8609        }
8610
8611        // Test 6: Large array performance
8612        {
8613          const size_t n = 10000;
8614          std::vector<std::vector<int>> keys(2);
8615          keys[0].resize(n);
8616          keys[1].resize(n);
8617
8618          std::mt19937 gen(42);
8619          std::uniform_int_distribution<int> dist(0, 1000);
8620
8621          for (size_t i = 0; i < n; ++i) {
8622            keys[0][i] = dist(gen);
8623            keys[1][i] = dist(gen);
8624          }
kurtosis (np_test_1_all.cpp:11433)
11423    // std::cout << "Skewness of [1,2,3,4,5]: " << skew_result.getElementAt({ 0 }) << std::endl;
11424    // Should be close to 0 for symmetric data
11425    if (!(std::abs(skew_result.getElementAt({ 0 })) < 0.1)) {
11426        std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::abs(skew_result.getElementAt({ 0 })) < 0.1)";
11427        std::cout << std::string("[FAIL] ") + description << std::endl;
11428        throw std::runtime_error(description);
11429    }
11430    // std::cout << "[OK] Skewness calculation\n";
11431
11432    // Test kurtosis
11433    auto kurt_result = kurtosis(normal_data);
11434    // std::cout << "Kurtosis of [1,2,3,4,5]: " << kurt_result.getElementAt({ 0 }) << std::endl;
11435    // std::cout << "[OK] Kurtosis calculation\n";
11436
11437    // Test moment
11438    auto moment2_result = moment(normal_data, 2);
11439    // std::cout << "2nd moment: " << moment2_result.getElementAt({ 0 }) << std::endl;
11440    if (!(moment2_result.getElementAt({ 0 }) > 0)) {
11441        std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(moment2_result.getElementAt({ 0 }) > 0)";
11442        std::cout << std::string("[FAIL] ") + description << std::endl;
11443        throw std::runtime_error(description);
levels (np_test_5_all.cpp:105)
 95            }
 96
 97            std::cout << " -> tests passed" << std::endl;
 98        }
 99
100        // ===========================================================================
101        // Test 2: Compression Levels
102        // ===========================================================================
103
104        void np_test_zlib_compression_levels() {
105            std::cout << "========= compression levels (0-9) =============================";
106
107            std::vector<unsigned char> data = create_test_data(1000, 'A');
108
109            for (int level = 0; level <= 9; ++level) {
110                uLongf compressed_len = compressBound(static_cast<uLong>(data.size()));
111                std::vector<Bytef> compressed(compressed_len);
112
113                int result = compress2(compressed.data(), &compressed_len,
114                                      data.data(), static_cast<uLong>(data.size()), level);
mask (np_test_1_all.cpp:27691)
27681    void test_mask_rows_cols() {
27682      std::cout << "========= ma::mask_rows() and ma::mask_cols(): mask operations ===";
27683
27684      auto data = numpy::array({ {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0} });
27685      auto mask = numpy::array({ {false, true, false}, {false, false, false} });
27686      auto ma = numpy::ma::masked_array(data, mask);
27687
27688      auto result_rows = numpy::ma::mask_rows(ma);
27689      auto result_cols = numpy::ma::mask_cols(ma);
27690
27691      // std::cout << "  ma::mask_rows(): row 0 fully masked: " << (result_rows.mask().getElementAt({ 0, 0 }) ? "true" : "false") << std::endl;
27692      // std::cout << "  ma::mask_cols(): column 1 fully masked: " << (result_cols.mask().getElementAt({ 1, 1 }) ? "true" : "false");
27693      std::cout << " -> tests passed";
27694    }
27695
27696    void test_compress_rowcols() {
27697      std::cout << "========= ma::compress_rowcols(): remove masked rows/columns ===";
27698
27699      auto data = numpy::array({ {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}, {7.0, 8.0, 9.0} });
27700      auto mask = numpy::array({ {false, false, false}, {false, true, false}, {false, false, false} });
27701      auto ma = numpy::ma::masked_array(data, mask);
mask (np_test_1_all.cpp:27691)
27681    void test_mask_rows_cols() {
27682      std::cout << "========= ma::mask_rows() and ma::mask_cols(): mask operations ===";
27683
27684      auto data = numpy::array({ {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0} });
27685      auto mask = numpy::array({ {false, true, false}, {false, false, false} });
27686      auto ma = numpy::ma::masked_array(data, mask);
27687
27688      auto result_rows = numpy::ma::mask_rows(ma);
27689      auto result_cols = numpy::ma::mask_cols(ma);
27690
27691      // std::cout << "  ma::mask_rows(): row 0 fully masked: " << (result_rows.mask().getElementAt({ 0, 0 }) ? "true" : "false") << std::endl;
27692      // std::cout << "  ma::mask_cols(): column 1 fully masked: " << (result_cols.mask().getElementAt({ 1, 1 }) ? "true" : "false");
27693      std::cout << " -> tests passed";
27694    }
27695
27696    void test_compress_rowcols() {
27697      std::cout << "========= ma::compress_rowcols(): remove masked rows/columns ===";
27698
27699      auto data = numpy::array({ {1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}, {7.0, 8.0, 9.0} });
27700      auto mask = numpy::array({ {false, false, false}, {false, true, false}, {false, false, false} });
27701      auto ma = numpy::ma::masked_array(data, mask);
name (np_test_1_all.cpp:24865)
24855      uint64_t before_restore = rng.next_uint64();
24856      rng.set_state(state);
24857      uint64_t after_restore = rng.next_uint64();
24858
24859      if (before_restore != after_restore) {
24860        std::cout << "  [FAIL] : in np_test_bitgen_mt19937() : state restore failed";
24861        throw std::runtime_error("np_test_bitgen_mt19937 failed: state");
24862      }
24863
24864      // Test name
24865      if (rng.name() != "MT19937") {
24866        std::cout << "  [FAIL] : in np_test_bitgen_mt19937() : incorrect name";
24867        throw std::runtime_error("np_test_bitgen_mt19937 failed: name");
24868      }
24869
24870      std::cout << " -> tests passed" << std::endl;
24871    }
24872
24873    // ============================================================================
24874    // PCG64 TESTS
24875    // ============================================================================
names (np_test_2_all.cpp:18817)
18807      create_txt_file("test_auto_names.txt");
18808
18809      // Don't provide names - should generate f0, f1, f2, f3
18810      auto data = numpy::io::recfromtxt(csv_test_dir + "test_auto_names.txt");
18811
18812      auto dtype = data.getDType();
18813
18814      // Verify auto-generated names
18815      if (!dtype.hasField("f0") || !dtype.hasField("f1") ||
18816        !dtype.hasField("f2") || !dtype.hasField("f3")) {
18817        std::cout << "  [FAIL] : Missing auto-generated field names (f0, f1, f2, f3)";
18818        throw std::runtime_error("np_test_io_extensions_recfromtxt_auto_names failed: missing auto names");
18819      }
18820
18821      std::cout << " -> tests passed" << std::endl;
18822    }
18823
18824    // ============================================================================
18825    // ERROR HANDLING TESTS
18826    // ============================================================================
nbytes (np_test_2_all.cpp:3547)
3537      }
3538
3539      // Test itemsize
3540      if (!(itemsize(arr) == sizeof(double))) {
3541          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(itemsize(arr) == sizeof(double))";
3542          std::cout << std::string("[FAIL] ") + description << std::endl;
3543          throw std::runtime_error(description);
3544      }
3545
3546      // Test nbytes
3547      if (!(nbytes(arr) == 24 * sizeof(double))) {
3548          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(nbytes(arr) == 24 * sizeof(double))";
3549          std::cout << std::string("[FAIL] ") + description << std::endl;
3550          throw std::runtime_error(description);
3551      }
3552
3553      // Test flags
3554      auto flags_info = flags(arr);
3555      if (!(flags_info.owndata == true)) {
3556          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(flags_info.owndata == true)";
3557          std::cout << std::string("[FAIL] ") + description << std::endl;
ndim (np_test_2_all.cpp:3526)
3516    void testArrayInfo() {
3517      std::cout << "Testing array information functions...\n";
3518
3519      // Test basic info functions
3520      auto arr = createFloat64Array({ 2, 3, 4 });
3521      for (size_t i = 0; i < arr.getSize(); ++i) {
3522        arr.setElementAt({ i / 12, (i / 4) % 3, i % 4 }, static_cast<double>(i));
3523      }
3524
3525      // Test ndim
3526      if (!(ndim(arr) == 3)) {
3527          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(ndim(arr) == 3)";
3528          std::cout << std::string("[FAIL] ") + description << std::endl;
3529          throw std::runtime_error(description);
3530      }
3531
3532      // Test size
3533      if (!(size(arr) == 24)) {
3534          std::string description = std::string("testArrayInfo():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(size(arr) == 24)";
3535          std::cout << std::string("[FAIL] ") + description << std::endl;
3536          throw std::runtime_error(description);
objects (np_test_1_all.cpp:2136)
2126        std::string description = std::string("testObjectHolderEdgeCases():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(copy_ptr != large_ptr)";
2127        std::cout << std::string("[FAIL] ") + description << std::endl;
2128        throw std::runtime_error(description);
2129    }
2130    if (!(copy_ptr->data.size() == 10000)) {
2131        std::string description = std::string("unknown_function():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(copy_ptr->data.size() == 10000)";
2132        std::cout << std::string("[FAIL] ") + description << std::endl;
2133        throw std::runtime_error(description);
2134    }
2135
2136    // Test 7: Object containing other objects (if supported)
2137    object_ inner_obj(std::string("inner"));
2138
2139    struct ObjectContainer {
2140        object_ contained;
2141        ObjectContainer(object_ obj) : contained(obj) {}
2142    };
2143
2144    ObjectContainer container(inner_obj);
2145    object_ container_obj(container);
2146    if (!(container_obj.is_type<ObjectContainer>())) {
of (np_test_1_all.cpp:20581)
20571    SchurValidator<std::complex<double>> validator;
20572    SchurBenchmark benchmark("Hermitian matrices");
20573
20574    bool all_passed = true;
20575
20576    // Create Hermitian matrix
20577    NDArray<std::complex<double>> matrix({ 3, 3 });
20578    matrix.setElementAt({ 0, 0 }, std::complex<double>(2, 0));
20579    matrix.setElementAt({ 0, 1 }, std::complex<double>(1, 1));
20580    matrix.setElementAt({ 0, 2 }, std::complex<double>(0, -1));
20581    matrix.setElementAt({ 1, 0 }, std::complex<double>(1, -1));  // Conjugate of (0,1)
20582    matrix.setElementAt({ 1, 1 }, std::complex<double>(3, 0));
20583    matrix.setElementAt({ 1, 2 }, std::complex<double>(1, 0));
20584    matrix.setElementAt({ 2, 0 }, std::complex<double>(0, 1));   // Conjugate of (0,2)
20585    matrix.setElementAt({ 2, 1 }, std::complex<double>(1, 0));
20586    matrix.setElementAt({ 2, 2 }, std::complex<double>(4, 0));
20587
20588    // std::cout << "  Testing 3x3 Hermitian matrix..." << std::endl;
20589
20590    benchmark.time_operation([&]() {
20591      auto schur_result = schur_decomposition(matrix);
pad (np_test_1_all.cpp:18733)
18723    std::cout << "========= testPadding =======================";
18724
18725    // Create test array
18726    auto array = createInt32Array({ 2, 2 }, 0);
18727    array.setElementAt({ 0, 0 }, 1);
18728    array.setElementAt({ 0, 1 }, 2);
18729    array.setElementAt({ 1, 0 }, 3);
18730    array.setElementAt({ 1, 1 }, 4);
18731
18732    // Test constant padding
18733    auto padded_const = pad(array, 1, "constant", 0);
18734    if (!(padded_const.getShape()[0] == 4)) {
18735        std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[0] == 4)";
18736        std::cout << std::string("[FAIL] ") + description << std::endl;
18737        throw std::runtime_error(description);
18738    }
18739    if (!(padded_const.getShape()[1] == 4)) {
18740        std::string description = std::string("testPadding():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(padded_const.getShape()[1] == 4)";
18741        std::cout << std::string("[FAIL] ") + description << std::endl;
18742        throw std::runtime_error(description);
18743    }
pairs (np_test_2_all.cpp:8793)
8783          if (result != expected) {
8784            std::cout << "   IPP integer msort:                                                                      -> [FAIL]";
8785            throw std::runtime_error("IPP integer msort: FAILED - incorrect sorted order");
8786          }
8787          // std::cout << "[OK] IPP integer msort: PASSED" << std::endl;
8788        }
8789
8790        // Test 2: Float msort with stability test
8791        {
8792          // Test stability using pairs (value, original_index)
8793          struct TestPair {
8794            double value;
8795            int original_index;
8796            bool operator==(const TestPair& other) const {
8797              return value == other.value && original_index == other.original_index;
8798            }
8799            bool operator<(const TestPair& other) const {
8800              return value < other.value;
8801            }
8802          };
pow (np_test_1_all.cpp:15230)
15220        std::cout << "[FAIL] Broadcasting validation failed" << std::endl;
15221        errors++;
15222      }
15223
15224      // Test 11: Performance with caching
15225      std::cout << "========= test_caching_performance =======================" ;
15226
15227      int call_count = 0;
15228      auto expensive_func = [&call_count](double x) {
15229        call_count++;
15230        return std::pow(x, 3) + std::sin(x);  // Simulate expensive computation
15231        };
15232
15233      auto cached_vectorized = numpy::vectorize(expensive_func, true, 100);
15234
15235      numpy::NDArray<double> test_array({ 3 });
15236      test_array.setElementAt({ 0 }, 1.0);
15237      test_array.setElementAt({ 1 }, 2.0);
15238      test_array.setElementAt({ 2 }, 3.0);
15239
15240      // First call
pow (np_test_1_all.cpp:15230)
15220        std::cout << "[FAIL] Broadcasting validation failed" << std::endl;
15221        errors++;
15222      }
15223
15224      // Test 11: Performance with caching
15225      std::cout << "========= test_caching_performance =======================" ;
15226
15227      int call_count = 0;
15228      auto expensive_func = [&call_count](double x) {
15229        call_count++;
15230        return std::pow(x, 3) + std::sin(x);  // Simulate expensive computation
15231        };
15232
15233      auto cached_vectorized = numpy::vectorize(expensive_func, true, 100);
15234
15235      numpy::NDArray<double> test_array({ 3 });
15236      test_array.setElementAt({ 0 }, 1.0);
15237      test_array.setElementAt({ 1 }, 2.0);
15238      test_array.setElementAt({ 2 }, 3.0);
15239
15240      // First call
prefix (np_test_1_all.cpp:9465)
9455    vstring_ short_str("A");
9456    vstring_ long_str("AAAAA");
9457    if (!(short_str < long_str)) {
9458        std::string description = std::string("testStringOperationEdgeCasesVariableStrings():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(short_str < long_str)";
9459        std::cout << std::string("[FAIL] ") + description << std::endl;
9460        throw std::runtime_error(description);
9461    }
9462
9463    // Test with strings that are prefixes
9464    vstring_ prefix("Test");
9465    vstring_ prefix_extended("Testing");
9466    if (!(prefix < prefix_extended)) {
9467        std::string description = std::string("testStringOperationEdgeCasesVariableStrings():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(prefix < prefix_extended)";
9468        std::cout << std::string("[FAIL] ") + description << std::endl;
9469        throw std::runtime_error(description);
9470    }
9471    if (!(!(prefix > prefix_extended))) {
9472        std::string description = std::string("testStringOperationEdgeCasesVariableStrings():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!(prefix > prefix_extended))";
9473        std::cout << std::string("[FAIL] ") + description << std::endl;
9474        throw std::runtime_error(description);
prod (np_test_1_all.cpp:11795)
11785        throw std::runtime_error(description);
11786    }
11787    // std::cout << "[OK] min and max work correctly\n";
11788
11789    // Test product
11790    auto small_array = createInt32Array({ 3 }, 0);
11791    small_array.setElementAt({ 0 }, 2);
11792    small_array.setElementAt({ 1 }, 3);
11793    small_array.setElementAt({ 2 }, 4);
11794
11795    auto prod_result = prod(small_array);
11796    if (!(prod_result.getElementAt({ 0 }) == 24)) {
11797        std::string description = std::string("testBasicStatistics():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(prod_result.getElementAt({ 0 }) == 24)";
11798        std::cout << std::string("[FAIL] ") + description << std::endl;
11799        throw std::runtime_error(description);
11800    }
11801    // std::cout << "[OK] prod works correctly\n";
11802    std::cout << " -> tests passed" << std::endl;
11803  }
11804
11805  void testVarianceAndStandardDeviation() {
product (np_test_1_all.cpp:5362)
5352    try {
5353        auto result = array1.multiplyArrays(array2);
5354        std::cout << "[FAIL] Incompatible shape multiplication should have thrown" << std::endl;
5355    } catch (const std::invalid_argument& e) {
5356        // std::cout << "[OK] Incompatible multiplication properly throws: " << e.what();
5357    }
5358
5359    // Test incompatible dot product
5360    try {
5361        auto result = array1.dotProduct(array2);  // 2x3 * 3x2 should actually work
5362        // std::cout << "[OK] Compatible dot product (2x3 * 3x2) works" << std::endl;
5363    } catch (const std::exception& e) {
5364        std::cout << "  [FAIL] : in testIncompatibleShapesErrorExtended(): Unexpected dot product error: " << e.what();
5365        throw std::runtime_error("testIncompatibleShapesErrorExtended(): Unexpected dot product error: " + std::string(e.what()));
5366    }
5367
5368    // Test truly incompatible dot product
5369    auto array3 = createInt32Array({2, 2}, 1);
5370    try {
5371        auto result = array1.dotProduct(array3);  // 2x3 * 2x2 should fail
5372        std::cout << "[FAIL] Incompatible dot product should have thrown" << std::endl;
replace (np_test_1_all.cpp:6717)
6707    std::vector<std::string> text = {"Hello world", "The world is big", "world peace"};
6708    auto arr = array<64>(text);
6709
6710    // std::cout << "Original text:" << std::endl;
6711    for (size_t i = 0; i < arr.size(); ++i) {
6712        // std::cout << "'" << arr[i] << "'";
6713    }
6714
6715    // Test replace
6716    auto replaced = replace(arr, "world", "universe");
6717    // std::cout << "After replacing 'world' with 'universe':" << std::endl;
6718    for (size_t i = 0; i < replaced.size(); ++i) {
6719        // std::cout << "'" << replaced[i] << "'";
6720    }
6721
6722    // Test replace with count limit
6723    std::vector<std::string> repeated_text = {"test test test", "more test cases", "test everything"};
6724    auto repeated_arr = array<64>(repeated_text);
6725    auto limited_replace = replace(repeated_arr, "test", "example", 1);
representation (np_test_2_all.cpp:13663)
13653  // no using namespace in tests - to avoid name clashes
13654
13655  // use a separate namespace for each test group
13656  namespace numpy_tests_bitwise_repr {
13657
13658    // ============================================================================
13659    // BASE_REPR TESTS
13660    // ============================================================================
13661
13662    void np_test_base_repr_binary() {
13663      std::cout << "========= base_repr: binary representation (base=2) =======================";
13664
13665      // Test basic binary conversion
13666      std::string result1 = numpy::base_repr(5, 2);
13667      if (result1 != "101") {
13668        std::cout << "  [FAIL] : base_repr(5, 2) returned \"" << result1 << "\", expected \"101\"";
13669        throw std::runtime_error("np_test_base_repr_binary failed");
13670      }
13671
13672      std::string result2 = numpy::base_repr(255, 2);
13673      if (result2 != "11111111") {
representation (np_test_2_all.cpp:13663)
13653  // no using namespace in tests - to avoid name clashes
13654
13655  // use a separate namespace for each test group
13656  namespace numpy_tests_bitwise_repr {
13657
13658    // ============================================================================
13659    // BASE_REPR TESTS
13660    // ============================================================================
13661
13662    void np_test_base_repr_binary() {
13663      std::cout << "========= base_repr: binary representation (base=2) =======================";
13664
13665      // Test basic binary conversion
13666      std::string result1 = numpy::base_repr(5, 2);
13667      if (result1 != "101") {
13668        std::cout << "  [FAIL] : base_repr(5, 2) returned \"" << result1 << "\", expected \"101\"";
13669        throw std::runtime_error("np_test_base_repr_binary failed");
13670      }
13671
13672      std::string result2 = numpy::base_repr(255, 2);
13673      if (result2 != "11111111") {
result (np_test_1_all.cpp:6090)
6080        throw std::runtime_error(description);
6081    }
6082    // std::cout << "Timer restart test passed. Second: " << second_elapsed << " ms" << std::endl;
6083
6084    std::cout << " -> tests passed" << std::endl;
6085}
6086
6087void test_benchmark_result_storageBenchmarkSorting() {
6088    std::cout << "========= test_benchmark_result_storage =======================";
6089
6090    BenchmarkResult result("TestAlgorithm", 1000, 15.5, true, 4096);
6091
6092    if (!(result.algorithm_name == "TestAlgorithm")) {
6093        std::string description = std::string("test_benchmark_result_storageBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.algorithm_name == \"TestAlgorithm\")";
6094        std::cout << std::string("[FAIL] ") + description << std::endl;
6095        throw std::runtime_error(description);
6096    }
6097    if (!(result.array_size == 1000)) {
6098        std::string description = std::string("test_benchmark_result_storageBenchmarkSorting():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(result.array_size == 1000)";
6099        std::cout << std::string("[FAIL] ") + description << std::endl;
6100        throw std::runtime_error(description);
sequences (np_test_1_all.cpp:9081)
9071    NDArray<vstring_> str_array = createVariableStringArrayFromInitializerList({
9072        "First", "Second", "Third"
9073    });
9074    // std::cout << "Variable string array created successfully" << std::endl;
9075    std::cout << " -> tests passed" << std::endl;
9076}
9077
9078void testUTF8EdgeCasesVariableStrings() {
9079    std::cout << "========= testUTF8EdgeCasesVariableStrings =======================";
9080
9081    // Test 1: Invalid UTF-8 sequences (should be handled gracefully)
9082    std::string invalid_utf8_orphaned = "\x80\x81\x82";  // Orphaned continuation bytes
9083    vunicode_ orphaned_test(invalid_utf8_orphaned);
9084    // Should not crash and produce some result
9085    if (!(!orphaned_test.to_utf8().empty() || orphaned_test.empty())) {
9086        std::string description = std::string("testUTF8EdgeCasesVariableStrings():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(!orphaned_test.to_utf8().empty() || orphaned_test.empty())";
9087        std::cout << std::string("[FAIL] ") + description << std::endl;
9088        throw std::runtime_error(description);
9089    }
9090
9091    std::string invalid_utf8_start = "\xF8\xF9\xFF";  // Invalid start bytes
shape (np_test_1_all.cpp:3751)
3741    }
3742
3743    for (size_t j = 0; j < 3; ++j) {
3744        arr3.setElementAt({0, j}, static_cast<double>((j + 1) * 100));  // [100, 200, 300]
3745    }
3746
3747    // Broadcast all arrays together
3748    std::vector<NDArray<double>> arrays = {arr1, arr2, arr3};
3749    auto broadcasted = broadcast_arrays(arrays);
3750
3751    // All should have shape (2, 3)
3752    for (const auto& arr : broadcasted) {
3753        if (!((arr.getShape() == std::vector<size_t>{2, 3}))) {
3754            std::string description = std::string("test_broadcast_arrays():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !((arr.getShape() == std::vector<size_t>{2, 3}))";
3755            std::cout << std::string("[FAIL] ") + description << std::endl;
3756            throw std::runtime_error(description);
3757        }
3758    }
3759
3760    // Check values
3761    if (!(broadcasted[0].getElementAt({0, 1}) == 2.0)) {
shift (np_test_1_all.cpp:2761)
2751        throw std::runtime_error(description);
2752    }
2753    if (!(left_array.getElementAt({3}) == 16384)) {
2754        std::string description = std::string("testBitShifts():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(left_array.getElementAt({3}) == 16384)";
2755        std::cout << std::string("[FAIL] ") + description << std::endl;
2756        throw std::runtime_error(description);
2757    }
2758
2759    // std::cout << "[OK] Left shift by array\n";
2760
2761    // Test excessive shift (should result in 0)
2762    auto excessive_left = left_shift(arr, 20); // More than 16 bits
2763    if (!(excessive_left.getElementAt({0}) == 0)) {
2764        std::string description = std::string("testBitShifts():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(excessive_left.getElementAt({0}) == 0)";
2765        std::cout << std::string("[FAIL] ") + description << std::endl;
2766        throw std::runtime_error(description);
2767    }
2768    if (!(excessive_left.getElementAt({1}) == 0)) {
2769        std::string description = std::string("testBitShifts():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(excessive_left.getElementAt({1}) == 0)";
2770        std::cout << std::string("[FAIL] ") + description << std::endl;
2771        throw std::runtime_error(description);
size (np_test_1_all.cpp:47)
37using namespace numpy;
38using namespace numpy::benchmark;
39using namespace numpy::char_;
40
41// Helper functions for array comparison tests
42namespace {
43    const double TOLERANCE = 1e-10;
44
45    bool allTrue(const NDArray<bool>& arr) {
46        std::vector<size_t> indices(arr.getShape().size(), 0);
47        do {
48            if (!arr.getElementAt(indices)) {
49                return false;
50            }
51        } while (incrementIndices(indices, arr.getShape()));
52        return true;
53    }
54
55    bool allFalse(const NDArray<bool>& arr) {
56        std::vector<size_t> indices(arr.getShape().size(), 0);
skew (np_test_1_all.cpp:11422)
11412    std::cout << "========= testDistributionShapeMeasures =======================";
11413
11414    // Test skewness with known data
11415    auto normal_data = createFloat32Array({ 5 }, 0.0f);
11416    normal_data.setElementAt({ 0 }, 1.0f);
11417    normal_data.setElementAt({ 1 }, 2.0f);
11418    normal_data.setElementAt({ 2 }, 3.0f);
11419    normal_data.setElementAt({ 3 }, 4.0f);
11420    normal_data.setElementAt({ 4 }, 5.0f);
11421
11422    auto skew_result = skew(normal_data);
11423    // std::cout << "Skewness of [1,2,3,4,5]: " << skew_result.getElementAt({ 0 }) << std::endl;
11424    // Should be close to 0 for symmetric data
11425    if (!(std::abs(skew_result.getElementAt({ 0 })) < 0.1)) {
11426        std::string description = std::string("testDistributionShapeMeasures():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(std::abs(skew_result.getElementAt({ 0 })) < 0.1)";
11427        std::cout << std::string("[FAIL] ") + description << std::endl;
11428        throw std::runtime_error(description);
11429    }
11430    // std::cout << "[OK] Skewness calculation\n";
11431
11432    // Test kurtosis
ss (np_test_1_all.cpp:25034)
25024    }
25025
25026    // ============================================================================
25027    // SEEDSEQUENCE TESTS
25028    // ============================================================================
25029
25030    void np_test_bitgen_seedsequence() {
25031      std::cout << "========= SeedSequence =======================";
25032
25033      // Test construction
25034      numpy::random::SeedSequence ss(42);
25035
25036      // Test state generation
25037      auto state = ss.generate_state(10);
25038      if (state.size() != 10) {
25039        std::cout << "  [FAIL] : in np_test_bitgen_seedsequence() : generate_state size";
25040        throw std::runtime_error("np_test_bitgen_seedsequence failed");
25041      }
25042
25043      // Test spawning
25044      auto children = ss.spawn(5);
str (np_test_1_all.cpp:13279)
13269        throw std::runtime_error(description);
13270    }
13271    // std::cout << "[OK] Vectorized str_len works correctly\n";
13272    std::cout << " -> tests passed" << std::endl;
13273  }
13274
13275  void test_numpy_compatibility_examples() {
13276    std::cout << "========= test_numpy_compatibility_examples =======================";
13277
13278    // Example: numpy string slicing behavior
13279    vstring_ str("hello world");  // length = 11
13280
13281    // These should behave like NumPy string slicing
13282    if (!(str.slice(5, 20).to_string() == " world")) {
13283        std::string description = std::string("test_numpy_compatibility_examples():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(str.slice(5, 20).to_string() == \" world\")";
13284        std::cout << std::string("[FAIL] ") + description << std::endl;
13285        throw std::runtime_error(description);
13286    }
13287    if (!(str.slice(-20, 5).to_string() == "hello")) {
13288        std::string description = std::string("test_numpy_compatibility_examples():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(str.slice(-20, 5).to_string() == \"hello\")";
13289        std::cout << std::string("[FAIL] ") + description << std::endl;
string (np_test_1_all.cpp:454)
444    // Modify through different views
445    view1.setElementAt({0, 0}, 100);
446    view2.setElementAt({2, 1}, 200);  // This is (1, 2) in original
447    view3.setElementAt({0, 0}, 300);  // This is (1, 1) in original
448
449    // std::cout << "After modifications through multiple views:" << std::endl;
450    //original.printArray();
451
452    // Verify all changes are reflected
453    if (!(original.getElementAt({0, 0}) == 100)) {
454        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({0, 0}) == 100)";
455        std::cout << std::string("[FAIL] ") + description << std::endl;
456        throw std::runtime_error(description);
457    }
458    if (!(original.getElementAt({1, 2}) == 200)) {
459        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 2}) == 200)";
460        std::cout << std::string("[FAIL] ") + description << std::endl;
461        throw std::runtime_error(description);
462    }
463    if (!(original.getElementAt({1, 1}) == 300)) {
464        std::string description = std::string("testAdvancedViewLifecycle():") + __FILE__ + ":" + std::to_string(__LINE__) + ": !(original.getElementAt({1, 1}) == 300)";
tz_convert (np_test_5_all.cpp:22899)
22889      if (floored_h.hour() != 14 || floored_h.minute() != 0 || floored_h.second() != 0) {
22890        pass = false;
22891        fail_msg = "floor to hour failed";
22892      }
22893
22894      // ceil to hour
22895      numpy::Timestamp ceiled_h = ts.ceil("h");
22896      if (ceiled_h.hour() != 15 || ceiled_h.minute() != 0) {
22897        pass = false;
22898        fail_msg = "ceil to hour failed";
22899      }
22900
22901      // round to hour (37 minutes -> round up)
22902      numpy::Timestamp rounded_h = ts.round("h");
22903      if (rounded_h.hour() != 15) {
22904        pass = false;
22905        fail_msg = "round to hour should be 15 (37 > 30)";
22906      }
22907
22908      // normalize (floor to day)
22909      numpy::Timestamp normalized = ts.normalize();
tz_convert (np_test_5_all.cpp:22899)
22889      if (floored_h.hour() != 14 || floored_h.minute() != 0 || floored_h.second() != 0) {
22890        pass = false;
22891        fail_msg = "floor to hour failed";
22892      }
22893
22894      // ceil to hour
22895      numpy::Timestamp ceiled_h = ts.ceil("h");
22896      if (ceiled_h.hour() != 15 || ceiled_h.minute() != 0) {
22897        pass = false;
22898        fail_msg = "ceil to hour failed";
22899      }
22900
22901      // round to hour (37 minutes -> round up)
22902      numpy::Timestamp rounded_h = ts.round("h");
22903      if (rounded_h.hour() != 15) {
22904        pass = false;
22905        fail_msg = "round to hour should be 15 (37 > 30)";
22906      }
22907
22908      // normalize (floor to day)
22909      numpy::Timestamp normalized = ts.normalize();
tz_localize (np_test_5_all.cpp:22892)
22882      auto pass = true;
22883      std::string fail_msg;
22884
22885      numpy::Timestamp ts(2024, 6, 15, 14, 37, 45, 123456);
22886
22887      // floor to hour
22888      numpy::Timestamp floored_h = ts.floor("h");
22889      if (floored_h.hour() != 14 || floored_h.minute() != 0 || floored_h.second() != 0) {
22890        pass = false;
22891        fail_msg = "floor to hour failed";
22892      }
22893
22894      // ceil to hour
22895      numpy::Timestamp ceiled_h = ts.ceil("h");
22896      if (ceiled_h.hour() != 15 || ceiled_h.minute() != 0) {
22897        pass = false;
22898        fail_msg = "ceil to hour failed";
22899      }
22900
22901      // round to hour (37 minutes -> round up)
22902      numpy::Timestamp rounded_h = ts.round("h");
tz_localize (np_test_5_all.cpp:22892)
22882      auto pass = true;
22883      std::string fail_msg;
22884
22885      numpy::Timestamp ts(2024, 6, 15, 14, 37, 45, 123456);
22886
22887      // floor to hour
22888      numpy::Timestamp floored_h = ts.floor("h");
22889      if (floored_h.hour() != 14 || floored_h.minute() != 0 || floored_h.second() != 0) {
22890        pass = false;
22891        fail_msg = "floor to hour failed";
22892      }
22893
22894      // ceil to hour
22895      numpy::Timestamp ceiled_h = ts.ceil("h");
22896      if (ceiled_h.hour() != 15 || ceiled_h.minute() != 0) {
22897        pass = false;
22898        fail_msg = "ceil to hour failed";
22899      }
22900
22901      // round to hour (37 minutes -> round up)
22902      numpy::Timestamp rounded_h = ts.round("h");
unused (np_test_3_all.cpp:18289)
18279      int n = 3;
18280      int kl = 1;
18281      int ku = 1;
18282      int ldab = 2 * kl + ku + 1;  // = 4 for gbtrf
18283      numpy::NDArray<double> AB({ static_cast<size_t>(ldab), static_cast<size_t>(n) });
18284
18285      // Fill band matrix in LAPACK band storage format
18286      // Row ku = 1 contains the superdiagonal
18287      // Row kl+ku = 2 contains the diagonal
18288      // Row kl+ku+1 = 3 contains the subdiagonal
18289      AB.setElementAt({ 0, 0 }, 0.0);  // unused (extra space for pivoting)
18290      AB.setElementAt({ 0, 1 }, 0.0);
18291      AB.setElementAt({ 0, 2 }, 1.0);  // A[0,2] doesn't exist, just filling
18292
18293      AB.setElementAt({ 1, 0 }, 0.0);  // unused
18294      AB.setElementAt({ 1, 1 }, 1.0);  // superdiagonal A[0,1]
18295      AB.setElementAt({ 1, 2 }, 1.0);  // superdiagonal A[1,2]
18296
18297      AB.setElementAt({ 2, 0 }, 4.0);  // diagonal A[0,0]
18298      AB.setElementAt({ 2, 1 }, 4.0);  // diagonal A[1,1]
18299      AB.setElementAt({ 2, 2 }, 4.0);  // diagonal A[2,2]
v (np_test_3_all.cpp:5664)
5654      // std::cout << "Computed eigenvalues:" << std::endl;
5655      //eig_result.eigenvalues.printArray();
5656
5657      // std::cout << "Eigenvectors:" << std::endl;
5658      //eig_result.eigenvectors.printArray();
5659
5660      // Verify A*v = lambda*v for each eigenvector
5661      double max_residual = 0.0;
5662      for (size_t k = 0; k < 3; ++k) {
5663        // Extract k-th eigenvector
5664        NDArray<complex128> v({ 3, 1 });
5665        for (size_t i = 0; i < 3; ++i) {
5666          v.setElementAt({ i, 0 }, eig_result.eigenvectors.getElementAt({ i, k }));
5667        }
5668
5669        complex128 lambda = eig_result.eigenvalues.getElementAt({ k });
5670
5671        // Compute A*v
5672        auto Av = matmul(matrix, v);
5673
5674        // Compute lambda*v
value (np_test_1_all.cpp:7786)
7776}
7777
7778void testFloat16PrecisionFloat16() {
7779    std::cout << "========= testFloat16PrecisionFloat16 =======================";
7780
7781    // Test precision limits
7782    float16 small_val(0.0001f);
7783    float16 large_val(30000.0f);
7784    float16 very_small(1e-8f);  // This might underflow to zero
7785
7786    // std::cout << "Small value (0.0001): " << small_val << std::endl;
7787    // std::cout << "Large value (30000): " << large_val << std::endl;
7788    // std::cout << "Very small value (1e-8): " << very_small << std::endl;
7789
7790    // Test conversion accuracy
7791    float original = 1.234f;
7792    float16 converted(original);
7793    float back_converted = static_cast<float>(converted);
7794
7795    // std::cout << "Original float: " << std::setprecision(10) << original << std::endl;
7796    // std::cout << "Float16 version: " << converted << std::endl;
values (np_test_1_all.cpp:15133)
15123        std::cout << " -> tests passed" << std::endl;
15124      }
15125      else {
15126        std::cout << "[FAIL] Where function failed" << std::endl;
15127        errors++;
15128      }
15129
15130      // Test 8: Clip function
15131      std::cout << "========= test_clip_function =======================" ;
15132
15133      numpy::NDArray<double> values({ 5 });
15134      values.setElementAt({ 0 }, -2.0);
15135      values.setElementAt({ 1 }, -1.0);
15136      values.setElementAt({ 2 }, 0.5);
15137      values.setElementAt({ 3 }, 2.0);
15138      values.setElementAt({ 4 }, 5.0);
15139      double min_val = -1.0;
15140      double max_val = 3.0;
15141
15142      auto clip_result = numpy::clip(values, min_val, max_val);
values (np_test_1_all.cpp:15133)
15123        std::cout << " -> tests passed" << std::endl;
15124      }
15125      else {
15126        std::cout << "[FAIL] Where function failed" << std::endl;
15127        errors++;
15128      }
15129
15130      // Test 8: Clip function
15131      std::cout << "========= test_clip_function =======================" ;
15132
15133      numpy::NDArray<double> values({ 5 });
15134      values.setElementAt({ 0 }, -2.0);
15135      values.setElementAt({ 1 }, -1.0);
15136      values.setElementAt({ 2 }, 0.5);
15137      values.setElementAt({ 3 }, 2.0);
15138      values.setElementAt({ 4 }, 5.0);
15139      double min_val = -1.0;
15140      double max_val = 3.0;
15141
15142      auto clip_result = numpy::clip(values, min_val, max_val);
write (np_test_1_all.cpp:27015)
27005    }
27006
27007    void test_get_remaining_size() {
27008      std::cout << "========= get_remaining_size: calculate remaining file bytes =======================";
27009
27010      // Create temporary test file
27011      const char* test_filename = "temp_test_file_phase5.bin";
27012      {
27013        std::ofstream out(test_filename, std::ios::binary);
27014        const char data[100] = {};
27015        out.write(data, 100);
27016      }
27017
27018      // Test with filename
27019      size_t size1 = io::get_remaining_size(test_filename);
27020      if (size1 != 100) {
27021        std::cout << "  [FAIL] : in test_get_remaining_size() : expected 100 bytes, got " << size1;
27022        throw std::runtime_error("test_get_remaining_size failed: incorrect file size");
27023      }
27024
27025      // Test with file stream