SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2401.04071 · CVPR · 2024

Fun with Flags: Robust Principal Directions via Flag Manifolds

Nathan Mankovich

arXiv · PDF · Open in the Atlas

Code that ran

10 of 13 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 7 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2401.04071.json · badge: /api/ran/2401.04071.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
nmank/funwithflags canonical (classifier label)
classifier basis: census
10 ran · 3 no recorded run
FunctionStatusWhere it lives
generate_ellipse_outlier1 Ran
ran, honoured the contract we drafted
nmank/funwithflags/Hands/Figure4Feb.py
code served (permissive licence) · get_code("74f1f97fa37842af")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (56, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# The function takes a single parameter: seed (int)
# It uses np.random.seed(seed) to set the random seed
# Then generates various random values and performs numpy operations
# Returns a numpy array

ARGS = {
    "seed": 42
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (56, 2) — shape (56, 2) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_centroids Ran
ran, honoured the contract we drafted
nmank/funwithflags/Hands/hand_utils.py
code served (permissive licence) · get_code("ce5449152f7a695f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# The function get_centroids expects a numpy array of points
# It splits 66 points into two groups of 33 each and computes their means
# Each point should have some dimensionality (e.g., 2D or 3D coordinates)

# Create a synthetic LV cardiac dataset with 66 points (33 per circle)
# Using 2D points as is typical for cardiac datasets
np.random.seed(0)
points = np.random.randn(66, 2).astype(np.float32)

ARGS = {
    "points": points
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_data Ran
ran, honoured the contract we drafted
nmank/funwithflags/RemoteSensing/landuse_outliers.py
code served (permissive licence) · get_code("964be9a7a8c74669")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family int; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import numpy as np
from PIL import Image
import cv2

# Create temporary directory structure with mock image files
temp_dir = tempfile.mkdtemp()
os.makedirs(os.path.join(temp_dir, 'UCMerced_LandUse', 'Images', 'agricultural'), exist_ok=True)

# Create mock .tif images
class_name = 'agricultural'
for i in range(15):
    if i < 10:
        im_num = f'0{i}'
    else:
        im_num = str(i)
    
    # Create a random RGB image (256x256) and save as .tif
    random_image = np.random.randint(0, 255, (256, 256, 3), dtype=np.uint8)
    image_path = os.path.join(temp_dir, 'UCMerced_LandUse', 'Images', class_name, f'{class_name}{im_num}.tif')
    Image.fromarray(random_image).save(image_path)

# Change working directory to temp directory
original_cwd = os.getcwd()
os.chdir(temp_dir)

ARGS = {
    'class_name': 'agricultural',
    'n_pts': 10
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, cv2, matplotlib, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family int — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
getxy Ran
ran, honoured the contract we drafted
nmank/funwithflags/Hands/read_files.py
code served (permissive licence) · get_code("a878af77a0c2f762")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

def setup():
    line = "1.5 2.3 3.7 4.1"
    return {"line": line}

ARGS = setup()
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
getxy_selective Ran
ran, honoured the contract we drafted
nmank/funwithflags/Hands/read_files.py
code served (permissive licence) · get_code("7c245012f2192ee8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

def getxy_selective(line):
    points = line.split()
    return [float(points[2]), float(points[3])]

# The function expects a string parameter 'line' that can be split into whitespace-separated points
# It accesses indices [2] and [3] after splitting, so we need at least 4 elements
line_input = "point0 point1 3.14 2.71 point4"

ARGS = {
    "line": line_input
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
interp Ran
ran on a synthesized input
nmank/funwithflags/Hands/my_interpolate.py
code served (permissive licence) · get_code("adab89d94f21c30f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from scipy import interpolate

# Create a simple set of 2D points for interpolation
# Using 5 points with (x, y) coordinates
points = np.array([
    [0.0, 0.0],
    [1.0, 1.0],
    [2.0, 0.5],
    [3.0, 2.0],
    [4.0, 1.5]
], dtype=np.float64)

ARGS = {
    "points": points,
    "closed_curve": False,
    "k_": 3,
    "s_": 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_inliers Ran
ran; our contract draft was wrong, not the code
nmank/funwithflags/Faces/face_outliers.py
code served (permissive licence) · get_code("dcce316c77aea54b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile
import numpy as np
from PIL import Image
import shutil

# Create a temporary directory structure mimicking the Yale faces dataset
temp_dir = tempfile.mkdtemp()
data_dir = os.path.join(temp_dir, 'data', 'CroppedYale')
os.makedirs(data_dir, exist_ok=True)

# Create subject directories
subject_dirs = ['yaleB01', 'yaleB02']
for subject_id in subject_dirs:
    subject_path = os.path.join(data_dir, subject_id)
    os.makedirs(subject_path, exist_ok=True)
    
    # Create some .pgm files (we'll use PNG and rely on plt.imread to read them)
    # Create 3 non-Ambient images
    for i in range(3):
        img_array = np.random.randint(0, 256, (100, 100), dtype=np.uint8)
        img_path = os.path.join(subject_path, f'yaleB01_P00A+000_0{i}.pgm')
        Image.fromarray(img_array).save(img_path)
    
    # Create an Ambient image that should be skipped
    ambient_array = np.random.randint(0, 256, (100, 100), dtype=np.uint8)
    ambient_path = os.path.join(subject_path, 'yaleB01_P00A+000_Ambient.pgm')
    Image.fromarray(ambient_array).save(ambient_path)

# Change to temp directory so relative path './data/CroppedYale/' works
original_dir = os.getcwd()
os.chdir(temp_dir)

try:
    # ii is the index into the sorted list of subject directories
    ii = 0
    
    ARGS = {
        'ii': ii
    }
finally:
    # Clean up will happen after the function is called
    pass
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, cv2, matplotlib, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_1d Ran
ran, honoured the contract we drafted
nmank/funwithflags/Hands/hand_utils.py
code served (permissive licence) · get_code("c07f581677d9ad3d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 1, dtype family float, shape (4,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# hand is a 2D numpy array that gets indexed with [:, 0] and [:, 1]
# So it needs at least 2 columns
# The function concatenates these two columns and reshapes to 1D
# Let's create a small 2D array with shape (2, 2) - batch of 2, with 2 features
hand = np.array([[1.0, 2.0], [3.0, 4.0]])

ARGS = {
    "hand": hand
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
readPoints Ran
ran, honoured the contract we drafted
nmank/funwithflags/Hands/read_files.py
code served (permissive licence) · get_code("68f711db53a47c88")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import tempfile

# Create a temporary directory and test file
temp_dir = tempfile.mkdtemp()

# Create a test points file with comments and data
test_file = os.path.join(temp_dir, "test_points.txt")
with open(test_file, 'w') as f:
    f.write("# This is a comment\n")
    f.write("# Another comment\n")
    f.write("3\n")
    f.write("# Comment before points\n")
    f.write("1.0 2.0 3.0\n")
    f.write("4.5 5.5 6.5\n")
    f.write("7.2 8.2 9.2\n")

# Define custom getxy function (using the default provided in the function)
def custom_getxy(line):
    points = line.split()
    return [float(point) for point in points]

# Build ARGS dictionary with all parameters
ARGS = {
    "filepath": temp_dir,
    "filename": "test_points.txt",
    "getxy": custom_getxy
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 2, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unmake_1d Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
nmank/funwithflags/Hands/hand_utils.py
code served (permissive licence) · get_code("9732c8d7c92fd323")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (57, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Analyzing the function:
# - unmake_1d takes a parameter 'hand'
# - It accesses hand[i] and hand[i + 56] for i in range(0, hand.shape[0] // 2)
# - This means hand needs at least 112 elements (to access index 56 + something)
# - It returns a 2D array of shape (hand.shape[0] // 2, 2)
# - hand needs to be indexable and have a shape attribute, so it should be a numpy array

# Create a hand array with at least 112 elements
# Using 114 elements so that hand.shape[0] // 2 = 57, and we can access up to hand[56 + 56] = hand[112]
hand = np.arange(114, dtype=np.float32)

ARGS = {
    "hand": hand
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (57, 2) — shape (57, 2) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ftype_roc Not yet run
unverified (harvested, no recorded run)
nmank/funwithflags/Euclidean/Table4.py
code served (permissive licence) · get_code("57d3d876bd258d3e")
How it ran

no invocation recorded.

get_outliers Not yet run
unverified (harvested, no recorded run)
nmank/funwithflags/RemoteSensing/landuse_outliers.py
code served (permissive licence) · get_code("622d3a10b2bfeede")
How it ran

no invocation recorded.

load_outliers Not yet run
unverified (harvested, no recorded run)
nmank/funwithflags/Faces/face_outliers.py
code served (permissive licence) · get_code("0b0e415d9e5eca94")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 13 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Principal component analysis (PCA), along with its extensions to manifolds and outlier contaminated data, have been indispensable in computer vision and machine learning. In this work, we present a unifying formalism for PCA and its variants, and introduce a framework based on the flags of linear subspaces, i.e. a hierarchy of nested linear subspaces of increasing dimension, which not only allows for a common implementation but also yields novel variants, not explored previously. We begin by generalizing traditional PCA methods that either maximize variance or minimize reconstruction error. We expand these interpretations to develop a wide array of new dimensionality reduction algorithms by accounting for outliers and the data manifold. To devise a common computational approach, we recast robust and dual forms of PCA as optimization problems on flag manifolds. We then integrate tangent space approximations of principal geodesic analysis (tangent-PCA) into this flag-based framework, creating novel robust and dual geodesic PCA variations. The remarkable flexibility offered by the 'flagification' introduced here enables even more algorithmic variants identified by specific flag types. Last but not least, we propose an effective convergent solver for these flag-formulations employing the Stiefel manifold. Our empirical results on both real-world and synthetic scenarios, demonstrate the superiority of our novel algorithms, especially in terms of robustness to outliers on manifolds.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2401.04071")
get_code_for_paper("2401.04071")
have("2401.04071")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2401.04071.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2401.04071.svg)](https://syntology.ai/paper/2401.04071)

Connect an agent — have() is free.