Find a global ordering for layers in a HoloMap of CompositeOverlay
   types.
7529
def layer_sort(hmap):
   
   orderings = {}
   for o in hmap:
      okeys = [get_overlay_spec(o, k, v) for k, v in o.data.items()]
      if len(okeys) == 1 and not okeys[0] in orderings:
         orderings[okeys[0]] = []
      else:
         orderings.update({k: [] if k == v else [v] for k, v in zip(okeys[1:], okeys)})
   return [i for g in sort_topologically(orderings) for i in sorted(g)]
60316
private List<ClassInfo> getOverrideOrder(final Set<ClassInfo> visited, final List<ClassInfo> overrideOrderOut) {
        if (visited.add(this)) {
            overrideOrderOut.add(this);
            for (final ClassInfo iface : getInterfaces()) {
                iface.getOverrideOrder(visited, overrideOrderOut);
            }
            final ClassInfo superclass = getSuperclass();
            if (superclass != null) {
                superclass.getOverrideOrder(visited, overrideOrderOut);
            }
        }
        return overrideOrderOut;
    }
678534
def getOverlayAlpha(self, ulOverlayHandle):
        """"""

        fn = self.function_table.getOverlayAlpha
        pfAlpha = c_float()
        result = fn(ulOverlayHandle, byref(pfAlpha))
        return result, pfAlpha.value
1211681
def _callbackPlaceFillOrders(self, d):
        
        if isinstance(d, FilledOrder):
            self.onOrderMatched(d)
        elif isinstance(d, Order):
            self.onOrderPlaced(d)
        elif isinstance(d, UpdateCallOrder):
            self.onUpdateCallOrder(d)
        else:
            pass
203528
def getMirrorTextureGL(self, eEye):
        """"""

        fn = self.function_table.getMirrorTextureGL
        pglTextureId = glUInt_t()
        pglSharedTextureHandle = glSharedTextureHandle_t()
        result = fn(eEye, byref(pglTextureId), byref(pglSharedTextureHandle))
        return result, pglTextureId, pglSharedTextureHandle
1252447
function getGetUniformHook1(defaultNormalMap, defaultRoughnessMap, defaultDiffuseMap) {

    return function (renderable, gBufferMat, symbol) {
        var standardMaterial = renderable.material;
        if (symbol === 'doubleSided') {
            return standardMaterial.isDefined('fragment', 'DOUBLE_SIDED');
        }
        else if (symbol === 'uvRepeat' || symbol === 'uvOffset' || symbol === 'alpha') {
            return standardMaterial.get(symbol);
        }
        else if (symbol === 'normalMap') {
            return standardMaterial.get(symbol) || defaultNormalMap;
        }
        else if (symbol === 'diffuseMap') {
            return standardMaterial.get(symbol) || defaultDiffuseMap;
        }
        else if (symbol === 'alphaCutoff') {
            // TODO DIFFUSEMAP_ALPHA_ALPHA
            if (standardMaterial.isDefined('fragment', 'ALPHA_TEST')) {
                var alphaCutoff = standardMaterial.get('alphaCutoff');
                return alphaCutoff || 0;
            }
            return 0;
        }
        else {
            var useRoughnessWorkflow = standardMaterial.isDefined('fragment', 'USE_ROUGHNESS');
            var roughGlossMap = useRoughnessWorkflow ? standardMaterial.get('roughnessMap') : standardMaterial.get('glossinessMap');
            switch (symbol) {
                case 'glossiness':
                    return useRoughnessWorkflow ? (1.0 - standardMaterial.get('roughness')) : standardMaterial.get('glossiness');
                case 'roughGlossMap':
                    return roughGlossMap;
                case 'useRoughGlossMap':
                    return !!roughGlossMap;
                case 'useRoughness':
                    return useRoughnessWorkflow;
                case 'roughGlossChannel':
                    return useRoughnessWorkflow
                        ? standardMaterial.getDefine('fragment', 'ROUGHNESS_CHANNEL')
                        : standardMaterial.getDefine('fragment', 'GLOSSINESS_CHANNEL');
            }
        }
    };
}
224817
def layers(self, annotationtype=None,set=None):
        """"""
        if inspect.isclass(annotationtype): annotationtype = annotationtype.ANNOTATIONTYPE
        return [ x for x in self.select(AbstractAnnotationLayer,set,False,True) if annotationtype is None or x.ANNOTATIONTYPE == annotationtype ]
299635
public static CompositeOverlay getCompositeOverlay(Collection<TileDao> tileDaos, BoundedOverlay overlay) {

        CompositeOverlay compositeOverlay = getCompositeOverlay(tileDaos);

        compositeOverlay.addOverlay(overlay);

        return compositeOverlay;
    }
757680
def function(self,p):
        """"""
        generators = self._advance_pattern_generators(p)

        assert hasattr(p.operator,'reduce'),repr(p.operator)+" does not support 'reduce'."

        # CEBALERT: mask gets applied by all PGs including the Composite itself
        # (leads to redundant calculations in current lissom_oo_or usage, but
        # will lead to problems/limitations in the future).
        patterns = [pg(xdensity=p.xdensity,ydensity=p.ydensity,
                       bounds=p.bounds,mask=p.mask,
                       x=p.x+p.size*(pg.x*np.cos(p.orientation)- pg.y*np.sin(p.orientation)),
                       y=p.y+p.size*(pg.x*np.sin(p.orientation)+ pg.y*np.cos(p.orientation)),
                       orientation=pg.orientation+p.orientation,
                       size=pg.size*p.size)
                    for pg in generators]
        image_array = p.operator.reduce(patterns)
        return image_array
419531
def order(self, piecewise=False):
        
        if piecewise:
            return {k: v.order() for k, v in self.items()}
        return self.master_graph.order()
884720
public static UIComponent getCompositeComponentBasedOnLocation(final FacesContext facesContext, 
            final Location location, int ccLevel)
    {
        //1 Use getCurrentComponent and getCurrentCompositeComponent to look on the component stack
        UIComponent currentCompositeComponent = UIComponent.getCurrentCompositeComponent(facesContext);
        
        //1.1 Use getCurrentCompositeComponent first!
        if (currentCompositeComponent != null)
        {
            Location componentLocation = (Location) currentCompositeComponent.getAttributes().get(LOCATION_KEY);
            if (componentLocation != null 
                    && componentLocation.getPath().equals(location.getPath()) && 
                    (ccLevel == getCCLevel(currentCompositeComponent)) )
            {
                return currentCompositeComponent;
            }
        }

        UIComponent currentComponent = UIComponent.getCurrentComponent(facesContext);
        
        if (currentComponent == null)
        {
            // Cannot found any component, because we don't have any reference!
            return null;
        }
        
        //2. Look on the stack using a recursive algorithm.
        UIComponent matchingCompositeComponent
                = lookForCompositeComponentOnStack(facesContext, location, ccLevel, currentComponent);
        
        if (matchingCompositeComponent != null)
        {
            return matchingCompositeComponent;
        }
        
        //2. Try to find it using UIComponent.getCurrentCompositeComponent(). 
        // This one will look the direct parent hierarchy of the component,
        // to see if the composite component can be found.
        if (currentCompositeComponent != null)
        {
            currentComponent = currentCompositeComponent;
        }
        else
        {
            //Try to find the composite component looking directly the parent
            //ancestor of the current component
            //currentComponent = UIComponent.getCurrentComponent(facesContext);
            boolean found = false;
            while (currentComponent != null && !found)
            {
                String findComponentExpr = (String) currentComponent.getAttributes().get(CC_FIND_COMPONENT_EXPRESSION);
                if (findComponentExpr != null)
                {
                    UIComponent foundComponent = facesContext.getViewRoot().findComponent(findComponentExpr);
                    if (foundComponent != null)
                    {
                        Location foundComponentLocation = (Location) currentComponent.getAttributes().get(LOCATION_KEY);
                        if (foundComponentLocation != null 
                                && foundComponentLocation.getPath().equals(location.getPath()) &&
                                ccLevel == getCCLevel(foundComponent))
                        {
                            return foundComponent;
                        }
                        else
                        {
                            while (foundComponent != null)
                            {
                                Location componentLocation
                                        = (Location) foundComponent.getAttributes().get(LOCATION_KEY);
                                if (componentLocation != null 
                                        && componentLocation.getPath().equals(location.getPath()) &&
                                        ccLevel == getCCLevel(foundComponent))
                                {
                                    return foundComponent;
                                }
                                // get the composite component's parent
                                foundComponent = UIComponent.getCompositeComponentParent(foundComponent);
                            }
                        }
                    }
                }

                if (UIComponent.isCompositeComponent(currentComponent))
                {
                    found = true;
                }
                else
                {
                    currentComponent = currentComponent.getParent();
                }
            }
        }
        
        //if currentComponent != null means we have a composite component that we can check
        //Use UIComponent.getCompositeComponentParent() to traverse here.
        while (currentComponent != null)
        {
            Location componentLocation = (Location) currentComponent.getAttributes().get(LOCATION_KEY);
            if (componentLocation != null 
                    && componentLocation.getPath().equals(location.getPath()) &&
                    ccLevel == getCCLevel(currentComponent))
            {
                return currentComponent;
            }
            // get the composite component's parent
            currentComponent = UIComponent.getCompositeComponentParent(currentComponent);
        }
        
        // not found
        return null;
    }
871657
function() {
      var self = this;

      var oldLayers = this.layers;
      this.layers = {};

      function findLayerView(layer) {
        var lv = _.find(oldLayers, function(layer_view) {
          var m = layer_view.model;
          return m.isEqual(layer);
        });
        return lv;
      }

      function canReused(layer) {
        return self.map.layers.find(function(m) {
          return m.isEqual(layer);
        });
      }

      // remove all
      for(var layer in oldLayers) {
        var layer_view = oldLayers[layer];
        if (!canReused(layer_view.model)) {
          layer_view.remove();
        }
      }

      this.map.layers.each(function(lyr) {
        var lv = findLayerView(lyr);
        if (!lv) {
          self._addLayer(lyr);
        } else {
          lv.setModel(lyr);
          self.layers[lyr.cid] = lv;
          self.trigger('newLayerView', lv, lv.model, self);
        }
      });

    }
180214
def layer_stack_from_hparams(hparams, prefix):
  """"""
  layers = hparams.get(prefix + "layers")
  return transformer.LayerStack(
      [layers_registry[l](hparams, prefix) for l in layers],
      dropout_rate=hparams.layer_prepostprocess_dropout,
      norm_epsilon=hparams.norm_epsilon)
699234
def findlayer(self, z):
        '''
        '''
        if z > self.z[0]:
            modellayer, ltype = -1, 'above'
            layernumber = None
        elif z < self.z[-1]:
            modellayer, ltype = len(self.layernumber), 'below'
            layernumber = None
        else:
            modellayer = np.argwhere((z <= self.z[:-1]) & (z >= self.z[1:]))[0, 0]
            layernumber = self.layernumber[modellayer]
            ltype = self.ltype[modellayer] 
        return layernumber, ltype, modellayer
409271
def visible_object_groups(self):
        
        return (i for (i, l) in enumerate(self.layers)
                if l.visible and isinstance(l, TiledObjectGroup))
524704
def layers():
  """"""
  global _cached_layers
  if _cached_layers is not None:
    return _cached_layers
  layers_module = tf.layers
  try:
    from tensorflow.python import tf2  # pylint: disable=g-direct-tensorflow-import,g-import-not-at-top
    if tf2.enabled():
      tf.logging.info("Running in V2 mode, using Keras layers.")
      layers_module = tf.keras.layers
  except ImportError:
    pass
  _cached_layers = layers_module
  return layers_module
482434
def find_order(graph):
    '''
    
    '''
    while graph:
        # Find all items without a parent
        leftmost = [l for l, s in graph.items() if not s]
        if not leftmost:
            raise ValueError('Dependency cycle detected! %s' % graph)
        # If there is more than one, sort them for predictable order
        leftmost.sort()
        for result in leftmost:
            # Yield and remove them from the graph
            yield result
            graph.pop(result)
            for bset in graph.values():
                bset.discard(result)