Skip to content

Commit

Permalink
update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlujan91 committed May 3, 2024
1 parent b7b37a3 commit aa219cf
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 215 deletions.
46 changes: 25 additions & 21 deletions examples/01_Curvilinear/03._Curvilinear_Interpolation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warped interpolation took 0.00297 seconds\n"
"Warped interpolation took 0.00322 seconds\n"
]
}
],
Expand All @@ -212,7 +212,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Curvilinear interpolation took 0.01057 seconds\n"
"Curvilinear interpolation took 0.01260 seconds\n"
]
}
],
Expand Down Expand Up @@ -246,7 +246,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f8f8a5db2f0>"
"<matplotlib.legend.Legend at 0x7fc7c1640410>"
]
},
"execution_count": 8,
Expand Down Expand Up @@ -402,7 +402,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warped interpolation took 0.00154 seconds\n"
"Warped interpolation took 0.00985 seconds\n"
]
}
],
Expand Down Expand Up @@ -431,7 +431,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Curvilinear interpolation took 0.00699 seconds\n"
"Curvilinear interpolation took 0.00764 seconds\n"
]
}
],
Expand All @@ -457,7 +457,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f8f8a9ce4e0>"
"<matplotlib.legend.Legend at 0x7fc7c1402a20>"
]
},
"execution_count": 15,
Expand All @@ -476,7 +476,8 @@
}
],
"source": [
"plt.imshow(function_2(grid_x, grid_y), extent=(-0.5, 0.5, -0.5, 0.5), origin=\"lower\")\n",
"plt.imshow(function_2(grid_x, grid_y),\n",
" extent=(-0.5, 0.5, -0.5, 0.5), origin=\"lower\")\n",
"plt.plot(rand_x.flat, rand_y.flat, \"ok\", ms=2, label=\"input points\")\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
Expand Down Expand Up @@ -626,7 +627,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warped interpolation took 0.00118 seconds\n"
"Warped interpolation took 0.00202 seconds\n"
]
}
],
Expand All @@ -653,7 +654,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Curvilinear interpolation took 0.00667 seconds\n"
"Curvilinear interpolation took 0.00884 seconds\n"
]
}
],
Expand Down Expand Up @@ -687,7 +688,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f8f8a5e7d10>"
"<matplotlib.legend.Legend at 0x7fc7c0992ae0>"
]
},
"execution_count": 23,
Expand Down Expand Up @@ -842,7 +843,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warped interpolation took 0.00456 seconds\n"
"Warped interpolation took 0.00925 seconds\n"
]
}
],
Expand All @@ -869,7 +870,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Curvilinear interpolation took 0.00888 seconds\n"
"Curvilinear interpolation took 0.01510 seconds\n"
]
}
],
Expand Down Expand Up @@ -983,7 +984,8 @@
" return np.maximum(\n",
" 0.0,\n",
" 1.0\n",
" - np.exp(0.5 - np.prod(np.asarray(args) + 0.2, axis=0) ** (1.0 / len(args))),\n",
" - np.exp(0.5 - np.prod(np.asarray(args) +\n",
" 0.2, axis=0) ** (1.0 / len(args))),\n",
" )"
]
},
Expand Down Expand Up @@ -1064,7 +1066,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warped interpolation took 0.00753 seconds\n"
"Warped interpolation took 0.00896 seconds\n"
]
}
],
Expand All @@ -1091,7 +1093,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Curvilinear interpolation took 0.02471 seconds\n"
"Curvilinear interpolation took 0.02468 seconds\n"
]
},
{
Expand Down Expand Up @@ -1125,7 +1127,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f8f8a40bf50>"
"<matplotlib.legend.Legend at 0x7fc7c0cad910>"
]
},
"execution_count": 39,
Expand Down Expand Up @@ -1154,7 +1156,8 @@
" cmap=\"viridis\",\n",
" edgecolor=\"none\",\n",
")\n",
"ax.scatter(rand_x, rand_y, values, c=values, cmap=\"viridis\", label=\"input points\")\n",
"ax.scatter(rand_x, rand_y, values, c=values,\n",
" cmap=\"viridis\", label=\"input points\")\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
]
Expand Down Expand Up @@ -1291,7 +1294,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Warped interpolation took 0.00407 seconds\n"
"Warped interpolation took 0.00391 seconds\n"
]
}
],
Expand All @@ -1318,7 +1321,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Curvilinear interpolation took 0.02417 seconds\n"
"Curvilinear interpolation took 0.02572 seconds\n"
]
}
],
Expand All @@ -1344,7 +1347,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f8f80364560>"
"<matplotlib.legend.Legend at 0x7fc7c0222ae0>"
]
},
"execution_count": 47,
Expand Down Expand Up @@ -1373,7 +1376,8 @@
" cmap=\"viridis\",\n",
" edgecolor=\"none\",\n",
")\n",
"ax.scatter(rand_x, rand_y, values, c=values, cmap=\"viridis\", label=\"input points\", s=1)\n",
"ax.scatter(rand_x, rand_y, values, c=values,\n",
" cmap=\"viridis\", label=\"input points\", s=1)\n",
"ax.view_init(30, 150)\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
Expand Down
61 changes: 31 additions & 30 deletions examples/01_Curvilinear/04._Piecewise_Affine_Interpolation.ipynb

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions examples/02_Unstructured/06._Unstructured_Interpolation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f71736739e0>"
"<matplotlib.legend.Legend at 0x7f8ee90f9d60>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -361,7 +361,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f717346b320>"
"<matplotlib.legend.Legend at 0x7f8ee90b25d0>"
]
},
"execution_count": 13,
Expand All @@ -380,7 +380,8 @@
}
],
"source": [
"plt.imshow(function_2(grid_x, grid_y).T, extent=(-0.5, 0.5, -0.5, 0.5), origin=\"lower\")\n",
"plt.imshow(function_2(grid_x, grid_y).T,\n",
" extent=(-0.5, 0.5, -0.5, 0.5), origin=\"lower\")\n",
"plt.plot(rand_x, rand_y, \"ok\", label=\"input points\")\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
Expand Down Expand Up @@ -550,7 +551,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f71731ecc50>"
"<matplotlib.legend.Legend at 0x7f8ee8e1d8e0>"
]
},
"execution_count": 20,
Expand Down Expand Up @@ -727,7 +728,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f71730a20c0>"
"<matplotlib.legend.Legend at 0x7f8ee8ee8d10>"
]
},
"execution_count": 27,
Expand Down Expand Up @@ -815,7 +816,8 @@
" return np.maximum(\n",
" 0.0,\n",
" 1.0\n",
" - np.exp(0.5 - np.prod(np.asarray(args) + 0.2, axis=0) ** (1.0 / len(args))),\n",
" - np.exp(0.5 - np.prod(np.asarray(args) +\n",
" 0.2, axis=0) ** (1.0 / len(args))),\n",
" )"
]
},
Expand Down Expand Up @@ -908,7 +910,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f7173299640>"
"<matplotlib.legend.Legend at 0x7f8ec5f6fd10>"
]
},
"execution_count": 34,
Expand Down Expand Up @@ -937,7 +939,8 @@
" cmap=\"viridis\",\n",
" edgecolor=\"none\",\n",
")\n",
"ax.scatter(rand_x, rand_y, values, c=values, cmap=\"viridis\", label=\"input points\")\n",
"ax.scatter(rand_x, rand_y, values, c=values,\n",
" cmap=\"viridis\", label=\"input points\")\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
]
Expand Down Expand Up @@ -1086,7 +1089,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7f7170352810>"
"<matplotlib.legend.Legend at 0x7f8ebff05400>"
]
},
"execution_count": 41,
Expand Down Expand Up @@ -1115,7 +1118,8 @@
" cmap=\"viridis\",\n",
" edgecolor=\"none\",\n",
")\n",
"ax.scatter(rand_x, rand_y, values, c=values, cmap=\"viridis\", label=\"input points\")\n",
"ax.scatter(rand_x, rand_y, values, c=values,\n",
" cmap=\"viridis\", label=\"input points\")\n",
"ax.view_init(30, 150)\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
Expand Down
20 changes: 12 additions & 8 deletions examples/02_Unstructured/07._Regression_Interpolation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fc5ae771970>"
"<matplotlib.legend.Legend at 0x7f6e47053e00>"
]
},
"execution_count": 7,
Expand Down Expand Up @@ -400,7 +400,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fc5a856f050>"
"<matplotlib.legend.Legend at 0x7f6e46b75580>"
]
},
"execution_count": 12,
Expand All @@ -419,7 +419,8 @@
}
],
"source": [
"plt.imshow(np.hypot(grid_x, grid_y).T, extent=(-0.5, 0.5, -0.5, 0.5), origin=\"lower\")\n",
"plt.imshow(np.hypot(grid_x, grid_y).T,\n",
" extent=(-0.5, 0.5, -0.5, 0.5), origin=\"lower\")\n",
"plt.plot(rand_x, rand_y, \"ok\", label=\"input points\")\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
Expand Down Expand Up @@ -721,7 +722,8 @@
" return np.maximum(\n",
" 0.0,\n",
" 1.0\n",
" - np.exp(0.5 - np.prod(np.asarray(args) + 0.2, axis=0) ** (1.0 / len(args))),\n",
" - np.exp(0.5 - np.prod(np.asarray(args) +\n",
" 0.2, axis=0) ** (1.0 / len(args))),\n",
" )"
]
},
Expand Down Expand Up @@ -843,7 +845,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fc5a8096ba0>"
"<matplotlib.legend.Legend at 0x7f6e4416e7e0>"
]
},
"execution_count": 26,
Expand Down Expand Up @@ -872,7 +874,8 @@
" cmap=\"viridis\",\n",
" edgecolor=\"none\",\n",
")\n",
"ax.scatter(rand_x, rand_y, values, c=values, cmap=\"viridis\", label=\"input points\")\n",
"ax.scatter(rand_x, rand_y, values, c=values,\n",
" cmap=\"viridis\", label=\"input points\")\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
]
Expand Down Expand Up @@ -1065,7 +1068,7 @@
{
"data": {
"text/plain": [
"<matplotlib.legend.Legend at 0x7fc589483830>"
"<matplotlib.legend.Legend at 0x7f6e3c6d67e0>"
]
},
"execution_count": 33,
Expand Down Expand Up @@ -1094,7 +1097,8 @@
" cmap=\"viridis\",\n",
" edgecolor=\"none\",\n",
")\n",
"ax.scatter(rand_x, rand_y, values, c=values, cmap=\"viridis\", label=\"input points\")\n",
"ax.scatter(rand_x, rand_y, values, c=values,\n",
" cmap=\"viridis\", label=\"input points\")\n",
"ax.view_init(30, 150)\n",
"plt.title(\"Original\")\n",
"plt.legend(loc=\"lower right\")"
Expand Down
11 changes: 5 additions & 6 deletions src/multinterp/curvilinear/_scikit_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

from multinterp.grids import _CurvilinearGrid
from multinterp.rectilinear._multi import MultivariateInterp
from multinterp.utilities import import_backends, update_mc_kwargs

AVAILABLE_BACKENDS, BACKEND_MODULES = import_backends()
from multinterp.utilities import mgrid, update_mc_kwargs


class PiecewiseAffineInterp(_CurvilinearGrid, MultivariateInterp):
Expand All @@ -15,9 +13,10 @@ def __init__(self, values, grids, options=None):
self.mc_kwargs = update_mc_kwargs(options)

source = self.grids.reshape((self.ndim, -1)).T
coordinates = BACKEND_MODULES[self.backend].mgrid[
tuple(slice(0, dim) for dim in self.shape)
]
coordinates = mgrid(
tuple(slice(0, dim) for dim in self.shape),
backend=self.backend,
)
destination = coordinates.reshape((self.ndim, -1)).T

interpolator = PiecewiseAffineTransform()
Expand Down
Loading

0 comments on commit aa219cf

Please sign in to comment.