-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
77 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
TASK_X_REMOTE_TASKFILES=1 | ||
SOURCE_FOLDER=src/cvxball | ||
SOURCE_FOLDER=src/cvx | ||
TESTS_FOLDER=src/tests | ||
MARIMO_FOLDER=book/marimo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ dependencies = [ | |
"plotly>=5.24.1", | ||
# Install solvers | ||
"clarabel>=0.9.0" | ||
|
||
] | ||
|
||
[project.urls] | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from dataclasses import dataclass | ||
|
||
import numpy as np | ||
import plotly.graph_objects as go | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Circle: | ||
center: np.ndarray | ||
radius: float | ||
|
||
def scatter(self, num=100, color="red"): | ||
t = np.linspace(0, 2 * np.pi, num=num) | ||
radius = self.radius | ||
circle_x = self.center[0] + radius * np.cos(t) | ||
circle_y = self.center[1] + radius * np.sin(t) | ||
|
||
return go.Scatter( | ||
x=circle_x, | ||
y=circle_y, | ||
mode="lines", | ||
line=dict(color=color, width=2), | ||
name=f"Circle(r = {self.radius})", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from dataclasses import dataclass | ||
|
||
import numpy as np | ||
import plotly.graph_objects as go | ||
|
||
|
||
@dataclass(frozen=True) | ||
class Cloud: | ||
points: np.ndarray | ||
|
||
def scatter(self, size=10): | ||
return go.Scatter( | ||
x=self.points[:, 0], | ||
y=self.points[:, 1], | ||
mode="markers", | ||
marker=dict(symbol="x", size=size, color="blue"), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import plotly.graph_objects as go | ||
|
||
|
||
def create_figure(): | ||
# Create the scatter plot | ||
fig = go.Figure() | ||
|
||
# Update layout for equal aspect ratio and axis labels | ||
fig.update_layout( | ||
xaxis_title="x", | ||
yaxis_title="y", | ||
yaxis=dict( | ||
scaleanchor="x", | ||
scaleratio=1, | ||
), | ||
) | ||
|
||
return fig |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
|
||
from cvx.ball.solver import min_circle_cvx | ||
from cvx.ball.utils.cloud import Cloud | ||
from cvx.ball.utils.figure import create_figure | ||
|
||
|
||
def test_random(): | ||
p = np.array([[2.0, 4.0], [0, 0], [2.5, 2.0]]) | ||
cloud = Cloud(p) | ||
circle = min_circle_cvx(p, solver="CLARABEL") | ||
|
||
fig = create_figure() | ||
fig.add_trace(circle.scatter()) | ||
fig.add_trace(cloud.scatter()) | ||
|
||
# fig.show() |
This file was deleted.
Oops, something went wrong.