<commit_before>from py4j.java_gateway import java_import
from pymrgeo.rastermapop import RasterMapOp
from unittest import TestCase
from functools import partial

class RasterMapOpTestSupport(TestCase):

    def __init__(self, mrgeo):
        self._mrgeo = mrgeo
        jvm = self._mrgeo._get_jvm()
        # Import the raster map op test support class and all other needed classes
        java_import(jvm, "org.mrgeo.core.*")
        java_import(jvm, "org.mrgeo.data.*")
        java_import(jvm, "org.mrgeo.data.raster.RasterWritable")
        java_import(jvm, "org.mrgeo.mapalgebra.utils.StandaloneRasterMapOpTestSupport")
        java_import(jvm, "org.mrgeo.mapalgebra.raster.RasterMapOp")
        java_import(jvm, "org.apache.spark.rdd.RDD")
        java_import(jvm, "org.mrgeo.utils.tms.*")
        self._rasterMapOpTestSupport = jvm.StandaloneRasterMapOpTestSupport()
        self._jvm = jvm
        self._sparkContext = mrgeo.sparkContext
        self._rasterMapOpTestSupport.useSparkContext(self._sparkContext)


    # Default image no data
        self._defaultImageNoData = self._getDoubleArray([0.0])
        # Default image initial data
        self._defaultImageInitialData = self._getDoubleArray([1.0])


    def createRasterMapOp(self, tileIds, zoomLevel, tileSize, imageNoData = None, imageInitialData = None):
        if imageNoData is None:
            imageNoData = self._defaultImageNoData
        if imageInitialData is None:
            imageInitialData = self._defaultImageInitialData

        #Capture image initial and nodata to compare against
        self._imageInitialData = imageInitialData
        self._imageNoData = imageNoData
        mapop = self._rasterMapOpTestSupport.createRasterMapOp(tileIds, zoomLevel, tileSize, imageNoData, imageInitialData)
        return RasterMapOp(mapop=mapop, gateway=self._mrgeo.gateway, context=self._sparkContext)

    def createRasterMapOpWithBounds(self, tileIds, zoomLevel, tileSize, w, s, e, n, imageNoData = None,
                                    imageInitialData = None):
        if imageNoData is None:
            imageNoData = self._defaultImageNoData
        if imageInitialData is None:
            imageInitialData = self._defaultImageInitialData

        bounds = self._jvm.Bounds(w, s, e, n)
        mapop = self._rasterMapOpTestSupport.createRasterMapOpWithBounds(tileIds, zoomLevel, tileSize, bounds, imageNoData, imageInitialData)<commit_msg>Add missing name parameter<commit_after>from py4j.java_gateway import java_import
from pymrgeo.rastermapop import RasterMapOp
from unittest import TestCase
from functools import partial

class RasterMapOpTestSupport(TestCase):

    def __init__(self, mrgeo):
        self._mrgeo = mrgeo
        jvm = self._mrgeo._get_jvm()
        # Import the raster map op test support class and all other needed classes
        java_import(jvm, "org.mrgeo.core.*")
        java_import(jvm, "org.mrgeo.data.*")
        java_import(jvm, "org.mrgeo.data.raster.RasterWritable")
        java_import(jvm, "org.mrgeo.mapalgebra.utils.StandaloneRasterMapOpTestSupport")
        java_import(jvm, "org.mrgeo.mapalgebra.raster.RasterMapOp")
        java_import(jvm, "org.apache.spark.rdd.RDD")
        java_import(jvm, "org.mrgeo.utils.tms.*")
        self._rasterMapOpTestSupport = jvm.StandaloneRasterMapOpTestSupport()
        self._jvm = jvm
        self._sparkContext = mrgeo.sparkContext
        self._rasterMapOpTestSupport.useSparkContext(self._sparkContext)


    # Default image no data
        self._defaultImageNoData = self._getDoubleArray([0.0])
        # Default image initial data
        self._defaultImageInitialData = self._getDoubleArray([1.0])


    def createRasterMapOp(self, tileIds, zoomLevel, tileSize, name='', imageNoData=None, imageInitialData=None):
        if imageNoData is None:
            imageNoData = self._defaultImageNoData
        if imageInitialData is None:
            imageInitialData = self._defaultImageInitialData

        #Capture image initial and nodata to compare against
        self._imageInitialData = imageInitialData
        self._imageNoData = imageNoData
        mapop = self._rasterMapOpTestSupport.createRasterMapOp(tileIds, zoomLevel, tileSize, name, imageNoData, imageInitialData)
        return RasterMapOp(mapop=mapop, gateway=self._mrgeo.gateway, context=self._sparkContext)

    def createRasterMapOpWithBounds(self, tileIds, zoomLevel, tileSize, w, s, e, n, name='', imageNoData=None,
                                    imageInitialData=None):
        if imageNoData is None:
            imageNoData = self._defaultImageNoData
        if imageInitialData is None:
            imageInitialData = self._defaultImageInitialData

        bounds = self._jvm.Bounds(w, s, e, n)
        mapop = self._rasterMapOpTestSupport.createRasterMapOpWithBounds(tileIds, zoomLevel, tileSize, name,
                                                                         bounds, imageNoData, imageInitialData)
{'fraction_non_alphanumeric': 0.08054772452678212, 'fraction_numerical': 0.002013693113169553, 'mean_word_length': 3.1219917012448133, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '135451', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1451, 'n_words': 304}