Objects Quickly - AI tools at your finger tips
Project description
OQ - Objects Quickly
Quick access to popular data science and machine learning libraries.
Overview
OQ (Objects Quickly) is a convenience package that provides instant access to commonly used objects and functions from popular Python data science and machine learning libraries. It eliminates the need for repetitive imports and gives you quick access to the tools you need.
Key Features
- Optional Dependencies: All scientific/ML libraries are optional - only import what you have installed
- Flexible Imports: Use module-specific imports (
import oq.pd) or get everything at once (import oq) - Configurable: Control which modules are imported and in what order
- Zero Setup: Works out of the box with intelligent defaults
- Name Collision Handling: Import order determines precedence when function names overlap
Installation
Basic Installation
pip install oq
This installs only the core package with configuration support.
With Optional Dependencies
Install specific libraries:
# Data science essentials
pip install oq[datascience] # numpy, pandas, scipy, matplotlib, seaborn
# Machine learning
pip install oq[ml] # scikit-learn, xgboost, lightgbm
# Deep learning
pip install oq[deeplearning] # torch, tensorflow
# Visualization
pip install oq[viz] # matplotlib, seaborn, plotly
# Everything
pip install oq[all]
Or install individual libraries:
pip install oq[numpy]
pip install oq[pandas]
pip install oq[sklearn]
# etc.
Available individual extras: numpy, pandas, scipy, matplotlib, seaborn, plotly, sklearn, xgboost, lightgbm, torch, tensorflow, statsmodels
Usage
Module-Specific Imports
Import and use objects from specific libraries:
# Import pandas utilities
from oq import pd
# Use pandas objects directly
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
print(pd.concat([df, df]))
# Import numpy utilities
from oq import np
# Use numpy objects directly
arr = np.array([1, 2, 3])
print(np.mean(arr))
Root-Level Import (Auto-Import)
Import everything from all installed libraries at once:
import oq
# All objects from installed libraries are available directly
df = oq.DataFrame({'a': [1, 2, 3]}) # from pandas
arr = oq.array([1, 2, 3]) # from numpy
model = oq.RandomForestClassifier() # from sklearn
Module Abbreviations
OQ uses intuitive abbreviations for popular libraries:
| Abbreviation | Library | Description |
|---|---|---|
np |
numpy | Numerical computing |
pd |
pandas | Data manipulation and analysis |
sp |
scipy | Scientific computing |
plt |
matplotlib.pyplot | Plotting and visualization |
sns |
seaborn | Statistical visualization |
sk |
sklearn | Machine learning (scikit-learn) |
xgb |
xgboost | Gradient boosting |
lgb |
lightgbm | Light gradient boosting |
torch |
torch | Deep learning (PyTorch) |
tf |
tensorflow | Deep learning (TensorFlow) |
px |
plotly.express | Interactive visualization |
sm |
statsmodels | Statistical modeling |
Configuration
Default Behavior
By default, OQ:
- Auto-imports all available modules to the root namespace
- Imports in this order:
np,pd,sp,plt,sns,sk,xgb,lgb,torch,tf,px,sm - Later imports take precedence in case of name conflicts
Custom Configuration
You can customize OQ's behavior by creating a configuration file. OQ uses the config2py package for configuration management.
Create a config file at one of these locations:
~/.config/oq/config.json- Custom location set via
OQ_APP_DATA_DIRenvironment variable
Example configuration:
{
"import_config": {
"auto_import_to_root": true,
"module_order": [
"pd",
"np",
"sk"
],
"enabled_modules": {
"np": true,
"pd": true,
"sp": false,
"plt": true,
"sns": false,
"sk": true,
"xgb": false,
"lgb": false,
"torch": false,
"tf": false,
"px": false,
"sm": false
}
}
}
Configuration options:
auto_import_to_root: Whether to auto-import modules tooqnamespace (default:true)module_order: Order in which modules are imported (determines precedence for name conflicts)enabled_modules: Which modules to import when usingimport oq
Handling Name Conflicts
When multiple libraries define functions with the same name, the import order determines which one is used:
import oq
# If both numpy and torch are installed, and numpy comes first in module_order:
oq.tensor # This will be torch.tensor (later in import order wins)
To avoid conflicts, use module-specific imports:
from oq import np, torch
np_array = np.array([1, 2, 3])
torch_tensor = torch.tensor([1, 2, 3])
How It Works
OQ uses dynamic introspection to extract callable objects from installed libraries:
- Conditionally imports libraries (fails gracefully if not installed)
- Uses the
guidepackage to extract all public callables - Injects them into the module namespace
- Makes them available for your use
This means:
- No manual maintenance of exported functions
- Always up-to-date with the latest library versions
- Only imports what you have installed
- Zero overhead if you don't use certain libraries
Examples
Data Analysis Workflow
import oq
# Load data
df = oq.read_csv('data.csv')
# Analyze
print(df.describe())
# Transform
arr = oq.array(df['column'])
normalized = oq.scale(arr) # sklearn's scale
# Visualize
oq.figure(figsize=(10, 6))
oq.plot(df['x'], df['y'])
oq.show()
Machine Learning Pipeline
from oq import pd, np, sk
# Load data
df = pd.read_csv('data.csv')
X = df.drop('target', axis=1)
y = df['target']
# Train model
model = sk.RandomForestClassifier()
model.fit(X, y)
# Predict
predictions = model.predict(X)
accuracy = sk.accuracy_score(y, predictions)
print(f'Accuracy: {accuracy}')
Quick Exploration
import oq
# Just start working with your data
data = oq.array([[1, 2], [3, 4], [5, 6]])
df = oq.DataFrame(data, columns=['A', 'B'])
print(df.corr())
# Plot
oq.scatter(df['A'], df['B'])
Development
Running Tests
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License - see LICENSE file for details.
Author
Thor Whalen
Links
- GitHub: https://github.com/thorwhalen/oq
- PyPI: https://pypi.org/project/oq/
Related Projects
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oq-0.0.4.tar.gz.
File metadata
- Download URL: oq-0.0.4.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
789a60021815f9240ec7174e7afe58f4334a3b4200f18363d37848d2cea195d0
|
|
| MD5 |
cad2c11740a6f25216b1907651e25479
|
|
| BLAKE2b-256 |
ed1cc25406fdd2bfcf74362c489a554dac9030cebe302b15387ca839d75392e3
|
File details
Details for the file oq-0.0.4-py3-none-any.whl.
File metadata
- Download URL: oq-0.0.4-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81cb4259dfb843cec95951d22716a85adb6e46ac097f698cd9bf0ea1a085a6da
|
|
| MD5 |
546b59123e24151a87cc798a979fb3bd
|
|
| BLAKE2b-256 |
dc2dd320f80e063795762f918fdff316eb356b8854b537b4cff733958bc3a2e7
|