Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion copulas/bivariate/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def partial_derivative_scalar(self, U, V):
self.check_fit()

X = np.column_stack((U, V))
return self.partial_derivative(X)
return self.partial_derivative(X).item()

def set_random_state(self, random_state):
"""Set the random state.
Expand Down
2 changes: 1 addition & 1 deletion copulas/bivariate/frank.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ def _tau_to_theta(self, alpha):
def debye(t):
return t / (np.exp(t) - 1)

debye_value = integrate.quad(debye, EPSILON, alpha)[0] / alpha
debye_value = integrate.quad(debye, EPSILON, alpha.item())[0] / alpha
return 4 * (debye_value - 1) / alpha + 1 - self.tau
4 changes: 2 additions & 2 deletions copulas/multivariate/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def get_likelihood(self, uni_matrix):
for i in range(num_edge):
edge = self.edges[i]
value, left_u, right_u = edge.get_likelihood(uni_matrix)
new_uni_matrix[edge.L, edge.R] = left_u
new_uni_matrix[edge.R, edge.L] = right_u
new_uni_matrix[edge.L, edge.R] = left_u.item()
new_uni_matrix[edge.R, edge.L] = right_u.item()
values[0, i] = np.log(value)

return np.sum(values), new_uni_matrix
Expand Down
2 changes: 1 addition & 1 deletion copulas/multivariate/vine.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ def _sample_row(self):

new_x = self.ppfs[current](np.array([tmp]))

sampled[current] = new_x
sampled[current] = new_x.item()

for s in neighbors:
if s not in visited:
Expand Down
5 changes: 5 additions & 0 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
'<=': operator.le,
'==': operator.eq,
}
EXTERNAL_DEPENDENCY_CAPS = {
'scikit-learn': '1.8.0'
}


if not hasattr(inspect, 'getargspec'):
Expand Down Expand Up @@ -110,6 +113,8 @@ def install_minimum(c):
if minimum_versions:
install_deps = ' '.join(minimum_versions)
c.run(f'python -m pip install {install_deps}')
for dep, cap in EXTERNAL_DEPENDENCY_CAPS.items():
c.run(f'python -m pip install "{dep}<{cap}"')


@task
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/bivariate/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ def test_partial_derivative_scalar(self, derivative_mock):
# Setup
instance = Bivariate(copula_type=CopulaTypes.CLAYTON)
instance.fit(self.X)
derivative_mock.return_value = np.array([1.0])

# Run
result = instance.partial_derivative_scalar(0.5, 0.1)

# Check
assert result == derivative_mock.return_value
assert result == 1.0

expected_args = ((np.array([[0.5, 0.1]]), 0), {})
assert len(expected_args) == len(derivative_mock.call_args)
Expand Down