use this for supporting nested projector instances
554626
function findSafe($element, selector, ignore) {
          var $self = $element;
          return $self.find(selector).filter(function() {
            var $parents = $(this).parents();
            var i;
            for (i = 0; (i < $parents.length); i++) {
              if ($parents[i] === $self[0]) {
                return true;
              }
              if ($($parents[i]).is(ignore)) {
                return false;
              }
            }
          });
        }
1191204
def projectSphereFilter(actor):
    
    poly = actor.polydata()
    psf = vtk.vtkProjectSphereFilter()
    psf.SetInputData(poly)
    psf.Update()
    a = Actor(psf.GetOutput())
    return a
517052
function(layerContext, node) {
        var srs    = this.getChildValue(node);
        if (typeof layerContext.projections != "object") {
            layerContext.projections = {};
        }
        var values = srs.split(/ +/);
        for (var i=0, len=values.length; i<len; i++) {
            layerContext.projections[values[i]] = true;
        }
    }
606637
def apply_projection(projection, value):
    """"""
    if isinstance(value, Sequence):
        # Apply projection to each item in the list.
        return [
            apply_projection(projection, item)
            for item in value
        ]
    elif not isinstance(value, Mapping):
        # Non-dictionary values are simply ignored.
        return value

    # Extract projection for current level.
    try:
        current_projection = [p[0] for p in projection]
    except IndexError:
        return value

    # 
    for name in list(value.keys()):
        if name not in current_projection:
            value.pop(name)
        elif isinstance(value[name], dict):
            # Apply projection recursively.
            value[name] = apply_projection(
                [p[1:] for p in projection if p[0] == name],
                value[name]
            )

    return value
175823
def get_plot(self_or_cls, obj, renderer=None, **kwargs):
        
        if isinstance(obj, DynamicMap) and obj.unbounded:
            dims = ', '.join('%r' % dim for dim in obj.unbounded)
            msg = ('DynamicMap cannot be displayed without explicit indexing '
                   'as {dims} dimension(s) are unbounded. '
                   '\nSet dimensions bounds with the DynamicMap redim.range '
                   'or redim.values methods.')
            raise SkipRendering(msg.format(dims=dims))

        # Initialize DynamicMaps with first data item
        initialize_dynamic(obj)

        if not isinstance(obj, Plot):
            if not displayable(obj):
                obj = collate(obj)
                initialize_dynamic(obj)
            obj = Compositor.map(obj, mode='data', backend=self_or_cls.backend)

        if not renderer:
            renderer = self_or_cls
            if not isinstance(self_or_cls, Renderer):
                renderer = self_or_cls.instance()
        if not isinstance(obj, Plot):
            obj = Layout.from_values(obj) if isinstance(obj, AdjointLayout) else obj
            plot_opts = dict(self_or_cls.plot_options(obj, self_or_cls.size),
                             **kwargs)
            plot = self_or_cls.plotting_class(obj)(obj, renderer=renderer,
                                                   **plot_opts)
            defaults = [kd.default for kd in plot.dimensions]
            init_key = tuple(v if d is None else d for v, d in
                             zip(plot.keys[0], defaults))
            plot.update(init_key)
        else:
            plot = obj
        return plot
582984
def _update_from_pb(self, instance_pb):
        
        if not instance_pb.display_name:  # Simple field (string)
            raise ValueError("Instance protobuf does not contain display_name")
        self.display_name = instance_pb.display_name
        self.configuration_name = instance_pb.config
        self.node_count = instance_pb.node_count
206434
def _from_java_impl(cls, java_stage):
        

        # Load information from java_stage to the instance.
        estimator = JavaParams._from_java(java_stage.getEstimator())
        evaluator = JavaParams._from_java(java_stage.getEvaluator())
        epms = [estimator._transfer_param_map_from_java(epm)
                for epm in java_stage.getEstimatorParamMaps()]
        return estimator, epms, evaluator
955853
function viewBuilder(contexts, joins) {

  var merge = require('merge');
  var heirarchy = {};
  var graph = {
    nodes: [],
    links: []
  };
  var nodeMap = {};
  var depth;
  var fullContext;

  function createJoinNodes(joins, parent) {

    if(joins instanceof Array) {
      for (var i = 0; i < joins.length; i++) {
        createJoinNodes(joins[i], parent);
      }
    }
    if(joins instanceof Object && !(joins instanceof Array)) {

      for (var key in joins) {
        var parentIndex = getParentNode(key);
        if (typeof parent === 'number') {
          addLink(parent, parentIndex);
        }
        createJoinNodes(joins[key], parentIndex);
      }
    }
    if (typeof joins === 'string') {
      addJoinNode(parent, joins);
    }
  }

  function getParentNode(name) {
    for (var i = 0; i < graph.nodes.length; i++) {
      if (graph.nodes[i].key === name) {
        return i;
      }
    }
    graph.nodes.push({
      name: name,
      key: name
    });
    return i++;
  }


  function addJoinNode(parent, name) {
    var nodeIndex;
    for (var i = 0; i < graph.nodes.length; i++) {
      if (graph.nodes[i].key === name) {
        nodeIndex = i;
      }
    }
    addLink(parent, nodeIndex);
  }

  function createNode(name, specs) {
    return {
      name: name, 
      shoulds: specs, 
      depth: depth, 
      key: fullContext.match(new RegExp(name+'$')) ? fullContext : name
    };
  }

  function addNode(name, specs) {
    var index = graph.nodes.length;
    graph.nodes.push(createNode(name, specs));
    return index;
  }
  
  function mergeNode(index, name, specs) {
    graph.nodes[index] = merge.recursive(graph.nodes[index],createNode(name,specs));
  }

  function addLink(source, target) {
    var match;
    for (var i = 0; i < graph.links.length; i++) {
      if (graph.links[i].source == source && graph.links[i].target == target) {
        match = true;
      }
    }

    if (!match) {
      graph.links.push({ source: source, target: target });
    }
  }

  function traverseMap(map, parents, node) {
    depth++;
    var mapPointer = map[parents[0]];
    if ( mapPointer && parents.length > 1) {
      parents.splice(0, 1);
      return traverseMap(mapPointer, parents, node);
    } 
    var currentContext = parents[0];
    mapPointer = map;
    if( mapPointer.hasOwnProperty(currentContext)){
      mergeNode(mapPointer[currentContext]._index,currentContext, node.specs);
    } else {
      mapPointer[currentContext] = {
        '_index': addNode(currentContext, (parents.length > 1) ? [] : node.specs)
      };
      if(map._index !== undefined) {
        addLink(map._index, mapPointer[currentContext]._index);
      }
    }

    if (parents.length > 1) {
      parents.splice(0, 1);
      return traverseMap(mapPointer[currentContext], parents, node);
    }
  }

  function addContext(node) {
    for (var i = 0; i < node._parents.length; i++) {
      depth = -1;
      traverseMap(nodeMap, node._parents, node);
    }
  }

  for (var key in contexts) {
    fullContext = key;
    addContext(contexts[key], key);
  }
  createJoinNodes(joins);
  return graph;
}
382045
public void init(ScreenLocation itsLocation, BasePanel parentScreen, Converter fieldConverter, int iDisplayFieldDesc, Map<String, Object> properties)
    {
        m_converterField = null;
        m_screenParent = null;
        
        if (itsLocation == null) if (parentScreen != null)
            itsLocation = parentScreen.getNextLocation(ScreenConstants.NEXT_LOGICAL, ScreenConstants.SET_ANCHOR); 
        m_itsLocation = itsLocation;

        m_bIsFocusTarget = true;
        m_bEnabled = true;
        m_screenParent = parentScreen;
        m_converterField = fieldConverter;
        m_iDisplayFieldDesc = iDisplayFieldDesc;    // The value passed in is...

        if (m_screenParent != null)
        {
            if (itsLocation.getLocationConstant() != ScreenConstants.FIRST_SCREEN_LOCATION)
                m_screenParent.addSField(this);
            else
                m_screenParent.addSField(this, 0);
        }
        boolean bEditableControl = true;
        if (this.getScreenFieldView() == null)
            this.setScreenFieldView(this.setupScreenFieldView(bEditableControl));
        this.getScreenFieldView().addPhysicalControl();
        if (m_converterField != null)
            m_converterField.addComponent(this);        // Have the field add me to its list for display
        if (this.getDisplayFieldDesc(this)) if (this.getSeparateFieldDesc()) if (m_converterField != null)
            this.setupControlDesc();
    }
403038
function ObjectCollection(parent) {
    tr.model.EventContainer.call(this);
    this.parent = parent;
    this.instanceMapsById_ = {}; // id -> TimeToObjectInstanceMap
    this.instancesByTypeName_ = {};
    this.createObjectInstance_ = this.createObjectInstance_.bind(this);
  }
927500
function fromRawMappings(modules: Array<ModuleTransport>): Generator {
  const generator = new Generator();
  let carryOver = 0;

  for (var j = 0, o = modules.length; j < o; ++j) {
    var module = modules[j];
    var {code, map} = module;

    if (Array.isArray(map)) {
      addMappingsForFile(generator, map, module, carryOver);
    } else if (map != null) {
      throw new Error(
        `Unexpected module with full source map found: ${module.sourcePath}`
      );
    }

    carryOver = carryOver + countLines(code);
  }

  return generator;
}
208247
def stage(obj, parent=None, member=None):
    
    obj = Staged(obj, parent, member)

    if isinstance(obj, Mapping):
        for key, value in obj.items():
            stage(value, obj, key)
    elif isinstance(obj, Sequence) and not isinstance(obj, string_types):
        for index, value in enumerate(obj):
            stage(value, obj, index)
    elif isinstance(obj, Set):
        for value in obj:
            stage(value, obj, None)

    return obj
561336
function (subMesh) {
                var mesh = subMesh.getRenderingMesh();
                if (_this._meshExcluded(mesh)) {
                    return;
                }
                var scene = mesh.getScene();
                var engine = scene.getEngine();
                // Culling
                engine.setState(subMesh.getMaterial().backFaceCulling);
                // Managing instances
                var batch = mesh._getInstancesRenderList(subMesh._id);
                if (batch.mustReturn) {
                    return;
                }
                var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
                if (_this.isReady(subMesh, hardwareInstancedRendering)) {
                    var effect = _this._volumetricLightScatteringPass;
                    if (mesh === _this.mesh) {
                        if (subMesh.effect) {
                            effect = subMesh.effect;
                        }
                        else {
                            effect = subMesh.getMaterial().getEffect();
                        }
                    }
                    engine.enableEffect(effect);
                    mesh._bind(subMesh, effect, BABYLON.Material.TriangleFillMode);
                    if (mesh === _this.mesh) {
                        subMesh.getMaterial().bind(mesh.getWorldMatrix(), mesh);
                    }
                    else {
                        var material = subMesh.getMaterial();
                        _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
                        // Alpha test
                        if (material && material.needAlphaTesting()) {
                            var alphaTexture = material.getAlphaTestTexture();
                            _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
                            if (alphaTexture) {
                                _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
                            }
                        }
                        // Bones
                        if (mesh.useBones && mesh.computeBonesUsingShaders) {
                            _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
                        }
                    }
                    // Draw
                    mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, BABYLON.Material.TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
                }
            }
433436
function resolve(projections, projection) {
  if (_.isArray(projection)) {
    const net = {};

    for (const proj of projection) {
      _.merge(net, resolve(projections, proj));
    }

    return net;
  } else if (_.isObject(projection)) {
    return projection;
  } else if (_.isString(projection)) {
    const rslt = projections[projection];

    if (!rslt) {
      throw new Error(`No project named "${projection}"`);
    }

    return rslt;
  } else {
    throw new Error('invalid projection');
  }
}
810015
def _one_projector(args: Dict[str, Any], index: int) -> Union[int, np.ndarray]:
    """"""
    num_shard_qubits = args['num_shard_qubits']
    shard_num = args['shard_num']
    if index >= num_shard_qubits:
        return _kth_bit(shard_num, index - num_shard_qubits)
    return _zero_one_vects(args)[index]
985530
public static Map<ModuleAdapter<?>, Object> loadModules(Loader loader,
      Object[] seedModulesOrClasses) {
    Map<ModuleAdapter<?>, Object> seedAdapters =
        new LinkedHashMap<ModuleAdapter<?>, Object>(seedModulesOrClasses.length);
    for (int i = 0; i < seedModulesOrClasses.length; i++) {
      if (seedModulesOrClasses[i] instanceof Class<?>) {
        ModuleAdapter<?> adapter = loader.getModuleAdapter((Class<?>) seedModulesOrClasses[i]);
        seedAdapters.put(adapter, adapter.newModule());
      } else {
        ModuleAdapter<?> adapter = loader.getModuleAdapter(seedModulesOrClasses[i].getClass());
        seedAdapters.put(adapter, seedModulesOrClasses[i]);
      }
    }

    // Add the adapters that we have module instances for. This way we won't
    // construct module objects when we have a user-supplied instance.
    Map<ModuleAdapter<?>, Object> result =
        new LinkedHashMap<ModuleAdapter<?>, Object>(seedAdapters);

    // Next collect included modules
    Map<Class<?>, ModuleAdapter<?>> transitiveInclusions =
        new LinkedHashMap<Class<?>, ModuleAdapter<?>>();
    for (ModuleAdapter<?> adapter : seedAdapters.keySet()) {
      collectIncludedModulesRecursively(loader, adapter, transitiveInclusions);
    }
    // and create them if necessary
    for (ModuleAdapter<?> dependency : transitiveInclusions.values()) {
      if (!result.containsKey(dependency)) {
        result.put(dependency, dependency.newModule());
      }
    }
    return result;
  }
567758
function() {
        // If the projections differ we need to reproject
        var bounds;
        if (this.ovmap.getProjection() != this.map.getProjection()) {
            bounds = this.map.getExtent().transform(
                this.map.getProjectionObject(), 
                this.ovmap.getProjectionObject() );
        } else {
            bounds = this.map.getExtent();
        }
        var pxBounds = this.getRectBoundsFromMapBounds(bounds);
        if (pxBounds) {
            this.setRectPxBounds(pxBounds);
        }
    }