Skip to content

%%time magic affects variables outside the cells #11665

@gustavovelascoh

Description

@gustavovelascoh

Hi, I was working on a couple of notebooks and noticed a strange behaviour. First, a variable which type was numpy.ndarray within the same cell, reports type list in the next cell. Second, a variable created in the cell with %%time is not found in the next cell.

I think it is related with #11659.

I created this question in stackoverflow with more details:

TL;DR

I am facing a weird issue (or I am missing something basic). I have a Jupyter notebook and in one cell there is a variable saved as numpy.ndarray, but when I print its type in the next cell, the variable appears as of type list. How is this possible? In my machine works fine, in a VM does not.


Detailed description:

I am working on a certain pull request updating a jupyter notebook, and as I having some plotting issues in my current setup, I tried to test it in a different machine/system with updated packages and components.

In my laptop I have Ubuntu 16.04 and this configuration:

> The version of the notebook server is: 5.7.4 The server is running on
> this version of Python: Python 3.5.2 (default, Nov 12 2018, 13:43:14) 
> [GCC 5.4.0 20160609]
> 
> Current Kernel Information: Python 3.5.2 (default, Nov 12 2018,
> 13:43:14)
> IPython 7.2.0 -- An enhanced Interactive Python. Type '?' for help.

I created a virtual machine, installed Ubuntu 18.04 and use this configuration:

> The version of the notebook server is: 5.7.6 The server is running on
> this version of Python: Python 3.5.2 (default, Oct 22 2018, 11:32:17) 
> [GCC 8.2.0]
> 
> Current Kernel Information: Python 3.5.2 (default, Oct 22 2018, 11:32:17)
> IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.

Then I identified that in the VM, a variable changes its type from numpy.ndarray to list with no reason (for me). The variable is pos. This is causing me problems as it is used later for indexing purposes

Laptop:

Laptop

Virtual Machine:
vm

What is going on here? Am I missing something on this?

Any hint is appreciated :) Thanks.


UPDATE:

I've tried another notebook in the VM, and now it's not just the type changing but the variable not reached in a different cell (variable joint_vars):

enter image description here

Should it be some misconfiguration of the environment in the VM?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions