Skip to content

Commit 6a081b5

Browse files
authored
Merge branch 'CUQI-DTU:main' into RegularizedGaussian-Additional-Constraints
2 parents a3da372 + 61f29c7 commit 6a081b5

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
matrix:
1515
os: [ubuntu-latest] # Add windows-latest, macos-latest to test on multiple OS
16-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
16+
python-version: ["3.9", "3.10", "3.11", "3.12"]
1717
steps:
1818
- uses: actions/checkout@v3
1919
- name: Set up Python ${{ matrix.python-version }}

cuqi/distribution/_beta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def logpdf(self, x):
4848

4949
# Check bounds
5050
if np.any(x<=0) or np.any(x>=1) or np.any(self.alpha<=0) or np.any(self.beta<=0):
51-
return -np.Inf
51+
return -np.inf
5252

5353
# Compute logpdf
5454
return np.sum(sps.beta.logpdf(x, a=self.alpha, b=self.beta))

cuqi/distribution/_cauchy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ def _is_out_of_bounds(self, x):
7575
def logpdf(self, x):
7676

7777
if self._is_out_of_bounds(x):
78-
return -np.Inf
78+
return -np.inf
7979

8080
return np.sum(-np.log(np.pi*self.scale*(1+((x-self.location)/self.scale)**2)))
8181

8282
def cdf(self, x):
8383

8484
if self._is_out_of_bounds(x):
85-
return -np.Inf
85+
return -np.inf
8686

8787
return np.sum(sps.cauchy.cdf(x, loc=self.location, scale=self.scale))
8888

cuqi/distribution/_truncated_normal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TruncatedNormal(Distribution):
3737
p = cuqi.distribution.TruncatedNormal(mean=0, std=1, low=-2, high=2)
3838
samples = p.sample(5000)
3939
"""
40-
def __init__(self, mean=None, std=None, low=-np.Inf, high=np.Inf, is_symmetric=False, **kwargs):
40+
def __init__(self, mean=None, std=None, low=-np.inf, high=np.inf, is_symmetric=False, **kwargs):
4141
# Init from abstract distribution class
4242
super().__init__(is_symmetric=is_symmetric, **kwargs)
4343

@@ -97,7 +97,7 @@ def logpdf(self, x):
9797
# the unnormalized logpdf
9898
# check if x falls in the range between np.array a and b
9999
if np.any(x < self.low) or np.any(x > self.high):
100-
return -np.Inf
100+
return -np.inf
101101
else:
102102
return self._normal.logpdf(x)
103103

cuqi/geometry/_geometry.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,15 @@ def __repr__(self) -> str:
228228
if self.par_shape == self.fun_shape:
229229
return "{}[{}]".format(self.__class__.__name__,
230230
self.par_shape if len(self.par_shape) != 1 else self.par_shape[0])
231-
return "{}[{}: {}]".format(self.__class__.__name__,
232-
self.par_shape if len(self.par_shape) != 1 else self.par_shape[0],
233-
self.fun_shape if len(self.fun_shape) != 1 else self.fun_shape[0])
231+
return "{}[{}: {}]".format(
232+
self.__class__.__name__,
233+
self.par_shape if len(self.par_shape) != 1 else self.par_shape[0],
234+
(
235+
self.fun_shape
236+
if (self.fun_shape is None or len(self.fun_shape) != 1)
237+
else self.fun_shape[0]
238+
),
239+
)
234240

235241
def _all_values_equal(self, obj):
236242
"""Returns true of all values of the object and self are equal"""

demos/demo38_truncated_normal.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
p = cuqi.distribution.TruncatedNormal(
1313
mean=np.array([0, 0]),
1414
std=np.array([1, 1]),
15-
low=np.array([0, -np.Inf]),
16-
high=np.array([np.Inf, 0]))
15+
low=np.array([0, -np.inf]),
16+
high=np.array([np.inf, 0]))
1717

1818
plt.figure()
1919
plot_2D_density(p, -5, 5, -5, 5)
@@ -40,8 +40,8 @@
4040
x = cuqi.distribution.TruncatedNormal(
4141
mean=np.array([0, 0]),
4242
std=np.array([1, 1]),
43-
low=np.array([0, -np.Inf]),
44-
high=np.array([np.Inf, 0]))
43+
low=np.array([0, -np.inf]),
44+
high=np.array([np.inf, 0]))
4545
# the data distribution
4646
b = cuqi.distribution.Gaussian(A@x, 0.1)
4747

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ maintainers = [
1212
{name = "Chao Zhang", email = "[email protected]"}
1313
]
1414
readme = "README.md"
15-
requires-python = ">=3.8"
15+
requires-python = ">=3.9"
1616
license = {file = "LICENSE"}
1717
dynamic = ["dependencies", "version"]
1818

0 commit comments

Comments
 (0)