Skip to content

Commit

Permalink
Load test images from scipy.datasets
Browse files Browse the repository at this point in the history
The API `scipy.misc.accent()` is deprecated. Use the new API
`scipy.datasets.accent()`.
  • Loading branch information
antonysigma committed Jan 7, 2025
1 parent d114511 commit d79159d
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ ProxImaL
=====================
![Build Status](https://github.com/comp-imaging/ProxImaL/actions/workflows/python-package.yml/badge.svg)

ProxImaL is a Python-embedded modeling language for image optimization problems.
It allows you to express your problem in a natural way that follows the math,
ProxImaL is a Python-embedded modeling language for image optimization problems.
It allows you to express your problem in a natural way that follows the math,
and automatically determines an efficient method for solving the problem.
ProxImaL makes it easy to experiment with many different priors and other problem reformulations,
without worrying about the details of how the problem is solved.
Expand All @@ -17,7 +17,7 @@ import scipy.misc
import matplotlib.pyplot as plt

# Generate data.
I = scipy.misc.ascent()
I = scipy.datasets.ascent()
np.random.seed(1)
b = I + 10*np.random.randn(*I.shape)

Expand Down Expand Up @@ -53,5 +53,5 @@ See [the accompanying paper](https://stevendiamond.me/pdf/proximal.pdf) for a fu

A tutorial and other documentation can be found at [proximal-lang.org](http://www.proximal-lang.org/).

This git repository holds the latest development version of ProxImaL. For installation instructions,
This git repository holds the latest development version of ProxImaL. For installation instructions,
see the [install guide](http://www.proximal-lang.org/en/latest/install/index.html) at [proximal-lang.org](http://www.proximal-lang.org/).
6 changes: 3 additions & 3 deletions doc/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
Welcome to ProxImaL
=====================

ProxImaL is a Python-embedded modeling language for image optimization problems.
It allows you to express your problem in a natural way that follows the math,
ProxImaL is a Python-embedded modeling language for image optimization problems.
It allows you to express your problem in a natural way that follows the math,
and automatically determines an efficient method for solving the problem.
ProxImaL makes it easy to experiment with many different priors and other problem reformulations,
without worrying about the details of how the problem is solved.
Expand All @@ -22,7 +22,7 @@ For example, the following code denoises an image using simple sparse gradient a
import matplotlib.pyplot as plt
# Generate data.
I = scipy.misc.ascent()
I = scipy.datasets.ascent()
np.random.seed(1)
b = I + 10*np.random.randn(*I.shape)
Expand Down
2 changes: 1 addition & 1 deletion proximal/examples/basic_denoise.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from proximal.utils.utils import Impl

# Generate data.
I = scipy.misc.ascent()
I = scipy.datasets.ascent()
np.random.seed(1)
b = I + 10 * np.random.randn(*I.shape)

Expand Down
4 changes: 2 additions & 2 deletions proximal/examples/test_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

# Error
print('Maximum error {0}'.format(
np.linalg.norm(output_ref.ravel() - output.ravel(), np.Inf)))
np.linalg.norm(output_ref.ravel() - output.ravel(), np.inf)))

plt.subplot(223)
plt.imshow(output_ref, interpolation="nearest", clim=(0.0, 1.0), cmap='gray')
Expand All @@ -73,6 +73,6 @@

# Error
print('Maximum error {0}'.format(
np.linalg.norm(output_ref.ravel() - output_trans.ravel(), np.Inf)))
np.linalg.norm(output_ref.ravel() - output_trans.ravel(), np.inf)))

plt.show()
4 changes: 2 additions & 2 deletions proximal/examples/test_warp.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
plt.title('Output from halide')

# Error
delta = np.linalg.norm(output_ref.ravel() - output.ravel(), np.Inf)
delta = np.linalg.norm(output_ref.ravel() - output.ravel(), np.inf)
norm = np.amax((output_ref.max(), output.max()))
print('Relative error {0}'.format(delta / norm))

Expand Down Expand Up @@ -111,7 +111,7 @@
plt.title('Output trans from CV2')

# Error
delta = np.linalg.norm(output_ref_trans.ravel() - output_trans.ravel(), np.Inf)
delta = np.linalg.norm(output_ref_trans.ravel() - output_trans.ravel(), np.inf)
norm = np.amax((output_ref_trans.max(), output_trans.max()))
print('Relative error trans {0}'.format(delta / norm))
plt.show()
2 changes: 1 addition & 1 deletion proximal/tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def assertItemsAlmostEqual(self,

assert a.shape == b.shape

norm_infinity_b = np.linalg.norm(b.ravel(), np.Inf)
norm_infinity_b = np.linalg.norm(b.ravel(), np.inf)

if norm_infinity_b == 0:
# b is a zero matrix / vector
Expand Down
9 changes: 4 additions & 5 deletions proximal/tests/test_halide.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import numpy as np
from scipy.misc import ascent
from scipy.datasets import ascent
from scipy.signal import convolve2d

import proximal as px
Expand All @@ -17,7 +16,7 @@ def test_compile(self):
"""Test compilation
"""
Halide('A_conv', reconfigure=True, recompile=True, verbose=False)


def _get_testvector(self):
# Load image
Expand All @@ -28,7 +27,7 @@ def _get_testvector(self):
K /= K.size

return np_img, K


def test_run(self):
""" Test running
Expand All @@ -43,7 +42,7 @@ def test_run(self):
output_ref = convolve2d(np_img, K, mode='same', boundary='wrap')

self.assertItemsAlmostEqual(output, output_ref)

def _test_algo(self, algo, check_convergence=True):
""" Ensure all internal buffers of the algortihms are Fortran-style ordered.
"""
Expand Down
2 changes: 1 addition & 1 deletion proximal/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Imports
import numpy as np
from scipy.misc import ascent, face
from scipy.datasets import ascent, face
import cv2
import os
from numpy.fft import fftn, ifftn, fft2, ifft2
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ test = [
"pytest",
"pytest-cov",
"ruff",

# Required by scipy.datasets.accent()
"pooch",
]

[project.urls]
Expand Down

0 comments on commit d79159d

Please sign in to comment.