question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

API: should ``Layer()`` not derive from ``BaseObject``?

See original GitHub issue

Since Layer is the main interface, it would be nice if tab completion on the object only listed relevant pieces of the API so that you can quickly find what plot types are available (e.g. point(), bar(), text(), etc.)

Currently, since it derives from BaseObject the namespace is polluted with all sorts of traitlet stuff that the user probably doesn’t care about.

I’d propose something like this:

class LayerObject(BaseObject):
    # traitlet-related stuff goes here
    def __init__(self, *args, **kwargs):
        super(LayerObject, self).__init__(**kwargs)

    # etc.

class Layer(object):
    # non-traitlet-related Layer methods here
    def __init__(self, *args, **kwargs):
        if len(args)==1:
            self.data = args[0]
        self._layerobject = LayerObject(**kwargs)

    def point(self):
        self.mark = 'point'
        return self

    # etc.

The only problem would be if we ever want to pass Layer to some other class this would complicate things. What do you think?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:34 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
ellisonbgcommented, May 20, 2016

I don’t feel too strongly about the ordering but like the idea of being consistent with the vegalite examples. So +1 to marking first

Sent from my iPhone

On May 20, 2016, at 9:44 AM, Kanit Wongsuphasawat notifications@github.com wrote:

To be clear, either order works currently.

Yep. I mean, unless you have strong preference, can we put mark_point() before encode() in the all the example so we can establish convention? (For the same reason, in all VL examples, we put mark before encoding although order does not really matter in JSON. 😃 )

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

1reaction
jakevdpcommented, May 21, 2016

I imagine that as we hit other pain points in configuration, we can come up with more API solutions similar to mark_point(color='red'). I landed on this as I went through the basic examples and tried to implement them in Altair. I don’t know what the right solution will be as we go deeper into configs, but I believe that API-wise, exactly mirroring the VegaLite spec should not be our preferred solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Derived type's properties missing in JSON response from ASP ...
This happens when a property uses a derived type; any properties defined in the derived type but not in the base/interface will not...
Read more >
OpenLayers v7.1.0 API - Class: BaseObject
Most non-trivial classes inherit from this. This extends Observable with observable properties, where each property is observable as well as the object as...
Read more >
Base object (lv_obj) - LVGL documentation
Overview¶. The 'Base Object' implements the basic properties of widgets on a screen, such as: coordinates. parent object. children. main style.
Read more >
Maps marker layers show no results when using custom ...
Clients will encounter an issue when plotting a Marker Layer whose Base Object's address location is derived from an object with the API...
Read more >
Scripting API: SerializeReference - Unity - Manual
Object; A class derived from a generic type, but not a specific specialization of a generic ... Otherwise only m_Data from Base object...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found