Skip to content

Commit

Permalink
small fix: removed invalid use of params.pool_size
Browse files Browse the repository at this point in the history
  • Loading branch information
LonnekeScheffer committed Apr 29, 2024
1 parent c492ef7 commit 4f286cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions docs/source/developer_docs/example_code/SillyEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def encode(self, dataset, params: EncoderParams) -> Dataset:
np.random.seed(self.random_seed)

# Generate the design matrix from the sequence dataset
encoded_examples = self._get_encoded_examples(dataset, params)
encoded_examples = self._get_encoded_examples(dataset)

# EncoderHelper contains some utility functions, including this function for encoding the labels
labels = EncoderHelper.encode_dataset_labels(dataset, params.label_config, params.encode_labels)
Expand All @@ -87,18 +87,18 @@ def encode(self, dataset, params: EncoderParams) -> Dataset:
return self._construct_encoded_dataset(dataset, encoded_data)


def _get_encoded_examples(self, dataset: Dataset, params: EncoderParams) -> np.array:
def _get_encoded_examples(self, dataset: Dataset) -> np.array:
if isinstance(dataset, SequenceDataset):
return self._get_encoded_sequences(dataset, params)
return self._get_encoded_sequences(dataset)
elif isinstance(dataset, ReceptorDataset):
return self._get_encoded_receptors(dataset, params)
return self._get_encoded_receptors(dataset)
elif isinstance(dataset, RepertoireDataset):
return self._get_encoded_repertoires(dataset, params)
return self._get_encoded_repertoires(dataset)

def _get_encoded_sequences(self, dataset: SequenceDataset, params: EncoderParams) -> np.array:
def _get_encoded_sequences(self, dataset: SequenceDataset) -> np.array:
encoded_sequences = []

for sequence in dataset.get_data(params.pool_size):
for sequence in dataset.get_data():
# Each sequence is a ReceptorSequence object.
# Different properties of the sequence can be retrieved here, examples:
identifier = sequence.get_id()
Expand All @@ -112,10 +112,10 @@ def _get_encoded_sequences(self, dataset: SequenceDataset, params: EncoderParams

return np.array(encoded_sequences)

def _get_encoded_receptors(self, dataset: ReceptorDataset, params: EncoderParams) -> np.array:
def _get_encoded_receptors(self, dataset: ReceptorDataset) -> np.array:
encoded_receptors = []

for receptor in dataset.get_data(params.pool_size):
for receptor in dataset.get_data():
# Each receptor is a Receptor subclass object (e.g., TCABReceptor, BCReceptor)
# A Receptor contains two paired ReceptorSequence objects
identifier = receptor.get_id()
Expand All @@ -138,10 +138,10 @@ def _get_encoded_receptors(self, dataset: ReceptorDataset, params: EncoderParams

return np.array(encoded_receptors)

def _get_encoded_repertoires(self, dataset: RepertoireDataset, params: EncoderParams) -> np.array:
def _get_encoded_repertoires(self, dataset: RepertoireDataset) -> np.array:
encoded_repertoires = []

for repertoire in dataset.get_data(params.pool_size):
for repertoire in dataset.get_data():
# Each repertoire is a Repertoire object.
# Different properties of the repertoire can be retrieved here, examples:
identifiers = repertoire.get_sequence_identifiers(as_list=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _encode_examples(self, dataset, params: EncoderParams):

sequence_encoder = self._prepare_sequence_encoder()
feature_names = sequence_encoder.get_feature_names(params)
for sequence in dataset.get_data(params.pool_size):
for sequence in dataset.get_data():
counts = self._encode_sequence(sequence, params, sequence_encoder, Counter())
encoded_sequences.append(counts)
sequence_ids.append(sequence.sequence_id)
Expand Down
2 changes: 1 addition & 1 deletion immuneML/encodings/onehot/OneHotSequenceEncoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _encode_new_dataset(self, dataset: SequenceDataset, params: EncoderParams):
return encoded_dataset

def _encode_data(self, dataset: SequenceDataset, params: EncoderParams):
sequence_objs = [obj for obj in dataset.get_data(params.pool_size)]
sequence_objs = [obj for obj in dataset.get_data()]

sequences = [obj.get_sequence(self.sequence_type) for obj in sequence_objs]

Expand Down

0 comments on commit 4f286cd

Please sign in to comment.