Return a MeasureDimension proxy, which wraps the partition to provide access to
        columns in terms of measures and dimensions
327697
def measuredim(self):
        """"""

        if isinstance(self, PartitionProxy):
            return MeasureDimensionPartition(self._obj)
        else:
            return MeasureDimensionPartition(self)
897905
def primary_measures(self):
        
        from ambry.valuetype.core import ROLE

        for c in self.columns:

            if not c.parent and c.role == ROLE.MEASURE:
                    yield c
695005
static Collection<Collection<MeasurementDTO>> measurementDTOs(Results<Measurement> measurements) {
        return Lists.newArrayList(Iterables.transform(measurements, new Function<Results.Row<Measurement>, Collection<MeasurementDTO>>() {

            @Override
            public Collection<MeasurementDTO> apply(Row<Measurement> input) {
                return Collections2.transform(input.getElements(), new Function<Measurement, MeasurementDTO>() {

                    @Override
                    public MeasurementDTO apply(Measurement input) {
                        return new MeasurementDTO(
                                input.getTimestamp().asMillis(),
                                new ResourceDTO(input.getResource().getId(), unwrapMap(input.getResource().getAttributes())),
                                input.getName(),
                                input.getValue(),
                                input.getAttributes());
                    }
                });
            }
        }));
    }
382810
def _construct_df(self, mol2_lines, col_names, col_types):
        """"""
        return self._atomsection_to_pandas(self._get_atomsection(mol2_lines),
                                           col_names=col_names,
                                           col_types=col_types)
1081573
def get_size(self):
        """"""
        self.curses.setupterm()
        return self.curses.tigetnum('cols'), self.curses.tigetnum('lines')
1007297
def create_measure(measure_files)
      hqmf_xml = measure_files.hqmf_xml
      # update the valueset info in each elm (update version and remove urn:oid)
      measure_files.cql_libraries.each { |cql_lib_files| modify_elm_valueset_information(cql_lib_files.elm) }

      measure = CQM::Measure.new(HQMFMeasureLoader.extract_fields(hqmf_xml))
      measure.cql_libraries = create_cql_libraries(measure_files.cql_libraries, measure.main_cql_library)
      measure.composite = measure_files.components.present?
      measure.calculation_method = @measure_details[:episode_of_care] ? 'EPISODE_OF_CARE' : 'PATIENT'
      measure.calculate_sdes = @measure_details[:calculate_sdes]

      hqmf_model = HQMF::Parser::V2CQLParser.new.parse(hqmf_xml) # TODO: move away from using V2CQLParser

      elms = measure.cql_libraries.map(&:elm)
      elm_valuesets = ValueSetHelpers.unique_list_of_valuesets_referenced_by_elms(elms)
      verify_hqmf_valuesets_match_elm_valuesets(elm_valuesets, hqmf_model)

      value_sets_from_single_code_references = ValueSetHelpers.make_fake_valuesets_from_single_code_references(elms, @vs_model_cache)
      measure.source_data_criteria = SourceDataCriteriaLoader.new(hqmf_xml, value_sets_from_single_code_references).extract_data_criteria
      measure.value_sets = value_sets_from_single_code_references
      measure.value_sets.concat(@value_set_loader.retrieve_and_modelize_value_sets_from_vsac(elm_valuesets)) if @value_set_loader.present?

      ## this to_json is needed, it doesn't actually produce json, it just makes a hash that is better
      ## suited for our uses (e.g. source_data_criteria goes from an array to a hash keyed by id)
      hqmf_model_hash = hqmf_model.to_json.deep_symbolize_keys!
      HQMFMeasureLoader.add_fields_from_hqmf_model_hash(measure, hqmf_model_hash)

      return measure
    end
619706
def convert(values, source_measure_or_unit_abbreviation, target_measure_or_unit_abbreviation):
    

    source_dimension = get_dimension_by_unit_measure_or_abbreviation(source_measure_or_unit_abbreviation)
    target_dimension = get_dimension_by_unit_measure_or_abbreviation(target_measure_or_unit_abbreviation)

    if source_dimension == target_dimension:
        source=JSONObject({})
        target=JSONObject({})
        source.unit_abbreviation, source.factor = _parse_unit(source_measure_or_unit_abbreviation)
        target.unit_abbreviation, target.factor = _parse_unit(target_measure_or_unit_abbreviation)

        source.unit_data = get_unit_by_abbreviation(source.unit_abbreviation)
        target.unit_data = get_unit_by_abbreviation(target.unit_abbreviation)

        source.conv_factor = JSONObject({'lf': source.unit_data.lf, 'cf': source.unit_data.cf})
        target.conv_factor = JSONObject({'lf': target.unit_data.lf, 'cf': target.unit_data.cf})

        if isinstance(values, float):
            # If values is a float => returns a float
            return (source.conv_factor.lf / target.conv_factor.lf * (source.factor * values)
                    + (source.conv_factor.cf - target.conv_factor.cf)
                    / target.conv_factor.lf) / target.factor
        elif isinstance(values, list):
            # If values is a list of floats => returns a list of floats
            return [(source.conv_factor.lf / target.conv_factor.lf * (source.factor * value)
                    + (source.conv_factor.cf - target.conv_factor.cf)
                    / target.conv_factor.lf) / target.factor for value in values]
    else:
        raise HydraError("Unit conversion: dimensions are not consistent.")
1197122
def size(self):
        
        return len(self._query_compiler.index) * len(self._query_compiler.columns)
683840
synchronized Dimension getPreferredSize() {
        return new Dimension(getFontWidth() * virtualTerminal.getTerminalSize().getColumns(),
                getFontHeight() * virtualTerminal.getTerminalSize().getRows());
    }
625621
private static <T, G extends T> void generateSetMeasuredDimension(DexMaker dexMaker,
                                                                      TypeId<G> generatedType,
                                                                      TypeId<T> baseType) {
        final String methodName = ViewMethod.SET_MEASURED_DIMENSION.getName();

        final MethodId<T, Void> superMethod = baseType.getMethod(VOID_TYPE, methodName, TypeId.INT,
                TypeId.INT);

        final MethodId<G, Void> callsSuperMethod = generatedType.getMethod(VOID_TYPE,
                ViewMethod.SET_MEASURED_DIMENSION.getInvokeName(), TypeId.INT, TypeId.INT);

        final Code code = dexMaker.declare(callsSuperMethod, PUBLIC);

        final Local<G> localThis = code.getThis(generatedType);
        final Local<Integer> localWidth = code.getParameter(0, TypeId.INT);
        final Local<Integer> localHeight = code.getParameter(1, TypeId.INT);
        code.invokeSuper(superMethod, null, localThis, localWidth, localHeight);
        code.returnVoid();
    }
1373258
def store(self, measurement):
        
        os.makedirs(self._getPathToMeasurementMetaDir(measurement.idAsPath), exist_ok=True)
        output = marshal(measurement, measurementFields)
        with open(self._getPathToMeasurementMetaFile(measurement.idAsPath), 'w') as outfile:
            json.dump(output, outfile)
        return output
684413
def table_measure(self, columns, content):
        
        dimensions = {}
        for row in content:
            i = 0
            for cell in row:
                # Calculate maximum from:
                dimensions[i] = max(
                        dimensions.get(i, 0),              # current column max width
                        len(cell),                         # current cell value width
                        len(columns[i].get('label', '')),  # column label width
                        columns[i].get('width_min', 0),    # configured column minimal width
                    )
                i += 1
        return dimensions
934715
def get_dimension_by_unit_measure_or_abbreviation(measure_or_unit_abbreviation,**kwargs):
    

    unit_abbreviation, factor = _parse_unit(measure_or_unit_abbreviation)

    units = db.DBSession.query(Unit).filter(Unit.abbreviation==unit_abbreviation).all()

    if len(units) == 0:
        raise HydraError('Unit %s not found.'%(unit_abbreviation))
    elif len(units) > 1:
        raise HydraError('Unit %s has multiple dimensions not found.'%(unit_abbreviation))
    else:
        dimension = db.DBSession.query(Dimension).filter(Dimension.id==units[0].dimension_id).one()
        return str(dimension.name)
309047
def measureSize(self, diff, chunkSize):
        
        (toUUID, fromUUID) = self.toArg.diff(diff)
        isInteractive = sys.stderr.isatty()
        return self.toObj.diff(self._client.measureSize(
            toUUID,
            fromUUID,
            diff.size,
            chunkSize,
            isInteractive,
        ))
493399
def df(unit = 'GB'):
    ''''''
    details = {}
    headers = ['Filesystem', 'Type', 'Size', 'Used', 'Available', 'Capacity', 'MountedOn']
    n = len(headers)

    unit = df_conversions[unit]
    p = subprocess.Popen(args = ['df', '-TP'], stdout = subprocess.PIPE) # -P prevents line wrapping on long filesystem names
    stdout, stderr = p.communicate()

    lines = stdout.split("\n")
    lines[0] = lines[0].replace("Mounted on", "MountedOn").replace("1K-blocks", "Size").replace("1024-blocks", "Size")
    assert(lines[0].split() == headers)

    lines = [l.strip() for l in lines if l.strip()]
    for line in lines[1:]:
        tokens = line.split()
        if tokens[0] == 'none': # skip uninteresting entries
            continue

        assert(len(tokens) == n)
        d = {}
        for x in range(1, len(headers)):
            d[headers[x]] = tokens[x]
        d['Size'] = float(d['Size']) / unit
        assert(d['Capacity'].endswith("%"))
        d['Use%'] = d['Capacity']
        d['Used'] = float(d['Used']) / unit
        d['Available'] = float(d['Available']) / unit
        d['Using'] = 100*(d['Used']/d['Size']) # same as Use% but with more precision

        if d['Type'].startswith('ext'):
            pass
            d['Using'] += 5 # ext2, ext3, and ext4 reserve 5% by default
        else:
            ext3_filesystems = ['ganon:', 'kortemmelab:', 'albana:']
            for e3fs in ext3_filesystems:
                if tokens[0].find(e3fs) != -1:
                    d['Using'] += 5 # ext3 reserves 5%
                    break

        details[tokens[0]] = d

    return details
1307156
def _fetch_dimensions(self, dataset):
        
        for dimension in super(SCB, self)._fetch_dimensions(dataset):
            if dimension.id == "Region":
                yield Dimension(dimension.id,
                                datatype="region",
                                dialect="skatteverket",
                                label=dimension.label)
            else:
                yield dimension
629966
def get_term_size():
        ''''''
        rows, columns = os.popen('stty size', 'r').read().split()
        return int(rows), int(columns)