internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: sunpy/sunpy

Issue:
Remove the need to have astropy installed before installing SunPy
Currently you can not have a clean python environment and do a `pip install sunpy` you have to have astropy + numpy installed first.



Discussion:
But this does not break our conda install instructions, right?

nope. This is a pip thing that has existed for a while.


Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,6 @@
     register_commands, adjust_compiler, get_debug_option, get_package_info)
 from astropy_helpers.git_helpers import get_git_devstr
 from astropy_helpers.version_helpers import generate_version_py
-from sunpy.tests.setup_command import SunPyTest
 
 # Get some values from the setup.cfg
 from distutils import config
@@ -64,9 +63,14 @@
 # modify distutils' behavior.
 cmdclassd = register_commands(PACKAGENAME, VERSION, RELEASE)
 
-# Overwrite the Astropy Testing framework
-cmdclassd['test'] = type('SunPyTest', (SunPyTest,),
-                         {'package_name': 'sunpy'})
+try:
+    from sunpy.tests.setup_command import SunPyTest
+    # Overwrite the Astropy Testing framework
+    cmdclassd['test'] = type('SunPyTest', (SunPyTest,),
+                            {'package_name': 'sunpy'})
+except Exception:
+    # Catch everything, if it doesn't work, we still want SunPy to install.
+    pass
 
 # Adjust the compiler in case the default on this platform is to use a
 # broken one.
diff --git a/sunpy/io/setup_package.py b/sunpy/io/setup_package.py
--- a/sunpy/io/setup_package.py
+++ b/sunpy/io/setup_package.py
@@ -1,18 +1,18 @@
 from __future__ import absolute_import
 
 import os
+import sys
 import platform
 
 from distutils.core import Extension
 from glob import glob
 
 from astropy_helpers import setup_helpers
-from astropy.extern import six
 
 
 def get_extensions():
 
-    if platform.system() == 'Windows' or six.PY3:
+    if platform.system() == 'Windows' or sys.version_info.major == 3:
         return list()
     else:
         # 'numpy' will be replaced with the proper path to the numpy includes


Test patch:
Repository: sunpy/sunpy

Issue:
Remove VSO qr.num_records() in favour of len(qr)
This can be confirmed with the following code 

```
from sunpy.net import vso
client=vso.VSOClient()
qr = client.query(vso.attrs.Time('2014/12/01 06:55', '2014/12/01 06:56'), vso.attrs.Instrument('hmi'))
qr.num_records
```

Or perhaps we should get rid of num_records completely for 0.7



Discussion:
yeah it should probably go in favour of `len(qr)`

I agree.  non-pythonic.

On Thu, Jul 30, 2015 at 11:54 AM, Stuart Mumford notifications@github.com
wrote:

> yeah it should probably go in favour of len(qr)
> 
> —
> Reply to this email directly or view it on GitHub
> https://github.com/sunpy/sunpy/issues/1514#issuecomment-126379005.

This should be modified for 0.6.1 so that it returns an int and not a table, but removed for 0.7.

This is not actually a bug. `num_records` is a method not a property. The correct invocation is:

``` python
In [7]: qr.num_records()
Out[7]: 6
```

the reason that

``` python
In [6]: qr.num_records
```

prints a table is that it is the same as doing:

``` python
In [5]: qr
```

where it returns the `__repr__` of the table.


Resolving patch:
diff --git a/sunpy/net/vso/vso.py b/sunpy/net/vso/vso.py
--- a/sunpy/net/vso/vso.py
+++ b/sunpy/net/vso/vso.py
@@ -193,10 +193,6 @@ def total_size(self):
         # Warn about -1 values?
         return sum(record.size for record in self if record.size > 0)
 
-    def num_records(self):
-        """ Return number of records. """
-        return len(self)
-
     def time_range(self):
         """ Return total time-range all records span across. """
         return (


Test patch:
Repository: sunpy/sunpy

Issue:
H-alpha Submap not working with arcsec units
I am using this Kanzelhohe H-alpha file - ftp://ftp.kso.ac.at/Ha4M/2011/20110116/processed/kanz_halph_fi_20110116_080851.fts.gz and when I try to create a submap the result is an empty array.

``` python
hmap=sunpy.map.Map('kanz_halph_fi_20110116_080851.fts.gz')
hmap.meta['waveunit']=u.aa #changing ANG to proper units
hmap.plot()
smap = hmap.submap(u.Quantity([100, 300], u.arcsec),
                   u.Quantity([0, 500], u.arcsec))
```

``` python
>>> smap
SunPy GenericMap
---------
Observatory:     KHPI
Instrument:  HA2
Detector:    TM4200
Measurement:     6563.0 aa
Wavelength:  6563.0 aa
Obs Date:    2011-01-16 08:08:51
dt:      0.007808 s
Dimension:   [ 0.  0.] pix
scale:       [ 1.02585  1.02585] arcsec / pix

array([], shape=(0, 0), dtype=float32)
```

Whereas with pixel units it works.

``` python

>>> smap = hmap.submap(u.Quantity([100, 300], u.pix),
...                   u.Quantity([0, 500], u.pix))
>>> smap
SunPy GenericMap
---------
Observatory:     KHPI
Instrument:  HA2
Detector:    TM4200
Measurement:     6563.0 aa
Wavelength:  6563.0 aa
Obs Date:    2011-01-16 08:08:51
dt:      0.007808 s
Dimension:   [ 200.  500.] pix
scale:       [ 1.02585  1.02585] arcsec / pix

array([[  62.,   52.,   71., ...,   70.,   73.,   77.],
       [  68.,   63.,   54., ...,   75.,   67.,   82.],
       [  59.,   68.,   60., ...,   72.,   72.,   72.],
       ..., 
       [ 105.,   95.,  101., ...,  949.,  911.,  901.],
       [ 113.,  103.,  106., ...,  936.,  888.,  868.],
       [ 104.,  100.,  106., ...,  945.,  914.,  911.]], dtype=float32)

```



Discussion:
@slyardley can you provide a link to the file?

Sorry the link didn't work it should be there now!

@slyardley it is asking me for a username + password?

@Cadair the password is available here: http://cesar.kso.ac.at/main/ftp.php
Sorry we had to leave for a seminar..

Ok, so the issue is that the header is "solar_x" "solar_y" when the MDI fix we merged a while ago only checks for "solar-x", "solar-y" a PR is on it's way.

A hack is the following:

``` python
hmap=sunpy.map.Map('kanz_halph_fi_20110116_080851.fts.gz')
hmap.meta['waveunit'] = 'AA' #changing ANG to proper units
hmap.meta['CTYPE1'] = 'HPLN-TAN'
hmap.meta['CTYPE2'] = 'HPLT-TAN'
```


Resolving patch:
diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py
--- a/sunpy/map/mapbase.py
+++ b/sunpy/map/mapbase.py
@@ -211,10 +211,10 @@ def wcs(self):
         # "solar-y" ctypes.  This overrides the default assignment and
         # changes it to a ctype that is understood.  See Thompson, 2006, A.&A.,
         # 449, 791.
-        if w2.wcs.ctype[0].lower() == "solar-x":
+        if w2.wcs.ctype[0].lower() in ("solar-x", "solar_x"):
             w2.wcs.ctype[0] = 'HPLN-TAN'
 
-        if w2.wcs.ctype[1].lower() == "solar-y":
+        if w2.wcs.ctype[1].lower() in ("solar-y", "solar_y"):
             w2.wcs.ctype[1] = 'HPLT-TAN'
 
         return w2


Test patch:
Repository: sunpy/sunpy

Issue:
Helioviewer is not working, homepage is downloaded instead of the requested image.
Few days ago, the helioviewer interface not download the image requested.

```
from sunpy.net.helioviewer import HelioviewerClient
hv = HelioviewerClient()
hv.download_png('2012/07/16 10:08:00', 4.8, "[SDO,AIA,AIA,171,1,100],[SOHO,LASCO,C2,white-light,1,100]", x1=-2800, x2=2800, y1=-2800, y2=2800, directory='~/Desktop')   # doctest: +SKIP
```

The file downloaded is the homepage from helioviewer!



Discussion:
@wafels what did you break?!

I think Helioviewer have done a large update, it will probably take us a while to catch up.

helioviewer.org now uses version 2 of the API.  Version 1 is still operating, but at a different location.  It should be possible to change the sunpy client to use version 1 of the helioviewer API at the new location.  I'll take a look. 


Resolving patch:
diff --git a/sunpy/net/helioviewer.py b/sunpy/net/helioviewer.py
--- a/sunpy/net/helioviewer.py
+++ b/sunpy/net/helioviewer.py
@@ -22,11 +22,18 @@
 
 class HelioviewerClient(object):
     """Helioviewer.org Client"""
-    def __init__(self, url="http://helioviewer.org/api/"):
+    def __init__(self, url="http://legacy.helioviewer.org/api/"):
+        """
+        url : location of the Helioviewer API.  The default location points to
+            version 1 of the API.  Version 1 of the Helioviewer API is
+            currently planned to be supported until the end of April 2017.
+        """
         self._api = url
 
     def get_data_sources(self, **kwargs):
-        """Returns a structured list of datasources available at Helioviewer.org"""
+        """
+        Returns a structured list of datasources available at helioviewer.org.
+        """
         params = {"action": "getDataSources"}
         params.update(kwargs)
 
@@ -36,8 +43,8 @@ def get_closest_image(self, date, **kwargs):
         """Finds the closest image available for the specified source and date.
 
         For more information on what types of requests are available and the
-        expected usage for the response, consult the Helioviewer
-        API documentation: http://helioviewer.org/api
+        expected usage for the response, consult the Helioviewer API
+        documentation: http://legacy.helioviewer.org/api/docs/v1/ .
 
         Parameters
         ----------


Test patch:
Repository: sunpy/sunpy

Issue:
LYRALightCurve returns level 2 data even when "lev" kwarg is set to 3.
The LYRALightCurve "lev" kwarg is supposed to allow the user to create a lightcurve object with level 2 (sub-second resolution) or level 3 (1-minute resolution).  At the moment, level 2 data is used even if lev=3.



Discussion:
The code seems to correctly download level 3 files, but with the keyword level=3, rather than lev=3. Is this therefore a documentation issue? The SunPy API reference doesn't seem to indicate what the allowed kwargs are.

@aringlis You're right!  This is good news!

Is this closable? It's not really a bug as the code does work - it's more a documentation issue, since the correct keyword to use isn't written down anywhere obvious.

well it should be documented!

It's probably worth waiting till we merge unidown

Hey! Could you tell me where exactly should the API kwargs be added? 


Resolving patch:
diff --git a/sunpy/lightcurve/sources/lyra.py b/sunpy/lightcurve/sources/lyra.py
--- a/sunpy/lightcurve/sources/lyra.py
+++ b/sunpy/lightcurve/sources/lyra.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 """Provides programs to process and analyze PROBA2/LYRA data."""
-from __future__ import absolute_import
+from __future__ import absolute_import, division, print_function
 
 import datetime
 import sys
@@ -40,12 +40,18 @@ class LYRALightCurve(LightCurve):
 
     PROBA2 was launched on 2 November 2009.
 
+    This class can download and hold either Level 2 data (the default) which
+    has sub-second resolution or Level 3 which is the Level 2 data averaged to
+    one minute cadence. The level can be specified with the ``level`` keyword
+    argument to `~sunpy.lightcurve.LyraLightCurve.create`.
+
     Examples
     --------
     >>> import sunpy
     >>> lyra = sunpy.lightcurve.LYRALightCurve.create()
     >>> lyra = sunpy.lightcurve.LYRALightCurve.create('~/Data/lyra/lyra_20110810-000000_lev2_std.fits')   # doctest: +SKIP
     >>> lyra = sunpy.lightcurve.LYRALightCurve.create('2011/08/10')
+    >>> lyra = sunpy.lightcurve.LYRALightCurve.create('2011/08/10', level=3)
     >>> lyra = sunpy.lightcurve.LYRALightCurve.create("http://proba2.oma.be/lyra/data/bsd/2011/08/10/lyra_20110810-000000_lev2_std.fits")
     >>> lyra.peek()   # doctest: +SKIP
 


Test patch:
Repository: sunpy/sunpy

Issue:
Deprecation warnings in rescale.py
``` python
In [13]: dimensions = u.Quantity(np.array(aia.data.shape) / 2048*u.pixel)

In [14]: sp = aia.superpixel(dimensions)
d:\sunpy-master\sunpy\image\rescale.py:226: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  offset[1]:offset[1] + nb*dimensions[1]]).reshape(na, dimensions[0], nb, dimensions[1])
d:\sunpy-master\sunpy\image\rescale.py:226: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  offset[1]:offset[1] + nb*dimensions[1]]).reshape(na, dimensions[0], nb, dimensions[1])
d:\sunpy-master\sunpy\image\rescale.py:226: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  offset[1]:offset[1] + nb*dimensions[1]]).reshape(na, dimensions[0], nb, dimensions[1])
d:\sunpy-master\sunpy\image\rescale.py:226: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  offset[1]:offset[1] + nb*dimensions[1]]).reshape(na, dimensions[0], nb, dimensions[1])
d:\sunpy-master\sunpy\image\rescale.py:226: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  offset[1]:offset[1] + nb*dimensions[1]]).reshape(na, dimensions[0], nb, dimensions[1])
d:\sunpy-master\sunpy\image\rescale.py:226: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  offset[1]:offset[1] + nb*dimensions[1]]).reshape(na, dimensions[0], nb, dimensions[1])
```



Discussion:

Resolving patch:
diff --git a/sunpy/image/rescale.py b/sunpy/image/rescale.py
--- a/sunpy/image/rescale.py
+++ b/sunpy/image/rescale.py
@@ -216,6 +216,9 @@ def reshape_image_to_4d_superpixel(img, dimensions, offset):
     http://mail.scipy.org/pipermail/numpy-discussion/2010-July/051760.html
 
     """
+    # make sure the input dimensions are integers
+    dimensions = [int(dim) for dim in dimensions]
+
     # New dimensions of the final image
     na = int(np.floor((img.shape[0] - offset[0]) / dimensions[0]))
     nb = int(np.floor((img.shape[1] - offset[1]) / dimensions[1]))


Test patch:
Repository: sunpy/sunpy

Issue:
convert_data_to_pixel issue
This line in convert_data_to_pixel:
  pixelx = (x - crval[0]) / cdelt[0] + (crpix[1] - 1)
should be:
  pixelx = (x - crval[0]) / cdelt[0] + (crpix[0] - 1)

I found the problem using 0.6.3, but looking at the source, it persists in 0.6.4.



Discussion:
Can you provide a link to the source code please? If you click on the line number on github it will give you a link.

Thanks for the bug report.

https://github.com/sunpy/sunpy/blob/2052149cdd85e600ac4ec2724eab852e30bb255e/sunpy/wcs/wcs.py#L136

On Tue, May 10, 2016 at 6:12 AM, Stuart Mumford notifications@github.com
wrote:

> Can you provide a link to the source code please? If you click on the line
> number on github it will give you a link.
> 
> Thanks for the bug report.
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly or view it on GitHub
> https://github.com/sunpy/sunpy/issues/1763#issuecomment-218115502

yes, that is a bug. What's noteworthy is that we don't use that code in map anymore.

@thothsartre What are you using that implementation of `data_to_pixel` doing that conversion through `Map.data_to_pixel()` is better as it accounts for rotation correctly.

Thanks for the pointer to Map.data_to_pixel(); looks like it'll take a bit more code to set up, but should work well.  I'm extracting portions of data read from FITS files given data coordinates, and convert_data_to_pixel was used to get the corresponding image coordinates.

@thothsartre If you want to extract a sub section of an image from a larger image you can use [`Map.submap()`](http://docs.sunpy.org/en/stable/code_ref/map.html#sunpy.map.mapbase.GenericMap.submap) where you can specify the arguments in either data or image coordinates. HTH.

@Cadair  Many thanks!  That's very helpful.


Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -94,7 +94,7 @@
 
 intersphinx_mapping.pop('h5py', None)
 intersphinx_mapping['astropy'] = ('http://docs.astropy.org/en/stable/', None)
-intersphinx_mapping['sqlalchemy'] = ('http://docs.sqlalchemy.org/en/rel_0_8/', None)
+intersphinx_mapping['sqlalchemy'] = ('http://docs.sqlalchemy.org/en/latest/', None)
 intersphinx_mapping['pandas'] = ('http://pandas.pydata.org/pandas-docs/stable/', None)
 intersphinx_mapping['skimage'] = ('http://scikit-image.org/docs/stable/', None)
 intersphinx_mapping['wcsaxes'] = ('http://wcsaxes.readthedocs.org/en/stable/', None)
diff --git a/sunpy/wcs/wcs.py b/sunpy/wcs/wcs.py
--- a/sunpy/wcs/wcs.py
+++ b/sunpy/wcs/wcs.py
@@ -133,7 +133,7 @@ def convert_data_to_pixel(x, y, scale, reference_pixel, reference_coordinate):
     # coord = inv_proj_tan(coord)
 
     # note that crpix[] counts pixels starting at 1
-    pixelx = (x - crval[0]) / cdelt[0] + (crpix[1] - 1)
+    pixelx = (x - crval[0]) / cdelt[0] + (crpix[0] - 1)
     pixely = (y - crval[1]) / cdelt[1] + (crpix[1] - 1)
 
     return pixelx, pixely


Test patch:
Repository: sunpy/sunpy

Issue:
convert_data_to_pixel issue
This line in convert_data_to_pixel:
  pixelx = (x - crval[0]) / cdelt[0] + (crpix[1] - 1)
should be:
  pixelx = (x - crval[0]) / cdelt[0] + (crpix[0] - 1)

I found the problem using 0.6.3, but looking at the source, it persists in 0.6.4.



Discussion:
Can you provide a link to the source code please? If you click on the line number on github it will give you a link.

Thanks for the bug report.

https://github.com/sunpy/sunpy/blob/2052149cdd85e600ac4ec2724eab852e30bb255e/sunpy/wcs/wcs.py#L136

On Tue, May 10, 2016 at 6:12 AM, Stuart Mumford notifications@github.com
wrote:

> Can you provide a link to the source code please? If you click on the line
> number on github it will give you a link.
> 
> Thanks for the bug report.
> 
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly or view it on GitHub
> https://github.com/sunpy/sunpy/issues/1763#issuecomment-218115502

yes, that is a bug. What's noteworthy is that we don't use that code in map anymore.

@thothsartre What are you using that implementation of `data_to_pixel` doing that conversion through `Map.data_to_pixel()` is better as it accounts for rotation correctly.

Thanks for the pointer to Map.data_to_pixel(); looks like it'll take a bit more code to set up, but should work well.  I'm extracting portions of data read from FITS files given data coordinates, and convert_data_to_pixel was used to get the corresponding image coordinates.

@thothsartre If you want to extract a sub section of an image from a larger image you can use [`Map.submap()`](http://docs.sunpy.org/en/stable/code_ref/map.html#sunpy.map.mapbase.GenericMap.submap) where you can specify the arguments in either data or image coordinates. HTH.

@Cadair  Many thanks!  That's very helpful.


Resolving patch:
diff --git a/sunpy/wcs/wcs.py b/sunpy/wcs/wcs.py
--- a/sunpy/wcs/wcs.py
+++ b/sunpy/wcs/wcs.py
@@ -133,7 +133,7 @@ def convert_data_to_pixel(x, y, scale, reference_pixel, reference_coordinate):
     # coord = inv_proj_tan(coord)
 
     # note that crpix[] counts pixels starting at 1
-    pixelx = (x - crval[0]) / cdelt[0] + (crpix[1] - 1)
+    pixelx = (x - crval[0]) / cdelt[0] + (crpix[0] - 1)
     pixely = (y - crval[1]) / cdelt[1] + (crpix[1] - 1)
 
     return pixelx, pixely


Test patch:
Repository: sunpy/sunpy

Issue:
Mapbase turns on all warnings regardless of user preferences
The following line should be removed from the function `_validate_meta(self)`

```
warnings.simplefilter('always', Warning)
```

The level of warnings should be user configurable and not superseded by mapbase.



Discussion:
I agree, this is also a good time where issue #1859 would be applicable.


Resolving patch:
diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py
--- a/sunpy/map/mapbase.py
+++ b/sunpy/map/mapbase.py
@@ -655,8 +655,6 @@ def _validate_meta(self):
 
         """
 
-        warnings.simplefilter('always', Warning)
-
         for meta_property in ('cunit1', 'cunit2', 'waveunit'):
             if (self.meta.get(meta_property) and
                 u.Unit(self.meta.get(meta_property),


Test patch:
Repository: sunpy/sunpy

Issue:
Deprecate vso.Wave
This change will get a lot of people.


Discussion:

Resolving patch:
diff --git a/sunpy/net/vso/attrs.py b/sunpy/net/vso/attrs.py
--- a/sunpy/net/vso/attrs.py
+++ b/sunpy/net/vso/attrs.py
@@ -26,6 +26,7 @@
     Attr, AttrWalker, AttrAnd, AttrOr, DummyAttr, ValueAttr
 )
 from sunpy.util.multimethod import MultiMethod
+from sunpy.util.decorators import deprecated
 from sunpy.time import parse_time
 from sunpy.extern.six import iteritems
 
@@ -142,6 +143,14 @@ def __repr__(self):
                                                             self.unit)
 
 
+@deprecated("0.8", message="Wave has been renamed Wavelength",
+            alternative="sunpy.net.vso.attrs.wavelength")
+class Wave(Wavelength):
+    """
+    Wavelength search attribute. See `sunpy.net.vso.attrs.Wavelength`.
+    """
+
+
 class Time(Attr, _Range):
     """
     Specify the time range of the query.


Test patch:
Repository: sunpy/sunpy

Issue:
map.date() doesn't behave as "wanted" by the code
The condition https://github.com/sunpy/sunpy/blob/5ea7fe6bee8accc0f9c08da943c112a32549c419/sunpy/map/mapbase.py#L409

will never happen... and if it does, the following statement after the `warning` will fail
 https://github.com/sunpy/sunpy/blob/5ea7fe6bee8accc0f9c08da943c112a32549c419/sunpy/map/mapbase.py#L414

So, I would either remove the `warning` or implement better the preferred behaviour. As it is now can just make us believe there's a net protecting the users... when there's not.

The [coverage](https://coveralls.io/builds/12747866/source?filename=sunpy%2Fmap%2Fmapbase.py#L406) shows that too.


Discussion:
I think can change to `self.meta.get('date-obs', None)` and then inside the condition assign `time = 'now'`. That way the warning will show.
Also `parse_time` is called twice which is kind of redundant. I suggest leaving out the first one.

Resolving patch:
diff --git a/sunpy/map/mapbase.py b/sunpy/map/mapbase.py
--- a/sunpy/map/mapbase.py
+++ b/sunpy/map/mapbase.py
@@ -405,12 +405,13 @@ def nickname(self, n):
     @property
     def date(self):
         """Image observation time"""
-        time = parse_time(self.meta.get('date-obs', 'now'))
+        time = self.meta.get('date-obs', None)
         if time is None:
             warnings.warn_explicit("Missing metadata for observation time."
                                    " Using current time.",
                                    Warning, __file__,
                                    inspect.currentframe().f_back.f_lineno)
+            time = 'now'
         return parse_time(time)
 
     @property


Test patch: