Flutter I can't read an image with readasbytessync with local file - flutter

i do not understand why the image directly from image_picker work but not the image load from app directory, i thought it was a rights issue (I have the right to read or record), but the images come from the same folder.
I don't know if I'm clear, but has anyone had the same problem?
Code:
print(image);
final fileBytes = image.readAsBytesSync();
print(fileBytes);
Return of the just taken image:
File: '/data/user/0/com.wallis.env_wallis/app_flutter/1.jpg'
[255, 216, 255, 225, 1, 149, 69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 10, 1, 59, 0, 2, 0, 0, 0, 22, 0, 0, 0, 134, 1, 0, 0, 4, 0, 0, 0, 1, 0, 0, 2, 128, 1, 16, 0, 2, 0, 0, 0, 6, 0, 0, 0, 156, 1, 1, 0, 4, 0, 0, 0, 1, 0, 0, 1, 224, 1, 15, 0, 2, 0, 0, 0, 7, 0, 0, 0, 162, 1, 14, 0, 2, 0, 0, 0, 1, 0, 0, 0, 0, 135, 105, 0, 4, 0, 0, 0, 1, 0, 0, 0, 189, 1, 18, 0, 3, 0, 0, 0, 1, 0, 6, 0, 0, 1, 50, 0, 2, 0, 0, 0, 20, 0, 0, 0, 169, 136, 37, 0, 4, 0, 0, 0, 1, 0, 0, 1, 47, 0, 0, 0, 0, 50, 52, 46, 68, 69, 83, 84, 82, 85, 67, 84, 73, 79, 78, 32, 70, 79, 82, 69, 84, 83, 0, 77, 105, 32, 57, 84, 0, 88, 105, 97, 111, 109, 105, 0, 50, 48, 50, 49, 58, 49, 48, 58, 48, 51, 32, 48, 57, 58, 52, 50, 58, 51, 57, 0, 0, 7, 164, 3, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 136, 39, 0, 3, 0, 0, 0, 1, 76, 165, 0, 0, 146, 10, 0, 5, 0, 0, 0, 1, 0, 0, 1, 23, 130, 154, 0, 5, 0, 0, 0, 1, 0, 0, 1, 31, 146, 9, 0, 3, 0, 0, 0, 1, 0, 16, 0, 0, 146, 8, 0, 4, 0, 0, 0, 1, 0, 0, 0, 0, 130, 157, 0, 5, 0, 0, 0, 1, 0, 0, 1, 39, 0, 0, 0, 0, 0, 0, 18, 162,
Return of the image taken in the folder :
File: '/data/user/0/com.wallis.env_wallis/app_flutter/485.jpg'
[]

the exifs seem to have trouble being saved after renaming the image several times, when I sent a renamed image it was fine but when I renamed the image again that was the problem.
So I shifted the time when I rename the images to fix the problem.

Related

PyVis: visually cluster based on edge weight

I am trying to visually cluster nodes in a network based on the weight of their edges: nodes with high edge weight should be close by in the 2d Euclidean space of the output image.
I built my network with NetworkX and converted it to PyVis in order to display it.
I'm wondering if there's a way to set up PyVis so that nodes with high weight edges between them are close by, ideally I would love it to look like this example.
I'm also wondering if instead I should pre-emptively cluster the nodes in NetworkX, tag them, and then use this information to display them close by (for clustering see this answer).
Another alternative would be to remove all edges except for those with high relative value (0.0075 in my example below), but I don't know if this would help with getting PyVis to visually cluster the nodes together.
Or are there any other alternatives to obtain something nice (PageRank, etc)? There seems to be a dearth of information on how to properly visualise graph data (I haven't found much apart from this).
Here's a MWE to reproduce what I'm seeing; basically, in this minimal example, I would like to see nodes [7,9,16,51,57] be clustered close together, compared to the other nodes (ideally I would love it to look like this example - I can always figure out the colouring later on):
def draw_graph3( networkx_graph, notebook=True, output_filename='graph.html', open_output=False,
show_buttons=False, only_physics_buttons=False ):
# import
from pyvis import network as net
# make a pyvis network
pyvis_graph = net.Network( notebook=notebook )
pyvis_graph.width = '1000px'
# for each node and its attributes in the networkx graph
for node, node_attrs in networkx_graph.nodes( data=True ):
pyvis_graph.add_node( node, **node_attrs )
# print(node,node_attrs)
# for each edge and its attributes in the networkx graph
for source, target, edge_attrs in networkx_graph.edges( data=True ):
# if value/width not specified directly, and weight is specified, set 'value' to 'weight'
if not 'value' in edge_attrs and not 'width' in edge_attrs and 'weight' in edge_attrs:
# place at key 'value' the weight of the edge
edge_attrs[ 'value' ] = edge_attrs[ 'weight' ]
# add the edge
pyvis_graph.add_edge( source, target, **edge_attrs )
# turn buttons on
if show_buttons:
if only_physics_buttons:
pyvis_graph.show_buttons( filter_=[ 'physics' ] )
else:
pyvis_graph.show_buttons()
# return and also save
pyvis_graph.show( output_filename )
if open_output:
import webbrowser
import os
webbrowser.open( f'file://{os.getcwd()}/{output_filename}' )
# Build NetworkX graph
import networkx as nx
pre_neurons = [7, 9, 16, 51, 57, 114, 122, 126, 129, 138, 170, 202, 208, 221, 254]
post_neurons = [7, 9, 16, 51, 57, 114, 122, 126, 129, 138, 170, 202, 208, 221, 254]
edges_pre = [7, 7, 7, 9, 9, 9, 9, 9, 16, 16, 16, 16, 16, 16, 16, 16, 16, 51, 51, 51, 51, 51, 51, 57, 57, 57, 57, 57, 57, 114, 114, 114, 114, 114, 114, 114, 114, 122, 122, 122, 126, 126, 126, 126, 126, 126, 129, 129, 129, 129, 129, 138, 138, 138, 138, 138, 138, 170, 170, 170, 170, 170, 170, 202, 202, 202, 202, 202, 202, 202, 208, 208, 208, 208, 208, 208, 221, 221, 254, 254, 254, 254, 254, 254, 254, 254]
edges_post = [122, 129, 170, 51, 122, 129, 138, 208, 7, 9, 51, 57, 114, 129, 170, 208, 221, 9, 129, 170, 202, 221, 254, 114, 129, 170, 202, 208, 254, 51, 122, 126, 129, 138, 202, 208, 254, 114, 202, 208, 9, 51, 122, 202, 221, 254, 51, 114, 126, 138, 170, 7, 57, 114, 126, 129, 170, 7, 9, 57, 126, 138, 221, 51, 114, 126, 129, 170, 208, 221, 7, 51, 138, 170, 202, 254, 51, 170, 9, 16, 57, 114, 122, 126, 138, 170]
edges_weights = [0.0, 0.0, 0.0, 0.0075, 0.0, 0.0, 0.0, 0.0, 0.0075, 0.0075, 0.0075, 0.0075, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0075, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0, 0.0, 0.0, 0.0005, 0.0005, 0.0005, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005, 0.0, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0, 0.0005, 0.0, 0.0, 0.0, 0.0005, 0.0005, 0.0005, 0.0005, 0.0005]
g = nx.Graph()
g.add_nodes_from( pre_neurons )
g.add_nodes_from( post_neurons )
for i, j, w in zip( edges_pre, edges_post, edges_weights ):
g.add_edge( i, j, weight=w )
a = draw_graph3( g, output_filename='test.html', open_output=True, notebook=False, show_buttons=True,
only_physics_buttons=True )

Flutter : Save and Fetch ImageNetwork from API using SQFlite

I have problem with Insert and Fetch Image From API to local Directory.
So i have code to save image like this :
Save Image Code
Future saveImage(String imgUrl, String imgUrl2) async {
var response = await http.get("$baseURLimage/berita/$imgUrl");
var documentDirectory = await getApplicationDocumentsDirectory();
File file = File(join(documentDirectory.path, imgUrl2));
file.writeAsBytesSync(response.bodyBytes);
print(response);
print(response.bodyBytes);
print(documentDirectory);
print(file);
return file;
}
Button Code
void _saveImage() async {
var saveImage =
await api.saveImage(widget.gambarBerita, widget.gambarBerita);
print(saveImage);
}
In Console give me this :
I/flutter (23336): Instance of 'Response'
I/flutter (23336): [255, 216, 255, 224, 0, 16, 74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 255, 219, 0, 132, 0, 13, 13, 13, 13, 14, 13, 14, 16, 16, 14, 20, 22, 19, 22, 20, 30, 27, 25, 25, 27, 30, 45, 32, 34, 32, 34, 32, 45, 68, 42, 50, 42, 42, 50, 42, 68, 60, 73, 59, 55, 59, 73, 60, 108, 85, 75, 75, 85, 108, 125, 105, 99, 105, 125, 151, 135, 135, 151, 190, 181, 190, 249, 249, 255, 1, 13, 13, 13, 13, 14, 13, 14, 16, 16, 14, 20, 22, 19, 22, 20, 30, 27, 25, 25, 27, 30, 45, 32, 34, 32, 34, 32, 45, 68, 42, 50, 42, 42, 50, 42, 68, 60, 73, 59, 55, 59, 73, 60, 108, 85, 75, 75, 85, 108, 125, 105, 99, 105, 125, 151, 135, 135, 151, 190, 181, 190, 249, 249, 255, 255, 192, 0, 17, 8, 11, 244, 8, 88, 3, 1, 34, 0, 2, 17, 1, 3, 17, 1, 255, 196, 0, 156, 0, 0, 2, 3, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 5, 3, 6, 7, 16, 0, 2, 2, 1, 4, 1, 3, 3, 2, 4, 5, 5, 0, 0, 1, 13, 0, 1, 2, 3, 17, 4, 18, 33, 49, 5, 19, 65, 81, 34, 50, 97, 20, 113, 6, 35, 66, 82, 21, 51, 129, 145, 161, 36, 52, 98, 114, 177, 67, 83, 37, 53, 115, 22, 68, 99, 193, 8
I/flutter (23336): Directory: '/data/user/0/com.example.flutter_news/app_flutter'
I/flutter (23336): File: '/data/user/0/com.example.flutter_news/app_flutter/92dae9b51087d930a32aff53eaded163.jpg'
I/flutter (23336): File: '/data/user/0/com.example.flutter_news/app_flutter/92dae9b51087d930a32aff53eaded163.jpg'
But my images still not saved in my device.
can you help me ?
You can use package https://pub.dev/packages/network_to_file_image
In demo, it download image and show it, so you can see success or not directly
From official introduction
This is a mixture of FileImage and NetworkImage. It will download the image from the url once, save it locally in the file system, and then use it from there in the future.
full example code
import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:network_to_file_image/network_to_file_image.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
String flutterLogoUrl =
"https://upload.wikimedia.org/wikipedia/commons/1/17/Google-flutter-logo.png";
String flutterLogoFileName = "flutter.png";
void main() async {
runApp(
MaterialApp(
home: Demo(
url: flutterLogoUrl,
file: await file(flutterLogoFileName),
),
),
);
}
Future<File> file(String filename) async {
Directory dir = await getApplicationDocumentsDirectory();
String pathName = p.join(dir.path, filename);
return File(pathName);
}
class Demo extends StatelessWidget {
final String url;
final File file;
const Demo({Key key, this.url, this.file}) : super(key: key);
#override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: const Text('Network to file image example')),
body: Padding(
padding: const EdgeInsets.all(30.0),
child: Image(image: NetworkToFileImage(url: url, file: file, debug: true)),
),
);
}
In demo picture, you can see it print image url and saved file path

flutter: File download from server

I am downloading file from server but I don't know what happened so, kindly tell me how to solve this issue?
await Dio().post("https://test.blockchainhuissieray.com/api/download_file.php", data: {
"jwt" : token,
"fileID" : id,
"directory" : widget.folderName
},
options: Options(
contentType: ContentType.parse("application/json")
)).then((res) => res.data).then((data) async{
var intList = data.toString().codeUnits;
print('File : $intList');
print(data);
var filePath = await ImagePickerSaver.saveFile(fileData: Uint8List.fromList(intList));
print(filePath);
var savedFile = File.fromUri(Uri.file(filePath));
setState(() {
_imageFile = Future<File>.sync(() => savedFile);
images.add(File(data));
imagel = File(data);
});
}).catchError((err){print(err);});
print(images);
setState(() {
showDialog(
context: context,
builder: (context){
return AlertDialog(
content: Center(
child: Image.file(imagel,
fit: BoxFit.cover,),
),
);
}
);
});
I/flutter ( 6918): File : [65533, 65533, 65533, 65533, 2, 118, 69, 120, 105, 102, 0, 0, 77, 77, 0, 42, 0, 0, 0, 8, 0, 8, 1, 16, 0, 2, 0, 0, 0, 26, 0, 0, 0, 110, 1, 0, 0, 4, 0, 0, 0, 1, 0, 0, 3, 65533, 1, 1, 0, 4, 0, 0, 0, 1, 0, 0, 5, 0, 1, 50, 0, 2, 0, 0, 0, 20, 0, 0, 0, 65533, 1, 18, 0, 3, 0, 0, 0, 1, 0, 1, 0, 0, 65533, 105, 0, 4, 0, 0, 0, 1, 0, 0, 0, 65533, 65533, 37, 0, 4, 0, 0, 0, 1, 0, 0, 1, 65533, 1, 15, 0, 2, 0, 0, 0, 7, 0, 0, 0, 65533, 0, 0, 0, 0, 65, 110, 100, 114, 111, 105, 100, 32, 83, 68, 75, 32, 98, 117, 105, 108, 116, 32, 102, 111, 114, 32, 120, 56, 54, 0, 50, 48, 49, 57, 58, 48, 53, 58, 49, 55, 32, 49, 48, 58, 52, 54, 58, 48, 53, 0, 71, 111, 111, 103, 108, 101, 0, 0, 16, 65533, 65533, 0, 5, 0, 0, 0, 1, 0, 0, 1, 105, 65533, 65533, 0, 5, 0, 0, 0, 1, 0, 0, 1, 113, 65533, 65533, 0, 2, 0, 0, 0, 4, 52, 50, 54, 0, 65533, 65533, 0, 2, 0, 0, 0, 4, 52, 50, 54, 0, 65533, 65533, 0, 2, 0, 0, 0, 4, 52, 50, 54, 0, 65533, 10, 0, 5, 0, 0, 0, 1, 0, 0, 1, 121, 65533, 9, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 65533, 39, 0, 3, 0, 0, 0, 1, 0,
I/flutter ( 6918): ����vExif
V/MediaStore( 6918): Create the thumbnail in memory: origId=266, kind=1, isVideo=false
D/skia ( 6918): --- Failed to create image decoder with message 'unimplemented'
I/chatty ( 6918): uid=10087(io.hexasoft.bch) identical 1 line
D/skia ( 6918): --- Failed to create image decoder with message 'unimplemented'
I/flutter ( 6918): saved filePath:
I/flutter ( 6918):
I/flutter ( 6918): [File: '����vExif
You may want to use the path_provider package instead of the ImagePicker plugin. Then write those raw bytes to a file in the temporary directory. Use the file path you generated from there and display the image that way. Or, if you don't need to save the image to the local storage you could display the image with the raw bytearray by using Image.memory instead of Image.file

Receiving Sysex messages with audiokit

I have an app which is sending controller settings to a hardware synthesizer using sysex.
In other words: such a syses messages selects a parameter from the synth, and sets its value.
With audiokit this is pretty simple.
Such a message looks like this:
[240, 00, 32, 51, 1, 16, 112, 00, 40, 95, 247]
Which sets parameter 40 (in parameter group 112) to 95
00, 32, 51, 1 defines the synth model, other the part number and channel.
Now I try to build the opposite: the synth sends its parameters and values to the app.
I do receive such sysex messages in the new versions of audiokit with the receivedMIDISystemCommand(_ data: [MIDIByte]) function.
Example with midi connection over bluetooth (when using Yamaha MD-BT01 ):
[240, 0, 32, 111, 64, 89, 0, 64, 87, 64, 192, 239, 91, 21, 191, 1, 0, 0, 1, 0, 247]
And something different when using wired MIDI to USB (Roland UM-ONE)
Using my wired Roland UM-ONE i receive different messages. they all look like this: [240, 0, 32, 15, 223, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 240, 0, 32, 15, 223, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 247]
most messages contain 21, 17 or 13.
A lot of messages only contain one number, which is 247
The first two messages contain a lot of numbers, maybe about 30, with mostly zero's
The Parameters should have values between 0 and 127 when I send them towards the synthesizer (this are integers in my app, converted to midi bytes just before they are sent: midiByte(127) ).
But the numbers I receive are higher numbers, as shown in the example above.
I think I need to convert these numbers in some way, but how? What type of numbers am I looking at?
Can somebody point me towards some possibilities?

SciPy: create a number sequence generator from constraints

I have been reading Probabilistic Programming and Bayesian Methods for Hackers and I'm hopeful that with PyMC3 I can create a number sequence generator. Here are 34 examples of the kind of number sequences I want to generate:
(20, [0, 0, 0, 4, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
(24, [0, 0, 0, 5, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
(23, [0, 0, 0, 1, 0, 0, 0, 0, 6, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
(21, [0, 0, 0, 4, 5, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
I'm trying to create a number sequence generator that, given the first number in the tuple (like 22), it produces a list of numbers that look like the second:
[0, 0, 0, 6, 1, 0, 0, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1]
I understand the constraints (the sum of the list equals the first number, some positions in the list are always zero, etc.) and I realize that I can create something like this:
import pymc as pm
tau = pm.DiscreteUniform("tau", lower=0, upper=22)
and then do something like this:
tau.random()
But I can't quite get how to construct the constraints and get it to output a list of numbers.
I'm not sure PyMC3 is the right tool here, unless you want to infer something about some hyperparameters -- supposing you store the count data you posted in a 34 x 89 numpy array, then the following suffices:
from scipy.stats import multinomial
import numpy as np
data = np.array([[0, 0, 0, 4, ...], ..., ])
p = data.sum(axis=1) / data.sum()
row_count = 22
number_of_samples = 10
samples = multinomial(row_count, p=p).rvs(number_of_samples)