Skip to content

Imports inside functions #188

@JuliaKukulies

Description

@JuliaKukulies

I realized that we are currently quite inconsistent with importing modules in functions vs. importing modules at the top of the tobac modules. An example is that in some modules, we import numpy at the top whereas in other modules it is imported in every single function.

It is not the most important, but at some point, we should maybe discuss and agree on a rule for this and go through all files to remove redundant imports. Keeping most imports at the top of the file would have a few advantages:

  • PEP8 compliant
  • easier to keep track of which imports are needed for which module
  • probably more efficient (especially when functions are called frequently, e.g. for every timestep/threshold/feature)
  • potential ImportErrors are raised immediately before any code is run

Any thoughts?

Metadata

Metadata

Assignees

Labels

RefactorCode that doesn't intend to change the functionality, but instead refactor/clean up.to be deleted?

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions