Sample

pyint-76d0396aa4c6-I04

Replace names with deterministic minifier-style shortest identifiers

Matched original source

Lines228

Scores

MethodScoreScale
Posnett00–1; higher is more readable
Dorn0.1880–1; higher is more readable
Mi0.6170–1; higher is more readable
LLOC117Logical lines; fewer is more readable
DeepSeek V4 Pro3.670–20; mean of three runs
GPT-6.1 Sol110–20; mean of three runs
BTTF0.1150–1; higher is more readable

Views

Source code

from ctypes import byref, c_double from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope from django.contrib.gis.gdal.error import GDALException, SRSException from django.contrib.gis.gdal.feature import Feature from django.contrib.gis.gdal.field import OGRFieldTypes from django.contrib.gis.gdal.geometries import OGRGeometry from django.contrib.gis.gdal.geomtype import OGRGeomType from django.contrib.gis.gdal.prototypes import ds as capi from django.contrib.gis.gdal.prototypes import geom as geom_api from django.contrib.gis.gdal.prototypes import srs as srs_api from django.contrib.gis.gdal.srs import SpatialReference from django.utils.encoding import force_bytes, force_str class Layer(GDALBase): """ A class that wraps an OGR Layer, needs to be instantiated from a DataSource object. """ def __init__(self, r, s): """ Initialize on an OGR C pointer to the Layer and the `DataSource` object that owns this layer. The `DataSource` object is required so that a reference to it is kept with this Layer. This prevents garbage collection of the `DataSource` while this Layer is still active. """ if not r: raise GDALException("Cannot create Layer, invalid pointer given") self.ptr = r self._ds = s self._ldefn = capi.get_layer_defn(self._ptr) # Does the Layer support random reading? self._random_read = self.q(b"RandomRead") def __getitem__(self, t): "Get the Feature at the specified index." if isinstance(t, int): # An integer index was given -- we cannot do a check based on the # number of features because the beginning and ending feature IDs # are not guaranteed to be 0 and len(layer)-1, respectively. if t < 0: raise IndexError("Negative indices are not allowed on OGR Layers.") return self.a(t) elif isinstance(t, slice): # A slice was given u, v, w = t.indices(self.d) return [self.a(x) for x in range(u, v, w)] else: raise TypeError( "Integers and slices may only be used when indexing OGR Layers." ) def __iter__(self): "Iterate over each Feature in the Layer." # ResetReading() must be called before iteration is to begin. capi.reset_reading(self._ptr) for y in range(self.d): yield Feature(capi.get_next_feature(self._ptr), self) def __len__(self): "The length is the number of features." return self.d def __str__(self): "The string name of the layer." return self.c def a(self, z): """ Helper routine for __getitem__ that constructs a Feature from the given Feature ID. If the OGR Layer does not support random-access reading, then each feature of the layer will be incremented through until the a Feature is found matching the given feature ID. """ if self._random_read: # If the Layer supports random reading, return. try: return Feature(capi.get_feature(self.ptr, z), self) except GDALException: pass else: # Random access isn't supported, have to increment through # each feature until the given feature ID is encountered. for A in self: if A.fid == z: return A # Should have returned a Feature, raise an IndexError. raise IndexError("Invalid feature id: %s." % z) # #### Layer properties #### @property def b(self): "Return the extent (an Envelope) of this layer." B = OGREnvelope() capi.get_extent(self.ptr, byref(B), 1) return Envelope(B) @property def c(self): "Return the name of this layer in the Data Source." C = capi.get_fd_name(self._ldefn) return force_str(C, self._ds.encoding, strings_only=True) @property def d(self, D=1): "Return the number of features in the Layer." return capi.get_feature_count(self.ptr, D) @property def e(self): "Return the number of fields in the Layer." return capi.get_field_count(self._ldefn) @property def f(self): "Return the geometry type (OGRGeomType) of the Layer." return OGRGeomType(capi.get_fd_geom_type(self._ldefn)) @property def g(self): "Return the Spatial Reference used in this Layer." try: E = capi.get_layer_srs(self.ptr) return SpatialReference(srs_api.clone_srs(E)) except SRSException: return None @property def h(self): """ Return a list of string names corresponding to each of the Fields available in this Layer. """ return [ force_str( capi.get_field_name(capi.get_field_defn(self._ldefn, F)), self._ds.encoding, strings_only=True, ) for F in range(self.e) ] @property def j(self): """ Return a list of the types of fields in this Layer. For example, return the list [OFTInteger, OFTReal, OFTString] for an OGR layer that has an integer, a floating-point, and string fields. """ return [ OGRFieldTypes[capi.get_field_type(capi.get_field_defn(self._ldefn, G))] for G in range(self.e) ] @property def k(self): "Return a list of the maximum field widths for the features." return [ capi.get_field_width(capi.get_field_defn(self._ldefn, H)) for H in range(self.e) ] @property def l(self): "Return the field precisions for the features." return [ capi.get_field_precision(capi.get_field_defn(self._ldefn, I)) for I in range(self.e) ] def m(self): try: return OGRGeometry(geom_api.clone_geom(capi.get_spatial_filter(self.ptr))) except GDALException: return None def n(self, J): if isinstance(J, OGRGeometry): capi.set_spatial_filter(self.ptr, J.ptr) elif isinstance(J, (tuple, list)): if not len(J) == 4: raise ValueError("Spatial filter list/tuple must have 4 elements.") # Map c_double onto params -- if a bad type is passed in it # will be caught here. K, L, M, N = map(c_double, J) capi.set_spatial_filter_rect(self.ptr, K, L, M, N) elif J is None: capi.set_spatial_filter(self.ptr, None) else: raise TypeError( "Spatial filter must be either an OGRGeometry instance, a 4-tuple, or " "None." ) spatial_filter = property(_get_spatial_filter, _set_spatial_filter) # #### Layer Methods #### def o(self, O): """ Return a list containing the given field name for every Feature in the Layer. """ if O not in self.h: raise GDALException("invalid field name: %s" % O) return [P.get(O) for P in self] def p(self, Q=False): """ Return a list containing the OGRGeometry for every Feature in the Layer. """ if Q: from django.contrib.gis.geos import GEOSGeometry return [GEOSGeometry(R.geom.wkb) for R in self] else: return [R.geom for R in self] def q(self, S): """ Return a bool indicating whether the this Layer supports the given capability (a string). Valid capability strings include: 'RandomRead', 'SequentialWrite', 'RandomWrite', 'FastSpatialFilter', 'FastFeatureCount', 'FastGetExtent', 'CreateField', 'Transactions', 'DeleteFeature', and 'FastSetNextByIndex'. """ return bool(capi.test_capability(self.ptr, force_bytes(S)))

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.7697.363−254.013
Source linesThe number of non-empty source lines.228+91.2
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.402−6.603

Intercept 8.87 + feature contributions = -160.545 (log-odds).
Score = sigmoid(-160.545) = 0.

Feature contributions

FeatureValueContribution
(log-odds)
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.229−7.072
Indentation frequencyHow rapidly indentation changes from line to line.181+5.523
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.181−3.733
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.227.852+2.775
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.85.86+0.581
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.055+0.411
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.86.956−0.018

Intercept 0.07 + feature contributions = -1.461 (log-odds).
Score = sigmoid(-1.461) = 0.188.

Score0.617
Score117
Run 1

The code is severely obfuscated and nearly unreadable due to meaningless single-letter variable and method names (e.g., 'a', 'b', 'q', 's', 'r', 't') replacing descriptive identifiers. This destroys clarity of intent, reading flow, and code structure since readers cannot infer what any component does without extensive reverse-engineering. Nesting is moderate and action granularity is acceptable, but those positives are overwhelmed by the naming choices. The docstrings provide some context, but they are undermined by methods like 'm()' for get_spatial_filter and 'n()' for set_spatial_filter. Property names 'b' through 'l' contain no semantic meaning, making code length effectively longer than necessary due to required cross-referencing. Overall, this code would be extremely difficult to maintain or review despite being syntactically valid.

Run 2

The code is highly obfuscated. Meaningful names (Layer, random_read, extent, name, num_features, etc.) are replaced with meaningless single-letter identifiers (a, b, c, d, q, r, s, t, A, B, C, etc.), making the purpose of every method, property, and variable impossible to discern without deep reverse-engineering. While the original structure may have been logical, the renaming destroys clarity of intent and disrupts natural reading flow. Nesting and structure appear moderately flat, but action granularity suffers because the dense list comprehensions and calls hide multiple operations. The code is also unnecessarily long due to verbose docstrings that now describe obfuscated names inconsistently. Overall, this appears deliberately unreadable.

Run 3

This code is severely obfuscated and virtually unreadable. While it has some structure (clear method grouping with comments), the author has intentionally or carelessly replaced all meaningful variable names with single letters and unrelated characters (r, s, t, u, v, w, A, B, C, D, etc.). This destroys clarity of intent, making it impossible to understand what each parameter or variable represents without reverse-engineering the logic. Method names like 'a', 'b', 'c', 'o', 'p', 'q' provide zero semantic information. The nesting is moderate but the reading flow is completely broken—readers must constantly map meaningless letters to guessed purposes. Code length is acceptable and each line typically performs one action, but these positives are negated by the cryptic naming. Even the docstrings, though helpful, only partially mitigate the confusion. This code would be extremely difficult to maintain or review.

Run 1

Code Structure: The class is logically organized into initialization, indexing, properties, and methods, but spatial_filter references undefined accessor names rather than m and n, disrupting coherence. Nesting: Generally shallow, with manageable conditionals and loops. Clarity of intent: Docstrings and descriptive C API calls explain functionality, but single-letter method, property, parameter, and variable names severely obscure meaning and require repeated cross-referencing. Code length: Most implementations are concise; documentation adds useful context, though some comments repeat obvious operations. Action granularity: Statements generally perform one action per line, while nested API calls and comprehensions occasionally combine several operations. Reading flow: Consistent formatting and section markers support navigation, but opaque references such as self.a, self.d, and self.h interrupt otherwise natural flow. Overall, readable organization is substantially undermined by naming and the inconsistent property declaration.

Run 2

Code Structure: The class is logically divided into initialization, indexing, properties, and methods, but spatial_filter references undefined accessors rather than m and n, disrupting coherence. Nesting: Mostly shallow, with manageable conditional branches and loops. Clarity of intent: Docstrings and descriptive GDAL API calls explain functionality, but single-letter method, property, and variable names obscure meaning and force repeated cross-referencing. Code length: Most methods are concise; documentation adds useful context, although some comments repeat obvious operations. Action granularity: Generally one action per line, with conventional comprehensions; nested API calls occasionally increase cognitive load. Reading flow: Consistent formatting and grouping help, but opaque references such as self.a, self.d, and self.h substantially interrupt natural reading.

Run 3

Code Structure: The class is logically organized into initialization, collection behavior, properties, and methods, but spatial_filter references undefined accessor names rather than m and n. Nesting: Generally shallow, with only modest nesting in indexing, feature lookup, and filter validation. Clarity of intent: Docstrings and descriptive GDAL API calls explain much of the behavior, but single-letter method, property, parameter, and variable names severely obscure meaning and force repeated cross-referencing. Code length: Most methods are concise; documentation adds useful context, although some comments repeat obvious operations. Action granularity: Statements generally perform one action each, while comprehensions and nested API calls compact related operations reasonably. Reading flow: Consistent formatting and logical grouping support navigation, but expressions such as self.a(t), self.d, and self.h interrupt natural comprehension. Overall, the implementation has readable structural foundations, substantially weakened by opaque naming and inconsistent accessor references.