Skip to content

Commit 0514dc9

Browse files
authored
Merge branch 'main' into new_examples_FEI
2 parents 4039741 + 3e45290 commit 0514dc9

71 files changed

Lines changed: 8718 additions & 5706 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
indent_style = space
9+
indent_size = 4
10+
11+
[*.{yaml,yml,toml}]
12+
indent_size = 2
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ assignees: ''
2121
## Steps to Reproduce
2222

2323
<!-- Steps to reproduce the bug -->
24-
1.
25-
2.
26-
3.
24+
1.
25+
2.
26+
3.
2727

2828
## Minimal Code Example
2929

@@ -37,12 +37,12 @@ from rehline import ReHLine
3737

3838
## Environment
3939

40-
- OS:
41-
- Python version:
42-
- ReHLine version:
43-
- NumPy version:
44-
- SciPy version:
45-
- scikit-learn version:
40+
- OS:
41+
- Python version:
42+
- ReHLine version:
43+
- NumPy version:
44+
- SciPy version:
45+
- scikit-learn version:
4646

4747
## Additional Context
4848

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ jobs:
3030
python-version: ${{ matrix.python-version }}
3131

3232
- name: Install package and test dependencies
33-
run: pip install ".[test]" pytest-cov
33+
run: pip install -e ".[test]" pytest-cov
3434

3535
- name: Run tests
36-
run: pytest -v --tb=short --cov=rehline --cov-report=xml --cov-report=term
36+
run: pytest -v --tb=short --cov-report=xml
3737

3838
- name: Upload coverage to Codecov
3939
if: success()

.github/workflows/wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Build and upload to PyPI
22

3-
on:
3+
on:
44
push:
55
paths-ignore:
66
- .gitignore
@@ -27,7 +27,7 @@ jobs:
2727
uses: pypa/cibuildwheel@v3.3.1
2828
env:
2929
CIBW_BUILD_VERBOSITY: 1
30-
30+
3131
- uses: actions/upload-artifact@v6
3232
with:
3333
name: rehline-wheels-${{ matrix.os }}-${{ strategy.job-index }}

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ rehline.egg-info/
1414
*.log
1515
env/
1616

17+
# Coverage reports
18+
.coverage
19+
coverage.xml
20+
htmlcov/
21+
1722
# Files during package building
1823
eigen-3.4.0/
1924
eigen-5.0.1/
@@ -41,4 +46,7 @@ eigen3.zip
4146
*-checkpoint.py
4247

4348
# local
44-
local/
49+
local/
50+
51+
# auto API
52+
doc/source/autoapi/

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v5.0.0
4+
hooks:
5+
- id: trailing-whitespace
6+
args: [--markdown-linebreak-ext=md]
7+
- id: end-of-file-fixer
8+
- id: check-yaml
9+
- id: check-added-large-files
10+
args: [--maxkb=500]
11+
- id: check-merge-conflict
12+
13+
- repo: https://github.com/astral-sh/ruff-pre-commit
14+
rev: v0.11.4
15+
hooks:
16+
- id: ruff
17+
args: [--fix, --exit-non-zero-on-fix]
18+
- id: ruff-format
19+
20+
- repo: https://github.com/codespell-project/codespell
21+
rev: v2.4.1
22+
hooks:
23+
- id: codespell
24+
additional_dependencies: [tomli]
25+
args: [--skip, "*.so,*.cpp,*.h,*.zip,eigen-*,build,dist,.git"]

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ sphinx:
2929
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
3030
python:
3131
install:
32-
- requirements: ./requirements.txt
32+
- requirements: ./requirements.txt

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"tuple": "cpp",
77
"utility": "cpp"
88
}
9-
}
9+
}

README.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ See more details in the [ReHLine documentation](https://rehline-python.readthedo
3030
pip install rehline
3131
```
3232

33+
### Development Install
34+
35+
For contributors and developers:
36+
37+
```bash
38+
git clone https://github.com/softmin/ReHLine-python.git
39+
cd ReHLine-python
40+
pip install -e ".[dev]"
41+
```
42+
43+
To run tests:
44+
45+
```bash
46+
pytest tests/
47+
```
48+
3349
## 🚀 Quick Start
3450

3551
### Scikit-Learn Style API (Recommended)
@@ -79,20 +95,27 @@ print(f"Best params: {grid_search.best_params_}")
7995
from rehline import ReHLine
8096
import numpy as np
8197

98+
# Generate sample data
99+
np.random.seed(42)
100+
X = np.random.randn(100, 5)
101+
y = np.random.choice([-1, 1], size=100)
102+
n, d = X.shape
103+
C = 1.0
104+
82105
# Define custom PLQ loss parameters
83106
clf = ReHLine()
84107
# Set custom U, V matrices for ReLU loss
85108
# and S, T, tau for ReHU loss
86109
## U
87-
clf.U = -(C*y).reshape(1,-1)
110+
clf._U = -(C*y).reshape(1,-1)
88111
## V
89-
clf.V = (C*np.array(np.ones(n))).reshape(1,-1)
112+
clf._V = (C*np.ones(n)).reshape(1,-1)
90113

91114
# Set custom linear constraints A*beta + b >= 0
92115
X_sen = X[:,0]
93116
tol_sen = 0.1
94-
clf.A = np.repeat([X_sen @ X], repeats=[2], axis=0) / n
95-
clf.A[1] = -clf.A[1]
117+
clf._A = np.repeat([X_sen @ X], repeats=[2], axis=0) / n
118+
clf._A[1] = -clf._A[1]
96119

97120
clf.fit(X)
98121
```
@@ -113,7 +136,7 @@ ReHLine excels at solving a wide range of machine learning problems:
113136
| **Sparse Learning** | Feature selection with L1 regularization | Scales to high dimensions |
114137
| **Custom Optimization** | Any PLQ loss with linear constraints | Flexible framework for research |
115138

116-
<!--
139+
<!--
117140
## 📝 Formulation
118141
119142
**ReHLine** is designed to address the empirical regularized ReLU-ReHU minimization problem, named *ReHLine optimization*, of the following form:

0 commit comments

Comments
 (0)