Skip to content

[1.2.0] Registered SpectralMagSystem is not able to retrieved from registry #132

Closed
@bhayden53

Description

@bhayden53

The registry code looks a little voodoo-ey at first glance, so I haven't tracked down what's happening yet. But here is a minimal example to reproduce the bug.

sncosmo.version = 1.2.0

First, expected behavior.

band = sncosmo.get_bandpass('sdssg')
sncosmo.register(band,'sdssg_test')
sncosmo.get_bandpass('sdssg_test')

No errors, this behaves fine. Now try this:

magsys = sncosmo.get_magsystem('vega')
sncosmo.register(magsys, 'vega_test')
sncosmo.get_magsystem('vega_test')
Exception: No MagSystem named 'vega_test' in registry. Registered names: 'ab', 'vega', 'bd17'
sncosmo.register(magsys, 'vega_test')
Exception: SpectralMagSystem named vega_test already in registry. Use force=True to override.

Activity

bhayden53

bhayden53 commented on Mar 6, 2016

@bhayden53
Author

Aha! sncosmo.get_magsystem looks for an sncosmo.spectral.MagSystem object, however, sncosmo.get_magsystem actually returns an instance of sncosmo.spectral.SpectralMagSystem.

Unfortunately under the hood everywhere that sncosmo needs to read a magnitude system it seems to use sncosmo.get_magsystem, which means that currently the user cannot specify any custom magnitude systems to be used elsewhere.

kbarbary

kbarbary commented on Mar 6, 2016

@kbarbary
Member

Yeah, this is something I've been thinking about improving. The answer would be separate registries for bandpasses, magsystems and sources, rather than throwing them all in the same dictionary and keying by the class. Keying by the class presents problems for subclasses, as you've discovered.

Try sncosmo.register(magsys, 'name', data_class=sncosmo.MagSystem) in the meantime.

kbarbary

kbarbary commented on Jun 7, 2016

@kbarbary
Member

Fixed by #136

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      [1.2.0] Registered SpectralMagSystem is not able to retrieved from registry · Issue #132 · sncosmo/sncosmo