hash stringlengths 64 64 | content stringlengths 0 1.51M |
|---|---|
38130b17f976bb6e9362cab7c0b3b3194c6644a357928a4401fd5a46c34d13c7 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file is the main file used when running tests with pytest directly,
# in particular if running e.g. ``pytest docs/``.
import os
import tempfile
import hypothesis
from astropy import __version__
try:
from pytest_astropy_header.display import... |
bded93adc301a0fcc3dd01dc4f3e259ca71231cc421fd7bee8443d206b1ce143 | #!/usr/bin/env python
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# NOTE: The configuration for the package, including the name, version, and
# other information are set in the setup.cfg file.
import sys
# First provide helpful messages if contributors try and run legacy commands
# for tests or d... |
73b018608b35beb850df948ebe0315cbe4f8019618c62ccea33612d1f828bdf7 | import os
import shutil
import sys
import erfa # noqa
import pytest
import astropy # noqa
if len(sys.argv) == 3 and sys.argv[1] == '--astropy-root':
ROOT = sys.argv[2]
else:
# Make sure we don't allow any arguments to be passed - some tests call
# sys.executable which becomes this script when producing... |
f3a0aeb97076b413c5b12bf54c9d21687bfae4f546d809811d8fd5110a7aa5eb | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Astropy is a package intended to contain core functionality and some
common tools needed for performing astronomy and astrophysics research with
Python. It also provides an index for other astronomy packages and tools for
managing them.
"""
import os
... |
ab94da6ed51f8e247cb5bf4f29bd54aa85a12e98494aebf149298826f5daa769 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""This module defines a logging class based on the built-in logging module.
.. note::
This module is meant for internal ``astropy`` usage. For use in other
packages, we recommend implementing your own logger instead.
"""
import inspect
import ... |
849d26898fd469a494890a464c47e1076f6d55df28b54c2619cc895ab57340d1 | # NOTE: First try _dev.scm_version if it exists and setuptools_scm is installed
# This file is not included in astropy wheels/tarballs, so otherwise it will
# fall back on the generated _version module.
try:
try:
from ._dev.scm_version import version
except ImportError:
from ._version import ver... |
e3970894c3f13086681508803f5f44c92c2fd9b69c5f237606b04099de0ac0dd | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This file contains pytest configuration settings that are astropy-specific
(i.e. those that would not necessarily be shared by affiliated packages
making use of astropy's test runner).
"""
import builtins
import os
import sys
import tempfile
import wa... |
b083f49c5a623cf28e75b25cd79688276dbe7ed19355a301169da9235586360e | # Licensed under a 3-clause BSD style license - see LICENSE.rst
# This file needs to be included here to make sure commands such
# as ``pytest docs/...`` works, since this
# will ignore the conftest.py file at the root of the repository
# and the one in astropy/conftest.py
import os
import tempfile
import pytest
# M... |
6f600f3b21fec07e8bd0aecdf780f73a4b028ba7cacacb37ef41fecbcb1b874f | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
#
# Astropy documentation build configuration file.
#
# This file is execfile()d with the current directory set to its containing dir.
#
# Note that not all possible configuration values are present in this file.
#
# All configurati... |
c07338c94a815b26b8846754da892de4c0e1b22dde30525e9980609aeaba4861 | # NOTE: this hook should be added to
# https://github.com/pyinstaller/pyinstaller-hooks-contrib
# once that repository is ready for pull requests
from PyInstaller.utils.hooks import collect_data_files
datas = collect_data_files('skyfield')
|
bfa48512aada02006c25f249d8b46593f5a541cd7244d7f675f740dab06a9099 | # -*- coding: utf-8 -*-
"""
========================
Title of Example
========================
This example <verb> <active tense> <does something>.
The example uses <packages> to <do something> and <other package> to <do other
thing>. Include links to referenced packages like this: `astropy.io.fits` to
show the astro... |
547790e0143fe9a8b1996e4cecd461eb313bd82630ddb4630845753fd1343eef | # -*- coding: utf-8 -*-
r"""
==========================================================
Create a new coordinate class (for the Sagittarius stream)
==========================================================
This document describes in detail how to subclass and define a custom spherical
coordinate frame, as discussed in... |
169d08766b27d0e8c3edf0512170a6796246d917db295c0b3463aa7bfb1c4330 | # -*- coding: utf-8 -*-
"""
================================================================
Convert a radial velocity to the Galactic Standard of Rest (GSR)
================================================================
Radial or line-of-sight velocities of sources are often reported in a
Heliocentric or Solar-syst... |
9035692fe1ca2a75b94864183c99f6dfb14e7c446c8fa7bdbb53ec46b965569a | # -*- coding: utf-8 -*-
"""
========================================================================
Transforming positions and velocities to and from a Galactocentric frame
========================================================================
This document shows a few examples of how to use and customize the
`~ast... |
12bef7dc219d41692d2cbc9fe75a49900ea1f0df6e831e5d70e413d075a0fb12 | # -*- coding: utf-8 -*-
"""
===================================================================
Determining and plotting the altitude/azimuth of a celestial object
===================================================================
This example demonstrates coordinate transformations and the creation of
visibility cur... |
fbb510c5e0186d5e16961c613d3831dbd37a4d215fe262121af70c4b3d053210 | # -*- coding: utf-8 -*-
"""
==================
Edit a FITS header
==================
This example describes how to edit a value in a FITS header
using `astropy.io.fits`.
*By: Adrian Price-Whelan*
*License: BSD*
"""
from astropy.io import fits
#####################################################################... |
f060aa9837a0df597dbb32aa17d9db8fda514facc6f269012d3fc9611751b903 | # -*- coding: utf-8 -*-
"""
=====================================================
Create a multi-extension FITS (MEF) file from scratch
=====================================================
This example demonstrates how to create a multi-extension FITS (MEF)
file from scratch using `astropy.io.fits`.
*By: Erik Bray*... |
f8e82631004deaaab5e0800e207f27d16652fb1494aaeb6bec42c040fe4f5c35 | # -*- coding: utf-8 -*-
"""
=====================================================================
Accessing data stored as a table in a multi-extension FITS (MEF) file
=====================================================================
FITS files can often contain large amount of multi-dimensional data and
tables. T... |
78cf5c60f74125abbfa26c0a951f75863b38c484d06ca630714937cedada6e19 | # -*- coding: utf-8 -*-
"""
=======================================
Read and plot an image from a FITS file
=======================================
This example opens an image stored in a FITS file and displays it to the screen.
This example uses `astropy.utils.data` to download the file, `astropy.io.fits` to open
th... |
042abe04a704fa7bcd949b1e95727d07e411096873c00d61d30b3d539d20354a | # -*- coding: utf-8 -*-
"""
==========================================
Create a very large FITS file from scratch
==========================================
This example demonstrates how to create a large file (larger than will fit in
memory) from scratch using `astropy.io.fits`.
*By: Erik Bray*
*License: BSD*
"""... |
93f258becc4ec5da3768b6fd02d801854a4cb29f419856cfe08914b80cd312c8 | # -*- coding: utf-8 -*-
"""
=====================================================
Convert a 3-color image (JPG) to separate FITS images
=====================================================
This example opens an RGB JPEG image and writes out each channel as a separate
FITS (image) file.
This example uses `pillow <htt... |
39925d73352c68f7255c1d0d924280ef6398a56b59b5ccb3c0347e3e2b53f09f | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This subpackage contains classes and functions for defining and converting
between different physical units.
This code is adapted from the `pynbody
<https://github.com/pynbody/pynbody>`_ units module written by Andrew
Pontzen, who has granted the Ast... |
a671682046f0a87fb4fee08f99dc39dc03225cc8bc17033841e75048b23dbe9d | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines the astrophysics-specific units. They are also
available in the `astropy.units` namespace.
"""
from . import si
from astropy.constants import si as _si
from .core import (UnitBase, def_unit, si_prefixes,... |
0b2781faaca6b6933abaa13f2824ea15230bbd10fdeb9f957443315a055f1d91 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Support for ``typing`` py3.9+ features while min version is py3.8.
"""
from typing import *
try: # py 3.9+
from typing import Annotated
except (ImportError, ModuleNotFoundError): # optional dependency
try:
from typing_extensions imp... |
46d21d999a60a43886c5596edc5958a66299b51124ae7af43c8397e3ab1ac805 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""Defines the physical types that correspond to different units."""
import numbers
import warnings
from . import core
from . import si
from . import astrophys
from . import cgs
from . import imperial # Need this for backward namespace compat, see issu... |
993c714f2008288a714601027ad005de4d23245e3e460918c66069eb7966a3f1 | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines miscellaneous units. They are also
available in the `astropy.units` namespace.
"""
from . import si
from astropy.constants import si as _si
from .core import (UnitBase, def_unit, si_prefixes, binary_prefi... |
010acb8739268afb39b57f68a20f26d00f041fc45ee6f0591da35fd4805716f5 | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines SI prefixed units that are required by the VOUnit standard
but that are rarely used in practice and liable to lead to confusion (such as
``msolMass`` for milli-solar mass). They are in a separate module from... |
98d90b12739822c658236023dbfa4ba1e70bcecfe2b6c8ce4758d9dac28d0ff6 | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines the CGS units. They are also available in the
top-level `astropy.units` namespace.
"""
from fractions import Fraction
from . import si
from .core import UnitBase, def_unit
_ns = globals()
def_unit(['c... |
803f838d8eb7c8a0c705c85801a5d3a7910d261cd3ec6b0c93f820d7a20e9f56 | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines deprecated units.
These units are not available in the top-level `astropy.units`
namespace. To use these units, you must import the `astropy.units.deprecated`
module::
>>> from astropy.units import dep... |
798e04161d76df505a2134d2a0639c178eeb668445a39d09c62316f3f6122d68 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
Miscellaneous utilities for `astropy.units`.
None of the functions in the module are meant for use outside of the
package.
"""
import io
import re
from fractions import Fraction
import numpy as np
from numpy import finfo
_float_finfo = finfo(float... |
6e22b6f296084fcb81cf2a1e4acd1bbb4aa695238cf7a9cee400daa246530a39 | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This package defines colloquially used Imperial units. They are
available in the `astropy.units.imperial` namespace, but not in the
top-level `astropy.units` namespace, e.g.::
>>> import astropy.units as u
>>> mph = u... |
da2c0c67aa0ef24cf668a71f1e193d77284f17db328cafe168a9477cec0b0494 | # -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license - see LICENSE.rst
"""
This module defines structured units and quantities.
"""
# Standard library
import operator
import numpy as np
from .core import Unit, UnitBase, UNITY
__all__ = ['StructuredUnit']
DTYPE_OBJECT = np.dtype('O')
def _names... |
End of preview. Expand in Data Studio
SWE-Bench Verified
import argparse
from dataclasses import dataclass, asdict
import datasets
from pathlib import Path
import subprocess
from typing import Dict, List
import tqdm
from datasets import Dataset
import hashlib
from dataclasses import dataclass
@dataclass
class CodebaseFile:
path: str
content: str
class SWEBenchProblem:
def __init__(self, row):
self._row = row
@property
def repo(self) -> str:
return self._row["repo"]
@property
def base_commit(self) -> str:
return self._row["base_commit"]
@property
def instance_id(self) -> str:
return self._row["instance_id"]
VALID_EXTENSIONS = {"py"}
def hash_file_content(file_content: str) -> str:
return hashlib.sha256(file_content.encode()).hexdigest()
@dataclass
class FileInCodebase:
file_path: str
content_hash: str
@dataclass
class CodebaseContent:
instance_id: str
files: List[FileInCodebase]
def clone_repos(problems: list[SWEBenchProblem], repos_dir: Path):
repos_dir.mkdir(exist_ok=False, parents=True)
if len(list(repos_dir.iterdir())):
raise ValueError("Repos dir should be empty")
repos = {problem.repo for problem in problems}
for repo in tqdm.tqdm(repos, desc="Cloning repos"):
output = subprocess.run(
["git", "clone", f"https://github.com/{repo}.git"],
cwd=repos_dir,
capture_output=True,
)
assert output.returncode == 0
def get_codebase_content(
problem: SWEBenchProblem, repos_dir: Path, hash_to_content: Dict[str, str]
) -> CodebaseContent:
repo = problem.repo.split("/")[-1]
repo_path = repos_dir / repo
subprocess.run(
["git", "checkout", problem.base_commit], cwd=repo_path, capture_output=True
)
contexts = []
for file_path in repo_path.rglob("*"):
if not file_path.is_file:
continue
if file_path.suffix[1:] not in VALID_EXTENSIONS: # [1:] excludes the '.'
continue
try:
content = file_path.read_text()
except UnicodeDecodeError:
# Ignore these files.
continue
content_hash = hash_file_content(content)
if content_hash not in hash_to_content:
hash_to_content[content_hash] = content
contexts.append(
FileInCodebase(
file_path=str(file_path.relative_to(repo_path)),
content_hash=content_hash,
)
)
return CodebaseContent(instance_id=problem.instance_id, files=contexts)
@dataclass
class ContentDatasetElement:
hash: str
content: str
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--repo_directory",
type=Path,
default=Path("/scr/ryanehrlich/swebench_verified_repos"),
)
parser.add_argument(
"--output_dataset_name",
type=str,
default="ScalingIntelligence/swe-bench-verified-codebase-content-staging",
)
args = parser.parse_args()
dataset = datasets.load_dataset("princeton-nlp/SWE-bench_Verified", split="test")
problems = [SWEBenchProblem(row) for row in dataset]
clone_repos(problems, args.repo_directory)
hash_to_content = {}
codebase_content_per_problem = [
get_codebase_content(problem, args.repo_directory, hash_to_content)
for problem in tqdm.tqdm(problems, desc="Fetching codebase content")
]
hash_to_content_in_hf_form = [
{
"hash": hash_,
"content": content,
}
for (hash_, content) in hash_to_content.items()
]
codebase_content_in_hf_form = [
asdict(problem) for problem in codebase_content_per_problem
]
file_content_dataset = Dataset.from_list(hash_to_content_in_hf_form, split="test")
problems_dataset = Dataset.from_list(codebase_content_in_hf_form, split="test")
file_content_dataset.push_to_hub(
args.output_dataset_name, "file_content", private=True, max_shard_size="256MB"
)
problems_dataset.push_to_hub(
args.output_dataset_name, "problem_files", private=True, max_shard_size="256MB"
)
if __name__ == "__main__":
main()
- Downloads last month
- 11