Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No known mechanism for handling <class 'datetime.date'> → <class 'datetime.date'>; using default #826

Open
daniel-klein opened this issue Dec 15, 2024 · 3 comments

Comments

@daniel-klein
Copy link
Contributor

No description provided.

@cliffckerr
Copy link
Contributor

Could you give an example?

@daniel-klein
Copy link
Contributor Author

If a user updates parameters for a date parameter, like start or stop, a warning is thrown. This is because Pars.update does not recognize datetime.date:

# Perform the update
        for key,new in pars.items():
            if key not in self.keys(): # It's a new parameter and create=True: update directly
                self[key] = new
            else:
                old = self[key] # Get the existing object we're about to update
                if isinstance(old, atomic_classes): # It's a number, string, etc: update directly
                    self[key] = new

                elif isinstance(old, Pars): # It's a Pars object: update recursively
                    old.update(new, create=create)
                elif isinstance(old, ss.ndict): # Update module containers
                    self._update_ndict(key, old, new)
                elif isinstance(old, ss.Module):  # Update modules
                    self._update_module(key, old, new)
                elif isinstance(old, ss.TimePar):
                    self._update_timepar(key, old, new)
                elif isinstance(old, ss.Dist): # Update a distribution
                    self._update_dist(key, old, new)
                elif callable(old): # It's a function: update directly
                    self[key] = new
                elif isinstance(old, dict):
                    self[key] = new # Take dictionaries directly, without warning the user
                else: # Everything else; not used currently but could be
                    warnmsg = f'No known mechanism for handling {type(old)}{type(new)}; using default'
                    ss.warn(warnmsg)
                    self[key] = new

@daniel-klein
Copy link
Contributor Author

One possible solution is to add datetime.date to atomic_classes.

daniel-klein added a commit that referenced this issue Jan 7, 2025
@daniel-klein daniel-klein mentioned this issue Jan 7, 2025
4 tasks
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

No branches or pull requests

2 participants