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

Issue:
REGR: assigning multiple columns using pandas.Index raises a ValueError
#2577 caused a regression caught by momepy's CI.

See the example:

```py
df = gpd.read_file(gpd.datasets.get_path('nybb'))

other_df = pd.DataFrame({
    "foo": range(5),
    "bar": range(5)
})

df[other_df.columns] = other_df

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[20], line 1
----> 1 df[other_df.columns] = other_df

File [~/Git/geopandas/geopandas/geodataframe.py:1500](https://file+.vscode-resource.vscode-cdn.net/Users/martin/Git/geopandas/~/Git/geopandas/geopandas/geodataframe.py:1500), in GeoDataFrame.__setitem__(self, key, value)
   1494 def __setitem__(self, key, value):
   1495     """
   1496     Overwritten to preserve CRS of GeometryArray in cases like
   1497     df['geometry'] = [geom... for geom in df.geometry]
   1498     """
-> 1500     if (
   1501         not pd.api.types.is_list_like(key)
   1502         and key == self._geometry_column_name
   1503         or key == "geometry"
   1504         and self._geometry_column_name is None
   1505     ):
   1506         if pd.api.types.is_scalar(value) or isinstance(value, BaseGeometry):
   1507             value = [value] * self.shape[0]

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```

When "key" is a pandas.Index, we hit the error. It doesn't happen when I cast it to a list. I assume that that condition may need an additional pair of brackets so we don't check the index against `== "geometry"`

cc @m-richards 


Discussion:

Resolving patch:
diff --git a/geopandas/geodataframe.py b/geopandas/geodataframe.py
--- a/geopandas/geodataframe.py
+++ b/geopandas/geodataframe.py
@@ -1497,9 +1497,8 @@ def __setitem__(self, key, value):
         df['geometry'] = [geom... for geom in df.geometry]
         """
 
-        if (
-            not pd.api.types.is_list_like(key)
-            and key == self._geometry_column_name
+        if not pd.api.types.is_list_like(key) and (
+            key == self._geometry_column_name
             or key == "geometry"
             and self._geometry_column_name is None
         ):


Test patch:
diff --git a/geopandas/tests/test_geodataframe.py b/geopandas/tests/test_geodataframe.py
--- a/geopandas/tests/test_geodataframe.py
+++ b/geopandas/tests/test_geodataframe.py
@@ -1414,6 +1414,14 @@ def test_multiindex_geometry_colname_3_level_new_col(self):
         assert gdf._geometry_column_name == ("geometry", "", "")
         assert gdf.geometry.name == ("geometry", "", "")
 
+    def test_assign_cols_using_index(self):
+        nybb_filename = geopandas.datasets.get_path("nybb")
+        df = read_file(nybb_filename)
+        other_df = pd.DataFrame({"foo": range(5), "bar": range(5)})
+        expected = pd.concat([df, other_df], axis=1)
+        df[other_df.columns] = other_df
+        assert_geodataframe_equal(df, expected)
+
 
 def test_geodataframe_crs():
     gdf = GeoDataFrame(columns=["geometry"])
Repository: geopandas/geopandas

Issue:
ENH: link files with .fgb extension to FlatGeobuf driver
#### Is your feature request related to a problem?

I whish `GeoDataFrame.to_file()` method would recognize `.fgb` file-extensions as FlatGeobuf files and automatically select the corresponding driver. At this moment, it needs to be specified explicitly.

#### Describe the solution you'd like

The `filename` argument of `GeoDataFrame.to_file()` should recognize `.fgb` extensions as FlatGeobuf files.

#### API breaking implications

None

#### Describe alternatives you've considered

Explicitly specify the driver to use.

#### Additional context

I think that the only thing that needs to be changed is to add an entry

```python
  ".fgb":  "FlatGeobuf"
```
to the `_EXTENSION_TO_DRIVER` dict in `geopandas\io\file.py`





Discussion:
Yeah, that's correct. Can you make a PR?

Resolving patch:
diff --git a/geopandas/io/file.py b/geopandas/io/file.py
--- a/geopandas/io/file.py
+++ b/geopandas/io/file.py
@@ -141,6 +141,7 @@ def _check_engine(engine, func):
     ".mif": "MapInfo File",
     ".mid": "MapInfo File",
     ".dgn": "DGN",
+    ".fgb": "FlatGeobuf",
 }
 
 


Test patch:
Repository: geopandas/geopandas

Issue:
DOC: printed PROJ ERROR log in online docs
### Buggy behavior:
Below the code box in the [Reading Files section of the Getting Started page](https://geopandas.org/en/stable/getting_started/introduction.html#Reading-files), I get the following error message:
`ERROR 1: PROJ: proj_create_from_database: Open of /home/docs/checkouts/readthedocs.org/user_builds/geopandas/conda/stable/share/proj failed`
The output below that looks fine to me. Cf. this screenshot:

![grafik](https://user-images.githubusercontent.com/44754681/208923157-519a0da3-2484-407b-8d99-612df8b5a94b.png)

### Expected behavior:
No error message appearing.

### Steps to reproduce:
Visit the website at the above link.

### System Details

- Windows 10, version 22H2, build 19045.2364
- Browsers tested:
   - Firefox, version 108.0.1 (64-bit)
   - Chrome, official build, version 108.0.5359.125 (64-bit)
   - Edge, official build, version 108.0.1462.54 (64-bit)


----------

Please do let me know if this isn't the right place for this bug report, I'd be happy to move it.


Discussion:
Hey @MischaDy, thanks for the report, I've also noticed this. Although it's not ideal to have warnings in the docs, it is fortunately non critical in this example.
It's indeed not an actual error (in the sense of a Python exception that interrupts the execution of the code), but a printed error log from PROJ / pyproj. But it _is_ annoying and distracting. 

This was also mentioned at https://github.com/geopandas/geopandas/issues/2652#issuecomment-1326668393. For some reason the environment created online for building the docs has this issue, but so we can't reproduce this locally (which makes it hard to investigate).
Hello - I was wondering if this has been investigated further?
@nicholasbalasus there's some discussion in https://github.com/conda-forge/pyproj-feedstock/issues/130 but no solution as far as I can tell.

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -383,8 +383,8 @@ def setup(app):
         "https://fiona.readthedocs.io/en/stable/objects.inv",
     ),
     "folium": (
-        "https://python-visualization.github.io/folium/",
-        "https://python-visualization.github.io/folium/objects.inv",
+        "https://python-visualization.github.io/folium/latest",
+        "https://python-visualization.github.io/folium/latest/objects.inv",
     ),
     "geoplot": (
         "https://residentmario.github.io/geoplot/index.html",
diff --git a/geopandas/base.py b/geopandas/base.py
--- a/geopandas/base.py
+++ b/geopandas/base.py
@@ -4539,7 +4539,7 @@ def shortest_line(self, other, align=None):
         The operation works on a 1-to-1 row-wise manner:
 
         .. image:: ../../../_static/binary_op-01.svg
-        :align: center
+            :align: center
 
         Parameters
         ----------


Test patch:
Repository: inventree/InvenTree

Issue:
Show quantity when adding to BOM
I am building a BOM and I have a few parts like 1µF caps where there are multiple entries for different manufactures even thought they would be considered interchangeable. It would be nice to have the quantity displayed next to the add item to bom sub-part so that you can pick which one actually has parts in stock.

I think this touches on an issue of is there a way to have a generic heading like 1µF 0805 Caps and have multiple children fill it?


Discussion:
I'm not quite sure what you mean here, can you perhaps add some more detail, or a screenshot?

<img width="1184" alt="Screen Shot 2020-04-27 at 9 16 44 PM" src="https://user-images.githubusercontent.com/36831279/80436148-73756200-88cc-11ea-8747-52dd5e6fbda9.png">

To the right of where it reads `chip` you could provide additional item information to help narrow down picking a part. Like quantity.
Ah ok I understand. That might take some thought to work out the best way to implement. But I like the idea. In general the modal forms need to include a lot more context data! Cheers

Resolving patch:
diff --git a/InvenTree/part/forms.py b/InvenTree/part/forms.py
--- a/InvenTree/part/forms.py
+++ b/InvenTree/part/forms.py
@@ -196,11 +196,19 @@ class Meta:
         ]
 
 
+class PartModelChoiceField(forms.ModelChoiceField):
+    """ Extending string representation of Part instance with available stock """
+    def label_from_instance(self, part):
+        return f'{part} - {part.available_stock}'
+
+
 class EditBomItemForm(HelperForm):
     """ Form for editing a BomItem object """
 
     quantity = RoundingDecimalFormField(max_digits=10, decimal_places=5)
 
+    sub_part = PartModelChoiceField(queryset=Part.objects.all())
+
     class Meta:
         model = BomItem
         fields = [
diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py
--- a/InvenTree/part/models.py
+++ b/InvenTree/part/models.py
@@ -268,7 +268,7 @@ def save(self, *args, **kwargs):
         super().save(*args, **kwargs)
 
     def __str__(self):
-        return "{n} - {d}".format(n=self.full_name, d=self.description)
+        return f"{self.full_name} - {self.description}"
 
     def checkAddToBOM(self, parent):
         """


Test patch:
Repository: inventree/InvenTree

Issue:
Homepage / splash screen
Home page should show important outstanding information

- [x] parts with stock below minimum_stock level
- [ ] outstanding purchase orders
- [ ] outstanding customer orders
- [x] stock required to meet pending builds
- [ ] stock that requires attention for some reason


Discussion:
Improvements made in https://github.com/inventree/InvenTree/pull/203

Resolving patch:
diff --git a/InvenTree/build/api.py b/InvenTree/build/api.py
--- a/InvenTree/build/api.py
+++ b/InvenTree/build/api.py
@@ -59,7 +59,10 @@ def filter_queryset(self, queryset):
         status = self.request.query_params.get('status', None)
 
         if status is not None:
-            queryset = queryset.filter(status=status)
+            # Get status codes
+            codes = status.split('-')
+            # Filter by codes
+            queryset = queryset.filter(status__in=codes)
 
         # Filter by associated part?
         part = self.request.query_params.get('part', None)
diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py
--- a/InvenTree/part/api.py
+++ b/InvenTree/part/api.py
@@ -405,6 +405,27 @@ def filter_queryset(self, queryset):
             except (ValueError, Part.DoesNotExist):
                 pass
 
+        # Filter by latest part creation date
+        latest_parts = params.get('latest_parts', None)
+
+        if latest_parts is not None:
+            # Get the last 5 created parts
+            queryset = queryset.order_by('-creation_date')[:5]
+
+        # Filter invalid BOMs
+        bom_invalid = params.get('bom_invalid', None)
+
+        if bom_invalid is not None:
+            # Get assemblies with invalid BOMs
+            assemblies = queryset.filter(active=True).filter(assembly=True)
+            valid_boms = []
+
+            for part in assemblies:
+                if part.is_bom_valid:
+                    valid_boms.append(part.pk)
+
+            queryset = assemblies.exclude(pk__in=valid_boms)
+
         # Filter by 'starred' parts?
         starred = params.get('starred', None)
 
@@ -477,6 +498,22 @@ def filter_queryset(self, queryset):
                 # Filter items which have an 'in_stock' level higher than 'minimum_stock'
                 queryset = queryset.filter(Q(in_stock__gte=F('minimum_stock')))
 
+        # Filter by "parts which need stock to complete build"
+        stock_to_build = params.get('stock_to_build', None)
+
+        if stock_to_build is not None:
+            # Filter only active parts
+            queryset = queryset.filter(active=True)
+            parts_need_stock = []
+
+            # Find parts with active builds
+            # where any subpart's stock is lower than quantity being built
+            for part in queryset:
+                if part.active_builds and part.can_build < part.quantity_being_built:
+                    parts_need_stock.append(part.pk)
+
+            queryset = queryset.filter(pk__in=parts_need_stock)
+
         return queryset
 
     permission_classes = [


Test patch:
Repository: inventree/InvenTree

Issue:
Method to extract Default Location from API?
Either in the Part creation or in Category creation through the Django interface, a Default Location can be set.  Through the API, I know how to neither query nor set that default location. When adding new Parts or StockItems through the API, it would be nice to set the location to the Default for the Category or Part automatically.

Is there a method via API for finding this Default Location that I'm missing?

This is, for me, the last piece of the puzzle for scanning a bag barcode from existing inventory to new StockItem (and SupplierPart, MFG, Part as necessary).  It's working without Location for now - I've added several already. Thanks again, @SchrodingersGat. 


Discussion:

Resolving patch:
diff --git a/InvenTree/part/serializers.py b/InvenTree/part/serializers.py
--- a/InvenTree/part/serializers.py
+++ b/InvenTree/part/serializers.py
@@ -2,30 +2,20 @@
 JSON serializers for Part app
 """
 import imghdr
-
-from rest_framework import serializers
-
-from .models import Part, PartStar
-
-from .models import PartCategory
-from .models import BomItem
-from .models import PartParameter, PartParameterTemplate
-from .models import PartAttachment
-from .models import PartTestTemplate
-from .models import PartSellPriceBreak
-
-from stock.models import StockItem
-
 from decimal import Decimal
 
-from sql_util.utils import SubquerySum, SubqueryCount
-
 from django.db.models import Q
 from django.db.models.functions import Coalesce
+from InvenTree.serializers import (InvenTreeAttachmentSerializerField,
+                                   InvenTreeModelSerializer)
+from InvenTree.status_codes import BuildStatus, PurchaseOrderStatus
+from rest_framework import serializers
+from sql_util.utils import SubqueryCount, SubquerySum
+from stock.models import StockItem
 
-from InvenTree.status_codes import PurchaseOrderStatus, BuildStatus
-from InvenTree.serializers import InvenTreeModelSerializer
-from InvenTree.serializers import InvenTreeAttachmentSerializerField
+from .models import (BomItem, Part, PartAttachment, PartCategory,
+                     PartParameter, PartParameterTemplate, PartSellPriceBreak,
+                     PartStar, PartTestTemplate)
 
 
 class CategorySerializer(InvenTreeModelSerializer):
@@ -41,6 +31,7 @@ class Meta:
             'pk',
             'name',
             'description',
+            'default_location',
             'pathstring',
             'url',
             'parent',
@@ -304,6 +295,7 @@ class Meta:
             'category_detail',
             'component',
             'description',
+            'default_location',
             'full_name',
             'image',
             'in_stock',


Test patch:
Repository: inventree/InvenTree

Issue:
Add IPN as a sort option when building a purchase order
When I was adding items to my PO I noticed you can only search by the 'Supplier SKU' since all my parts have either the MFG# or my IPN on them it would be awesome if you could add those part numbers in the search when adding to PO.

Some suppliers SKUs don't always make sense and it would be easier if you could search for it by IPN.


Discussion:
I just thought to myself that you can probabley goto the part and add it to a PO but I haven't tried this yet.

Resolving patch:
diff --git a/InvenTree/company/models.py b/InvenTree/company/models.py
--- a/InvenTree/company/models.py
+++ b/InvenTree/company/models.py
@@ -423,12 +423,16 @@ def pretty_name(self):
         return str(self)
 
     def __str__(self):
-        s = "{supplier} ({sku})".format(
-            sku=self.SKU,
-            supplier=self.supplier.name)
+        s = ''
+
+        if self.part.IPN:
+            s += f'{self.part.IPN}'
+            s += ' | '
+
+        s += f'{self.supplier.name} | {self.SKU}'
 
         if self.manufacturer_string:
-            s = s + ' - ' + self.manufacturer_string
+            s = s + ' | ' + self.manufacturer_string
         
         return s
 


Test patch:
Repository: inventree/InvenTree

Issue:
Typo in "Create new part" / "Edit Part Properties" forms: "Link to extenal URL"
Per the title.

While I'm at it, inconsistent capitalisation of these two form titles.


Discussion:
https://github.com/inventree/InvenTree/blob/9ed787b4da8a75d6bdc695d2fee1c6ae440af697/InvenTree/part/models.py#L565

Resolving patch:
diff --git a/InvenTree/part/migrations/0052_auto_20201027_1557.py b/InvenTree/part/migrations/0052_auto_20201027_1557.py
new file mode 100644
--- /dev/null
+++ b/InvenTree/part/migrations/0052_auto_20201027_1557.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.0.7 on 2020-10-27 04:57
+
+import InvenTree.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('part', '0051_bomitem_optional'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='part',
+            name='link',
+            field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True),
+        ),
+    ]
diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py
--- a/InvenTree/part/models.py
+++ b/InvenTree/part/models.py
@@ -562,7 +562,7 @@ def clean(self):
 
     revision = models.CharField(max_length=100, blank=True, null=True, help_text=_('Part revision or version number'))
 
-    link = InvenTreeURLField(blank=True, null=True, help_text=_('Link to extenal URL'))
+    link = InvenTreeURLField(blank=True, null=True, help_text=_('Link to external URL'))
 
     image = StdImageField(
         upload_to=rename_part_image,
diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py
--- a/InvenTree/part/views.py
+++ b/InvenTree/part/views.py
@@ -510,7 +510,7 @@ class PartCreate(AjaxCreateView):
     model = Part
     form_class = part_forms.EditPartForm
 
-    ajax_form_title = _('Create new part')
+    ajax_form_title = _('Create New Part')
     ajax_template_name = 'part/create_part.html'
 
     role_required = 'part.add'


Test patch:
Repository: inventree/InvenTree

Issue:
Quick view of what roles are assigned to each group
![image](https://user-images.githubusercontent.com/10080325/96441885-fc56d000-1255-11eb-93fd-e9a1d7a16471.png)

As above:

- Next to each group, show a column for each possible role
- For each cell, show which permissions are used (read / add / modify / delete)


Discussion:

Resolving patch:
diff --git a/InvenTree/users/admin.py b/InvenTree/users/admin.py
--- a/InvenTree/users/admin.py
+++ b/InvenTree/users/admin.py
@@ -87,6 +87,64 @@ class RoleGroupAdmin(admin.ModelAdmin):
         RuleSetInline,
     ]
 
+    list_display = ('name', 'admin', 'part', 'stock', 'build', 'purchase_order', 'sales_order')
+
+    def get_rule_set(self, obj, rule_set_type):
+        ''' Return list of permissions for the given ruleset '''
+
+        # Get all rulesets associated to object
+        rule_sets = RuleSet.objects.filter(group=obj.pk)
+
+        # Select ruleset based on type
+        for rule_set in rule_sets:
+            if rule_set.name == rule_set_type:
+                break
+
+        def append_permission_level(permission_level, next_level):
+            if not permission_level:
+                return next_level
+
+            if permission_level[:-1].endswith('|'):
+                permission_level += next_level
+            else:
+                permission_level += ' | ' + next_level
+
+            return permission_level
+
+        permission_level = ''
+
+        if rule_set.can_view:
+            permission_level = append_permission_level(permission_level, 'V')
+
+        if rule_set.can_add:
+            permission_level = append_permission_level(permission_level, 'A')
+
+        if rule_set.can_change:
+            permission_level = append_permission_level(permission_level, 'C')
+
+        if rule_set.can_delete:
+            permission_level = append_permission_level(permission_level, 'D')
+        
+        return permission_level
+
+    def admin(self, obj):
+        return self.get_rule_set(obj, 'admin')
+
+    def part(self, obj):
+        return self.get_rule_set(obj, 'part')
+
+    def stock(self, obj):
+        return self.get_rule_set(obj, 'stock')
+
+    def build(self, obj):
+        return self.get_rule_set(obj, 'build')
+
+    def purchase_order(self, obj):
+        return self.get_rule_set(obj, 'purchase_order')
+
+    def sales_order(self, obj):
+        return self.get_rule_set(obj, 'sales_order')
+
     def get_formsets_with_inlines(self, request, obj=None):
         for inline in self.get_inline_instances(request, obj):
             # Hide RuleSetInline in the 'Add role' view


Test patch:
Repository: inventree/InvenTree

Issue:
Restore backup
I have found several mentions of doing a backup in the documentation but no mention of how to perform the restore.
In my test instance I've configured "backup_dir" in config.yaml and performed a backup with "inv backup". Could not find a "restore" method defined in tasks.py

Is there something I'm missing?


Discussion:

Resolving patch:
diff --git a/tasks.py b/tasks.py
--- a/tasks.py
+++ b/tasks.py
@@ -349,12 +349,22 @@ def backup(c):
     Create a backup of database models and uploaded media files.
 
     Backup files will be written to the 'backup_dir' file specified in 'config.yaml'
-
     """
 
     manage(c, 'dbbackup')
     manage(c, 'mediabackup')
 
+@task
+def restore(c):
+    """
+    Restores database models and media files.
+
+    Backup files are read from the 'backup_dir' file specified in 'config.yaml'
+    """
+
+    manage(c, 'dbrestore')
+    manage(c, 'mediarestore')
+
 @task(help={'address': 'Server address:port (default=127.0.0.1:8000)'})
 def server(c, address="127.0.0.1:8000"):
     """


Test patch: