Correct codacy warnings
This commit is contained in:
committed by
Nicola Demo
parent
1bc1b3a580
commit
3e30450e9a
@@ -27,7 +27,7 @@ class BaseDataset(Dataset):
|
||||
if not hasattr(cls, '__slots__'):
|
||||
raise TypeError(
|
||||
'Something is wrong, __slots__ must be defined in subclasses.')
|
||||
return super(BaseDataset, cls).__new__(cls)
|
||||
return object.__new__(cls)
|
||||
|
||||
def __init__(self, problem, device):
|
||||
""""
|
||||
|
||||
@@ -26,7 +26,7 @@ class PinaDataModule(LightningDataModule):
|
||||
eval_size=.1,
|
||||
batch_size=None,
|
||||
shuffle=True,
|
||||
datasets = None):
|
||||
datasets=None):
|
||||
"""
|
||||
Initialize the object, creating dataset based on input problem
|
||||
:param AbstractProblem problem: PINA problem
|
||||
@@ -38,9 +38,11 @@ class PinaDataModule(LightningDataModule):
|
||||
:param datasets: list of datasets objects
|
||||
"""
|
||||
super().__init__()
|
||||
dataset_classes = [SupervisedDataset, UnsupervisedDataset, SamplePointDataset]
|
||||
dataset_classes = [SupervisedDataset, UnsupervisedDataset,
|
||||
SamplePointDataset]
|
||||
if datasets is None:
|
||||
self.datasets = [DatasetClass(problem, device) for DatasetClass in dataset_classes]
|
||||
self.datasets = [DatasetClass(problem, device) for DatasetClass in
|
||||
dataset_classes]
|
||||
else:
|
||||
self.datasets = datasets
|
||||
|
||||
@@ -100,8 +102,6 @@ class PinaDataModule(LightningDataModule):
|
||||
for key, value in dataset.condition_names.items()
|
||||
}
|
||||
|
||||
|
||||
|
||||
def train_dataloader(self):
|
||||
"""
|
||||
Return the training dataloader for the dataset
|
||||
@@ -158,11 +158,13 @@ class PinaDataModule(LightningDataModule):
|
||||
if seed is not None:
|
||||
generator = torch.Generator()
|
||||
generator.manual_seed(seed)
|
||||
indices = torch.randperm(sum(lengths), generator=generator).tolist()
|
||||
indices = torch.randperm(sum(lengths),
|
||||
generator=generator).tolist()
|
||||
else:
|
||||
indices = torch.arange(sum(lengths)).tolist()
|
||||
else:
|
||||
indices = torch.arange(0, sum(lengths), 1, dtype=torch.uint8).tolist()
|
||||
indices = torch.arange(0, sum(lengths), 1,
|
||||
dtype=torch.uint8).tolist()
|
||||
offsets = [
|
||||
sum(lengths[:i]) if i > 0 else 0 for i in range(len(lengths))
|
||||
]
|
||||
|
||||
@@ -5,6 +5,9 @@ from .pina_subset import PinaSubset
|
||||
|
||||
|
||||
class Batch:
|
||||
"""
|
||||
Implementation of the Batch class used during training to perform SGD optimization.
|
||||
"""
|
||||
|
||||
def __init__(self, dataset_dict, idx_dict):
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class PinaDataLoader:
|
||||
Create batches according to the batch_size provided in input.
|
||||
"""
|
||||
self.batches = []
|
||||
n_elements = sum([len(v) for v in self.dataset_dict.values()])
|
||||
n_elements = sum(len(v) for v in self.dataset_dict.values())
|
||||
if batch_size is None:
|
||||
batch_size = n_elements
|
||||
indexes_dict = {}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
"""
|
||||
Module for PinaSubset class
|
||||
"""
|
||||
|
||||
|
||||
class PinaSubset:
|
||||
"""
|
||||
TODO
|
||||
|
||||
@@ -6,8 +6,9 @@ from .base_dataset import BaseDataset
|
||||
|
||||
class UnsupervisedDataset(BaseDataset):
|
||||
"""
|
||||
This class extend BaseDataset class to handle unsupervised dataset,
|
||||
composed of input points and, optionally, conditional variables
|
||||
This class extend BaseDataset class to handle
|
||||
unsupervised dataset,composed of input points
|
||||
and, optionally, conditional variables
|
||||
"""
|
||||
data_type = 'unsupervised'
|
||||
__slots__ = ['input_points', 'conditional_variables']
|
||||
|
||||
Reference in New Issue
Block a user