Skip to content
Open
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f70c9cd
Added schemas Folder with __init__.py
JanNolten Nov 7, 2025
e007679
Added field_validator.py to group repeated validation
JanNolten Nov 7, 2025
ccac5cc
Added field_serializer.py to group repeated serialization
JanNolten Nov 7, 2025
11c2a35
added function_validator.py to validate elephant functions
JanNolten Nov 7, 2025
46ff38b
Added Pydantic Models for statistics
JanNolten Nov 7, 2025
5fb18dc
Added Pydantic Models for spike_train_correlation
JanNolten Nov 7, 2025
d5324bf
Added Pydantic Models for spike_train_synchrony
JanNolten Nov 7, 2025
c99b6c0
Original arguments are passed into the function
JanNolten Nov 7, 2025
cb533cc
Added pytest.ini to .gitignore
JanNolten Nov 7, 2025
71b7dc0
Added tests and option to skip validation
JanNolten Nov 7, 2025
7f4f5ef
Transfering Bug fixes
JanNolten Nov 7, 2025
b282cc3
Transfering Bug fixes
JanNolten Nov 7, 2025
9c3402a
Transfering Bug fixes
JanNolten Nov 7, 2025
ac00866
Implemented validation for statistics
JanNolten Nov 7, 2025
a95f9f8
Implemented validation for spike_train_correlation
JanNolten Nov 7, 2025
69745c2
Implemented validation for spike_train_synchrony
JanNolten Nov 7, 2025
460e9cd
Allowed some ValueErrors to also be TypeErrors
JanNolten Nov 7, 2025
bf9b837
Merge branch 'NeuralEnsemble:master' into feature/partial
JanNolten Nov 7, 2025
fac02e1
Removed ; at end of lines
JanNolten Nov 10, 2025
4fdd64a
Added Pydantic to requirements
JanNolten Nov 10, 2025
b5f0ff7
Merge branch 'NeuralEnsemble:master' into feature/partial
JanNolten Nov 11, 2025
7d933a4
Removed Self from typing, because it only works in python>=3.11.0
JanNolten Nov 11, 2025
932f1d4
Added ability to disable validation globally
JanNolten Nov 11, 2025
1f58b12
Allow t_start to be negative because it should be able to be used tha…
JanNolten Nov 11, 2025
6f2b7d3
Allowed all t_start and t_stop to be negative, becuase they could be …
JanNolten Nov 18, 2025
c46228d
Removed the option to skip validation with the extra kwargs not_valid…
JanNolten Nov 24, 2025
ae94ee6
Simplified test to make them more understandable
JanNolten Nov 24, 2025
ca247c0
Make test stricter by checking for the exact Error Type. Also Fixed Bugs
JanNolten Nov 24, 2025
91df787
Forgot to remove a print statement
JanNolten Nov 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions elephant/schemas/function_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from inspect import signature
from pydantic import BaseModel

skip_validation = False

def validate_with(model_class: type[BaseModel]):
"""
A decorator that validates the inputs of a function using a Pydantic model.
Expand All @@ -13,7 +15,7 @@ def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):

if kwargs.pop("not_validate", False):
if kwargs.pop("not_validate", False) or skip_validation:
# skip validation, call inner function directly
return func(*args, **kwargs)

Copy link
Author

@JanNolten JanNolten Nov 20, 2025

Choose a reason for hiding this comment

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

Should be able to call function without validation, if it does not work how it should or if the user knows he has valid data and therefore wants to save some calculation time.

Expand All @@ -29,4 +31,10 @@ def wrapper(*args, **kwargs):
return func(*args, **kwargs)
wrapper._is_validate_with = True
return wrapper
return decorator
return decorator

def activate_validation():
skip_validation = False

def deactivate_validation():
skip_validation = True
Copy link
Author

Choose a reason for hiding this comment

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

Should also be able to disable the validation globally, so it does not get annoying, if you never want to use it.

Loading