Can't import Representation class twice (from different packages/telescopes)
See original GitHub issueI try to import two functions from two packages of two telescopes (CTA / FACT).
Both define a PlanarRepresentation
class internally.
Error:
438 if repr_name in REPRESENTATION_CLASSES:
439 raise ValueError("Representation class {0} already defined"
--> 440 .format(repr_name))
441
442 REPRESENTATION_CLASSES[repr_name] = cls
ValueError: Representation class planar already defined
MWE without the packages, but same Error, basically just redefining the Representation class:
from astropy.coordinates import BaseRepresentation
class PlanarRepresentation(BaseRepresentation):
attr_classes = ['a', 'b']
def __init__(self, x, y, copy=True, **kwargs):
pass
class PlanarRepresentation(BaseRepresentation):
attr_classes = ['a', 'b']
def __init__(self, x, y, copy=True, **kwargs):
pass
Issue Analytics
- State:
- Created 5 years ago
- Comments:28 (23 by maintainers)
Top Results From Across the Web
Same class name in different packages - java - Stack Overflow
Yes, you can have two classes with the same name in multiple packages. However, you can't import both classes in the same file...
Read more >Can I import same package twice? Will JVM load the package ...
Yes, you can import a class twice in Java, it doesn't create any issues but, irrespective of the number of times you import,...
Read more >Modern IDEs are magic. Why are so many coders still using ...
Vim is more than an editor, vim is a language and a tool to translate intent into code. I can 2p to paste...
Read more >Can python distinguish two different functions defined ... - Quora
You have two workaround options: assigning a different name on import: from foo import bar as foobar; importing the foo and baz modules,...
Read more >Simulation Curriculum • Support • FAQ • SkySafari for Android
SkySafari for Android Frequently Asked Questions. This page contains answers to the most frequently asked questions about SkySafari for Android.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The use case is arguably mostly laziness: if you want to initialize or convert, you don’t have to import the relevant class, but just give its name.
So, indeed, changing the name of your class would resolve it, though I think that longer term it still seems reasonable to move the class up to astropy.
Well, it certainly is not something we can change any more; it is even in the Getting Started section on coordinates; http://docs.astropy.org/en/latest/coordinates/index.html#representation