Skip to content

Commit

Permalink
cant have codecov going down
Browse files Browse the repository at this point in the history
  • Loading branch information
bnb32 committed Nov 20, 2023
1 parent ef61e16 commit c422acf
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import pytest
import tensorflow as tf

from phygnn.layers.custom_layers import (SkipConnection,
SpatioTemporalExpansion,
FlattenAxis,
ExpandDims,
TileLayer,
GaussianNoiseAxis)
from phygnn.layers.handlers import Layers, HiddenLayers
from phygnn.layers.custom_layers import (
ExpandDims,
FlattenAxis,
GaussianNoiseAxis,
SkipConnection,
SpatioTemporalExpansion,
TileLayer,
)
from phygnn.layers.handlers import HiddenLayers, Layers


@pytest.mark.parametrize(
Expand Down Expand Up @@ -208,7 +210,7 @@ def test_temporal_depth_to_time(t_mult, s_mult, t_roll):
n_filters = 2 * s_mult**2 * t_mult
shape = (1, 4, 4, 3, n_filters)
n = np.product(shape)
x = np.arange(n).reshape((shape))
x = np.arange(n).reshape(shape)
y = layer(x)
assert y.shape[0] == x.shape[0]
assert y.shape[1] == s_mult * x.shape[1]
Expand Down Expand Up @@ -387,3 +389,37 @@ def test_squeeze_excite_3d():
x = layer(x)
with pytest.raises(tf.errors.InvalidArgumentError):
tf.assert_equal(x_in, x)


def test_fno_2d():
"""Test the FNO layer with 2D data (4D tensor input)"""
hidden_layers = [
{'class': 'FNO', 'filters': 8, 'sparsity_threshold': 0.01,
'activation': 'relu'}]
layers = HiddenLayers(hidden_layers)
assert len(layers.layers) == 1

x = np.random.normal(0, 1, size=(1, 4, 4, 3))

for layer in layers:
x_in = x
x = layer(x)
with pytest.raises(tf.errors.InvalidArgumentError):
tf.assert_equal(x_in, x)


def test_fno_3d():
"""Test the FNO layer with 3D data (5D tensor input)"""
hidden_layers = [
{'class': 'FNO', 'filters': 8, 'sparsity_threshold': 0.01,
'activation': 'relu'}]
layers = HiddenLayers(hidden_layers)
assert len(layers.layers) == 1

x = np.random.normal(0, 1, size=(1, 4, 4, 6, 3))

for layer in layers:
x_in = x
x = layer(x)
with pytest.raises(tf.errors.InvalidArgumentError):
tf.assert_equal(x_in, x)

0 comments on commit c422acf

Please sign in to comment.