Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • kwant kwant
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 147
    • Issues 147
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 20
    • Merge requests 20
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • kwantkwant
  • kwantkwant
  • Issues
  • #386
Closed
Open
Issue created Aug 18, 2020 by Jacob Fuchs@j.fuchs.ur

Automatic dtype=object for ragged input is deprecated for numpy 1.19

Package versions

  • conda 4.8.4
  • python 3.8.5 (h4d41432_2_cpython on conda_forge)
  • numpy 1.19.1 (py38h8854b6b_0 on conda_forge)
  • kwant 1.4.2 (py38h2e4ba3f_2 on conda_forge)

Description

When using kwant.plotter.current or kwant.solvers.common.SMatrix.__init__ (see below), one gets the following deprecation warning:

VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray

Reason

Numpy changed the behaviour in version 1.19, see https://numpy.org/doc/1.19/release/1.19.0-notes.html#deprecate-automatic-dtype-object-for-ragged-input.

Steps to reproduce

Installing kwant:

conda create -n testkwant
conda activate testkwant
conda install -c conda-forge kwant

Testing with closed_system.py:

curl https://kwant-project.org/doc/1/_downloads/closed_system.py --output closed_system.py
python closed_system.py

output:

closed_system.py:96: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  kwant.plotter.current(syst, current, colorbar=False)

Testing with superconductor.py:

curl https://kwant-project.org/doc/1/_downloads/superconductor.py --output superconductor.py
python superconductor.py

output:

~/.conda/envs/testkwant/lib/python3.8/site-packages/kwant/solvers/common.py:820: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  np.array(self.block_offsets)[list(self.in_leads)]
~/.conda/envs/testkwant/lib/python3.8/site-packages/kwant/solvers/common.py:822: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  np.array(self.block_offsets)[list(self.out_leads)]
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking