-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Allow default_value to Instance #518
Comments
Does the |
Thanks @rmorshea It's a workaround for sure, but morally it should be part of the trait, not the class, no? |
@krey unfortunately no. Default values that are declared without class A:
my_list= []
a_1 = A()
a_1.my_list.append(1)
a_2 = A()
assert a_2.my_list== [1] We might expect to a_1.my_list is a_2.my_list If it were possible to declare: class A(HasTraits):
my_list= Instance(list, default=[]) You'd encounter a similar problem. Forcing you to use class A(HasTraits):
my_list = Instance(list)
@default("my_list")
def _my_list_default(self):
return [] If you don't specify https://github.com/ipython/traitlets/blob/master/traitlets/traitlets.py#L1841 |
I would like to have a trait that is a pandas dataframe:
Unfortunately, the constructor
pd.DataFrame
does not have a dtypes argument where I could specify the datatypes by column. (This issue is old enough to go to school now pandas-dev/pandas#4464)And the only way to initialize it properly is:
The text was updated successfully, but these errors were encountered: