Skip to content

bug #447

@ljchang

Description

@ljchang

When using a different mask to load Brain_Data, you can't get a summary of the variable due to a bug in repr. Should be easy to fix.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File [/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/IPython/core/formatters.py:708](http://localhost:8888/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/IPython/core/formatters.py#line=707), in PlainTextFormatter.__call__(self, obj)
    701 stream = StringIO()
    702 printer = pretty.RepresentationPrinter(stream, self.verbose,
    703     self.max_width, self.newline,
    704     max_seq_length=self.max_seq_length,
    705     singleton_pprinters=self.singleton_printers,
    706     type_pprinters=self.type_printers,
    707     deferred_pprinters=self.deferred_printers)
--> 708 printer.pretty(obj)
    709 printer.flush()
    710 return stream.getvalue()

File [/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/IPython/lib/pretty.py:410](http://localhost:8888/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/IPython/lib/pretty.py#line=409), in RepresentationPrinter.pretty(self, obj)
    407                         return meth(obj, self, cycle)
    408                 if cls is not object \
    409                         and callable(cls.__dict__.get('__repr__')):
--> 410                     return _repr_pprint(obj, self, cycle)
    412     return _default_pprint(obj, self, cycle)
    413 finally:

File [/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/IPython/lib/pretty.py:778](http://localhost:8888/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/IPython/lib/pretty.py#line=777), in _repr_pprint(obj, p, cycle)
    776 """A pprint that just redirects to the normal repr function."""
    777 # Find newlines and replace them with p.break_()
--> 778 output = repr(obj)
    779 lines = output.splitlines()
    780 with p.group():

File [/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/nltools/data/brain_data.py:325](http://localhost:8888/opt/anaconda3/envs/pyfeatlive/lib/python3.11/site-packages/nltools/data/brain_data.py#line=324), in Brain_Data.__repr__(self)
    318 def __repr__(self):
    319     return "%s.%s(data=%s, Y=%s, X=%s, mask=%s)" % (
    320         self.__class__.__module__,
    321         self.__class__.__name__,
    322         self.shape(),
    323         self.Y.shape,
    324         self.X.shape,
--> 325         os.path.basename(self.mask.get_filename()),
    326     )

File <frozen posixpath>:142, in basename(p)

TypeError: expected str, bytes or os.PathLike object, not NoneType

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions