Skip to content

Conversation

@GiovanniCanali
Copy link
Collaborator

@GiovanniCanali GiovanniCanali commented Nov 11, 2025

Description

This PR fixes #574

Checklist

  • Code follows the project’s Code Style Guidelines
  • Tests have been added or updated
  • Documentation has been updated if necessary
  • Pull request is linked to an open issue

@GiovanniCanali GiovanniCanali self-assigned this Nov 11, 2025
@GiovanniCanali GiovanniCanali force-pushed the domain branch 2 times, most recently from 03ab912 to f03bfa9 Compare November 11, 2025 17:05
@GiovanniCanali GiovanniCanali added enhancement New feature or request pr-to-fix Label for PR that needs modification low priority Low priority fix labels Nov 11, 2025
@GiovanniCanali GiovanniCanali force-pushed the domain branch 14 times, most recently from b784158 to 69510e6 Compare November 13, 2025 16:10
@GiovanniCanali
Copy link
Collaborator Author

This PR introduces the following improvements:

  • Renames files to align with the PINA naming conventions (see Names convention #445).
  • Separates the abstract interface from the base classes (see Adding base classes with only method definition #672).
  • Implements the partial method for all domains and set operations, enabling full-boundary retrieval.
  • Fixes uniform sampling for EllipsoidDomain and SimplexDomain, ensuring a truly uniform distribution.
  • Redefines the sampling strategy for improved speed and robustness.
  • Adds stricter, shared validation checks across all domains to prevent initialization issues.
  • Expands the test suite for domains and set operations.
  • Updates tutorial6.

These modifications do not affect the user experience, aside from the new additions.

@GiovanniCanali GiovanniCanali force-pushed the domain branch 2 times, most recently from f62602f to 0395c89 Compare November 19, 2025 13:58
@GiovanniCanali GiovanniCanali added pr-to-review Label for PR that are ready to been reviewed and removed pr-to-fix Label for PR that needs modification labels Nov 19, 2025
@GiovanniCanali GiovanniCanali marked this pull request as ready for review November 19, 2025 14:06
@GiovanniCanali GiovanniCanali requested review from a team and dario-coscia as code owners November 19, 2025 14:06
@GiovanniCanali
Copy link
Collaborator Author

MEMO: if #717 is merged into dev before this PR, fix the conditions related to the spatial boundaries (use partial method).

Copy link
Member

@FilippoOlivo FilippoOlivo left a comment

Choose a reason for hiding this comment

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

Hi @GiovanniCanali, thank you for the PR. It is a great improvement PINA geometries. I started the review and I have some doubts about how BaseDomain is structured. Specifically in how sampling modes are handled. I leaved some comments on the involved lines of code. I will continue the review and give you a feedback also on other classes soon

"""

# Define available sampling modes
__AVAILABLE_MODES = ("random", "grid", "lh", "chebyshev", "latin")
Copy link
Member

Choose a reason for hiding this comment

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

Are these available for all the domains?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

__AVAILABLE_MODES stores all sampling modes defined in PINA. Each domain generally uses only a subset of these modes. In the __init__ of every class inheriting from BaseDomain, you’ll find a line like:

self.sample_modes = [...]

This calls the corresponding setter, which serves two purposes:

  1. It defines the sampling modes available for that specific domain.
  2. It validates the mode defined in the __init__, raising an error if it is not included in __AVAILABLE_MODES.

The only exception is CartesianDomain, which does not call the setter (it does not even have a __init__), because its available modes coincide exactly with the full set in __AVAILABLE_MODES.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Basically, this is just a variable storing all available modes. Through the setter, each domain defines a subset of these values.

Copy link
Member

Choose a reason for hiding this comment

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

In my opinion, it is better to have a distance __AVAILABLE_MODES for each subclass

# Define available sampling modes
__AVAILABLE_MODES = ("random", "grid", "lh", "chebyshev", "latin")

def __init__(self, domain_dict=None):
Copy link
Member

Choose a reason for hiding this comment

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

I think the name of the variable is not the best one. Can you rename it like "variables_dict"?

for v in domain_dict.values():
check_consistency(v, (int, float))

# Iterate over domain_dict items
Copy link
Member

Choose a reason for hiding this comment

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

Can you make a separate function for that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Deleted previous comment, that was my mistake.

I would keep this logic inside the same function: the base class __init__ performs all necessary checks, and this behavior belongs to that same scope.

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

Labels

enhancement New feature or request low priority Low priority fix pr-to-review Label for PR that are ready to been reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants