-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_ops.py
56 lines (39 loc) · 1.15 KB
/
demo_ops.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import stages
from utils import *
import matplotlib.pyplot as plt
import seaborn
os.makedirs("plots", exist_ok=True)
def plot_points(pts, title=None, counter=[0]):
df = pd.DataFrame(pts, columns=["x", "y", "z"])
plt.xlim(-5, 5)
plt.ylim(-5, 5)
seaborn.scatterplot(
data=df,
x="x", y="y", hue="z",
)
if title:
plt.title(title)
plt.tight_layout()
plt.savefig(f"plots/demo_ops_{counter[0]}.png")
counter[0] += 1
plt.show()
def swap_xy(pts):
return np.stack((pts[:,1], pts[:,0], pts[:,2]), axis=-1)
pts = np.random.randn(1000, 3)
x, _ = stages.FakeReader(points_per_chunk=100)(pts)
x = stages.Decimate(2)(x)
out1 = stages.Collect()(x)
x = stages.Filter(min_x=-1, max_y=2)(x)
out2 = stages.Collect()(x)
x = stages.Translate(-1, 1, 0.5)(x)
out3 = stages.Collect()(x)
x = stages.Scale(2, 1, 3)(x)
out4 = stages.Collect()(x)
x = stages.Lambda(swap_xy)(x)
out5 = stages.Collect()(x)
plot_points(pts, title="original")
plot_points(out1, title="decimated")
plot_points(out2, title="filtered")
plot_points(out3, title="translated")
plot_points(out4, title="scaled")
plot_points(out5, title="lambda: swap_xy")