Spaces:
Running
Running
Commit
·
8c495c2
1
Parent(s):
fe9e665
modif tests with dummy csv
Browse files- README.md +7 -1
- tests/conftest.py +43 -54
- tests/dummy_dataset.csv +100 -0
README.md
CHANGED
|
@@ -44,7 +44,7 @@ git clone https://github.com/romybeaute/MOSAICapp.git
|
|
| 44 |
cd MOSAICapp
|
| 45 |
|
| 46 |
# Create virtual environment (recommended)
|
| 47 |
-
|
| 48 |
source .venv/bin/activate
|
| 49 |
|
| 50 |
# Install dependencies and the package
|
|
@@ -111,6 +111,12 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on reporting bugs, suggest
|
|
| 111 |
|
| 112 |
## Tests
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
```bash
|
| 115 |
pytest tests/test_core_functions.py -v
|
| 116 |
```
|
|
|
|
| 44 |
cd MOSAICapp
|
| 45 |
|
| 46 |
# Create virtual environment (recommended)
|
| 47 |
+
python3 -m venv .venv
|
| 48 |
source .venv/bin/activate
|
| 49 |
|
| 50 |
# Install dependencies and the package
|
|
|
|
| 111 |
|
| 112 |
## Tests
|
| 113 |
|
| 114 |
+
**Run everything:**
|
| 115 |
+
```bash
|
| 116 |
+
pytest tests/ -v
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
**Run only fast tests:**
|
| 120 |
```bash
|
| 121 |
pytest tests/test_core_functions.py -v
|
| 122 |
```
|
tests/conftest.py
CHANGED
|
@@ -1,73 +1,62 @@
|
|
| 1 |
-
"""Pytest fixtures for MOSAIC tests."""
|
| 2 |
|
| 3 |
import os
|
| 4 |
-
import tempfile
|
| 5 |
-
|
| 6 |
-
import numpy as np
|
| 7 |
-
import pandas as pd
|
| 8 |
import pytest
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
|
| 11 |
@pytest.fixture
|
| 12 |
-
def
|
| 13 |
-
"""
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
"
|
| 20 |
-
|
| 21 |
-
|
| 22 |
|
| 23 |
@pytest.fixture
|
| 24 |
-
def sample_dataframe(
|
| 25 |
-
"""DataFrame
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
@pytest.fixture
|
| 34 |
-
def
|
| 35 |
-
"""
|
| 36 |
-
|
| 37 |
-
sample_dataframe.to_csv(f, index=False)
|
| 38 |
-
path = f.name
|
| 39 |
-
yield path
|
| 40 |
-
if os.path.exists(path):
|
| 41 |
-
os.unlink(path)
|
| 42 |
-
|
| 43 |
|
| 44 |
@pytest.fixture
|
| 45 |
-
def sample_embeddings():
|
| 46 |
-
"""
|
| 47 |
np.random.seed(42)
|
| 48 |
-
|
| 49 |
-
|
| 50 |
|
| 51 |
@pytest.fixture
|
| 52 |
-
def larger_corpus():
|
| 53 |
-
"""
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
"The presence was comforting.",
|
| 59 |
-
"Patterns emerged in the visual field.",
|
| 60 |
-
"Geometric patterns were everywhere.",
|
| 61 |
-
]
|
| 62 |
-
return base * 5
|
| 63 |
-
|
| 64 |
|
| 65 |
@pytest.fixture
|
| 66 |
-
def larger_embeddings(
|
| 67 |
-
"""
|
| 68 |
-
|
| 69 |
-
return np.random.randn(len(larger_corpus), 384).astype(np.float32)
|
| 70 |
-
|
| 71 |
|
| 72 |
@pytest.fixture
|
| 73 |
def topic_config():
|
|
|
|
| 1 |
+
"""Pytest fixtures for MOSAIC tests using local dummy dataset."""
|
| 2 |
|
| 3 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
import pytest
|
| 5 |
+
import pandas as pd
|
| 6 |
+
import numpy as np
|
| 7 |
+
from pathlib import Path
|
| 8 |
|
| 9 |
@pytest.fixture
|
| 10 |
+
def sample_csv():
|
| 11 |
+
"""Returns the path to the dummy_dataset.csv file located in the same directory."""
|
| 12 |
+
# Get the directory where this conftest.py file resides
|
| 13 |
+
current_dir = Path(__file__).parent
|
| 14 |
+
file_path = current_dir / "dummy_dataset.csv"
|
| 15 |
+
|
| 16 |
+
if not file_path.exists():
|
| 17 |
+
pytest.fail(f"Test data file not found at: {file_path}")
|
| 18 |
+
|
| 19 |
+
return str(file_path)
|
| 20 |
|
| 21 |
@pytest.fixture
|
| 22 |
+
def sample_dataframe(sample_csv):
|
| 23 |
+
"""Loads the CSV into a DataFrame and normalizes column names."""
|
| 24 |
+
df = pd.read_csv(sample_csv)
|
| 25 |
+
|
| 26 |
+
# Normalize text column name for tests (handle 'report' vs 'text')
|
| 27 |
+
if 'text' not in df.columns:
|
| 28 |
+
if 'report' in df.columns:
|
| 29 |
+
df = df.rename(columns={'report': 'text'})
|
| 30 |
+
else:
|
| 31 |
+
# Fallback: assume first column is text if neither exists
|
| 32 |
+
df = df.rename(columns={df.columns[0]: 'text'})
|
| 33 |
+
|
| 34 |
+
return df
|
| 35 |
|
| 36 |
@pytest.fixture
|
| 37 |
+
def sample_texts(sample_dataframe):
|
| 38 |
+
"""Returns the list of text reports from the dataframe."""
|
| 39 |
+
return sample_dataframe['text'].tolist()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
@pytest.fixture
|
| 42 |
+
def sample_embeddings(sample_texts):
|
| 43 |
+
"""Generates random embeddings matching the exact length of the CSV data."""
|
| 44 |
np.random.seed(42)
|
| 45 |
+
# Generate (n_samples, 384) matrix
|
| 46 |
+
return np.random.randn(len(sample_texts), 384).astype(np.float32)
|
| 47 |
|
| 48 |
@pytest.fixture
|
| 49 |
+
def larger_corpus(sample_texts):
|
| 50 |
+
"""
|
| 51 |
+
Alias for sample_texts.
|
| 52 |
+
Since the dummy dataset is sufficiently large, we reuse it.
|
| 53 |
+
"""
|
| 54 |
+
return sample_texts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
@pytest.fixture
|
| 57 |
+
def larger_embeddings(sample_embeddings):
|
| 58 |
+
"""Alias for sample_embeddings matching the larger corpus."""
|
| 59 |
+
return sample_embeddings
|
|
|
|
|
|
|
| 60 |
|
| 61 |
@pytest.fixture
|
| 62 |
def topic_config():
|
tests/dummy_dataset.csv
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
report
|
| 2 |
+
Geometric patterns started rotating behind my eyelids.
|
| 3 |
+
The colors in the room became incredibly vivid; they started breathing.
|
| 4 |
+
I saw a bright white light. It seemed to emanate from everywhere.
|
| 5 |
+
Fractal imagery appeared. It shifted slowly from green to purple.
|
| 6 |
+
The edges of objects became fuzzy. Everything looked indistinct.
|
| 7 |
+
Visual acuity increased significantly. I could see every pore on my hand.
|
| 8 |
+
I perceived trails of light following moving objects.
|
| 9 |
+
The room appeared to stretch. It warped like a funhouse mirror.
|
| 10 |
+
Complex architectural structures appeared in my peripheral vision.
|
| 11 |
+
Everything looked two-dimensional. It was like a flat painting.
|
| 12 |
+
My body felt incredibly heavy. It felt as if I were sinking into the floor.
|
| 13 |
+
I lost all sensation in my hands and feet.
|
| 14 |
+
A warm tingling sensation started at the base of my spine. It moved up to my neck.
|
| 15 |
+
I felt a disconnect between my mind and my physical form.
|
| 16 |
+
My breathing became very rhythmic. It was deep and without my control.
|
| 17 |
+
I felt physically larger than the room I was sitting in.
|
| 18 |
+
A sensation of floating weightlessness took over.
|
| 19 |
+
I felt a rhythmic pulsing in my chest. It matched the beat of the music.
|
| 20 |
+
My limbs felt elongated. They felt rubbery and strange.
|
| 21 |
+
There was a distinct pressure in the center of my forehead.
|
| 22 |
+
I was overcome by a profound sense of universal love.
|
| 23 |
+
A sudden wave of anxiety washed over me. However, it passed quickly.
|
| 24 |
+
I felt completely at peace with past conflicts.
|
| 25 |
+
There was an intense feeling of gratitude for simply existing.
|
| 26 |
+
I felt deeply connected to the people around me.
|
| 27 |
+
Tears of joy started streaming down my face. I could not control them.
|
| 28 |
+
I felt a sense of awe. I felt insignificant in the face of the universe.
|
| 29 |
+
Old memories surfaced. They brought a mix of nostalgia and sadness.
|
| 30 |
+
I felt incredibly safe. I felt held by the environment.
|
| 31 |
+
A burst of euphoria made me want to laugh out loud.
|
| 32 |
+
Time seemed to stop completely. A minute felt like an hour.
|
| 33 |
+
My sense of self dissolved. I became part of the music.
|
| 34 |
+
Thoughts were racing faster than I could process them.
|
| 35 |
+
My mind was completely silent. It was a rare state of no-thought.
|
| 36 |
+
I understood the concept of infinity intuitively.
|
| 37 |
+
The boundary between myself and the external world vanished.
|
| 38 |
+
I had a sudden insight into a problem. I had been struggling with it for years.
|
| 39 |
+
Language felt clumsy. It was inadequate to describe the experience.
|
| 40 |
+
I forgot who I was for a brief moment.
|
| 41 |
+
The past and future seemed to merge. They became a single present moment.
|
| 42 |
+
I saw a bright light. Then, I felt a deep sense of peace.
|
| 43 |
+
My hands felt huge. In contrast, the room looked tiny.
|
| 44 |
+
The music became visible as colors. At the same time, I felt my body floating.
|
| 45 |
+
I felt a sharp pain in my stomach. This was followed by a release of tension.
|
| 46 |
+
The walls were breathing. I felt connected to the house.
|
| 47 |
+
Time slowed down. I could see the air moving.
|
| 48 |
+
I felt a vibration in my teeth. I also saw blue flashes.
|
| 49 |
+
My ego dissolved. I was just pure awareness watching the room.
|
| 50 |
+
I remembered my childhood. This made me feel a wave of grief.
|
| 51 |
+
The floor patterns were moving. My legs felt like jelly.
|
| 52 |
+
I felt like I was underwater. The sounds were muffled.
|
| 53 |
+
Bright geometric shapes appeared. I felt very cold.
|
| 54 |
+
I laughed uncontrollably. The room spun around me.
|
| 55 |
+
I felt a presence in the room. I saw a shadow move.
|
| 56 |
+
My thoughts were looping. I couldn't speak.
|
| 57 |
+
The light was blinding. I felt a sense of holiness.
|
| 58 |
+
I felt tiny like an ant. The world was massive.
|
| 59 |
+
Colors tasted sweet. Sounds had textures.
|
| 60 |
+
I felt a burning sensation in my chest. It turned into love.
|
| 61 |
+
The world looked digital. It was like a computer simulation.
|
| 62 |
+
I saw my own face in the mirror. I didn't recognize it.
|
| 63 |
+
A deep hum vibrated through my bones. The light turned red.
|
| 64 |
+
I felt like I was spinning very fast. Yet, I was standing still.
|
| 65 |
+
The concept of money seemed absurd. I started laughing.
|
| 66 |
+
I felt a deep empathy for a tree outside the window.
|
| 67 |
+
My hands looked alien. I saw trails when I moved them.
|
| 68 |
+
I felt a knot in my throat. It released into a scream.
|
| 69 |
+
The silence was deafening. The darkness was full of light.
|
| 70 |
+
I felt like I was being pulled upwards. It was like a giant magnet.
|
| 71 |
+
My skin felt hard. It felt like it was made of stone.
|
| 72 |
+
I saw faces in the clouds. I felt they were watching me.
|
| 73 |
+
I felt a wave of heat. Then, I felt a wave of cold.
|
| 74 |
+
The music sounded internal. It was coming from inside my head.
|
| 75 |
+
I felt a deep sense of forgiveness for myself.
|
| 76 |
+
The room folded in on itself. I was in a void.
|
| 77 |
+
I felt like I was made of light and sound.
|
| 78 |
+
I saw a tunnel of light. I felt no fear.
|
| 79 |
+
My thoughts were clear. They were sharp like crystal.
|
| 80 |
+
I felt the rotation of the earth beneath me.
|
| 81 |
+
The air felt thick like syrup. It was harder to breathe.
|
| 82 |
+
I saw sparks of light. They appeared when I closed my eyes.
|
| 83 |
+
I felt a deep sadness for the state of the world.
|
| 84 |
+
My body was vibrating. It was at a high frequency.
|
| 85 |
+
I saw the structure of the universe in a flower.
|
| 86 |
+
I felt like I had lived this moment before.
|
| 87 |
+
The colors were hyper-real. They were more real than real life.
|
| 88 |
+
I felt a heavy weight on my chest. I couldn't move.
|
| 89 |
+
I saw a grid overlaying everything in the room.
|
| 90 |
+
I felt a separation between my observer self and my thinking self.
|
| 91 |
+
My voice sounded strange. It sounded distant to my ears.
|
| 92 |
+
I felt a rush of energy up my spine. I saw white.
|
| 93 |
+
The objects in the room seemed to have personalities.
|
| 94 |
+
I felt like I was melting. I was melting into the chair.
|
| 95 |
+
I saw a vision of my future. I felt calm.
|
| 96 |
+
The world turned into a cartoon for a second.
|
| 97 |
+
I felt a deep connection to my ancestors.
|
| 98 |
+
I saw a kaleidoscope of colors. I felt dizzy.
|
| 99 |
+
My heart was beating so fast. I thought it would explode.
|
| 100 |
+
I felt a sense of absolute truth. I felt clarity.
|