Skip to content

Commit

Permalink
Merge pull request #37 from mansakrishna23/main
Browse files Browse the repository at this point in the history
removing tests for now
  • Loading branch information
mansakrishna23 authored Jul 6, 2024
2 parents 452c48e + 5855787 commit 6f64e09
Showing 1 changed file with 1 addition and 105 deletions.
106 changes: 1 addition & 105 deletions tests/test_pinn.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pinnicle as pinn
import numpy as np
import deepxde as dde
from pinnicle.utils import data_misfit, plot_nn, plot_similarity, plot_residuals, tripcolor_similarity, tripcolor_residuals
from pinnicle.utils import data_misfit, plot_nn
import pytest

dde.config.set_default_float('float64')
Expand Down Expand Up @@ -216,107 +216,3 @@ def test_plot(tmp_path):
assert Y.shape == (10,10)
assert len(im_data) == 5
assert im_data['u'].shape == (10,10)

def test_similarity(tmp_path):
hp["save_path"] = str(tmp_path)
hp["is_save"] = False
issm["data_size"] = {"u":100, "v":100, "s":100, "H":100, "C":None}
hp["data"] = {"ISSM": issm}
experiment = pinn.PINN(params=hp)
experiment.compile()
# plot_similarity(pinn, feature_name, sim='MAE', cmap='jet', scale=1, cols=[0, 1, 2])
# default
fig, axs = plot_similarity(experiment, feature_name='s')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = plot_similarity(experiment, feature_name='H', cols=[0])
assert (fig is not None) and (np.size(axs) == 1)
fig, axs = plot_similarity(experiment, feature_name="u", sim="mae", cols=[2])
assert (fig is not None) and (np.size(axs) == 1)
fig, axs = plot_similarity(experiment, feature_name="v", sim="Mse", cols=[2, 1])
assert (fig is not None) and (np.size(axs) == 2)
fig, axs = plot_similarity(experiment, feature_name="C", sim="rmse", cols=[0, 2, 1])
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = plot_similarity(experiment, feature_name="H", sim="SIMPLE")
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = plot_similarity(experiment, feature_name=['u', 'v'], feat_title='vel')
assert (fig is not None) and (np.size(axs) == 3)
with pytest.raises(TypeError):
fig, axs = plot_similarity(experiment, feature_name=['u', 'v'])

def test_residuals(tmp_path):
hp["save_path"] = str(tmp_path)
hp["is_save"] = False
issm["data_size"] = {"u":100, "v":100, "s":100, "H":100, "C":None}
hp["data"] = {"ISSM": issm}
experiment = pinn.PINN(params=hp)
experiment.compile()
# plot_residuals(pinn, cmap='RdBu', cbar_bins=10, cbar_limits=[-5e3, 5e3])
# default
fig, axs = plot_residuals(experiment)
assert (fig is not None) and (np.size(axs)==2)
fig, axs = plot_residuals(experiment, cmap='jet')
assert (fig is not None) and (np.size(axs)==2)
fig, axs = plot_residuals(experiment, cbar_bins=5)
assert (fig is not None) and (np.size(axs)==2)
fig, axs = plot_residuals(experiment, cbar_limits=[-1e4, 1e4])
assert (fig is not None) and (np.size(axs)==2)
fig, axs = plot_residuals(experiment, cmap='rainbow', cbar_bins=20, cbar_limits=[-7.5e3, 7.5e3])
assert (fig is not None) and (np.size(axs)==2)

# add more physics, test again
MC = {}
MC["scalar_variables"] = {"B":1.26802073401e+08}
hp["equations"] = {"SSA":SSA, 'MC':MC}
experiment = pinn.PINN(params=hp)
experiment.compile()

fig, axs = plot_residuals(experiment)
assert (fig is not None) and (np.size(axs)==3)

def test_trisimilarity(tmp_path):
hp["equations"] = {"SSA":SSA}
hp["save_path"] = str(tmp_path)
hp["is_save"] = False
issm["data_size"] = {"u":100, "v":100, "s":100, "H":100, "C":None}
hp["data"] = {"ISSM": issm}
experiment = pinn.PINN(params=hp)
experiment.compile()
# plot_similarity(pinn, feature_name, sim='MAE', cmap='jet', scale=1, cols=[0, 1, 2])
# default
fig, axs = tripcolor_similarity(experiment, feature_name='s')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name='s', sim='mae')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name='s', sim='SIMPLE')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name='s', cmap='terrain')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name='s', sim='Rmse')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name='s', sim='mse')
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name='s', colorbar_bins=5)
assert (fig is not None) and (np.size(axs) == 3)
fig, axs = tripcolor_similarity(experiment, feature_name=['u', 'v'], feat_title='vel', scale=experiment.model_data.yts)
assert (fig is not None) and (np.size(axs) == 3)
with pytest.raises(TypeError):
fig, axs = tripcolor_similarity(experiment, feature_name=['u', 'v'])

def test_triresiduals(tmp_path):
hp["equations"] = {"SSA":SSA}
hp["save_path"] = str(tmp_path)
hp["is_save"] = False
issm["data_size"] = {"u":100, "v":100, "s":100, "H":100, "C":None}
hp["data"] = {"ISSM": issm}
experiment = pinn.PINN(params=hp)
experiment.compile()

fig, axs = tripcolor_residuals(experiment)
assert (fig is not None) and (np.size(axs)==2)
fig, axs = tripcolor_residuals(experiment, cmap='jet')
assert (fig is not None) and (np.size(axs)==2)
fig, axs = tripcolor_residuals(experiment, colorbar_bins=5)
assert (fig is not None) and (np.size(axs)==2)
fig, axs = tripcolor_residuals(experiment, cbar_limits=[-7e3, 7e3])
assert (fig is not None) and (np.size(axs)==2)

0 comments on commit 6f64e09

Please sign in to comment.