Skip to content

Commit b44af37

Browse files
committed
Basic test
1 parent 4489a35 commit b44af37

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

scripts/tests/test_csv.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
11
import pandas as pd
2+
import numpy as np
23

3-
print("Pandas version:", pd.__version__)
4+
# Create a DataFrame with NumPy arrays
5+
df = pd.DataFrame({
6+
'id': [1, 2],
7+
'embedding': [np.array([0.1, 0.2, 0.3]), np.array([0.4, 0.5, 0.6])]
8+
})
49

5-
df = pd.DataFrame({"Name": ["Alice", "Bob"], "Age": [25, 30]})
6-
print(df)
10+
# Save to CSV
11+
csv_file = "test_numpy_array.csv"
12+
df.to_csv(csv_file, index=False)
13+
print(f"Saved CSV:\n{open(csv_file).read()}")
14+
15+
# Read back the CSV
16+
df_loaded = pd.read_csv(csv_file)
17+
18+
# Print results
19+
print("\nLoaded DataFrame:")
20+
print(df_loaded)
21+
22+
# Check if numpy arrays were converted to strings
23+
if isinstance(df_loaded["embedding"][0], str):
24+
print("\nTest Passed: NumPy arrays were converted to strings in CSV")
25+
else:
26+
print("\nTest Failed: NumPy arrays were not converted as expected")

scripts/tests/test_numpy_array.csv

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
id,embedding
2+
1,[0.1 0.2 0.3]
3+
2,[0.4 0.5 0.6]

0 commit comments

Comments
 (0)