Skip to content

fix fss node not returning T/F and not handling cases with only one f… - #1368

Open
perib wants to merge 2 commits into
EpistasisLab:mainfrom
perib:fss_fix
Open

perib wants to merge 2 commits into
EpistasisLab:mainfrom
perib:fss_fix

Conversation

@perib

@perib perib commented Apr 9, 2025

Copy link
Copy Markdown
Contributor

What does this PR do?

FSSNode was not returning True or False for the mutation/crossover operations as required.
Additionally, when only a single feature set was passed in, there would be an error thrown. This was found in issue #1366

Where should the reviewer start?

How should this PR be tested?

subset_1_dict  = { "sense_strands" :  ['a', 'b', 'c']}
fss_1 = FSSNode(subsets=subset_1_dict)

ind1 = fss_1.generate()

for i in range(1000):
    ind1.mutate()

Before this would throw an error like :

File "/scratch2/users/mpb703/conda_environments/tpot_v1/lib/python3.10/site-packages/tpot/search_spaces/nodes/fss_node.py", line 113, in mutate self.selected_subset_name = rng.choice(names) File "numpy/random/_generator.pyx", line 803, in numpy.random._generator.Generator.choice ValueError: a cannot be empty unless no samples are take

@perib

perib commented Mar 7, 2026

Copy link
Copy Markdown
Contributor Author

bump

Copilot AI lite review requested due to automatic review settings September 4, 2026 03:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The bug fix and new boolean contract behavior are not covered by tests, making the change prone to regression.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates the Feature Set Selector search-space individual so its genetic operators (mutation/crossover) correctly return a boolean “changed” flag and avoids an exception when only a single feature subset is available (issue #1366 scenario).

Changes:

  • Guard mutate() to avoid rng.choice([]) when only one subset exists, returning False when no mutation is possible.
  • Make mutate() and crossover() explicitly return True/False to match the boolean contract used by pipeline operators.
File summaries
File Description
tpot/search_spaces/nodes/fss_node.py Adds boolean return semantics to mutation/crossover and handles single-subset mutation safely.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 109 to +126
def mutate(self, rng=None):
rng = np.random.default_rng(rng)
#get list of names not including the current one
names = [name for name in self.names_list if name != self.selected_subset_name]
self.selected_subset_name = rng.choice(names)
self.sel_subset = self.subset_dict[self.selected_subset_name]
if len(self.names_list)>1:
names = [name for name in self.names_list if name != self.selected_subset_name]
self.selected_subset_name = rng.choice(names)
self.sel_subset = self.subset_dict[self.selected_subset_name]
return True
else:
return False


def crossover(self, other, rng=None):
if self.selected_subset_name == other.selected_subset_name:
return False
self.selected_subset_name = other.selected_subset_name
self.sel_subset = other.sel_subset
return True
names = [name for name in self.names_list if name != self.selected_subset_name]
self.selected_subset_name = rng.choice(names)
self.sel_subset = self.subset_dict[self.selected_subset_name]
if len(self.names_list)>1:

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants