nebius/SWE-bench-extra huggingface dataset:
Repository: QuantStack/py2vega

Issue:
Built-in functions
The Python built-in `len` function could be mapped to the Vega `length` function
The Python built-in `slice` function could be mapped to the Vega `slice` function
The Python built-in `str` function could be mapped to the Vega `toString` function
...

Comments:

Patch:
diff --git a/py2vega/main.py b/py2vega/main.py
index d00a21a..f153309 100644
--- a/py2vega/main.py
+++ b/py2vega/main.py
@@ -20,6 +20,16 @@ operator_mapping = {
     ast.Mod: '%'
 }
 
+# Note that built-in functions like `abs`, `min`, `max` which already have an equivalent in
+# Vega expressions are already supported automatically
+builtin_function_mapping = {
+    'bool': '(isValid({args}) ? toBoolean({args}) : false)',
+    'float': 'toNumber({args})',
+    'int': 'floor(toNumber({args}))',
+    'len': 'length({args})',
+    'str': 'toString({args})'
+}
+
 
 class Py2VegaSyntaxError(SyntaxError):
     pass
@@ -220,11 +230,13 @@ class VegaExpressionVisitor(ast.NodeVisitor):
         if isinstance(node.func, ast.Attribute):
             func_name = node.func.attr
 
+        args = ', '.join([self.visit(arg) for arg in node.args])
+
+        if func_name in builtin_function_mapping:
+            return builtin_function_mapping[func_name].format(args=args)
+
         if func_name in vega_functions:
-            return '{}({})'.format(
-                func_name,
-                ', '.join([self.visit(arg) for arg in node.args])
-            )
+            return '{func_name}({args})'.format(func_name=func_name, args=args)
 
         raise NameError('name \'{}\' is not defined, only a subset of Python is supported'.format(func_name))
 


Test patch:
diff --git a/test/test_py2vega.py b/test/test_py2vega.py
index ea54940..4fbbb57 100644
--- a/test/test_py2vega.py
+++ b/test/test_py2vega.py
@@ -93,6 +93,35 @@ def test_compare():
     assert py2vega(code, whitelist) == '(indexof(value, \'chevrolet\') == -1)'
 
 
+def test_call():
+    code = 'toBoolean(3)'
+    assert py2vega(code, whitelist) == 'toBoolean(3)'
+
+    code = 'bool(3)'
+    assert py2vega(code, whitelist) == '(isValid(3) ? toBoolean(3) : false)'
+
+    code = 'toString(3)'
+    assert py2vega(code, whitelist) == 'toString(3)'
+
+    code = 'str(3)'
+    assert py2vega(code, whitelist) == 'toString(3)'
+
+    code = 'toNumber("3")'
+    assert py2vega(code, whitelist) == 'toNumber(\'3\')'
+
+    code = 'float("3")'
+    assert py2vega(code, whitelist) == 'toNumber(\'3\')'
+
+    code = 'int("3")'
+    assert py2vega(code, whitelist) == 'floor(toNumber(\'3\'))'
+
+    code = 'length(value)'
+    assert py2vega(code, whitelist) == 'length(value)'
+
+    code = 'len(value)'
+    assert py2vega(code, whitelist) == 'length(value)'
+
+
 def foo(value):
     return 'red' if value < 150 else 'green'
Repository: RDFLib/rdflib

Issue:
Minor typo(?) in example
I think the comment on line 36 is wrong and should read
```
# add a graph for John's facts to the Conjunctive Graph 
```
https://github.com/RDFLib/rdflib/blob/e4fe0fdbd4de7e1183418f302315b51a14602e03/examples/conjunctive_graphs.py#L36-L37

No big deal, but it may be confusing to learners.

Comments:

Patch:
diff --git a/examples/conjunctive_graphs.py b/examples/conjunctive_graphs.py
index f714d9ff..a66a3aa8 100644
--- a/examples/conjunctive_graphs.py
+++ b/examples/conjunctive_graphs.py
@@ -33,7 +33,7 @@ if __name__ == "__main__":
     gmary.add((mary, ns["hasName"], Literal("Mary")))
     gmary.add((mary, ns["loves"], john))
 
-    # add a graph for Mary's facts to the Conjunctive Graph
+    # add a graph for John's facts to the Conjunctive Graph
     gjohn = Graph(store=store, identifier=cjohn)
     # John's graph contains his cute name
     gjohn.add((john, ns["hasCuteName"], Literal("Johnny Boy")))
diff --git a/rdflib/namespace.py b/rdflib/namespace.py
index 84cbe508..27f6d9ea 100644
--- a/rdflib/namespace.py
+++ b/rdflib/namespace.py
@@ -804,7 +804,7 @@ class NamespaceManager(object):
 NAME_START_CATEGORIES = ["Ll", "Lu", "Lo", "Lt", "Nl"]
 SPLIT_START_CATEGORIES = NAME_START_CATEGORIES + ["Nd"]
 NAME_CATEGORIES = NAME_START_CATEGORIES + ["Mc", "Me", "Mn", "Lm", "Nd"]
-ALLOWED_NAME_CHARS = [u"\u00B7", u"\u0387", u"-", u".", u"_", u":"]
+ALLOWED_NAME_CHARS = [u"\u00B7", u"\u0387", u"-", u".", u"_", u":", u"%"]
 
 
 # http://www.w3.org/TR/REC-xml-names/#NT-NCName


Test patch:
diff --git a/test/test_issue801.py b/test/test_issue801.py
new file mode 100644
index 00000000..ae27f346
--- /dev/null
+++ b/test/test_issue801.py
@@ -0,0 +1,19 @@
+"""
+Issue 801 - Problem with prefixes created for URIs containing %20
+"""
+from rdflib import Namespace, Graph, BNode, Literal
+import unittest
+
+class TestIssue801(unittest.TestCase):
+
+    def test_issue_801(self):
+        g = Graph()
+        example = Namespace('http://example.org/')
+        g.bind('', example)
+        node = BNode()
+        g.add((node, example['first%20name'], Literal('John')))
+        self.assertEqual(g.serialize(format="turtle").decode().split("\n")[-3],
+                '[] :first%20name "John" .')
+
+if __name__ == "__main__":
+    unittest.main()
Repository: RDFLib/rdflib

Issue:
can't get rid of default prefix definition in trig serialization
I have a trig file with just one graph like this:

```trig
@prefix adm: <http://purl.bdrc.io/ontology/admin/> .
@prefix bda: <http://purl.bdrc.io/admindata/> .
@prefix bdg: <http://purl.bdrc.io/graph/> .

bdg:W1NLM5228 {
    bda:W1NLM5228 a adm:AdminData ;
        adm:status bda:StatusReleased .
}
```

In my use case I need to be able to read it, modify it and then write it with the same prefix definitions, but when I do something very simple like

```python
import rdflib
from rdflib import Literal, Graph, Dataset, URIRef
import os

ds = Dataset()
ds.parse("bug.trig", format="trig", publicID=URIRef("http://purl.bdrc.io/graph/W1NLM5228"))
ds.remove_graph(URIRef("urn:x-rdflib:default")) # doesn't work
ds.serialize(filepath+"-bug", format="trig")
```

the output I get is

```trig
@prefix adm: <http://purl.bdrc.io/ontology/admin/> .
@prefix bda: <http://purl.bdrc.io/admindata/> .
@prefix bdg: <http://purl.bdrc.io/graph/> .
@prefix ns1: <urn:x-rdflib:> .

bdg:W1NLM5228 {
    bda:W1NLM5228 a adm:AdminData ;
        adm:status bda:StatusReleased .
}
```

and I seem unable to remove the `ns1: <urn:x-rdflib:>` prefix definition. Is there any way to do so? Thanks!

Comments:

Patch:
diff --git a/rdflib/plugins/serializers/trig.py b/rdflib/plugins/serializers/trig.py
index 0fa62b71..d4052b29 100644
--- a/rdflib/plugins/serializers/trig.py
+++ b/rdflib/plugins/serializers/trig.py
@@ -34,6 +34,9 @@ class TrigSerializer(TurtleSerializer):
 
     def preprocess(self):
         for context in self.contexts:
+            # do not write unnecessary prefix (ex: for an empty default graph)
+            if len(context) == 0:
+                continue
             self.store = context
             self.getQName(context.identifier)
             self._subjects = {}


Test patch:
diff --git a/test/test_trig.py b/test/test_trig.py
index dbb1adbf..30bff634 100644
--- a/test/test_trig.py
+++ b/test/test_trig.py
@@ -192,3 +192,9 @@ def test_prefixes():
     assert "ns2: <http://ex.org/docs/".encode("latin-1") in data, data
     assert "<ns2:document1>".encode("latin-1") not in data, data
     assert "ns2:document1".encode("latin-1") in data, data
+
+
+def test_issue_2154():
+    ds = rdflib.Dataset()
+    sg = ds.serialize(format="trig")
+    assert "prefix" not in sg, sg
Repository: RDFLib/rdflib

Issue:
Separator in group_concat function with explicit empty string incorrectly defaults to 'space' character
Using the group_concat function with the separator indicating an _empty string_ ("") leads incorrectly to the default use of a space character as separator (" ").

**Example code:**



```
PREFIX : <http://example.org/>

SELECT ?subject (GROUP_CONCAT(?object; separator="") AS ?concatenatedObjects)
WHERE {
  VALUES (?subject ?object) {
    (:subject1 "a")
    (:subject1 "b")
    (:subject1 "c")
  }
}
GROUP BY ?subject
```

**Expected outcome for concatenatedObjects:**

`abc`

**Instead we get:**

`a b c`

Comments:

Patch:
diff --git a/rdflib/plugins/sparql/aggregates.py b/rdflib/plugins/sparql/aggregates.py
index d4a7d659..84ac8936 100644
--- a/rdflib/plugins/sparql/aggregates.py
+++ b/rdflib/plugins/sparql/aggregates.py
@@ -245,11 +245,16 @@ class Sample(Accumulator):
 
 
 class GroupConcat(Accumulator):
-    def __init__(self, aggregation):
+    value: List[Literal]
+
+    def __init__(self, aggregation: CompValue):
         super(GroupConcat, self).__init__(aggregation)
         # only GROUPCONCAT needs to have a list as accumulator
         self.value = []
-        self.separator = aggregation.separator or " "
+        if aggregation.separator is None:
+            self.separator = " "
+        else:
+            self.separator = aggregation.separator
 
     def update(self, row: FrozenBindings, aggregator: "Aggregator") -> None:
         try:


Test patch:
diff --git a/test/test_sparql/test_translate_algebra.py b/test/test_sparql/test_translate_algebra.py
index 20b23327..ca9e67bd 100644
--- a/test/test_sparql/test_translate_algebra.py
+++ b/test/test_sparql/test_translate_algebra.py
@@ -11,6 +11,7 @@ from _pytest.mark.structures import Mark, MarkDecorator, ParameterSet
 
 import rdflib.plugins.sparql.algebra as algebra
 import rdflib.plugins.sparql.parser as parser
+from rdflib import Graph, Literal, URIRef
 from rdflib.plugins.sparql.algebra import translateAlgebra
 
 
@@ -304,3 +305,25 @@ def test_roundtrip(test_spec: AlgebraTest, data_path: Path) -> None:
     # TODO: Execute the raw query (query_text) and the reconstituted query
     # (query_from_query_from_algebra) against a well defined graph and ensure
     # they yield the same result.
+
+
+def test_sparql_group_concat():
+    """Tests if GROUP_CONCAT correctly uses the separator keyword"""
+    query = """
+    PREFIX : <http://example.org/>
+
+    SELECT ?subject (GROUP_CONCAT(?object; separator="")
+                        AS ?concatenatedObjects)
+    WHERE {
+      VALUES (?subject ?object) {
+        (:pred "a")
+        (:pred "b")
+        (:pred "c")
+      }
+    }
+    GROUP BY ?subject
+    """
+
+    g = Graph()
+    q = dict(g.query(query))
+    assert q[URIRef("http://example.org/pred")] == Literal("abc")