Codacy Small Bug Fixes:

- cleaned up imports
- cleaned up some code
- added docstrings
This commit is contained in:
SpartaKushK
2023-07-25 16:43:45 +02:00
committed by Nicola Demo
parent bd88e24174
commit 625a77c0d5
13 changed files with 132 additions and 118 deletions

View File

@@ -1,3 +1,4 @@
""" Implementation of adaptive linear layer. """
import torch
from torch.nn.parameter import Parameter

View File

@@ -1,7 +1,7 @@
import torch
from torch.nn.parameter import Parameter
class AdaptiveReLU(torch.nn.Module):
class AdaptiveReLU(torch.nn.Module, Parameter):
'''
Implementation of soft exponential activation.
Shape:

View File

@@ -1,4 +1,3 @@
""" """
from torch.utils.data import Dataset, DataLoader
import functools

View File

@@ -82,7 +82,8 @@ class CartesianDomain(Location):
pts = chebyshev_roots(n).mul(.5).add(.5).reshape(-1, 1)
elif mode == 'grid':
pts = torch.linspace(0, 1, n).reshape(-1, 1)
elif mode == 'lh' or mode == 'latin':
# elif mode == 'lh' or mode == 'latin':
elif mode in ['lh', 'latin']:
pts = torch_lhs(n, dim)
pts *= bounds[:, 1] - bounds[:, 0]

View File

@@ -1,3 +1,4 @@
""" Integral class for continous convolution"""
import torch

View File

@@ -4,6 +4,8 @@ from ..utils import check_consistency
class Network(torch.nn.Module):
""" Network class with starndard forward method
and possibility to pass extra features."""
def __init__(self, model, extra_features=None):
super().__init__()

View File

@@ -1,6 +1,5 @@
""" Module for plotting. """
import matplotlib.pyplot as plt
import numpy as np
import torch
from pina import LabelTensor
@@ -43,7 +42,8 @@ class Plotter:
proj = '3d' if len(variables) == 3 else None
ax = fig.add_subplot(projection=proj)
for location in solver.problem.input_pts:
coords = solver.problem.input_pts[location].extract(variables).T.detach()
coords = solver.problem.input_pts[location].extract(
variables).T.detach()
if coords.shape[0] == 1: # 1D samples
ax.plot(coords[0], torch.zeros(coords[0].shape), '.',
label=location)