12,139 questions
0
votes
1
answer
179
views
How can I map on a list that returns a tuple?
MRE:
MyType = MyDataCtor [MyType] | MyDataCtor2 MyType MyType | ... other cases (none of which require the map operation)
foo :: Type1 -> Type2 -> (Type1, Type2)
For example, for the ...
-1
votes
1
answer
58
views
How to Join two RDDs in pyspark with nested tuples
I need to join two RDDs as part of my programming assignment. The problem is that the first RDD is nested, while the other is flat. I tried different things, but nothing seemed to work. Is there any ...
0
votes
1
answer
52
views
Issues with tuple comparison while using a specific class that bypasses comparison
During a current school project of mine, I came up with a specific sorting algorithm which I nicknamed parallel_sort. By giving it a list of integers and a list of dictionaries, it sorts the ...
6
votes
2
answers
267
views
Forwarding multiple sets of variadic arguments
I'm building a container which uses, as its internal representation, a couple of standard containers, each with a different type. I need to code my version of emplace(..) and here's where I got stuck.
...
0
votes
2
answers
113
views
Typescript sort array of array tuples
I have tuples in the form (Status and priority)
[State,prio]
States are defined so:
enum State {
A = "A",
B = "B",
C = "C"
...
}
Now i want to sort an ...
2
votes
2
answers
200
views
derived class cannot call recursively inherited member functions C++
I'm making it using multi inheritance with a pair struct that contains
an index and the type of the element in a recursive structure like this:
template<int index, typename... ts>
struct ok;
...
2
votes
2
answers
135
views
Tuples index when using Ellipsis in a numpy array
I have a code that loops on tuples indexes:
for _ip in np.ndindex(params_shape):
...
loglik[_ip, ...] = ...
If my tuple is (0, 1), I would like the last line to access loglik[0, 1, ...]. ...
1
vote
2
answers
103
views
Convert dataframe of boolean values to list of ranges where value is True. (eg. output: "column-header, 24-79")
My goal is to compare the contents of two 2-d arrays (~15k rows, 8 columns) and get a list of the rows/columns where the comparison (greater-than) is true. I need that output in a readable format, ...
0
votes
1
answer
78
views
How to concatenate two tuples?
I want to concatenate two tuples in DolphinDB in the way similar to concatenating vectors.
For example, I have two tuples:
a=(1,2,3)
and
b=(4,5,6)
and I attempted to use
join
to obtain
re=(1,2,3,4,...
2
votes
3
answers
236
views
C++: How to iterate over tuple in compile-time?
How to iterate over tuple in compile-time?
problem code:
#include <array>
#include <cstddef>
#include <tuple>
namespace {
class Solution {
public:
template <size_t ...
4
votes
2
answers
215
views
A tuple-like container that only allows unique and non-convertible types
I needed a type that could generalize several types that cannot be converted to each other. For example: There are 2 types A and B. A is not convertible to B, B is not convertible to A. That is, these ...
4
votes
1
answer
113
views
Clang-tidy bugprone-use-after-move with perfect forwarding
clang-tidy reports the following piece of code as bugprone-use-after-move
template <typename F, typename Tuple, size_t... I>
auto transform_tuple_impl(F&& f, Tuple&& tuple, std::...
2
votes
1
answer
285
views
Dataframe behavior: Pandas 1.1.5 vs 2.3.0
I recently had to update the virtual environment for one of my libraries from Python 3.7 to 3.10, which also involved updating Pandas from 1.1.5 to 2.3.0.
In the previous virtual environment, this ...
1
vote
2
answers
97
views
constexpr std::tuple-like utility so you can use it with non constexpr tuple members
It would be nice if there was something like tuple but that didn't actually construct the types, but just held them as template parameters, with the features of std::tuple, the indexing and such. Is ...
-2
votes
1
answer
82
views
Tuple comprehension creates generator; List comprehension evaluates all elements right away [duplicate]
I am using a long ad hoc script for exploratory data analysis -- not for tool development. The script has gotten quite long, so I've taken to deling ephemeral variables to keep the Spyder Variable ...
0
votes
0
answers
28
views
Matplotlib Slider: function set_val does not work following standard prescriptions?
I am a beginner with the Slider tool and retrieved a code which used to work but does not anymore. I found a similar code here to test the Slider tool in this answer which provides a self-contained ...
0
votes
0
answers
30
views
A correct CriteriaBuilder is needed which handle private List<TableViewToQueryGroup> queryGroups correctly with @EmbeddedId
I have a TableView.class which is used to store the TableViewDefinitions:
public class TableView<T, U> extends Auditable implements Serializable {
@Id
@GeneratedValue(strategy = ...
2
votes
4
answers
172
views
How can I apply varadic arguments to a function with a fixed number of arguments
I have several custom data structures which are essentially arrays of primitive types:
template <typename T>
class Vec3 {
static constexpr size_t SIZE = 3;
T v[SIZE] = ...; // some init ...
2
votes
1
answer
258
views
How can I provide type hints while destructuring my class
I would like to create a class that looks something like ConfigAndPath:
import pathlib
from typing import TypeVar, Generic
from dataclasses import dataclass, astuple
class ConfigBase:
pass
T = ...
-5
votes
1
answer
159
views
Fast and efficient generation of large number of tuples
I have a following problem to solve. Given a number max generate all possible 3-tuples (for example) in the range from -max to max for all 3 numbers. Obviously I can write a simple nested loops (in C++...
-2
votes
3
answers
91
views
Modify elements of a list based on another list
I have two lists that look like -
list_a = [('gfhr_10_dfrght_sl', None, None), ('gfhr_11_dfrght_sl', None, None), ('mnop_yxt_done', None, None), ('mnop_yxt_gd', None, None), ('frdf_yxty_syn', None, ...
-3
votes
2
answers
112
views
Fastest way to convert results from tuple of tuples to 2D numpy.array
I'm training my AI model with a huge data set, so that it's impossible to preload all the data into memory at the beginning. I'm currently using psycopg2 to load data from a Postgresql DB during ...
0
votes
1
answer
103
views
Creating a Map from Flatten in Terraform
Here is my issue - I have a locals code block like the below. I need to create a Map from these values (these values are used in multiple places)
locals {
object = {
1 = {
name = "...
7
votes
2
answers
223
views
std::tie in constructor's initializer list
I have a following header:
#include <string_view>
#include <tuple>
std::tuple<int, int, int> foo(std::string_view sv);
class s {
public:
s(std::string_view sv);
...
1
vote
3
answers
73
views
Transforming 3-tuples to "unique" form for comparison of other property
Being primarily a crystallographer and chemist/physicist I encounter rather simple problems, which turn out not to be straightforward :-) My task here is that I have a set of, for example, integer ...
2
votes
1
answer
142
views
Inconsistency in structured binding declarations in C++
#include <iostream>
#include <tuple>
struct my_struct {
const std::tuple<int, float> t{5, 3.14};
template<std::size_t i>
decltype(std::get<i>(t)) get() {
...
0
votes
0
answers
15
views
loading a xml file using libSBML on Spyder - tuple index out of range problem
I am trying to use the python version of libSBMLon Spyder.I previously used Cobra to do so and it works. Now, I use the command "model = ls.SBMLReader.readSBML('model.xml')" and I get the ...
0
votes
1
answer
147
views
Terraform dynamically create a tuple
Here is the challenge:
I have an iterated for-each loop to create a bunch of elements in a list:
test_count = 90
test_items = [for i in range(local.test_count) : format("test%02s", i+1)]
...
0
votes
1
answer
98
views
Can anyone see what is wrong with my transpose function in F#?
Given a list of tuples, where each tuple consists of 3 integers, transpose the list recursively so that the "rows" and "columns" are swapped. The result will be a list of lists.
So ...
0
votes
2
answers
120
views
Handling tuples in URL query
I got myself into a big mess trying to add support for arrays in query arguments for an API.
The way I am handling this now is join array by commas
const params = new URLSearchParams()
params.append(&...
0
votes
1
answer
95
views
How to extend typescript interface with specific values enforced in an array property
I have a basic interface, which I use down the line to enforce specific values on other interfaces:
interface ObjectWithEnforcedValues {
values: readonly EnforcedValue[];
}
enum EnforcedValue {
...
2
votes
1
answer
62
views
make std::is_default_constructible<Reader>::value like tuple
I have class inherited from tuple and try to check default constructor with is_default_constructible
template< typename ... Args >
class IdentifierType: public std::tuple< Args... >
{
...
0
votes
1
answer
60
views
TypeError: unsupported operand type(s) for +: 'int' and 'str' for tuple containing only strings in Python
I have the following code that sums the elements in a tuple:
t = ("j","h","w","j")
print(sum(t))
I got the following error:
TypeError: unsupported operand type(...
1
vote
1
answer
81
views
Why does this sorted key lambda encounter an IndexError
I thought I understood the key argument for the sorted function, but for the life of me, I cannot figure out why it appears to be applying the tuple index to the string inside the tuple instead of to ...
-1
votes
1
answer
59
views
Dictionnary and Tuple definition in swift
on a classs definition i can set this :
private let GameWallDefinition = ["LL3":(104,0.0,62.0,10),"LL2":(99,0.0,60.0,20),"L0":(94,0.0,0.0,50)]
but i can for more esay ...
2
votes
3
answers
127
views
Structured binding declaration for class inherited from tuple
I have a class inherited from standard tuple:
#include <concepts>
#include <cstdint>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
...
3
votes
2
answers
174
views
How do I achieve *recursive variadic generic property inference* for siblings of an object/record?
I want to have the default property correctly infer the ArkType Type from the schema property, infinitely deep and infinitely wide. Accomplishing simple inference was easy... with the use of a ...
2
votes
3
answers
213
views
Can you add two (int) tuples together?
Something like:
var Tuple1 = (x:2,y:4);
var Tuple2 = (x:0,y:-1);
var Tuple3 = Tuple1 + Tuple2;
// desired output: (x:2,y:3)
Is there a simple way, or must I do something like:
Tuple3.x = Tuple1.x + ...
1
vote
1
answer
69
views
Still, is tuple now a persistent data structure in Elixir or not?
Here, José Valim explicitly wrote that it isn't persistent.
But the official documentation here (5th para.) says otherwise, it seems.
I'm confused because I don't know how to check it myself yet. Can ...
-1
votes
1
answer
148
views
lost value in reference c++ [closed]
I have a class inherited from standard tuple:
#include <concepts>
#include <cstdint>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>
...
0
votes
0
answers
76
views
How to initialize a tuple-derived class like a plain tuple when casting parameters implicitly? [duplicate]
I have 2 tuples:
std::tuple< std::wstring, int64_t > item(L"str", 10);;
std::tuple< const std::wstring&, int64_t > item_ref = item;
In the second tuple, the first param is ...
1
vote
1
answer
53
views
Convert string back to array of tuples
I have an array of tuples in PostgreSQL 17.
I couldn't get SELECT...INTO...FROM to work for some reason:
SELECT ARRAY[(1,2)] AS a INTO temp_table;
ERROR: column "a" has pseudo-type record[]
...
1
vote
2
answers
77
views
Construct a variadic std::tuple using a parameter pack of constructor arguments
I have the following class definitions. I would like to create an Alphabet of Letter classes where each Letter class is constructed using an argument from the parameter pack passed to the Alphabet ...
0
votes
1
answer
222
views
List unpacking in python
what seems to be the problem with the code
l = [1,2,4,5,6,7,8]
t = *l
i have read that *l gives comma separated single values so the statement should be similar to t = 1,2,3,4,5,6,7 which is a tuple ...
2
votes
1
answer
82
views
Assignment of tuple to pandas dataframe cell fails on joined dataframe
I have a DataFrame with tuples in cells:
import numpy as np
import pandas as pd
data = np.empty((3, 4), dtype=[('cost', np.int32), ('count', np.int32)])
data['count'] = 0
data['cost'] = [[10, 2, 20,...
1
vote
1
answer
369
views
Remote clickhouse error: DB::Exception: There's no column '__table1.event_params.key' in table '__table1'
I use remoteSecure function to query remote table from one clickhouse server to another. We have two enviroments PROD and DEV from where remote queries are sent. PROD clickhouse has version 23.7.3.14, ...
1
vote
0
answers
90
views
How to have different implementation for tuple of references vs tuple of values
I'm trying to write an ECS system that can query components by value, reference, or mutable reference. For this, I want a different implementation for various tuple types as an Archetype.
trait ...
3
votes
2
answers
109
views
Algorithm for Compact Representation of Tuples Using Cartesian Product
I have the following set of tuples:
('red', 'hot', 'big'),
('red', 'hot', 'small'),
('red', 'cold', 'big'),
('blue', 'hot', 'big'),
('blue', 'cold', 'big'),
('green', 'hot', 'big'),
('green', 'cold', '...
0
votes
1
answer
181
views
Why does a C++ iterator reference need to be const?
I'm trying out this demo code to play with std::ranges::views::cartesian_product in g++13. I'm wondering about the for loop in main:
#include <cstdio>
#include <tuple>
#include <array&...
2
votes
0
answers
245
views
Unity C# - Tuple must contain at least two elements - error
I am trying to update discord activities while playing my game in unity by DiscordGameSDK. I am weak in this area, so I admit that I copied everything from the guide, but I got stuck with this error:
...