Skip to content

Commit 0b518c6

Browse files
authored
Update build test and integration testing suite (#1324)
1 parent 32418f9 commit 0b518c6

File tree

4 files changed

+53
-13
lines changed

4 files changed

+53
-13
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ concurrency:
1414
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
1515

1616
jobs:
17-
build:
17+
import:
1818
runs-on: ${{ matrix.os }}
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
python-version: ["3.8", "3.9", "3.10"]
22+
python-version: ["3.8", "3.9", "3.10", "3.11"]
2323
os: [ubuntu-latest, macos-latest, windows-latest]
2424

2525
steps:

deepxde/config.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import random
3+
import sys
34

45
import numpy as np
56

@@ -52,7 +53,7 @@
5253
elif backend_name == "jax":
5354
xla_jit = True
5455
if xla_jit:
55-
print("Enable just-in-time compilation with XLA.\n")
56+
print("Enable just-in-time compilation with XLA.\n", file=sys.stderr, flush=True)
5657

5758

5859
def default_float():
@@ -179,9 +180,9 @@ def enable_xla_jit(mode=True):
179180
global xla_jit
180181
xla_jit = mode
181182
if xla_jit:
182-
print("Enable just-in-time compilation with XLA.\n")
183+
print("Enable just-in-time compilation with XLA.\n", file=sys.stderr, flush=True)
183184
else:
184-
print("Disable just-in-time compilation with XLA.\n")
185+
print("Disable just-in-time compilation with XLA.\n", file=sys.stderr, flush=True)
185186

186187

187188
def disable_xla_jit():

examples/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Directories where to look for *.py example scripts
2-
EXAMPLE_DIRECTORIES := function pinn_forward pinn_inverse
2+
EXAMPLE_DIRECTORIES := function operator pinn_forward pinn_inverse
33

44
# Environment variables for the scripts
55
# Note that the PYTHONPATH is relative to each example subdirectory, not the
@@ -24,12 +24,12 @@ run_all_examples: $(example_files)
2424
@echo -----------------------------------------------------
2525
@echo $@
2626
@echo -----------------------------------------------------
27-
@cd $(dir $@) && $(DDE_TEST_ENV) python ../sample_to_test.py $(notdir $@) | PYTHONPATH=../.. python -
27+
@cd $(dir $@) && $(DDE_TEST_ENV) python3 ../sample_to_test.py $(notdir $@) | PYTHONPATH=../.. python3 -
2828
@echo
2929
@echo
3030
@cd ..
3131

3232

3333
# Clean all data files in example directories
34-
clean: $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.dat)) $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.npz))
34+
clean: $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.dat)) $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.npz)) $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.pdf))
3535
rm $^

examples/sample_to_test.py

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
import re
1111
import sys
1212

13+
import deepxde as dde
1314

14-
EPOCHS_RE = re.compile(r"^(.*)epochs\s*=\s*(\d+)(.*)$", re.DOTALL)
15+
16+
ITERATIONS_RE = re.compile(r"^(.*)iterations\s*=\s*(\d+)(.*)$", re.DOTALL)
1517

1618
PROLOG = """
1719
from deepxde.optimizers import set_LBFGS_options
@@ -24,9 +26,9 @@
2426

2527
def transform(line, file_name):
2628
"""Apply transformations to line."""
27-
m = re.match(EPOCHS_RE, line)
29+
m = re.match(ITERATIONS_RE, line)
2830
if m is not None:
29-
line = m.expand(r"\1epochs=1\3")
31+
line = m.expand(r"\1iterations=1\3")
3032

3133
# Burgers_RAR.py has an additional convergence loop: force 1 single pass
3234
if file_name == "Burgers_RAR.py" and line.startswith("while"):
@@ -45,5 +47,42 @@ def transform(line, file_name):
4547

4648
print(PROLOG)
4749
with open(file_name, "r") as input:
48-
for line in input:
49-
sys.stdout.write(transform(line, file_name))
50+
if file_name not in (
51+
# this example uses skopt which is not maintained
52+
# and uses deprecated numpy API
53+
"Allen_Cahn.py",
54+
# the below examples have different code for different
55+
# backends
56+
"Beltrami_flow.py",
57+
"Helmholtz_Dirichlet_2d_HPO.py",
58+
"Laplace_disk.py",
59+
"Lotka_Volterra.py",
60+
"Poisson_Dirichlet_1d.py",
61+
"Poisson_periodic_1d.py",
62+
"diffusion_1d_exactBC.py",
63+
"diffusion_1d_resample.py",
64+
"diffusion_1d.py",
65+
"diffusion_reaction.py",
66+
"fractional_diffusion_1d.py",
67+
"fractional_Poisson_1d.py",
68+
"fractional_Poisson_2d.py",
69+
"fractional_Poisson_3d.py",
70+
"ide.py",
71+
"diffusion_1d_inverse.py",
72+
"fractional_Poisson_1d_inverse.py",
73+
"fractional_Poisson_2d_inverse.py",
74+
"Poisson_Lshape.py",
75+
"ode_system.py",
76+
"Lorenz_inverse.py",
77+
# gives error with tensorflow.compat.v1
78+
"Volterra_IDE.py",
79+
# the dataset is large and not included in repo
80+
"antiderivative_unaligned.py",
81+
"antiderivative_aligned.py",
82+
):
83+
lines = input.readlines()
84+
if dde.backend.get_preferred_backend() in lines[0].replace(",", "").replace(
85+
'"""', ""
86+
).replace("\n", "").split(" "):
87+
for line in lines:
88+
sys.stdout.write(transform(line, file_name))

0 commit comments

Comments
 (0)