-
Notifications
You must be signed in to change notification settings - Fork 0
Troubleshooting
This guide provides solutions for common issues encountered when using entropic_measurement.
- Installation Issues
- Import and Usage Errors
- Calculation Problems
- Performance Issues
- Debugging Tips
- Getting Help
Symptoms: Error messages during pip install entropic_measurement
Solutions:
-
Update pip:
pip install --upgrade pip -
Use virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install entropic_measurement
-
Install dependencies manually:
pip install numpy scipy pip install entropic_measurement
Symptoms: "Permission denied" or "Access is denied" during installation
Solutions:
-
Use user installation:
pip install --user entropic_measurement -
Run as administrator (Windows) or use
sudo(Linux/Mac) - Use virtual environment (recommended)
Symptoms: Package version conflicts during installation
Solutions:
- Create fresh virtual environment
- Check requirements: Ensure Python >= 3.7
-
Update conflicting packages:
pip install --upgrade numpy scipy
Symptoms: ImportError: No module named 'entropic_measurement'
Solutions:
-
Verify installation:
pip list | grep entropic - Check Python path: Ensure you're using the correct Python environment
-
Reinstall package:
pip uninstall entropic_measurement && pip install entropic_measurement
Symptoms: AttributeError: module has no attribute 'function_name'
Solutions:
-
Check import statement:
# Correct from entropic_measurement import calculate_entropy # Or import entropic_measurement as em result = em.calculate_entropy(data)
- Verify function name: Check documentation for correct function names
-
Update package:
pip install --upgrade entropic_measurement
Symptoms: Results contain NaN, inf, or -inf values
Solutions:
-
Check input data:
- Ensure no zero probabilities in entropy calculations
- Verify data is properly normalized
- Remove or handle missing values
-
Use safe calculation modes:
# Use base parameter to avoid log(0) entropy = calculate_entropy(data, base=2, handle_zeros=True)
Symptoms: Results don't match expected values
Solutions:
- Verify input format: Check data structure and types
- Check parameters: Ensure correct base (2, e, 10) for entropy calculations
- Validate preprocessing: Confirm data normalization is correct
- Compare with manual calculation: Test with simple known cases
Symptoms: MemoryError or system slowdown
Solutions:
-
Process in chunks:
def process_large_dataset(data, chunk_size=1000): results = [] for i in range(0, len(data), chunk_size): chunk = data[i:i+chunk_size] result = calculate_entropy(chunk) results.append(result) return results
- Use data streaming for very large files
- Increase system memory or use a machine with more RAM
Symptoms: Functions take longer than expected to complete
Solutions:
- Use vectorized operations: Ensure input data is numpy arrays
- Optimize data types: Use appropriate dtypes (float32 vs float64)
-
Profile your code:
import cProfile cProfile.run('your_entropy_calculation()')
- Consider parallel processing for independent calculations
Symptoms: Excessive RAM consumption
Solutions:
- Use generators instead of lists for large datasets
-
Delete intermediate variables: Use
del variable_name -
Monitor memory usage:
import psutil import os process = psutil.Process(os.getpid()) print(f"Memory usage: {process.memory_info().rss / 1024 / 1024} MB")
import logging
logging.basicConfig(level=logging.DEBUG)
# Your entropy calculations heredef validate_input(data):
print(f"Data type: {type(data)}")
print(f"Data shape: {getattr(data, 'shape', 'Not array-like')}")
print(f"Data range: {min(data)} to {max(data)}")
print(f"Contains NaN: {any(x != x for x in data)}")
return data
# Use before calculations
validated_data = validate_input(your_data)
result = calculate_entropy(validated_data)# Test with known entropy values
test_data = [0.5, 0.5] # Should give entropy = 1.0 (base 2)
result = calculate_entropy(test_data, base=2)
print(f"Expected: 1.0, Got: {result}")import sys
import numpy as np
import entropic_measurement
print(f"Python version: {sys.version}")
print(f"NumPy version: {np.__version__}")
print(f"entropic_measurement version: {entropic_measurement.__version__}")| Error Message | Likely Cause | Solution |
|---|---|---|
ValueError: probabilities must sum to 1 |
Unnormalized probability distribution | Normalize your data: data / data.sum()
|
RuntimeWarning: divide by zero |
Zero probabilities in entropy calculation | Use handle_zeros=True parameter or filter zeros |
TypeError: unsupported operand type(s) |
Wrong data type | Convert to numpy array: np.array(data)
|
IndexError: list index out of range |
Empty or malformed input | Check input data length and structure |
If you're still experiencing issues:
- Check the documentation: Review function docstrings and examples
- Search existing issues: Look through GitHub Issues
- Create a minimal example: Reproduce the issue with the smallest possible code
-
Report bugs: Open a new issue with:
- Python version
- Package version
- Complete error message
- Minimal reproducible example
# Include this information in your bug report
import sys
import numpy as np
import entropic_measurement
print(f"Python: {sys.version}")
print(f"NumPy: {np.__version__}")
print(f"entropic_measurement: {entropic_measurement.__version__}")
print(f"Platform: {sys.platform}")
# Your minimal example here- Python: 3.7+
- NumPy: 1.18+
- SciPy: 1.5+ (if using advanced features)
For legacy Python versions, use entropic_measurement < 1.0.0
Last updated: July 23, 2025