converts measurments tables from magic 2 to 3 (direction=magic3)
    or from model 3 to 2.5 (direction=magic2) [not available]
322900
def convert_meas(direction, Rec):
    
    if direction == 'magic3':
        columns = meas_magic2_2_magic3_map
        MeasRec = {}
        for key in columns:
            if key in list(Rec.keys()):
                # transfer info and change column name to data model 3.0
                MeasRec[columns[key]] = Rec[key]
        return MeasRec
    else:  # haven't added this way yet
        pass
1096456
def int2magic(magic_int):
    

    if (sys.version_info >= (3, 0)):
        return struct.pack('<Hcc', magic_int, bytes('\r', 'utf-8'), bytes('\n', 'utf-8'))
    else:
        return struct.pack('<Hcc', magic_int, '\r', '\n')
1008584
def check_for_meas_file(self):
        
        if self.data_model_num == 2:
            meas_file_name = "magic_measurements.txt"
            dm = "2.5"
        else:
            meas_file_name = "measurements.txt"
            dm = "3.0"
        if not os.path.isfile(os.path.join(self.WD, meas_file_name)):
            pw.simple_warning("Your working directory must have a {} format {} file to run this step.  Make sure you have fully completed step 1 (import magnetometer file) and ALSO converted to 3.0., if necessary), then try again.\n\nIf you are trying to look at data downloaded from MagIC, you must unpack the txt file first. Some contributions do not contain measurement data, in which case you won't be able to use this function.".format(dm, meas_file_name))
            return False
        return True
101364
function() {
			// Converting the row height CSS parameters (e.g. _sap_ui_table_RowHeight) is too complex (CSS calc()).
			// Therefore, the base sizes are used and calculation is done in JavaScript.

			function getPixelValue(sThemeParameterName) {
				return TableUtils.convertCSSSizeToPixel(ThemeParameters.get(sThemeParameterName));
			}

			mBaseSize.undefined = getPixelValue("_sap_ui_table_BaseSize");
			mBaseSize.sapUiSizeCozy = getPixelValue("_sap_ui_table_BaseSizeCozy");
			mBaseSize.sapUiSizeCompact = getPixelValue("_sap_ui_table_BaseSizeCompact");
			mBaseSize.sapUiSizeCondensed = getPixelValue("_sap_ui_table_BaseSizeCondensed");
			iBaseBorderWidth = getPixelValue("_sap_ui_table_BaseBorderWidth");

			iRowHorizontalFrameSize = iBaseBorderWidth;
			mDefaultRowHeight.undefined = mBaseSize.undefined + iRowHorizontalFrameSize;
			mDefaultRowHeight.sapUiSizeCozy = mBaseSize.sapUiSizeCozy + iRowHorizontalFrameSize;
			mDefaultRowHeight.sapUiSizeCompact = mBaseSize.sapUiSizeCompact + iRowHorizontalFrameSize;
			mDefaultRowHeight.sapUiSizeCondensed = mBaseSize.sapUiSizeCondensed + iRowHorizontalFrameSize;

			mThemeParameters.navigationIcon = ThemeParameters.get("_sap_ui_table_NavigationIcon");
			mThemeParameters.deleteIcon = ThemeParameters.get("_sap_ui_table_DeleteIcon");
			mThemeParameters.resetIcon = ThemeParameters.get("_sap_ui_table_ResetIcon");
		}
553055
def dms_to_decimal(degrees, minutes, seconds, hemisphere):
    '''
    
    '''
    dms = float(degrees) + float(minutes) / 60 + float(seconds) / 3600
    if hemisphere in "WwSs":
        dms = -1 * dms

    return dms
1089909
def rotation_to_apply(self, only90s=False, no_mirror=False):
        
        rotation = self.request.rotation_deg
        if (no_mirror and self.request.rotation_mirror):
            raise IIIFError(code=501, parameter="rotation",
                            text="This implementation does not support mirroring.")
        if (only90s and (rotation != 0.0 and rotation != 90.0 and
                         rotation != 180.0 and rotation != 270.0)):
            raise IIIFError(code=501, parameter="rotation",
                            text="This implementation supports only 0,90,180,270 degree rotations.")
        return(self.request.rotation_mirror, rotation)
381549
def _possibly_convert_objects(values):
    
    return np.asarray(pd.Series(values.ravel())).reshape(values.shape)
522580
def _convert_before_2_0_0_b3(self, dynamips_id):
        
        dynamips_dir = self.project.module_working_directory(self.manager.module_name.lower())
        for path in glob.glob(os.path.join(glob.escape(dynamips_dir), "configs", "i{}_*".format(dynamips_id))):
            dst = os.path.join(self._working_directory, "configs", os.path.basename(path))
            if not os.path.exists(dst):
                try:
                    shutil.move(path, dst)
                except OSError as e:
                    raise DynamipsError("Can't move {}: {}".format(path, str(e)))
        for path in glob.glob(os.path.join(glob.escape(dynamips_dir), "*_i{}_*".format(dynamips_id))):
            dst = os.path.join(self._working_directory, os.path.basename(path))
            if not os.path.exists(dst):
                try:
                    shutil.move(path, dst)
                except OSError as e:
                    raise DynamipsError("Can't move {}: {}".format(path, str(e)))
1173736
def convert(self, value, fromunits, tounits):
        ''''''
        if fromunits == tounits:
            return value
        if (fromunits,tounits) in self.unitmap:
            return value * self.unitmap[(fromunits,tounits)]
        if (tounits,fromunits) in self.unitmap:
            return value / self.unitmap[(tounits,fromunits)]
        raise fgFDMError("unknown unit mapping (%s,%s)" % (fromunits, tounits))
1236791
def _internal_convert(inp):
    
    '''
    
    '''

    # Read the "magic number" - 4 bytes.
    try:
        mn = struct.unpack('>BBBB', inp.read(4))
    except struct.error:
        raise FormatError(struct.error)

    # First two bytes are always zero, check it.
    if mn[0] != 0 or mn[1] != 0:
        msg = ("Incorrect first two bytes of the magic number: " +
               "0x{0:02X} 0x{1:02X}".format(mn[0], mn[1]))
        raise FormatError(msg)

    # 3rd byte is the data type code.
    dtype_code = mn[2]
    if dtype_code not in _DATA_TYPES_IDX:
        msg = "Incorrect data type code: 0x{0:02X}".format(dtype_code)
        raise FormatError(msg)

    # 4th byte is the number of dimensions.
    dims = int(mn[3])

    # See possible data types description.
    dtype, dtype_s, el_size = _DATA_TYPES_IDX[dtype_code]

    # 4-byte integer for length of each dimension.
    try:
        dims_sizes = struct.unpack('>' + 'I' * dims, inp.read(4 * dims))
    except struct.error as e:
        raise FormatError('Dims sizes: {0}'.format(e))

    # Full length of data.
    full_length = reduce(operator.mul, dims_sizes, 1)

    # Create a numpy array from the data
    try:
        result_array = numpy.frombuffer(
            inp.read(full_length * el_size),
            dtype=numpy.dtype(dtype)
        ).reshape(dims_sizes)
    except ValueError as e:
        raise FormatError('Error creating numpy array: {0}'.format(e))

    # Check for superfluous data.
    if len(inp.read(1)) > 0:
        raise FormatError('Superfluous data detected.')

    return result_array
1051805
function isOfMinimumVersion(version, minimumVersion) {
                if (version == null || minimumVersion == null) {
                    return false;
                }
                else if (version == null) {
                    return true;
                }
                var actualVersionPieces = ("" + version).split("."),
                    pieces = minimumVersion.split("."),
                    numberOfPieces = pieces.length;
    
                for (var i = 0; i < numberOfPieces; i++) {
                    var piece = parseInt(pieces[i], 10),
                        actualPiece = parseInt(actualVersionPieces[i], 10);
    
                    if (typeof actualPiece === "undefined") {
                        break;
                    }
                    else if (actualPiece > piece) {
                        break;
                    }
                    else if (actualPiece === piece) {
                        continue;
                    }
                    else {
                        return false;
                    }
                }
    
                return true;
            }
955675
def simxGetObjectOrientation(clientID, objectHandle, relativeToObjectHandle, operationMode):
    '''
    
    '''
    eulerAngles = (ct.c_float*3)()
    ret = c_GetObjectOrientation(clientID, objectHandle, relativeToObjectHandle, eulerAngles, operationMode)
    arr = []
    for i in range(3):
        arr.append(eulerAngles[i])
    return ret, arr
399936
def convert(self, values, nan_rep, encoding, errors):
        

        self.values = Int64Index(np.arange(self.table.nrows))
        return self
944641
def get_non_magic_cols(self):
        
        table_dm = self.data_model.dm[self.dtype]
        approved_cols = table_dm.index
        unrecognized_cols = (set(self.df.columns) - set(approved_cols))
        return unrecognized_cols
1369823
def to_si(self, values, from_unit):
        """"""
        if from_unit == 'W/m2-K':
            return values, from_unit
        else:
            return self.to_unit(values, 'W/m2-K', from_unit), 'W/m2-K'
374692
def mapping(self, kdims=None, vdims=None, **kwargs):
        ""
        if config.future_deprecations:
            self.param.warning(
                "The mapping method is deprecated and should no "
                "longer be used. Use another one of the common "
                "formats instead, e.g. .dframe, .array or .columns.")

        length = len(self)
        if not kdims: kdims = self.kdims
        if kdims:
            keys = zip(*[self.dimension_values(dim.name)
                         for dim in self.kdims])
        else:
            keys = [()]*length

        if not vdims: vdims = self.vdims
        if vdims:
            values = zip(*[self.dimension_values(dim.name)
                           for dim in vdims])
        else:
            values = [()]*length
        return OrderedDict(zip(keys, values))
300338
function adapt(callback) {
      /*
       * For Graphics Magick docs: http://www.graphicsmagick.org/GraphicsMagick.html#details-geometry
       * Inspiration: http://stackoverflow.com/questions/14705152/thumbnails-from-graphics-magick-without-upscaling
       */

      co(function*() {
        let externalStream = config.stream(path);

        if (!externalStream) {
          // Ensure the file exists on the filesystem.
          try {
            yield Q.nfcall(fs.stat, mkpath(imagesDir, matches.path));
          } catch (e) {
            return next();
          }
        }

        // Stream the image into a buffer. (passing a stream directly into GM was causing problems with gcloud streams)
        let stream = externalStream || fs.createReadStream(mkpath(imagesDir, path));

        try {
          var buffer = yield Q.nfcall(stream2buffer, stream);
        } catch (e) {
          return callback(e);
        }

        let img = gm(buffer);
        
        // Set up some options
        img
          // .filter('Triangle')
          // Not sure if these work in GM, but they are IM options
          // .define('filter:support=2')
          // .define('jpeg:fancy-upsampling=off')
          // .unsharp(0.25, 0.25, 8, 0.065)
          // .colors(136)
          // .dither(false)
          // .colorspace('sRGB')
          .out('-background', bg || (mimetype == 'image/png' ? 'transparent' : 'white'));

        img.size(function(err, nativeSize) {
          if (err || typeof nativeSize == 'undefined' || typeof nativeSize.width == 'undefined' || typeof nativeSize.height == 'undefined') {
            return callback(err || 'Failed to retrieve image dimensions.');
          }

          /**
           * Validate dimensions & determine sizing rules.
           */
          let imageWidth = width, imageHeight = height;       // The size of the image itself
          let canvasWidth = width, canvasHeight = height;     // The size of the canvas around the image
          let allowResize;

          // If we're resizing, ensure we never exceed the native image dimensions.
          if (!imageWidth && !imageHeight) {
            // Using native image size, no resizing necessary.
            imageWidth = nativeSize.width;
            imageHeight = nativeSize.height;
            canvasWidth = nativeSize.width;
            canvasHeight = nativeSize.height;

            allowResize = false;
          } else if ((imageWidth && !imageHeight) || (!imageWidth && imageHeight)) {
            // One size provided, scale the other proportionally.
            if (imageWidth) {
              imageHeight = Math.round(imageWidth * (nativeSize.height / nativeSize.width));
              canvasHeight = imageHeight >= nativeSize.height ? nativeSize.height : imageHeight;  // trim extra space from canvas height
            } else {
              imageWidth = Math.round(imageHeight * (nativeSize.width / nativeSize.height));
              canvasWidth = imageWidth >= nativeSize.width ? nativeSize.width : imageWidth;       // trim extra space from canvas width
            }

            allowResize = imageWidth < nativeSize.width && imageHeight < nativeSize.height;
          } else {
            // Two sizes provided.
            if (imageWidth > nativeSize.width && imageHeight > nativeSize.height) {
              // Do not exceed the native image size.
              imageWidth = nativeSize.width;
              imageHeight = nativeSize.height;
              allowResize = false;
            } else {
              if (imageWidth > nativeSize.width) {
                // Preserve requested height, but correct the width.
                imageWidth = 0;   // auto
              } else if (imageHeight > nativeSize.height) {
                // Preserve requested width, but correct the height.
                imageHeight = 0;  // auto
              }

              // Sizes are fine, fit into the requested box.
              allowResize = true;
            }
          }

          /**
           * Adapt the image.
           */
          
          if (mode == MODE_ASPECT_FILL) {
            img
              .resize(width, height, '^')
              .gravity('Center')
              .crop(width, height);
          } else if (mode == MODE_ASPECT_FIT) {
            if (allowResize) {
              let w = imageWidth == 0 ? null : (crop ? `${width}^` : imageWidth);
              let h = imageHeight == 0 ? null : (crop ? `${height}^` : imageHeight);

              img = img.resize(w, h);
            }

            img
              .gravity('Center')
              .extent(canvasWidth, canvasHeight);
          }

          img
            .quality(config.default.quality)
            .strip()
            .stream(function(err, stdout, stderr) {
              if (err) {
                return callback(err);
              }

              // calling .trim() on a GM object seems to have no effect,
              // so we need to perform that on the buffer if necessary.
              if (!trim) {
                return callback(null, stdout);
              }

              gm(stdout).trim().stream(function(err, stdout, stderr) {
                if (err) {
                  return callback(err);
                }

                callback(null, stdout);
              });
            });

        }); // /size
      }); // /co
    }