nebius/SWE-bench-extra huggingface dataset:
Repository: googleapis/python-bigquery

Issue:
Bigquery: Model reference repr seems wrong for model_id
For `ModelReference`'s repr use project_id against model_id

https://github.com/googleapis/python-bigquery/blob/be5c8b1ede9a2d762fd5574c32587d125eca4713/google/cloud/bigquery/model.py#L432-L435

Comments:

Patch:
diff --git a/google/cloud/bigquery/model.py b/google/cloud/bigquery/model.py
index d39ec5f2..a2510e86 100644
--- a/google/cloud/bigquery/model.py
+++ b/google/cloud/bigquery/model.py
@@ -430,6 +430,6 @@ class ModelReference(object):
         return hash(self._key())
 
     def __repr__(self):
-        return "ModelReference(project='{}', dataset_id='{}', project_id='{}')".format(
+        return "ModelReference(project_id='{}', dataset_id='{}', model_id='{}')".format(
             self.project, self.dataset_id, self.model_id
         )


Test patch:
diff --git a/tests/unit/model/test_model.py b/tests/unit/model/test_model.py
index bbb93ef9..90fc09e6 100644
--- a/tests/unit/model/test_model.py
+++ b/tests/unit/model/test_model.py
@@ -316,5 +316,5 @@ def test_repr(target_class):
     got = repr(model)
     assert got == (
         "Model(reference=ModelReference("
-        "project='my-proj', dataset_id='my_dset', project_id='my_model'))"
+        "project_id='my-proj', dataset_id='my_dset', model_id='my_model'))"
     )
diff --git a/tests/unit/model/test_model_reference.py b/tests/unit/model/test_model_reference.py
index ff1d1df7..39dabb55 100644
--- a/tests/unit/model/test_model_reference.py
+++ b/tests/unit/model/test_model_reference.py
@@ -136,5 +136,5 @@ def test_repr(target_class):
     got = repr(model)
     assert (
         got
-        == "ModelReference(project='my-proj', dataset_id='my_dset', project_id='my_model')"
+        == "ModelReference(project_id='my-proj', dataset_id='my_dset', model_id='my_model')"
     )
Repository: googleapis/python-datastore

Issue:
datastore Key id_or_name() returns None when id is 0
#### Description 
Expecting the Key().is_partial to return False for a Key with id=0.
The is_partial property relies on the id_or_name property.
The id_or_name property returns None when the id=0, which is not expected. Expecting the id to be returned instead.
The id_or_name property implementation is to simple. Should check for None or isinstance(self.id, int)

#### Environment details

  - OS type and version: Ubuntu 20.04
  - Python version: Python 3.8.5
  - pip version: pip 20.2.3
  - `google-cloud-datastore` version: 1.15.3

#### Steps to reproduce

1. Create a datastore key instance with Id = 0
2. Retrieve the id_or_name property, returns None, expected 0.

#### Code example

```python
def test_datastore_key():
    import google.cloud.datastore
    k = google.cloud.datastore.Key('EntityKind', 0, project="unittest")
    assert k.id == 0
    assert k.id_or_name == 0
    assert k.is_partial == False
```

#### Stack trace
```
assert None == 0
  +None
  -0
def test_datastore_key():
        import google.cloud.datastore
        k = google.cloud.datastore.Key('EntityKind', 0, project="unittest")
        assert k.id == 0
>       assert k.id_or_name == 0
E       assert None == 0
E         +None
E         -0
```


Comments:

Patch:
diff --git a/google/cloud/datastore/key.py b/google/cloud/datastore/key.py
index d03359b..c9beaeb 100644
--- a/google/cloud/datastore/key.py
+++ b/google/cloud/datastore/key.py
@@ -441,7 +441,9 @@ class Key(object):
         :returns: The last element of the key's path if it is either an ``id``
                   or a ``name``.
         """
-        return self.id or self.name
+        if self.id is None:
+            return self.name
+        return self.id
 
     @property
     def project(self):


Test patch:
diff --git a/tests/unit/test_key.py b/tests/unit/test_key.py
index 73565ea..9d130fb 100644
--- a/tests/unit/test_key.py
+++ b/tests/unit/test_key.py
@@ -488,6 +488,11 @@ class TestKey(unittest.TestCase):
         key = self._make_one("KIND", _NAME, project=self._DEFAULT_PROJECT)
         self.assertEqual(key.id_or_name, _NAME)
 
+    def test_id_or_name_w_id_zero(self):
+        _ID = 0
+        key = self._make_one("KIND", _ID, project=self._DEFAULT_PROJECT)
+        self.assertEqual(key.id_or_name, _ID)
+
     def test_parent_default(self):
         key = self._make_one("KIND", project=self._DEFAULT_PROJECT)
         self.assertIsNone(key.parent)
Repository: googleapis/python-spanner

Issue:
float value cannot be used to insert data to NUMERIC field.
Float data type is mapped to float: spanner.param_types.FLOAT64 [Link](https://github.com/googleapis/python-spanner/blob/master/google/cloud/spanner_dbapi/parse_utils.py#L35).

We need to add support to map decimal.Decimal type in python to Numeric type in spanner.

#### Environment details

  - OS type and version: MacOS Big Sur 11.2.3
  - Python version: 3.8.8
  - pip version: pip 21.0.1
  - `google-cloud-spanner` version: 3.2.0

#### Steps to reproduce

  1. Create a table with Numeric field.
  2. Insert data in field with type float

#### Code example

```python
sql='INSERT INTO t (x) VALUES (%s)', 
params=[3.194387483193242e+19]
```

Thanks!


Comments:

Patch:
diff --git a/google/cloud/spanner_dbapi/parse_utils.py b/google/cloud/spanner_dbapi/parse_utils.py
index 9ac6f3d..0a7d505 100644
--- a/google/cloud/spanner_dbapi/parse_utils.py
+++ b/google/cloud/spanner_dbapi/parse_utils.py
@@ -37,6 +37,7 @@ TYPES_MAP = {
     datetime.date: spanner.param_types.DATE,
     DateStr: spanner.param_types.DATE,
     TimestampStr: spanner.param_types.TIMESTAMP,
+    decimal.Decimal: spanner.param_types.NUMERIC,
 }
 
 SPANNER_RESERVED_KEYWORDS = {


Test patch:
diff --git a/tests/unit/spanner_dbapi/test_parse_utils.py b/tests/unit/spanner_dbapi/test_parse_utils.py
index c37c604..c612659 100644
--- a/tests/unit/spanner_dbapi/test_parse_utils.py
+++ b/tests/unit/spanner_dbapi/test_parse_utils.py
@@ -353,6 +353,7 @@ class TestParseUtils(unittest.TestCase):
     @unittest.skipIf(skip_condition, skip_message)
     def test_get_param_types(self):
         import datetime
+        import decimal
 
         from google.cloud.spanner_dbapi.parse_utils import DateStr
         from google.cloud.spanner_dbapi.parse_utils import TimestampStr
@@ -369,6 +370,7 @@ class TestParseUtils(unittest.TestCase):
             "h1": datetime.date(2011, 9, 1),
             "i1": b"bytes",
             "j1": None,
+            "k1": decimal.Decimal("3.194387483193242e+19"),
         }
         want_types = {
             "a1": param_types.INT64,
@@ -380,6 +382,7 @@ class TestParseUtils(unittest.TestCase):
             "g1": param_types.TIMESTAMP,
             "h1": param_types.DATE,
             "i1": param_types.BYTES,
+            "k1": param_types.NUMERIC,
         }
         got_types = get_param_types(params)
         self.assertEqual(got_types, want_types)
Repository: googleapis/python-spanner

Issue:
float value cannot be used to insert data to NUMERIC field.
Float data type is mapped to float: spanner.param_types.FLOAT64 [Link](https://github.com/googleapis/python-spanner/blob/master/google/cloud/spanner_dbapi/parse_utils.py#L35).

We need to add support to map decimal.Decimal type in python to Numeric type in spanner.

#### Environment details

  - OS type and version: MacOS Big Sur 11.2.3
  - Python version: 3.8.8
  - pip version: pip 21.0.1
  - `google-cloud-spanner` version: 3.2.0

#### Steps to reproduce

  1. Create a table with Numeric field.
  2. Insert data in field with type float

#### Code example

```python
sql='INSERT INTO t (x) VALUES (%s)', 
params=[3.194387483193242e+19]
```

Thanks!


Comments:

Patch:
diff --git a/google/cloud/spanner_dbapi/parse_utils.py b/google/cloud/spanner_dbapi/parse_utils.py
index 0a7d505..1744874 100644
--- a/google/cloud/spanner_dbapi/parse_utils.py
+++ b/google/cloud/spanner_dbapi/parse_utils.py
@@ -509,25 +509,11 @@ def sql_pyformat_args_to_spanner(sql, params):
             resolved_value = pyfmt % params
             named_args[key] = resolved_value
         else:
-            named_args[key] = cast_for_spanner(params[i])
+            named_args[key] = params[i]
 
     return sanitize_literals_for_upload(sql), named_args
 
 
-def cast_for_spanner(value):
-    """Convert the param to its Cloud Spanner equivalent type.
-
-    :type value: Any
-    :param value: The value to convert to a Cloud Spanner type.
-
-    :rtype: Any
-    :returns: The value converted to a Cloud Spanner type.
-    """
-    if isinstance(value, decimal.Decimal):
-        return str(value)
-    return value
-
-
 def get_param_types(params):
     """Determine Cloud Spanner types for the given parameters.
 


Test patch:
diff --git a/tests/unit/spanner_dbapi/test_parse_utils.py b/tests/unit/spanner_dbapi/test_parse_utils.py
index c612659..73277a7 100644
--- a/tests/unit/spanner_dbapi/test_parse_utils.py
+++ b/tests/unit/spanner_dbapi/test_parse_utils.py
@@ -307,7 +307,7 @@ class TestParseUtils(unittest.TestCase):
                 ),
                 (
                     "SELECT (an.p + @a0) AS np FROM an WHERE (an.p + @a1) = @a2",
-                    {"a0": 1, "a1": 1.0, "a2": str(31)},
+                    {"a0": 1, "a1": 1.0, "a2": decimal.Decimal("31")},
                 ),
             ),
         ]
@@ -339,17 +339,6 @@ class TestParseUtils(unittest.TestCase):
                     lambda: sql_pyformat_args_to_spanner(sql, params),
                 )
 
-    def test_cast_for_spanner(self):
-        import decimal
-
-        from google.cloud.spanner_dbapi.parse_utils import cast_for_spanner
-
-        dec = 3
-        value = decimal.Decimal(dec)
-        self.assertEqual(cast_for_spanner(value), str(dec))
-        self.assertEqual(cast_for_spanner(5), 5)
-        self.assertEqual(cast_for_spanner("string"), "string")
-
     @unittest.skipIf(skip_condition, skip_message)
     def test_get_param_types(self):
         import datetime
Repository: googlefonts/nanoemoji

Issue:
Ligature changed from rlig feature to ccmp
Different platforms or browsers have some differences in ligature support([Test](http://unifraktur.sourceforge.net/testcases/enable_opentype_features/)). Let us discuss what issues should be paid attention to in emoji ligatures.

noto-emoji and noto-emoji-svg both use ccmp by default

https://github.com/googlefonts/noto-emoji/blob/41ae6686ace1453b432ac907a165428f2e1ad54e/NotoColorEmoji.tmpl.ttx.tmpl#L311

https://github.com/adobe-fonts/noto-emoji-svg/blob/ed5c78c8e3d46fdf8dbf7532875aaabfdcdc5c3a/GSUB.fea#L4


Comments:

Patch:
diff --git a/src/nanoemoji/features.py b/src/nanoemoji/features.py
index 741ed2c..454df73 100644
--- a/src/nanoemoji/features.py
+++ b/src/nanoemoji/features.py
@@ -20,14 +20,17 @@
 from nanoemoji.glyph import glyph_name
 
 
-def generate_fea(rgi_sequences):
-    # Generate rlig feature with ligature lookup for multi-codepoint RGIs
+DEFAULT_GSUB_FEATURE_TAG = "ccmp"
+
+
+def generate_fea(rgi_sequences, feature_tag=DEFAULT_GSUB_FEATURE_TAG):
+    # Generate feature with ligature lookup for multi-codepoint RGIs
     rules = []
     rules.append("languagesystem DFLT dflt;")
     rules.append("languagesystem latn dflt;")
     rules.append("")
 
-    rules.append("feature rlig {")
+    rules.append(f"feature {feature_tag} {{")
     for rgi in sorted(rgi_sequences):
         if len(rgi) == 1:
             continue
@@ -35,6 +38,6 @@ def generate_fea(rgi_sequences):
         target = glyph_name(rgi)
         rules.append("  sub %s by %s;" % (" ".join(glyphs), target))
 
-    rules.append("} rlig;")
+    rules.append(f"}} {feature_tag};")
     rules.append("")
     return "\n".join(rules)


Test patch:
diff --git a/tests/features_test.py b/tests/features_test.py
new file mode 100644
index 0000000..fba756e
--- /dev/null
+++ b/tests/features_test.py
@@ -0,0 +1,19 @@
+from textwrap import dedent
+from nanoemoji.features import generate_fea, DEFAULT_GSUB_FEATURE_TAG
+import pytest
+
+
+@pytest.mark.parametrize("feature_tag", (DEFAULT_GSUB_FEATURE_TAG, "rlig"))
+def test_generate_fea(feature_tag):
+    rgi_sequences = [(0x1F64C,), (0x1F64C, 0x1F3FB), (0x1F64C, 0x1F3FC)]
+    assert generate_fea(rgi_sequences, feature_tag=feature_tag) == dedent(
+        f"""\
+        languagesystem DFLT dflt;
+        languagesystem latn dflt;
+
+        feature {feature_tag} {{
+          sub g_1f64c g_1f3fb by g_1f64c_1f3fb;
+          sub g_1f64c g_1f3fc by g_1f64c_1f3fc;
+        }} {feature_tag};
+        """
+    )
Repository: googlefonts/picosvg

Issue:
Failed to extract translation
.local/lib/python3.7/site-packages/picosvg/svg_transform.py", line 339, in decompose_translation
    ), f"Failed to extract translation from {self}, parts compose back to {test_compose}"
AssertionError: Failed to extract translation from Affine2D(a=-4.382842e-08, b=1.0027, c=-4.2262, d=-1.847346e-07, e=1133.4812, f=889.4797), parts compose back to Affine2D(a=-4.382842e-08, b=1.0027, c=-4.2262, d=-1.847346e-07, e=1133.4812, f=889.4796970082031)


Comments:

Patch:
diff --git a/src/picosvg/svg_transform.py b/src/picosvg/svg_transform.py
index 557b775..5e519bf 100644
--- a/src/picosvg/svg_transform.py
+++ b/src/picosvg/svg_transform.py
@@ -32,7 +32,7 @@ from picosvg.geometric_types import (
 )
 from picosvg.svg_meta import ntos
 
-DECOMPOSITION_ALMOST_EQUAL_TOLERANCE = 1e-6
+DECOMPOSITION_ALMOST_EQUAL_TOLERANCE = 1e-4
 
 _SVG_ARG_FIXUPS = collections.defaultdict(
     lambda: lambda _: None,


Test patch:
diff --git a/tests/svg_transform_test.py b/tests/svg_transform_test.py
index 2f18abe..d20dc60 100644
--- a/tests/svg_transform_test.py
+++ b/tests/svg_transform_test.py
@@ -353,6 +353,21 @@ class TestAffine2D:
                 Affine2D(1, 0, 0, 1, 50, -100),
                 Affine2D(0, -1.0, 1.0, 0, 0, 0),
             ),
+            # https://github.com/googlefonts/picosvg/issues/239
+            (
+                Affine2D(
+                    a=-4.382842e-08,
+                    b=1.0027,
+                    c=-4.2262,
+                    d=-1.847346e-07,
+                    e=1133.4812,
+                    f=889.4797,
+                ),
+                Affine2D(a=1, b=0, c=0, d=1, e=887.0845192597527, f=-268.2034070511364),
+                Affine2D(
+                    a=-4.382842e-08, b=1.0027, c=-4.2262, d=-1.847346e-07, e=0, f=0
+                ),
+            ),
         ],
     )
     def test_decompose_translation(
Repository: googlemaps/google-maps-services-python

Issue:
Allow user to append several values for same component filter type
It would be nice to allow several values for same component type. 
Use case: You may want to filter sublocalities via locality component type ("locality matches against both locality and sublocality types") and in addition you may restrict result set by another locality.

Maybe we should extend converting components by defaultdict containing lists?



Comments:

Patch:
diff --git a/googlemaps/convert.py b/googlemaps/convert.py
index 1c2264e..6206cfa 100644
--- a/googlemaps/convert.py
+++ b/googlemaps/convert.py
@@ -220,9 +220,17 @@ def components(arg):
 
     :rtype: basestring
     """
+
+    # Components may have multiple values per type, here we
+    # expand them into individual key/value items, eg:
+    # {"country": ["US", "AU"], "foo": 1} -> "country:AU", "country:US", "foo:1"
+    def expand(arg):
+        for k, v in arg.items():
+            for item in as_list(v):
+                yield "%s:%s" % (k, item)
+
     if isinstance(arg, dict):
-        arg = sorted(["%s:%s" % (k, arg[k]) for k in arg])
-        return "|".join(arg)
+        return "|".join(sorted(expand(arg)))
 
     raise TypeError(
         "Expected a dict for components, "


Test patch:
diff --git a/test/test_convert.py b/test/test_convert.py
index 851eda1..090a95f 100644
--- a/test/test_convert.py
+++ b/test/test_convert.py
@@ -91,6 +91,9 @@ class ConvertTest(unittest.TestCase):
         c = {"country": "US", "foo": 1}
         self.assertEqual("country:US|foo:1", convert.components(c))
 
+        c = {"country": ["US", "AU"], "foo": 1}
+        self.assertEqual("country:AU|country:US|foo:1", convert.components(c))
+
         with self.assertRaises(TypeError):
             convert.components("test")