Skip to content

Commit fbe26fd

Browse files
authored
Add uv packaging (#1)
* Add uv and numpy as dependency * Add pytest, and CI * Change main to master * Add passing test for now
1 parent 6d76873 commit fbe26fd

6 files changed

Lines changed: 197 additions & 53 deletions

File tree

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ["3.10", "3.11", "3.12", "3.13"]
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Install uv
20+
uses: astral-sh/setup-uv@v2
21+
with:
22+
version: "latest"
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
run: uv python install ${{ matrix.python-version }}
26+
27+
- name: Install dependencies
28+
run: |
29+
uv sync --all-extras --dev
30+
31+
- name: Test with pytest
32+
run: |
33+
uv run pytest

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.13

pyproject.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[project]
2+
name = "shellz"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
requires-python = ">=3.11"
6+
authors = [
7+
{ name = "Ivar Stangeby", email = "istangeby+shellz@gmail.com" }
8+
]
9+
keywords = ["blender", "addon", "seashell", "parametric", "3d-modeling"]
10+
dependencies = [
11+
"numpy>=2.3.1",
12+
]
13+
14+
[dependency-groups]
15+
dev = [
16+
"pytest>=8.4.1",
17+
]

src/main.py renamed to shellz/main.py

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import bpy
2-
3-
import numpy as np
4-
import PIL.Image
52
from mathutils import Vector
3+
import numpy as np
64

75
bl_info = {
86
"name": "Shellz",
@@ -208,16 +206,12 @@ def normalize_object_size(blender_object):
208206
v.co -= vMin
209207

210208

211-
class GeneratingCurve(object):
212-
pass
213-
214209

215210
def cot(alpha):
216211
return 1 / np.tan(alpha)
217212

218213

219-
class Ellipse(GeneratingCurve):
220-
214+
class Ellipse:
221215
def __init__(self, a=1, b=1, A=1, alpha=30, beta=30, omega=0, phi=0, mu=0, L=0, N=0, W_1=0, W_2=0, P=0):
222216
"""
223217
Initializes an elliptical generating curve with semi-axes a and b.
@@ -291,7 +285,7 @@ def _nodules(self, s, theta):
291285

292286
class Shell(object):
293287

294-
def __init__(self, helico_spiral, generating_curve):
288+
def __init__(self, helico_spiral: "HelicoSpiral", generating_curve: Ellipse):
295289
"""
296290
Initialize a shell by specifying the generating curve and the helico spiral.
297291
@@ -340,47 +334,3 @@ def __call__(self, theta):
340334
h[2] = -np.cos(beta) * np.exp(theta * cot)
341335

342336
return A * h
343-
344-
345-
def generate_texture(rho, kappa, mu, rho_0, sigma, nu, D_a, D_s, N, M):
346-
t_values, dt = np.linspace(0, 1, N, retstep=True)
347-
x_values, dx = np.linspace(0, 1, M, retstep=True)
348-
349-
s = np.zeros((N, M))
350-
a = np.zeros((N, M))
351-
352-
rho_array = np.random.normal(rho, scale=0.025, size=(N, M))
353-
s[0] = np.zeros(M)
354-
a[0] = np.zeros(M)
355-
356-
def rhs(a_prev, s_prev):
357-
da_ddx = np.gradient(np.gradient(a_prev))
358-
ds_ddx = np.gradient(np.gradient(s_prev))
359-
360-
da_dt = rho * s_prev * (a_prev ** 2 / (1 + kappa * a_prev ** 2) + rho_0) - mu * a_prev + D_a * da_ddx
361-
ds_dt = sigma - rho * s_prev * (a_prev ** 2 / (1 + kappa * a_prev ** 2) + rho_0) - nu * s_prev + D_s * ds_ddx
362-
363-
return da_dt, ds_dt
364-
365-
for i in range(0, N - 1):
366-
rho = rho_array[i]
367-
da_dt, ds_dt = rhs(a[i], s[i])
368-
369-
a[i + 1] = a[i] + dt * da_dt
370-
s[i + 1] = s[i] + dt * ds_dt
371-
372-
return a / np.max(a, axis=(0, 1))
373-
374-
375-
if __name__ == '__main__':
376-
register()
377-
378-
texture_map = generate_texture(rho=0.1, rho_0=0.005, mu=0.1, D_a=0.004, sigma=0.012, nu=0, D_s=0.0, kappa=1,
379-
N=100,
380-
M=100)
381-
import matplotlib.pyplot as plt
382-
383-
plt.imshow(texture_map)
384-
map = np.uint8(texture_map * 255)
385-
img = PIL.Image.fromarray(map)
386-
img.save('test.png')

tests/test_unit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def test_true():
2+
assert True

0 commit comments

Comments
 (0)