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

Issue:
[DOC] Misleading docstring parameters for convert utility function of dask_to_pd and vice versa
#### Describe the issue linked to the documentation
The docstring of function `convert_dask_to_pandas` and `convert_pandas_to_dask` has been interchanged in terms of parameters and return object

```python
def convert_dask_to_pandas(obj):
    """Convert dask DataFrame to pandas DataFrame, preserving MultiIndex.

    Parameters
    ----------
    obj : pandas.DataFrame

    Returns
    -------
    dask DataFrame
        MultiIndex levels 0 .. -1 of X are converted to columns of name
        __index__[indexname], where indexname is name of multiindex level,
        or the integer index if the level has no name
        other columns and column names are identical to those of X
    """
```

Here the type of parameter for the function should be `dask.DataFrame` while the return type should be `pandas.DataFrame`. There's similar issue in the docstring of `convert_pandas_to_dask`.


Discussion:

Resolving patch:
diff --git a/sktime/datatypes/_adapter/dask_to_pd.py b/sktime/datatypes/_adapter/dask_to_pd.py
--- a/sktime/datatypes/_adapter/dask_to_pd.py
+++ b/sktime/datatypes/_adapter/dask_to_pd.py
@@ -44,11 +44,11 @@ def convert_dask_to_pandas(obj):
 
     Parameters
     ----------
-    obj : pandas.DataFrame
+    obj : dask DataFrame
 
     Returns
     -------
-    dask DataFrame
+    pandas.DataFrame
         MultiIndex levels 0 .. -1 of X are converted to columns of name
         __index__[indexname], where indexname is name of multiindex level,
         or the integer index if the level has no name
@@ -86,7 +86,7 @@ def convert_pandas_to_dask(obj, npartitions=1, chunksize=None, sort=True):
 
     Parameters
     ----------
-    obj : dask DataFrame
+    obj : pandas.DataFrame
     npartitions : int or None, optional, default = 1
         npartitions passed to dask from_pandas when converting obj to dask
     chunksize : int or None, optional, default = None
@@ -96,7 +96,7 @@ def convert_pandas_to_dask(obj, npartitions=1, chunksize=None, sort=True):
 
     Returns
     -------
-    pandas.DataFrame
+    dask DataFrame
         MultiIndex levels 0 .. -1 of X are converted to columns of name
         __index__[indexname], where indexname is name of multiindex level,
         or the integer index if the level has no name


Test patch:
Repository: tough-dev-school/education-backend

Issue:
Установить django-axes
https://github.com/jazzband/django-axes


Discussion:

Resolving patch:
diff --git a/src/app/settings.py b/src/app/settings.py
--- a/src/app/settings.py
+++ b/src/app/settings.py
@@ -77,6 +77,7 @@
     'rest_framework.authtoken',
     'django_filters',
 
+    'axes',
     'django.contrib.admin',
     'django.contrib.auth',
     'django.contrib.contenttypes',
@@ -98,6 +99,7 @@
     'django.contrib.auth.middleware.RemoteUserMiddleware',
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
+    'axes.middleware.AxesMiddleware',
     'debug_toolbar.middleware.DebugToolbarMiddleware',
 ]
 
@@ -148,6 +150,7 @@
 }
 AUTH_USER_MODEL = 'users.User'
 AUTHENTICATION_BACKENDS = [
+    'axes.backends.AxesBackend',
     'django.contrib.auth.backends.ModelBackend',
     'django.contrib.auth.backends.RemoteUserBackend',
 ]


Test patch:
Repository: tough-dev-school/education-backend

Issue:
Кастомные теги в мейлчимпе
Чтобы можно было в лид-магните указать теги, которые пробрасываются в аудиторию мейлчимпа


Discussion:

Resolving patch:
diff --git a/src/magnets/creator.py b/src/magnets/creator.py
--- a/src/magnets/creator.py
+++ b/src/magnets/creator.py
@@ -23,6 +23,7 @@ def _create_user(self) -> User:
             name=self.data['name'],
             email=self.data['email'],
             subscribe=True,
+            tags=self.tags,
         )()
 
     def _create_log_entry(self):
@@ -30,3 +31,7 @@ def _create_log_entry(self):
             user=self.user,
             campaign=self.campaign,
         )
+
+    @property
+    def tags(self):
+        return [f'{self.campaign.slug}-lead-magnet']
diff --git a/src/shipping/shipments/course.py b/src/shipping/shipments/course.py
--- a/src/shipping/shipments/course.py
+++ b/src/shipping/shipments/course.py
@@ -24,7 +24,7 @@ def subscribe_to_mailchimp(self):
             subscribe_to_mailchimp.delay(
                 list_id=self.course.mailchimp_list_id,
                 user_id=self.user.pk,
-                tags=[self.course.slug],
+                tags=[self.course.slug, f'{self.course.slug}-purchased'],
             )
 
     def invite_to_clickmeeting(self):


Test patch:
diff --git a/src/magnets/tests/tests_lead_magnet_creator.py b/src/magnets/tests/tests_lead_magnet_creator.py
--- a/src/magnets/tests/tests_lead_magnet_creator.py
+++ b/src/magnets/tests/tests_lead_magnet_creator.py
@@ -44,12 +44,6 @@ def test_nameless(creator):
     assert created.last_name == ''
 
 
-def test_user_is_subscribed(creator, subscribe):
-    creator(name='r00t', email='support@m1crosoft.com')()
-
-    subscribe.assert_called_once()
-
-
 def test_existing_user(creator, mixer):
     user = mixer.blend(User, first_name='Фёдор', last_name='Шаляпин', email='support@m1crosoft.com')
     creator(name='Фёдор Шаляпин', email='support@m1crosoft.com')()
@@ -59,6 +53,13 @@ def test_existing_user(creator, mixer):
     assert get_user() == user
 
 
+def test_user_is_subscribed_with_tags(creator, mixer, subscribe):
+    user = mixer.blend(User, first_name='Фёдор', last_name='Шаляпин', email='support@m1crosoft.com')
+    creator(name='r00t', email='support@m1crosoft.com')()
+
+    subscribe.assert_called_once_with(user_id=user.pk, tags=['eggs-lead-magnet'])
+
+
 def test_log_entry_is_created(creator, campaign):
     creator(name='Фёдор Шаляпин', email='support@m1crosoft.com')()
 
diff --git a/src/shipping/tests/course_shipment/tests_course_shipment_to_mailchimp.py b/src/shipping/tests/course_shipment/tests_course_shipment_to_mailchimp.py
--- a/src/shipping/tests/course_shipment/tests_course_shipment_to_mailchimp.py
+++ b/src/shipping/tests/course_shipment/tests_course_shipment_to_mailchimp.py
@@ -17,7 +17,7 @@ def test(shipment, user, subscribe_to_mailchimp):
     subscribe_to_mailchimp.assert_called_once_with(
         list_id='100500',
         user_id=user.id,
-        tags=['sewing'],
+        tags=['sewing', 'sewing-purchased'],
     )
Repository: tough-dev-school/education-backend

Issue:
User.DoesNotExist: User matching query does not exist.
Sentry Issue: [EDUCATION-BACKEND-23](https://sentry.io/organizations/f213/issues/2200858697/?referrer=github_integration)

```
User.DoesNotExist: User matching query does not exist.
  File "celery/app/autoretry.py", line 34, in run
    return task._orig_run(*args, **kwargs)
  File "app/tasks.py", line 77, in subscribe_to_mailchimp
    user=apps.get_model('users.User').objects.get(pk=user_id),
  File "django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 435, in get
    raise self.model.DoesNotExist(
```


Discussion:

Resolving patch:
diff --git a/src/app/tasks.py b/src/app/tasks.py
--- a/src/app/tasks.py
+++ b/src/app/tasks.py
@@ -3,6 +3,7 @@
 from anymail.exceptions import AnymailRequestsAPIError
 from django.apps import apps
 from django.conf import settings
+from django.core.exceptions import ObjectDoesNotExist
 from requests.exceptions import RequestException
 
 from app.celery import celery
@@ -57,11 +58,12 @@ def invite_to_zoomus(webinar_id: str, user_id: int):
 
 
 @celery.task(
-    autoretry_for=[RequestException, MailchimpException],
+    autoretry_for=[RequestException, MailchimpException, ObjectDoesNotExist],
     retry_kwargs={
         'max_retries': 10,
         'countdown': 5,
     },
+    rate_limit='1/s',
 )
 def subscribe_to_mailchimp(user_id: int, list_id=None, tags=None):
     if list_id is None:


Test patch:
Repository: tough-dev-school/education-backend

Issue:
Массовые операции над промокодами
Всякий раз перед запуском нового курса приходится обходить старые промокоды и отключать их. Хочу массовую операцию, в админке. чтобы я просто выбрал их все и отключил.


Discussion:
Задачу забирает @Taranovskiy

Resolving patch:
diff --git a/src/orders/admin/__init__.py b/src/orders/admin/__init__.py
--- a/src/orders/admin/__init__.py
+++ b/src/orders/admin/__init__.py
@@ -1,2 +1,2 @@
 import orders.admin.orders.admin  # noqa
-import orders.admin.promocodes  # noqa
+import orders.admin.promocodes.admin  # noqa
diff --git a/src/orders/admin/promocodes/actions.py b/src/orders/admin/promocodes/actions.py
new file mode 100644
--- /dev/null
+++ b/src/orders/admin/promocodes/actions.py
@@ -0,0 +1,8 @@
+from django.utils.translation import gettext_lazy as _
+
+from app.admin import admin
+
+
+@admin.action(description=_('Deactivate selected promo codes'))
+def deactivate(modeladmin, request, queryset):
+    queryset.update(active=False)
diff --git a/src/orders/admin/promocodes.py b/src/orders/admin/promocodes/admin.py
similarity index 92%
rename from src/orders/admin/promocodes.py
rename to src/orders/admin/promocodes/admin.py
--- a/src/orders/admin/promocodes.py
+++ b/src/orders/admin/promocodes/admin.py
@@ -3,6 +3,7 @@
 from django.utils.translation import gettext_lazy as _
 
 from app.admin import ModelAdmin, admin
+from orders.admin.promocodes import actions
 from orders.models import PromoCode
 
 
@@ -26,6 +27,8 @@ class PromoCodeAdmin(ModelAdmin):
         'active',
     ]
 
+    actions = [actions.deactivate]
+
     def get_queryset(self, request):
         return super().get_queryset(request) \
             .with_order_count()


Test patch:
Repository: tough-dev-school/education-backend

Issue:
В админке во всех названиях курса выводить название потока
Сейчас совершенно непонятно, к какому потоку принадлежит курс — приходится догадываться по старшинству. Надо, чтобы вот тут (см. ниже) выводилось название ProductGroup, к которому привязан курс.

<img width="1511" alt="Screenshot 2022-06-20 at 10 55 18" src="https://user-images.githubusercontent.com/1592663/174552950-bf6ee7e8-6ba7-43f7-af90-5ba2fededfd7.png">




Discussion:
@f213 , взял это

Resolving patch:
diff --git a/src/products/models/course.py b/src/products/models/course.py
--- a/src/products/models/course.py
+++ b/src/products/models/course.py
@@ -105,3 +105,11 @@ def send_email_to_all_purchased_users(self, template_id: str):
                 to=user.email,
                 template_id=template_id,
             )
+
+    def __str__(self) -> str:
+        name = getattr(self, "name", None)
+        group = getattr(self, "group", None)
+        if name is not None and group is not None:
+            return f"{name} - {group.name}"
+
+        return super().__str__()


Test patch:
diff --git a/src/homework/tests/answers/tests_answer_string.py b/src/homework/tests/answers/tests_answer_str.py
similarity index 100%
rename from src/homework/tests/answers/tests_answer_string.py
rename to src/homework/tests/answers/tests_answer_str.py
diff --git a/src/products/tests/courses/tests_course_str.py b/src/products/tests/courses/tests_course_str.py
new file mode 100644
--- /dev/null
+++ b/src/products/tests/courses/tests_course_str.py
@@ -0,0 +1,14 @@
+import pytest
+
+pytestmark = [pytest.mark.django_db]
+
+
+def test_course(mixer):
+    course = mixer.blend("products.Course", name="Курс как стать милым котиком")
+    assert str(course) == "Курс как стать милым котиком"
+
+
+def test_course_with_group(mixer):
+    group = mixer.blend("products.Group", name="Милые котики")
+    course_with_group = mixer.blend("products.Course", name="Курс как стать милым котиком", group=group)
+    assert str(course_with_group) == "Курс как стать милым котиком - Милые котики"
Repository: hylang/hy

Issue:
fn/do
``` clojure
(fn []
  (do (print "Foo")))
```

breaks



Discussion:

Resolving patch:
diff --git a/hy/compiler.py b/hy/compiler.py
--- a/hy/compiler.py
+++ b/hy/compiler.py
@@ -67,7 +67,7 @@ def _mangle_branch(self, tree):
 
         if self.returnable and len(tree) > 0:
             el = tree[0]
-            if not isinstance(el, ast.stmt):
+            if not isinstance(el, (ast.stmt, list)):
                 el = tree.pop(0)
                 ret.append(ast.Return(value=el,
                                       lineno=el.lineno,


Test patch:
diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy
--- a/tests/native_tests/language.hy
+++ b/tests/native_tests/language.hy
@@ -85,6 +85,17 @@
       (assert (= 1 1))
       (assert (= 1 1)))))
 
+(defn test-branching-expr-count-with-do []
+  "NATIVE: make sure we execute the right number of expressions in the branch"
+  (setv counter 0)
+  (if false
+    (assert (= 2 1))
+    (do
+      (setv counter (+ counter 1))
+      (setv counter (+ counter 1))
+      (setv counter (+ counter 1))))
+  (assert (= counter 3)))
+
 
 (defn test-cond []
   "NATIVE: test if cond sorta works."
@@ -229,3 +240,38 @@
              [2 4]))
   (assert (= (list-comp (, x y) (x (range 2) y (range 2)))
              [(, 0 0) (, 0 1) (, 1 0) (, 1 1)])))
+
+(defn test-defn-order []
+  "NATIVE: test defn evaluation order"
+  (setv acc [])
+  (defn my-fun []
+    (.append acc "Foo")
+    (.append acc "Bar")
+    (.append acc "Baz"))
+  (my-fun)
+  (assert (= acc ["Foo" "Bar" "Baz"])))
+
+(defn test-defn-return []
+  "NATIVE: test defn return"
+  (defn my-fun [x]
+    (+ x 1))
+  (assert (= 43 (my-fun 42))))
+
+(defn test-defn-do []
+  "NATIVE: test defn evaluation order with do"
+  (setv acc [])
+  (defn my-fun []
+    (do
+      (.append acc "Foo")
+      (.append acc "Bar")
+      (.append acc "Baz")))
+  (my-fun)
+  (assert (= acc ["Foo" "Bar" "Baz"])))
+
+(defn test-defn-do-return []
+  "NATIVE: test defn return with do"
+  (defn my-fun [x]
+    (do
+      (+ x 42)  ; noop
+      (+ x 1)))
+  (assert (= 43 (my-fun 42))))
Repository: hylang/hy

Issue:
Allow (raise)
That's actually valid in Python to re-raise the last catched exception.



Discussion:

Resolving patch:
diff --git a/hy/compiler.py b/hy/compiler.py
--- a/hy/compiler.py
+++ b/hy/compiler.py
@@ -167,10 +167,10 @@ def compile_do_expression(self, expr):
 
     @builds("throw")
     @builds("raise")
-    @checkargs(min=1)
+    @checkargs(max=1)
     def compile_throw_expression(self, expr):
         expr.pop(0)
-        exc = self.compile(expr.pop(0))
+        exc = self.compile(expr.pop(0)) if expr else None
         return ast.Raise(
             lineno=expr.start_line,
             col_offset=expr.start_column,


Test patch:
diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py
--- a/tests/compilers/test_ast.py
+++ b/tests/compilers/test_ast.py
@@ -94,22 +94,24 @@ def test_ast_good_do():
 
 def test_ast_good_throw():
     "Make sure AST can compile valid throw"
+    hy_compile(tokenize("(throw)"))
     hy_compile(tokenize("(throw 1)"))
 
 
 def test_ast_bad_throw():
     "Make sure AST can't compile invalid throw"
-    cant_compile("(throw)")
+    cant_compile("(raise 1 2 3)")
 
 
 def test_ast_good_raise():
     "Make sure AST can compile valid raise"
+    hy_compile(tokenize("(raise)"))
     hy_compile(tokenize("(raise 1)"))
 
 
 def test_ast_bad_raise():
     "Make sure AST can't compile invalid raise"
-    cant_compile("(raise)")
+    cant_compile("(raise 1 2 3)")
 
 
 def test_ast_good_try():
diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy
--- a/tests/native_tests/language.hy
+++ b/tests/native_tests/language.hy
@@ -178,6 +178,26 @@
 
   (try (pass) (except [IOError]) (except))
 
+  ;; Test correct (raise)
+  (let [[passed false]]
+    (try
+      (try
+        (raise IndexError)
+        (except [IndexError] (raise)))
+      (except [IndexError]
+              (setv passed true)))
+    (assert passed))
+
+  ;; Test incorrect (raise)
+  (let [[passed false]]
+    (try
+      (raise)
+      ;; Python 2 raises TypeError
+      ;; Python 3 raises RuntimeError
+      (except [[TypeError RuntimeError]]
+              (setv passed true)))
+    (assert passed))
+
   (try
     (raise (KeyError))
     (catch [[IOError]] (assert false))
Repository: hylang/hy

Issue:
Implement integer division operator
Hy doesn't seem to know about Python's integer division operator ("//") yet.



Discussion:

Resolving patch:
diff --git a/hy/compiler.py b/hy/compiler.py
--- a/hy/compiler.py
+++ b/hy/compiler.py
@@ -708,6 +708,7 @@ def compile_compare_op_expression(self, expression):
     @builds("%")
     @builds("-")
     @builds("/")
+    @builds("//")
     @builds("*")
     @checkargs(min=2)
     def compile_maths_expression(self, expression):
@@ -717,6 +718,7 @@ def compile_maths_expression(self, expression):
 
         ops = {"+": ast.Add,
                "/": ast.Div,
+               "//": ast.FloorDiv,
                "*": ast.Mult,
                "-": ast.Sub,
                "%": ast.Mod}


Test patch:
diff --git a/tests/native_tests/math.hy b/tests/native_tests/math.hy
--- a/tests/native_tests/math.hy
+++ b/tests/native_tests/math.hy
@@ -29,6 +29,10 @@
   "NATIVE: Test division"
   (assert (= 25 (/ 100 2 2)))))
 
+(setv test_int_div (fn []
+  "NATIVE: Test integer division"
+  (assert (= 25 (// 101 2 2)))))
+
 (defn test-modulo []
   "NATIVE: test mod"
   (assert (= (% 10 2) 0)))
Repository: hylang/hy

Issue:
Unifying division
Since we are effectively creating a new language, we might as well fix one of the nastiest Python portability problems between 2 and 3: division. I propose to do an implicit "from **future** import division" at the top of any Hy module, as well as before starting the REPL, when running under Python 2.x.



Discussion:
I'm +1.

If we want to break stuff, why not go the lisp way and return fractions?

Personally I'd be happy with returning fractions, which have been part of the Python standard library since 2.6. But for a Python-compatible language I prefer following Python habits as much as possible. We can always provide a more lispy math stack with fractions etc. in the Hy standard library ;-)

Right, let's just do future division. It trips me up all day, and Hy shouldn't behave _that_ differently from 2 to 3. 

:+1: on the idea.


Resolving patch:
diff --git a/hy/importer.py b/hy/importer.py
--- a/hy/importer.py
+++ b/hy/importer.py
@@ -31,7 +31,7 @@
 import sys
 import ast
 import os
-
+import __future__
 
 if sys.version_info[0] >= 3:
     from io import StringIO
@@ -39,6 +39,10 @@
     from StringIO import StringIO  # NOQA
 
 
+def compile_(ast, filename, mode):
+    return compile(ast, filename, mode, __future__.CO_FUTURE_DIVISION)
+
+
 def import_buffer_to_hst(fd):
     tree = tokenize(fd.read() + "\n")
     tree = process(tree)
@@ -65,7 +69,7 @@ def import_file_to_module(name, fpath):
     _ast = import_file_to_ast(fpath)
     mod = imp.new_module(name)
     mod.__file__ = fpath
-    eval(compile(_ast, fpath, "exec"), mod.__dict__)
+    eval(compile_(_ast, fpath, "exec"), mod.__dict__)
     return mod
 
 
@@ -77,7 +81,7 @@ def hy_eval(hytree, namespace):
     foo.end_column = 0
     hytree.replace(foo)
     _ast = hy_compile(hytree, root=ast.Expression)
-    return eval(compile(_ast, "<eval>", "eval"), namespace)
+    return eval(compile_(_ast, "<eval>", "eval"), namespace)
 
 
 def write_hy_as_pyc(fname):
@@ -88,7 +92,7 @@ def write_hy_as_pyc(fname):
             timestamp = long(os.stat(fname).st_mtime)
 
     _ast = import_file_to_ast(fname)
-    code = compile(_ast, fname, "exec")
+    code = compile_(_ast, fname, "exec")
     cfile = "%s.pyc" % fname[:-len(".hy")]
 
     with open(cfile, 'wb') as fc:


Test patch:
diff --git a/tests/native_tests/math.hy b/tests/native_tests/math.hy
--- a/tests/native_tests/math.hy
+++ b/tests/native_tests/math.hy
@@ -27,7 +27,10 @@
 
 (setv test_div (fn []
   "NATIVE: Test division"
-  (assert (= 25 (/ 100 2 2)))))
+  (assert (= 25 (/ 100 2 2)))
+  ; Commented out until float constants get implemented
+  ; (assert (= 0.5 (/ 1 2)))
+  (assert (= 1 (* 2 (/ 1 2))))))
 
 (setv test_int_div (fn []
   "NATIVE: Test integer division"
Repository: hylang/hy

Issue:
Quote doesn't return valid lists
```
=> (car (quote [if 1 2 3]))
u'if'
=> (cdr (quote [if 1 2 3]))
[1, 2, 3]
```

=> OK

```
=> (car (quote (if 1 2 3)))
u'_hy_hoisted_fn_1'
=> (car (car (quote (if 1 2 3))))
u'_'
=> (cdr (quote (if 1 2 3)))
[]
```

=> Not ok



Discussion:
@jd ok, this is due to bad hoisting behavior -- I could have sworn I filed a bug on this.

Huge ACK.


Resolving patch:
diff --git a/hy/core/mangles.py b/hy/core/mangles.py
--- a/hy/core/mangles.py
+++ b/hy/core/mangles.py
@@ -27,6 +27,11 @@
 
 class HoistableMangle(hy.mangle.Mangle):
     def should_hoist(self):
+        for frame in self.stack:
+            if (isinstance(frame, HyExpression) and
+                    frame and frame[0] == "quote"):
+                return False
+
         for frame in self.stack:
             if frame is self.scope:
                 return False


Test patch:
diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy
--- a/tests/native_tests/language.hy
+++ b/tests/native_tests/language.hy
@@ -583,7 +583,9 @@
   (setf test-payload (quote (+ x 2)))
   (setf x 4)
   (assert (= 6 (eval test-payload)))
-  (assert (= 6 (eval (quote ((fn [] (+ 3 3)))))))
+  ; (assert (= 6 (eval (quote ((fn [] (+ 3 3)))))))
+  ; XXX: This must be commented out while we resolve stmts being run through
+  ; eval. Please fix me. -- PRT
   (assert (= 1 (eval (quote 1))))
   (assert (= "foobar" (eval (quote "foobar"))))
   (setv x (quote 42))
@@ -616,3 +618,10 @@
   (assert (= (dirname "/some/path") "/some"))
   (assert (= op.dirname dirname))
   (assert (= dn dirname)))
+
+
+(defn test-quoted-hoistable []
+  "NATIVE: test quoted hoistable"
+  (setf f (quote (if true true true)))
+  (assert (= (car f) "if"))
+  (assert (= (cdr f) (quote (true true true)))))
Repository: hylang/hy

Issue:
LIST-COMP breaks with certain variable names
Try compiling:

```
(list-comp (, i j) (i [-1 0 1] j [-1 0 1]))
```

With hy and you'll get some strange errors. If you replace "i" and "j" with "x" and "y" respectively, the same piece of code works as expected.



Discussion:
..... awesome


Resolving patch:
diff --git a/hy/lex/states.py b/hy/lex/states.py
--- a/hy/lex/states.py
+++ b/hy/lex/states.py
@@ -67,10 +67,11 @@ def _resolve_atom(obj):
     except ValueError:
         pass
 
-    try:
-        return HyComplex(obj)
-    except ValueError:
-        pass
+    if obj != "j":
+        try:
+            return HyComplex(obj)
+        except ValueError:
+            pass
 
     table = {
         "true": "True",


Test patch:
diff --git a/tests/lex/test_lex.py b/tests/lex/test_lex.py
--- a/tests/lex/test_lex.py
+++ b/tests/lex/test_lex.py
@@ -230,3 +230,12 @@ def test_hashbang():
     """ Ensure we can escape things """
     entry = tokenize("#!this is a comment\n")
     assert entry == []
+
+
+def test_complex():
+    """Ensure we tokenize complex numbers properly"""
+    # This is a regression test for #143
+    entry = tokenize("(1j)")[0][0]
+    assert entry == HyComplex("1.0j")
+    entry = tokenize("(j)")[0][0]
+    assert entry == HySymbol("j")
diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy
--- a/tests/native_tests/language.hy
+++ b/tests/native_tests/language.hy
@@ -420,7 +420,8 @@
   (assert (= (sorted (list-comp (* y 2) ((, x y) (.items {"1" 1 "2" 2}))))
              [2 4]))
   (assert (= (list-comp (, x y) (x (range 2) y (range 2)))
-             [(, 0 0) (, 0 1) (, 1 0) (, 1 1)])))
+             [(, 0 0) (, 0 1) (, 1 0) (, 1 1)]))
+  (assert (= (list-comp j (j [1 2])) [1 2])))
 
 
 (defn test-defn-order []