Skip to content

Commit 1e4eb57

Browse files
committed
Update documentation and project standards to use uv
1 parent 26252ae commit 1e4eb57

File tree

5 files changed

+77
-39
lines changed

5 files changed

+77
-39
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,44 @@
22

33
## Installing Efficiency & Convexity
44

5-
First, set up a virtual environment (e.g. via [miniconda](https://docs.conda.io/en/latest/miniconda.html), `conda create -n eff_conv python=3.11`, and `conda activate eff_conv`).
6-
75
1. Download or clone this repository and navigate to the root folder.
86

97
2. Install the IB Optimizer (We recommend doing this inside a virtual environment)
108

119
`pip install -e .`
1210

11+
## Development, Examples, & Tests
12+
13+
### Setting Up the Environment
14+
15+
First, install [uv](https://docs.astral.sh/uv/getting-started/installation/). After `uv` is installed navigate to root of the project and execute:
16+
17+
```sh
18+
uv sync
19+
```
20+
21+
### Testing
22+
23+
Tests are located in `src/tests` and can be run using:
24+
25+
```sh
26+
uv run pytest
27+
```
28+
29+
### Examples
30+
31+
Examples can be found in the `src/examples` folder. Each example will have documentation of how to execute its scripts in their respective `README.md` files.
32+
Note that oftentimes scripts from each example are to be executed in the `src/examples` folder, NOT the folder of the example itself.
33+
1334
## References
1435

36+
<details>
1537
<summary>Links:</summary>
1638

1739
> Tishby, N., Fernando P., & Bialek, W. (2000). The information bottleneck method. The 37th annual Allerton Conference on Communication, Control, and Computing. pp. 368–377. https://doi.org/10.48550/arXiv.physics/0004057
1840
1941
> Skinner, L. (2025). Convexity is a Fundamental Feature of Efficient Semantic Compression in Probability Spaces. https://hdl.handle.net/1773/53008
2042
43+
> Zaslavsky, N., Kemp, C., Regier, T., & Tishby, N. (2018). Efficient compression in color naming and its evolution. Proceedings of the National Academy of Sciences, 115(31), 7937–7942. https://doi.org/10.1073/pnas.1800521115
44+
2145
</details>

pyproject.toml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ license = {file = "LICENSE.txt"}
2121
dependencies = [
2222
"scipy",
2323
"numpy",
24-
"pytest",
25-
"black",
26-
"statsmodels==0.14.5",
27-
"pandas==2.3.0",
28-
"open3d==0.19.0",
29-
"matplotlib==3.10.3",
30-
"scikit-image==0.25.2",
3124
]
3225

3326
[project.urls]
@@ -36,6 +29,24 @@ dependencies = [
3629

3730
[dependency-groups]
3831
dev = [
32+
"black",
3933
"ruff>=0.14.0",
4034
"ty>=0.0.1a21",
35+
"pytest",
4136
]
37+
38+
[project.optional-dependencies]
39+
colors = [
40+
"statsmodels==0.14.5",
41+
"pandas==2.3.0",
42+
"open3d==0.19.0",
43+
"matplotlib==3.10.3",
44+
"scikit-image==0.25.2",
45+
]
46+
47+
[tool.setuptools]
48+
package-dir = { "" = "src" }
49+
50+
[tool.setuptools.packages.find]
51+
where = ["src"]
52+
include = ["eff_conv*"]

src/examples/colors/README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
The paper and appendix can be found [here](./docs/).
66

77
## Setup
8-
After setting up the `eff_conv` environment, install the proper prerequisites:
8+
After setting up the general `uv` environment, install the proper prerequisites:
99
```sh
10-
python -m pip install -r requirements.txt
10+
uv sync --extra colors
1111
```
1212

1313
## How To Run
@@ -23,13 +23,11 @@ populate the relevant files.
2323

2424
### Creating the WCS and CIELab visualizations
2525

26-
TODO: The stimulus grid needs to be updated
27-
2826
In the `examples` directory, run the following commands to get CIELab visualization (Figure 2 in the paper):
2927
```sh
30-
python -m colors.visualization.cloud color_reg
31-
python -m colors.visualization.cloud color_rot 20
32-
python -m colors.visualization.cloud color_diff 20 diff
28+
uv run -m colors.visualization.cloud color_reg
29+
uv run -m colors.visualization.cloud color_rot 20
30+
uv run -m colors.visualization.cloud color_diff 20 diff
3331
```
3432

3533
This will create the files `color_reg.png`, `color_rot.png`, and `color_diff.png` in the `output/color` folder.
@@ -42,7 +40,7 @@ The raw model files for each experiement are very large (ranging from 250 MB for
4240
If you wish to run this experiment with your own data, after doing the data generation for experiment 1 and 2 you will need to generate the `.csv` files using the following command:
4341

4442
```sh
45-
python -m colors.utils.minimize_models
43+
uv run -m colors.utils.minimize_models
4644
```
4745

4846
### Experiment 1
@@ -51,7 +49,7 @@ python -m colors.utils.minimize_models
5149

5250
To generate the color model run the following command in the `examples` directory:
5351
```sh
54-
python -m colors.exp1.generate_color_model
52+
uv run -m colors.exp1.generate_color_model
5553
```
5654

5755
#### Data Analysis
@@ -61,11 +59,11 @@ Please ensure you have the minimized `.csv` files before doing analysis.
6159
You can generate the plots and correlations using the respective commands:
6260
```sh
6361
# Plots
64-
python -m colors.exp1.generate_color_plot
65-
python -m colors.exp1.gen_whisker_plots
62+
uv run -m colors.exp1.generate_color_plot
63+
uv run -m colors.exp1.gen_whisker_plots
6664
# Correlations
67-
python -m colors.exp1.generate_color_correlation
68-
python -m colors.utils.ols_model color_model
65+
uv run -m colors.exp1.generate_color_correlation
66+
uv run -m colors.utils.ols_model color_model
6967
```
7068

7169
### Experiments 2 & 3
@@ -74,7 +72,7 @@ python -m colors.utils.ols_model color_model
7472

7573
To generate the test models for experiments 2 and 3, you can run the followign command in the `examples` directory:
7674
```sh
77-
python -m colors.exp2_3.generate_models
75+
uv run -m colors.exp2_3.generate_models
7876
```
7977

8078
### Data Analysis
@@ -83,8 +81,8 @@ Please ensure you have the minimized `.csv` files before doing analysis.
8381

8482
After this you can generate the plots and correlations using the respective commands:
8583
```sh
86-
python -m colors.exp2_3.generate_plots
87-
python -m colors.exp2_3.calculate_correlation
84+
uv run -m colors.exp2_3.generate_plots
85+
uv run -m colors.exp2_3.calculate_correlation
8886
```
8987

9088
### OLS Models
@@ -93,7 +91,7 @@ Please ensure you have the minimized `.csv` files before running the OLS model.
9391

9492
After the `.csv` files are generated, you can generate the the OLS model for a given environment with the following command
9593
```sh
96-
python -m colors.utils.ols_model [environment_name]
94+
uv run -m colors.utils.ols_model [environment_name]
9795
```
9896

9997
## Additional Documentation

src/examples/colors/visualization/cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,6 @@ def custom_draw(
184184
pcd,
185185
extras=[xy_grid, xz_grid, yz_grid],
186186
lookat=min_bound + np.array([-20, 0, 10]),
187-
up=np.ndarray([1, 0, 0]),
187+
up=np.array([1, 0, 0]),
188188
camera_position=center + np.array([-135, -180, -220]),
189189
)

uv.lock

Lines changed: 17 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)