Skip to content

Commit

Permalink
Update build test and integration testing suite (#1324)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp authored Sep 18, 2023
1 parent 32418f9 commit 0b518c6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ concurrency:
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
build:
import:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
Expand Down
7 changes: 4 additions & 3 deletions deepxde/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import random
import sys

import numpy as np

Expand Down Expand Up @@ -52,7 +53,7 @@
elif backend_name == "jax":
xla_jit = True
if xla_jit:
print("Enable just-in-time compilation with XLA.\n")
print("Enable just-in-time compilation with XLA.\n", file=sys.stderr, flush=True)


def default_float():
Expand Down Expand Up @@ -179,9 +180,9 @@ def enable_xla_jit(mode=True):
global xla_jit
xla_jit = mode
if xla_jit:
print("Enable just-in-time compilation with XLA.\n")
print("Enable just-in-time compilation with XLA.\n", file=sys.stderr, flush=True)
else:
print("Disable just-in-time compilation with XLA.\n")
print("Disable just-in-time compilation with XLA.\n", file=sys.stderr, flush=True)


def disable_xla_jit():
Expand Down
6 changes: 3 additions & 3 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Directories where to look for *.py example scripts
EXAMPLE_DIRECTORIES := function pinn_forward pinn_inverse
EXAMPLE_DIRECTORIES := function operator pinn_forward pinn_inverse

# Environment variables for the scripts
# Note that the PYTHONPATH is relative to each example subdirectory, not the
Expand All @@ -24,12 +24,12 @@ run_all_examples: $(example_files)
@echo -----------------------------------------------------
@echo $@
@echo -----------------------------------------------------
@cd $(dir $@) && $(DDE_TEST_ENV) python ../sample_to_test.py $(notdir $@) | PYTHONPATH=../.. python -
@cd $(dir $@) && $(DDE_TEST_ENV) python3 ../sample_to_test.py $(notdir $@) | PYTHONPATH=../.. python3 -
@echo
@echo
@cd ..


# Clean all data files in example directories
clean: $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.dat)) $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.npz))
clean: $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.dat)) $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.npz)) $(foreach dir,$(EXAMPLE_DIRECTORIES),$(wildcard $(dir)/*.pdf))
rm $^
49 changes: 44 additions & 5 deletions examples/sample_to_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
import re
import sys

import deepxde as dde

EPOCHS_RE = re.compile(r"^(.*)epochs\s*=\s*(\d+)(.*)$", re.DOTALL)

ITERATIONS_RE = re.compile(r"^(.*)iterations\s*=\s*(\d+)(.*)$", re.DOTALL)

PROLOG = """
from deepxde.optimizers import set_LBFGS_options
Expand All @@ -24,9 +26,9 @@

def transform(line, file_name):
"""Apply transformations to line."""
m = re.match(EPOCHS_RE, line)
m = re.match(ITERATIONS_RE, line)
if m is not None:
line = m.expand(r"\1epochs=1\3")
line = m.expand(r"\1iterations=1\3")

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

print(PROLOG)
with open(file_name, "r") as input:
for line in input:
sys.stdout.write(transform(line, file_name))
if file_name not in (
# this example uses skopt which is not maintained
# and uses deprecated numpy API
"Allen_Cahn.py",
# the below examples have different code for different
# backends
"Beltrami_flow.py",
"Helmholtz_Dirichlet_2d_HPO.py",
"Laplace_disk.py",
"Lotka_Volterra.py",
"Poisson_Dirichlet_1d.py",
"Poisson_periodic_1d.py",
"diffusion_1d_exactBC.py",
"diffusion_1d_resample.py",
"diffusion_1d.py",
"diffusion_reaction.py",
"fractional_diffusion_1d.py",
"fractional_Poisson_1d.py",
"fractional_Poisson_2d.py",
"fractional_Poisson_3d.py",
"ide.py",
"diffusion_1d_inverse.py",
"fractional_Poisson_1d_inverse.py",
"fractional_Poisson_2d_inverse.py",
"Poisson_Lshape.py",
"ode_system.py",
"Lorenz_inverse.py",
# gives error with tensorflow.compat.v1
"Volterra_IDE.py",
# the dataset is large and not included in repo
"antiderivative_unaligned.py",
"antiderivative_aligned.py",
):
lines = input.readlines()
if dde.backend.get_preferred_backend() in lines[0].replace(",", "").replace(
'"""', ""
).replace("\n", "").split(" "):
for line in lines:
sys.stdout.write(transform(line, file_name))

0 comments on commit 0b518c6

Please sign in to comment.