Private transform method of a Transformer. This serves as batch-prediction method for our purposes.
496229
def _transform(self, df):
        
        output_col = self.getOutputCol()
        label_col = self.getLabelCol()
        new_schema = copy.deepcopy(df.schema)
        new_schema.add(StructField(output_col, StringType(), True))

        rdd = df.rdd.coalesce(1)
        features = np.asarray(
            rdd.map(lambda x: from_vector(x.features)).collect())
        # Note that we collect, since executing this on the rdd would require model serialization once again
        model = model_from_yaml(self.get_keras_model_config())
        model.set_weights(self.weights.value)
        predictions = rdd.ctx.parallelize(
            model.predict_classes(features)).coalesce(1)
        predictions = predictions.map(lambda x: tuple(str(x)))

        results_rdd = rdd.zip(predictions).map(lambda x: x[0] + x[1])
        results_df = df.sql_ctx.createDataFrame(results_rdd, new_schema)
        results_df = results_df.withColumn(
            output_col, results_df[output_col].cast(DoubleType()))
        results_df = results_df.withColumn(
            label_col, results_df[label_col].cast(DoubleType()))

        return results_df
147066
public static <T,K,V> Observable.Transformer<T,ImmutableMap<K,V>> toImmutableMap(final Func1<T,K> keyMapper, final Func1<T,V> valueMapper) {
        return new Observable.Transformer<T,ImmutableMap<K,V>>() {
            @Override
            public Observable<ImmutableMap<K, V>> call(Observable<T> observable) {
                return observable.collect(new Func0<ImmutableMap.Builder<K, V>>() {
                    @Override
                    public ImmutableMap.Builder<K, V> call() {
                        return ImmutableMap.builder();
                    }
                }, new Action2<ImmutableMap.Builder<K, V>, T>() {
                    @Override
                    public void call(ImmutableMap.Builder<K, V> builder, T t) {
                        builder.put(keyMapper.call(t), valueMapper.call(t));
                    }
                })
                .map(new Func1<ImmutableMap.Builder<K, V>, ImmutableMap<K, V>>() {
                    @Override
                    public ImmutableMap<K, V> call(ImmutableMap.Builder<K, V> builder) {
                        return builder.build();
                    }
                });
            }
        };
    }
384595
public static TransformerFactory newTransformerFactory( String factoryClassName, ClassLoader classLoader )
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
    {
        // use reflection to avoid JAXP 1.4 (and hence JDK6) requirement

        Class<?>[] methodTypes = new Class[] { String.class, ClassLoader.class };

        Method method = TransformerFactory.class.getDeclaredMethod( "newInstance", methodTypes );

        Object[] methodArgs = new Object[] { factoryClassName, classLoader };

        return (TransformerFactory) method.invoke( null, methodArgs );
    }
352997
private Collection<Integer> transform(StreamTransformation<?> transform) {

		if (alreadyTransformed.containsKey(transform)) {
			return alreadyTransformed.get(transform);
		}

		LOG.debug("Transforming " + transform);

		if (transform.getMaxParallelism() <= 0) {

			// if the max parallelism hasn't been set, then first use the job wide max parallelism
			// from the ExecutionConfig.
			int globalMaxParallelismFromConfig = env.getConfig().getMaxParallelism();
			if (globalMaxParallelismFromConfig > 0) {
				transform.setMaxParallelism(globalMaxParallelismFromConfig);
			}
		}

		// call at least once to trigger exceptions about MissingTypeInfo
		transform.getOutputType();

		Collection<Integer> transformedIds;
		if (transform instanceof OneInputTransformation<?, ?>) {
			transformedIds = transformOneInputTransform((OneInputTransformation<?, ?>) transform);
		} else if (transform instanceof TwoInputTransformation<?, ?, ?>) {
			transformedIds = transformTwoInputTransform((TwoInputTransformation<?, ?, ?>) transform);
		} else if (transform instanceof SourceTransformation<?>) {
			transformedIds = transformSource((SourceTransformation<?>) transform);
		} else if (transform instanceof SinkTransformation<?>) {
			transformedIds = transformSink((SinkTransformation<?>) transform);
		} else if (transform instanceof UnionTransformation<?>) {
			transformedIds = transformUnion((UnionTransformation<?>) transform);
		} else if (transform instanceof SplitTransformation<?>) {
			transformedIds = transformSplit((SplitTransformation<?>) transform);
		} else if (transform instanceof SelectTransformation<?>) {
			transformedIds = transformSelect((SelectTransformation<?>) transform);
		} else if (transform instanceof FeedbackTransformation<?>) {
			transformedIds = transformFeedback((FeedbackTransformation<?>) transform);
		} else if (transform instanceof CoFeedbackTransformation<?>) {
			transformedIds = transformCoFeedback((CoFeedbackTransformation<?>) transform);
		} else if (transform instanceof PartitionTransformation<?>) {
			transformedIds = transformPartition((PartitionTransformation<?>) transform);
		} else if (transform instanceof SideOutputTransformation<?>) {
			transformedIds = transformSideOutput((SideOutputTransformation<?>) transform);
		} else {
			throw new IllegalStateException("Unknown transformation: " + transform);
		}

		// need this check because the iterate transformation adds itself before
		// transforming the feedback edges
		if (!alreadyTransformed.containsKey(transform)) {
			alreadyTransformed.put(transform, transformedIds);
		}

		if (transform.getBufferTimeout() >= 0) {
			streamGraph.setBufferTimeout(transform.getId(), transform.getBufferTimeout());
		}
		if (transform.getUid() != null) {
			streamGraph.setTransformationUID(transform.getId(), transform.getUid());
		}
		if (transform.getUserProvidedNodeHash() != null) {
			streamGraph.setTransformationUserHash(transform.getId(), transform.getUserProvidedNodeHash());
		}

		if (!streamGraph.getExecutionConfig().hasAutoGeneratedUIDsEnabled()) {
			if (transform.getUserProvidedNodeHash() == null && transform.getUid() == null) {
				throw new IllegalStateException("Auto generated UIDs have been disabled " +
					"but no UID or hash has been assigned to operator " + transform.getName());
			}
		}

		if (transform.getMinResources() != null && transform.getPreferredResources() != null) {
			streamGraph.setResources(transform.getId(), transform.getMinResources(), transform.getPreferredResources());
		}

		return transformedIds;
	}
1268003
def _transform(self, *transforms):
        
        sequence = None
        for transform in transforms:
            if sequence:
                sequence = Sequence(sequence, transform=transform)
            else:
                sequence = Sequence(self, transform=transform)
        return sequence
1033294
private void initializeTransformer() {
    TransformerFactory transformerFactory = new TransformerFactory();
    transformer = transformerFactory.getTransformer(topViewResize, dragView, this);
    transformer.setViewHeight(topViewHeight);
    transformer.setXScaleFactor(scaleFactorX);
    transformer.setYScaleFactor(scaleFactorY);
    transformer.setMarginRight(marginRight);
    transformer.setMarginBottom(marginBottom);
  }
274181
private Transformer createTransformer(boolean indent) {

    try {
      Transformer result = this.transformerFactory.newTransformer();
      if (indent) {
        result.setOutputProperty(OutputKeys.INDENT, "yes");
      }
      return result;
    } catch (TransformerConfigurationException e) {
      throw new IllegalStateException("XML Transformer misconfigured!" + " Probably your JVM does not support the required JAXP version!", e);
    }
  }
534962
public void setPresetTransformer(String transformerName){
        for(Transformer t : Transformer.values()){
            if(t.equals(transformerName)){
                setPresetTransformer(t);
                return;
            }
        }
    }
1044492
public <A> JFeatureSpec<T> required(final SerializableFunction<T, A> f,
                                      final Transformer<A, ?, ?> t) {
    Function1<T, A> g = JavaOps.requiredFn(f);
    return wrap(self.required(g, t));
  }
880411
function transformer(data) {
        var newData = {};
        var keys = Object.keys(data), length = keys.length, key, i;
        for ( i = 0; i < length; i++) {
          key = keys[i];
          newData[key] = data[key];
        }
        return newData;
      }
1150753
private static synchronized TransformerFactory getTransformerFactory()
    {
        if (transformerFactory == null)
        {
            transformerFactory = TransformerFactory.newInstance();
            transformerFactory.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_DTD, "");
            transformerFactory.setAttribute(javax.xml.XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");
        }
        return transformerFactory;
    }
121222
@UnstableApi
    public final void setPrivateKeyMethod(OpenSslPrivateKeyMethod method) {
        ObjectUtil.checkNotNull(method, "method");
        Lock writerLock = ctxLock.writeLock();
        writerLock.lock();
        try {
            SSLContext.setPrivateKeyMethod(ctx, new PrivateKeyMethod(engineMap, method));
        } finally {
            writerLock.unlock();
        }
    }
814265
private static void generateSingleReadMethod(PrefsEntity entity) {
		// read method
		PrefsTransform transform;
		Converter<String, String> converter = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_CAMEL);

		for (PrefsProperty item : entity.getCollection()) {
			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("get" + converter.convert(item.getName())).addModifiers(Modifier.PUBLIC)
					.addJavadoc("reads property <code>$L</code> from shared pref with key <code>$L</code>\n\n", item.getName(), item.getPreferenceKey())
					.addJavadoc("@return property $L value\n", item.getName()).returns(item.getPropertyType().getTypeName());

			if (item.hasTypeAdapter()) {
				transform = PrefsTransformer.lookup(item.typeAdapter.getDataTypeTypename());
			} else {
				transform = PrefsTransformer.lookup(item);
			}

			transform.generateReadProperty(methodBuilder, "prefs", typeName(item.getElement().asType()), "defaultBean", item, false, ReadType.RETURN);

			builder.addMethod(methodBuilder.build());
		}

	}
1320872
public Transformer<String, Integer> run() {
        return new Transformer<String, Integer>() {
            @Override
            public Observable<Integer> call(Observable<String> commands) {
                return run(commands);
            }
        };
    }
1109408
public Feature transform(Source input) throws TransformationException {
        if (input == null) {
            return null;
        } else {
            EntityClassReader reader = EntityClassReader.getClassReaderFor(input.getClass());
            try {
                return reader.asFeature(input);
            } catch (InvalidObjectReaderException e) {
                // Can't happen!
                throw new TransformationException("Transformation failed", e);
            }
        }
    }
438846
@Nonnull
    public <T> Word<T> transform(Function<? super I, ? extends T> transformer) {
        int len = length();
        Object[] array = new Object[len];
        int i = 0;
        for (I symbol : this) {
            array[i++] = transformer.apply(symbol);
        }
        return new SharedWord<>(array);
    }
583786
public static synchronized <T> IExpectationSetters<T> expectPrivate(Object instance, String methodName,
                                                                        Class<?> where, Class<?>[] parameterTypes, Object... arguments) throws Exception {
        if (instance == null) {
            throw new IllegalArgumentException("Instance or class to expect cannot be null.");
        }
        Method[] methods = null;
        if (methodName != null) {
            if (parameterTypes == null) {
                methods = Whitebox.getMethods(where, methodName);
            } else {
                methods = new Method[]{Whitebox.getMethod(where, methodName, parameterTypes)};
            }
        }
        Method methodToExpect;
        if (methods != null && methods.length == 1) {
            methodToExpect = methods[0];
        } else {
            methodToExpect = WhiteboxImpl.findMethodOrThrowException(instance, null, methodName, arguments);
        }

        return doExpectPrivate(instance, methodToExpect, arguments);
    }