Skip to content

Commit

Permalink
Merge pull request #155 from aai-institute/fix/deepxde-device-test
Browse files Browse the repository at this point in the history
Fix: Test failing when using DeepXDE
  • Loading branch information
Samuel Burbulla authored Aug 20, 2024
2 parents 9f08539 + c2c938e commit 8e16597
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/pde/deepxde_example.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import torch
import deepxde as dde
import matplotlib.pyplot as plt
import numpy as np

Expand All @@ -12,6 +11,10 @@ def deepxde_example():
https://deepxde.readthedocs.io/en/latest/demos/operator/poisson.1d.pideeponet.html
"""

# deepxde sets the device context internally, which can conflict with the testing setup, when dealing with different
# devices (i.e. GPU and CPU). To ensure that the correct device is set the dependency is isolated.
import deepxde as dde # noqa

# Poisson equation: -u_xx = f
def equation(x, y, f):
dy_xx = dde.grad.hessian(y, x)
Expand Down
5 changes: 4 additions & 1 deletion tests/pde/test_pideeponet.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import torch
import deepxde as dde
import matplotlib.pyplot as plt
import numpy as np
import continuiti as cti
Expand All @@ -15,6 +14,10 @@ def test_pideeponet():
https://deepxde.readthedocs.io/en/latest/demos/operator/poisson.1d.pideeponet.html
"""

# deepxde sets the device context internally, which can conflict with the testing setup, when dealing with different
# devices (i.e. GPU and CPU). To ensure that the correct device is set the dependency is isolated.
import deepxde as dde # noqa

# Poisson equation: -v_xx = f
mse = torch.nn.MSELoss()

Expand Down

0 comments on commit 8e16597

Please sign in to comment.